|
|
@@ -532,60 +532,45 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement |
|
|
|
db.Update(finaChargeStuYearItemEntity); |
|
|
|
|
|
|
|
#endregion |
|
|
|
//“取消非固定项的限制后”注释: |
|
|
|
//判断实缴金额是否缴清费用 |
|
|
|
//如果存在未缴费的非固定项目,直接判定部分缴费 |
|
|
|
var fgdfinaChargeStuYearItem = db.FindList<FinaChargeStuYearItemEntity>("select * from FinaChargeStuYearItem where ChargeItemType=2 and PayFeeStatus<>1 and FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
var gdfinaChargeStuYearItem = db.FindList<FinaChargeStuYearItemEntity>("select * from FinaChargeStuYearItem where ChargeItemType=1 and PayFeeStatus<>1 and FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
//if (fgdfinaChargeStuYearItem.Count()==0) |
|
|
|
//var fgdfinaChargeStuYearItem = db.FindList<FinaChargeStuYearItemEntity>("select * from FinaChargeStuYearItem where ChargeItemType=2 and PayFeeStatus<>1 and FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
//var gdfinaChargeStuYearItem = db.FindList<FinaChargeStuYearItemEntity>("select * from FinaChargeStuYearItem where ChargeItemType=1 and PayFeeStatus<>1 and FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
//如果存在未缴费的非固定项目,应缴余额和超出应收应该排除掉 |
|
|
|
//同时满足固定项目超出的情况 |
|
|
|
//if (fgdfinaChargeStuYearItem.Count() == 0) |
|
|
|
//{ |
|
|
|
// //FinaChargeStuYear表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>=0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end),PayFeeStatus=(case when(NeedToPay-" + dresult + ">=0) then 4 else 1 end) where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
// //FinaChargeStudent表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStudent set NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>=0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
//} |
|
|
|
//else |
|
|
|
//{ |
|
|
|
// decimal sjcount = Convert.ToDecimal(db.FindObject("select isnull(sum(SJAmount),0) from FinaChargeStuOrder where StuNo='" + orderEntity.StuNo + "' and Status=1 and YearNo='" + orderEntity.YearNo + "' ")); |
|
|
|
// //增加本次缴费金额 |
|
|
|
// sjcount = sjcount + orderEntity.SJAmount.Value; |
|
|
|
// decimal yjcount = finaChargeStuYearEntity.YJAmount.Value; |
|
|
|
// if (sjcount >= yjcount) |
|
|
|
// decimal fgdcount = fgdfinaChargeStuYearItem.Sum(m => m.NeedToPay).Value; |
|
|
|
// if (gdfinaChargeStuYearItem.Sum(m => m.NeedToPay).Value - dresult <= 0) |
|
|
|
// { |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='1' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
// //FinaChargeStuYear表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=" + fgdcount + ",FSBlance=FSBlance+" + (dresult - gdfinaChargeStuYearItem.Sum(m => m.NeedToPay)) + ",PayFeeStatus=4 where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
// //FinaChargeStudent表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStudent set NeedToPay=" + fgdcount + ",FSBlance=FSBlance+" + (dresult - gdfinaChargeStuYearItem.Sum(m => m.NeedToPay)) + " where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
// } |
|
|
|
// else//更新部分缴费状态 |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='4' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
// //FinaChargeStuYear表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=FSBlance+0,PayFeeStatus=4 where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
// //FinaChargeStudent表 |
|
|
|
// db.ExecuteBySql("update FinaChargeStudent set NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=FSBlance+0 where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
// } |
|
|
|
//} |
|
|
|
//else |
|
|
|
//{ |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='4' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
//} |
|
|
|
|
|
|
|
//如果存在未缴费的非固定项目,应缴余额和超出应收应该排除掉 |
|
|
|
//同时满足固定项目超出的情况 |
|
|
|
if (fgdfinaChargeStuYearItem.Count() == 0) |
|
|
|
{ |
|
|
|
//FinaChargeStuYear表 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>=0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end),PayFeeStatus=(case when(NeedToPay-" + dresult + ">=0) then 4 else 1 end) where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
//FinaChargeStudent表 |
|
|
|
db.ExecuteBySql("update FinaChargeStudent set NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>=0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
decimal fgdcount = fgdfinaChargeStuYearItem.Sum(m => m.NeedToPay).Value; |
|
|
|
if (gdfinaChargeStuYearItem.Sum(m => m.NeedToPay).Value - dresult <= 0) |
|
|
|
{ |
|
|
|
//FinaChargeStuYear表 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=" + fgdcount + ",FSBlance=FSBlance+" + (dresult - gdfinaChargeStuYearItem.Sum(m => m.NeedToPay)) + ",PayFeeStatus=4 where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
//FinaChargeStudent表 |
|
|
|
db.ExecuteBySql("update FinaChargeStudent set NeedToPay=" + fgdcount + ",FSBlance=FSBlance+" + (dresult - gdfinaChargeStuYearItem.Sum(m => m.NeedToPay)) + " where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//FinaChargeStuYear表 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=FSBlance+0,PayFeeStatus=(case when(NeedToPay-" + dresult + "+" + fgdcount + ">=0) then 4 else 1 end) where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
//FinaChargeStudent表 |
|
|
|
db.ExecuteBySql("update FinaChargeStudent set NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=FSBlance+0 where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
} |
|
|
|
} |
|
|
|
//“取消非固定项的限制后”增加: |
|
|
|
//FinaChargeStuYear表 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end),PayFeeStatus=(case when(NeedToPay-" + dresult + ">0) then 4 else 1 end) where FSYId='" + finaChargeStuYearItemEntity.FSYId + "'"); |
|
|
|
//FinaChargeStudent表 |
|
|
|
db.ExecuteBySql("update FinaChargeStudent set NeedToPay=(case when(NeedToPay-" + dresult + ")>0 then (NeedToPay-" + dresult + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult + ")>0 then (0+FSBlance) else (abs(NeedToPay-" + dresult + ")+FSBlance) end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
|
|
|
|
db.Commit(); |
|
|
|
//自动分配超出金额 |
|
|
|
AutoCharge(finaChargeStuYearEntity.FSYear.Value); |
|
|
@@ -632,9 +617,9 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement |
|
|
|
{ |
|
|
|
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 and b.FSYear='" + YearNo + "' order by priority desc "); |
|
|
|
var FinaChargeStuYearItemHasBalance = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where F_DeleteMark=0 and a.FSBlance>0 and b.FSYear='" + YearNo + "' 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.NeedToPay>0 and b.FSYear='" + YearNo + "' order by priority "); |
|
|
|
var FinaChargeStuYearItemHasDJ = BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>("select a.*,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId where F_DeleteMark=0 and a.NeedToPay>0 and b.FSYear='" + YearNo + "' order by priority "); |
|
|
|
foreach (var hasBalanceItem in FinaChargeStuYearItemHasBalance) |
|
|
|
{ |
|
|
|
if (hasBalanceItem.FSBlance > 0) |
|
|
|