From 0ee5641e03646c59d2d872e71160f7892c245749 Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Wed, 19 Jun 2024 17:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E8=A5=BF?= =?UTF-8?q?=E6=98=8C=EF=BC=9A=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E7=BC=B4=E8=B4=B9=E8=AE=A2=E5=8D=95=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=A4=84=E7=90=86=E7=BC=B4=E8=B4=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PayFeeResultTwoController.cs | 104 +++++++++++++++++- DigitalSchoolApi/Controllers/YKTTrabs.cs | 22 ++-- 2 files changed, 109 insertions(+), 17 deletions(-) diff --git a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs index 9238627..eecf942 100644 --- a/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs +++ b/DigitalSchoolApi/Controllers/PayFeeResultTwoController.cs @@ -118,6 +118,19 @@ namespace DigitalSchoolApi.Controllers return Ok(); } + /// + /// 根据学生缴费订单id手动处理缴费结果 + /// + /// + /// + [HttpPost] + public IHttpActionResult SetPayResultHandleByFCSOId(string FCSOId) + { + + BackgroundJob.Enqueue(() => DoPayResultHandleByFCSOId(FCSOId)); + return Ok(); + } + public void UnInvoiceHandle(bool isexcel) { try @@ -214,7 +227,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','对接支付结果地址接口失败:" + reStr + ":" + e.Message + ":" + e.StackTrace + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','FCSOId:" + item.Id + " 对接支付结果地址接口失败:" + reStr + ":" + e.Message + ":" + e.StackTrace + "',getdate())"); } } xml.LoadXml(reStr); @@ -225,7 +238,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','FCSOId:" + item.Id + " 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; @@ -308,9 +321,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','orderid:" + Orderid + " StuNo:" + REM1 + "',getdate())"); - conncore.Execute( - "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','缴费状态更新成功',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'ccb','FCSOId:" + item.Id + " orderid:" + Orderid + " StuNo:" + REM1 + " 缴费状态更新成功',getdate())"); } } } @@ -319,7 +330,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','error:code=" + s + "xml=" + 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','FCSOId:" + item.Id + " error:code=" + s + "xml=" + Learun.Util.Str.ReplaceHtml(reStr) + "',getdate())"); } } } @@ -335,6 +346,87 @@ group by a.FSYear,b.StuNo ) aa left join } } + public void DoPayResultHandleByFCSOId(string FCSOId) + { + try + { + using (IDbConnection conn = new SqlConnection(_sqlConnection)) + { + var item = conn.QuerySingleOrDefault("select * from FinaChargeStuOrder where Id='" + FCSOId + "' and Status=0 and OrderType=1 "); + if (item != null) + { + conn.Execute("update FinaChargeStuOrder set Status='1' where Id='" + item.Id + "'"); + + //记录缴费前余额、待缴金额 + 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 + "'"); + //实缴、缴费余额更新 + //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 + "'"); + //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 + "'"); + //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 + "'"); + //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 + "'"); + foreach (var finaChargeStuOrderDetailEntity in detaillist) + { + if (finaChargeStuOrderDetailEntity.SJAmount > 0) + { + //计算学生缴费项目当前欠缴金额 + var olditem = oldFinaChargeStuYearItem.FirstOrDefault(m => m.ChargeItemCode == finaChargeStuOrderDetailEntity.ChargeItemCode); + 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.NeedToPay + "','" + finaChargeStuOrderDetailEntity.SJAmount + "','" + newitem.NeedToPay + "','" + olditem.FSBlance + "'," + + "'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) + { + 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','【手动处理缴费结果】FCSOId:" + FCSOId + " StuNo:" + item.StuNo + "可以触发开票接口',getdate())"); + } + //开票 + Task.Run(() => YKTTrabs.InvoiceEBillMethodTwo(item)); + } + 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','【手动处理缴费结果】FCSOId:" + FCSOId + " StuNo:" + item.StuNo + " 缴费状态更新成功',getdate())"); + } + } + + } + } + catch (Exception e) + { + using (IDbConnection conn = new SqlConnection(_sqlConnection)) + { + conn.Execute("update FinaChargeStuOrder set PayTime=null,PayMode=null,BankOrder=null where Id='" + FCSOId + "'"); + } + 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())"); + } + } + } + public void GetOrderResult(string orderid) { try diff --git a/DigitalSchoolApi/Controllers/YKTTrabs.cs b/DigitalSchoolApi/Controllers/YKTTrabs.cs index 5af514a..6fe3f04 100644 --- a/DigitalSchoolApi/Controllers/YKTTrabs.cs +++ b/DigitalSchoolApi/Controllers/YKTTrabs.cs @@ -811,7 +811,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,'typecode','开票typecode:" + item.Key + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'typecode','FCSOId:" + orderEntity.Id + " 开票typecode:" + item.Key + "',getdate())"); } InvoiceEBillByTypeTwo(conn, orderEntity, item.Key, item); } @@ -820,7 +820,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,'piaoju','开票异常:" + ex.Message + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票异常:" + ex.Message + "',getdate())"); } } } @@ -831,7 +831,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,'piaoju','开票异常:" + ex.Message + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票准备报错:" + ex.Message + "',getdate())"); } } } @@ -1086,7 +1086,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,'piaoju','发送给开票系统原始数据:" + JsonConvert.SerializeObject(biParam) + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 发送给开票系统原始数据:" + JsonConvert.SerializeObject(biParam) + "',getdate())"); } var data = Convert.ToBase64String(encoding.GetBytes(JsonConvert.SerializeObject(biParam))); var noise = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); @@ -1113,7 +1113,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,'piaoju','开票系统返回:" + datain + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票系统返回:" + datain + "',getdate())"); } string returnresult = encoding.GetString(Convert.FromBase64String(datain)); if (returnresult != "") @@ -1127,7 +1127,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,'piaoju','开票系统成功返回:" + messagedecode + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票系统成功返回:" + messagedecode + "',getdate())"); } dynamic billInfo = JsonConvert.DeserializeObject(messagedecode); string eBillCode = billInfo.eBillCode; @@ -1162,7 +1162,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,'piaoju','查询开票url返回:" + datainvoice + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 查询开票url返回:" + datainvoice + "',getdate())"); } string returnresultinvoice = encoding.GetString(Convert.FromBase64String(datainvoice)); resultobj = JsonConvert.DeserializeObject(returnresultinvoice); @@ -1173,7 +1173,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,'piaoju','查询开票url成功返回:" + messagedecode + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 查询开票url成功返回:" + messagedecode + "',getdate())"); } dynamic InvoiceUrlInfo = JsonConvert.DeserializeObject(messagedecode); string pictureUrl = InvoiceUrlInfo.pictureUrl; @@ -1187,7 +1187,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,'piaoju','查询开票url错误:" + messagedecode + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 查询开票url错误:" + messagedecode + "',getdate())"); } } } @@ -1198,7 +1198,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,'piaoju','开票系统错误:" + messagedecode + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票系统错误:" + messagedecode + "',getdate())"); } } } @@ -1210,7 +1210,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,'piaoju','开票系统报错:" + e.Message + "',getdate())"); + "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'piaoju','FCSOId:" + orderEntity.Id + " 开票系统报错:" + e.Message + "',getdate())"); } } }