TG.WXCRM.V4/WEB/Controllers/Csvr/CustomerUCController.cs

2574 lines
111 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Aop.Api.Domain;
using CRM.Core.DTO;
using CRM.Core.DTO.Res;
using Newtonsoft.Json;
using Ninject;
using NPOI.HSSF.Record;
using NPOI.SS.Format;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.UI.WebControls.WebParts;
using WX.CRM.BLL.Base;
using WX.CRM.BLL.Soft;
using WX.CRM.BLL.Util;
using WX.CRM.Common;
using WX.CRM.Common.BlowFish;
using WX.CRM.Common.Employee;
using WX.CRM.IBLL.Base;
using WX.CRM.IBLL.Csvr;
using WX.CRM.IBLL.Ord;
using WX.CRM.IBLL.Quality;
using WX.CRM.IBLL.Res;
using WX.CRM.IBLL.Sms;
using WX.CRM.IBLL.Soft;
using WX.CRM.IBLL.Util;
using WX.CRM.IBLL.WeWork;
using WX.CRM.IBLL.Ww;
using WX.CRM.IBLL.Wx;
using WX.CRM.Model.DTO;
using WX.CRM.Model.Entity;
using WX.CRM.Model.Enum;
using WX.CRM.Model.QueryMap;
using WX.CRM.Model.Ww;
using WX.CRM.WEB.ViewModel.Sale;
using WX.CRM.WebHelper;
using WX.CRM.WebHelper.RedisFactory;
using static WX.CRM.WEB.Controllers.WeiXin.JZOrderController;
namespace WX.CRM.WEB.Controllers.Csvr
{
public class CustomerUCController : BaseController
{
[Inject]
public CACHE_BL cache_BL { get; set; }
private IORD_SPECIALMEMO_Q specialMemoBiz_Q;
private IORD_SERVICEMEMO_Q serviceMemoBiz_Q;
private IORD_SALEMEMO_Q saleMemoBiz_Q;
private IORD_SPECIALMEMO specialMemoBiz;
private IORD_SERVICEMEMO serviceMemoBiz;
private IORD_SALEMEMO saleMemoBiz;
private ICACHE_Q cacheQ;
private IORD_PURPOSEMEMO_Q purposeMemoBiz_Q;
private IORD_PURPOSEMEMO purposeMemoBiz;
private IRES_CUSTOMERDETAIL_Q customerDetail_Q;
private IRES_CUSTOMER_Q customer_Q;
private IBAS_PROVINCE_Q provinceQ;
private IBAS_CITY_Q cityQ;
private ICSVR_RELATIONCUSTOMER_Q relationcustomer;
private IRES_CUSTOMERUSER_Q customeruser_q;
private readonly IRES_CUSTOMEREXTEND _customerExt;
private readonly IRES_CUSTOMEREXTEND_Q _customerExtQ;
private readonly ISOFT_USER _softUser;
private readonly ISOFT_USER_Q _softUserQ;
private ICSVR_CALLRECORD_Q csvr_callRecordQ;
private IORD_MEMO_Q ord_memo_Q;
private ISMS_BATCHMSG_Q batchMsg_Q;
private readonly IWX_SZZYORDER _wxSzzyorder;
private IWX_RCONTACT wxrcontact;
private CACHE_BL _cache_bl;
private SecurityHelper sHelper = new SecurityHelper();
[Ninject.Inject]
public IBAS_PARAMETER_Q _BAS_PARAMETER_Q { get; set; }
[Inject]
public ICSVR_CALLRECORD CSVR_CALLRECORD_BL { get; set; }
[Inject]
public IWX_TDORDER wx_TDorder_BL { get; set; }
[Inject]
public IRES_CUSTOMERUSER_Q _customerUser_Q { get; set; }
[Inject]
public ICSVR_CALLRECORD_Q _CSVR_CALLRECORD_Q { get; set; }
//[Inject]
//public IGJS_CUSTOMERCHECK_Q customerCheck_Q { get; set; }
[Inject]
public IQC_CUSTOMERCOMPLAIN_Q customerComplain_Q { get; set; }
[Inject]
public IRES_CALLOUTCUSTOMER _RES_CALLOUTCUSTOMER { get; set; }
[Inject]
public IWX_SZZYORDER2 _wxSzzyorder2 { get; set; }
[Inject]
public IWX_ORDEREXT wx_OrderExt_BL { get; set; }
[Inject]
public IWX_SZZYSUBPRODUCT wx_szzysubproduct { get; set; }
[Inject]
public IRES_MYALLOCATERES _myallocate { get; set; }
[Inject]
public IRES_DISTRIBUTE _distribute { get; set; }
[Inject]
public IWW_EXTUSER _wwExtUser { get; set; }
[Inject]
public IWW_EXTUSER_RESID _wwExtUserResId { get; set; }
[Inject]
public IWW_HHUSER _wwHhUser { get; set; }
[Inject]
public ISecurityHelper securityHelper { get; set; }
[Inject]
public IRES_CUSTOMER_RFM _rfm { get; set; }
[Inject]
public ICSVR_FAVORITECUSTOMER_Q _favoriteCustomer { get; set; }
[Inject]
public IRES_RESOURCEMOBILE_Q _resource { get; set; }
[Inject]
public IRES_CUSTOMER RES_CUSTOMER { get; set; }
public RedisFactory redisFactory = new RedisFactory();
public CustomerUCController(
IORD_SPECIALMEMO_Q _specialMemoBiz_Q,
IORD_SERVICEMEMO_Q _serviceMemoBiz_Q,
IORD_SALEMEMO_Q _saleMemoBiz_Q,
IORD_PURPOSEMEMO_Q _purposeMemoBiz_Q,
IRES_CUSTOMERDETAIL_Q _customerDetail_Q,
ICACHE_Q _cacheQ,
IRES_CUSTOMER_Q _customer_Q,
IBAS_PROVINCE_Q _provinceQ,
IBAS_CITY_Q _cityQ,
IRES_CUSTOMERUSER_Q customerUserQ,
ICSVR_RELATIONCUSTOMER_Q _relationcustomer,
IRES_CUSTOMEREXTEND customerExt, IRES_CUSTOMEREXTEND_Q customerExtQ,
ISOFT_USER softUser,
ISOFT_USER_Q softUserQ,
ICSVR_CALLRECORD_Q _csvr_callRecordQ,
IORD_SPECIALMEMO _specialMemoBiz,
IORD_SERVICEMEMO _serviceMemoBiz,
IORD_SALEMEMO _saleMemoBiz,
IORD_PURPOSEMEMO _purposeMemoBiz,
IORD_MEMO_Q _ord_memo_Q,
ISMS_BATCHMSG_Q _batchMsg_Q,
IWX_SZZYORDER wxSzzyorder,
IWX_RCONTACT _wxrcontact
)
{
this.specialMemoBiz_Q = _specialMemoBiz_Q;
this.serviceMemoBiz_Q = _serviceMemoBiz_Q;
this.saleMemoBiz_Q = _saleMemoBiz_Q;
this.purposeMemoBiz_Q = _purposeMemoBiz_Q;
this.customerDetail_Q = _customerDetail_Q;
this.cacheQ = _cacheQ;
this.customer_Q = _customer_Q;
this.provinceQ = _provinceQ;
this.cityQ = _cityQ;
this.relationcustomer = _relationcustomer;
this.customeruser_q = customerUserQ;
this._customerExt = customerExt;
this._customerExtQ = customerExtQ;
this._softUser = softUser;
this._softUserQ = softUserQ;
this.csvr_callRecordQ = _csvr_callRecordQ;
this.saleMemoBiz = _saleMemoBiz;
this.specialMemoBiz = _specialMemoBiz;
this.serviceMemoBiz = _serviceMemoBiz;
this.purposeMemoBiz = _purposeMemoBiz;
this.ord_memo_Q = _ord_memo_Q;
this.batchMsg_Q = _batchMsg_Q;
_wxSzzyorder = wxSzzyorder;
this.wxrcontact = _wxrcontact;
this._cache_bl = new CACHE_BL();
}
//
// GET: /CustomerUC/
#region
public ActionResult FastMemo(CustomerInfo info)
{
ViewBag.CustomerInfo = info;
var fastmemo = cacheQ.GetValue_Parameter("fastmemo");
ViewBag.fastmemo = fastmemo;
return View();
}
public ActionResult CustomerBaseInfoUC(CustomerInfo info)
{
//RES_CUSTOMER cData = new RES_CUSTOMER();
ViewBag.CustomerInfo = info;
//try
//{
//var resData = info.ResCustomerList.Where(p => p.RESID == info.CustomerId).FirstOrDefault();
RES_CUSTOMER cData = info.ResCustomerList.Where(p => p.RESID == info.CustomerId).FirstOrDefault();
if (info.IsOther == 1)
{
cData = info.ResCustomerList.Where(p => p.RESID == info.RequsetResId).FirstOrDefault();
}
if (cData == null)
{
RES_CUSTOMER rescustomer = customer_Q.getResCustomerByResId(info.CustomerId);
//RES_CUSTOMER rescustomer = redisFactory.GetInfo_Rescustomer(info.CustomerId);
string nresid = rescustomer == null ? "" : rescustomer.CUSTOMERID;
Response.Redirect(Url.Action("ErrorView", "Error", new { message = string.Format("错误提示:{0},{1}客户信息合并出现问题,请重新申请合并!", info.CustomerId, nresid) }));
}
customer_Q.GetResCustomerOtherInfo(ref cData);//获取多余的字段
if (cData.RES_CUSTOMERDETAIL != null)
{
cData.map_ADDRESS_ALL = cityQ.GetAddressStr(cData.map_PROVINCEID, cData.map_CITY) + cData.map_ADDRESS;//地址获取
RES_CUSTOMERDETAIL model = cData.RES_CUSTOMERDETAIL;
cData.map_CNAME = model.CNAME;
//if (!string.IsNullOrEmpty(model.CNAME))
//{
// if (model.CNAME.Length > 4)
// cData.map_CNAME = model.CNAME.Substring(0, 4);
// else
// cData.map_CNAME = model.CNAME;
//}
cData.map_PRIMARYNUMBERADDRESS = model.PRIMARYNUMBERADDRESS;
cData.map_ResId = cData.RESID;
cData.UMID = cData.UMID;
if (string.IsNullOrWhiteSpace(model.AMOUNTTYPEID))
{
cData.map_AMOUNTTYPEID = "";
}
else
{
var m = cacheQ.GetList_SubComType(ComType.CustomerZJL).FirstOrDefault(p => p.SUBTYPECODE == model.AMOUNTTYPEID);
if (m != null)
{
cData.map_AMOUNTTYPEID = m.map_SUBTYPENAME;
}
}
if (string.IsNullOrWhiteSpace(model.JOBTYPEID))
{
cData.map_JOBTYPEID = "";
}
else
{
var m = cacheQ.GetList_SubComType(ComType.CustomerZY).FirstOrDefault(p => p.SUBTYPECODE == model.JOBTYPEID);
if (m != null)
{
cData.map_JOBTYPEID = m.map_SUBTYPENAME;
}
}
cData.map_GENDER = model.GENDER == "m" ? "男" : "女";
cData.map_ADDRESS = model.ADDRESS;
//cData.isBound = model.ISBOUND;//是否绑定客服
cData.isBound = _customerUser_Q.GetResidBound(cData.RESID) ? 1 : 0;
cData.TYPE = cData.TYPE;
var lists = _customerUser_Q.GetListByCustomerId(cData.CUSTOMERID);
if (lists.Count > 0)
{
ViewBag.register = true;
}
var ZJL = cacheQ.GetList_SubComType(ComType.CustomerZJL).Select(item => new SelectListItem() { Text = item.SUBTYPENAME, Value = item.SUBTYPECODE }).ToList();
ViewBag.ZJL = ZJL;
}
var residArr = info.ResCustomerList.Select(p => p.RESID).ToArray();
var allocateList = _myallocate.GetList(p => residArr.Contains(p.RESID));
ViewBag.CustomerInfo = info;
ViewBag.companyCode = companyCode;//公司编码
ViewBag.allocateList = allocateList;
ViewBag.userId = UserId;
ViewBag.rfm = _rfm.GetResCustomerRfm(residArr);
var favCustomer = _favoriteCustomer.GetModel_FavoriteCustomer(info.CustomerId, null);
var comTypeList = DataCacheHelper.GetCache().GetList_SubComType(WX.CRM.Model.Enum.ComType.FavoritesCustType);
string favoritesCustType = string.Empty;
if (favCustomer != null)
{
var comtypeInfo = comTypeList.FirstOrDefault(P => P.map_SUBTYPECODE == favCustomer.PARAKEY);
if (comtypeInfo != null)
{
favoritesCustType = comtypeInfo.map_SUBTYPENAME;
}
}
//客户内外诉标签
try
{
var webapi = cacheQ.GetValue_Parameter(Parameter.Hg_Core_WebApi);
//webapi = "https://localhost:7090";
var url = $"{webapi}/api/OutComplaint/ComplaintLabel";
var para = $"resId={info.CustomerId}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = result.ToObject<WX.CRM.Common.Employee.ApiResult<ComplaintLabelDto>>();
ViewBag.Complaint = data?.data;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
//客户普通标签
try
{
var webapi = cacheQ.GetValue_Parameter(Parameter.zxd_core_webapi_url);
//webapi = "https://localhost:7090";
var url = $"{webapi}api/Customer/GetTag";
var para = $"resid={info.CustomerId}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = result.ToObject<WX.CRM.Common.Employee.ApiResult<List<Res_TagDto>>>();
ViewBag.ResTag = data?.data;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
//客户内外诉标签
try
{
var webapi = cacheQ.GetValue_Parameter("HgActionUrl");
//webapi = "https://localhost:7090";
var url = $"{webapi}api/Complaint/Label";
var para = $"resId={info.CustomerId}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = result.ToObject<WX.CRM.Common.Employee.ApiResult<int>>();
ViewBag.ComplaintId = data?.data;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
//客户年龄身份证地址IP信息
try
{
var url = cacheQ.GetValue_Parameter(Parameter.Customer_DetailUrl);
if (!string.IsNullOrWhiteSpace(url))
{
var para = $"appid=&appuserid=&fields=username,age,gender,id_province,id_city,id_area,ip,country,province,city&resid={info.CustomerId}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = result.ToObject<WX.CRM.Common.Employee.ApiResult<List<CustomerInfoDto>>>();
if (data.code == 0 && data.data != null)
{
var dto = data.data;
ViewBag.CName = dto.FirstOrDefault(x => x.name == "username")?.val;
ViewBag.Age = dto.FirstOrDefault(x => x.name == "age")?.val;
ViewBag.Genger = dto.FirstOrDefault(x => x.name == "gender")?.val_name;
ViewBag.IdCardAddr = $"{dto.FirstOrDefault(x => x.name == "id_province")?.val}{dto.FirstOrDefault(x => x.name == "id_city")?.val}{dto.FirstOrDefault(x => x.name == "id_area")?.val}";
ViewBag.IpAddr = $"{dto.FirstOrDefault(x => x.name == "province")?.val}{dto.FirstOrDefault(x => x.name == "city")?.val}";
}
}
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
ViewBag.FavoritesCustType = favoritesCustType;
return View(cData);
}
public ActionResult CustomerCheckUC(CustomerInfo info)
{
//List<string> listTradeCode = info.GjsCustomerList.Select(m => m.TRADECODE).ToList();
//string tradeCodes = string.Join(",", listTradeCode);
//List<GJS_CUSTOMERCHECKRUMOR> customerCheckList = customerCheck_Q.GetList_GjsCustomerCheckByTradecodes(listTradeCode);
List<string> listResId = info.ResCustomerList.Select(m => m.RESID).ToList();
List<QC_CUSTOMERCOMPLAIN_Extend> customerComplainList = customerComplain_Q.GetList_CustomerComplainByResIds(listResId);
//QC_CUSTOMERCOMPLAIN_Extend customerComplain = null;
//if (customerComplainList != null)
//{
// customerComplain = customerComplainList.FirstOrDefault();
//}
var isSH = false;
var roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
if ((roleCodes.Contains("[SH]") || roleCodes.Contains("[GLY]")))
{
isSH = true;
}
//ViewBag.customerCheckList = customerCheckList;
ViewBag.customerComplain = customerComplainList;
ViewBag.customerId = info.CustomerId;
ViewBag.isSH = isSH;
ViewBag.isHasAddFXRole = userRoleCodes.Contains("[RISKADD]") ? "1" : "0";
return View();
}
public ActionResult CustomerCategoryUC(CustomerInfo info)
{
ViewBag.CustomerInfo = info;
//List<FXH_CUSTOMERCATEGORYTYPE> typeList = customerCategory.GetTypeList(info.CustomerId);
//ViewBag.typeList = typeList;
//string paraValue = "";
//DateTime? lossAmtDate = cacheQ.GetGjs_TradeCustomerTotalList().Where(m => info.GjsCustomerList.Select(p => p.TRADECODE).ToArray().Contains(m.TRADECODE)).Where(m => m.LOSSAMTDATE != null).Select(p => p.LOSSAMTDATE).OrderByDescending(d => d).FirstOrDefault();
//if (lossAmtDate != null)
// paraValue = cacheQ.GetValue_Parameter(Model.Enum.Parameter.Gjs_LossAmt);
//ViewBag.LossAmt = paraValue;
//ViewBag.LossAmtDate = lossAmtDate;
//List<GJS_CustomerCategoryInfoView> model2 = _gjsCustomercategoryQ.GetList_CustomerCategoryInfo(info);
//ViewBag.GJS_CustomerCategoryInfoViewList = model2;
return View();
}
public ActionResult CustomerExtendUC(CustomerInfo info)
{
var list = _customerExtQ.GetList_CustomerExt(info.CustomerId);
var SKtype = cacheQ.GetList_SubComType(ComType.CustomerExtendSK).ToList();
var Item = cacheQ.GetList_SubComType(ComType.CustomerExtendChoseItem).ToList();
//var resData = info.GjsCustomerList.Where(p => p.RESID == info.CustomerId).FirstOrDefault();
SKtype.AddRange(Item);
foreach (var it in list)
{
BAS_SUBCOMTYPE subName = SKtype.Where(p => p.SUBTYPECODE == it.CUSTOMEREXTENDSUBTYPEID).FirstOrDefault();
if (it.CUSTOMEREXTENDTYPEID == "CustomerExtendSK")
{
it.CUSTOMEREXTENDSUBTYPEID = subName == null ? "" : subName.SUBTYPENAME;
}
else
{
it.CUSTOMEREXTENDSUBTYPEID = "看盘时间";
}
}
ViewBag.resid = info.CustomerId;
ViewBag.List = list;
//ViewBag.tradeCode = resData == null ? "" : resData.TRADECODE;
ViewBag.tradeCode = "";
return View();
}
public ActionResult ContactUC(CustomerInfo info)
{
var _CTI_CALLOUT_CUSTOMER = cacheQ.GetValue_Parameter("CTI_CALLOUT_CUSTOMER");
var _sys_Environment_DeptCode = cacheQ.GetValue_Parameter("Sys_Environment_DeptCode");
bool nedCallOutNum = true;
//if (null != _sys_Environment_DeptCode)
// nedCallOutNum = _sys_Environment_DeptCode == Sys_Environment_DeptCode.LVTD01.ToString() ||
// userRoleNames.Contains("VIP热线电话");
if (_CTI_CALLOUT_CUSTOMER != null && _CTI_CALLOUT_CUSTOMER.ToLower() == "true")
_init_CallOutPara(info.RequsetResId, _sys_Environment_DeptCode, nedCallOutNum);
else
_init_CallOutNum(_sys_Environment_DeptCode, nedCallOutNum);
string weixinzhushou = cacheQ.GetValue_Parameter("WeiXin_WebChatAssistant");
bool isShowwxzs = false;
if (!string.IsNullOrEmpty(weixinzhushou) && weixinzhushou == "show")
{
isShowwxzs = true;
}
ViewBag.IsShowWeiXinZhuShou = isShowwxzs;
ViewBag.resid = info.CustomerId;
ViewBag.ResCustList = info.ResCustomerList;
ViewBag.CanShowMoile = cacheQ.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_CanShowResMobile);
string roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
//升级客服角色
if (roleCodes.IndexOf("GJSSJKF") >= 0)
{
ViewBag.GJSSJKF = "1";
}
var cti = _CSVR_CALLRECORD_Q.Sys_Environment_CTI_VER();
if (null != cti)
{
ViewBag.CTI_VER = Convert.ToInt32(cti);
}
ViewBag.DeptCode = _sys_Environment_DeptCode.ToUpper();
ViewBag.IsBC = nedCallOutNum.ToString().ToLower();
ViewBag.Eid = Eid;
ViewBag.RoleCodes = roleCodes;
ViewBag.IsFromHg = info.IsFromHg;
return View();
}
private void _init_CallOutPara(string resid, string _sys_Environment_DeptCode, bool nedCallOutNum)
{
var CallOutPhoneList = new List<System.Web.UI.WebControls.ListItem>();
var CallOutPhoneDefault = new List<String>();
var calloutPara = cacheQ.GetList_CallOutPara();
if (calloutPara == null || calloutPara.Count == 0)
{
return;
}
foreach (var callout in calloutPara)
{
if (callout.ISSHOW == 0)//网络号码
{
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = callout.CALLOUTNAME, Value = callout.CALLOUTNUM });
}
else
{
var chk = _RES_CALLOUTCUSTOMER.IsCallOut(resid, callout.CALLOUTTYPE);
if (chk)
{
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = callout.CALLOUTNAME, Value = callout.CALLOUTNUM });
}
}
}
ViewBag.CallOutPhoneDefault = CallOutPhoneDefault;
ViewBag.CallOutPhone = CallOutPhoneList;
}
private void _init_CallOutNum(string _sys_Environment_DeptCode, bool nedCallOutNum)
{
var CallOutPhoneList = new List<System.Web.UI.WebControls.ListItem>();
var CallOutPhoneDefault = new List<String>();
#region VIP号码
string roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
var calloutpara = "";
//VIP热线坐席
if (roleCodes.IndexOf("VIPCall") > -1)
{
calloutpara = cacheQ.GetValue_Parameter("Sys_Environment_VIPCallOut");
}
else
{
calloutpara = cacheQ.GetValue_Parameter("Sys_Environment_CallOut");
}
/*
* 参数表KEYSys_Environment_CallOut 数据格式7300|1,7333|9
* 含义勾选框7300,7333,选不同参数发送不同号码如选7300调用参数1。
*
* 参数格式变更7300|1,7333|9#7444#1
* 含义7300|1,7333|9VIP号码7444号码池号码1默认号码。
*/
int xx = 0;
if (nedCallOutNum)//VIP号码#号码池号码
{
if (calloutpara != null && !string.IsNullOrEmpty(calloutpara))
{
var vipstr = calloutpara.Split('#');//取VIP号码
if (!string.IsNullOrEmpty(vipstr[0]))
{
foreach (var callout in (vipstr[0]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))// 7300|1,7333|9
{
xx++;
//if (xx > 1 && roleCodes.IndexOf("[SH]") == -1 && roleCodes.IndexOf("[GJSGJKF]") == -1)//售后和主管才能有权选择
// break;
var valAndText = callout.Split('|');
if (valAndText.Length == 2)
{
//if (roleCodes.IndexOf("[SH]") > -1 && xx==2)
//{
// CallOutPhoneDefault.Add(valAndText[1]);
//}
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = valAndText[0], Value = valAndText[1] });
}
else
{
//if (roleCodes.IndexOf("[SH]") > -1 && xx == 2)
//{
// CallOutPhoneDefault.Add(valAndText[0]);
//}
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = valAndText[0], Value = valAndText[0] });
}
}
//CallOutPhoneDefault.Add(CallOutPhoneList.FirstOrDefault().Value);
}
}
}
#endregion VIP号码
#region
if (calloutpara != null && !string.IsNullOrEmpty(calloutpara))
{
var vipstr = calloutpara.Split('#');//取号码池
if (vipstr.Length >= 2 && !string.IsNullOrEmpty(vipstr[1]))
{
foreach (var callout in (vipstr[1]).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
var valAndText = callout.Split('|');
if (valAndText.Length == 2)
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = valAndText[0], Value = valAndText[1] });
else
CallOutPhoneList.Add(new System.Web.UI.WebControls.ListItem { Text = valAndText[0], Value = valAndText[0] });
}
}
}
#endregion
#region
if (calloutpara != null && !string.IsNullOrEmpty(calloutpara))
{
var vipstr = calloutpara.Split('#');//取VIP号码
if (vipstr.Length == 3)
{
CallOutPhoneDefault.Add(vipstr[2]);
}
}
#endregion
ViewBag.CallOutPhoneDefault = CallOutPhoneDefault;
ViewBag.CallOutPhone = CallOutPhoneList;
}
public ActionResult CustomerUserUC(CustomerInfo info)
{
//OldVersion
List<SOFT_USER> list = customeruser_q.GetListByCustomerId(info.CustomerId);
var softuser = _softUserQ.GetUserList_userName(list.Select(m => m.USERNAME).ToArray());
var ResCustList = info.ResCustomerList;
//redis版本
//var ResCustList = info.ResCustomerList;
//string[] resids = ResCustList.Select(m => m.RESID).ToArray();
//List<RES_CUSTOMERUSER> list = redisFactory.GetList_Rescustomeruser(info.CustomerId, resids);
//var softuser = redisFactory.GetList_SoftUser(list.Select(m => m.USERNAME).Distinct().ToArray());
Dictionary<string, RES_CUSTOMER> dic = new Dictionary<string, RES_CUSTOMER>();
//foreach (var model in softuser)
//{
// RES_CUSTOMERUSER customeruser = list.FirstOrDefault(p => p.USERNAME == model.USERNAME);
// var rescustomer = ResCustList.FirstOrDefault(m => m.RESID == customeruser.RESID);
// dic.Add(model.USERNAME, rescustomer);
//}
foreach (var model in list)
{
if (!dic.ContainsKey(model.USERNAME))
{
var rescustomer = ResCustList.FirstOrDefault(m => m.RESID == model.RESID);
dic.Add(model.USERNAME, rescustomer);
}
}
ViewBag.SoftUser = softuser;
ViewBag.ResId = info.CustomerId;
ViewBag.UserNameList = string.Join(",", softuser.Select(m => m.USERNAME));
ViewBag.ResDic = dic;
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_公共权限)]
public JsonResult GetOtherUser(string resid, string softusername)
{
try
{
resid = customer_Q.GetResidByUMID(resid);
if (string.IsNullOrWhiteSpace(resid))
{
return Json(new { reslust = false, message = "客户id不能为空" });
}
var _regUser = new GET_REGUSER();
//_regUser.initDeptIdRelation();
var deptids = new List<decimal>();
var user = cache_BL.GetUserList().FirstOrDefault(n => n.EID == Eid);
if (user.DEPTID.HasValue && user.DEPTID > 0)
deptids.Add(user.DEPTID.Value);
else
deptids.AddRange(cache_BL.GetList_BusinessLines().Select(x => x.BUSINESSID));
var result = _regUser.GetUserByZXD(resid, companyCode, Eid, deptids);
if (result.result)
{
foreach (var activeModel in result.data)
{
SyncRegExtraModel extraModel = new SyncRegExtraModel
{
deptId = _regUser.BuildDeptIdByResId(activeModel.resid, userId: UserId)
};
_regUser.RegUser(activeModel.mobile, activeModel.regcampainid.ToString(), "", activeModel.username, activeModel.regdate, 0, activeModel.mobile, platform: activeModel.reglatform, extraModel: extraModel);
if (activeModel.mainresid != null && activeModel.mainresid != activeModel.resid)
{
using (var db = new crmContext())
{
var resCustomer = db.RES_CUSTOMER.FirstOrDefault(n => n.RESID == activeModel.resid);
if (resCustomer != null)
{
resCustomer.CUSTOMERID = activeModel.mainresid;
db.SaveChanges();
}
}
}
}
return Json(new { reslust = true, message = result.retmsg });
}
else
{
return Json(new { reslust = false, message = result.retmsg });
}
}
catch (Exception e)
{
LogHelper.Error(e.ToString());
return Json(new { reslust = false, message = "系统错误" });
}
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_公共权限)]
public JsonResult GetOtherUserBySoftName(string softname)
{
try
{
if (string.IsNullOrWhiteSpace(softname))
{
return Json(new { reslust = false, message = "软件名不能为空" });
}
var deptids = new List<decimal>();
var user = cache_BL.GetUserList().FirstOrDefault(n => n.EID == Eid);
if (user.DEPTID.HasValue && user.DEPTID > 0)
deptids.Add(user.DEPTID.Value);
else
deptids.AddRange(cache_BL.GetList_BusinessLines().Select(x => x.BUSINESSID));
var _regUser = new GET_REGUSER();
var result = _regUser.GetUserByZXDSoftName(softname, companyCode, Eid, deptids);
if (result.result)
{
foreach (var activeModel in result.data)
{
try
{
var v_resid = ResUtil.CreateResId(activeModel.mobile);
SyncRegExtraModel extraModel = new SyncRegExtraModel
{
deptId = _regUser.BuildDeptIdByResId(activeModel.resid, userId: UserId)
};
_regUser.RegUser(activeModel.mobile, activeModel.regcampainid.ToString(), "", activeModel.username, activeModel.regdate, 0, activeModel.mobile, platform: activeModel.reglatform, extraModel: extraModel);
}
catch (Exception ex)
{
LogHelper.Error($"手机号转换失败{activeModel.mobile} {ex.Message}");
}
}
return Json(new { reslust = true, message = result.retmsg });
}
else
{
return Json(new { reslust = false, message = result.retmsg });
}
}
catch (Exception e)
{
LogHelper.Error(e.ToString());
return Json(new { reslust = false, message = "系统错误" });
}
}
public ActionResult CustomerAddWxUserUC(CustomerInfo info)
{
ViewBag.WorkwxEid = Eid;
ViewBag.ResId = info.CustomerId;
ViewBag.RcontactList = wxrcontact.GetRcontactByResId(info.CustomerId);
string roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);//获取员工角色
ViewBag.RoleCodes = roleCodes;
return View();
}
[Inject]
public IWw_huser _iww_hhuser_service { get; set; }
#region
public ActionResult CustomerAddWWUserUC(CustomerInfo info)
{
List<WwExtUserView> view = new List<WwExtUserView>();
try
{
//var userlist = _wwExtUserResId.GetList(p => p.RESID == info.CustomerId);
var userlist = new List<ExUserModel>();
try
{
var webapi = cache_BL.GetValue_Parameter(Parameter.ZXD_CORE_WEBAPI);
webapi = $"{webapi}/Api/Customer/GetWorkWXUserSelect";
var para = $"resId={info.CustomerId}&deptCode={companyCode}";
var result = Utility.GetData(webapi, para, Encoding.UTF8);
var rsp = Newtonsoft.Json.JsonConvert.DeserializeObject<WX.CRM.Common.StockHelper.ApiResult<List<ExUserModel>>>(result);
if (rsp != null && rsp.Data != null && rsp.Data.Count > 0)
{
userlist.AddRange(rsp.Data);
}
}
catch (Exception ex)
{
LogHelper.Error($"获取企微客户关系报错");
}
List<decimal> eidList = new List<decimal>();
foreach (var user in userlist)
{
if (user != null)
{
Ww_Extuser extuser = _iww_hhuser_service.ExtUserGet(user.USERID);
//var extuser = _wwExtUser.Get(p => p.USERID == user.USERID);
try
{
if (extuser != null)
{
var exinfo = extuser.exinfo.ToObject<WwExtUserView>();
if (exinfo == null)
continue;
exinfo.corpid = extuser.corpid;
foreach (var item in exinfo.follow_user)
{
var hhuser = _iww_hhuser_service.HHuser_Get(item.userid, exinfo.corpid);
WW_HHUSER_EID hheid = _iww_hhuser_service.GetModel(item.userid, exinfo.corpid);
if (hheid != null)
{
item.saleeid = InnerUserHelper.Instance.GetEidAndNameByEid(hheid.EID);
if (hheid.EID.HasValue)
{
eidList.Add(hheid.EID.Value);
item.eid = hheid.EID;
}
}
else
{
item.saleeid = "";
}
//var hhuser = _wwHhUser.Get(p => p.USERID == item.userid);
if (hhuser != null)
item.uname = hhuser.uname;
item.bindtime = user.CTIME.ToString("yyyy-MM-dd HH:mm:ss");
item.remark = Utility.ReplaceMobile(item.remark);
for (int i = 0; i < item.remark_mobiles.Count; i++)
{
item.remark_mobiles[i] = Utility.ReplaceMobile(item.remark_mobiles[i]);
}
}
if (user.Deptcode == companyCode)
{
exinfo.isSeftUser = true;
}
//extUserInfo = exinfo.ToJson();
view.Add(exinfo);
}
}
catch (Exception ex)
{
LogHelper.Error($"记录错误信息:{extuser.ToJson()}报错了{ex.Message}");
}
}
}
if (eidList.Count > 0)
{
var userDeptName = new CACHE_BL().GetUserDeptNameByEid(eidList);
foreach (var item in view)
{
foreach (var user in item.follow_user)
{
user.deptname = userDeptName.FirstOrDefault(n => n.Eid == user.eid) == null ? "" : userDeptName.FirstOrDefault(n => n.Eid == user.eid).DeptName;
}
}
}
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
ViewBag.extUserInfo = view.ToJson();
ViewBag.ResId = info.CustomerId;
ViewBag.DeptCode = Utility.GetSettingOrNullByKey("DataClientCode");
ViewBag.WwMessage_Url = cacheQ.GetValue_Parameter("WwMessage_Url");
ViewBag.companycode = companyCode;//公司ID
ViewBag.UnBindWxExt = IsRoleToolBar(InitRights.CONST_客户企微解绑, InitToolBar.CONST_Other1);
ViewBag.MergeRoot = IsRoleToolBar(InitRights.CONST_合并软件用户, InitToolBar.CONST_Other1);
return View();
}
private bool IsRoleToolBar(string role, int toobar)
{
int outInt = 0;
var rights = UserRightsHelper.getUserRights();
if ((role != null) && (rights != null))
{
string[] rolesRights = rights.Where(p => p.Contains(role)).ToArray();
for (int i = 0; i < rolesRights.Length; i++)
{
if ((rolesRights[i] != null) && (rolesRights[i].Length > 4) && (string.Compare(rolesRights[i], 0, role, 0, 4, StringComparison.OrdinalIgnoreCase) == 0) && int.TryParse(rolesRights[i].Substring(4), out outInt) && (outInt & toobar) > 0)
{
return true;
}
}
}
return false;
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_客户企微解绑, InitToolBar.CONST_Other1)]
public JsonResult UnBindWwExtUser(string resId, string userId, string appid)
{
if (string.IsNullOrEmpty(userId))
{
return Json(new { result = false, message = "请选择企业微信" }, JsonRequestBehavior.AllowGet);
}
if (string.IsNullOrEmpty(resId))
{
return Json(new { result = false, message = "参数错误" }, JsonRequestBehavior.AllowGet);
}
bool ret = true;
string message = "解除关联成功!";
try
{
ret = _wxSzzyorder.DeleteResIdByWwUserName(resId, userId);
if (ret)
{
//_wxSzzyorder.UpdateIsBoundByResId(resId);
RES_CUSTOMER.UnBindCustomerQw(resId, userId);
var url = _cache_bl.GetValue_Parameter(Parameter.Core_ZxdService_WebApi);
url = $"{url.Trim('/')}/Api/Extuser/BindExtUser";
var para = new
{
resid = resId,
deptcode = companyCode,
userid = userId,
type = "unbind"
};
if (string.IsNullOrWhiteSpace(companyCode))
{
var sysComCode = Utility.GetSettingOrNullByKey("DataClientCode");
para = new
{
resid = resId,
deptcode = sysComCode,
userid = userId,
type = "bind"
};
}
var rep = Utility.PostAjaxData(url, para.ToJson(), Encoding.UTF8);
var reqInfo = JsonConvert.DeserializeObject<ApiResult<bool>>(rep);
if (reqInfo.code != 0)
{
message = "关联成功!同步到总部失败!";
}
else
{
try
{
//解绑用户中心数据
var cmsurl = _cache_bl.GetValue_Parameter(Parameter.Cms_PostWebApi);
if (string.IsNullOrWhiteSpace(cmsurl))
{
cmsurl = "http://post.hc.dn8188.com";
}
cmsurl = $"{cmsurl.Trim('/')}/Rights/UnbindUser.html";
var time = (long)Utility.ConvertDateTimeInt(DateTime.Now);
var content = JsonConvert.SerializeObject(new { account = "dn.crm", time });
var contentpara = sHelper.createSignEncodingStr(content);
var urlUp = cmsurl + "?" + contentpara;
if (!appid.EndsWith("_1"))
{
appid = $"{appid}_1";
}
var cmspara = new
{
appid = appid,
appuserid = userId,
};
var cmsrep = Utility.PostAjaxData(urlUp, cmspara.ToJson(), Encoding.UTF8);
var cmsResult = JsonConvert.DeserializeAnonymousType(cmsrep, new { errcode = -1, errmsg = string.Empty });
if (cmsResult.errcode != 0)
{
LogHelper.Info($"解绑软件用户名不成功{cmsResult.errmsg}");
}
}
catch (Exception ex)
{
LogHelper.Info($"解绑软件用户名不成功{ex.Message}");
}
}
}
}
catch (Exception e)
{
ret = false;
LogHelper.Info("异常:" + e.ToString());
message = "出现错误!";
}
return Json(new { result = ret, message = message }, JsonRequestBehavior.AllowGet);
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_合并软件用户, InitToolBar.CONST_Other1)]
public JsonResult MergeSoftUser(string resId, string userId, string appid)
{
if (string.IsNullOrEmpty(userId))
{
return Json(new { result = false, message = "请选择企业微信" }, JsonRequestBehavior.AllowGet);
}
if (string.IsNullOrEmpty(resId))
{
return Json(new { result = false, message = "参数错误" }, JsonRequestBehavior.AllowGet);
}
var softUserList = _softUserQ.GetUserByResid(resId);
if (softUserList.Count == 0)
{
return Json(new { result = false, message = "没有软件用户名可合并" }, JsonRequestBehavior.AllowGet);
}
bool ret = false;
string message = "合并用户成功!";
try
{
var url = _cache_bl.GetValue_Parameter(Parameter.Cms_PostWebApi);
if (string.IsNullOrWhiteSpace(url))
{
url = "http://post.hc.dn8188.com";
}
url = $"{url.Trim('/')}/Rights/ConcatSoftUserName.html";
var time = (long)Utility.ConvertDateTimeInt(DateTime.Now);
var content = JsonConvert.SerializeObject(new { account = "dn.crm", time });
var contentpara = sHelper.createSignEncodingStr(content);
var urlUp = url + "?" + contentpara;
if (!appid.EndsWith("_1"))
{
appid = $"{appid}_1";
}
var para = new
{
appid = appid,
appuserid = userId,
softusername = softUserList.FirstOrDefault()?.USERNAME
};
var rep = Utility.PostAjaxData(urlUp, para.ToJson(), Encoding.UTF8);
var cmsResult = JsonConvert.DeserializeAnonymousType(rep, new { errcode = -1, errmsg = string.Empty });
if (cmsResult.errcode == 0)
{
ret = true;
message = "合并软件名成功!";
}
else
{
message = cmsResult.errmsg;
}
}
catch (Exception e)
{
ret = false;
LogHelper.Info("异常:" + e.ToString());
message = "出现错误!";
}
return Json(new { result = ret, message = message }, JsonRequestBehavior.AllowGet);
}
public JsonResult BindWwExtUser(string resId, string userId)
{
if (string.IsNullOrEmpty(userId))
{
return Json(new { result = false, message = "请选择企业微信" }, JsonRequestBehavior.AllowGet);
}
if (string.IsNullOrEmpty(resId))
{
return Json(new { result = false, message = "参数错误" }, JsonRequestBehavior.AllowGet);
}
bool ret = true;
string message = "关联成功!";
try
{
ret = _wxSzzyorder.UpdateResIdByWwUserName(resId, userId);
if (ret)
{
//_wxSzzyorder.UpdateIsBoundByResId(resId);
RES_CUSTOMER.BindCustomerQw(resId, userId);
//调用接口
var url = _cache_bl.GetValue_Parameter(Parameter.Core_ZxdService_WebApi);
url = $"{url.Trim('/')}/Api/Extuser/BindExtUser";
var para = new
{
resid = resId,
deptcode = companyCode,
userid = userId,
type = "bind"
};
if (string.IsNullOrWhiteSpace(companyCode))
{
var sysComCode = Utility.GetSettingOrNullByKey("DataClientCode");
para = new
{
resid = resId,
deptcode = sysComCode,
userid = userId,
type = "bind"
};
}
var rep = Utility.PostAjaxData(url, para.ToJson(), Encoding.UTF8);
LogHelper.Info($"返回结果{rep.ToJson()}");
var reqInfo = JsonConvert.DeserializeObject<ApiResult<bool>>(rep);
if (reqInfo.code != 0)
{
message = "关联成功!同步到总部失败!";
LogHelper.Error($"绑定失败" + rep);
}
}
}
catch (Exception e)
{
ret = false;
LogHelper.Error("绑定外部联系人异常:" + e.ToString());
message = "出现错误!";
}
return Json(new { result = ret, message = message }, JsonRequestBehavior.AllowGet);
}
#endregion
public ActionResult CustomerLoginInfo(CustomerInfo info)
{
string loginInfoResId = info == null ? "" : info.CustomerId;
return View((object)loginInfoResId);
}
public ActionResult CustomerOtherInfo(CustomerInfo info)
{
RES_CUSTOMER_Extend customer = new RES_CUSTOMER_Extend();
//try
//{
if (info != null && !string.IsNullOrEmpty(info.CustomerId))
{
var getCustomer = customer_Q.GetModel(info.CustomerId.Trim());
var amounttype = cacheQ.GetList_SubComType(ComType.CustomerZJL).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.AMOUNTTYPEID);
var customertype = cacheQ.GetList_SubComType(ComType.CustomerType).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.CUSTOMERTYPEID);
var jobtype = cacheQ.GetList_SubComType(ComType.CustomerZY).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.JOBTYPEID);
var OperationType = cacheQ.GetList_SubComType(ComType.CustomerCZXG).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.OPERATIONTYPE);
var customerfrom = cacheQ.GetList_SubComType(ComType.CustomerFrom).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.CUSTOMERFROM);
customer.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL();
if (getCustomer != null)
{
var province = provinceQ.GetProvince(getCustomer.map_PROVINCEID == null ? 1 : getCustomer.map_PROVINCEID.Value);
var city = cityQ.GetCity(getCustomer.map_CITY == null ? 1 : getCustomer.map_CITY.Value);
customer.map_ResId = getCustomer.map_ResId;
customer.map_CACCOUNT = getCustomer.RES_CUSTOMERDETAIL.CACCOUNT;
customer.map_CTIME = getCustomer.map_CTIME;
customer.map_CNAME = getCustomer.map_CNAME;
customer.map_GENDER = getCustomer.map_GENDER == "m" ? "男" : "女";
customer.map_EMAIL = getCustomer.map_EMAIL;
customer.map_MSN = getCustomer.map_MSN;
customer.map_FAX = getCustomer.map_FAX;
customer.map_ADDRESS = getCustomer.map_ADDRESS;
customer.map_AMOUNTTYPEID = amounttype == null ? "" : amounttype.SUBTYPENAME;
customer.map_CUSTOMERTYPEID = customertype == null ? "" : customertype.SUBTYPENAME;
customer.map_JOBTYPEID = jobtype == null ? "" : jobtype.SUBTYPENAME;
customer.map_OPERATIONTYPE = OperationType == null ? "" : OperationType.SUBTYPENAME;
customer.map_CUSTOMERFROM = customerfrom == null ? "" : customerfrom.SUBTYPENAME;
customer.map_PROVINCE = province == null ? "" : province.NAME;
customer.map_GETCITY = city == null ? "" : city.NAME;
}
}
//}
//catch (Exception ex)
//{
// LogHelper.Error(ex.Message);
//}
return View(customer);
}
public ActionResult RelationCustomerUC(CustomerInfo info)
{
List<CSVR_RELATIONCUSTOMER> list = new List<CSVR_RELATIONCUSTOMER>();
try
{
if (info != null && !string.IsNullOrEmpty(info.CustomerId))
{
list = relationcustomer.GetRelationByResId(info.CustomerId);
}
}
catch (Exception ex)
{
LogHelper.Error(ex.Message);
}
// ViewBag.List = list;
ViewBag.RelationResId = info.CustomerId;
return View(list);
}
public ActionResult CustomerInfo(CustomerInfo info)
{
try
{
RES_CUSTOMER_Extend customer = new RES_CUSTOMER_Extend();
//try
//{
if (info != null && !string.IsNullOrEmpty(info.CustomerId))
{
var getCustomer = customer_Q.GetModel(info.CustomerId.Trim());
var amounttype = cacheQ.GetList_SubComType(ComType.CustomerZJL).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.AMOUNTTYPEID);
var customertype = cacheQ.GetList_SubComType(ComType.CustomerType).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.CUSTOMERTYPEID);
var jobtype = cacheQ.GetList_SubComType(ComType.CustomerZY).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.JOBTYPEID);
var OperationType = cacheQ.GetList_SubComType(ComType.CustomerCZXG).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.RES_CUSTOMERDETAIL.OPERATIONTYPE);
var customerfrom = cacheQ.GetList_SubComType(ComType.CustomerFrom).FirstOrDefault(p => p.SUBTYPECODE == getCustomer.CUSTOMERFROM);
customer.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL();
if (getCustomer != null)
{
var province = provinceQ.GetProvince(getCustomer.map_PROVINCEID == null ? 1 : getCustomer.map_PROVINCEID.Value);
var city = cityQ.GetCity(getCustomer.map_CITY == null ? 1 : getCustomer.map_CITY.Value);
customer.map_ResId = getCustomer.map_ResId;
customer.map_CACCOUNT = getCustomer.RES_CUSTOMERDETAIL.CACCOUNT;
customer.map_CTIME = getCustomer.map_CTIME;
customer.map_CNAME = getCustomer.RES_CUSTOMERDETAIL.CNAME;
customer.map_GENDER = getCustomer.map_GENDER == "m" ? "男" : "女";
customer.map_EMAIL = getCustomer.RES_CUSTOMERDETAIL.EMAIL;
customer.map_MSN = getCustomer.RES_CUSTOMERDETAIL.MSN;
customer.map_FAX = getCustomer.RES_CUSTOMERDETAIL.FAX;
customer.map_ADDRESS = getCustomer.RES_CUSTOMERDETAIL.ADDRESS;
customer.map_AMOUNTTYPEID = amounttype == null ? "" : amounttype.SUBTYPENAME;
customer.map_CUSTOMERTYPEID = customertype == null ? "" : customertype.SUBTYPENAME;
customer.map_JOBTYPEID = jobtype == null ? "" : jobtype.SUBTYPENAME;
customer.map_OPERATIONTYPE = OperationType == null ? "" : OperationType.SUBTYPENAME;
customer.map_PROVINCE = province == null ? "" : province.NAME;
customer.map_GETCITY = city == null ? "" : city.NAME;
customer.map_CUSTOMERFROM = customer.map_CUSTOMERFROM;
}
}
//}
//catch (Exception ex)
//{
// LogHelper.Error(ex.Message);
//}
return View(customer);
}
catch (Exception ex)
{
LogHelper.Error(ex);
return View();
}
}
#endregion
#region
public ViewResult CustomerAllMemoUC(CustomerInfo info)
{
var deptCode = Utility.GetSettingOrNullByKey("DataClientCode");
ViewBag.DeptCode = deptCode;
return View(info);
}
public JsonResult GetMemoQueryHtml(Pager pager, string ResId, string MemoType, decimal? pageType, string IsValid)
{
string isShowMobileOfContent = cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_IsShowMobileOfContent);
List<ORD_MemoQuery> list = new List<ORD_MemoQuery>();
#region
switch (Convert.ToInt32(MemoType))
{
case (int)WX.CRM.Model.Enum.EnumMemoType.:
list = ord_memo_Q.GetMemoListByResId(ref pager, ResId, WX.CRM.Model.Enum.EnumMemoType., IsValid);
break;
case (int)WX.CRM.Model.Enum.EnumMemoType.:
list = ord_memo_Q.GetMemoListByResId(ref pager, ResId, WX.CRM.Model.Enum.EnumMemoType., IsValid);
break;
case (int)WX.CRM.Model.Enum.EnumMemoType.:
list = ord_memo_Q.GetMemoListByResId(ref pager, ResId, WX.CRM.Model.Enum.EnumMemoType., IsValid);
break;
case (int)WX.CRM.Model.Enum.EnumMemoType.:
list = ord_memo_Q.GetMemoListByResId(ref pager, ResId, WX.CRM.Model.Enum.EnumMemoType., IsValid);
break;
case 7:
list = ord_memo_Q.GetAllMemoListByResId(int.MaxValue, ResId, IsValid);//获取所有工单
//list = redisFactory.LoadMemo(ResId, IsValid);
break;
}
#endregion
Table table = new Table("", true);
table.gridPager = pager;
ICACHE_Q ui = DataCacheHelper.GetCache();
List<ORD_MEMOTYPE> memoTypeList = ui.GetList_MemoType(0);//缓存读取 工单大类数据
List<ORD_MEMOSUBTYPE> memoSubTypeList = ui.GetList_MemoSubType(0);//缓存读取 获取所有工单小类数据
List<ORD_MEMOSTYLE> styleList = DataCacheHelper.GetCache().GetList_MemoStyle();
Dictionary<int, string> Memo_Type = OperationUtil.GetDicFromEnum<WX.CRM.Model.Enum.EnumMemoType>();
var deptCode = Utility.GetSettingOrNullByKey("DataClientCode");
if (deptCode == "QBJZ")
{
Memo_Type = OperationUtil.GetDicFromEnum<WX.CRM.Model.Enum.EnumMemoType_B1>();
}
ORD_MEMOTYPE memotype = null;
ORD_MEMOSUBTYPE memosubType = null;
#region
// 六合、内容需求
var needPrivateMemoCompanyCodes = cacheQ.GetValue_Parameter(Parameter.NeedPrivateMemoCompanyCodes);
if (!string.IsNullOrEmpty(needPrivateMemoCompanyCodes) && needPrivateMemoCompanyCodes.Split(',').Contains(companyCode))
{
var roles = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
if (!roles.Contains("[CKGD]"))
{
list = list.Where(x => x.INNERUSERID == UserId).ToList();
ViewBag.IsShow = false;
}
else
{
ViewBag.IsShow = true;
}
}
else
{
ViewBag.IsShow = true;
}
#endregion
foreach (ORD_MemoQuery model in list)
{
table.AddCol(double.Parse(model.MEMOID.ToString()));
if (MemoType == "7")
{
table.AddCol(Memo_Type[Convert.ToInt32(model.MEMO_TYPE)]);
table.AddCol(Handler.MethodRsource.GetMemoBusinessName(Convert.ToInt32(model.MEMO_TYPE), Convert.ToInt32(model.BUSINESSID)));
}
memotype = memoTypeList.FirstOrDefault(m => m.TYPEID == model.MEMOTYPEID);
table.AddCol(memotype == null ? "" : memotype.TYPENAME);
memosubType = memoSubTypeList.FirstOrDefault(m => m.SUBTYPEID == model.MEMOSUBTYPEID);
table.AddCol(memosubType == null ? "" : memosubType.TYPENAME);
if (model.ExtMemoId.HasValue)
{
model.STRCONTENT = model.STRCONTENT + string.Format("<a style='padding-left:20px' href='javascript:void(0)' onclick='mmore({0})'>更多</a>", model.ExtMemoId.Value);
}
if (model.STRCONTENT.Contains("证监会") || model.STRCONTENT.Contains("投诉监管"))
{
model.STRCONTENT = model.STRCONTENT.Replace("证监会", "<span class='markClass'>证监会</span>").Replace("投诉监管", "<span class='markClass'>投诉监管</span>");
}
if (pageType != null)//查看更多工单的,显示全部工单内容
{
if (!string.IsNullOrEmpty(isShowMobileOfContent) && isShowMobileOfContent == "1")
{
table.AddCol(model.STRCONTENT);
}
else
{
table.AddCol(Utility.ReplaceMobile(model.STRCONTENT));
}
}
else
{
if (!string.IsNullOrEmpty(isShowMobileOfContent) && isShowMobileOfContent == "1")
{
table.AddCol(model.STRCONTENT, 20, model.STRCONTENT);
}
else
{
table.AddCol(Utility.ReplaceMobile(model.STRCONTENT), 20, Utility.ReplaceMobile(model.STRCONTENT));
}
}
table.AddCol(InnerUserHelper.Instance.EidAndName(model.INNERUSERID));
if (model.CTIME.HasValue)
table.AddCol(model.CTIME.Value.ToString("yyyy-MM-dd") + "<br/>" + model.CTIME.Value.ToString("HH:mm:ss"));
else
table.AddCol("");
table.AddCol(GetTimeSpace(model.CALLTIME, model.CALLTIMEEND));
table.AddCol(string.Format("<a href='javascript:void(0);' onclick='javascript: ReroldCallTime({0});' >修正</a>", model.MEMOID));
table.AddRow(GetStyle(styleList, model.MEMOSTYLEID));
}
if (ViewBag.IsShow == false)
{
for (var i = 0; i < 10; i++)
{
table.AddCol("*");
}
table.AddRow(GetStyle(styleList, null));
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#region
public JsonResult GetMessageHtml(Pager pg, string ResId, int? rn, DateTime? stime, DateTime? etime)
{
Table table = new Table("", true);
table.gridPager = pg;
var ds = batchMsg_Q.GetMessageList(ref pg, ResId, rn, stime, etime);
foreach (System.Data.DataRow item in ds.Tables[0].Rows)
{
table.AddCol(item["RESID"]);
table.AddCol(string.IsNullOrEmpty(item["EID"].ToString()) ? "" : item["EID"].ToString() + " - " + item["UNAME"].ToString());
//table.AddCol(PhoneHelper.FormatPhoneUserNameContent(item["MESSAGE"].ToString()));
if (item["SUBTYPECODE"] == null)
table.AddCol(PhoneHelper.FormatPhoneUserNameContent(item["MESSAGE"].ToString(), ""));
else
table.AddCol(PhoneHelper.FormatPhoneUserNameContent(item["MESSAGE"].ToString(), item["SUBTYPECODE"].ToString()));
table.AddCol(item["SENDTIME"]);
table.AddRow();
}
var json = new
{
totalPages = pg.totalPages,
totalRows = pg.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion
#region
public JsonResult UpdateNoCallTime(string MemoId)
{
bool result = false;
try
{
decimal memoid = Convert.ToDecimal(MemoId);
CSVR_CALLRECORD_BL.UpdateCallTime(memoid);
result = true;
}
catch (Exception ex)
{
result = false;
}
var json = new
{
result = result
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public bool UpdateNoTime(List<MemoIds> memoIds)
{
try
{
string Strmemoids = "";
if (memoIds.Count > 0)
{
foreach (var item in memoIds)
{
Strmemoids += item.MemoId + ",";
}
}
Strmemoids = Strmemoids.Substring(0, Strmemoids.Length - 1);
CSVR_CALLRECORD_BL.UpdateNoTimeBymemoids(Strmemoids);
return true;
}
catch
{
return false;
}
}
public class MemoIds
{
public Nullable<decimal> MemoId { get; set; }
public Nullable<decimal> UserEid { get; set; }
}
#endregion
private string GetStyle(List<ORD_MEMOSTYLE> styleList, decimal? id)
{
if (id == null)
return "style='color:black;'";
ORD_MEMOSTYLE style = styleList.Where(m => m.STYLEID == id.Value).FirstOrDefault();
if (style == null)
return "style='color:black;'";
else
return string.Format("style='color:{0};'", style.STYLECODE);
}
private string GetTimeSpace(DateTime? time1, DateTime? time2)
{
string timeStr = "";
if (time1 == null)
timeStr += "--:--:--";
else
timeStr += time1.Value.ToString("HH:mm:ss");
timeStr += "~<br/>";
if (time2 == null)
timeStr += "--:--:--";
else
timeStr += time2.Value.ToString("HH:mm:ss");
return timeStr;
}
#endregion
#region
public ViewResult SaleDptAllMemoUC(CustomerInfo info)
{
return View(info);
}
public JsonResult GetSaleDeptMemoQueryHtml(Pager pager, string ResId, string MemoType, decimal? pageType, string IsValid)
{
string isShowMobileOfContent = cacheQ.GetValue_Parameter(Model.Enum.Parameter.Sys_IsShowMobileOfContent);
List<ORD_MemoQuery> list = ord_memo_Q.GetTGAllMemoListByResId(int.MaxValue, ResId, IsValid);//获取所有工单
Table table = new Table("", true);
table.gridPager = pager;
ICACHE_Q ui = DataCacheHelper.GetCache();
//List<ORD_MEMOTYPE> memoTypeList = ui.GetList_MemoType(0);//缓存读取 工单大类数据
//List<ORD_MEMOSUBTYPE> memoSubTypeList = ui.GetList_MemoSubType(0);//缓存读取 获取所有工单小类数据
List<ORD_MEMOSTYLE> styleList = DataCacheHelper.GetCache().GetList_MemoStyle();
Dictionary<int, string> Memo_Type = OperationUtil.GetDicFromEnum<WX.CRM.Model.Enum.EnumMemoType>();
//ORD_MEMOTYPE memotype = null;
//ORD_MEMOSUBTYPE memosubType = null;
foreach (ORD_MemoQuery model in list)
{
table.AddCol(model.MEMOID);
table.AddCol(Memo_Type[Convert.ToInt32(model.MEMO_TYPE)]);
table.AddCol(Handler.MethodRsource.GetMemoBusinessName(Convert.ToInt32(model.MEMO_TYPE), Convert.ToInt32(model.BUSINESSID)));
//memotype = memoTypeList.FirstOrDefault(m => m.TYPEID == model.MEMOTYPEID);
//table.AddCol(memotype == null ? "" : memotype.TYPENAME);
//memosubType = memoSubTypeList.FirstOrDefault(m => m.SUBTYPEID == model.MEMOSUBTYPEID);
//table.AddCol(memosubType == null ? "" : memosubType.TYPENAME);
if (pageType != null)//查看更多工单的,显示全部工单内容
{
if (!string.IsNullOrEmpty(isShowMobileOfContent) && isShowMobileOfContent == "1")
{
table.AddCol(model.STRCONTENT);
}
else
{
table.AddCol(Utility.ReplaceMobile(model.STRCONTENT));
}
}
else
{
if (!string.IsNullOrEmpty(isShowMobileOfContent) && isShowMobileOfContent == "1")
{
table.AddCol(model.STRCONTENT, 20, model.STRCONTENT);
}
else
{
table.AddCol(Utility.ReplaceMobile(model.STRCONTENT), 20, Utility.ReplaceMobile(model.STRCONTENT));
}
}
//table.AddCol(InnerUserHelper.Instance.EidAndName(model.INNERUSERID));
table.AddCol(model.TGsalesName);
if (model.CTIME.HasValue)
table.AddCol(model.CTIME.Value.ToString("yyyy-MM-dd") + "<br/>" + model.CTIME.Value.ToString("HH:mm:ss"));
else
table.AddCol("");
table.AddCol(GetTimeSpace(model.CALLTIME, model.CALLTIMEEND));
table.AddRow(GetStyle(styleList, model.MEMOSTYLEID));
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
#endregion
#region
public ViewResult CustomerOrderUC(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View();
}
public ViewResult CustomerModuleUC()
{
return View();
}
#endregion
#region
public ViewResult CustomerLevel2OrderUC(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
var coreUrl = cache_BL.GetValue_Parameter(Parameter.zxd_core_webapi_url);
ViewBag.Core_ZxdCoreUrl = coreUrl.Trim('/');
return View();
}
#endregion
#region
public ViewResult CustomerActivityUC(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View();
}
#endregion
#region
public ViewResult CustomerWxUserUC(CustomerInfo info)
{
DataTable tab = null;
try
{
ViewBag.WorkwxEid = Eid;
string roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);//获取员工角色
ViewBag.RoleCodes = roleCodes;
tab = wxrcontact.GetChatUserByResId(info.CustomerId);
}
catch (Exception ex)
{
WX.CRM.Common.LogHelper.Error("【CustomerUCController.CustomerWxUserUC()】" + ex.Message + ex.StackTrace);
}
ViewBag.modelList = tab;
return View();
}
#endregion
#region 线
public ViewResult SalesLeadsUC(CustomerInfo info)
{
ViewBag.resid = info.CustomerId;
return View();
}
public JsonResult GetSalesLead(string resid)
{
var appid = Utility.GetSettingOrNullByKey("appid");
var appSecret = Utility.GetSettingOrNullByKey("appSecret");
List<saleslead> saleslead = new List<saleslead>();
var salesleadDto = new List<saledsleadDto>();
var url = cacheQ.GetValue_Parameter("salesLeadUrl");
if (string.IsNullOrWhiteSpace(url))
{
//url = $"http://sc.soft.dn8188.com/dev.html";
url = $"https://inapp.hc.dn8188.com/saleclue/detail.html";
}
try
{
var userlist = _wwExtUserResId.GetList(p => p.RESID == resid);
foreach (var user in userlist)
{
if (user != null)
{
var extuser = _wwExtUser.Get(p => p.USERID == user.USERID);
if (extuser != null)
{
var exinfo = extuser.EXINFO.ToObject<WwExtUserView>();
exinfo.corpid = extuser.CORPID;
string name = "企业微信";
if (exinfo.external_contact != null)
{
name = exinfo.external_contact.name;
saleslead.Add(new Model.DTO.saleslead() { linkUrl = url, name = name, appid = exinfo.corpid, appuserid = exinfo.external_contact.external_userid });
}
}
}
}
List<SOFT_USER> list = customeruser_q.GetListByCustomerId(resid);
string deptId = "";
var lineList = new BAS_BUSSINESSLINE_BL().GetBusinessLineByRoot(UserId);
if (lineList.Count > 0)
{
deptId = string.Join(",", lineList.Select(n => Convert.ToString(n.BUSINESSID)).Distinct().ToList());
}
if (string.IsNullOrWhiteSpace(deptId))
{
BAS_PARAMETER deptSetting = _BAS_PARAMETER_Q.GetModel_Patameter("SalesLeadsDeptSetting");
if (deptSetting != null && !string.IsNullOrEmpty(deptSetting.PARAVALUE))
{
try
{
var saledeptList = deptSetting.PARAVALUE.ToObject<List<SalesLeadSetting>>();
deptId = saledeptList.FirstOrDefault(n => n.DeptCode == saleDeptCode)?.DeptId;
}
catch (Exception e)
{
LogHelper.Error(e.ToString());
}
}
}
foreach (var item in list)
{
string name = PhoneHelper.FormatPhoneUserName(item.USERNAME);
saleslead.Add(new Model.DTO.saleslead() { linkUrl = url, name = name, appid = "com.dongniu", appuserid = item.USERNAME, deptid = deptId, eid = Eid.ToString() });
}
BAS_PARAMETER model = _BAS_PARAMETER_Q.GetModel_Patameter("ISVR_Saleclus_Get");
if (model != null && !string.IsNullOrEmpty(model.PARAVALUE))
{
try
{
string httpurl = model.PARAVALUE;
List<RES_CUSTOMER> customerlist = customer_Q.GetList_CustomerByResid(resid);
IList<string> mm = _resource.GetNumberByResIdList(customerlist.Select(m => m.RESID).ToList());
mm = mm.Where(n => !string.IsNullOrEmpty(n)).ToList();
var objecb = new { mobiles = mm };
string retmss = Utility.PostAjaxData(httpurl, JsonHelper.ObjDivertToJson(objecb), Encoding.UTF8);
var result = JsonHelper.JsonDivertToObj<SaleClusResult>(retmss);
if (result.iRet == 0 && result.list.Count > 0)
{
foreach (var item in result.list)
{
var en = saleslead.FirstOrDefault(m => m.appuserid == item.appuserid && m.appid == item.appid);
if (en != null)
{
continue;
}
string myname = item.appuserid;
if (item.appuserid.Length > 10)
{
myname = item.appuserid.Substring(0, 10) + "*****";
}
saleslead.Add(new Model.DTO.saleslead() { linkUrl = url, name = myname, appid = item.appid, appuserid = item.appuserid, deptid = deptId, eid = Eid.ToString() });
}
}
}
catch (Exception e)
{
LogHelper.Error(e.ToString());
}
}
// 加密数据进content
WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper();
var content = "";
var j = "";
var ext_flag = DateTimeTool.ConvertDateTimeLong(DateTime.Now);
saleslead.ForEach(s =>
{
//content = "";
//j = "";
//j = JsonConvert.SerializeObject(new saledsleadDesDto { appid = s.appid, appuserid = s.appuserid, deptid = s.deptid, eid = s.eid, ext_flag = ext_flag });
j = JsonConvert.SerializeObject(new { account = appid, password = appSecret, s.appid, s.appuserid, s.eid, time = ext_flag });
content = HttpUtility.UrlEncode(sHelper.encyptData("saleclue", j));
salesleadDto.Add(new saledsleadDto { linkUrl = s.linkUrl, name = s.name, content = content });
});
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new { result = false, message = "错误:" + ex.ToString() }, JsonRequestBehavior.AllowGet);
}
return Json(new { result = true, message = "succed", retmsg = salesleadDto }, JsonRequestBehavior.AllowGet);
}
public JsonResult GetSalesLeadUrl(string appid, string appuserid)
{
var account = Utility.GetSettingOrNullByKey("appid");
var appSecret = Utility.GetSettingOrNullByKey("appSecret");
WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper();
var ext_flag = DateTimeTool.ConvertDateTimeLong(DateTime.Now);
//var model = JsonConvert.SerializeObject(new saledsleadDesDto { appid = appid, appuserid = appuserid, eid = Eid.ToString(), ext_flag = ext_flag });
var model = JsonConvert.SerializeObject(new { account, password = appSecret, appid, appuserid, eid = Eid.ToString(), time = ext_flag });
var content = HttpUtility.UrlEncode(sHelper.encyptData("saleclue", model));
//var url = "http://sc.soft.dn8188.com/dev.html?content=" + content + "&clientid=WK_EXT";
var url = "https://inapp.hc.dn8188.com/saleclue/detail.html?content=" + content;
return Json(new { result = true, message = "succed", retmsg = url }, JsonRequestBehavior.AllowGet);
}
public JsonResult GetExt_flag()
{
var ext_flag = DateTimeTool.ConvertDateTimeLong(DateTime.Now);
var sourceString = Utility.Encrypt(ext_flag.ToString());
var retmsg = HttpUtility.UrlEncode(sourceString, Encoding.UTF8);
return Json(new { result = true, message = "succed", retmsg = retmsg }, JsonRequestBehavior.AllowGet);
}
#endregion 线
#region
public ViewResult CustomerQwUserUC(CustomerInfo info)
{
DataTable tab = null;
try
{
ViewBag.WorkwxEid = Eid;
string roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);//获取员工角色
ViewBag.RoleCodes = roleCodes;
tab = wxrcontact.GetChatQwByResId(info.CustomerId);
}
catch (Exception ex)
{
WX.CRM.Common.LogHelper.Error("【CustomerUCController.CustomerQwUserUC()】" + ex.Message + ex.StackTrace);
}
ViewBag.modelList = tab;
return View();
}
#endregion
#region
public ViewResult CustomerScreenRecord(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View();
}
#endregion
#region
public ViewResult CustomerZxOrder(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
ViewBag.UserRoles = userRoleCodes;
return View(info);
}
public JsonResult GetOrderListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
string[] resids = customer_Q.GetAllResidByCustomerId(resId);
List<string> resIds = redisFactory.GetList_Rescustomer(resids, resId).Select(s => s.RESID).ToList();
var list = _wxSzzyorder.GetList(p => resIds.Contains(p.RESID));
//var list2 = _wxSzzyorder2.GetList(p => resIds.Contains(p.RESID));
foreach (WX_SZZYORDER model in list)
{
table.AddCol(model.ORDERID);
table.AddCol(string.Format("<font style='color:red;'>{0}</font>", model.SZZYORDERID.ToString()));
table.AddCol(model.SUBPRODUCTNAME);
table.AddCol(getOrderTypeStr(model.ORDERTYPE));
table.AddCol(getOrderStatusStr(model.ORDERSTATUS));
table.AddCol(model.CTIME);
table.AddCol(model.OTIME);
table.AddCol(model.NEEDPAY);
table.AddCol(model.FINALPAY);
table.AddCol(model.ARRIVALPAY);
table.AddCol(model.ARRIVALTIME);
table.AddCol(model.TEAMSERVE == 1 ? "<font style='color:red;font-weight:700'>分公司</font>" : "<font style='color:red;font-weight:700'>总公司</font>");
var link = string.Format("<a href = 'javascript:GetWxPayInfo({0})'> 银行信息 </a> {1}", model.ORDERID, model.ISOPEN == 1 ? string.Format("<a href = 'javascript:RenewOrder({0})'> 续费 </a>", model.ORDERID) : "");
table.AddCol(link);
table.AddRow("onclick='selectRow(this)'");
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public JsonResult GetPrepaymentListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
string[] resids = customer_Q.GetAllResidByCustomerId(resId);
List<string> resIds = redisFactory.GetList_Rescustomer(resids, resId).Select(s => s.RESID).ToList();
var list = new List<SzzyPrepaymentResultData>();
if (resIds != null)
{
}
foreach (SzzyPrepaymentResultData model in list)
{
table.AddCol(model.prepayment_id);
table.AddCol(model.realname);
table.AddCol(model.to_bank_name);
table.AddCol(model.remit_time);
table.AddCol(model.amount);
table.AddCol(getPrepaymentStatusStr(model.status));
table.AddCol(model.order_id);
table.AddCol(model.ctime);
table.AddCol(model.expire_days);
table.AddRow();
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public ViewResult CustomerCallRecord(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
CACHE_BL cache_BL = new CACHE_BL();
var audioUrl = cache_BL.GetValue_Parameter(Parameter.Core_HgAudioUrl);
ViewBag.audioUrl = audioUrl;
return View(info);
}
public JsonResult GetRecordListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
Pager pg = new Pager { page = 1, rows = 150 };
var list = CSVR_CALLRECORD_BL.GetCallRecord(ref pg, new Model.MAP.QueryUserComboDto(null, null, null, null), null, null, null, null, resId, null, null, -1, -1);
List<AiAudioList> res = new List<AiAudioList>();
if (list != null && list.Tables[0] != null)
{
foreach (DataRow item in list.Tables[0].Rows)
{
var strIsTran = "";
AiAudioList model = new AiAudioList
{
RECORDID = item["RECORDID"] == DBNull.Value ? "" : item["RECORDID"].ToString(),
strIsTran = strIsTran,
TIMELENGTH = item["TIMELENGTH"] == DBNull.Value ? "" : item["TIMELENGTH"].ToString(),
UNAME = item["UNAME"] + "" + item["SALESEID"],
FileName = item["FileName"] == DBNull.Value ? "" : item["FileName"].ToString(),
ServerID = item["ServerID"] == DBNull.Value ? "" : item["ServerID"].ToString(),
OUTDEPT = item["OUTDEPT"] == DBNull.Value ? "" : item["OUTDEPT"].ToString()
};
if (item["ISTRAN"].ToString() == "1")
{
strIsTran = "(转接)";
}
if (item["CALLTYPE"].ToString() == "1")//呼出
{
model.strIsTran = "呼出" + strIsTran;
model.SERVICENUMBER = item["SERVICENUMBER"].ToString();
model.TELNUMBERLAST4 = item["TELNUMBERLAST4"].ToString();
}
else
{
model.strIsTran = "呼入" + strIsTran;
model.SERVICENUMBER = item["TELNUMBERLAST4"].ToString();
model.TELNUMBERLAST4 = item["SERVICENUMBER"].ToString();
}
if (item["TIMESTART"] != DBNull.Value)
{
model.TIMESTART = Convert.ToDateTime(item["TIMESTART"]);
}
if (item["TIMEEND"] != DBNull.Value)
{
model.TIMEEND = Convert.ToDateTime(item["TIMEEND"]);
}
model.isAiCall = false;
res.Add(model);
}
}
try
{
CACHE_BL cache_BL = new CACHE_BL();
var url = cache_BL.GetValue_Parameter(Parameter.Core_ZxdService_GetAiAudioRecord);
var para = "page=1&limit=150&resId=" + resId;
var retmsg = Utility.PostData(url + "?" + para, Encoding.UTF8);
var retmessage = JsonConvert.DeserializeObject<AiAudioRecordDto>(retmsg);
var aiAudioList = retmessage.retmsg;
foreach (var audio in aiAudioList)
{
res.Add(new AiAudioList
{
RECORDID = audio.Id.ToString(),
strIsTran = "呼出",
SERVICENUMBER = audio.Robot,
TELNUMBERLAST4 = audio.Phone,
TIMELENGTH = audio.SvcTime.ToString(),
TIMESTART = audio.StartTime,
TIMEEND = audio.EndTime,
UNAME = "机器人坐席",
FileName = audio.FileName
});
}
}
catch (Exception ex)
{
LogHelper.Error("获取Ai录音错误" + ex.Message);
}
res = res.OrderByDescending(n => n.TIMESTART).Take(150).ToList();
WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper();
//foreach (var item in res)
for (var i = 0; i < res.Count(); i++)
{
var item = res[i];
table.AddCol(item.RECORDID);
table.AddCol(item.strIsTran);
table.AddCol(item.SERVICENUMBER);//主叫
table.AddCol(item.TELNUMBERLAST4);//被叫
table.AddCol(item.TIMELENGTH);
table.AddCol(item.TIMESTART);
table.AddCol(item.TIMEEND);
table.AddCol(item.UNAME);
if (!item.isAiCall)
{
string cti;
string outdept = string.Empty;
if (item.OUTDEPT != "")
{
outdept = item.OUTDEPT;
}
string playurl = _getCallRecordUrl(item.ServerID.ToString(), item.FileName, outdept, out cti);
var playcrl = string.Format("<input id=\"BtnPlayer\" type=\"button\" value=\" 播 放 \" onclick=\"PalyRecord('{0}','DivPlayer{1}','{2}',{3})\" />", playurl, item.RECORDID, cti == null ? "" : cti, Convert.ToInt64(item.RECORDID));
playcrl += string.Format("<div id=\"DivPlayer{0}\"></div><input type=\"hidden\" id=\"hidRecordUrl\" value=\"{1}\" />", item.RECORDID, playurl);
table.AddCol(playcrl);
}
else
{
var playcrl = string.Format("<input id=\"BtnPlayer\" type=\"button\" value=\" 播 放 \" onclick=\"PalyAiRecord('{0}')\" />", item.FileName);
var t = sHelper.encyptData("UPWEBSITE", item.RECORDID);
//playcrl += string.Format("<input id=\"BtnPlayer\" type=\"button\" value=\" 查 看 \" onclick=\"AiAudioDetail('{0}')\" />", sHelper.decyptData("UPWEBSITE", item.RECORDID));
//playcrl += string.Format("<input id=\"BtnPlayer\" type=\"button\" value=\" 查 看 \" onclick=\"AiAudioDetail('{0}')\" />", t);
table.AddCol(playcrl);
}
table.AddRow();
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
private string _getCallRecordUrl(string _ServerID, string _FileName, out string cti)
{
var playurl = "";
cti = "";
var _IAD_localhostCallRecord = _BAS_PARAMETER_Q.GetModel_Patameter("ICSR_IAD_localhostCallRecord");
if (null != _IAD_localhostCallRecord)
{
var FuturesRecordServerUrl = _IAD_localhostCallRecord.PARAVALUE;
playurl = FuturesRecordServerUrl + "?serverID=" + _ServerID + "&file=" + _FileName.Replace("\\", "/");
cti = _CSVR_CALLRECORD_Q.Sys_Environment_CTI_VER();
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + "?file=" + _FileName.Replace("\\", "/");
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
var shjctiinterface = Utility.GetSettingByKey("shj");
playurl = shjctiinterface + "?action=record_download&filename=/var/spool/asterisk/monitor/" + _FileName.Replace("\\", "/");
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + "?file=" + _FileName;
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + _FileName;
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.new).ToString())
{
_IAD_localhostCallRecord = _BAS_PARAMETER_Q.GetModel_Patameter("ICSR_IAD_localhostCallRecord_AX");
var filename = _FileName;
if (null != _IAD_localhostCallRecord)
{
playurl = _IAD_localhostCallRecord.PARAVALUE + (filename.StartsWith("UP") ? "/home/" + filename : filename);
playurl = playurl.Replace("\\", "/");
}
}
}
return playurl;
}
private string _getCallRecordUrl(string _ServerID, string _FileName, string outdept, out string cti)
{
var playurl = "";
cti = "";
var _IAD_localhostCallRecord = _BAS_PARAMETER_Q.GetModel_Patameter("ICSR_IAD_localhostCallRecord");
if (null != _IAD_localhostCallRecord)
{
var FuturesRecordServerUrl = _IAD_localhostCallRecord.PARAVALUE;
playurl = FuturesRecordServerUrl + "?serverID=" + _ServerID + "&file=" + _FileName.Replace("\\", "/");
cti = _CSVR_CALLRECORD_Q.Sys_Environment_CTI_VER();
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + "?file=" + _FileName.Replace("\\", "/");
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
var shjctiinterface = Utility.GetSettingByKey("shj");
playurl = shjctiinterface + "?action=record_download&filename=/var/spool/asterisk/monitor/" + _FileName.Replace("\\", "/");
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + "?file=" + _FileName;
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.).ToString())
{
playurl = FuturesRecordServerUrl + _FileName;
}
if (cti != null && cti == ((int)WX.CRM.Model.Enum.CTI_VER.new).ToString())
{
_IAD_localhostCallRecord = _BAS_PARAMETER_Q.GetModel_Patameter("ICSR_IAD_localhostCallRecord_AX" + (string.IsNullOrEmpty(outdept) ? "" : ("_" + outdept)));
var filename = _FileName;
if (null != _IAD_localhostCallRecord)
{
playurl = _IAD_localhostCallRecord.PARAVALUE + (filename.StartsWith("UP") ? "/home/" + filename : filename);
playurl = playurl.Replace("\\", "/");
}
}
}
return playurl;
}
public ViewResult CustomerTDOrder(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View(info);
}
public ViewResult CustomerJZOrder(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View(info);
}
public ViewResult CustomerCommonOrder(CustomerInfo info)
{
ViewBag.CustomerId = info.CustomerId;
return View(info);
}
public JsonResult GetTDOrderListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
//string[] resids = customer_Q.GetAllResidByCustomerId(customerId);
//List<string> resIds = redisFactory.GetList_Rescustomer(resids, customerId).Select(s => s.RESID).ToList();
//var list = _wxSzzyorder.GetList(p => p.RESID == resId);
string[] resids = customer_Q.GetAllResidByCustomerId(resId);
List<string> resIds = redisFactory.GetList_Rescustomer(resids, resId).Select(s => s.RESID).ToList();
var list = _wxSzzyorder.GetList(p => resIds.Contains(p.RESID));
foreach (WX_SZZYORDER model in list)
{
table.AddCol(model.ORDERID);
table.AddCol(model.SZZYORDERID);
table.AddCol(model.SUBPRODUCTNAME);
table.AddCol(getOrderTypeStr(model.ORDERTYPE));
table.AddCol(getOrderStatusStr(model.ORDERSTATUS));
table.AddCol(model.CTIME);
table.AddCol(model.OTIME);
table.AddCol(model.NEEDPAY);
table.AddCol(model.FINALPAY);
table.AddCol(model.ARRIVALPAY);
table.AddCol(model.ARRIVALTIME);
table.AddRow("onclick='selectRow(this)'");
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public class userRet
{
public string orderid { set; get; }
public string softwarename { set; get; }
}
public JsonResult GetJZOrderListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
//string[] resids = customer_Q.GetAllResidByCustomerId(customerId);
//List<string> resIds = redisFactory.GetList_Rescustomer(resids, customerId).Select(s => s.RESID).ToList();
//var list = _wxSzzyorder.GetList(p => p.RESID == resId);
string[] resids = customer_Q.GetAllResidByCustomerId(resId);
List<string> resIds = redisFactory.GetList_Rescustomer(resids, resId).Select(s => s.RESID).ToList();
var list = _wxSzzyorder.GetList(p => resIds.Contains(p.RESID)).OrderByDescending(p => p.ORDERID);
//var softuser = _softUserQ.GetUserList_userName(list.Select(m => m.USERNAME).ToArray());
var zxdUsernameList = new List<userRet>();
//根据订单id获取对应的软件用户名
try
{
var orderidList = String.Join(";", list.Select(s => s.ORDERID));
var webapi = _cache_bl.GetValue_Parameter(Parameter.zxd_core_webapi_url);
var zxdurl = $"{webapi}Api/Customer/UsernamesByOrderid";
//var zxdurl = $"http://localhost:5244/Api/Customer/UsernamesByOrderid?orderidList={orderidList}";
var result = Utility.GetData(zxdurl, $"orderidList={orderidList}", Encoding.Default);
zxdUsernameList = result.ToObject<WX.CRM.Common.Employee.ApiResult<List<userRet>>>().data;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
//加密Clientid
string clientid = cacheQ.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_OrderClientIdKey);
if (string.IsNullOrWhiteSpace(clientid))
{
clientid = "UPWEBSITE";
}
//合同配置地址
string url = cacheQ.GetValue_Parameter(Parameter.UserCenter_RiaService_ContractSign);//合同地址
string threeUrl = cacheQ.GetValue_Parameter(Parameter.UserCenter_RiaService_ContractSignThree);//三要素合同地址
foreach (WX_SZZYORDER model in list)
{
var zxdUsername = zxdUsernameList.Find(z => z.orderid == model.ORDERID.ToString());
table.AddCol(model.ORDERID);
table.AddCol(model.SZZYORDERID);
table.AddCol(model.SUBPRODUCTNAME);
table.AddCol(getOrderTypeStr(model.ORDERTYPE));
table.AddCol(zxdUsername != null ? zxdUsername.softwarename : "");
table.AddCol(model.ORDERSTATUSNAME);
table.AddCol(model.CTIME);
table.AddCol(model.OTIME);
table.AddCol(model.NEEDPAY);
//table.AddCol(model.FINALPAY);
table.AddCol(model.ARRIVALPAY);
table.AddCol(model.OPENDAYS);
table.AddCol(model.GIFTDAYS);
table.AddCol(model.GIFTDAYS2);
if (model.ISOPEN == 1)
{
table.AddCol("");
}
else
{
var color = string.Empty;
if (!string.IsNullOrEmpty(model.CONTRACTCODE))
{
color = "color:green;";
if (model.RISKCTRLSTATUS == -1)
{
color = "color:orange";
}
}
//===================合同Url测试===============
//合同生成URL测试
WX_ORDEREXT extorder = wx_OrderExt_BL.GetModel(model.ORDERID);
WX_SZZYSUBPRODUCT product = wx_szzysubproduct.GetModel(model.SUBPRODUCTID.Value);
var json2 = new
{
productName = model.SUBPRODUCTNAME,
period = string.Format("{0}天", model.OPENDAYS),
price = string.Format("{0}元", model.NEEDPAY.Value.ToString("#0.00")),
userId = extorder.SOFTUSERNAME,
productLevel = product?.PRODUCTLEVEL,
productInvestTime = product?.PRODUCTINVESTTIME,
productInvestType = product?.PRODUCTINVESTTYPE,
issupplement = 1,
orderId = model.SZZYORDERID.ToString(),
htid = string.Format("DN{0}", model.SZZYORDERID.ToString())
};
string content = securityHelper.encyptData(clientid, Utility.ConvertToJSON(json2));
string sign = securityHelper.signData(clientid, content);
var htUrl = "";// url + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(content), HttpUtility.UrlEncode(sign), clientid);
var threehtUrl = threeUrl + string.Format("?content={0}&sign={1}&clientId={2}&protocolType=", HttpUtility.UrlEncode(content), HttpUtility.UrlEncode(sign), clientid);
//=============================================
table.AddCol(string.Format("<a style=\"" + color + "\" href=\"javascript:void(0);\" onclick=\"ShowThreeHeTongUrl('{2}')\">获取地址</a><input id=\"{1}\" value=\"{0}\" style=\"display:none\" /><input id=\"{3}\" value=\"{4}\" style=\"display:none\" />", threehtUrl, "h" + model.ORDERID.ToString(), "h" + model.ORDERID.ToString(), "t" + model.ORDERID.ToString(), threehtUrl));
}
table.AddCol(string.Format("<a href='javascript:GetWxPayInfo({0})'> 银行信息 </a>", model.ORDERID));
if (!string.IsNullOrWhiteSpace(model.CONTRACTCODE) && zxdUsername != null)
table.AddCol(string.Format("<a href=\"javascript:void(0);\" onclick=\"ShowRiskInfo('{0}','{1}')\"> 查看 </a>", zxdUsername.softwarename, model.SZZYORDERID));
else
table.AddCol("");
table.AddRow("onclick='selectRow(this)'");
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public JsonResult GetCommonOrderListHtml(string resId, CustomerInfo info)
{
Table table = new Table("", true);
string[] resids = customer_Q.GetAllResidByCustomerId(resId);
List<string> resIds = redisFactory.GetList_Rescustomer(resids, resId).Select(s => s.RESID).ToList();
var list = _wxSzzyorder.GetList(p => resIds.Contains(p.RESID));
foreach (WX_SZZYORDER model in list)
{
table.AddCol(model.ORDERID);
table.AddCol(model.SUBPRODUCTNAME);
table.AddCol(getOrderTypeStr(model.ORDERTYPE));
table.AddCol(getOrderStatusStr(model.ORDERSTATUS));
table.AddCol(model.CTIME);
table.AddCol(model.OTIME);
table.AddCol(model.NEEDPAY);
table.AddCol(model.FINALPAY);
table.AddCol(model.ARRIVALPAY);
table.AddRow("onclick='selectRow(this)'");
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
public JsonResult GiveUp(string resid)
{
try
{
var response = _distribute.GiveUp(resid, UserId);
return Json(new { result = true, msg = response }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return Json(new { result = false, msg = string.Empty }, JsonRequestBehavior.AllowGet);
}
}
public JsonResult GetRiskInfo(string userName, string szzyOrderId)
{
if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(szzyOrderId))
{
//加密Clientid
string clientid = cacheQ.GetValue_Parameter(WX.CRM.Model.Enum.Parameter.Sys_OrderClientIdKey);
if (string.IsNullOrWhiteSpace(clientid))
{
clientid = "UPWEBSITE";
}
var riskinfoUrl = cache_BL.GetValue_Parameter("riskinfo");
if (string.IsNullOrEmpty(riskinfoUrl))
riskinfoUrl = "https://r2.soft.dn8188.com/contract_sign_crm/get_riskinfo";
var bf = "{\"uid\": \"" + userName + "\",\"htid\":\"DN" + szzyOrderId + "\"}";
var hqr = BlowFish.encode(bf);
var para = new { hqr };
var res = Utility.PostAjaxData(riskinfoUrl, para.ToJson(), Encoding.UTF8);
var ret1 = JsonHelper.JsonDivertToObj<RiskInfoDto>(res);
if (ret1.ret == 0)
{
//风险评测页面
string riskcontent = sHelper.encyptData(clientid, Utility.ConvertToJSON(ret1));
string risksign = sHelper.signData(clientid, riskcontent);
var hgUrl = cache_BL.GetValue_Parameter(Parameter.Core_HgAudioUrl);
var a = HttpUtility.UrlEncode(riskcontent);
var b = HttpUtility.UrlEncode(risksign);
string fxpcUrl = string.Format("{0}/Compliance/NewRisk?content={1}&sign={2}&clientId={3}&decode=false",
hgUrl, a, b, clientid);
return Json(new { result = true, url = fxpcUrl }, JsonRequestBehavior.AllowGet);
}
}
return Json(new { result = false, url = "" }, JsonRequestBehavior.AllowGet);
}
private string getOrderTypeStr(decimal? orderType)
{
if (!orderType.HasValue)
return "";
if (orderType == 1)
{
return "普通订单";
}
else if (orderType == 2)
{
return "续费订单";
}
else if (orderType == 3)
{
return "升级订单";
}
else if (orderType == 4)
{
return "换课订单";
}
else
{
return "";
}
}
private string getPrepaymentStatusStr(decimal? status)
{
if (!status.HasValue)
return "";
if (status == 0)
{
return "初始(未确认)";
}
else if (status == 1)
{
return "已确认";
}
else if (status == 2)
{
return "已支付(已用于订单付款)";
}
else if (status == 3)
{
return "已到期(三十天到期)";
}
else if (status == 4)
{
return "已退款";
}
else if (status == 5)
{
return "无效(汇款记录被拒绝)";
}
else
{
return "";
}
}
private string getOrderStatusStr(string orderStatus)
{
if (orderStatus == "0")
{
return string.Format("<font style=\"color:red\">下单失败</span>");
}
else if (orderStatus == "1")
{
return "未开通";
}
else if (orderStatus == "2")
{
return "部分支付";
}
else if (orderStatus == "3")
{
return "已支付";
}
else if (orderStatus == "4")
{
return "已开通";
}
else if (orderStatus == "5")
{
return "已到期";
}
else if (orderStatus == "6")
{
return "已升级";
}
else if (orderStatus == "7")
{
return "已退款";
}
else if (orderStatus == "8")
{
return "已取消";
}
else if (orderStatus == "9")
{
return "已关闭";
}
else if (orderStatus == "10")
{
return "隐藏";
}
else
{
return "";
}
}
#endregion
public class WwExtUserView
{
public bool isSeftUser { get; set; }
public External_Contact external_contact { get; set; }
public List<Follow_User> follow_user { get; set; }
public string corpid { get; set; }
}
public class External_Contact
{
public string external_userid { get; set; }
public string name { get; set; }
//public int type { get; set; }
//public string avatar { get; set; }
}
public class Follow_User
{
public string saleeid { get; set; }
public decimal? eid { get; set; }
public string deptname { get; set; }
public string userid { get; set; }
public string remark { get; set; }
public string description { get; set; }
public long createtime { get; set; }
public string bindtime { get; set; }
public List<string> remark_mobiles { get; set; }
public string uname { get; set; }
}
/// <summary>
/// 销售组部分配置参数
/// </summary>
public class SalesLeadSetting
{
public string DeptCode { get; set; }
public string DeptId { get; set; }
public string DeptName { get; set; }
}
public class AiAudioList
{
public string RECORDID { get; set; }
public string strIsTran { get; set; }
public string SERVICENUMBER { get; set; }
public string TELNUMBERLAST4 { get; set; }
public string TIMELENGTH { get; set; }
public DateTime? TIMESTART { get; set; }
public DateTime? TIMEEND { get; set; }
public string UNAME { get; set; }
public string ServerID { get; set; }
public string FileName { get; set; }
public string OUTDEPT { get; set; }
public bool isAiCall { get; set; } = true;
}
}
}