From 351f3897dd5344dc07aaa69e4a365d46b4f3aff3 Mon Sep 17 00:00:00 2001 From: fzp <645608524@qq.com> Date: Sun, 20 Aug 2023 18:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=86=E9=85=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinaChargeStuOrderService.cs | 95 +++++++++++++++++-- 1 file changed, 89 insertions(+), 6 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuOrder/FinaChargeStuOrderService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuOrder/FinaChargeStuOrderService.cs index 46a5da81a..e9743f94a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuOrder/FinaChargeStuOrderService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuOrder/FinaChargeStuOrderService.cs @@ -468,14 +468,97 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement { try { - //获取有缴费余额的固定项目 - var FinaChargeStuYearItemHasBalance = BaseRepository("CollegeMIS").FindList("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where ChargeItemType=1 and F_DeleteMark=0 and a.FSBlance>0"); - //获取欠费的固定项目 - var FinaChargeStuYearItemHasDJ = BaseRepository("CollegeMIS").FindList("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where ChargeItemType=1 and F_DeleteMark=0 and a.FSBlance<0"); + Random ran = new Random(); + //获取有缴费余额的固定项目,按照优先级倒排,即优先级低的,先拿出多出余额去分配给高的项目 + var FinaChargeStuYearItemHasBalance = BaseRepository("CollegeMIS").FindList("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where ChargeItemType=1 and F_DeleteMark=0 and a.FSBlance>0 order by priority desc "); + //获取欠费的固定项目,按照优先级排序,优先级高的首先会分配到多出的余额 + var FinaChargeStuYearItemHasDJ = BaseRepository("CollegeMIS").FindList("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where ChargeItemType=1 and F_DeleteMark=0 and a.FSBlance<0 order by priority "); foreach (var hasBalanceItem in FinaChargeStuYearItemHasBalance) { - //可分配余额 - decimal balance = hasBalanceItem.FSBlance.Value; + if (hasBalanceItem.FSBlance > 0) + { + //可分配余额 + decimal balance = hasBalanceItem.FSBlance.Value; + foreach (var QJItem in FinaChargeStuYearItemHasDJ) + { + var db = BaseRepository("CollegeMIS").BeginTrans(); + if (QJItem.FSBlance<0 && hasBalanceItem.FSBlance>0) + { + //费用变更表 + //含余额表扣减 + FinaChargeStuBalanceEntity finaChargeStuBalanceMinus = new FinaChargeStuBalanceEntity(); + finaChargeStuBalanceMinus.Create(); + finaChargeStuBalanceMinus.StuNo = hasBalanceItem.StuNo; + finaChargeStuBalanceMinus.FSYear = hasBalanceItem.FSYear; + finaChargeStuBalanceMinus.FCSOId = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + finaChargeStuBalanceMinus.ChargeItemCode = hasBalanceItem.ChargeItemCode; + finaChargeStuBalanceMinus.ChargeItemName = hasBalanceItem.ChargeItemName; + finaChargeStuBalanceMinus.Standard = hasBalanceItem.Standard; + finaChargeStuBalanceMinus.DJAmount = 0; + finaChargeStuBalanceMinus.QJAmount = 0; + finaChargeStuBalanceMinus.OldBalance = hasBalanceItem.FSBlance; + finaChargeStuBalanceMinus.ChangeDate = DateTime.Now; + finaChargeStuBalanceMinus.ChangeType = 5; + //欠费表增加 + FinaChargeStuBalanceEntity finaChargeStuBalanceAdd = new FinaChargeStuBalanceEntity(); + finaChargeStuBalanceAdd.Create(); + finaChargeStuBalanceAdd.StuNo = QJItem.StuNo; + finaChargeStuBalanceAdd.FSYear = QJItem.FSYear; + finaChargeStuBalanceAdd.FCSOId = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + finaChargeStuBalanceAdd.ChargeItemCode = QJItem.ChargeItemCode; + finaChargeStuBalanceAdd.ChargeItemName = QJItem.ChargeItemName; + finaChargeStuBalanceAdd.Standard = QJItem.Standard; + finaChargeStuBalanceAdd.DJAmount = Math.Abs(QJItem.FSBlance.Value); + finaChargeStuBalanceMinus.ChangeDate = DateTime.Now; + finaChargeStuBalanceMinus.ChangeType = 6; + //余额分配还有剩余 + if (balance + QJItem.FSBlance >= 0) + { + QJItem.SJAmount = QJItem.Standard; + QJItem.FSBlance = 0; + QJItem.PayFeeStatus = 1; + hasBalanceItem.FSBlance = hasBalanceItem.FSBlance + QJItem.FSBlance; + finaChargeStuBalanceMinus.PaymentAmount = QJItem.FSBlance; + finaChargeStuBalanceMinus.ChangeAmount = QJItem.FSBlance; + finaChargeStuBalanceMinus.NowBalance = hasBalanceItem.FSBlance; + db.Insert(finaChargeStuBalanceMinus); + //欠费变更 + finaChargeStuBalanceAdd.PaymentAmount = Math.Abs(QJItem.FSBlance.Value); + finaChargeStuBalanceAdd.QJAmount = 0; + finaChargeStuBalanceAdd.OldBalance = 0; + finaChargeStuBalanceAdd.ChangeAmount = Math.Abs(QJItem.FSBlance.Value); + finaChargeStuBalanceAdd.NowBalance = 0; + db.Insert(finaChargeStuBalanceAdd); + db.Update(hasBalanceItem); + db.Update(QJItem); + db.Commit(); + continue; + } + else + { + QJItem.SJAmount = QJItem.SJAmount + hasBalanceItem.FSBlance; + QJItem.FSBlance = QJItem.FSBlance + hasBalanceItem.FSBlance; + QJItem.PayFeeStatus = 4; + hasBalanceItem.FSBlance = 0; + finaChargeStuBalanceMinus.PaymentAmount = -hasBalanceItem.FSBlance; + finaChargeStuBalanceMinus.ChangeAmount = -hasBalanceItem.FSBlance; + finaChargeStuBalanceMinus.NowBalance = 0; + db.Insert(finaChargeStuBalanceMinus); + //欠费变更 + finaChargeStuBalanceAdd.PaymentAmount = hasBalanceItem.FSBlance; + finaChargeStuBalanceAdd.QJAmount = QJItem.FSBlance+ hasBalanceItem.FSBlance; + finaChargeStuBalanceAdd.OldBalance = 0; + finaChargeStuBalanceAdd.ChangeAmount = hasBalanceItem.FSBlance; + finaChargeStuBalanceAdd.NowBalance = 0; + db.Insert(finaChargeStuBalanceAdd); + db.Update(hasBalanceItem); + db.Update(QJItem); + db.Commit(); + break; + } + } + } + } } } catch (Exception ex)