286 lines
9.9 KiB
C#
286 lines
9.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WX.CRM.BLL.Application.UserComBox;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.Common.Layui;
|
|
using WX.CRM.DAL.Ww;
|
|
using WX.CRM.IBLL.Ww;
|
|
using WX.CRM.Model.crmModel;
|
|
using WX.CRM.Model.DTO;
|
|
using WX.CRM.Model.Entity;
|
|
using WX.CRM.Model.Ww;
|
|
|
|
namespace WX.CRM.BLL.Ww
|
|
{
|
|
public class Ww_huser_BL : IWw_huser
|
|
{
|
|
|
|
private Ww_huser_Dal _dal = new Ww_huser_Dal();
|
|
private WW_HHUSER_EID_ACT_BL _hhUserAct = new WW_HHUSER_EID_ACT_BL();
|
|
private CACHE_BL cache_BL = new CACHE_BL();
|
|
public List<Ww_Corp> Corp_Get()
|
|
{
|
|
return new Ww_huser_Dal().Corp_Get();
|
|
}
|
|
/// <summary>
|
|
/// 外部联系人单个获取
|
|
/// </summary>
|
|
/// <param name="userid"></param>
|
|
/// <returns></returns>
|
|
public Ww_Extuser ExtUserGet(string userid)
|
|
{
|
|
return new Ww_huser_Dal().ExtUserGet(userid);
|
|
}
|
|
|
|
public Ww_hhuser HHuser_Get(string userid)
|
|
{
|
|
return new Ww_huser_Dal().HHuser_Get(userid);
|
|
}
|
|
public Ww_hhuser HHuser_Get(string userid, string corpid)
|
|
{
|
|
return new Ww_huser_Dal().HHuser_Get(userid, corpid);
|
|
}
|
|
/// <summary>
|
|
/// 获取企业微信成员列表
|
|
/// </summary>
|
|
/// <param name="v_name"></param>
|
|
/// <param name="v_corpid"></param>
|
|
/// <param name="v_deptid"></param>
|
|
/// <returns></returns>
|
|
public List<Ww_hhuserModel> WorList_Get(ref Laypage page, string v_name, string v_corpid, string v_deptid, decimal? txt_companyId, string txt_deptId, string txt_groupIds, decimal? txt_userId, decimal? seid, int assignStatus,int orderType)
|
|
{
|
|
List<decimal> ALLdeptIDS = new List<decimal>();
|
|
List<decimal> ALLgidS = new List<decimal>();
|
|
if (!string.IsNullOrEmpty(txt_deptId))
|
|
{
|
|
var depts = OperationUtil.ConvertToDecimal(txt_deptId.Split(','));
|
|
UserServices userservices = new UserServices(cache_BL);
|
|
foreach (var item in depts)
|
|
{
|
|
List<decimal> deptIDS = new List<decimal>();
|
|
List<decimal> gidS = new List<decimal>();
|
|
userservices.GetAllDeptIDOrGidByDeptId(item, ref deptIDS, ref gidS);//获取所有的组别和gid
|
|
ALLdeptIDS.AddRange(deptIDS);
|
|
ALLgidS.AddRange(gidS);
|
|
}
|
|
}
|
|
return new Ww_huser_Dal().WorList_Get(ref page, v_name, v_corpid, v_deptid, txt_companyId, txt_deptId, txt_groupIds, txt_userId, seid, assignStatus, ALLdeptIDS, ALLgidS, orderType);
|
|
}
|
|
public Dictionary<string, List<int>> GetAllCorpDept(string companycode)
|
|
{
|
|
return new Ww_huser_Dal().GetAllCorpDept(companycode);
|
|
}
|
|
public List<Ww_Extuser> GeExtUsertList(string corpid, string name, ref Pager pager)
|
|
{
|
|
return new Ww_huser_Dal().GeExtUsertList(corpid, name, ref pager);
|
|
}
|
|
|
|
public WW_HHUSER_EID GetModel(string userid, string corp)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
return db.WW_HHUSER_EID.FirstOrDefault(m => m.CORPID == corp && m.USERID == userid);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据客服ID
|
|
/// </summary>
|
|
/// <param name="userid"></param>
|
|
/// <returns></returns>
|
|
public List<WW_HHUSER_EID> GetUserList(params decimal[] userid)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
return db.WW_HHUSER_EID.Where(m => userid.Contains(m.INNERUSERID)).ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据客服的企微ID
|
|
/// </summary>
|
|
/// <param name="userid"></param>
|
|
/// <returns></returns>
|
|
public List<WW_HHUSER_EID> GetUserListByQWUserId(params string[] userid)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
if (userid == null || userid.Length == 0)
|
|
return new List<WW_HHUSER_EID>();
|
|
return db.WW_HHUSER_EID.Where(m => userid.Contains(m.USERID)).ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置工号
|
|
/// </summary>
|
|
/// <param name="eid"></param>
|
|
/// <param name="userid"></param>
|
|
/// <param name="corp"></param>
|
|
/// <param name="erro"></param>
|
|
/// <returns></returns>
|
|
public bool SetEid(decimal eid, string userid, string corp, decimal? status, ref ValidationErrors erro)
|
|
{
|
|
bool isok = false;
|
|
try
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var model = db.WW_HHUSER_EID.FirstOrDefault(m => m.CORPID == corp && m.USERID == userid);
|
|
var user = db.BAS_INNERUSER.FirstOrDefault(m => m.EID == eid && m.ISDISMISS == 0);
|
|
if (user == null)
|
|
{
|
|
erro.Add("工号不正确!");
|
|
return false;
|
|
}
|
|
if (model == null)
|
|
{
|
|
model = new WW_HHUSER_EID()
|
|
{
|
|
CORPID = corp,
|
|
EID = eid,
|
|
USERID = userid,
|
|
INNERUSERID = user.PKID
|
|
};
|
|
if (status.HasValue)
|
|
{
|
|
model.ASSIGNSTATUS = status;
|
|
}
|
|
db.WW_HHUSER_EID.Add(model);
|
|
}
|
|
else
|
|
{
|
|
model.EID = eid;
|
|
model.INNERUSERID = user.PKID;
|
|
if (status.HasValue)
|
|
{
|
|
model.ASSIGNSTATUS = status;
|
|
}
|
|
}
|
|
|
|
db.WW_HHUSER_EID_ACT.Add(new WW_HHUSER_EID_ACT(new SEQUENCES_BL().Seq_base_get(Model.Enum.PKIDType.LargeTable), model.CORPID, model.USERID, Convert.ToInt32(model.EID), status, "addOrupdate"));
|
|
|
|
db.SaveChanges();
|
|
isok = true;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e.ToString());
|
|
erro.Add(e.ToString());
|
|
}
|
|
return isok;
|
|
|
|
}
|
|
|
|
public bool SetAssignStatus(AssignStatusDto dto)
|
|
{
|
|
try
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var model = db.WW_HHUSER_EID.FirstOrDefault(m => m.CORPID == dto.appid && m.USERID == dto.userid);
|
|
if (model != null)
|
|
{
|
|
model.ASSIGNSTATUS = dto.status;
|
|
model.ERRORCODE = dto.errcode;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
LogHelper.Info("不能找到数据:" + dto.ToJson());
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取企业合规的关键词
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Hg_KeyWord> GetKeyWordAll()
|
|
{
|
|
return new Ww_huser_Dal().GetKeyWordAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改关键字
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool UpdateKeyWord(Hg_KeyWordAllModel model, ref string message)
|
|
{
|
|
return new Ww_huser_Dal().UpdateKeyWord(model, ref message);
|
|
}
|
|
|
|
public bool SetKeyWords(string keywords, ref ValidationErrors erro)
|
|
{
|
|
return new Ww_huser_Dal().SetKeyWords(keywords, ref erro);
|
|
}
|
|
public List<Hg_MessageModel> GetHg_Message(ref Pager pager, string userNames, DateTime? msgstime, DateTime? msgetime, DateTime? stime, DateTime? etime, string keyword, string kefid, string userid, int? status)
|
|
{
|
|
return new Ww_huser_Dal().GetHg_Message(ref pager, userNames, msgstime, msgetime, stime, etime, keyword, kefid, userid, status);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将合规信息修改成已读
|
|
/// </summary>
|
|
/// <param name="msgid"></param>
|
|
/// <returns></returns>
|
|
public bool Read(string msgid)
|
|
{
|
|
return new Ww_huser_Dal().Read(msgid);
|
|
}
|
|
/// <summary>
|
|
/// 根据msgid获取 违规关键字
|
|
/// </summary>
|
|
/// <param name="msgids"></param>
|
|
/// <returns></returns>
|
|
public List<Hg_Message_WordModel> GetMsgWordList(params string[] msgids)
|
|
{
|
|
return new Ww_huser_Dal().GetMsgWordList(msgids);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 已经违规
|
|
/// </summary>
|
|
/// <param name="msgid"></param>
|
|
/// <returns></returns>
|
|
public bool Violations(string msgid)
|
|
{
|
|
return new Ww_huser_Dal().Violations(msgid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取单条数据
|
|
/// </summary>
|
|
/// <param name="msgid"></param>
|
|
/// <returns></returns>
|
|
public Hg_MessageModel GetMsgById(string msgid)
|
|
{
|
|
return new Ww_huser_Dal().GetMsgById(msgid);
|
|
}
|
|
|
|
public Ww_Extuser GetExtUserByUnionId(string unionid)
|
|
{
|
|
return _dal.GetExtUserByUnionId(unionid);
|
|
}
|
|
|
|
public List<Ww_User_Extuser> GetUserExtUserByUserId(string userid)
|
|
{
|
|
return _dal.GetUserExtUserByUserId(userid);
|
|
}
|
|
}
|
|
}
|