diff --git a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs index 80d72cd..b072dd7 100644 --- a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs +++ b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs @@ -27,6 +27,42 @@ namespace DigitalSchoolApi.Controllers private static string payresulturl = ConfigurationManager.AppSettings["payresulturl"]; + + /// + /// 定时更新线上收费状态到新生表 + /// + /// + public IHttpActionResult SyncPayStatusToFresh() + { + RecurringJob.AddOrUpdate("SyncPayStatusToFresh", + () => SyncStuInfoFreshPayStatus(), + Cron.Minutely, TimeZoneInfo.Local); + return Ok(); + } + + /// + /// 更新线上收费状态到新生表 + /// + public void SyncStuInfoFreshPayStatus() + { + try + { + using (IDbConnection conn = new SqlConnection(_sqlConnection)) + { + conn.Execute(@"update StuInfoFresh set payfeestatus=1 + from FinaChargeStuYear a left join StuInfoFresh b on a.stuno = b.stuno where a.PayFeeStatus <> 0"); + } + } + catch (Exception e) + { + using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) + { + conncore.Execute( + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),122,'syncpaystatustofresh','" + e.Message + "',getdate())"); + } + } + } + /// /// 每分钟执行缴费后处理 /// @@ -91,7 +127,7 @@ namespace DigitalSchoolApi.Controllers foreach (var stuorderEntity in stuorderlist) { //开票 - YKTTrabs.InvoiceEBillMethodTwo(stuorderEntity); + YKTTrabs.InvoiceEBillMethodTwo(stuorderEntity); } } } @@ -140,7 +176,7 @@ namespace DigitalSchoolApi.Controllers using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) { conncore.Execute( - "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','s = 000000: "+ Learun.Util.Str.ReplaceHtml(reStr) + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','s = 000000: " + Learun.Util.Str.ReplaceHtml(reStr) + "',getdate())"); } string Orderid = ((XmlElement)xml.SelectSingleNode("TX/TX_INFO/LIST/ORDER")).InnerText; string PAYMENT_MONEY = ((XmlElement)xml.SelectSingleNode("TX/TX_INFO/LIST/PAYMENT_MONEY")).InnerText; @@ -162,7 +198,7 @@ namespace DigitalSchoolApi.Controllers //string Orderid = item.orderid; //string REM1 = item.StuNo; //string REM2 = item.YearNo.ToString(); - if (ORDER_STATUS=="1") + if (ORDER_STATUS == "1") { conn.Execute("update FinaChargeStuOrder set SJAmount='" + PAYMENT_MONEY + "',Status='" + ORDER_STATUS + "',PayTime='" + TRAN_DATE + "',PayMode='" + PAY_MODE + "',BankOrder='" + OriOvrlsttnEV_Trck_No + "' where orderid='" + Orderid + "'"); ////判断实缴金额是否缴清费用 @@ -180,30 +216,30 @@ namespace DigitalSchoolApi.Controllers //} //记录缴费前余额、待缴金额 var oldFinaChargeStuYearItem = conn.Query(@"select b.* from [dbo].[FinaChargeStuOrderDetail] a left join [dbo].[FinaChargeStuYearItem] b on a.ChargeItemCode=b.ChargeItemCode - where a.[FCSOId] = '"+item.Id+"' and b.FSYId = '"+ item.FSYId + "'"); + where a.[FCSOId] = '" + item.Id + "' and b.FSYId = '" + item.FSYId + "'"); //实缴、缴费余额更新 //FinaChargeStuYearItem表 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+"'"); +where a.[FCSOId]='" + item.Id + "' and b.FSYId='" + item.FSYId + "'"); //FinaChargeStuYear表 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 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+"'"); + 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 where a.[FCSOId] = '" + item.Id + "' and b.FSYId = '" + item.FSYId + "'"); - IEnumerable detaillist =conn.Query("select * from FinaChargeStuOrderDetail where FCSOId='"+item.Id+"'"); + IEnumerable detaillist = conn.Query("select * from FinaChargeStuOrderDetail where FCSOId='" + item.Id + "'"); foreach (var finaChargeStuOrderDetailEntity in detaillist) { - if (finaChargeStuOrderDetailEntity.SJAmount>0) + if (finaChargeStuOrderDetailEntity.SJAmount > 0) { //计算学生缴费项目当前欠缴金额 var olditem = oldFinaChargeStuYearItem.FirstOrDefault(m => m.ChargeItemCode == finaChargeStuOrderDetailEntity.ChargeItemCode); @@ -214,8 +250,8 @@ group by a.FSYear,b.StuNo ) aa left join "'0','" + newitem.FSBlance + "',getdate(),'1')"); } } - int PayFeeStatus = Convert.ToInt32(conn.ExecuteScalar("select PayFeeStatus from FinaChargeStuYear where StuNo='"+item.StuNo+"' and FSYear='"+item.YearNo+"'")); - if (PayFeeStatus==1) + int PayFeeStatus = Convert.ToInt32(conn.ExecuteScalar("select PayFeeStatus from FinaChargeStuYear where StuNo='" + item.StuNo + "' and FSYear='" + item.YearNo + "'")); + if (PayFeeStatus == 1) { //开票 Task.Run(() => YKTTrabs.InvoiceEBillMethodTwo(item)); @@ -245,7 +281,7 @@ group by a.FSYear,b.StuNo ) aa left join using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) { conncore.Execute( - "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','catch error:" + e.Message + ":"+e.StackTrace+"',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','catch error:" + e.Message + ":" + e.StackTrace + "',getdate())"); } } } diff --git a/DigitalSchoolApi/DigitalSchoolApi.csproj b/DigitalSchoolApi/DigitalSchoolApi.csproj index 335f2f6..b8b867e 100644 --- a/DigitalSchoolApi/DigitalSchoolApi.csproj +++ b/DigitalSchoolApi/DigitalSchoolApi.csproj @@ -419,6 +419,7 @@ + diff --git a/DigitalSchoolApi/Models/FinaChargeStuYearEntity.cs b/DigitalSchoolApi/Models/FinaChargeStuYearEntity.cs new file mode 100644 index 0000000..6d8b259 --- /dev/null +++ b/DigitalSchoolApi/Models/FinaChargeStuYearEntity.cs @@ -0,0 +1,90 @@ +using Learun.Util; +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement +{ + /// + /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 + /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + /// 创 建:超级管理员 + /// 日 期:2023-08-07 15:52 + /// 描 述:学生年度缴费管理 + /// + public class FinaChargeStuYearEntity + { + #region 实体成员 + /// + /// FSYId + /// + public string FSYId { get; set; } + /// + /// StuNo + /// + public string StuNo { get; set; } + /// + /// FSYear + /// + public int? FSYear { get; set; } + /// + /// 应缴金额(收费标准) + /// + public decimal? YJAmount { get; set; } + /// + /// 实缴金额(已缴金额) + /// + public decimal? SJAmount { get; set; } + /// + /// 应缴余额 + /// + public decimal? NeedToPay { get; set; } + /// + /// 超出应收额 + /// + public decimal? FSBlance { get; set; } + /// + /// 缴费标志(0未缴费,1已缴清,4部分缴纳) + /// + public int? PayFeeStatus { get; set; } + #endregion + + #region 扩展操作 + /// + /// 新增调用 + /// + public void Create() + { + this.FSYId = Guid.NewGuid().ToString(); + } + /// + /// 编辑调用 + /// + /// + public void Modify(string keyValue) + { + this.FSYId = keyValue; + } + #endregion + #region 扩展字段 + [NotMapped] + public string DeptNo { get; set; } + [NotMapped] + public string MajorNo { get; set; } + [NotMapped] + public string ClassNo { get; set; } + [NotMapped] + public string Grade { get; set; } + [NotMapped] + public string IdentityCardNo { get; set; } + [NotMapped] + public string StuName { get; set; } + [NotMapped] + public bool? GenderNo { get; set; } + [NotMapped] + public decimal? PayMoney { get; set; } + [NotMapped] + public string orderid { get; set; } + #endregion + } +} +