LR-20210131IOQH\Administrator
2021-08-10 d4a6d65f5e449c3e5464aa18ae97bf8953987217
zhengcaioa/Services/CooperOrderService.cs
@@ -82,6 +82,12 @@
                    updateproject.Modifier = entity.Modifier;
                    updateproject.Modifytime = entity.Modifytime;
                    updateproject.SonghuoGongsi = entity.SonghuoGongsi;
                    updateproject.SonghuoDanhao = entity.SonghuoDanhao;
                    updateproject.SonghuoTime1 = entity.SonghuoTime1;
                    updateproject.HuifangJdr = entity.HuifangJdr;
                    updateproject.HuifangKehuyijian = entity.HuifangKehuyijian;
                }
                _context.SaveChanges();
@@ -148,7 +154,7 @@
                string[] XdTimes = searchEntity.XdTime.Split("|");
                DateTime.TryParse(XdTimes[0], out XdTimestart);
                DateTime.TryParse(XdTimes[1], out XdTimeend);
                //XdTimeend = XdTimeend.AddDays(1);
                XdTimeend = XdTimeend.AddDays(1);
            }
@@ -205,6 +211,16 @@
                      into ksssss
                         from kkk in ksssss.DefaultIfEmpty()
                         join l in _context.FiBooks
                    on a.OrderType1 equals l.Id
                    into lsssss
                         from lll in lsssss.DefaultIfEmpty()
                         join m in _context.FiMembers
                   on a.OrderType1 equals m.Id
                   into msssss
                         from mmm in msssss.DefaultIfEmpty()
                         where a.RecStatus == "A"
                          && (string.IsNullOrWhiteSpace(searchEntity.XdTime) || (a.XdTime >= XdTimestart && a.XdTime <= XdTimeend))
                                    && (string.IsNullOrWhiteSpace(searchEntity.Ywjl) || ggg.Ywjl == searchEntity.Ywjl.Trim())
@@ -221,12 +237,11 @@
                                          && (string.IsNullOrWhiteSpace(searchEntity.WangongStatus) || a.WangongStatus == searchEntity.WangongStatus.Trim())
                                           && (string.IsNullOrWhiteSpace(searchEntity.SonghuoStatus) || a.SonghuoStatus == searchEntity.SonghuoStatus.Trim())
                                            && (string.IsNullOrWhiteSpace(searchEntity.HuifangStatussss) || a.HuifangStatus == searchEntity.HuifangStatussss.Trim())
                                              && (string.IsNullOrWhiteSpace(searchEntity.HuiyuanId) || ggg.HuiyuanId == searchEntity.HuiyuanId.Trim())
                         select new CooperOrderDTO
        select new CooperOrderDTO
                         {
                             Id = a.Id,
                             XdTime = a.XdTime,
@@ -288,12 +303,19 @@
                             YouhuiStatus = kkk.Id,
                             OrderType1 = a.OrderType1,
                             OrderType2 = a.OrderType2,
                             OrderType1Name = string.IsNullOrEmpty(lll.BookName)? string.IsNullOrEmpty(mmm.MemberType)? a.OrderType1 : mmm.MemberType : lll.BookName,
                             SonghuoGongsi = a.SonghuoGongsi,
                             SonghuoDanhao = a.SonghuoDanhao,
                             SonghuoTime1 = a.SonghuoTime1,
                             HuifangJdr = a.HuifangJdr,
                             HuifangKehuyijian = a.HuifangKehuyijian,
                         }
                ).OrderByDescending(x => x.OrderNo).ToList();
            if (searchEntity.totalrows == 0)
            //if (searchEntity.totalrows == 0)
                searchEntity.totalrows = query.Count();
            var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
            data.LoadData(searchEntity, lianlist);
@@ -416,8 +438,11 @@
                updateproject.SonghuoStatus = dto.SonghuoStatus;
                updateproject.Songhuoer = dto.Songhuoer;
                updateproject.Songhuotime = dto.Songhuotime;
                updateproject.ShouliStatus = dto.ShouliStatus;
                updateproject.SonghuoTime1 = dto.SonghuoTime1;
                updateproject.SonghuoDanhao = dto.SonghuoDanhao;
                updateproject.SonghuoGongsi = dto.SonghuoGongsi;
                _context.SaveChanges();
                resultEntity.ReturnID = dto.Id;
@@ -480,13 +505,13 @@
                var updateproject = _context.CooperOrders.Find(dto.Id);
                updateproject.HuifangKehuyijian = dto.HuifangKehuyijian;
                updateproject.HuifangJdr =    dto.HuifangJdr;
                updateproject.Huifanger = dto.Huifanger;
                updateproject.Huifangtime = dto.Huifangtime;
                updateproject.HuifangStatus = dto.HuifangStatus;
                updateproject.Huifangremark = dto.Huifangremark;
                updateproject.PingjiaStatus = dto.PingjiaStatus;
                _context.SaveChanges();
                resultEntity.ReturnID = dto.Id;
@@ -695,7 +720,7 @@
        public List<CooperOrderDTO> GetList(string userid, DateTime datemin, DateTime datemax)
        {
            var entity = _context.CooperOrders.Where(x => x.RecStatus == "A" && x.Creater == userid && x.Shoulitime >= datemin && x.Shoulitime < datemax).ToList();
            var entity = _context.CooperOrders.Where(x => x.RecStatus == "A" && x.ShouliStatus != "0" && x.Creater == userid && x.Createtime >= datemin && x.Createtime < datemax).ToList();
@@ -704,5 +729,177 @@
            return result;
        }
        public List<CooperOrderDTO> GetListtongji(string userid, DateTime datemin, DateTime datemax)
        {
            var listCode = (from a in _context.SysCodeDtls
                            join b in _context.SysCodes
                            on a.CodeId equals b.Id
                            where a.RecStatus == "A"
                                          && b.RecStatus == "A"
                            select new CodeDataEntity()
                            {
                                CodeId = b.Id,
                                CodeTable = b.CodeTable,
                                CodeField = b.CodeField,
                                CodeSn = a.CodeSn,
                                Comments = a.Comments,
                                Contents = a.Contents,
                                RecStatus = a.RecStatus,
                                Sort = a.Sort
                            });
            var entity = (from a in _context.CooperOrders.Where(x => x.RecStatus == "A" && x.ShouliStatus != "0" && x.Creater == userid && x.Createtime >= datemin && x.Createtime < datemax)
                                          join b in listCode.Where(x => x.CodeTable == "CooperOrder" && x.CodeField == "shouli_status")
                                         on a.ShouliStatus equals b.CodeSn
                                         into bsss
                                         from bbb in bsss.DefaultIfEmpty()
                                         join c in listCode.Where(x => x.CodeTable == "CooperOrder" && x.CodeField == "huifang_status")
                                        on a.HuifangStatus equals c.CodeSn
                                        into csss
                                         from ccc in csss.DefaultIfEmpty()
                                         join d in listCode.Where(x => x.CodeTable == "CooperOrder" && x.CodeField == "pingjia_status")
                                       on a.PingjiaStatus equals d.CodeSn
                                       into dsss
                                         from ddd in dsss.DefaultIfEmpty()
                                         join e in listCode.Where(x => x.CodeTable == "system" && x.CodeField == "shifou")
                                        on a.ChedanStatus equals e.CodeSn
                                        into esssss
                                         from eee in esssss.DefaultIfEmpty()
                                         join f in listCode.Where(x => x.CodeTable == "CooperVisit" && x.CodeField == "jtype")
                                         on a.OrderType equals f.CodeSn
                                          into fsssss
                                         from fff in fsssss.DefaultIfEmpty()
                                         join g in _context.CooperatecustomCustomers.Where(x => x.RecStatus == "A")
                                          on a.Khdw equals g.Id
                                         into gsss
                                         from ggg in gsss.DefaultIfEmpty()
                                         join h in _context.Projects.Where(x => x.RecStatus == "A")
                                        on a.OrderPro equals h.Id
                                       into hsss
                                         from hhh in hsss.DefaultIfEmpty()
                                         join i in listCode.Where(x => x.CodeTable == "system" && x.CodeField == "shifou")
                                       on a.WangongStatus equals i.CodeSn
                                       into isssss
                                         from iii in isssss.DefaultIfEmpty()
                                         join j in listCode.Where(x => x.CodeTable == "system" && x.CodeField == "shifou")
                                       on a.SonghuoStatus equals j.CodeSn
                                       into jsssss
                                         from jjj in jsssss.DefaultIfEmpty()
                                         join k in _context.Oayouhuis.Where(x => x.Recstatus == "A")
                                      on a.Id equals k.CooperOrderId
                                      into ksssss
                                         from kkk in ksssss.DefaultIfEmpty()
                                         join l in _context.FiBooks
                                    on a.OrderType1 equals l.Id
                                    into lsssss
                                         from lll in lsssss.DefaultIfEmpty()
                                         join m in _context.FiMembers
                                   on a.OrderType1 equals m.Id
                                   into msssss
                                         from mmm in msssss.DefaultIfEmpty()
                                         select new CooperOrderDTO
                                         {
                                             Id = a.Id,
                                             XdTime = a.XdTime,
                                             XdTimeName = a.XdTime.ToString("yyyy-MM-dd"),
                                             OrderNo = a.OrderNo,
                                             Khdw = a.Khdw,
                                             KhdwName = ggg.Name,
                                             OrderType = a.OrderType,
                                             OrderTypeName = fff.Comments,
                                             OrderPro = a.OrderPro,
                                             OrderProName = hhh.Name,
                                             OrderNum = a.OrderNum,
                                             Price = a.Price,
                                             Money = a.Money,
                                             Shr = a.Shr,
                                             ShrAddress = a.ShrAddress,
                                             ShrTel = a.ShrTel,
                                             Remark = a.Remark,
                                             Creater = a.Creater,
                                             Createtime = a.Createtime,
                                             RecStatus = a.RecStatus,
                                             Modifier = a.Modifier,
                                             Modifytime = a.Modifytime,
                                             ShouliStatus = a.ShouliStatus,
                                             ShouliStatusName = bbb.Comments,
                                             Shoulier = a.Shoulier,
                                             Shoulitime = a.Shoulitime,
                                             ChedanStatus = a.ChedanStatus,
                                             ChedanStatusName = eee.Comments,
                                             Chedaner = a.Chedaner,
                                             Chedantime = a.Chedantime,
                                             Chedan = a.Chedan,
                                             HuifangStatus = a.HuifangStatus,
                                             HuifangStatusName = ccc.Comments,
                                             Huifanger = a.Huifanger,
                                             Huifangtime = a.Huifangtime,
                                             Huifangremark = a.Huifangremark,
                                             PingjiaStatus = a.PingjiaStatus,
                                             PingjiaStatusName = ddd.Comments,
                                             Pingjiaer = a.Pingjiaer,
                                             Pingjiatime = a.Pingjiatime,
                                             Youhui = a.Youhui,
                                             Youhuier = a.Youhuier,
                                             Youhuitime = a.Youhuitime,
                                             SonghuoStatusName = jjj.Comments,
                                             SonghuoStatus = a.SonghuoStatus,
                                             Songhuoer = a.Songhuoer,
                                             Songhuotime = a.Songhuotime,
                                             WangongStatusName = iii.Comments,
                                             WangongStatus = a.WangongStatus,
                                             Wangonger = a.Wangonger,
                                             Wangongtime = a.Wangongtime,
                                             YouhuiStatus = kkk.Id,
                                             OrderType1 = a.OrderType1,
                                             OrderType2 = a.OrderType2,
                                             OrderType1Name = string.IsNullOrEmpty(lll.BookName) ? string.IsNullOrEmpty(mmm.MemberType) ? a.OrderType1 : mmm.MemberType : lll.BookName,
                                             SonghuoGongsi = a.SonghuoGongsi,
                                             SonghuoDanhao = a.SonghuoDanhao,
                                             SonghuoTime1 = a.SonghuoTime1,
                                             HuifangJdr = a.HuifangJdr,
                                             HuifangKehuyijian = a.HuifangKehuyijian,
                                         }
                ).OrderByDescending(x => x.OrderNo).ToList();
            return entity;
        }
    }
}