using Core.Web.App_Start;
using Core.Web.WebHelper;
using CRM.Core.BLL.Base;
using CRM.Core.BLL.Hg;
using CRM.Core.BLL.Util;
using CRM.Core.Common.Layui;
using CRM.Core.DTO;
using CRM.Core.Model.Entity;
using CRM.Core.Model.Enum;
using CRM.Core.Model.Map;
using CRM.Core.Model.QueryModels;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WX.CRM.Common;
namespace Core.Web.Controllers
{
///
/// 合规管理
///
public class HGManagerController : BaseController
{
CACHE_BL cache_BL = new CACHE_BL();
Hg_Message_BL hg_bll = new Hg_Message_BL();
ValidationErrors erros = new ValidationErrors();
[AuthorizeRedirect(RightsConfig.CONST_合规报表, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
// GET: HGManager
public ActionResult Report()
{
ViewBag.companyList = cache_BL.GetCompanyVirtual();
return View();
}
#region 微信合规
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_NotButton, true)]
public ActionResult Wx()
{
ViewBag.rightCode = RightsConfig.CONST_微信聊天记录;
ViewBag.companyList = cache_BL.GetCompanyVirtual();
return View();
}
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_NotButton, false)]
[HttpPost]
///
/// 微信
///
///
public JsonResult WxList(Laypage pager, Hg_Wx_Message_Query param)
{
var list = hg_bll.GetWxList(ref pager, param);
foreach (var item in list)
{
if (item.msgtype == 34)
{
var host = ConfigurationManager.AppSettings["WxMessage_" + item.detpcode].ToString();
item.voiceUrl = host + "/WxMessageSvr.svc/WxAudio/Get?url=" + item.voiceUrl;
}
}
var data = new LayuiData()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other1, false)]
public JsonResult ReadComplete(int[] ids)
{
try
{
hg_bll.ReadWxComplete(ids, ref erros);
if (erros.Count() > 0)
{
return Json(new retMsg { result = false, retcode = -1, retmsg = erros.Error }, JsonRequestBehavior.AllowGet);
}
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
}
}
///
/// 添加违规信息
///
///
///
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other2, true)]
public ActionResult WxHg(string ids)
{
ViewBag.MsgType = "wx";
return HG(ids);//调用公共合规界面
}
#endregion
#region 企业微信
[AuthorizeRedirect(RightsConfig.CONST_企微聊天记录, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
///
/// 企业微信
///
///
public ActionResult QW()
{
ViewBag.rightCode = RightsConfig.CONST_企微聊天记录;
ViewBag.companyList = cache_BL.GetCompanyVirtual();
return View();
}
[AuthorizeRedirect(RightsConfig.CONST_企微聊天记录, ToolBarConfig.CONST_NotButton, false)]
[HttpPost]
///
/// 微信
///
///
public JsonResult QWList(Laypage pager, Hg_Qw_Message_Query param)
{
var list = hg_bll.GetQWList(ref pager, param, ref erros);
foreach (var item in list)
{
if (item.msgtype == "phone")
{
var host = ConfigurationManager.AppSettings["QxMessageFile_" + item.detpcode].ToString();
item.voiceUrl = host + $"/playamr?corpid={item.corpid}&fname={item.nfile}";
}
else
{
var host = ConfigurationManager.AppSettings["QxMessage_" + item.detpcode].ToString();
DateTime now = DateTime.Now;
DateTime etime = DateTime.Now;
if (item.ctime.AddDays(15) > now)
{
etime = now;
}
else
{
etime = item.ctime.AddDays(15);
}
var obj = new
{
NeedLocaltion = 1,
msgid = item.msgid,
stime = item.ctime.AddDays(-15).ToString("yyyy-MM-dd"),
etime = etime.ToString("yyyy-MM-dd")
};
item.httpurl = host + $"/Admin/OutHHuser/MessageDetial?locationJson={HttpUtility.UrlEncode(Newtonsoft.Json.JsonConvert.SerializeObject(obj))}&isgroup=false&corp={item.corpid}&nickname={HttpUtility.UrlEncode(item.cusname)}&customer={item.tolist}&uname={HttpUtility.UrlEncode(item.kehuname)}&userid={item.fromer}&IsHg=True";
}
}
var data = new LayuiData()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
if (erros.Count > 0)
{
data.msg = erros.Error;
data.code = 1;
}
//foreach (var item in list)
//{
// if (item.msgtype == 34)
// {
// var host = ConfigurationManager.AppSettings["WxMessage_" + item.detpcode].ToString();
// item.voiceUrl = host + "/WxMessageSvr.svc/WxAudio/Get?url=" + item.voiceUrl;
// }
//}
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other1, false)]
public JsonResult QWReadComplete(int[] ids)
{
try
{
hg_bll.ReadQWComplete(ids, ref erros);
if (erros.Count() > 0)
{
return Json(new retMsg { result = false, retcode = -1, retmsg = erros.Error }, JsonRequestBehavior.AllowGet);
}
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
}
}
///
/// 添加违规信息
///
///
///
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other2, true)]
public ActionResult QWHg(string ids)
{
ViewBag.MsgType = "qw";
return HG(ids);//调用公共合规界面
}
#endregion
#region 电话录音合规
[AuthorizeRedirect(RightsConfig.CONST_录音记录, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
///
/// 电话录音
///
///
public ActionResult ReCord()
{
ViewBag.rightCode = RightsConfig.CONST_录音记录;
ViewBag.companyList = cache_BL.GetCompanyVirtual();
return View();
}
[AuthorizeRedirect(RightsConfig.CONST_企微聊天记录, ToolBarConfig.CONST_NotButton, false)]
[HttpPost]
///
/// 微信
///
///
public JsonResult ReCordList(Laypage pager, Hg_ReCord_Query param)
{
var list = hg_bll.GetRecordList(ref pager, param, ref erros);
foreach (var item in list)
{
if (item.voiceurl.IndexOf("http") > -1)
{
continue;
}
var host = ConfigurationManager.AppSettings["video_" + item.detpcode].ToString();
item.voiceurl = host + item.voiceurl;//组合数据
}
var data = new LayuiData()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
if (erros.Count > 0)
{
data.msg = erros.Error;
data.code = 1;
}
//foreach (var item in list)
//{
// if (item.msgtype == 34)
// {
// var host = ConfigurationManager.AppSettings["WxMessage_" + item.detpcode].ToString();
// item.voiceUrl = host + "/WxMessageSvr.svc/WxAudio/Get?url=" + item.voiceUrl;
// }
//}
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other1, false)]
public JsonResult ReCordReadComplete(int[] ids)
{
try
{
hg_bll.ReadRecordComplete(ids, ref erros);
if (erros.Count() > 0)
{
return Json(new retMsg { result = false, retcode = -1, retmsg = erros.Error }, JsonRequestBehavior.AllowGet);
}
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
}
}
///
/// 添加违规信息
///
///
///
[AuthorizeRedirect(RightsConfig.CONST_微信聊天记录, ToolBarConfig.CONST_Other2, true)]
public ActionResult ReCordHg(string ids)
{
ViewBag.MsgType = "record";
return HG(ids);//调用公共合规界面
}
#endregion
BAS_PARAMETER_BL paramter_bl = new BAS_PARAMETER_BL();
#region 标记合规,公共界面
[HttpGet]
///
/// 合规标记
///
///
public ActionResult HG(string ids)
{
ViewBag.ids = ids;
var hglevel = paramter_bl.GetValue_Parameter(Parameter.HG_Level);//封装出来的接口
List typelist = Newtonsoft.Json.JsonConvert.DeserializeObject>(hglevel);
ViewBag.HgType = typelist;
return View("HG");
}
public JsonResult HGSave(string ids, string hgdetail, string hgresult, string hgtype, string hgsubtype, string msgtype)
{
try
{
bool result = false;
if (msgtype == "wx")
result = hg_bll.WxViolationAdd(ids, hgdetail, hgresult, hgtype, hgsubtype, ref erros);
else if (msgtype == "qw")
result = hg_bll.QWViolationAdd(ids, hgdetail, hgresult, hgtype, hgsubtype, ref erros);
else if (msgtype == "record")
result = hg_bll.RecordViolationAdd(ids, hgdetail, hgresult, hgtype, hgsubtype, ref erros);
if (erros.Count() > 0)
{
return Json(new retMsg { result = false, retcode = -1, retmsg = erros.Error }, JsonRequestBehavior.AllowGet);
}
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
}
}
#endregion
#region 违规列表
[AuthorizeRedirect(RightsConfig.CONST_标记违规记录, ToolBarConfig.CONST_NotButton, true)]
[HttpGet]
///
/// 电话录音
///
///
public ActionResult HgMsg()
{
ViewBag.rightCode = RightsConfig.CONST_标记违规记录;
ViewBag.companyList = cache_BL.GetCompanyVirtual();
var hglevel = paramter_bl.GetValue_Parameter(Parameter.HG_Level);//封装出来的接口
List typelist = Newtonsoft.Json.JsonConvert.DeserializeObject>(hglevel);
ViewBag.HgType = typelist;
return View();
}
[AuthorizeRedirect(RightsConfig.CONST_标记违规记录, ToolBarConfig.CONST_NotButton, false)]
[HttpPost]
///
/// 微信
///
///
public JsonResult HgList(Laypage pager, Hg_Violation_Query param)
{
var list = hg_bll.GetViolationList(ref pager, param, ref erros);
foreach (var item in list)
{
if (item.msgtype == "语音" && item.type == "WX")
{
var host = ConfigurationManager.AppSettings["WxMessage_" + item.detpcode].ToString();
item.voiceUrl = host + "/WxMessageSvr.svc/WxAudio/Get?url=" + item.voiceUrl;
}
if (item.msgtype == "电话录音")
{
if (item.voiceUrl.IndexOf("http") > -1)
{
continue;
}
var host = ConfigurationManager.AppSettings["video_" + item.detpcode].ToString();
item.voiceUrl = host + item.voiceUrl;//组合数据
}
if (item.msgtype == "企微通话")
{
var host = ConfigurationManager.AppSettings["QxMessage_" + item.detpcode].ToString();
item.voiceUrl = host + $"/playamr?corpid={item.corpid}&fname={item.voiceUrl}";
}
}
var data = new LayuiData()
{
msg = "数据加载成功!",
count = pager.count,
code = 0,
data = list
};
if (erros.Count > 0)
{
data.msg = erros.Error;
data.code = 1;
}
return Json(data, JsonRequestBehavior.AllowGet);
}
[AuthorizeRedirect(RightsConfig.CONST_标记违规记录, ToolBarConfig.CONST_Delete, false)]
public JsonResult HgDelete(int id)
{
try
{
hg_bll.ViolationDelete(id, ref erros);
if (erros.Count() > 0)
{
return Json(new retMsg { result = false, retcode = -1, retmsg = erros.Error }, JsonRequestBehavior.AllowGet);
}
return Json(new retMsg { result = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new retMsg { result = false, retcode = 0, retmsg = ex.ToString() }, JsonRequestBehavior.AllowGet);
}
}
#endregion
}
}