1046 lines
44 KiB
C#
1046 lines
44 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using ICSharpCode.SharpZipLib.Zip;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||
using Microsoft.AspNetCore.StaticFiles;
|
||
using Mini.Common;
|
||
using Mini.Model.CrmModel;
|
||
using Mini.Model.DTO;
|
||
using Mini.Model.Entity;
|
||
using Mini.Model.Enum;
|
||
using Mini.Model.Map;
|
||
using Mini.Model.ViewModel;
|
||
using Mini.Services.Bas;
|
||
using Mini.Services.ww;
|
||
using Mini.Web.ThreadClass;
|
||
using Mini.Web.WebHelper;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using Microsoft.AspNetCore.Http;
|
||
namespace Mini.Web.Areas.Admin.Controllers
|
||
{
|
||
public class QDOutHHuserController : Controller
|
||
{
|
||
private readonly Iww_QDhhuser_Service _iww_hhuser_service;
|
||
private readonly IBasParameterService _bas_parameter;
|
||
private readonly IBasConfigService _config;
|
||
public QDOutHHuserController(Iww_QDhhuser_Service iww_hhuser_service, IBasParameterService bas_parameter, IBasConfigService config)
|
||
{
|
||
this._iww_hhuser_service = iww_hhuser_service;
|
||
this._bas_parameter = bas_parameter;
|
||
this._config = config;
|
||
}
|
||
#region 企业微信聊天记录
|
||
[Area("Admin")]
|
||
public ActionResult Index(string companycode, string isHg)
|
||
{
|
||
//ToolBar
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = { "Other1", "Other2", "Other3", "Other4", "Other5" };
|
||
tool.AllowButton(toolbtn);
|
||
tool.AddOtherButton("Other1", "聊天记录", "", "", true);
|
||
tool.AddOtherButton("Other2", "外部联系人", "", "", true);
|
||
tool.AddOtherButton("Other3", "查找客户", "", "", true);
|
||
tool.AddOtherButton("Other4", "群管理", "", "", true);
|
||
tool.AddOtherButton("Other5", "备注姓名", "", "", true);
|
||
ViewBag.ToolBar = tool;
|
||
ViewBag.isHg = isHg;
|
||
|
||
//string tableId = "tablist";
|
||
//Table tab = new Table(tableId);
|
||
//tab.AddHeadCol("corpid", "20%", "企业ID");
|
||
//tab.AddHeadCol("corpname", "", "企业号");
|
||
//tab.AddHeadCol("userid", "20%", "ID");
|
||
//tab.AddHeadCol("uname", "", "名称");
|
||
//tab.AddHeadRow();
|
||
//ViewBag.gridTable = tab.GetHead(); //+ Pagination.GetPage(pager, tableId, "5,10,15,20");
|
||
|
||
List<Ww_Corp> list = _iww_hhuser_service.Corp_Get();
|
||
if (!string.IsNullOrEmpty(companycode))
|
||
{
|
||
string companycodeFormat = string.Format("[{0}]", companycode);
|
||
list = list.Where(m => m.companycode.Contains(companycodeFormat)).ToList();
|
||
}
|
||
List<SelectListItem> selectlist = new List<SelectListItem>();
|
||
if (string.IsNullOrEmpty(companycode))//公司为空才能请选择
|
||
{
|
||
selectlist.Add(new SelectListItem() { Value = "", Text = "请选择" });
|
||
}
|
||
List<object> datalist = new List<object>();
|
||
if (list.Count > 0)
|
||
{
|
||
foreach (Ww_Corp item in list)
|
||
{
|
||
|
||
selectlist.Add(new SelectListItem() { Text = item.corpname, Value = item.corpid });
|
||
if (!string.IsNullOrEmpty(companycode))
|
||
{
|
||
if (!string.IsNullOrEmpty(item.deptid))
|
||
{
|
||
JObject obj = (JObject)Newtonsoft.Json.Linq.JObject.Parse(item.deptid);
|
||
datalist.Add(new { corpid = item.corpid, deptid = obj[companycode].ToString() });
|
||
}
|
||
else
|
||
{
|
||
datalist.Add(new { corpid = item.corpid, deptid = "" });
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
selectlist.Add(new SelectListItem() { Value = "-1", Text = "无数据" });
|
||
}
|
||
ViewBag.Select = selectlist;
|
||
ViewBag.companycode = companycode;
|
||
ViewBag.DataList = JsonConvert.SerializeObject(datalist);
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult GetWeWorktHtmlList(Laypage pager, string name, string corp, string deptid, string columns)
|
||
{
|
||
var layUidata = new LayuiData<Ww_hhuserModel>();
|
||
try
|
||
{
|
||
|
||
List<Ww_hhuserModel> list = _iww_hhuser_service.WorList_Get(ref pager, name, corp, deptid);
|
||
layUidata.msg = "数据加载成功";
|
||
layUidata.code = 0;
|
||
layUidata.data = list;
|
||
layUidata.count = pager.count;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
||
}
|
||
return Json(layUidata);
|
||
//List<Ww_hhuserModel> list = _iww_hhuser_service.WorList_Get(name, corp);
|
||
//Table table = new Table(columns, true);
|
||
//DateTime nowtime = DateTime.Now;
|
||
//foreach (var item in list)
|
||
//{
|
||
// table.AddCol(item.corpid);
|
||
// table.AddCol(item.corpname);
|
||
// table.AddCol(item.userid);
|
||
// table.AddCol(item.uname);
|
||
// table.AddRow();
|
||
//}
|
||
//var json = new
|
||
//{
|
||
// rowsList = table.GetRows()
|
||
//};
|
||
//return Json(json, new JsonSerializerSettings() { DateFormatString = "yyyy-MM-dd HH:mm:ss" });
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region 企业微通话记录
|
||
[Area("Admin")]
|
||
public ActionResult Record(string companycode)
|
||
{
|
||
//ToolBar
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = { };
|
||
tool.AllowButton(toolbtn);
|
||
ViewBag.ToolBar = tool;
|
||
|
||
List<Ww_Corp> list = _iww_hhuser_service.Corp_Get();
|
||
if (!string.IsNullOrEmpty(companycode))
|
||
{
|
||
string companycodeFormat = string.Format("[{0}]", companycode);
|
||
list = list.Where(m => m.companycode.Contains(companycodeFormat)).ToList();
|
||
}
|
||
List<SelectListItem> selectlist = new List<SelectListItem>();
|
||
if (string.IsNullOrEmpty(companycode))//公司为空才能请选择
|
||
{
|
||
selectlist.Add(new SelectListItem() { Value = "", Text = "请选择" });
|
||
}
|
||
foreach (Ww_Corp item in list)
|
||
{
|
||
selectlist.Add(new SelectListItem() { Text = item.corpname, Value = item.corpid });
|
||
}
|
||
ViewBag.Select = selectlist;
|
||
ViewBag.companycode = companycode;
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult GetRecordHtmlList(Laypage pager, string corpid, DateTime? stime, DateTime? etime, string customername, string kefuname, string companycode)
|
||
{
|
||
|
||
var layUidata = new LayuiData<Ww_RecordModel>();
|
||
try
|
||
{
|
||
List<Ww_RecordModel> list = _iww_hhuser_service.RecordList_Get(ref pager, corpid, stime, etime, customername, kefuname, companycode);
|
||
foreach (Ww_RecordModel item in list)
|
||
{
|
||
item.customername = ManagerPhoneHelper.FormatPhoneUserName(item.customername);
|
||
}
|
||
layUidata.msg = "数据加载成功";
|
||
layUidata.code = 0;
|
||
layUidata.data = list;
|
||
layUidata.count = pager.count;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
||
}
|
||
return Json(layUidata);
|
||
}
|
||
#endregion
|
||
|
||
#region 企业微信群
|
||
[Area("Admin")]
|
||
public ActionResult Group(string corp)
|
||
{
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = { "Other1", "Other2" };
|
||
tool.AllowButton(toolbtn);
|
||
tool.AddOtherButton("Other1", "设置群名称", "", "", true);
|
||
tool.AddOtherButton("Other2", "聊天记录", "", "", true);
|
||
ViewBag.ToolBar = tool;
|
||
ViewBag.corp = corp;
|
||
return View();
|
||
}
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult GetGroupList(Laypage pager, string corp, string name)
|
||
{
|
||
|
||
var layUidata = new LayuiData<Ww_MsgRoom>();
|
||
|
||
string ss = pager?.order;
|
||
try
|
||
{
|
||
name = name != null ? name.Trim() : name;
|
||
List<Ww_MsgRoom> list = _iww_hhuser_service.GetRoom(ref pager, corp, name);
|
||
layUidata.msg = "数据加载成功";
|
||
layUidata.code = 0;
|
||
layUidata.count = pager.count;
|
||
layUidata.data = list;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
||
}
|
||
return Json(layUidata);
|
||
}
|
||
|
||
[HttpGet]
|
||
[Area("Admin")]
|
||
public ActionResult RoomEdit(string corp, string roomid, string type)
|
||
{
|
||
Ww_MsgRoom model = new Ww_MsgRoom();
|
||
if (string.IsNullOrEmpty(roomid) || string.IsNullOrEmpty(corp))
|
||
{
|
||
ViewBag.isOK = "0";
|
||
ViewBag.Msg = "参数不对!";
|
||
}
|
||
else
|
||
{
|
||
model = _iww_hhuser_service.GetRoom(corp, roomid);
|
||
model.corp = corp;
|
||
}
|
||
ViewBag.type = type;
|
||
return View(model);
|
||
}
|
||
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult RoomEditSave(Ww_MsgRoom model)
|
||
{
|
||
bool result = _iww_hhuser_service.UpdateRomeName(model.corp, model.roomid, model.roomname);
|
||
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "设置成功!" };
|
||
if (!result)
|
||
{
|
||
ret.retmsg = "设置失败!";
|
||
}
|
||
return Json(ret);
|
||
}
|
||
|
||
[Area("Admin")]
|
||
public ActionResult GroupRoom(string type, string roomid, string corp, string weixincrmaccount, string isHg)
|
||
{
|
||
Ww_MsgRoom model = new Ww_MsgRoom()
|
||
{
|
||
corp = corp,
|
||
roomid = roomid,
|
||
userlist = ""
|
||
};
|
||
string isOldLevel = _config.GetConfig(BasConfigEnums.IsOutAndInnerGroupLevel);//获取配置信息
|
||
if (isOldLevel == "0")//老版本
|
||
{
|
||
model = _iww_hhuser_service.GetRoom(corp, roomid);
|
||
}
|
||
else
|
||
{//新版本
|
||
if (type == "inner")
|
||
{
|
||
Ww_RoomChat cha = _iww_hhuser_service.GetRoomChat(corp, roomid);//内部群
|
||
model.ctime = cha.ctime;
|
||
model.membernum = cha.membernum;
|
||
model.ctimestr = cha.ctime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||
if (!string.IsNullOrEmpty(cha.members))
|
||
{
|
||
List<Ww_Roomchat_Member> member = JsonConvert.DeserializeObject<List<Ww_Roomchat_Member>>(cha.members);
|
||
model.userlist = string.Join(",", member.Select(m => m.memberid));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Ww_GroupChat cha = _iww_hhuser_service.GetWw_GroupChat(corp, roomid);//外部群
|
||
if (cha == null)//如果type为空,找不到外部群,就去内部群查找
|
||
{
|
||
Ww_RoomChat cha2 = _iww_hhuser_service.GetRoomChat(corp, roomid);//内部群
|
||
if (cha2 != null)
|
||
{
|
||
model.ctime = cha2.ctime;
|
||
model.membernum = cha2.membernum;
|
||
model.ctimestr = cha2.ctime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||
if (!string.IsNullOrEmpty(cha2.members))
|
||
{
|
||
List<Ww_Roomchat_Member> member = JsonConvert.DeserializeObject<List<Ww_Roomchat_Member>>(cha2.members);
|
||
model.userlist = string.Join(",", member.Select(m => m.memberid));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
model = _iww_hhuser_service.GetRoom(corp, roomid);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
model.ctime = cha.ctime;
|
||
model.membernum = cha.membernum;
|
||
model.ctimestr = cha.ctime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||
if (!string.IsNullOrEmpty(cha.member_list))
|
||
{
|
||
List<Ww_Groupchat_Member> member = JsonConvert.DeserializeObject<List<Ww_Groupchat_Member>>(cha.member_list);
|
||
model.userlist = string.Join(",", member.Select(m => m.userid));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
ViewBag.isHg = isHg;
|
||
ViewBag.corp = corp;
|
||
ViewBag.roomid = roomid;
|
||
ViewBag.roomInfo = model;
|
||
List<GroupUser> info = _iww_hhuser_service.GetGroupUser(corp, model);
|
||
ViewBag.groupuser = info;
|
||
ViewBag.type = type;
|
||
ViewBag.weixincrmaccount = weixincrmaccount;
|
||
return View();
|
||
}
|
||
|
||
#endregion
|
||
|
||
[Area("Admin")]
|
||
public ActionResult Choose(string companycode)
|
||
{
|
||
ViewBag.companycode = companycode;
|
||
return View();
|
||
}
|
||
[Area("Admin")]
|
||
public ActionResult Find(string companycode)
|
||
{
|
||
ViewBag.companycode = companycode;
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult GetFindHtmlList(Laypage pager, string name,string myphone, string companycode, string columns)
|
||
{
|
||
var layUidata = new LayuiData<Ww_FindUserShow>() { code = 0, msg = "数据加载成功" };
|
||
try
|
||
{
|
||
List<Ww_FindUserShow> showlist = new List<Ww_FindUserShow>();
|
||
if (string.IsNullOrWhiteSpace(name))
|
||
{
|
||
layUidata.msg = "请输入查询条件!";
|
||
layUidata.code = 1;
|
||
}
|
||
else
|
||
{
|
||
name = name.Trim();
|
||
List<Ww_FindUser_Model> list = _iww_hhuser_service.Find_User(ref pager, name, myphone, companycode);
|
||
|
||
if (list.Count > 0)
|
||
{
|
||
foreach (var model in list)
|
||
{
|
||
Ww_FindUserShow show = new Ww_FindUserShow();
|
||
show.corpid = model.corpid;
|
||
show.corpname = model.corpname;
|
||
show.userid = model.userid;
|
||
show.uname = model.uname;
|
||
show.name = ManagerPhoneHelper.FormatPhoneUserName(model.name);
|
||
show.extuserid = model.extuserid;
|
||
show.avatar = model.avatar;
|
||
string exinfo = model.exinfo;
|
||
if (!string.IsNullOrEmpty(exinfo) && exinfo.Trim() != "-")
|
||
{
|
||
ww_exinfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<ww_exinfo>(exinfo);
|
||
follow follow = info.follow_user.FirstOrDefault(m => m.userid == model.userid);
|
||
if (follow != null)
|
||
{
|
||
show.remark = ManagerPhoneHelper.FormatPhoneUserName(follow.remark);
|
||
show.createtime = Utility.ToUnityString(DateTimeTool.GetTimeFromLinuxShortTime(follow.createtime.Value), 2);
|
||
show.remark_mobiles = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", follow.remark_mobiles));
|
||
}
|
||
else
|
||
{
|
||
//show.remark_mobiles = ManagerPhoneHelper.FormatPhoneUserName(Utility.ToUnityString(model.ctime, 2));
|
||
|
||
}
|
||
}
|
||
showlist.Add(show);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
layUidata.msg = "无数据!";
|
||
layUidata.code = 1;
|
||
}
|
||
}
|
||
layUidata.data = showlist;
|
||
layUidata.count = pager.count;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
||
}
|
||
return Json(layUidata);
|
||
}
|
||
|
||
|
||
[Area("Admin")]
|
||
public ActionResult Outer(string userid, string corp)
|
||
{
|
||
ViewBag.userid = userid;
|
||
ViewBag.corp = corp;
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult GetOuterHtmlList(string userid, string corp, string columns)
|
||
{
|
||
var layUidata = new LayuiData<Ww_exinfoShow>();
|
||
try
|
||
{
|
||
List<Ww_User_ExtuserModel> list = _iww_hhuser_service.Extuser_Get(userid, corp);
|
||
DateTime nowtime = DateTime.Now;
|
||
List<ww_exinfo> infolist = new List<ww_exinfo>();
|
||
foreach (Ww_User_ExtuserModel model in list)
|
||
{
|
||
string exinfo = model.exinfo;
|
||
if (!string.IsNullOrEmpty(exinfo) && exinfo.Trim() != "-")
|
||
{
|
||
ww_exinfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<ww_exinfo>(exinfo);
|
||
follow follow = info.follow_user.FirstOrDefault(m => m.userid == userid);
|
||
if (follow != null)
|
||
{
|
||
info.self = follow;
|
||
info.follow_user = null;
|
||
infolist.Add(info);
|
||
}
|
||
else
|
||
{
|
||
info.self = new follow() { createtime = null, remark = "" };
|
||
info.follow_user = null;
|
||
info.external_contact = new external() { external_userid = model.userid, name = model.cname };
|
||
infolist.Add(info);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ww_exinfo info = new ww_exinfo();
|
||
info.self = new follow() { createtime = null, remark = "" };
|
||
info.follow_user = null;
|
||
info.external_contact = new external() { external_userid = model.userid, name = model.cname };
|
||
infolist.Add(info);
|
||
}
|
||
}
|
||
infolist = infolist.OrderByDescending(m => m.self.createtime).ToList();
|
||
List<Ww_exinfoShow> showList = new List<Ww_exinfoShow>();
|
||
foreach (ww_exinfo model in infolist)
|
||
{
|
||
Ww_exinfoShow show = new Ww_exinfoShow();
|
||
show.external_userid = model.external_contact.external_userid;
|
||
show.name = ManagerPhoneHelper.FormatPhoneUserName(model.external_contact.name);
|
||
if (model.self != null)
|
||
{
|
||
show.remark = ManagerPhoneHelper.FormatPhoneUserName(model.self.remark);
|
||
if (model.self.createtime != null)
|
||
show.createtime = Utility.ToUnityString(DateTimeTool.GetTimeFromLinuxShortTime(model.self.createtime.Value), 2);
|
||
show.remark_mobiles = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", model.self.remark_mobiles));
|
||
}
|
||
showList.Add(show);
|
||
}
|
||
layUidata.msg = "数据加载成功";
|
||
layUidata.code = 0;
|
||
layUidata.data = showList;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
||
}
|
||
return Json(layUidata);
|
||
}
|
||
|
||
|
||
[Area("Admin")]
|
||
public ActionResult Message(string userid, string uname, string corp, string isHg)
|
||
{
|
||
ViewBag.userid = userid;
|
||
ViewBag.uname = uname ?? "";
|
||
ViewBag.corp = corp;
|
||
ViewBag.isHg = isHg;
|
||
List<Ww_User_ExtuserModel> list = _iww_hhuser_service.Extuser_Get(userid, corp);
|
||
List<Ww_User_ExtuserShow> showList = new List<Ww_User_ExtuserShow>();
|
||
//将外部联系人数据解析500
|
||
foreach (Ww_User_ExtuserModel model in list)
|
||
{
|
||
Ww_User_ExtuserShow showmodel = new Ww_User_ExtuserShow()
|
||
{
|
||
avatar = model.avatar,//头像
|
||
external_userid = model.userid,//外部联系人ID
|
||
lmsgtime = model.lmsgtime,//最后聊天时间
|
||
name = ManagerPhoneHelper.FormatPhoneUserName(model.cname),//姓名
|
||
corpid = model.corpid
|
||
};
|
||
string exinfo = model.exinfo;
|
||
if (!string.IsNullOrEmpty(exinfo) && exinfo.Trim() != "-")
|
||
{
|
||
ww_exinfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<ww_exinfo>(exinfo);
|
||
follow follow = info.follow_user.FirstOrDefault(m => m.userid == userid);
|
||
if (follow != null)
|
||
{
|
||
info.self = follow;
|
||
info.follow_user = null;
|
||
|
||
showmodel.remark = ManagerPhoneHelper.FormatPhoneUserName(follow.remark);
|
||
if (follow.createtime != null)
|
||
showmodel.createtime = Utility.ToUnityString(DateTimeTool.GetTimeFromLinuxShortTime(follow.createtime.Value), 2);
|
||
showmodel.remark_mobiles = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", follow.remark_mobiles));
|
||
|
||
}
|
||
}
|
||
showList.Add(showmodel);
|
||
}
|
||
|
||
ViewBag.rcontact = list;
|
||
ViewBag.showlist = showList;
|
||
ViewBag.inneruser = _iww_hhuser_service.InnerUser_Get(userid, corp);
|
||
List<Ww_MsgRoom> roomeCList = new List<Ww_MsgRoom>();
|
||
string roomErro = "";
|
||
try
|
||
{
|
||
roomeCList = GetRoomList(userid, corp);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
roomErro = e.ToString();
|
||
LogHelper.Error("错误:" + e.ToString());
|
||
}
|
||
ViewBag.roomList = roomeCList;
|
||
ViewBag.roomErro = roomErro;
|
||
|
||
return View();
|
||
}
|
||
private List<Ww_MsgRoom> GetRoomList(string userid, string corp)
|
||
{
|
||
List<Ww_MsgRoom> roomeCList = new List<Ww_MsgRoom>();
|
||
string wocha = RequestGet(Mini.Common.Utility.GetSettingByKey("InnerFile") + "userroom?user=" + userid + "&corpid=" + corp);
|
||
Ww_room info = Common.JsonHelper.JsonDivertToObj<Ww_room>(wocha);
|
||
string roomeCListStr = info == null ? "" : info.roomlist;
|
||
if (!string.IsNullOrEmpty(roomeCListStr))
|
||
{
|
||
string items = "";
|
||
foreach (var item in roomeCListStr.Split(','))
|
||
{
|
||
if (!string.IsNullOrEmpty(item))
|
||
{
|
||
items += "[" + item + "]";
|
||
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(items))
|
||
{
|
||
items = items.Replace("][", "','").Replace("[", "'").Replace("]", "'");
|
||
roomeCList = _iww_hhuser_service.GetRoomList(corp, items);
|
||
}
|
||
}
|
||
return roomeCList;
|
||
}
|
||
|
||
[Area("Admin")]
|
||
public ActionResult GetPath(string url)
|
||
{
|
||
string wocha = RequestGet(url);
|
||
return Content(wocha);
|
||
}
|
||
|
||
public static string RequestGet(string url)
|
||
{
|
||
string lasjosn = "";
|
||
if (url.IndexOf("userjson?") > -1 || url.IndexOf("roomjson?") > -1 || url.IndexOf("recordjson?") > -1)
|
||
{
|
||
List<string> wocha = new List<string>();
|
||
List<object> jsonlist = new List<object>();
|
||
try
|
||
{
|
||
wocha = Utility.GetArryData(url, "", Encoding.UTF8);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error("错误:" + url + "**" + e.ToString());
|
||
}
|
||
|
||
foreach (var item in wocha)
|
||
{
|
||
if (string.IsNullOrEmpty(item))
|
||
continue;
|
||
try
|
||
{
|
||
//LogHelper.Error("--json--");
|
||
//LogHelper.Error(item);
|
||
//LogHelper.Error("--json-end--");
|
||
var obj = Common.JsonHelper.JsonDivertToObj<object>(item);
|
||
jsonlist.Add(obj);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
//LogHelper.Error(e.ToString());
|
||
}
|
||
}
|
||
lasjosn = Common.JsonHelper.ObjDivertToJson(jsonlist);
|
||
}
|
||
else if (url.IndexOf("userroom?") > -1)//群信息获取 不做处理
|
||
{
|
||
string wocha = "";
|
||
try
|
||
{
|
||
wocha = Utility.GetData(url, "", Encoding.UTF8);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error("错误:" + url + "**" + e.ToString());
|
||
}
|
||
if (string.IsNullOrEmpty(wocha))
|
||
wocha = "{}";
|
||
lasjosn = wocha;
|
||
}
|
||
return lasjosn;
|
||
|
||
}
|
||
[Area("Admin")]
|
||
public ActionResult User_extuserList(string exuserid, string isHg, string showstyle)
|
||
{
|
||
List<Wx_ExuserModel> list = new List<Wx_ExuserModel>();
|
||
try
|
||
{
|
||
if (!string.IsNullOrEmpty(exuserid))
|
||
{
|
||
list = _iww_hhuser_service.Extuser_GetAllUser(exuserid);
|
||
foreach (var item in list)
|
||
{
|
||
item.name = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", item.name));
|
||
}
|
||
}
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e.ToString());
|
||
}
|
||
List<Ww_MsgRoom> roomeCList = new List<Ww_MsgRoom>();
|
||
try
|
||
{
|
||
string notShowGroup = _bas_parameter.GetParameterValue(ParameterEnums.NotShowGroupCorp);
|
||
List<RoomParam> roomlist = list.GroupBy(m => new { m.corpid, m.extuserid }).Select(m => new RoomParam { corpid = m.Key.corpid, extuserid = m.Key.extuserid }).ToList();
|
||
foreach (RoomParam item in roomlist)
|
||
{
|
||
if (notShowGroup.IndexOf($"[{item.corpid}]") > -1)
|
||
{
|
||
continue;
|
||
}
|
||
List<Ww_MsgRoom> roomeCList2 = new List<Ww_MsgRoom>(); //_iww_hhuser_service.GetRoomListByChengYuan(item.corpid, item.extuserid);
|
||
foreach (Ww_MsgRoom ww in roomeCList2)
|
||
{
|
||
|
||
if (roomeCList.Where(m => m.roomid == ww.roomid).Count() == 0)
|
||
{
|
||
Ww_MsgRoom room = new Ww_MsgRoom
|
||
{
|
||
corp = ww.corp,
|
||
roomid = ww.roomid,
|
||
ctime = ww.ctime,
|
||
ctimestr = ww.ctimestr,
|
||
roomname = ww.roomname,
|
||
userlist = ww.userlist
|
||
};
|
||
room.ctimestr = room.ctime.HasValue ? room.ctime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||
roomeCList.Add(room);
|
||
}
|
||
}
|
||
}
|
||
roomeCList = roomeCList.OrderByDescending(m => m.ctime).ToList();
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error("错误:" + e.ToString());
|
||
}
|
||
|
||
ViewBag.data = Common.JsonHelper.ObjDivertToJson(list);
|
||
ViewBag.roomData = Common.JsonHelper.ObjDivertToJson(roomeCList);//群的列表
|
||
ViewBag.isHg = isHg;
|
||
return View();
|
||
}
|
||
|
||
[Area("Admin")]
|
||
public ActionResult OneMessage(string corpid, string name, string extuserid, string uname, string userid)
|
||
{
|
||
|
||
ViewBag.corpid = corpid;
|
||
ViewBag.name = name;
|
||
ViewBag.extuserid = extuserid;
|
||
ViewBag.uname = uname;
|
||
ViewBag.userid = userid;
|
||
return View();
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="userid">客服ID</param>
|
||
/// <param name="uname">客服名称</param>
|
||
/// <param name="corp">公司ID</param>
|
||
/// <param name="customer">客户ID</param>
|
||
/// <param name="nickname">客户名称</param>
|
||
/// <param name="locationJson">定位的json信息</param>
|
||
/// <returns></returns>
|
||
[Area("Admin")]
|
||
public ActionResult MessageDetial(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson)
|
||
{
|
||
string[] ROLES = { "NONW" };
|
||
ViewBag.IsHiddenEWM = MangerEWM.GetIsHiddenEWM(ROLES);
|
||
ViewBag.userid = userid;
|
||
ViewBag.uname = uname;
|
||
ViewBag.corp = corp;
|
||
ViewBag.customer = customer;
|
||
ViewBag.nickname = nickname;
|
||
ViewBag.isgroup = isgroup;
|
||
ViewBag.locationJson = string.IsNullOrEmpty(locationJson) ? "{\"NeedLocaltion\":0}" : locationJson;
|
||
|
||
bool IsCanLoadKeyWords = false;
|
||
if (isHg != null && isHg == "True")
|
||
{
|
||
IsCanLoadKeyWords = true;
|
||
}
|
||
ViewBag.IsCanLoadKeyWords = IsCanLoadKeyWords;
|
||
if (IsCanLoadKeyWords)
|
||
ViewBag.KeyWrods = _bas_parameter.GetParameterValue(ParameterEnums.WeiXin_IllegalKewords);
|
||
else
|
||
ViewBag.KeyWrods = "";
|
||
|
||
ViewBag.ShowSaleLine = _bas_parameter.GetParameterValue(ParameterEnums.ShowSaleLine);
|
||
ViewBag.SaleLineHttp = _bas_parameter.GetParameterValue(ParameterEnums.SaleLineHttp);
|
||
List<Wx_ExuserModel> list = new List<Wx_ExuserModel>();
|
||
string zhi = _bas_parameter.GetParameterValue(ParameterEnums.ShowOtherSaleLT);
|
||
if (!string.IsNullOrEmpty(customer) && zhi == "true")
|
||
list = _iww_hhuser_service.Extuser_GetAllUser(customer);//外部联系人
|
||
ViewBag.OtherKeFu = list.Where(m => m.userid != userid).ToList();//其他客服,排除掉当前客服
|
||
|
||
string folderName = string.Format("temp_{0}_{1}_{2}", corp, userid, customer);
|
||
string groupname = "";
|
||
if (isgroup == "true")
|
||
{
|
||
Ww_MsgRoom model = _iww_hhuser_service.GetRoom(corp, customer);
|
||
ViewBag.roomInfo = model;
|
||
ViewBag.nickname = string.IsNullOrEmpty(model.roomname) ? "群:" + model.roomid : "群:" + model.roomname;
|
||
groupname = ViewBag.nickname;
|
||
|
||
List<GroupUser> info = _iww_hhuser_service.GetGroupUser(corp, model);
|
||
ViewBag.groupuser = Common.JsonHelper.ObjDivertToJson(info);
|
||
}
|
||
else
|
||
{
|
||
ViewBag.groupuser = "[]";
|
||
}
|
||
if (MessagePack.GenerateDownFile.ContainsKey(folderName))
|
||
{
|
||
ViewBag.IsPackNow = 1;//是不是正在下载
|
||
}
|
||
else
|
||
{
|
||
ViewBag.IsPackNow = 0;
|
||
var webPath = FileUnit.GetBaseDirectory();//站点目录
|
||
var tmpPath = Path.Combine(webPath, "temp");//临时文件目录
|
||
string zipPath = Path.Combine(tmpPath, folderName + ".zip");
|
||
ViewBag.folderName = folderName;
|
||
FileInfo info = new FileInfo(zipPath);
|
||
ViewBag.zipPathName = string.Format("{0} 与 {1} 的聊天记录", uname, nickname);
|
||
if (isgroup == "true")
|
||
{
|
||
ViewBag.zipPathName = string.Format("{0}的聊天记录", groupname);
|
||
}
|
||
if (info.Exists)
|
||
{
|
||
string name = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + ".zip";//获取最后修改时间
|
||
ViewBag.NowPathName = string.Format("{0} 与 {1} 的聊天记录{2}", uname, nickname, name);
|
||
if (isgroup == "true")
|
||
{
|
||
ViewBag.NowPathName = string.Format("{0}的聊天记录{1}", groupname, name);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ViewBag.NowPathName = "";
|
||
}
|
||
}
|
||
return View();
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="userid">客服ID</param>
|
||
/// <param name="uname">客服名称</param>
|
||
/// <param name="corp">公司ID</param>
|
||
/// <param name="customer">客户ID</param>
|
||
/// <param name="nickname">客户名称</param>
|
||
/// <param name="locationJson">定位的json信息</param>
|
||
/// <returns></returns>
|
||
[Area("Admin")]
|
||
public ActionResult MessageDetial10(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson)
|
||
{
|
||
string[] ROLES = { "NONW" };
|
||
ViewBag.IsHiddenEWM = MangerEWM.GetIsHiddenEWM(ROLES);
|
||
ViewBag.userid = userid;
|
||
ViewBag.uname = uname;
|
||
ViewBag.corp = corp;
|
||
ViewBag.customer = customer;
|
||
ViewBag.nickname = nickname;
|
||
ViewBag.isgroup = isgroup;
|
||
ViewBag.locationJson = string.IsNullOrEmpty(locationJson) ? "{\"NeedLocaltion\":0}" : locationJson;
|
||
|
||
bool IsCanLoadKeyWords = false;
|
||
if (isHg != null && isHg == "True")
|
||
{
|
||
IsCanLoadKeyWords = true;
|
||
}
|
||
ViewBag.IsCanLoadKeyWords = IsCanLoadKeyWords;
|
||
if (IsCanLoadKeyWords)
|
||
ViewBag.KeyWrods = _bas_parameter.GetParameterValue(ParameterEnums.WeiXin_IllegalKewords);
|
||
else
|
||
ViewBag.KeyWrods = "";
|
||
|
||
ViewBag.ShowSaleLine = _bas_parameter.GetParameterValue(ParameterEnums.ShowSaleLine);
|
||
ViewBag.SaleLineHttp = _bas_parameter.GetParameterValue(ParameterEnums.SaleLineHttp);
|
||
List<Wx_ExuserModel> list = new List<Wx_ExuserModel>();
|
||
string zhi = _bas_parameter.GetParameterValue(ParameterEnums.ShowOtherSaleLT);
|
||
if (!string.IsNullOrEmpty(customer) && zhi == "true")
|
||
list = _iww_hhuser_service.Extuser_GetAllUser(customer);//外部联系人
|
||
ViewBag.OtherKeFu = list.Where(m => m.userid != userid).ToList();//其他客服,排除掉当前客服
|
||
|
||
string folderName = string.Format("temp_{0}_{1}_{2}", corp, userid, customer);
|
||
string groupname = "";
|
||
if (isgroup == "true")
|
||
{
|
||
Ww_MsgRoom model = _iww_hhuser_service.GetRoom(corp, customer);
|
||
ViewBag.roomInfo = model;
|
||
ViewBag.nickname = string.IsNullOrEmpty(model.roomname) ? "群:" + model.roomid : "群:" + model.roomname;
|
||
groupname = ViewBag.nickname;
|
||
|
||
List<GroupUser> info = _iww_hhuser_service.GetGroupUser(corp, model);
|
||
ViewBag.groupuser = Common.JsonHelper.ObjDivertToJson(info);
|
||
}
|
||
else
|
||
{
|
||
ViewBag.groupuser = "[]";
|
||
}
|
||
if (MessagePack.GenerateDownFile.ContainsKey(folderName))
|
||
{
|
||
ViewBag.IsPackNow = 1;//是不是正在下载
|
||
}
|
||
else
|
||
{
|
||
ViewBag.IsPackNow = 0;
|
||
var webPath = FileUnit.GetBaseDirectory();//站点目录
|
||
var tmpPath = Path.Combine(webPath, "temp");//临时文件目录
|
||
string zipPath = Path.Combine(tmpPath, folderName + ".zip");
|
||
ViewBag.folderName = folderName;
|
||
FileInfo info = new FileInfo(zipPath);
|
||
ViewBag.zipPathName = string.Format("{0} 与 {1} 的聊天记录", uname, nickname);
|
||
if (isgroup == "true")
|
||
{
|
||
ViewBag.zipPathName = string.Format("{0}的聊天记录", groupname);
|
||
}
|
||
if (info.Exists)
|
||
{
|
||
string name = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + ".zip";//获取最后修改时间
|
||
ViewBag.NowPathName = string.Format("{0} 与 {1} 的聊天记录{2}", uname, nickname, name);
|
||
if (isgroup == "true")
|
||
{
|
||
ViewBag.NowPathName = string.Format("{0}的聊天记录{1}", groupname, name);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ViewBag.NowPathName = "";
|
||
}
|
||
}
|
||
return View();
|
||
|
||
}
|
||
|
||
|
||
[Area("Admin")]
|
||
[HttpGet]
|
||
public ActionResult GetNoEWMImgePath(string url)
|
||
{
|
||
string newurl = url.Replace("mediafile", "mediafilepath");
|
||
MediaResult meresult = MangerEWM.GetNoQcodeImg(url);
|
||
if (meresult.code != 2)
|
||
{
|
||
FileInfo fileInfo = new FileInfo(meresult.local);
|
||
var ext = fileInfo.Extension;
|
||
new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext, out var contenttype);
|
||
return new FileContentResult(System.IO.File.ReadAllBytes(meresult.local), contenttype ?? "application/octet-stream");
|
||
}
|
||
else
|
||
{
|
||
var webPath = FileUnit.GetBaseDirectory();//站点目录
|
||
var cantlookimg = Path.Combine(webPath, "wwwroot", "Content", "Images", "cantlook.jpg");//临时文件目录
|
||
var ext = ".jpg";
|
||
new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext, out var contenttype);
|
||
return new FileContentResult(System.IO.File.ReadAllBytes(cantlookimg), contenttype ?? "application/octet-stream");
|
||
}
|
||
}
|
||
|
||
[Area("Admin")]
|
||
[HttpPost]
|
||
public JsonResult Export(string isgroup, string userid, string uname, string corp, string cs_nickname, string cs_username, string IsHiddenEWM)
|
||
{
|
||
string[] ROLES = { "NONW" };
|
||
string IsHiddenEWMSTR = !string.IsNullOrEmpty(IsHiddenEWM) ? IsHiddenEWM : MangerEWM.GetIsHiddenEWM(ROLES);
|
||
string folderName = string.Format("temp_{0}_{1}_{2}", corp, userid, cs_username);
|
||
if (MessagePack.GenerateDownFile.ContainsKey(folderName))
|
||
return Json(new retMsg() { result = false, retcode = 500, retmsg = "服务器已在快马加鞭打包聊天记录了,请稍后刷新下载!" });
|
||
MessagePack.GenerateDownFile.Add(folderName, "");
|
||
|
||
MessagePack pack = new MessagePack() { corp = corp, cs_nickname = cs_nickname, cs_username = cs_username, folderName = folderName, isgroup = isgroup, uname = uname, userid = userid, selfurl = _config.GetConfig(BasConfigEnums.SelfUrl), IsHiddenEWM = IsHiddenEWMSTR };
|
||
pack.groupuser = "[]";
|
||
if (isgroup == "true")
|
||
{
|
||
Ww_MsgRoom model = _iww_hhuser_service.GetRoom(corp, cs_username);
|
||
pack.cs_nickname = string.IsNullOrEmpty(model.roomname) ? "群:" + model.roomid : "群:" + model.roomname;
|
||
List<GroupUser> info = _iww_hhuser_service.GetGroupUser(corp, model);
|
||
pack.groupuser = Common.JsonHelper.ObjDivertToJson(info);
|
||
}
|
||
Thread th = new Thread(pack.GenerateZip);
|
||
th.Start();
|
||
return Json(new retMsg() { result = true, retcode = 200, retmsg = "服务器正在努力打包,稍后下载。" });
|
||
//return File(new FileStream(zipPath, FileMode.Open), "application/x-zip-compressed", zipName + ".zip");
|
||
}
|
||
|
||
[Area("Admin")]
|
||
public FileResult DownLoad(string folderName, string zipname)
|
||
{
|
||
try
|
||
{
|
||
//byte[] outputb = Convert.FromBase64String(zipname);
|
||
//var sszipname = Encoding.Default.GetString(outputb);
|
||
LogHelper.Error("下载文件:"+zipname);
|
||
var webPath = FileUnit.GetBaseDirectory();//站点目录
|
||
var tmpPath = Path.Combine(webPath, "temp");//临时文件目录
|
||
string zipPath = Path.Combine(tmpPath, folderName + ".zip");
|
||
return File(new FileStream(zipPath, FileMode.Open), "application/x-zip-compressed", zipname);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e.ToString());
|
||
throw e;
|
||
}
|
||
}
|
||
[Area("Admin")]
|
||
[HttpPost]
|
||
public JsonResult RefreshPackStatus(string folderName, string holpName)
|
||
{
|
||
if (string.IsNullOrEmpty(folderName))
|
||
{
|
||
return Json(new retMsg() { result = false, retcode = 500, retmsg = "参数错误!" });
|
||
}
|
||
if (MessagePack.GenerateDownFile.ContainsKey(folderName))
|
||
return Json(new retMsg() { result = false, retcode = 500, retmsg = "服务器已在快马加鞭打包聊天记录了,请稍后刷新下载!" });
|
||
else
|
||
{
|
||
var webPath = FileUnit.GetBaseDirectory();//站点目录
|
||
var tmpPath = Path.Combine(webPath, "temp");//临时文件目录
|
||
string zipPath = Path.Combine(tmpPath, folderName + ".zip");
|
||
FileInfo info = new FileInfo(zipPath);
|
||
if (info.Exists)
|
||
{
|
||
string name = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + ".zip";//获取最后修改时间
|
||
return Json(new retMsg() { result = true, retcode = 200, retmsg = string.Format("{0}{1}", holpName, name) });
|
||
}
|
||
else
|
||
{
|
||
return Json(new retMsg() { result = false, retcode = 500, retmsg = "找不到文件,请重新打包下载!" });
|
||
}
|
||
}
|
||
}
|
||
|
||
[HttpGet]
|
||
[Area("Admin")]
|
||
public ActionResult Remarks(string corp, string userid)
|
||
{
|
||
Ww_hhuser_Name model = new Ww_hhuser_Name();
|
||
if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(corp))
|
||
{
|
||
ViewBag.isOK = "0";
|
||
ViewBag.Msg = "参数不对!";
|
||
}
|
||
else
|
||
{
|
||
model = _iww_hhuser_service.GetHHuserName(userid, corp);
|
||
if (model == null)
|
||
{
|
||
model = new Ww_hhuser_Name() { corpid = corp, userid = userid };
|
||
}
|
||
}
|
||
return View(model);
|
||
}
|
||
|
||
[HttpPost]
|
||
[Area("Admin")]
|
||
public JsonResult RemarksSave(Ww_hhuser_Name model)
|
||
{
|
||
bool result = _iww_hhuser_service.UpdateHHuserName(model);
|
||
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "设置成功!" };
|
||
if (!result)
|
||
{
|
||
ret.retmsg = "设置失败!";
|
||
}
|
||
return Json(ret);
|
||
}
|
||
}
|
||
} |