870 lines
30 KiB
C#
870 lines
30 KiB
C#
using CRM.Core.Model.Entity;
|
||
using CRM.Core.Model.Enum;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.Common.StockHelper;
|
||
|
||
namespace CRM.Core.BLL.Util
|
||
{
|
||
/// <summary>
|
||
/// 缓存BL
|
||
/// </summary>
|
||
public class CACHE_BL
|
||
{
|
||
#region 根据Model.Enum.Parameter 获取参数value
|
||
|
||
public string GetValue_Parameter(string key)
|
||
{
|
||
string cacheKey = "cache_Parameter_getList";
|
||
List<BAS_PARAMETER> modelist;
|
||
if (CacheHelper.Exists(cacheKey))
|
||
modelist = CacheHelper.Get<List<BAS_PARAMETER>>(cacheKey);
|
||
else
|
||
{
|
||
using (var db = new zxdContext())
|
||
{
|
||
modelist = db.BAS_PARAMETER.ToList();
|
||
CacheHelper.Set(cacheKey, modelist);
|
||
}
|
||
}
|
||
var model = modelist.FirstOrDefault(m => m.PARAKEY == key);
|
||
if (model == null)
|
||
return "";
|
||
return model.PARAVALUE;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据Model.Enum.Parameter 获取参数value
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetValue_Parameter(CRM.Core.Model.Enum.Parameter key)
|
||
{
|
||
string cacheKey = "cache_Parameter_getList";
|
||
List<CRM.Core.Model.Entity.BAS_PARAMETER> modelist;
|
||
if (CacheHelper.Exists(cacheKey))
|
||
modelist = CacheHelper.Get<List<CRM.Core.Model.Entity.BAS_PARAMETER>>(cacheKey);
|
||
else
|
||
{
|
||
using (CRM.Core.Model.Entity.zxdContext db = new CRM.Core.Model.Entity.zxdContext())
|
||
{
|
||
modelist = db.BAS_PARAMETER.ToList();
|
||
CacheHelper.Set(cacheKey, modelist);
|
||
}
|
||
}
|
||
string sss = key.ToString();
|
||
CRM.Core.Model.Entity.BAS_PARAMETER sysConfig = modelist.FirstOrDefault(m => m.PARAKEY == "Sys_Environment_DeptCode");
|
||
CRM.Core.Model.Entity.BAS_PARAMETER model = modelist.FirstOrDefault(m => m.PARAKEY == key.ToString() && m.DEPTCDOE == sysConfig.PARAVALUE);
|
||
if (model == null)
|
||
model = modelist.FirstOrDefault(m => m.PARAKEY == key.ToString() && (m.DEPTCDOE == "" || m.DEPTCDOE == null));
|
||
if (model == null)
|
||
return "";
|
||
return model.PARAVALUE;
|
||
}
|
||
|
||
public List<DeptmentDto> GetDeptments()
|
||
{
|
||
var webapi = GetValue_Parameter(Parameter.Zxd_CoreApiUrl);
|
||
var url = $"{webapi}api/deptment/Depts";
|
||
var result = Utility.GetData(url, "", Encoding.UTF8);
|
||
var response = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<List<DeptmentDto>>>(result);
|
||
if (response.code == 0 && response.data != null)
|
||
{
|
||
return response.data.Where(x => x.SortNo > 0).OrderBy(x => x.SortNo).ToList();
|
||
}
|
||
return new List<DeptmentDto>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据系统参数分类获取系统参数列表
|
||
/// </summary>
|
||
/// <param name="type">系统参数分类</param>
|
||
/// <returns></returns>
|
||
public List<BAS_PARAMETER> GetList_Parameter(CRM.Core.Model.Enum.ParameterGroup type)
|
||
{
|
||
string cacheKey = "cache_Parameter_getList";
|
||
List<CRM.Core.Model.Entity.BAS_PARAMETER> modelist;
|
||
if (CacheHelper.Exists(cacheKey))
|
||
modelist = CacheHelper.Get<List<CRM.Core.Model.Entity.BAS_PARAMETER>>(cacheKey);
|
||
else
|
||
{
|
||
using (CRM.Core.Model.Entity.zxdContext db = new CRM.Core.Model.Entity.zxdContext())
|
||
{
|
||
modelist = db.BAS_PARAMETER.ToList();
|
||
CacheHelper.Set(cacheKey, modelist);
|
||
}
|
||
}
|
||
List<CRM.Core.Model.Entity.BAS_PARAMETER> list = modelist.Where(m => m.GROUPID.Trim() == type.ToString().Trim()).ToList();
|
||
return list;
|
||
}
|
||
|
||
#endregion 根据Model.Enum.Parameter 获取参数value
|
||
|
||
#region 获取内部公司列表 cache_Company_getList
|
||
|
||
/// <summary>
|
||
/// 获取公司列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<BAS_COMPANY> GetList_innerCompany()
|
||
{
|
||
string cacheKey = "cache_Company_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<BAS_COMPANY>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
List<BAS_COMPANY> list = db.BAS_COMPANY.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
public List<Bas_CompanyChannel> GetCompanyCode()
|
||
{
|
||
string cacheKey = "cache_Company_Code";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<Bas_CompanyChannel>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var list = db.Bas_CompanyChannel.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
public List<Bas_CompanyVirtual> GetCompanyVirtual()
|
||
{
|
||
var cacheKey = "cache_comapny_virtual";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<Bas_CompanyVirtual>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var list = db.Bas_CompanyVirtual.Where(p => p.IsDelete == 0).OrderBy(p => p.Sort).ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
public List<Bas_CompanyWework> GetCompanyWework()
|
||
{
|
||
var cacheKey = "cache_comapny_wework";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<Bas_CompanyWework>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var list = db.Bas_CompanyWework.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
public List<Dictionary<string, string>> GetDeptDownList()
|
||
{
|
||
var cacheKey = "cache_deptDownList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<Dictionary<string, string>>>(cacheKey);
|
||
var companyList = GetCompanyVirtual();
|
||
var channelList = companyList.Where(n => !string.IsNullOrWhiteSpace(n.Channel)).Select(n => Convert.ToInt32(n.Channel.Split(',').FirstOrDefault())).ToList();
|
||
var depts = ConvertChannelName(channelList);
|
||
var allChannel = new List<Dictionary<string, string>>();
|
||
foreach (var company in depts)
|
||
{
|
||
var channel = new Dictionary<string, string>
|
||
{
|
||
{ "name", company.title },
|
||
{ "value", company.id.ToString() }
|
||
};
|
||
allChannel.Add(channel);
|
||
}
|
||
CacheHelper.Set(cacheKey, allChannel, DateTime.Now.AddDays(1));
|
||
return allChannel;
|
||
}
|
||
|
||
#endregion 获取内部公司列表 cache_Company_getList
|
||
|
||
#region 获取短信类型
|
||
|
||
public List<SMS_MSGTYPE> GetSmsTypeList()
|
||
{
|
||
string cacheKey = "cache_smsTypeList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<SMS_MSGTYPE>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
List<SMS_MSGTYPE> msgType = db.SMS_MSGTYPE.ToList();
|
||
CacheHelper.Set(cacheKey, msgType);
|
||
return msgType;
|
||
}
|
||
}
|
||
|
||
public List<SMS_MSGSUBTYPE> GetSmsSubTypeList()
|
||
{
|
||
var cacheKey = "cache_smsSubTypeList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<SMS_MSGSUBTYPE>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var msgType = db.SMS_MSGSUBTYPE.ToList();
|
||
CacheHelper.Set(cacheKey, msgType);
|
||
return msgType;
|
||
}
|
||
}
|
||
|
||
public List<SMS_MSGTYPE_CLIENT> GetSmsClientList()
|
||
{
|
||
var cacheKey = "cache_smsClientList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<SMS_MSGTYPE_CLIENT>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var msgType = db.SMS_MSGTYPE_CLIENT.ToList();
|
||
CacheHelper.Set(cacheKey, msgType);
|
||
return msgType;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取短信类型 树形
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public object GetSmsTypeTreeList()
|
||
{
|
||
string cacheKey = "cache_smsType_getTreeList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<object>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
List<SMS_MSGTYPE> msgType = db.SMS_MSGTYPE.ToList();
|
||
List<SMS_MSGSUBTYPE> msgSubType = db.SMS_MSGSUBTYPE.ToList();
|
||
var obj = new List<object>();
|
||
foreach (var model in msgType)
|
||
{
|
||
obj.Add(new { id = "-" + model.TYPECODE, text = model.TYPENAME, children = GetSmsTypeTreeChildList(msgSubType, model.TYPECODE) });
|
||
}
|
||
CacheHelper.Set(cacheKey, obj);
|
||
return obj;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取短信crm短信类型 树形(根据短信大类)
|
||
/// </summary>
|
||
/// <param name="typeCode">短信大类</param>
|
||
/// <returns></returns>
|
||
public object GetSmsCrmTreeList()
|
||
{
|
||
string cacheKey = "cache_smsCrmType_getTreeList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<object>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
List<SMS_MSGTYPE> msgType = db.SMS_MSGTYPE.Where(m => m.TYPECODE == "CRMSMS0001").ToList();
|
||
List<SMS_MSGSUBTYPE> msgSubType = db.SMS_MSGSUBTYPE.ToList();
|
||
var obj = new List<object>();
|
||
foreach (var model in msgType)
|
||
{
|
||
obj.Add(new { id = "-" + model.TYPECODE, text = model.TYPENAME, children = GetSmsTypeTreeChildList(msgSubType, model.TYPECODE) });
|
||
}
|
||
CacheHelper.Set(cacheKey, obj);
|
||
return obj;
|
||
}
|
||
}
|
||
|
||
private List<object> GetSmsTypeTreeChildList(List<SMS_MSGSUBTYPE> msgSubType, string parentId)
|
||
{
|
||
var obj = new List<object>();
|
||
foreach (var model in msgSubType.Where(m => m.TYPECODE == parentId))
|
||
{
|
||
obj.Add(new { id = model.SUBTYPEID, typeCode = model.TYPECODE, subTypeCode = model.SUBTYPECODE, text = model.SUBTYPENAME });
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
#endregion 获取短信类型
|
||
|
||
#region 销售部列表
|
||
|
||
public List<BAS_SALESDEPARTMENT> GetList_SalesDepartMent()
|
||
{
|
||
string cacheKey = "cache_SalesDepartMent_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<BAS_SALESDEPARTMENT>>(cacheKey);
|
||
using (zxdContext db = new zxdContext())
|
||
{
|
||
var list = db.BAS_SALESDEPARTMENT.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
#endregion 销售部列表
|
||
|
||
#region 角色查询
|
||
|
||
/// <summary>
|
||
/// 获取工单小类信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<BAS_ROLE> GetList_Role()
|
||
{
|
||
string cacheKey = "cache_Role_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<BAS_ROLE>>(cacheKey);
|
||
using (zxdContext db = new zxdContext())
|
||
{
|
||
List<BAS_ROLE> list = db.BAS_ROLE.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取角色编码
|
||
/// </summary>
|
||
/// <param name="roleIds">角色ID数组</param>
|
||
/// <returns></returns>
|
||
public string Get_RoleCodes(int[] roleIds)
|
||
{
|
||
List<BAS_ROLE> roleList = GetList_Role().Where(m => roleIds.Contains(m.ROLEID)).ToList();
|
||
StringBuilder codes = new StringBuilder();
|
||
foreach (BAS_ROLE role in roleList)
|
||
{
|
||
codes.AppendFormat("[{0}]", role.CODE);
|
||
}
|
||
return codes.ToString();
|
||
}
|
||
|
||
#endregion 角色查询
|
||
|
||
#region 菜单缓存
|
||
|
||
/// <summary>
|
||
/// 菜单缓存
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<BAS_LEFTMEMU> GetList_LeftMemu()
|
||
{
|
||
string cacheKey = "cache_LeftMemu_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<BAS_LEFTMEMU>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var list = db.BAS_LEFTMEMU.ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模块导航菜单缓存
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<BAS_MODULEMENU> GetList_ModuleMenu()
|
||
{
|
||
string cacheKey = "cache_ModuleMenu_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<BAS_MODULEMENU>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var list = db.BAS_MODULEMENU.OrderBy(m => m.SORTID).ToList();
|
||
CacheHelper.Set(cacheKey, list);
|
||
return list;
|
||
}
|
||
}
|
||
|
||
#endregion 菜单缓存
|
||
#region AI机器人缓存
|
||
|
||
public List<RobotModel> GetAiRobotList()
|
||
{
|
||
string cacheKey = "cache_AiRobot_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<RobotModel>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var configName = Parameter.AI_CallTaskConfig.ToString();
|
||
var robot = db.BAS_PARAMETER.FirstOrDefault(n => n.PARAKEY == configName);
|
||
List<RobotModel> robotList = new List<RobotModel>();
|
||
if (robot != null)
|
||
{
|
||
try
|
||
{
|
||
var robotModel = JsonConvert.DeserializeObject<RobotModel>(robot.PARAVALUE);
|
||
robotList.Add(robotModel);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.Message);
|
||
}
|
||
}
|
||
CacheHelper.Set(cacheKey, robotList);
|
||
return robotList;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 默认所有状态 -1
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
/// <returns></returns>
|
||
public List<AiStatus> GetAiStatus(int type = -1)
|
||
{
|
||
string cacheKey = $"cache_AiStatus_{type}";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<AiStatus>>(cacheKey);
|
||
List<AiStatus> res = new List<AiStatus>();
|
||
var dic = GetAiHgrecordStatusnameKV(type);
|
||
foreach (var item in dic)
|
||
{
|
||
AiStatus obj = new AiStatus
|
||
{
|
||
Text = item.Value.ToString(),
|
||
Value = item.Key
|
||
};
|
||
res.Add(obj);
|
||
}
|
||
CacheHelper.Set(cacheKey, res);
|
||
return res;
|
||
}
|
||
|
||
public Dictionary<int, string> GetAiHgrecordStatusnameKV(int type)
|
||
{
|
||
Dictionary<int, string> Ai_hgrecord_statusnameKV = new Dictionary<int, string>();
|
||
switch (type)
|
||
{
|
||
case 1:
|
||
Ai_hgrecord_statusnameKV.Add(1, "等待AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(2, "已提交AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(3, "AI外呼失败(未答完)");
|
||
Ai_hgrecord_statusnameKV.Add(7, "AI外呼失败(挂断)");
|
||
Ai_hgrecord_statusnameKV.Add(4, "AI外呼未接通");
|
||
Ai_hgrecord_statusnameKV.Add(5, "AI外呼成功");
|
||
Ai_hgrecord_statusnameKV.Add(8, "AI外呼取消");
|
||
break;
|
||
|
||
case 2:
|
||
Ai_hgrecord_statusnameKV.Add(-1, "忽略不做AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(0, "尚未进行AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(1, "等待AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(2, "已提交AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(3, "AI外呼失败(未答完)");
|
||
Ai_hgrecord_statusnameKV.Add(7, "AI外呼失败(挂断)");
|
||
Ai_hgrecord_statusnameKV.Add(4, "AI外呼未接通");
|
||
Ai_hgrecord_statusnameKV.Add(5, "AI外呼成功");
|
||
Ai_hgrecord_statusnameKV.Add(6, "等待AI重拨");
|
||
Ai_hgrecord_statusnameKV.Add(-2, "AI重拨失败");
|
||
Ai_hgrecord_statusnameKV.Add(8, "AI外呼取消");
|
||
Ai_hgrecord_statusnameKV.Add(9, "人工回访成功");
|
||
Ai_hgrecord_statusnameKV.Add(10, "电子回访成功");
|
||
break;
|
||
|
||
default:
|
||
Ai_hgrecord_statusnameKV.Add(-1, "忽略不做AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(0, "尚未进行AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(1, "等待AI外呼");
|
||
Ai_hgrecord_statusnameKV.Add(2, "AI外呼需人工介入");
|
||
Ai_hgrecord_statusnameKV.Add(5, "AI外呼成功");
|
||
Ai_hgrecord_statusnameKV.Add(4, "电子回访成功");
|
||
Ai_hgrecord_statusnameKV.Add(9, "人工回访成功");
|
||
break;
|
||
}
|
||
return Ai_hgrecord_statusnameKV;
|
||
}
|
||
|
||
public List<AI_CallTaskConfig> GetAICallTaskConfigList()
|
||
{
|
||
string cacheKey = "cache_AiCallTaskConfig_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
return CacheHelper.Get<List<AI_CallTaskConfig>>(cacheKey);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var configName = Parameter.AI_CallTaskConfig.ToString();
|
||
var robot = db.BAS_PARAMETER.FirstOrDefault(n => n.PARAKEY == configName);
|
||
List<AI_CallTaskConfig> robotList = new List<AI_CallTaskConfig>();
|
||
if (robot != null)
|
||
{
|
||
try
|
||
{
|
||
var robotModel = JsonConvert.DeserializeObject<AI_CallTaskConfig>(robot.PARAVALUE);
|
||
robotList.Add(robotModel);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.Message);
|
||
}
|
||
}
|
||
CacheHelper.Set(cacheKey, robotList);
|
||
return robotList;
|
||
}
|
||
}
|
||
|
||
public bool UpdateAICallTaskConfigList(ref ValidationErrors errors, List<AI_CallTaskConfig> robotList)
|
||
{
|
||
string cacheKey = "cache_AiCallTaskConfig_getList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
CacheHelper.Set(cacheKey, robotList);
|
||
using (var db = new zxdContext())
|
||
{
|
||
var configName = Parameter.AI_CallTaskConfig.ToString();
|
||
var robot = db.BAS_PARAMETER.FirstOrDefault(n => n.PARAKEY == configName);
|
||
|
||
if (robot != null)
|
||
{
|
||
try
|
||
{
|
||
robot.PARAVALUE = JsonConvert.SerializeObject(robotList.FirstOrDefault());
|
||
db.SaveChanges();
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
errors.Add(ex.Message);
|
||
LogHelper.Error(ex.Message);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
}
|
||
|
||
#endregion AI机器人缓存
|
||
#region
|
||
|
||
public List<DeptMapModel> GetDeptNameMapList()
|
||
{
|
||
List<DeptMapModel> list;
|
||
string cacheKey = "cache_GetList_GetDeptNameMapList";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
{
|
||
list = CacheHelper.Get<List<DeptMapModel>>(cacheKey);
|
||
}
|
||
else
|
||
{
|
||
var webapi = GetValue_Parameter(CRM.Core.Model.Enum.Parameter.Zxd_CoreApiUrl);
|
||
var url = $"{webapi}Api/Deptment/Depts";
|
||
var dataJson = Utility.GetData(url, "", Encoding.UTF8);
|
||
var result = JsonConvert.DeserializeObject<DeptMapApiModel>(dataJson);
|
||
CacheHelper.Set(cacheKey, result.data, DateTime.Now.AddMinutes(30));
|
||
return result.data;
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public List<DeptChannelModel> ConvertChannelName(List<int> channelList)
|
||
{
|
||
var list = GetDeptNameMapList();
|
||
List<DeptChannelModel> res = new List<DeptChannelModel>();
|
||
Dictionary<int, string> res1 = new Dictionary<int, string>();
|
||
channelList = channelList.Distinct().ToList();
|
||
foreach (var channel in channelList)
|
||
{
|
||
foreach (var item in list)
|
||
{
|
||
foreach (var ch in item.deptmentCampains)
|
||
{
|
||
if (channel >= ch.startCampainId && channel <= ch.endCampainId)
|
||
{
|
||
res.Add(new DeptChannelModel
|
||
{
|
||
channel = channel,
|
||
title = item.title,
|
||
code = item.code,
|
||
id = item.id,
|
||
});
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return res;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取 报备流程的事业线
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<DeptmentDto> GetReportDeptments()
|
||
{
|
||
var data = new List<DeptmentDto>();
|
||
var cacheKey = "cache_Report_dept_list";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
{
|
||
data = CacheHelper.Get<List<DeptmentDto>>(cacheKey);
|
||
}
|
||
else
|
||
{
|
||
var webapi = GetValue_Parameter(Parameter.Zxd_CoreApiUrl);
|
||
var url = $"{webapi.Trim('/')}/Api/Deptment/Depts";
|
||
var result = Utility.GetData(url, "", Encoding.UTF8);
|
||
var response = JsonConvert.DeserializeObject<ApiResult<List<DeptmentDto>>>(result);
|
||
if (response.Code == 0)
|
||
{
|
||
var deptids = GetValue_Parameter("ReportDeptList");
|
||
if (!string.IsNullOrWhiteSpace(deptids))
|
||
{
|
||
var ids = JsonConvert.DeserializeObject<List<int>>(deptids);
|
||
|
||
data = response.Data.Where(n => ids.Contains(n.DepartmentId)).ToList();
|
||
}
|
||
else
|
||
{
|
||
data = response.Data;
|
||
}
|
||
CacheHelper.Set(cacheKey, data, DateTime.Now.AddMinutes(1));
|
||
}
|
||
}
|
||
return data;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取 报备流程的事业线
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public List<OperatorModel> GetReportOperator()
|
||
{
|
||
var data = new List<OperatorModel>();
|
||
var cacheKey = "cache_Report_Operator_list";
|
||
if (CacheHelper.Exists(cacheKey))
|
||
{
|
||
data = CacheHelper.Get<List<OperatorModel>>(cacheKey);
|
||
}
|
||
else
|
||
{
|
||
var webapi = GetValue_Parameter(Parameter.Hg_Core_WebApi);
|
||
//webapi = "https://localhost:7090";
|
||
var url = $"{webapi.Trim('/')}/api/Live/operator/Get";
|
||
var result = Utility.GetData(url, "", Encoding.UTF8);
|
||
var response = JsonConvert.DeserializeObject<ApiResult<List<OperatorModel>>>(result);
|
||
if (response.Code == 0)
|
||
{
|
||
data = response.Data;
|
||
CacheHelper.Set(cacheKey, data, DateTime.Now.AddMinutes(5));
|
||
}
|
||
}
|
||
return data;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
public class DeptMapApiModel
|
||
{
|
||
public List<DeptMapModel> data { get; set; }
|
||
}
|
||
|
||
public class DeptMapModel
|
||
{
|
||
public decimal id { get; set; }
|
||
public string title { get; set; }
|
||
public string code { get; set; }
|
||
public List<channelVirtualModel> deptmentCampains { get; set; }
|
||
}
|
||
|
||
public class channelVirtualModel
|
||
{
|
||
public int startCampainId { get; set; }
|
||
public int endCampainId { get; set; }
|
||
}
|
||
|
||
public class DeptChannelModel
|
||
{
|
||
public int channel { get; set; }
|
||
public decimal id { get; set; }
|
||
public string title { get; set; }
|
||
public string code { get; set; }
|
||
}
|
||
|
||
public class RobotModel
|
||
{
|
||
public string Robot { get; set; }
|
||
public string RobotName { get; set; }
|
||
public string Remark { get; set; }
|
||
public string SMS { get; set; }
|
||
public DateTime StartTime { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建订单外呼任务配置
|
||
/// </summary>
|
||
public class AI_CallTaskConfig
|
||
{
|
||
/// <summary>
|
||
/// 订单外呼起始时间
|
||
/// </summary>
|
||
public DateTime StartTime { get; set; } = DateTime.Parse("2021-12-01");
|
||
|
||
/// <summary>
|
||
/// 仅呼叫近几天支付的订单
|
||
/// </summary>
|
||
public int CallDay { get; set; } = 7;
|
||
|
||
public List<int> ReCallStatus { get; set; }
|
||
|
||
/// <summary>
|
||
/// //优先级别1-紧急 2-优先
|
||
/// </summary>
|
||
public string Priority { get; set; } = "2";
|
||
|
||
/// <summary>
|
||
/// 最小订单金额
|
||
/// </summary>
|
||
public decimal MinAmount { get; set; } = 1m;
|
||
|
||
public List<int> ReCallMins { get; set; }
|
||
|
||
/// <summary>
|
||
/// 同人检查时间,分钟
|
||
/// </summary>
|
||
public int SameUserCheckTimeSpanMin { get; set; } = 1;
|
||
|
||
/// <summary>
|
||
/// 呼叫忽略配置
|
||
/// </summary>
|
||
public List<HitConfig> IgnoreHitConfigs { get; set; } = new List<HitConfig>();
|
||
|
||
/// <summary>
|
||
/// 呼叫话术
|
||
/// </summary>
|
||
public ProposProductConfig proposProductConfig { get; set; } = new ProposProductConfig();
|
||
|
||
/// <summary>
|
||
/// 是否发短信1:发, 0:不发
|
||
/// </summary>
|
||
public int Sms { get; set; }
|
||
|
||
/// <summary>
|
||
/// 发短信多久后外呼,分钟
|
||
/// </summary>
|
||
public int SmsExprieMinCall { get; set; } = 1;
|
||
|
||
public string Robot { get; set; }
|
||
|
||
public string CallNo { get; set; }
|
||
|
||
public string AppId { get; set; }
|
||
|
||
public string RobotName { get; set; }
|
||
|
||
public string Remark { get; set; }
|
||
|
||
/// <summary>
|
||
/// 允许外拨时间段
|
||
/// </summary>
|
||
public string HgrecordStime { get; set; }
|
||
|
||
/// <summary>
|
||
/// 允许外拨时间段
|
||
/// </summary>
|
||
public string HgrecordEtime { get; set; }
|
||
|
||
/// <summary>
|
||
/// 白名单
|
||
/// </summary>
|
||
public List<string> WhiteList { get; set; } = new List<string>();
|
||
}
|
||
|
||
public class HitConfig
|
||
{
|
||
/// <summary>
|
||
/// key
|
||
/// </summary>
|
||
public string HitKey { get; set; } = "Channel";
|
||
|
||
/// <summary>
|
||
/// 包含
|
||
/// </summary>
|
||
public List<string> Contain { get; set; }
|
||
|
||
/// <summary>
|
||
/// 不包含
|
||
/// </summary>
|
||
public List<string> NoContain { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// Channel 为范围,|连接,左右包含,如1000|2000
|
||
/// </summary>
|
||
public enum HitKey
|
||
{ Channel, Subproductid, Resid }
|
||
|
||
/// <summary>
|
||
/// 渠道范围
|
||
/// </summary>
|
||
public class ChannelItem
|
||
{
|
||
public int Min { get; set; }
|
||
public int Max { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 话术模板配置
|
||
/// </summary>
|
||
public class ProposProductConfig
|
||
{
|
||
/// <summary>
|
||
/// 单个订单配置
|
||
/// </summary>
|
||
public string OneTemplate { get; set; } = "请问您购买的产品是@Subproductname,购买期限是【#OpenDays】天@GiftExp,您本次支付的订单金额是【#Arrivalpay】元,对吗?";
|
||
|
||
/// <summary>
|
||
/// 多个订单配置
|
||
/// </summary>
|
||
public string MultipleTemplate { get; set; } = "请问您购买的产品是@Subproductname,其中@PayExp,您本次支付的订单金额是【#Arrivalpay】元,对吗?";
|
||
|
||
/// <summary>
|
||
/// 产品名称配置
|
||
/// </summary>
|
||
public string Subproductname { get; set; } = "【#Subproductname】";
|
||
|
||
/// <summary>
|
||
/// 支付信息配置
|
||
/// </summary>
|
||
public string PayExp { get; set; } = "@Subproductname购买期限是【#OpenDays】天@GiftExp";
|
||
|
||
/// <summary>
|
||
/// 过期时间配置
|
||
/// </summary>
|
||
public string GiftExp { get; set; } = ",赠送期限是【#OpenDays】天,";
|
||
}
|
||
|
||
public class AiStatus
|
||
{
|
||
public string Text { get; set; }
|
||
public int Value { get; set; }
|
||
}
|
||
|
||
public class DeptmentDto
|
||
{
|
||
public int Id { get; set; }
|
||
|
||
public string Title { get; set; }
|
||
|
||
public string Code { get; set; }
|
||
|
||
public string Appid { get; set; }
|
||
|
||
public int DepartmentId { get; set; }
|
||
|
||
public bool? IsDept { get; set; }
|
||
|
||
public string CompanyCode { get; set; }
|
||
public int? SortNo { get; set; }
|
||
|
||
public List<DeptmentCampainDto> DeptmentCampains { get; set; }
|
||
}
|
||
|
||
public class DeptmentCampainDto
|
||
{
|
||
public int StartCampainId { get; set; }
|
||
|
||
public int EndCampainId { get; set; }
|
||
}
|
||
|
||
public class OperatorModel
|
||
{
|
||
public int? Eid { get; set; }
|
||
public string Ename { get; set; }
|
||
}
|
||
} |