Переглянути джерело

自动分配逻辑

西昌缴费二期
fzp 1 рік тому
джерело
коміт
351f3897dd
1 змінених файлів з 89 додано та 6 видалено
  1. +89
    -6
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/ReceiveSendFeeManagement/FinaChargeStuOrder/FinaChargeStuOrderService.cs

+ 89
- 6
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<FinaChargeStuYearItemEntity>("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<FinaChargeStuYearItemEntity>("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<FinaChargeStuYearItemEntity>("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<FinaChargeStuYearItemEntity>("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)


Завантаження…
Відмінити
Зберегти