119 lines
4.3 KiB
C#
119 lines
4.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Res;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Res
|
|
{
|
|
public class RES_RESOURCEMOBILE_BL : IRES_RESOURCEMOBILE_Q
|
|
{
|
|
private string clientid = Utility.GetSettingByKey("CRMClientKey");
|
|
private WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper();
|
|
public RES_MOBILEQUERYLOG_BL res_MobileQueryLog_BL = new RES_MOBILEQUERYLOG_BL();
|
|
|
|
public string GetNumberByResId(string resId, PhoneLogModel phoneLogModel)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var customer = db.RES_CUSTOMER.FirstOrDefault(m => m.RESID == resId || m.UMID == resId);
|
|
try
|
|
{
|
|
if (customer != null && !string.IsNullOrWhiteSpace(customer.UMID))
|
|
{
|
|
string phone = new CACHE_BL().GetPhone(customer.UMID);
|
|
var model = new RES_MOBILEQUERYLOG();
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.INNERUSERID = phoneLogModel.userid;
|
|
model.TYPE = phoneLogModel.Method;
|
|
model.UMID = customer.UMID;
|
|
model.RESID = resId;
|
|
model.CTIME = DateTime.Now;
|
|
model.IP = Utility.GetIp();
|
|
res_MobileQueryLog_BL.Add(model);
|
|
return phone;
|
|
}
|
|
return "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Info($"umid解绑失败{ex.Message}{resId}");
|
|
var entry = db.RES_RESOURCEMOBILE.FirstOrDefault(n => n.RESID == customer.RESID);
|
|
return sHelper.decyptData(clientid, entry.MOBILE);
|
|
}
|
|
}
|
|
}
|
|
|
|
public IDictionary<string, string> GetNumberByResId(string[] resId)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var entrys = db.RES_RESOURCEMOBILE.Where(m => resId.Contains(m.RESID));
|
|
IDictionary<string, string> rsts = new Dictionary<string, string>();
|
|
if (entrys != null && entrys.Count() > 0)
|
|
{
|
|
foreach (var entry in entrys)
|
|
{
|
|
if (!rsts.ContainsKey(entry.RESID))
|
|
{
|
|
rsts[entry.RESID] = sHelper.decyptData(clientid, entry.MOBILE);
|
|
}
|
|
}
|
|
}
|
|
return rsts;
|
|
}
|
|
}
|
|
|
|
public IList<string> GetNumberByResIdList(List<string> data)
|
|
{
|
|
var list = new List<string>();
|
|
using (var db = new crmContext())
|
|
{
|
|
foreach (var item in data)
|
|
{
|
|
var entry = db.RES_RESOURCEMOBILE.FirstOrDefault(m => m.RESID == item);
|
|
if (entry == null)
|
|
list.Add("");
|
|
else
|
|
list.Add(sHelper.decyptData(clientid, entry.MOBILE));
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public IList<string> GetNumberByResIdListNoSql(List<string> data)
|
|
{
|
|
var list = new List<string>();
|
|
|
|
foreach (var item in data)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(item))
|
|
{
|
|
list.Add("");
|
|
continue;
|
|
}
|
|
try
|
|
{
|
|
list.Add(sHelper.decyptData(clientid, item));//直接解密,不需要访问数据库
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
try
|
|
{
|
|
list.Add(sHelper.decyptData("gd_crm", item));//直接解密,不需要访问数据库
|
|
//rsts[entry.RESID] = sHelper.decyptData("gd_crm", entry.MOBILE);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Info("号码:" + item);
|
|
LogHelper.Info(e.ToString());
|
|
}
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
} |