diff --git a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs index 53071fc..7bd4357 100644 --- a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs +++ b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs @@ -88,27 +88,8 @@ namespace DigitalSchoolApi.Controllers } foreach (var stuorderEntity in stuorderlist) { - //新老生判断 - if (Convert.ToInt32(conn.ExecuteScalar( - "select count(1) from StuInfoFresh where StuNo='" + stuorderEntity.StuNo + "' and grade='" + stuorderEntity.YearNo.ToString().Substring(2) + "'")) > 0) - { - conn.Execute("update StuInfoFresh set PayFeeStatus='1' where StuNo='" + stuorderEntity.StuNo + "'"); - if (Convert.ToInt32(conn.ExecuteScalar( - "select count(1) from StuInfoFresh where StuNo='" + stuorderEntity.StuNo + "' and grade='" + stuorderEntity.YearNo.ToString().Substring(2) + "' and IsInvoice=0 and PayFeeStatus='1' ")) > 0) - { - //开票 - Task.Run(() => YKTTrabs.InvoiceEBillMethod(stuorderEntity.orderid, true)); - } - } - else - { - conn.Execute("update StuInfoBasic_PayFee set PayStatus='1' where StuNo='" + stuorderEntity.StuNo + "' and PayYear='" + stuorderEntity.YearNo.ToString().Substring(2) + "'"); - if (Convert.ToInt32(conn.ExecuteScalar("select count(1) from StuInfoBasic_PayFee where StuNo='" + stuorderEntity.StuNo + "' and PayYear='" + stuorderEntity.YearNo + "' and InvoiceStatus=0 and PayStatus='1'")) > 0) - { - //开票 - Task.Run(() => YKTTrabs.InvoiceEBillMethod(stuorderEntity.orderid, false)); - } - } + //开票 + Task.Run(() => YKTTrabs.InvoiceEBillMethodTwo(stuorderEntity.orderid)); } } } @@ -200,19 +181,19 @@ namespace DigitalSchoolApi.Controllers where a.[FCSOId] = '"+item.Id+"' and b.FSYId = '"+ item.FSYId + "'"); //实缴、缴费余额更新 //FinaChargeStuYearItem表 - conn.Execute(@"update [dbo].[FinaChargeStuYearItem] set SJAmount=b.SJAmount+a.SJAmount,FSBlance=FSBlance+a.SJAmount,PayFeeStatus=(case when(FSBlance+a.SJAmount>=0) then 1 when(abs(FSBlance+a.SJAmount)=Standard) then 0 else 4 end) + conn.Execute(@"update [dbo].[FinaChargeStuYearItem] set SJAmount=b.SJAmount+a.SJAmount,NeedToPay=NeedToPay-a.SJAmount,PayFeeStatus=(case when(NeedToPay-a.SJAmount<=0) then 1 when(NeedToPay-a.SJAmount=Standard) then 0 else 4 end) from [dbo].[FinaChargeStuOrderDetail] a left join [dbo].[FinaChargeStuYearItem] b on a.ChargeItemCode=b.ChargeItemCode where a.[FCSOId]='" + item.Id + "' and b.FSYId='"+item.FSYId+"'"); //FinaChargeStuYear表 - conn.Execute(@" update FinaChargeStuYear set SJAmount=aa.SJAmount,FSBlance=aa.FSBlance,PayFeeStatus=(case when(aa.[FSBlance]>=0) then 1 else 4 end) -from (select isnull(sum(a.[FSBlance]),0) as [FSBlance],isnull(sum(a.SJAmount),0) as SJAmount,a.FSYear,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId + conn.Execute(@" update FinaChargeStuYear set SJAmount=aa.SJAmount,NeedToPay=aa.NeedToPay,PayFeeStatus=(case when(aa.NeedToPay<=0) then 1 else 4 end) +from (select isnull(sum(a.[NeedToPay]),0) as [NeedToPay],isnull(sum(a.SJAmount),0) as SJAmount,a.FSYear,b.StuNo from FinaChargeStuYearItem a left join FinaChargeStuYear b on a.FSYId=b.FSYId group by a.FSYear,b.StuNo ) aa left join FinaChargeStuYear b on aa.stuno=b.stuno and aa.FSYear=b.FSYear - where aa.StuNo='"+item.StuNo+"' and aa.FSYear='"+item.YearNo+"'"); + where aa.StuNo='" + item.StuNo+"' and aa.FSYear='"+item.YearNo+"'"); //FinaChargeStudent表 - conn.Execute(@"update FinaChargeStudent set FSBlance=a.[FSBlance] - from (select isnull(sum([FSBlance]),0) as [FSBlance],StuNo from [FinaChargeStuYear] group by StuNo) a left join - FinaChargeStudent b on a.stuno=b.stuno where a.stuno='"+item.StuNo+"'"); + conn.Execute(@"update FinaChargeStudent set NeedToPay=a.NeedToPay + from (select isnull(sum([NeedToPay]),0) as [NeedToPay],StuNo from [FinaChargeStuYear] group by StuNo) a left join + FinaChargeStudent b on a.stuno=b.stuno where a.stuno='" + item.StuNo+"'"); //FinaChargeStuBalance流水表 //记录缴费后余额、待缴金额 var newFinaChargeStuYearItem = conn.Query(@"select b.* from [dbo].[FinaChargeStuOrderDetail] a left join [dbo].[FinaChargeStuYearItem] b on a.ChargeItemCode=b.ChargeItemCode @@ -227,8 +208,8 @@ group by a.FSYear,b.StuNo ) aa left join var newitem = newFinaChargeStuYearItem.FirstOrDefault(m => m.ChargeItemCode == finaChargeStuOrderDetailEntity.ChargeItemCode); conn.Execute(@"insert into FinaChargeStuBalance(Id, StuNo, FSYear, FCSOId, ChargeItemCode, ChargeItemName, Standard, DJAmount, PaymentAmount, QJAmount, OldBalance, ChangeAmount, NowBalance, ChangeDate, ChangeType) values( newid(),'" + item.StuNo + "','" + item.YearNo + "','" + item.Id + "','" + finaChargeStuOrderDetailEntity.ChargeItemCode + "','" + finaChargeStuOrderDetailEntity.ChargeItemName + "','" + finaChargeStuOrderDetailEntity.YJAmount + "'," + - "'" + (olditem.FSBlance < 0 ? Math.Abs(olditem.FSBlance.Value) : 0) + "','" + finaChargeStuOrderDetailEntity.SJAmount + "','" + (newitem.FSBlance < 0 ? Math.Abs(newitem.FSBlance.Value) : 0) + "','" + (olditem.FSBlance <= 0 ? 0 : olditem.FSBlance) + "'," + - "'" + finaChargeStuOrderDetailEntity.SJAmount + "','" + (newitem.FSBlance <= 0 ? 0 : newitem.FSBlance) + "',getdate(),'1')"); + "'" + olditem.NeedToPay + "','" + finaChargeStuOrderDetailEntity.SJAmount + "','" + newitem.NeedToPay + "','" + olditem.FSBlance + "'," + + "'0','" + newitem.FSBlance + "',getdate(),'1')"); } } //开票 diff --git a/DigitalSchoolApi/Controllers/YKTTrabs.cs b/DigitalSchoolApi/Controllers/YKTTrabs.cs index 463d4ea..2222f02 100644 --- a/DigitalSchoolApi/Controllers/YKTTrabs.cs +++ b/DigitalSchoolApi/Controllers/YKTTrabs.cs @@ -1073,7 +1073,6 @@ namespace DigitalSchoolApi.Controllers biParam.memo = "缴费年度:" + orderEntity.YearNo + ",学号:" + orderEntity.StuNo; biParam.@operator = "林智慧"; biParam.reViewer = "陈劲华"; - biParam.totalAmt = Convert.ToDouble(stuEnrollFeeOrderDetailList.Sum(x => x.YJAmount));// Convert.ToDouble(orderEntity.YJAmount); biParam.noticeMode = "0"; List itemdetailList = new List(); foreach (var itemEntity in stuEnrollFeeOrderDetailList) @@ -1083,9 +1082,10 @@ namespace DigitalSchoolApi.Controllers itemdetail.itemName = itemEntity.ChargeItemName; itemdetail.count = 1; itemdetail.standard = Convert.ToDouble(itemEntity.YJAmount); - itemdetail.amt = Convert.ToDouble(itemEntity.YJAmount); + itemdetail.amt = Convert.ToDouble((itemEntity.SJAmount> itemEntity.YJAmount? itemEntity.YJAmount: itemEntity.SJAmount)); itemdetailList.Add(itemdetail); } + biParam.totalAmt = Convert.ToDouble(itemdetailList.Sum(m=>m.amt)); biParam.itemDetail = itemdetailList; //JsonConvert.SerializeObject(biParam) using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) diff --git a/DigitalSchoolApi/Models/FinaChargeStuYearItemEntity.cs b/DigitalSchoolApi/Models/FinaChargeStuYearItemEntity.cs index cc158c0..8a8a284 100644 --- a/DigitalSchoolApi/Models/FinaChargeStuYearItemEntity.cs +++ b/DigitalSchoolApi/Models/FinaChargeStuYearItemEntity.cs @@ -48,8 +48,13 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement /// SJAmount /// public decimal? SJAmount { get; set; } + + /// + /// 剩余待缴 + /// + public decimal? NeedToPay { get; set; } /// - /// 缴费余额 + /// 超出缴费余额 /// public decimal? FSBlance { get; set; } ///