1722 lines
86 KiB
C#
1722 lines
86 KiB
C#
using CRM.Core.DTO;
|
||
using CRM.Core.DTO.Res;
|
||
using Newtonsoft.Json;
|
||
using Ninject;
|
||
using RiaService.Services;
|
||
using RiaServiceLibrary;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Configuration;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Net.Http;
|
||
using System.Text;
|
||
using System.Web;
|
||
using WX.CRM.BLL.Base;
|
||
using WX.CRM.BLL.Soft;
|
||
using WX.CRM.BLL.Util;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Base;
|
||
using WX.CRM.IBLL.Csvr;
|
||
using WX.CRM.IBLL.Isvr;
|
||
using WX.CRM.IBLL.Res;
|
||
using WX.CRM.IBLL.Soft;
|
||
using WX.CRM.IBLL.Util;
|
||
using WX.CRM.IBLL.Ww;
|
||
using WX.CRM.IBLL.Wx;
|
||
using WX.CRM.Model.Entity;
|
||
using WX.CRM.Model.Enum;
|
||
using WX.CRM.Model.QueryMap;
|
||
using WX.CRM.WebHelper;
|
||
using WX.CRM.WebHelper.Infrastructure;
|
||
|
||
namespace RiaService
|
||
{
|
||
public class ResourceService : IResourceService
|
||
{
|
||
private ValidationErrors errors = new ValidationErrors();
|
||
private ISecurityHelper sHelper = NinjectControllerFactory.ninjectKernel.Get<ISecurityHelper>();
|
||
private IISVR_INTERFACECALLLOG logHelper = NinjectControllerFactory.ninjectKernel.Get<IISVR_INTERFACECALLLOG>();
|
||
private IRES_CUSTOMERUSER_Q res_customeruser = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMERUSER_Q>();
|
||
private IRES_CUSTOMERUSER res_customer_changeMobile = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMERUSER>();
|
||
|
||
private IRES_CUSTOMER res_customer = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER>();
|
||
private IRES_CUSTOMER_Q _resCustomerQ = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER_Q>();
|
||
private IRES_APPLY res_apply = NinjectControllerFactory.ninjectKernel.Get<IRES_APPLY>();
|
||
private IISVR_RiaSeviceActiveSoftOrder RiaSevicesoftOrder = NinjectControllerFactory.ninjectKernel.Get<IISVR_RiaSeviceActiveSoftOrder>();
|
||
private ICACHE_Q cacheQ = NinjectControllerFactory.ninjectKernel.Get<ICACHE_Q>();
|
||
private ISOFT_USER_Q softuserQ = NinjectControllerFactory.ninjectKernel.Get<ISOFT_USER_Q>();
|
||
private ISOFT_USER softuser = NinjectControllerFactory.ninjectKernel.Get<ISOFT_USER>();
|
||
private IBAS_PARAMETER_Q bas_parameterQ = NinjectControllerFactory.ninjectKernel.Get<IBAS_PARAMETER_Q>();
|
||
private IRES_RESOURCEMOBILE_Q _resourceMobile = NinjectControllerFactory.ninjectKernel.Get<IRES_RESOURCEMOBILE_Q>();
|
||
private string clientKey = WX.CRM.Common.Utility.GetSettingByKey("CRMClientKey");
|
||
private GET_REGUSER _regUser = new GET_REGUSER();
|
||
private ICSVR_UNITECUSTOMERAPPLY _uniteApply = NinjectControllerFactory.ninjectKernel.Get<ICSVR_UNITECUSTOMERAPPLY>();
|
||
private ICSVR_UNITECUSTOMERAPPLYDETAIL _uniteApplyDetail = NinjectControllerFactory.ninjectKernel.Get<ICSVR_UNITECUSTOMERAPPLYDETAIL>();
|
||
private ICSVR_TODOITEM _todoItem = NinjectControllerFactory.ninjectKernel.Get<ICSVR_TODOITEM>();
|
||
private IRES_DISTRIBUTE_DETAIL _resDistributeDetial = NinjectControllerFactory.ninjectKernel.Get<IRES_DISTRIBUTE_DETAIL>();
|
||
private ICSVR_FAVORITECUSTOMER_Q _favCustomerQ = NinjectControllerFactory.ninjectKernel.Get<ICSVR_FAVORITECUSTOMER_Q>();
|
||
private IRES_ACTIVITY_Q _resActivityQ = NinjectControllerFactory.ninjectKernel.Get<IRES_ACTIVITY_Q>();
|
||
private IRES_MYALLOCATERES _myallocate = NinjectControllerFactory.ninjectKernel.Get<IRES_MYALLOCATERES>();
|
||
private IRES_SHAREDPOOL_HIS _sharedPoolHis = NinjectControllerFactory.ninjectKernel.Get<IRES_SHAREDPOOL_HIS>();
|
||
private IRES_SHAREDPOOL_ONE _sharedPoolOne = NinjectControllerFactory.ninjectKernel.Get<IRES_SHAREDPOOL_ONE>();
|
||
private IBAS_INNERUSER_Q _user = NinjectControllerFactory.ninjectKernel.Get<IBAS_INNERUSER_Q>();
|
||
|
||
//private IRES_DISTRIBUTE _distribute = NinjectControllerFactory.ninjectKernel.Get<IRES_DISTRIBUTE>();
|
||
private IWX_SZZYORDER _order = NinjectControllerFactory.ninjectKernel.Get<IWX_SZZYORDER>();
|
||
|
||
//private IRES_CUSTOMER_LABEL _label = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER_LABEL>();
|
||
private IRES_SCENE _resScene = NinjectControllerFactory.ninjectKernel.Get<IRES_SCENE>();
|
||
|
||
//private IWW_EXTUSER _wwExtUser = NinjectControllerFactory.ninjectKernel.Get<IWW_EXTUSER>();
|
||
//private IWW_USER_EXTUSER _wwUserExtUser = NinjectControllerFactory.ninjectKernel.Get<IWW_USER_EXTUSER>();
|
||
private IWw_huser _wwHHUser = NinjectControllerFactory.ninjectKernel.Get<IWw_huser>();
|
||
|
||
//private IRES_ALLCOTE_USER _resAllcoteUser = NinjectControllerFactory.ninjectKernel.Get<IRES_ALLCOTE_USER>();
|
||
//private IRES_ALLOCATE res_allocate = NinjectControllerFactory.ninjectKernel.Get<IRES_ALLOCATE>();
|
||
private IBAS_BUSINESSLINE_Q _busLinesQ = NinjectControllerFactory.ninjectKernel.Get<IBAS_BUSINESSLINE_Q>();
|
||
|
||
// 在此处添加更多操作并使用 [OperationContract] 标记它们
|
||
#region JoinActive 方法
|
||
|
||
/// <summary>
|
||
/// 用户活动申请
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public string JoinActive(string content, string clientid, string sign)
|
||
{
|
||
bool isTrue = true;
|
||
string retMsg = string.Empty;
|
||
string resid = string.Empty;
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return retMsg;
|
||
}
|
||
|
||
#region 参数解析阶段
|
||
JionActiveDto activeModel = null;
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
try
|
||
{
|
||
activeModel = JsonHelper.JsonDivertToObj<JionActiveDto>(content);
|
||
|
||
if (activeModel != null && activeModel.campaignId != "softlogin")
|
||
{
|
||
LogHelper.Info("活动资源进入:" + activeModel.ToJson());//登录的数据过多,没多大作用,所以直接不做日志记录
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(activeModel.campaignId) && string.IsNullOrEmpty(activeModel.deptcode))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
return retMsg;
|
||
}
|
||
if (activeModel.accounttype == 0)
|
||
{
|
||
//手机号
|
||
activeModel.mobile = activeModel.account;
|
||
}
|
||
else if (activeModel.accounttype == 1)
|
||
{
|
||
//用户名
|
||
activeModel.username = activeModel.account;
|
||
}
|
||
else if (activeModel.accounttype == 2)
|
||
{
|
||
//客户ID
|
||
resid = activeModel.account;
|
||
}
|
||
else
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
return retMsg;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
isTrue = false;
|
||
|
||
LogHelper.Error(string.Concat("当前请求Url:", url, "|" + content + "|", ex.Message, ex.StackTrace));
|
||
}
|
||
#endregion 参数解析阶段
|
||
|
||
if (isTrue)
|
||
{
|
||
try
|
||
{
|
||
//获取已存在的活动名
|
||
var tagName = GetTagName(activeModel.campaignId);
|
||
//var tagName = default(string);
|
||
//var activityList = cacheQ.GetList_ResActivity();
|
||
//var activityexists = activityList.Where(p => p.RESOURCETAG == activeModel.campaignId).FirstOrDefault();
|
||
//if (activityexists != null)
|
||
//{
|
||
// tagName = activityexists.ACTIVITYNAME;
|
||
//}
|
||
|
||
int jsch = activeModel.ch ?? 0;
|
||
if (jsch >= 3000 && jsch <= 3099)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_3000_3099";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "东一活动报名");
|
||
}
|
||
else if (jsch >= 10000 && jsch <= 10999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_10000_10999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "东二活动报名");
|
||
}
|
||
else if (jsch >= 11000 && jsch <= 11999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_11000_11999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "好股来三活动报名");
|
||
}
|
||
else if (jsch >= 12000 && jsch <= 12999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_12000_12999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "好股来三活动报名");
|
||
}
|
||
else if (jsch >= 13000 && jsch <= 13999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_13000_13999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "好股来一活动报名");
|
||
}
|
||
else if (jsch >= 23000 && jsch <= 23999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_23000_23999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "好股来二活动报名");
|
||
}
|
||
else if ((jsch >= 7000 && jsch <= 7299) || (jsch >= 7300 && jsch <= 7599) || (jsch >= 8000 && jsch <= 8099))
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_7000_7299";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "六合一活动报名");
|
||
}
|
||
else if (jsch >= 8100 && jsch <= 8999)
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_8100_8999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "六合二活动报名");
|
||
}
|
||
else if ((jsch >= 7600 && jsch <= 7999) || (jsch >= 9000 && jsch <= 9999))//7600,7999|9000,9999
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_7600_9999";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "六合创新活动报名");
|
||
}
|
||
else if (jsch >= 100000 && jsch <= 100000)//六合投研服务中心
|
||
{
|
||
activeModel.campaignId = activeModel.campaignId + "_100000";
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "六合投研活动报名");
|
||
}
|
||
else
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = tagName ?? activeModel.campaignId, deptid = activeModel.deptid, ch = activeModel.ch }, typename: "活动报名");
|
||
}
|
||
if (activeModel.campaignId.StartsWith("softlogin"))
|
||
{
|
||
activeModel.campaignId = "softlogin";
|
||
}
|
||
|
||
//new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.campaignId, tagname = activeModel.campaignId });
|
||
//}
|
||
|
||
if (!string.IsNullOrEmpty(activeModel.mobile))
|
||
{
|
||
resid = ResUtil.CreateResId(activeModel.mobile);
|
||
if (string.IsNullOrWhiteSpace(activeModel.umid))
|
||
{
|
||
activeModel.umid = cacheQ.GetUMid(activeModel.mobile);
|
||
}
|
||
res_customer.ResgisterCustomer(activeModel.mobile, resid, activeModel.campaignId, v_umid: activeModel.umid);
|
||
}
|
||
else
|
||
{
|
||
PhoneLogModel phoneLogModel = new PhoneLogModel
|
||
{
|
||
Method = System.Reflection.MethodBase.GetCurrentMethod().Name,
|
||
userid = 0
|
||
};
|
||
if (!string.IsNullOrEmpty(resid))
|
||
{
|
||
activeModel.mobile = _resourceMobile.GetNumberByResId(resid, phoneLogModel);
|
||
}
|
||
else
|
||
{
|
||
var cust = res_customeruser.GetModelByUserName(activeModel.username);
|
||
if (cust == null)
|
||
{
|
||
retMsg = sHelper.encyptData(clientid, JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.不存在此用户 }));
|
||
return retMsg;
|
||
}
|
||
else
|
||
{
|
||
resid = cust.RESID;
|
||
activeModel.mobile = _resourceMobile.GetNumberByResId(resid, phoneLogModel);
|
||
}
|
||
}
|
||
}
|
||
|
||
//淘牛邦资源,不需要进入分配,只需要注册就可以了
|
||
//if (activeModel.campaignId == "TBN26001")
|
||
//{
|
||
// return HttpUtility.UrlEncode(sHelper.encyptData(clientid, JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, ResId = resid })));
|
||
//}
|
||
try
|
||
{
|
||
_busLinesQ.InsertBusCustomerMap(resid, activeModel.ch, activeModel.campaignId);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error($"【参加活动】【{resid}】插入业务线失败{ex.Message}");
|
||
}
|
||
var deptid = activeModel.deptid;
|
||
//根据渠道取deptid
|
||
if ((!deptid.HasValue || deptid <= 0) && jsch > 0)
|
||
{
|
||
var defaultDept = cacheQ.ConvertChannelName(new List<int> { jsch });
|
||
if (defaultDept.Count > 0)
|
||
{
|
||
deptid = Convert.ToInt32(defaultDept.FirstOrDefault().id);
|
||
}
|
||
}
|
||
//如果有工号,直接分配
|
||
if (activeModel.eid.HasValue && !string.IsNullOrEmpty(resid))
|
||
{
|
||
var user = _user.getInnerUserByEid(activeModel.eid.Value);
|
||
/* if ((deptid.HasValue || deptid <= 0) && user != null && user.DEPTID > 0)
|
||
{
|
||
deptid = user.DEPTID.Value;
|
||
}*/
|
||
var isExe = false;
|
||
|
||
var userList = cacheQ.GetUserList();
|
||
var pici = new SEQUENCES_BL().Seq_base_get();
|
||
|
||
using (var db = new crmContext())
|
||
{
|
||
var myRes = db.RES_MYALLOCATERES.FirstOrDefault(p => p.RESID == resid && p.DEPTID == deptid);
|
||
|
||
var para = bas_parameterQ.GetModel_Patameter("IgnoreManager");
|
||
if (para != null && myRes != null)
|
||
{
|
||
var manager = _user.GetModel(myRes.INNERUSERID);
|
||
|
||
if (!string.IsNullOrEmpty(para.PARAVALUE))
|
||
{
|
||
var manageList = para.PARAVALUE.Split(',');
|
||
foreach (var item in manageList)
|
||
{
|
||
if (item == manager.EID.ToString())
|
||
{
|
||
isExe = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//如果不存在分配关系,才需要分配
|
||
if (myRes == null || isExe)
|
||
{
|
||
var eid32 = activeModel.eid.Value;
|
||
if (user != null)
|
||
{
|
||
var info = new RES_ALLCOTE_USER()
|
||
{
|
||
ID = new SEQUENCES_BL().Seq_base_get(),
|
||
INNERUSERID = user.PKID,
|
||
EID = eid32,
|
||
NUM = 1,
|
||
CTIME = DateTime.Now,
|
||
PICI = pici,
|
||
RESID = resid,
|
||
TYPE = 1,
|
||
DEPTID = deptid
|
||
};
|
||
if (activeModel.groupid.HasValue)
|
||
{
|
||
info.SGID = activeModel.groupid.Value;
|
||
}
|
||
|
||
db.RES_ALLCOTE_USER.Add(info);
|
||
}
|
||
db.SaveChanges();
|
||
}
|
||
}
|
||
|
||
//资源分配关系
|
||
var eid1000 = userList.FirstOrDefault(p => p.EID == 10000).PKID;
|
||
|
||
_myallocate.ExeSeniorDistributeByResId(eid1000, pici, "诊股资源分配");
|
||
}
|
||
|
||
#region 添加客户与事业部的归属关系
|
||
_myallocate.InsertResCutomerRelation(jsch, resid);
|
||
#endregion 添加客户与事业部的归属关系
|
||
var apply = new RES_APPLY
|
||
{
|
||
CTIME = DateTime.Now,
|
||
JSONDATA = activeModel.jsondata,
|
||
JSONTYPE = 0,
|
||
MOBILE = activeModel.mobile,
|
||
RESID = resid,
|
||
RESOURCETAG = activeModel.campaignId,
|
||
RTIME = DateTime.Now,
|
||
STATUS = 0,
|
||
USERNAME = activeModel.username,
|
||
DATATYPE = activeModel.datatype,
|
||
EXTXML = activeModel.extxml,
|
||
KWORD = activeModel.kword,
|
||
SOURCETYPE = activeModel.resourcetype,
|
||
DEPTID = deptid
|
||
};
|
||
bool tr = res_apply.Create(ref errors, apply);
|
||
|
||
if (tr)
|
||
{
|
||
if (apply.RESOURCETAG == "softlogin")
|
||
{
|
||
softuser.UpdateByLastLoginTime(apply.RESID);
|
||
}
|
||
try
|
||
{
|
||
var user10000 = cacheQ.GetUserList().Find(p => p.EID == 10000).PKID;
|
||
var activity = _resActivityQ.GetModel(p => p.RESOURCETAG == apply.RESOURCETAG);
|
||
if (activity == null)
|
||
{
|
||
LogHelper.Info("未知的标签RESOURCETAG:" + apply.RESOURCETAG);
|
||
}
|
||
var favCustomer = _favCustomerQ.GetModel_FavoriteCustomer(apply.RESID, null);
|
||
if (favCustomer != null)
|
||
{
|
||
//说明这个用户有人收藏,提醒业务员
|
||
var todoItem = new CSVR_TODOITEM()
|
||
{
|
||
PKID = new SEQUENCES_BL().Seq_base_get(),
|
||
SENDEDUSERID = user10000,
|
||
RECEIVEDUSERID = favCustomer.SALESID,
|
||
ISPRIVATE = 1,
|
||
RESID = apply.RESID,
|
||
MEMO = "您收藏的客户参与了活动【" + (activity != null ? activity.ACTIVITYNAME : "未知") + "】",
|
||
STARTTIME = DateTime.Now,
|
||
URL = "/Csvr/CustomerInfo/CustomerDetail?resid=" + apply.RESID,
|
||
URLTITLE = "客户详细",
|
||
DOSTATUS = 0,
|
||
RESOURCETAG = apply.RESOURCETAG,
|
||
DEPTID = deptid,
|
||
EXTXML = string.IsNullOrEmpty(apply.KWORD) ? apply.EXTXML : apply.KWORD
|
||
};
|
||
if (!string.IsNullOrEmpty(apply.KWORD))
|
||
{
|
||
if (apply.RESOURCETAG == "RFM")
|
||
{
|
||
var labelObject = JsonConvert.DeserializeAnonymousType(apply.KWORD, new { rfmType = 0, rfmLabel = string.Empty, remark = string.Empty, reason = string.Empty });
|
||
//_label.Add(new RES_CUSTOMER_LABEL(new SEQUENCES_BL().Seq_base_get(PKIDType.LargeTable), apply.RESID, labelObject.rfmType, labelObject.rfmLabel, labelObject.reason, labelObject.remark));
|
||
|
||
todoItem.MEMO = labelObject.remark;
|
||
todoItem.REMARK = labelObject.reason;
|
||
}
|
||
else
|
||
{
|
||
todoItem.MEMO = apply.KWORD;
|
||
}
|
||
}
|
||
if (apply.RESOURCETAG == "softlogin")
|
||
{
|
||
todoItem.MEMO = "客户在" + DateTime.Now.ToString("yyyy-MM-dd") + "登录了";
|
||
}
|
||
_todoItem.Create(ref errors, todoItem);
|
||
LogHelper.Info(todoItem.ToJson());
|
||
}
|
||
else
|
||
{
|
||
var resMyAllocate = _myallocate.GetLastSale(apply.RESID, deptid);
|
||
if (resMyAllocate != null)
|
||
{
|
||
var userId = resMyAllocate.INNERUSERID;
|
||
var user = _user.GetModel(userId);
|
||
if (user.ISDISMISS == 0)
|
||
{
|
||
var todoItem = new CSVR_TODOITEM()
|
||
{
|
||
PKID = new SEQUENCES_BL().Seq_base_get(),
|
||
SENDEDUSERID = user10000,
|
||
RECEIVEDUSERID = resMyAllocate.INNERUSERID,
|
||
ISPRIVATE = 1,
|
||
RESID = apply.RESID,
|
||
MEMO = "分配的客户参与了活动【" + (activity != null ? activity.ACTIVITYNAME : "未知") + "】",
|
||
STARTTIME = DateTime.Now,
|
||
URL = "/Csvr/CustomerInfo/CustomerDetail?resid=" + apply.RESID,
|
||
URLTITLE = "客户详细",
|
||
DOSTATUS = 0,
|
||
RESOURCETAG = apply.RESOURCETAG,
|
||
DEPTID = deptid,
|
||
EXTXML = string.IsNullOrEmpty(apply.KWORD) ? apply.EXTXML : apply.KWORD
|
||
};
|
||
if (!string.IsNullOrEmpty(apply.KWORD))
|
||
{
|
||
if (apply.RESOURCETAG == "RFM")
|
||
{
|
||
var labelObject = JsonConvert.DeserializeAnonymousType(apply.KWORD, new { rfmType = 0, rfmLabel = string.Empty, remark = string.Empty, reason = string.Empty });
|
||
//_label.Add(new RES_CUSTOMER_LABEL(new SEQUENCES_BL().Seq_base_get(PKIDType.LargeTable), apply.RESID, labelObject.rfmType, labelObject.rfmLabel, labelObject.reason, labelObject.remark));
|
||
|
||
todoItem.MEMO = labelObject.remark;
|
||
todoItem.REMARK = labelObject.reason;
|
||
}
|
||
else
|
||
{
|
||
todoItem.MEMO = apply.KWORD;
|
||
}
|
||
}
|
||
if (apply.RESOURCETAG == "softlogin")
|
||
{
|
||
todoItem.MEMO = "客户在" + DateTime.Now.ToString("yyyy-MM-dd") + "登录了";
|
||
}
|
||
_todoItem.Create(ref errors, todoItem);
|
||
LogHelper.Info(todoItem.ToJson());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//查看是否有成交客户
|
||
var order = _order.Get(P => P.RESID == apply.RESID && P.ISOPEN == 1);
|
||
if (order != null)
|
||
{
|
||
var userId = order.INNERUSERID;
|
||
if (userId.HasValue)
|
||
{
|
||
var user = _user.GetModel(userId.Value);
|
||
if (user != null && user.ISDISMISS == 0)
|
||
{
|
||
var todoItem = new CSVR_TODOITEM()
|
||
{
|
||
PKID = new SEQUENCES_BL().Seq_base_get(),
|
||
SENDEDUSERID = user10000,
|
||
RECEIVEDUSERID = user.PKID,
|
||
ISPRIVATE = 1,
|
||
RESID = apply.RESID,
|
||
MEMO = "成交的客户参与了活动【" + (activity != null ? activity.ACTIVITYNAME : "未知") + "】",
|
||
STARTTIME = DateTime.Now,
|
||
URL = "/Csvr/CustomerInfo/CustomerDetail?resid=" + apply.RESID,
|
||
URLTITLE = "客户详细",
|
||
DOSTATUS = 0,
|
||
RESOURCETAG = apply.RESOURCETAG,
|
||
DEPTID = deptid,
|
||
EXTXML = string.IsNullOrEmpty(apply.KWORD) ? apply.EXTXML : apply.KWORD
|
||
};
|
||
if (!string.IsNullOrEmpty(apply.KWORD))
|
||
{
|
||
if (apply.RESOURCETAG == "RFM")
|
||
{
|
||
var labelObject = JsonConvert.DeserializeAnonymousType(apply.KWORD, new { rfmType = 0, rfmLabel = string.Empty, remark = string.Empty, reason = string.Empty });
|
||
//_label.Add(new RES_CUSTOMER_LABEL(new SEQUENCES_BL().Seq_base_get(PKIDType.LargeTable), apply.RESID, labelObject.rfmType, labelObject.rfmLabel, labelObject.reason, labelObject.remark));
|
||
|
||
todoItem.MEMO = labelObject.remark;
|
||
todoItem.REMARK = labelObject.reason;
|
||
}
|
||
else
|
||
{
|
||
todoItem.MEMO = apply.KWORD;
|
||
}
|
||
}
|
||
if (apply.RESOURCETAG == "softlogin")
|
||
{
|
||
todoItem.MEMO = "客户在" + DateTime.Now.ToString("yyyy-MM-dd") + "登录了";
|
||
}
|
||
_todoItem.Create(ref errors, todoItem);
|
||
LogHelper.Info(todoItem.ToJson());
|
||
}
|
||
}
|
||
}
|
||
|
||
//回收池资源,找到以前归属的客服,如果客服离职,找最近获取过该资源的客服
|
||
var sharedPoolHisList = _sharedPoolHis.GetList(p => p.RESID == apply.RESID);
|
||
if (sharedPoolHisList.Any())
|
||
{
|
||
var sharedPoolHis = sharedPoolHisList.OrderByDescending(p => p.CTIME).FirstOrDefault();
|
||
var userId = sharedPoolHis.SALESID.Value;
|
||
var user = _user.GetModel(userId);
|
||
if (user.ISDISMISS == 1)
|
||
{
|
||
//客服已经离职
|
||
var sharedPoolOneList = _sharedPoolOne.GetList(p => p.RESID == apply.RESID);
|
||
if (sharedPoolOneList.Any())
|
||
{
|
||
var sharedPoolOne = sharedPoolOneList.OrderByDescending(p => p.CTIME).FirstOrDefault();
|
||
userId = sharedPoolOne.SALESID;
|
||
}
|
||
}
|
||
var todoItem = new CSVR_TODOITEM()
|
||
{
|
||
PKID = new SEQUENCES_BL().Seq_base_get(),
|
||
SENDEDUSERID = user10000,
|
||
RECEIVEDUSERID = userId,
|
||
ISPRIVATE = 1,
|
||
RESID = apply.RESID,
|
||
MEMO = "回收的客户参与了活动【" + (activity != null ? activity.ACTIVITYNAME : "未知") + "】,回收的资源建议先收藏!",
|
||
STARTTIME = DateTime.Now,
|
||
URL = "/Csvr/CustomerInfo/CustomerDetail?resid=" + apply.RESID,
|
||
URLTITLE = "客户详细",
|
||
DOSTATUS = 0,
|
||
RESOURCETAG = apply.RESOURCETAG,
|
||
DEPTID = deptid,
|
||
EXTXML = string.IsNullOrEmpty(apply.KWORD) ? apply.EXTXML : apply.KWORD
|
||
};
|
||
if (!string.IsNullOrEmpty(apply.KWORD))
|
||
{
|
||
if (apply.RESOURCETAG == "RFM")
|
||
{
|
||
var labelObject = JsonConvert.DeserializeAnonymousType(apply.KWORD, new { rfmType = 0, rfmLabel = string.Empty, remark = string.Empty, reason = string.Empty });
|
||
//_label.Add(new RES_CUSTOMER_LABEL(new SEQUENCES_BL().Seq_base_get(PKIDType.LargeTable), apply.RESID, labelObject.rfmType, labelObject.rfmLabel, labelObject.reason, labelObject.remark));
|
||
|
||
todoItem.MEMO = labelObject.remark;
|
||
todoItem.REMARK = labelObject.reason;
|
||
}
|
||
else
|
||
{
|
||
todoItem.MEMO = apply.KWORD;
|
||
}
|
||
}
|
||
if (apply.RESOURCETAG == "softlogin")
|
||
{
|
||
todoItem.MEMO = "客户在" + DateTime.Now.ToString("yyyy-MM-dd") + "登录了";
|
||
}
|
||
_todoItem.Create(ref errors, todoItem);
|
||
LogHelper.Info(todoItem.ToJson());
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Info("未能找到客服的资源:【" + apply.RESID + "】");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception exx)
|
||
{
|
||
LogHelper.Error(exx.ToString());
|
||
}
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, ResId = resid });
|
||
}
|
||
else
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, ResId = resid });
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, ResId = "" });
|
||
LogHelper.Error(ex.Message + "|" + ex.StackTrace);
|
||
}
|
||
}
|
||
|
||
retMsg = HttpUtility.UrlEncode(sHelper.encyptData(clientid, retMsg));
|
||
return retMsg;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取活动名称
|
||
/// </summary>
|
||
/// <param name="code"></param>
|
||
/// <returns></returns>
|
||
private string GetTagName(string code)
|
||
{
|
||
var rspJson = default(string);
|
||
try
|
||
{
|
||
var host = ConfigurationManager.AppSettings["ZxdCoreWebApi"];
|
||
if (string.IsNullOrEmpty(host))
|
||
{
|
||
host = "http://120.77.165.155:8089";
|
||
}
|
||
var url = $"{host}/Api/Activity/GetActivityName";
|
||
var client = new HttpClient();
|
||
client.Timeout = TimeSpan.FromSeconds(5);
|
||
var json = JsonConvert.SerializeObject(new { Code = code });
|
||
var content = new StringContent(json);
|
||
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||
var result = client.PostAsync(url, content).Result;
|
||
rspJson = result.Content.ReadAsStringAsync().Result;
|
||
|
||
var rsp = JsonConvert.DeserializeObject<RetResult<string>>(rspJson);
|
||
if (rsp != null && !string.IsNullOrEmpty(rsp.Data))
|
||
{
|
||
return rsp.Data;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error($"GetTagName,{code},{rspJson},{ex.Message}");
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public class RetResult<T>
|
||
{
|
||
public int Ret { get; set; }
|
||
|
||
public string Message { get; set; }
|
||
|
||
public T Data { get; set; }
|
||
|
||
public RetResult(T data)
|
||
{
|
||
Data = data;
|
||
}
|
||
}
|
||
|
||
public JsonResult<string> AddActivity(ActivityDto dto)
|
||
{
|
||
var resutl = new ResServices().SaveActivityType(dto);
|
||
return new JsonResult<string> { result = resutl, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "success" };
|
||
}
|
||
|
||
#endregion JoinActive 方法
|
||
|
||
#region
|
||
|
||
public JsonResult<string> Event(UserCenterEventDto dto)
|
||
{
|
||
try
|
||
{
|
||
var tag = "UserCenterEvent" + dto.EventId.ToString();
|
||
|
||
//var activityList = cacheQ.GetList_ResActivity();
|
||
//var activityexists = activityList.Any(p => p.RESOURCETAG == tag);
|
||
//监测标签是否存在
|
||
//if (!activityexists)
|
||
//{
|
||
//如果没有标签则创建一个标签
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = tag, tagname = tag });
|
||
//}
|
||
|
||
new ResServices().SaveToDoItem(dto, tag);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e);
|
||
//return JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误 });
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = "error" };
|
||
}
|
||
|
||
//return JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "success" };
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 直播课
|
||
|
||
public string Scene(string content, string clientid, string sign)
|
||
{
|
||
var retMsg = string.Empty;
|
||
try
|
||
{
|
||
logHelper.AddCallLog(content, clientid, sign, "ResourceService/Scene");
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
//return HttpUtility.UrlEncode(sHelper.encyptData(clientid, JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 })));
|
||
}
|
||
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
|
||
var dto = JsonHelper.JsonDivertToObj<SceneDto>(content);
|
||
|
||
if (!string.IsNullOrEmpty(dto.mobile))
|
||
{
|
||
dto.resid = ResUtil.CreateResId(dto.mobile);
|
||
res_customer.ResgisterCustomer(dto.mobile, dto.resid, dto.ch.ToString());//注册资源
|
||
}
|
||
|
||
var model = new RES_SCENE()
|
||
{
|
||
ID = new SEQUENCES_BL().Seq_base_get(),
|
||
MOBILE = dto.mobile,
|
||
RESID = dto.resid,
|
||
APPID = dto.appid,
|
||
APPUSERID = dto.appuserid,
|
||
//HEADURL = dto.headurl,
|
||
//NICKNAME = dto.nickname,
|
||
SCENETITLE = dto.scenetitle,
|
||
SCENETYPE = dto.scenetype,
|
||
JOINTIME = dto.jointime,
|
||
CTIME = DateTime.Now,
|
||
CH = dto.ch,
|
||
DEPTCODE = dto.deptcode,
|
||
UNIONID = dto.unionid
|
||
};
|
||
LogHelper.Info("直播数据:" + model.ToJson());
|
||
if (!string.IsNullOrEmpty(model.UNIONID))
|
||
{
|
||
var extUser = _wwHHUser.GetExtUserByUnionId(model.UNIONID);
|
||
if (extUser != null)
|
||
{
|
||
model.HEADURL = extUser.avatar;
|
||
model.NICKNAME = extUser.name;
|
||
|
||
var userExtUserList = _wwHHUser.GetUserExtUserByUserId(extUser.userid);
|
||
//LogHelper.Info("userExtUserList:" + userExtUserList.ToJson());
|
||
if (userExtUserList.Any())
|
||
{
|
||
var hhUserList = _wwHHUser.GetUserListByQWUserId(userExtUserList.Select(p => p.userid).ToArray());
|
||
//LogHelper.Info("hhUserList:" + hhUserList.ToJson());
|
||
if (hhUserList.Any())
|
||
{
|
||
if (hhUserList.Count() > 1)
|
||
{
|
||
var hhUserList2 = hhUserList.Where(p => p.CORPID == model.APPID);
|
||
|
||
foreach (var item in hhUserList2)
|
||
{
|
||
model.EID = item.EID;
|
||
model.INNERUSERID = item.INNERUSERID;
|
||
_resScene.Add(model);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
model.EID = hhUserList.First().EID;
|
||
model.INNERUSERID = hhUserList.First().INNERUSERID;
|
||
_resScene.Add(model);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_resScene.Add(model);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_resScene.Add(model);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Info("直播课堂:unionid: " + model.UNIONID + " 找不到数据");
|
||
new ResServices().SaveScene(model);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
new ResServices().SaveScene(model);
|
||
}
|
||
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, ResId = string.Empty });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, ResId = string.Empty });
|
||
}
|
||
|
||
return HttpUtility.UrlEncode(sHelper.encyptData(clientid, retMsg));
|
||
}
|
||
|
||
public string UpdateSceneOnlineTime(string content, string clientid, string sign)
|
||
{
|
||
var retMsg = string.Empty;
|
||
try
|
||
{
|
||
//string url = Utility.GetClassAndMethodName(1);
|
||
logHelper.AddCallLog(content, clientid, sign, "ResourceService/UpdateSceneOnlineTime");
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
//return JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
return HttpUtility.UrlEncode(sHelper.encyptData(clientid, JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 })));
|
||
}
|
||
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
|
||
var dto = JsonHelper.JsonDivertToObj<SceneDto>(content);
|
||
|
||
if (string.IsNullOrWhiteSpace(dto.appid) || string.IsNullOrWhiteSpace(dto.appuserid) || dto.scenetype <= 0 || !dto.ch.HasValue || !dto.onlinetime.HasValue)
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
return HttpUtility.UrlEncode(retMsg);
|
||
}
|
||
|
||
var list = _resScene.GetList(p => p.APPID == dto.appid && p.APPUSERID == dto.appuserid && p.SCENETYPE == dto.scenetype).ToList();
|
||
foreach (var item in list)
|
||
{
|
||
item.ONLINETIME = dto.onlinetime;
|
||
_resScene.Update(item);
|
||
}
|
||
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误 });
|
||
}
|
||
|
||
return HttpUtility.UrlEncode(sHelper.encyptData(clientid, retMsg));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 合并客户
|
||
|
||
public string Merge(string content, string clientid, string sign)
|
||
{
|
||
var retMsg = string.Empty;
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return retMsg;
|
||
}
|
||
try
|
||
{
|
||
var decyptContent = sHelper.decyptData(clientid, content); //解密操作
|
||
|
||
var model = JsonHelper.JsonDivertToObj<MergeCustomerDto>(decyptContent);
|
||
|
||
var applyModel = new CSVR_UNITECUSTOMERAPPLY
|
||
{
|
||
APPLYTIME = DateTime.Now,
|
||
APPREMARK = "网站接口更新",
|
||
APPLYID = 600000207,
|
||
RESID1 = model.oldresid,
|
||
RESID2 = model.newresid,
|
||
STATE = 0
|
||
};
|
||
|
||
var lists = new List<CustomerRelation>
|
||
{
|
||
new CustomerRelation() { resId = model.oldresid, oldCustomerid = model.oldresid, newCustomerid = model.newresid },
|
||
new CustomerRelation() { resId = model.newresid, oldCustomerid = model.newresid, newCustomerid = model.newresid }
|
||
};
|
||
|
||
var uniteID = _uniteApply.Create_UniteCustomerApply(ref errors, applyModel);
|
||
_uniteApplyDetail.Creata_UnitCustomerApplyDetail(ref errors, lists, uniteID);
|
||
|
||
_uniteApply.Check_UniteCustomerApply(ref errors, uniteID, 600000207);
|
||
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误 });
|
||
}
|
||
|
||
return HttpUtility.UrlEncode(sHelper.encyptData(clientid, retMsg));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 活动订单模块
|
||
|
||
#region 活动订单资格验证(单独)
|
||
|
||
/// <summary>
|
||
/// 活动订单资格验证 (目前只有白金砖石至尊 和银管家为VIP的验证)
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public string CheckUserNameCompetence(string content, string clientid, string sign)
|
||
{
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
string retMsg = string.Empty;
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
return retMsg;
|
||
}
|
||
|
||
content = HttpUtility.UrlEncode(content, Encoding.UTF8);
|
||
return RiaSevicesoftOrder.ProcessHandling(Parameter.ISVR_AD_CheckUserNameCompetence, content);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 创建活动订单(单独)
|
||
|
||
/// <summary>
|
||
/// 活动订单建立(单独接口,只下单,不开通)
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public string upAgentCreateActiveOrder(string content, string clientid, string sign)
|
||
{
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
string retMsg = string.Empty;
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
return retMsg;
|
||
}
|
||
|
||
content = HttpUtility.UrlEncode(content, Encoding.UTF8);
|
||
return RiaSevicesoftOrder.ProcessHandling(Parameter.ISVR_AD_upAgentCreateActiveOrder, content);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 活动开通(单独)
|
||
|
||
/// <summary>
|
||
/// 活动订单建立(单独接口,开通订单)
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public retClass upAgentOpenOrder(string content, string clientid, string sign)
|
||
{
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
retClass retMsg = new retClass();
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.参数错误;
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
// retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.非法请求;
|
||
return retMsg;
|
||
}
|
||
|
||
content = sHelper.decyptData(clientid, content); //解密操作;
|
||
|
||
NewActiveAgentCreateAndOpen info = new NewActiveAgentCreateAndOpen();
|
||
|
||
try
|
||
{
|
||
info = JsonHelper.JsonDivertToObj<NewActiveAgentCreateAndOpen>(content);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("CreateAndOpenOrder的JSON转换出错" + ex.Message);
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.参数错误), orderid = "" });
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.参数错误;
|
||
|
||
return retMsg;
|
||
}
|
||
|
||
ActiveOrderHandlerModel openActive = new ActiveOrderHandlerModel();
|
||
openActive.optionUser = 1;
|
||
openActive.orderid = info.orderid;
|
||
|
||
string message = Utility.ConvertToJSON<ActiveOrderHandlerModel>(openActive);
|
||
message = RiaSevicesoftOrder.ProcessRequsetGet(Parameter.ISVR_AD_upAgentOpenOrder, message);
|
||
|
||
retMsg = JsonHelper.JsonDivertToObj<retClass>(message);
|
||
return retMsg;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 审核开通订单流程接口(集合)
|
||
|
||
public retClass CreateAndOpenOrder(string content, string clientid, string sign)
|
||
{
|
||
retClass retMsg = new retClass();
|
||
try
|
||
{
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
LogHelper.Error(content + "-----" + clientid + "---------" + sign);
|
||
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.非法请求;
|
||
//= { result = false, retcode = (int)EnumInterfaceErrcode.非法请求,orderId };
|
||
return retMsg;
|
||
}
|
||
|
||
content = sHelper.decyptData(clientid, content); //解密操作;
|
||
|
||
NewActiveAgentCreateAndOpen info = new NewActiveAgentCreateAndOpen();
|
||
|
||
try
|
||
{
|
||
info = JsonHelper.JsonDivertToObj<NewActiveAgentCreateAndOpen>(content);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("CreateAndOpenOrder的JSON转换出错" + ex.Message);
|
||
//retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.参数错误), orderid = "" });
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.参数错误;
|
||
return retMsg;
|
||
}
|
||
#region 变量定义区
|
||
int agentid = info.Agentid;
|
||
string campaignId = info.campaignId;
|
||
string userName = info.userName;
|
||
string userNo = info.usercardno;
|
||
string adminPwd = info.adminPwd;
|
||
|
||
if (string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(userNo))
|
||
{
|
||
//retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.参数错误), orderid = "" });
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.参数错误;
|
||
return retMsg;
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(userName))
|
||
{
|
||
userName = softuserQ.GetUser_userNameByCardNo(userNo).USERNAME;
|
||
}
|
||
else
|
||
{
|
||
var table = softuserQ.GetUser_userName(userName);
|
||
userNo = table.USERNO == null ? "" : table.USERNO.Value.ToString();
|
||
}
|
||
|
||
#endregion
|
||
|
||
string companyCode = cacheQ.GetValue_Parameter(Parameter.Sys_Bussiness_Code);
|
||
|
||
ActiveCheckInfo cku = new ActiveCheckInfo();
|
||
cku.AgentId = agentid;
|
||
cku.CampainId = campaignId;
|
||
cku.UserName = userName;
|
||
cku.CompanyCode = companyCode;
|
||
string json = Utility.ConvertToJSON<ActiveCheckInfo>(cku);
|
||
|
||
string retCheck = RiaSevicesoftOrder.ProcessRequsetGet(Parameter.ISVR_AD_CheckUserNameCompetence, json);
|
||
|
||
retActiveCheckInfo retUck = JsonHelper.JsonDivertToObj<retActiveCheckInfo>(retCheck);
|
||
|
||
if (!retUck.result)
|
||
{
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.参数错误), orderid = "" });
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = retUck.retcode;
|
||
return retMsg;
|
||
}
|
||
|
||
#region 创建订单
|
||
|
||
ActiveAgentCreateAndOpen saa = new ActiveAgentCreateAndOpen();
|
||
saa.Agentid = agentid;
|
||
saa.campaignId = campaignId;
|
||
saa.userName = userName;
|
||
saa.CompanyCode = companyCode;
|
||
string message = Utility.ConvertToJSON<ActiveAgentCreateAndOpen>(saa);
|
||
|
||
message = RiaSevicesoftOrder.ProcessRequsetGet(Parameter.ISVR_AD_upAgentCreateActiveOrder, message);
|
||
//message = RiaSevicesoftOrder.upAgentCreateActiveOrder(message);
|
||
retClass retmessage = JsonHelper.JsonDivertToObj<retClass>(message);
|
||
#endregion
|
||
|
||
#region 开通订单
|
||
|
||
if (retmessage.result)
|
||
{
|
||
if (!string.IsNullOrEmpty(retmessage.ApplyOrderId))
|
||
{
|
||
ActiveOrderHandlerModel openActive = new ActiveOrderHandlerModel();
|
||
openActive.optionUser = 1;
|
||
openActive.orderid = retmessage.ApplyOrderId;
|
||
|
||
message = Utility.ConvertToJSON<ActiveOrderHandlerModel>(openActive);
|
||
message = RiaSevicesoftOrder.ProcessRequsetGet(Parameter.ISVR_AD_upAgentOpenOrder, message);
|
||
retClass openreturnMsg = JsonHelper.JsonDivertToObj<retClass>(message);
|
||
if (openreturnMsg.result && openreturnMsg.retcode == 10000)
|
||
{
|
||
//retMsg = Utility.ObjectToJson(new { result = true, retcode = Convert.ToInt32(EnumInterfaceErrcode.调用成功), orderid = retmessage.orderId });
|
||
retMsg.orderId = retmessage.ApplyOrderId;
|
||
retMsg.result = true;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.调用成功;
|
||
return retMsg;
|
||
}
|
||
else if (openreturnMsg.retcode == 10044) //订单已经开通
|
||
{
|
||
retMsg.orderId = retmessage.ApplyOrderId;
|
||
retMsg.result = true;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.调用成功;
|
||
return retMsg;
|
||
}
|
||
else if (openreturnMsg.retcode == 10034)
|
||
{
|
||
//retMsg = Utility.ObjectToJson(new { result = true, retcode = Convert.ToInt32(EnumInterfaceErrcode.已拥有相同或更高版本), orderid = retmessage.orderId });
|
||
retMsg.orderId = retmessage.ApplyOrderId;
|
||
retMsg.result = true;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.已拥有相同或更高版本;
|
||
return retMsg;
|
||
}
|
||
else if (openreturnMsg.result && openreturnMsg.retcode == 10035)
|
||
{
|
||
retMsg.orderId = retmessage.ApplyOrderId;
|
||
retMsg.result = true;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.开通则撤销之前低版本;
|
||
return retMsg;
|
||
}
|
||
else
|
||
{
|
||
retMsg.orderId = retmessage.ApplyOrderId;
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.系统错误;
|
||
LogHelper.Error(string.Concat("CreateAndOpenOrder 开通订单", openreturnMsg.retcode + retmessage.ApplyOrderId));
|
||
return retMsg;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.系统错误), orderid = "" });
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.系统错误;
|
||
LogHelper.Error(string.Format("远程调用0135135接口出错,没有返回orderId,返回值是:retCode={0},result={1},orderid={2}", retMsg.retcode, retMsg.result, retmessage.ApplyOrderId));
|
||
return retMsg;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.系统错误), orderid = "" });
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.系统错误;
|
||
LogHelper.Error(string.Format("远程调用0135135接口出错,返回值是:retCode={0},result={1},orderid={2}", retMsg.retcode, retMsg.result, retmessage.ApplyOrderId));
|
||
|
||
return retMsg;
|
||
}
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg.orderId = "";
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.系统错误;
|
||
LogHelper.Error(ex.Message + "|" + ex.StackTrace);
|
||
return retMsg;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 撤销订单
|
||
|
||
/// <summary>
|
||
/// 撤销订单
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public retClass CancelActiveOrder(string content, string clientid, string sign)
|
||
{
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
retClass retMsg = new retClass();
|
||
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
//retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.非法请求;
|
||
return retMsg;
|
||
}
|
||
|
||
content = sHelper.decyptData(clientid, content); //解密操作;
|
||
|
||
NewActiveAgentCreateAndOpen info = new NewActiveAgentCreateAndOpen();
|
||
|
||
try
|
||
{
|
||
info = JsonHelper.JsonDivertToObj<NewActiveAgentCreateAndOpen>(content);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("CreateAndOpenOrder的JSON转换出错" + ex.Message);
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = Convert.ToInt32(EnumInterfaceErrcode.参数错误), orderid = "" });
|
||
retMsg.result = false;
|
||
retMsg.retcode = (int)EnumInterfaceErrcode.参数错误;
|
||
return retMsg;
|
||
}
|
||
|
||
ActiveCancelOrder cancelOrder = new ActiveCancelOrder();
|
||
cancelOrder.orderId = info.orderid;
|
||
cancelOrder.optionUser = 1;
|
||
content = Utility.ConvertToJSON<ActiveCancelOrder>(cancelOrder);
|
||
string msg = RiaSevicesoftOrder.ProcessRequsetGet(Parameter.ISVR_AD_CancelActiveOrder, content);
|
||
retMsg = JsonHelper.JsonDivertToObj<retClass>(msg);
|
||
return retMsg;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 同步用户注册逻辑
|
||
|
||
#region 注册同步
|
||
|
||
/// <summary>
|
||
/// 手动执行手机号注册,不带短信验证码验证
|
||
/// </summary>
|
||
/// <param name="key"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public Stream SyncRegUser(string content, string clientid, string sign)
|
||
{
|
||
LogHelper.Info("ResourceService.svc/SyncRegUser?content=" + HttpUtility.UrlEncode(content) + "&clientid=" + clientid + "&sign=" + HttpUtility.UrlEncode(sign));
|
||
bool isTrue = true;
|
||
string retMsg = string.Empty;
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
if (clientKey == "nj_crm")
|
||
{
|
||
clientid = SecurityHelper.OrderClientIdKey;
|
||
}
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
//LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
#region 参数解析阶段
|
||
|
||
SyncRegUserDto activeModel = null;
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
try
|
||
{
|
||
activeModel = Utility.JSONToObject<SyncRegUserDto>(content);
|
||
LogHelper.Info("activeModel:" + activeModel.ToJson());
|
||
if (string.IsNullOrEmpty(activeModel.username))
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
isTrue = false;
|
||
LogHelper.Error(string.Concat("当前请求Url:", url, "|" + content + "|", ex.Message, ex.StackTrace));
|
||
}
|
||
#endregion
|
||
|
||
if (isTrue)
|
||
{
|
||
try
|
||
{
|
||
////解决并发的问题
|
||
//bool cacheBool = CacheHelper.CheckTheCacheAndSava(activeModel.username);
|
||
//if (cacheBool)
|
||
//{
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.用户名已存在 });
|
||
// retMsg = sHelper.encyptData(clientid, retMsg);
|
||
// return Utility.GetStream(retMsg);
|
||
//}
|
||
|
||
//if (softuserQ.GetUser_userName(activeModel.username) != null)
|
||
//{
|
||
// retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.用户名已存在 });
|
||
// retMsg = sHelper.encyptData(clientid, retMsg);
|
||
// return Utility.GetStream(retMsg);
|
||
//}
|
||
|
||
DateTime? rgd = null;
|
||
if (activeModel.regDate.HasValue)
|
||
{
|
||
rgd = DateTimeTool.GetTimeFromLinuxTime(activeModel.regDate.Value);
|
||
}
|
||
|
||
//if (!string.IsNullOrEmpty(activeModel.mobile))
|
||
//{
|
||
// ConStringHelper.GetDecryptConnectingString(activeModel.mobile);
|
||
//}
|
||
|
||
//if (!string.IsNullOrEmpty(activeModel.activeMobile))
|
||
//{
|
||
// ConStringHelper.GetDecryptConnectingString(activeModel.activeMobile);
|
||
//}
|
||
|
||
//var activityList = cacheQ.GetList_ResActivity();
|
||
//var activityexists = activityList.Any(p => p.RESOURCETAG == activeModel.ch);
|
||
////监测标签是否存在
|
||
//if (!activityexists)
|
||
//{
|
||
//如果没有标签则创建一个标签
|
||
int jsch = 0;
|
||
int.TryParse(activeModel.ch, out jsch);
|
||
if (jsch >= 3000 && jsch <= 3099)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "东一注册资源");
|
||
}
|
||
else if (jsch >= 10000 && jsch <= 10999)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "东二注册资源");
|
||
}
|
||
else if (jsch >= 11000 && jsch <= 11999)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "好股来三注册资源");
|
||
}
|
||
else if (jsch >= 12000 && jsch <= 12999)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "好股来三注册资源");
|
||
}
|
||
else if (jsch >= 13000 && jsch <= 13999)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "好股来一注册资源");
|
||
}
|
||
else if (jsch >= 23000 && jsch <= 23999)
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "好股来二注册资源");
|
||
}
|
||
else if ((jsch >= 7000 && jsch <= 7299) || (jsch >= 7300 && jsch <= 7599) || (jsch >= 8000 && jsch <= 8099))
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "六合一注册资源");
|
||
}
|
||
else if ((jsch >= 8100 && jsch <= 8999))
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "六合二注册资源");
|
||
}
|
||
else if ((jsch >= 7600 && jsch <= 7999) || (jsch >= 9000 && jsch <= 9999))//7600,7999|9000,9999
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "六合创新注册资源");
|
||
}
|
||
else
|
||
{
|
||
new ResServices().SaveActivityType(new ActivityDto() { tag = activeModel.ch, tagname = activeModel.ch, ch = jsch }, typename: "注册资源");
|
||
}
|
||
//}
|
||
|
||
//18696548545,5001,6201075,5001,2013-8-7 13:54:16 【手机号,标签,卡号,用户名,注册时候】
|
||
if (activeModel.curChannel.HasValue)
|
||
{
|
||
activeModel.ch = activeModel.curChannel.ToString();
|
||
}
|
||
var resid = "";
|
||
//有号码的才走注册
|
||
if (!string.IsNullOrEmpty(activeModel.mobile))
|
||
{
|
||
var v_resid = ResUtil.CreateResId(activeModel.mobile);
|
||
resid = v_resid;
|
||
SyncRegExtraModel syncRegExtraModel = new SyncRegExtraModel
|
||
{
|
||
ch = jsch,
|
||
umid = activeModel.umid
|
||
};
|
||
_regUser.RegUser(activeModel.mobile, activeModel.ch, "", activeModel.username, rgd, 0, activeModel.mobile, activeModel.plat, eid: activeModel.eid, openid: activeModel.openid, openplat: activeModel.openplat, unionid: activeModel.unionId, liveCode: activeModel.liveCode, regSource: activeModel.regSource, refeid: activeModel.refeid, sgid: activeModel.groupid, extraModel: syncRegExtraModel);
|
||
try
|
||
{
|
||
_busLinesQ.InsertBusCustomerMap(v_resid, activeModel.curChannel, activeModel.ch);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error($"【{v_resid}】插入业务线失败{ex.Message}");
|
||
}
|
||
}
|
||
#region 添加客户与事业部的归属关系
|
||
_myallocate.InsertResCutomerRelation(jsch, resid);
|
||
#endregion
|
||
|
||
retMsg = Utility.ObjectToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("同步注册用户出现异常" + ex);
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.系统错误 });
|
||
}
|
||
finally
|
||
{
|
||
//CacheHelper.RemoveRegCache(activeModel.username);
|
||
}
|
||
}
|
||
|
||
retMsg = sHelper.encyptData(clientid, retMsg); //加密返回值
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
|
||
public Stream BindRegUser(string content, string clientid, string sign)
|
||
{
|
||
LogHelper.Info("cntent:" + content + ",clientid:" + clientid + ",sign:" + sign);
|
||
bool isTrue = true;
|
||
string retMsg = string.Empty;
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
var content2 = content;
|
||
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
//retMsg = sHelper.encyptData(clientid, retMsg);
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
#region 参数解析阶段
|
||
|
||
LogHelper.Info("开始解密");//解密后的内容
|
||
|
||
BindRegUserDto model = null;
|
||
|
||
try
|
||
{
|
||
LogHelper.Info("xx:" + content);
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
LogHelper.Info("内容:" + content);//解密后的内容
|
||
|
||
model = Utility.JSONToObject<BindRegUserDto>(content);
|
||
LogHelper.Info("model:" + model.ToJson());//解密后的内容
|
||
if (string.IsNullOrEmpty(model.username) && string.IsNullOrEmpty(model.unionId))
|
||
{
|
||
return Utility.GetStream(Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 }));
|
||
}
|
||
if (model.eid == 0 || model.ch == 0)
|
||
{
|
||
return Utility.GetStream(Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 }));
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
isTrue = false;
|
||
LogHelper.Error(string.Concat("当前请求Url:", url, "|" + content + "|", ex.ToString()));
|
||
}
|
||
#endregion
|
||
|
||
if (isTrue)
|
||
{
|
||
_regUser.BindUser(model);
|
||
|
||
retMsg = Utility.ObjectToJson(new { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
}
|
||
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 北3分配资源
|
||
|
||
public JsonResult<DistributeInfo> Distribute(DisDto dto)
|
||
{
|
||
if (dto.eid <= 0 || string.IsNullOrEmpty(dto.mobile) || dto.typeid <= 0 || string.IsNullOrEmpty(dto.fromtag))
|
||
{
|
||
return new JsonResult<DistributeInfo> { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, retmsg = null };
|
||
}
|
||
|
||
LogHelper.Info(dto.ToJson());
|
||
|
||
try
|
||
{
|
||
//注册资源
|
||
//var resid = ResUtil.CreateResId(dto.mobile);
|
||
//res_customer.ResgisterCustomer(dto.mobile, resid, dto.fromtag);
|
||
|
||
//var apply = new RES_APPLY
|
||
//{
|
||
// CTIME = DateTime.Now,
|
||
// JSONTYPE = 0,
|
||
// MOBILE = dto.mobile,
|
||
// RESID = resid,
|
||
// RESOURCETAG = dto.fromtag,
|
||
// RTIME = DateTime.Now,
|
||
// STATUS = 0,
|
||
//};
|
||
//res_apply.Create(ref errors, apply);
|
||
|
||
////执行分配
|
||
//var msg = _distribute.Bei3Allocate(resid, dto.eid, dto.typeid, dto.fromtag);
|
||
//LogHelper.Info("msg:" + msg);
|
||
//return new JsonResult<DistributeInfo> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = new DistributeInfo { resid = resid, msg = msg } };
|
||
return new JsonResult<DistributeInfo> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = null };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<DistributeInfo> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = null };
|
||
}
|
||
}
|
||
|
||
public JsonResult<string> Dis(string resid, int eid)
|
||
{
|
||
try
|
||
{
|
||
//var list = new List<RES_ALLCOTE_USER>();
|
||
|
||
//var pici = new SEQUENCES_BL().Seq_base_get();
|
||
|
||
//var info = new RES_ALLCOTE_USER()
|
||
//{
|
||
// ID = new SEQUENCES_BL().Seq_base_get(),
|
||
// INNERUSERID = InnerUserHelper.Instance.GetUserIdByEid(Convert.ToDecimal(eid)),
|
||
// EID = Convert.ToDecimal(eid),
|
||
// NUM = 1,
|
||
// CTIME = DateTime.Now,
|
||
// PICI = pici,
|
||
// RESID = null,
|
||
// TYPE = 0
|
||
//};
|
||
//list.Add(info);
|
||
|
||
//_resAllcoteUser.AddList(list);
|
||
|
||
//Pager pager = new Pager() { page = 1, rows = int.MaxValue };
|
||
|
||
//res_allocate.HandlerMyAllocate(ref pager, resid, null, string.Empty, 0, 0, 0, null, null, string.Empty, null, 0, null, null, string.Empty, string.Empty, null, null, null, null, null, null, null, null, 1213383504, pici, string.Empty, 0);
|
||
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "分配成功" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "分配失败" };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 活动分配接口
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public Stream ResAllocation(string content, string clientid, string sign)
|
||
{
|
||
bool isTrue = true;
|
||
string retMsg = string.Empty;
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
retMsg = sHelper.encyptData(clientid, retMsg);
|
||
//LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
#region 参数解析阶段
|
||
|
||
ResAllocationDto activeModel = null;
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
try
|
||
{
|
||
activeModel = Utility.JSONToObject<ResAllocationDto>(content);
|
||
LogHelper.Info("资源分配接口:" + activeModel.ToJson());
|
||
res_customer.ResAllocationCustomer(activeModel);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
retMsg = Utility.ObjectToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.参数错误 });
|
||
isTrue = false;
|
||
LogHelper.Error(string.Concat("当前请求Url:", url, "|" + content + "|", ex.Message, ex.StackTrace));
|
||
}
|
||
retMsg = Utility.ObjectToJson(new { result = isTrue, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
return Utility.GetStream(retMsg);
|
||
#endregion
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 用户活动申请
|
||
/// </summary>
|
||
/// <param name="content"></param>
|
||
/// <param name="clientid"></param>
|
||
/// <param name="sign"></param>
|
||
/// <returns></returns>
|
||
public Stream ChangeMobile(string content, string clientid, string sign)
|
||
{
|
||
bool isTrue = true;
|
||
string retMsg = string.Empty;
|
||
string resid = string.Empty;
|
||
string url = Utility.GetClassAndMethodName(1);
|
||
logHelper.AddCallLog(content, clientid, sign, url);
|
||
//验证是否非法请求
|
||
if (!sHelper.CheckClientValid(clientid, content, sign))
|
||
{
|
||
retMsg = JsonHelper.ObjDivertToJson(new { result = false, retcode = (int)EnumInterfaceErrcode.非法请求 });
|
||
LogHelper.Info("非法请求content:" + content + ",clientid=" + clientid + ",sign=" + sign);
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
content = sHelper.decyptData(clientid, content); //解密操作
|
||
var resetMobileDto = JsonHelper.JsonDivertToObj<ChangeMobile>(content);
|
||
if (!string.IsNullOrWhiteSpace(resetMobileDto.mobile))
|
||
{
|
||
resid = ResUtil.CreateResId(resetMobileDto.mobile);
|
||
if (_resCustomerQ.getResCustomerByResId(resid) == null)
|
||
{
|
||
res_customer.ResgisterCustomer(resetMobileDto.mobile, resid, "resetmobile");//注册资源
|
||
}
|
||
}
|
||
|
||
//处理用户名
|
||
var hasChange = res_customer_changeMobile.ChangeUserMobile(resid, resetMobileDto);//关联用户
|
||
retMsg = Utility.ObjectToJson(new { result = isTrue, retcode = (int)EnumInterfaceErrcode.调用成功 });
|
||
return Utility.GetStream(retMsg);
|
||
}
|
||
}
|
||
} |