From a3f1926a7530fd4a3b9196824a8e8b00c693e6e3 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期二, 01 四月 2025 11:11:50 +0800 Subject: [PATCH] Merge branch 'dev-lifepay-v1.3' of http://120.26.58.240:8888/r/LifePaymentApi into dev-lifepay-v1.3 --- LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs | 5 +++++ LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs | 1 + LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 5 +++++ LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs | 18 ++++++++++-------- LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs | 1 + LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs | 6 ++++++ LifePayment/LifePayment.Domain/Ali/AliPayApi.cs | 2 +- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 7 +++++-- LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs | 1 + 9 files changed, 35 insertions(+), 11 deletions(-) diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs index 11f4cf1..408752d 100644 --- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs +++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs @@ -652,6 +652,12 @@ } public class AddLifePayExpensesReceiptsInput { + + /// <summary> + /// 閫�娆捐鍗曞彿 + /// </summary> + public string OutRefundNo { get; set; } + /// <summary> /// 骞冲彴璁㈠崟鍙� /// </summary> diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs index eee8553..856e067 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs @@ -223,7 +223,6 @@ var data = new LifePayExpensesReceipts() { Id = Guid.NewGuid(), - OrderNo = input.OrderNo, OutOrderNo = input.OutOrderNo, LifePayType = input.LifePayType, ExpensesReceiptsType = input.ExpensesReceiptsType, @@ -238,6 +237,7 @@ if (query.Code == AlipayResultCode.Success && (query.TradeStatus == AlipayStatus.TRADESUCCESS || query.TradeStatus == AlipayStatus.TRADECLOSED)) { + data.OrderNo = input.OrderNo; data.ExtraProperties = JsonConvert.SerializeObject(query); data.FinishTime = Convert.ToDateTime(query.SendPayDate); data.Amount = Convert.ToDecimal(query.TotalAmount); @@ -246,9 +246,10 @@ } else { - var query = await _aliPayApi.QueryAlipayTradeRefund(new OrderInQuiryInput() { OutTradeNo = input.OrderNo }); + var query = await _aliPayApi.QueryAlipayTradeRefund(new OrderInQuiryInput() { OutTradeNo = input.OrderNo, OutRefundNo = input.OutRefundNo }); if (query.Code == AlipayResultCode.Success && query.RefundStatus == AlipayRefundStatus.Success) { + data.OrderNo = input.OutRefundNo; data.ExtraProperties = JsonConvert.SerializeObject(query); data.FinishTime = Convert.ToDateTime(query.GmtRefundPay); data.Amount = Convert.ToDecimal(query.RefundAmount); @@ -262,6 +263,7 @@ var query = await _wxPayApi.WxPayTradeQuery(input.OrderNo); if (query.TradeState == WxPayStatus.鏀粯鎴愬姛 || query.TradeState == WxPayStatus.杞叆閫�娆�) { + data.OrderNo = input.OrderNo; data.ExtraProperties = JsonConvert.SerializeObject(query); data.FinishTime = Convert.ToDateTime(query.SuccessTime); await _lifePayExpensesReceiptsRepository.InsertAsync(data); @@ -269,9 +271,10 @@ } else { - var query = await _wxPayApi.WxPayDomesticRefundsQuery(input.OrderNo); + var query = await _wxPayApi.WxPayDomesticRefundsQuery(input.OutRefundNo); if (query.Status == WxPayRefundStatus.閫�娆炬垚鍔�) { + data.OrderNo = input.OutRefundNo; data.ExtraProperties = JsonConvert.SerializeObject(query); data.FinishTime = Convert.ToDateTime(query.SuccessTime); await _lifePayExpensesReceiptsRepository.InsertAsync(data); @@ -316,15 +319,14 @@ /// 鍑鸿处 if (item.RefundOrderNo.IsNotNullOrEmpty()) { - if (input.LifePayType == LifePayTypeEnum.WxPay) - { - input.OrderNo = item.RefundOrderNo; - } + input.OutRefundNo = item.OrderNo; + input.ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts; + await AddLifePayExpensesReceipts(input); + input.OutRefundNo = item.RefundOrderNo; input.ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts; await AddLifePayExpensesReceipts(input); } - } } } diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 8053980..8d5907a 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -848,15 +848,18 @@ /// <returns></returns> public async Task<AlipayTradeFastpayRefundQueryResponse> QueryAlipayTradeRefund(OrderInQuiryInput input) { + var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OutTradeNo || x.RefundOrderNo == input.OutRefundNo).FirstOrDefaultAsync(); + CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "鏈壘鍒拌鍗曚俊鎭�"); + input.OutTradeNo = order.OrderNo; + input.OutRefundNo = order.RefundOrderNo; var result = await _aliPayApi.QueryAlipayTradeRefund(input); - var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OutTradeNo).FirstOrDefaultAsync(); if (result.Code == AlipayResultCode.Success && result.RefundStatus == AlipayRefundStatus.Success) { order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�; order.LifePayRefundStatus = LifePayRefundStatusEnum.宸查��娆�; await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { - OrderNo = result.OutTradeNo, + OrderNo = order.RefundOrderNo, OutOrderNo = result.TradeNo, LifePayType = LifePayTypeEnum.AliPay, ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts diff --git a/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs b/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs index b98c786..5a5b401 100644 --- a/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs +++ b/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs @@ -24,6 +24,11 @@ /// 浜ゆ槗鍒涘缓鏃朵紶鍏ョ殑鍟嗘埛璁㈠崟鍙� /// </summary> public string OutTradeNo { get; set; } + + /// <summary> + /// 閫�娆捐鍗曞彿 + /// </summary> + public string OutRefundNo { get; set; } } public class AlipayTradeRefundRequest diff --git a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs index b3f7f32..e989244 100644 --- a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs +++ b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs @@ -56,7 +56,7 @@ /// <returns></returns> public async Task<AlipayTradeFastpayRefundQueryResponse> QueryAlipayTradeRefund(OrderInQuiryInput input) { - AlipayTradeFastpayRefundQueryResponse response = await QueryTradeRefund(input.OutTradeNo, input.OutTradeNo); + AlipayTradeFastpayRefundQueryResponse response = await QueryTradeRefund(input.OutTradeNo, input.OutRefundNo); return response; } diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml index 20f824c..1d5df00 100644 --- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml +++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml @@ -764,6 +764,11 @@ 鍏呭�煎嚟璇� </summary> </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.OutRefundNo"> + <summary> + 閫�娆捐鍗曞彿 + </summary> + </member> <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.OrderNo"> <summary> 骞冲彴璁㈠崟鍙� diff --git a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs index 0d20883..9d79c31 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs @@ -74,6 +74,7 @@ await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { OrderNo = input.OutTradeNo, + OutRefundNo = input.OutBizNo, OutOrderNo = input.TradeNo, LifePayType = LifePayTypeEnum.AliPay, ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs index e3060bb..dca8f91 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs @@ -527,6 +527,7 @@ await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { OrderNo = res.OutTradeNo, + OutRefundNo = res.RefundId, OutOrderNo = res.TransactionId, LifePayType = LifePayTypeEnum.WxPay, ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses, diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs index bfec02f..afb1d87 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs @@ -115,6 +115,7 @@ await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { OrderNo = wxPayNotice.OutTradeNo, + OutRefundNo = wxPayNotice.OutRefundNo, OutOrderNo = wxPayNotice.TransactionId, LifePayType = LifePayTypeEnum.WxPay, ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts, -- Gitblit v1.9.1