100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.IBLL.Wx;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
|
|
namespace WX.CRM.BLL.Wx
|
|
{
|
|
public class WX_BALANCESALEGROUPERAUDIT_BL3 : DbContextRepository<WX_BALANCESALEGROUPERAUDIT3>, IWX_BALANCESALEGROUPERAUDIT3
|
|
{
|
|
public IList<WX_BALANCESALEGROUPERAUDIT3> GetAutitList(decimal[] gId, DateTime? balanceCode, string status, decimal? userId)
|
|
{
|
|
var where = PredicateExtensionses.True<WX_BALANCESALEGROUPERAUDIT3>();
|
|
if (gId != null && gId.Length > 1)
|
|
{
|
|
var g0 = gId[0];
|
|
var g1 = gId[1];
|
|
//where = where.And(p => p.GID == gId.Value);
|
|
//where = where.And(p => gId.Contains(p.GID.GetValueOrDefault()));
|
|
where = where.And(p => p.GID == g0 || p.GID == g1);
|
|
|
|
}
|
|
else if (gId != null && gId.Length > 0)
|
|
{
|
|
var g0 = gId[0];
|
|
where = where.And(p => p.GID == g0);
|
|
}
|
|
if (balanceCode.HasValue)
|
|
{
|
|
where = where.And(p => p.MONTH == balanceCode.Value);
|
|
}
|
|
if (!string.IsNullOrEmpty(status))
|
|
{
|
|
where = where.And(p => p.STATUS == status);
|
|
}
|
|
if (userId.HasValue)
|
|
{
|
|
where = where.And(p => p.INNERUSERID == userId);
|
|
}
|
|
var list = GetList(where);
|
|
return list.ToList();
|
|
}
|
|
|
|
public void AuditPerformanceGrouper(decimal PKID, int sta, string remark, decimal auditid, string auditname)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var info = db.WX_BALANCESALEGROUPERAUDIT3.FirstOrDefault(p => p.PKID == PKID);
|
|
if (info == null)
|
|
{
|
|
throw new Exception("未找到结算记录!");
|
|
}
|
|
if (info.STATUS == "已确认")
|
|
{
|
|
throw new Exception("已经确认过了!");
|
|
}
|
|
if (sta == 0)
|
|
info.STATUS = "未确认";
|
|
else if (sta == 1)
|
|
info.STATUS = "已确认";
|
|
else info.STATUS = "未知";
|
|
info.REMARK = remark;
|
|
info.AUDITBYUSERID = auditid;
|
|
info.AUDITBYUSERNAME = auditname;
|
|
info.AUDITTIME = System.DateTime.Now;
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
public void AuditBatchPerformanceGrouper(DateTime balanceCode, decimal userid, string auditname)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var balanceid = db.WX_BALANCESALEGROUPERAUDIT3.Where(p => p.MONTH == balanceCode).Max(m => m.BALANCEBATCHID);
|
|
|
|
var q = from a in db.WX_BALANCESALEGROUPERAUDIT3
|
|
join u in db.BAS_INNERUSER on a.INNERUSERID equals u.PKID
|
|
where a.BALANCEBATCHID == balanceid
|
|
&& a.MONTH == balanceCode
|
|
&& u.ISDISMISS == 1
|
|
&& a.STATUS == "未确认"
|
|
select a;
|
|
int c = q.Count();
|
|
if (c == 0)
|
|
throw new Exception("已经确认完成,不需要再次确认!");
|
|
var lis = q.ToList();
|
|
foreach (var o in lis)
|
|
{
|
|
o.STATUS = "已确认";
|
|
o.AUDITBYUSERID = userid;
|
|
o.AUDITBYUSERNAME = auditname;
|
|
o.AUDITTIME = System.DateTime.Now;
|
|
o.REMARK = "批量确认";
|
|
}
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|