|
|
@@ -366,20 +366,31 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement |
|
|
|
db.Insert(orderEntity); |
|
|
|
db.Insert(detail); |
|
|
|
//判断实缴金额是否缴清费用 |
|
|
|
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) |
|
|
|
{ |
|
|
|
//更新缴费状态 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='1' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
} |
|
|
|
else//更新部分缴费状态 |
|
|
|
{ |
|
|
|
//更新缴费状态 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='4' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
} |
|
|
|
//如果存在未缴费的非固定项目,直接判定部分缴费 |
|
|
|
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) |
|
|
|
//{ |
|
|
|
// 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) |
|
|
|
// { |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='1' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
// } |
|
|
|
// else//更新部分缴费状态 |
|
|
|
// { |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='4' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
// } |
|
|
|
//} |
|
|
|
//else |
|
|
|
//{ |
|
|
|
// //更新缴费状态 |
|
|
|
// db.ExecuteBySql("update FinaChargeStuYear set PayFeeStatus='4' where FSYId='" + finaChargeStuYearEntity.FSYId + "'"); |
|
|
|
//} |
|
|
|
//费用变更明细 |
|
|
|
FinaChargeStuBalanceEntity finaChargeStuBalanceEntity = new FinaChargeStuBalanceEntity(); |
|
|
|
finaChargeStuBalanceEntity.Create(); |
|
|
@@ -419,10 +430,23 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement |
|
|
|
} |
|
|
|
finaChargeStuYearItemEntity.PayFeeStatus = finaChargeStuYearItemEntity.NeedToPay > 0 ? 4 : 1; |
|
|
|
db.Update(finaChargeStuYearItemEntity); |
|
|
|
//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 else abs(NeedToPay-" + dresult + ") 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 else abs(NeedToPay-" + dresult + ") end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
//如果存在未缴费的非固定项目,应缴余额和超出应收应该排除掉 |
|
|
|
//同时满足固定项目超出的情况 |
|
|
|
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 else abs(NeedToPay-" + dresult + ") 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 else abs(NeedToPay-" + dresult + ") end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
} |
|
|
|
if(fgdfinaChargeStuYearItem.Count() >0 && gdfinaChargeStuYearItem.Sum(m => m.NeedToPay).Value - dresult <= 0) |
|
|
|
{ |
|
|
|
decimal fgdcount = fgdfinaChargeStuYearItem.Sum(m=>m.NeedToPay).Value; |
|
|
|
//FinaChargeStuYear表 |
|
|
|
db.ExecuteBySql("update FinaChargeStuYear set SJAmount=SJAmount+" + dresult + ",NeedToPay=(case when(NeedToPay-" + dresult+"+"+ fgdcount + ")>0 then (NeedToPay-" + dresult+"+"+ fgdcount + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult +"+"+ fgdcount + ")>=0 then 0 else abs(NeedToPay-" + dresult +"+"+ fgdcount + ") end),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 +"+"+ fgdcount + ")>0 then (NeedToPay-" + dresult +"+"+ fgdcount + ") else 0 end),FSBlance=(case when(NeedToPay-" + dresult +"+"+ fgdcount + ")>=0 then 0 else abs(NeedToPay-" + dresult +"+"+ fgdcount + ") end) where StuNo='" + finaChargeStuYearItemEntity.StuNo + "'"); |
|
|
|
} |
|
|
|
db.Commit(); |
|
|
|
snum++; |
|
|
|
} |
|
|
|