Exemplo n.º 1
0
        /// <summary>
        /// 获取需导出的账单款项列表
        /// </summary>
        /// <returns></returns>
        public virtual Dictionary <int, List <byte> > GetBillList(out decimal TotalAmount, List <Customer> customers)
        {
            TotalAmount = 0;
            Dictionary <int, List <byte> > retbyte = new Dictionary <int, List <byte> >();

            if (DeductCommandList.Count < 0)//如果没有此子公司的配置,则直接返回null
            {
                return(null);
            }
            var query = _FinanceFactory.CreateBillDAL().GetBillList(EnumBillStatus.Debts)
                        .Where(p => p.Business.ServicerSideID == DeductCommandList.FirstOrDefault().ServiceSideID)
                        .GroupBy(p => p.BusinessID).Select(z => new
            {
                ListBill = z.ToList()
            });

            if (query.Count() < 0)
            {
                return(null);
            }
            List <BillItem> fwfksbillitems = new List <BillItem>();

            retbyte.Add(SerDc.ServiceSideID, new List <byte>());
            Dictionary <int, List <BillItem> > bxksbillitems = new Dictionary <int, List <BillItem> >();
            Dictionary <int, List <BillItem> > fxbillitems   = new Dictionary <int, List <BillItem> >();

            foreach (var a in LendingDc)
            {
                retbyte.Add(a.LendingSideID, new List <byte>());
                bxksbillitems.Add(a.LendingSideID, new List <BillItem>());
                fxbillitems.Add(a.LendingSideID, new List <BillItem>());
            }
            foreach (var list in query)
            {
                List <Bill> bills = list.ListBill;
                for (int i = 0; i < bills.Count(); i++)
                {
                    if (bills[i].BillMonth.Trim() == GetDate())//判断是否是当期账单(若能,把存在逾期的本息扣失和罚息添加)
                    {
                        if (!IsExporeDQ(bills[i]))
                        {
                            continue;
                        }
                    }

                    if (GetIfResult(fwfksbillitems))//导出当期服务、担保费前,先把逾期服务费扣失添加上
                    {
                        TotalAmount += fwfksbillitems.Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[SerDc.ServiceSideID].AddRange(GetBankExportTemplate(SerDc).FomartTemplate(fwfksbillitems, customers));
                        fwfksbillitems = new List <BillItem>();
                    }
                    var fd = GetNoFullPayFD(bills[i].BillItems);//服务费、担保费
                    if (fd.Count > 0)
                    {
                        TotalAmount += fd.Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[SerDc.ServiceSideID].AddRange(GetBankExportTemplate(SerDc).FomartTemplate(fd, customers));
                    }
                    var fwfks = GetNoFullPayFWFKS(bills[i].BillItems);//服务费扣失
                    if (fwfks != null)
                    {
                        fwfksbillitems.Add(fwfks);
                    }

                    for (int j = 0; j < LendingDc.Count; j++)
                    {
                        if (GetIfResult(bxksbillitems[LendingDc[j].LendingSideID]))//本息扣失
                        {
                            TotalAmount += bxksbillitems[LendingDc[j].LendingSideID].Sum(p => p.Amount - p.ReceivedAmt);
                            retbyte[LendingDc[j].LendingSideID].AddRange(GetBankExportTemplate(LendingDc[j]).FomartTemplate(bxksbillitems[LendingDc[j].LendingSideID], customers));
                            bxksbillitems[LendingDc[j].LendingSideID] = new List <BillItem>();
                        }
                        if (GetIfResult(fxbillitems[LendingDc[j].LendingSideID]))//罚息
                        {
                            TotalAmount += fxbillitems[LendingDc[j].LendingSideID].Sum(p => p.Amount - p.ReceivedAmt);
                            retbyte[LendingDc[j].LendingSideID].AddRange(GetBankExportTemplate(LendingDc[j]).FomartTemplate(fxbillitems[LendingDc[j].LendingSideID], customers));
                            fxbillitems[LendingDc[j].LendingSideID] = new List <BillItem>();
                        }
                        if (bills[i].Business.LendingSideID == LendingDc[j].LendingSideID)
                        {
                            var bx = GetNoFullPayBX(bills[i].BillItems);//本息
                            if (bx.Count > 0)
                            {
                                TotalAmount += bx.Sum(p => p.Amount - p.ReceivedAmt);
                                retbyte[LendingDc[j].LendingSideID].AddRange(GetBankExportTemplate(LendingDc[j]).FomartTemplate(bx, customers));
                            }
                            var bxks = GetNoFullPayBXKS(bills[i].BillItems);//本息扣失
                            if (bxks != null)
                            {
                                bxksbillitems[LendingDc[j].LendingSideID].Add(bxks);
                            }
                            var fx = GetNoFullPayFX(bills[i].BillItems);//罚息
                            if (fx != null)
                            {
                                fxbillitems[LendingDc[j].LendingSideID].Add(fx);
                            }
                        }
                    }
                }
                for (int k = 0; k < LendingDc.Count; k++)
                {
                    if (bxksbillitems[LendingDc[k].LendingSideID].Count() > 0)
                    {
                        TotalAmount += bxksbillitems[LendingDc[k].LendingSideID].Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[LendingDc[k].LendingSideID].AddRange(GetBankExportTemplate(LendingDc[k]).FomartTemplate(bxksbillitems[LendingDc[k].LendingSideID], customers));
                        bxksbillitems[LendingDc[k].LendingSideID] = new List <BillItem>();
                    }
                    if (fxbillitems[LendingDc[k].LendingSideID].Count() > 0)
                    {
                        TotalAmount += fxbillitems[LendingDc[k].LendingSideID].Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[LendingDc[k].LendingSideID].AddRange(GetBankExportTemplate(LendingDc[k]).FomartTemplate(fxbillitems[LendingDc[k].LendingSideID], customers));
                        fxbillitems[LendingDc[k].LendingSideID] = new List <BillItem>();
                    }
                }
                if (fwfksbillitems.Count() > 0)
                {
                    TotalAmount += fwfksbillitems.Sum(p => p.Amount - p.ReceivedAmt);
                    retbyte[SerDc.ServiceSideID].AddRange(GetBankExportTemplate(SerDc).FomartTemplate(fwfksbillitems, customers));
                    fwfksbillitems = new List <BillItem>();
                }
            }
            return(retbyte);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取需导出的账单款项列表
        /// </summary>
        /// <returns></returns>
        public virtual Dictionary <int, List <string[]> > GetBillListExcelAndTxT(out decimal TotalAmount
                                                                                 , out Dictionary <int, List <byte> > retbyte,
                                                                                 List <Customer> customers, List <BankAccount> bankaccounts, List <Enumeration> enums, string bankkey)
        {
            TotalAmount = 0; int num = 1; retbyte = new Dictionary <int, List <byte> >(); int[] ser = new int[1] {
                1
            };
            Dictionary <int, List <string[]> > retstring = new Dictionary <int, List <string[]> >();

            if (DeductCommandList.Count < 0)//如果没有此子公司的配置,则直接返回null
            {
                return(null);
            }
            var query = _FinanceFactory.CreateBillDAL().GetBillList(EnumBillStatus.Debts)
                        .Where(p => p.Business.ServicerSideID == DeductCommandList.FirstOrDefault().ServiceSideID &&
                               p.Business.BankKey == bankkey)
                        .GroupBy(p => p.BusinessID).Select(z => new
            {
                ListBill = z.ToList()
            });

            if (query.Count() < 0)
            {
                return(null);
            }
            List <BillItem> fwfksbillitems = new List <BillItem>();
            Dictionary <int, List <BillItem> > bxksbillitems = new Dictionary <int, List <BillItem> >();
            Dictionary <int, List <BillItem> > fxbillitems   = new Dictionary <int, List <BillItem> >();
            var ServDc2    = DeductCommandList.Where(p => p.LendingSideID == p.ServiceSideID).ToList();
            var LendingDc2 = DeductCommandList.Where(p => p.LendingSideID != p.ServiceSideID).ToList();

            retstring.Add(GetCmd(ServDc2, true).ServiceSideID, new List <string[]>());
            retbyte.Add(GetCmd(ServDc2, false).LendingSideID, new List <byte>());

            foreach (var a in LendingDc2.Where(p => p.AnalysisCmdType != 0))
            {
                retstring.Add(a.LendingSideID, new List <string[]>()); //Excel
                retbyte.Add(a.LendingSideID, new List <byte>());       //TXT

                bxksbillitems.Add(a.LendingSideID, new List <BillItem>());
                fxbillitems.Add(a.LendingSideID, new List <BillItem>());
            }
            foreach (var list in query)
            {
                List <Bill> bills = list.ListBill;
                for (int i = 0; i < bills.Count(); i++)
                {
                    if (bills[i].BillMonth.Trim() == GetDate())//判断是否是当期账单(若能,把存在逾期的本息扣失和罚息添加)
                    {
                        if (!IsExporeDQ(bills[i]))
                        {
                            continue;
                        }
                    }

                    if (GetIfResult(fwfksbillitems))//导出当期服务、担保费前,先把逾期服务费扣失添加上
                    {
                        TotalAmount += fwfksbillitems.Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[GetCmd(ServDc2, true).ServiceSideID].AddRange(GetBankExportTemplate(GetCmd(ServDc2, true))
                                                                              .FomartTemplate(fwfksbillitems, customers));
                        fwfksbillitems = new List <BillItem>();
                    }
                    var fd = GetNoFullPayFD(bills[i].BillItems);//服务费、担保费
                    if (fd.Count > 0)
                    {
                        TotalAmount += fd.Sum(p => p.Amount - p.ReceivedAmt);

                        retbyte[GetCmd(ServDc2, true).ServiceSideID]
                        .AddRange(GetBankExportTemplate(GetCmd(ServDc2, true))    //TXT
                                  .FomartTemplate(fd, customers));

                        var ret  = GetNoFullPayFD(bills[i].BillItems);
                        var ret2 = GetNoFullPayFWFKS(bills[i].BillItems);
                        if (ret.Count > 0 && ret2 != null)
                        {
                            ret.Add(GetNoFullPayFWFKS(bills[i].BillItems));
                        }
                        else if (ret.Count == 0 && ret2 != null)
                        {
                            ret = new List <BillItem> {
                                ret2
                            }
                        }
                        ;

                        if (ret.Count > 0)
                        {
                            retstring[GetCmd(ServDc2, false).ServiceSideID]
                            .Add(GetBankExportTemplate2(GetCmd(ServDc2, false))    //Excel
                                 .GetGSImportExcelItem(ret, num, customers, bankaccounts,
                                                       enums, GetCmd(ServDc2, false).ServiceSideID));
                            num++;
                        }
                    }
                    var fwfks = GetNoFullPayFWFKS(bills[i].BillItems);//服务费扣失
                    if (fwfks != null)
                    {
                        fwfksbillitems.Add(fwfks);
                    }

                    for (int j = 0; j < GetCmdList(LendingDc2, true).Count(); j++)
                    {
                        if (GetIfResult(bxksbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID]))//本息扣失
                        {
                            TotalAmount += bxksbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID]
                                           .Sum(p => p.Amount - p.ReceivedAmt);
                            retbyte[GetCmdList(LendingDc2, true)[j].LendingSideID]
                            .AddRange(GetBankExportTemplate(GetCmdList(LendingDc2, true)[j])
                                      .FomartTemplate(bxksbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID], customers));

                            bxksbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID] = new List <BillItem>();
                        }
                        if (GetIfResult(fxbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID]))//罚息
                        {
                            TotalAmount += fxbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID]
                                           .Sum(p => p.Amount - p.ReceivedAmt);

                            retbyte[GetCmdList(LendingDc2, true)[j].LendingSideID]
                            .AddRange(GetBankExportTemplate(GetCmdList(LendingDc2, true)[j])
                                      .FomartTemplate(fxbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID], customers));
                            fxbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID] = new List <BillItem>();
                        }
                        if (bills[i].Business.LendingSideID == GetCmdList(LendingDc2, true)[j].LendingSideID)
                        {
                            var bx = GetNoFullPayBX(bills[i].BillItems); //本息
                            if (bx.Count > 0)
                            {
                                TotalAmount += bx.Sum(p => p.Amount - p.ReceivedAmt);

                                retbyte[GetCmdList(LendingDc2, true)[j].LendingSideID]
                                .AddRange(GetBankExportTemplate(GetCmdList(LendingDc2, true)[j])
                                          .FomartTemplate(bx, customers));

                                var ret2 = GetNoFullPayBXKS(bills[i].BillItems);
                                var ret3 = GetNoFullPayFX(bills[i].BillItems);
                                if (bx.Count > 0)
                                {
                                    if (ret2 != null)
                                    {
                                        bx.Add(ret2);
                                    }
                                    if (ret3 != null)
                                    {
                                        bx.Add(ret3);
                                    }
                                }
                                else if (bx.Count == 0 && (ret2 != null || ret3 != null))
                                {
                                    bx = new List <BillItem> {
                                        ret2, ret3
                                    }
                                }
                                ;

                                if (bx.Count > 0)
                                {
                                    retstring[GetCmdList(LendingDc2, false)[j].LendingSideID]
                                    .Add(GetBankExportTemplate2(GetCmdList(LendingDc2, false)[j])
                                         .GetGSImportExcelItem(bx, ser[0], customers, bankaccounts, enums,
                                                               GetCmdList(LendingDc2, false)[j].LendingSideID)); ser[0]++;
                                }
                            }
                            var bxks = GetNoFullPayBXKS(bills[i].BillItems);//本息扣失
                            if (bxks != null)
                            {
                                bxksbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID].Add(bxks);
                            }
                            var fx = GetNoFullPayFX(bills[i].BillItems);//罚息
                            if (fx != null)
                            {
                                fxbillitems[GetCmdList(LendingDc2, true)[j].LendingSideID].Add(fx);
                            }
                        }
                    }
                }
                for (int k = 0; k < GetCmdList(LendingDc2, true).Count(); k++)
                {
                    if (bxksbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID].Count() > 0)
                    {
                        TotalAmount += bxksbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID]
                                       .Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[GetCmdList(LendingDc2, true)[k].LendingSideID]
                        .AddRange(GetBankExportTemplate(GetCmdList(LendingDc2, true)[k])
                                  .FomartTemplate(bxksbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID], customers));
                        bxksbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID] = new List <BillItem>();
                    }
                    if (fxbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID].Count() > 0)
                    {
                        TotalAmount += fxbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID]
                                       .Sum(p => p.Amount - p.ReceivedAmt);
                        retbyte[GetCmdList(LendingDc2, true)[k].LendingSideID]
                        .AddRange(GetBankExportTemplate(GetCmdList(LendingDc2, true)[k])
                                  .FomartTemplate(fxbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID], customers));
                        fxbillitems[GetCmdList(LendingDc2, true)[k].LendingSideID] = new List <BillItem>();
                    }
                }
                if (fwfksbillitems.Count() > 0)
                {
                    TotalAmount += fwfksbillitems.Sum(p => p.Amount - p.ReceivedAmt);
                    retbyte[GetCmd(ServDc2, true).ServiceSideID].AddRange(GetBankExportTemplate(GetCmd(ServDc2, true))
                                                                          .FomartTemplate(fwfksbillitems, customers));
                    fwfksbillitems = new List <BillItem>();
                }
            }
            return(retstring);
        }