From 198692f89d178a34367f663c387ee388bae615f9 Mon Sep 17 00:00:00 2001 From: jianweie code Date: Fri, 15 Sep 2023 15:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=BE=AE=E4=BF=A1=E9=80=80=E6=AC=BE=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=B8=AD=E5=A6=82=E6=9E=9C=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E7=AB=AF=E8=87=AA=E5=B7=B1=E7=9A=84=E9=80=80=E6=AC=BE=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E5=87=BA=E7=8E=B0=E5=BC=82=E5=B8=B8=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E6=88=91=E4=BB=AC=E5=AF=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PayNotify/WeChatPayController.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/CoreCms.Net.Web.WebApi/Controllers/PayNotify/WeChatPayController.cs b/CoreCms.Net.Web.WebApi/Controllers/PayNotify/WeChatPayController.cs index 3bb69af8..ecd2ca60 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/PayNotify/WeChatPayController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/PayNotify/WeChatPayController.cs @@ -124,15 +124,20 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify var notify = await _client.ExecuteAsync(Request, payOptions); NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信退款结果通知", JsonConvert.SerializeObject(notify)); - if (notify.ReturnCode == WeChatPayCode.Success) - if (notify.RefundStatus == WeChatPayCode.Success) - { - //Console.WriteLine("OutTradeNo: " + notify.OutTradeNo); - var memo = JsonConvert.SerializeObject(notify); - await _billRefundServices.UpdateAsync(p => new CoreCmsBillRefund { memo = memo }, p => p.refundId == notify.OutTradeNo); - return WeChatPayNotifyResult.Success; - } - return NoContent(); + if (notify.ReturnCode != WeChatPayCode.Success) return NoContent(); + { + var memo = JsonConvert.SerializeObject(notify); + + var status = notify.RefundStatus == WeChatPayCode.Success + ? (int)GlobalEnumVars.BillRefundStatus.STATUS_REFUND + : (int)GlobalEnumVars.BillRefundStatus.STATUS_FAIL; + + await _billRefundServices.UpdateAsync(p => new CoreCmsBillRefund { memo = memo, updateTime = DateTime.Now, status = status }, p => p.refundId == notify.OutTradeNo); + + //这个返回只是告诉回调这个业务我们接收到了。 + return WeChatPayNotifyResult.Success; + } + } catch (Exception ex) {