128 lines
4.9 KiB
C#
128 lines
4.9 KiB
C#
using System;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Base
|
|
{
|
|
public class BAS_INNERUSER_EXT_BL : IBAS_INNERUSER_EXT_Q, IBAS_INNERUSER_EXT
|
|
{
|
|
public BAS_INNERUSER_EXT GetModel_InneruserExt(decimal id)
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
return db.BAS_INNERUSER_EXT.FirstOrDefault(m => m.INNERUSERID == id);
|
|
}
|
|
}
|
|
|
|
public bool Create_InnerUserExtend(ref ValidationErrors errors, BAS_INNERUSER_EXT model)
|
|
{
|
|
try
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
BAS_INNERUSER_EXT entry = db.BAS_INNERUSER_EXT.FirstOrDefault(m => m.INNERUSERID == model.INNERUSERID);
|
|
if (entry != null)
|
|
{
|
|
errors.Add("该员工扩展信息已存在!");
|
|
return false;
|
|
}
|
|
db.BAS_INNERUSER_EXT.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Update_InnerUserExtend(ref ValidationErrors errors, BAS_INNERUSER_EXT model, decimal operuserid)
|
|
{
|
|
try
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
BAS_INNERUSER_EXT entry = db.BAS_INNERUSER_EXT.FirstOrDefault(m => m.INNERUSERID == model.INNERUSERID);
|
|
if (entry == null)
|
|
return false;
|
|
////客服经理修改 添加日志
|
|
//if (entry.GJS_CUSTOMERMANAGER != model.GJS_CUSTOMERMANAGER)
|
|
//{
|
|
// BAS_INNERUSER_EXT_LOG log = Addlog(entry.INNERUSERID, operuserid, 1, model.GJS_CUSTOMERMANAGER, entry.GJS_CUSTOMERMANAGER);
|
|
// db.BAS_INNERUSER_EXT_LOG.Add(log);
|
|
//}
|
|
|
|
////客服修改 添加日志
|
|
//if (entry.GENERALCUSTOMER != model.GENERALCUSTOMER)
|
|
//{
|
|
// BAS_INNERUSER_EXT_LOG log = Addlog(entry.INNERUSERID, operuserid, 2, model.GENERALCUSTOMER, entry.GENERALCUSTOMER);
|
|
// db.BAS_INNERUSER_EXT_LOG.Add(log);
|
|
//}
|
|
|
|
////高级客服修改 添加日志
|
|
//if (entry.SENIORCUSTOMER != model.SENIORCUSTOMER)
|
|
//{
|
|
// BAS_INNERUSER_EXT_LOG log = Addlog(entry.INNERUSERID, operuserid, 3, model.SENIORCUSTOMER, entry.SENIORCUSTOMER);
|
|
// db.BAS_INNERUSER_EXT_LOG.Add(log);
|
|
//}
|
|
|
|
entry.FXH_FUTURESSTATUS = model.FXH_FUTURESSTATUS;
|
|
entry.FXH_TRADERSTATUS = model.FXH_TRADERSTATUS;
|
|
entry.FXH_TUTORSTATUS = model.FXH_TUTORSTATUS;
|
|
//entry.GJS_CUSTOMERMANAGER = model.GJS_CUSTOMERMANAGER;
|
|
//entry.GENERALCUSTOMER = model.GENERALCUSTOMER;
|
|
//entry.SENIORCUSTOMER = model.SENIORCUSTOMER;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void Update_UserCustomer(BAS_INNERUSER_EXT model, decimal operuserid)
|
|
{
|
|
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
BAS_INNERUSER_EXT entry = db.BAS_INNERUSER_EXT.FirstOrDefault(m => m.INNERUSERID == model.INNERUSERID);
|
|
if (entry == null)
|
|
throw new Exception("未找到扩展信息");
|
|
//客服经理修改 添加日志
|
|
|
|
BAS_INNERUSER_EXT_LOG log = Addlog(entry.INNERUSERID, operuserid, 5, model.CustomerType, entry.CustomerType);
|
|
db.BAS_INNERUSER_EXT_LOG.Add(log);
|
|
|
|
entry.GJS_CUSTOMERMANAGER = model.GJS_CUSTOMERMANAGER;
|
|
entry.GENERALCUSTOMER = model.GENERALCUSTOMER;
|
|
entry.SENIORCUSTOMER = model.SENIORCUSTOMER;
|
|
db.SaveChanges();
|
|
}
|
|
|
|
}
|
|
|
|
public BAS_INNERUSER_EXT_LOG Addlog(decimal inneruser, decimal operuserid, decimal type, decimal? newstatus, decimal? oldstatus)
|
|
{
|
|
BAS_INNERUSER_EXT_LOG log = new BAS_INNERUSER_EXT_LOG
|
|
{
|
|
PKID = new SEQUENCES_BL().Seq_base_get(),
|
|
UTIME = DateTime.Now,
|
|
OPTIONUSER = operuserid,
|
|
INNERUSERID = inneruser,
|
|
NEWSTATUS = newstatus,
|
|
OLDSTATUS = oldstatus,
|
|
EXTENDTYPE = type
|
|
};
|
|
return log;
|
|
}
|
|
}
|
|
}
|