167 lines
5.9 KiB
C#
167 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.QH;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.QH
|
|
{
|
|
public class QH_CUSTOMER_RESID_BL : DbContextRepository<QH_CUSTOMER_RESID>, IQH_CUSTOMER_RESID
|
|
{
|
|
public bool Add(QH_CUSTOMER_RESID qH_CUSTOMER_RESID, ref ValidationErrors errors)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
db.QH_CUSTOMER_RESID.Add(qH_CUSTOMER_RESID);
|
|
result = db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
public bool SetRecord(string resid, string recordid, decimal userid, ref ValidationErrors errors)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
QH_CUSTOMER_RESID model = db.QH_CUSTOMER_RESID.FirstOrDefault(m => m.RESID == resid);
|
|
if (model == null)
|
|
{
|
|
errors.Add("找不到数据!");
|
|
return false;
|
|
}
|
|
if (model.STATUS != 0)
|
|
{
|
|
|
|
string statusMsg = "未知";
|
|
if (model.STATUS.HasValue)
|
|
{
|
|
statusMsg = GetStatus(Convert.ToInt32(model.STATUS));
|
|
}
|
|
errors.Add("当前状态" + statusMsg + ",不能选择风控录音!");
|
|
return false;
|
|
}
|
|
model.RECORDID = Convert.ToDecimal(recordid);
|
|
model.RECORDUSERID = userid;
|
|
model.STATUS = 1;
|
|
model.RECORDCTIME = DateTime.Now;
|
|
result = db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
public bool Check(string resid, string useraccount, decimal userid, ref ValidationErrors errors)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
QH_CUSTOMER_RESID model = db.QH_CUSTOMER_RESID.FirstOrDefault(m => m.RESID == resid);
|
|
if (model == null)
|
|
{
|
|
errors.Add("找不到数据!");
|
|
return false;
|
|
}
|
|
if (model.STATUS != 1)
|
|
{
|
|
|
|
string statusMsg = "未知";
|
|
if (model.STATUS.HasValue)
|
|
{
|
|
statusMsg = GetStatus(Convert.ToInt32(model.STATUS));
|
|
}
|
|
errors.Add("当前状态" + statusMsg + ",不能通过审核!");
|
|
return false;
|
|
}
|
|
model.AUDITUSERID = userid;
|
|
model.AUDITTIME = DateTime.Now;
|
|
model.USERACCOUNT = useraccount;
|
|
model.STATUS = 2;
|
|
model.RECORDCTIME = DateTime.Now;
|
|
result = db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
private string GetStatus(int status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case 0: return "[已注册]";
|
|
case 1: return "[风控审核中]";
|
|
case 2: return "[审核通过]";
|
|
default: return "[未知]";
|
|
}
|
|
}
|
|
public List<QH_CUSTOMER_RESID> GetList(string[] resids)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var query = db.QH_CUSTOMER_RESID.AsQueryable();
|
|
query = query.Where(m => resids.Contains(m.RESID));
|
|
return query.ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取开户列表
|
|
/// </summary>
|
|
/// <param name="pager">分页信息</param>
|
|
/// <param name="resid">客户ID</param>
|
|
/// <param name="status">状态</param>
|
|
/// <param name="stime">时间过滤</param>
|
|
/// <param name="etime">结束时间</param>
|
|
/// <returns></returns>
|
|
public List<QH_CUSTOMER_RESID> GetList(ref Pager pager, string resid, decimal status, DateTime? stime, DateTime? etime)
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
var queryData = db.QH_CUSTOMER_RESID.AsQueryable<WX.CRM.Model.Entity.QH_CUSTOMER_RESID>();
|
|
|
|
if (!string.IsNullOrWhiteSpace(resid))
|
|
{
|
|
queryData = queryData.Where(m => m.RESID == resid);
|
|
}
|
|
if (status != -1)
|
|
{
|
|
queryData = queryData.Where(a => a.STATUS == status);
|
|
}
|
|
if (stime.HasValue)
|
|
{
|
|
queryData = queryData.Where(a => a.CTIME >= stime.Value);
|
|
}
|
|
if (etime.HasValue)
|
|
{
|
|
etime = etime.Value.AddDays(1);
|
|
queryData = queryData.Where(a => a.CTIME < etime.Value);
|
|
}
|
|
queryData = queryData.OrderByDescending(m => m.CTIME);
|
|
PagerUtil.SetPager<WX.CRM.Model.Entity.QH_CUSTOMER_RESID>(ref queryData, ref pager);//分页
|
|
return queryData.ToList();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |