From a5f0843b6b8f1d12ba8d100c81461386b80d7883 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 09 十二月 2025 17:43:54 +0800
Subject: [PATCH] fix: 退款
---
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 43 ++++++++
LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs | 76 ++++++++++++++-
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs | 21 ++++
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs | 6 +
LifePayment/LifePayment.Domain.Shared/Wallet/WalletConstant.cs | 1
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs | 9 +
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs | 35 +++++++
LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs | 16 +++
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml | 13 ++
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 34 ++++++
10 files changed, 247 insertions(+), 7 deletions(-)
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs
index 3f2a7a5..0efabe9 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs
@@ -24,6 +24,12 @@
Task AddLifePayExpensesReceipts(AddLifePayExpensesReceiptsInput input);
+ /// <summary>
+ /// 鑾峰彇閫�娆惧钩鍙版祦姘磋鎯�
+ /// </summary>
+ /// <returns></returns>
+ Task<GetRefundPlatformTradeDetailOutput> GetRefundPlatformTradeDetail(string orderNo);
+
Task GetAllLifePayExpensesReceipts();
Task GetAllChannlesRake();
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
index ba46193..46e301d 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -65,6 +65,13 @@
Task LifePayRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus);
/// <summary>
+ /// 閫�娆炬垚鍔熷鐞�
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ Task<int> LifePayRefundsSuccessHandler(AddLifePayExpensesReceiptsInput input);
+
+ /// <summary>
/// 渚涘簲鍟嗗洖璋冨鐞�
/// </summary>
/// <param name="orderNo"></param>
@@ -345,6 +352,6 @@
Task<bool> CheckChannelsStatus(string channlesId);
-
+ Task LifePayOrderHistory(string operateContent, string operateName, Guid relationId, int? tableType = (int)OperateHistoryTypeEnum.LifePayRefund);
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
index 4672d2e..8ee5f0c 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -894,4 +894,39 @@
public decimal SupplierRate { get; set; }
public decimal Rate { get; set; }
+}
+
+public class GetRefundPlatformTradeDetailOutput
+{
+ /// <summary>
+ /// 璁㈠崟鍙�
+ /// </summary>
+ public string OrderNo { get; set; }
+
+ /// <summary>
+ /// 閫�娆捐鍗曞彿
+ /// </summary>
+ public string RefundOrderNo { get; set; }
+
+ /// <summary>
+ /// 閫�娆剧敵璇锋椂闂�
+ /// </summary>
+ public DateTime RefundTime { get; set; }
+
+ /// <summary>
+ /// 閫�娆炬垚鍔熸椂闂�
+ /// </summary>
+ public DateTime RefundSuccessTime { get; set; }
+
+ public RefundPlatformStatusEnum RefundPlatformStatus { get; set; }
+
+ /// <summary>
+ /// 娓犻亾娴佹按鍙�
+ /// </summary>
+ public string OutOrderNo { get; set; }
+
+ /// <summary>
+ /// 鏀粯娓犻亾
+ /// </summary>
+ public LifePayTypeEnum LifePayType { get; set; }
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
index d93481e..002a208 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
@@ -1,7 +1,10 @@
锘縰sing LifePayment.Application.Contracts;
+using LifePayment.Domain;
using LifePayment.Domain.LifePay;
using LifePayment.Domain.Models;
using LifePayment.Domain.Shared;
+using Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,11 +12,9 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
-using Microsoft.EntityFrameworkCore;
using ZeroD.Util;
-using LifePayment.Domain;
+using ZeroD.Util.Fadd;
using static LifePayment.Domain.Shared.LifePaymentConstant;
-using Newtonsoft.Json;
namespace LifePayment.Application.LifePay
{
@@ -297,7 +298,7 @@
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.OrderNo = input.OrderNo;
data.ExtraProperties = JsonConvert.SerializeObject(query);
data.FinishTime = Convert.ToDateTime(query.GmtRefundPay);
data.Amount = Convert.ToDecimal(query.RefundAmount);
@@ -336,8 +337,74 @@
}
}
+ /// <summary>
+ /// 鑾峰彇閫�娆惧钩鍙版祦姘磋鎯�
+ /// </summary>
+ /// <returns></returns>
+ public async Task<GetRefundPlatformTradeDetailOutput> GetRefundPlatformTradeDetail(string orderNo)
+ {
+ var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayRefundStatus != LifePayRefundStatusEnum.寰呴��娆� && order.LifePayRefundStatus != LifePayRefundStatusEnum.閫�娆句腑, "褰撳墠璁㈠崟鐘舵�佹棤娉曟煡鐪嬮��娆炬祦姘�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.RefundOrderNo.IsNullOrEmpty(), "涓嶅瓨鍦ㄩ��娆炬祦姘磋鍗�");
+ var result = new GetRefundPlatformTradeDetailOutput();
+ if (order.LifePayType == LifePayTypeEnum.AliPay)
+ {
+ var query = await _aliPayApi.QueryAlipayTradeRefund(new OrderInQuiryInput() { OutTradeNo = order.OrderNo, OutRefundNo = order.RefundOrderNo });
+ result.OrderNo = order.OrderNo;
+ result.RefundOrderNo = order.RefundOrderNo;
+ result.OutOrderNo = query.TradeNo;
+ result.LifePayType = LifePayTypeEnum.AliPay;
+ result.RefundTime = Convert.ToDateTime(order.RefundTime);
+ result.RefundSuccessTime = Convert.ToDateTime(query.GmtRefundPay);
+ result.RefundPlatformStatus = MapWxpayRefundStatusToPlatformEnum(query.RefundStatus);
+ }
+ else if (order.LifePayType == LifePayTypeEnum.WxPay)
+ {
+ var query = await _wxPayApi.WxPayDomesticRefundsQuery(order.RefundOrderNo);
+ result.OrderNo = order.OrderNo;
+ result.RefundOrderNo = order.RefundOrderNo;
+ result.OutOrderNo = query.TransactionId;
+ result.LifePayType = LifePayTypeEnum.WxPay;
+ result.RefundTime = Convert.ToDateTime(query.CreateTime);
+ result.RefundSuccessTime = Convert.ToDateTime(query.SuccessTime);
+ result.RefundPlatformStatus = MapWxpayRefundStatusToPlatformEnum(query.Status);
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// 鏀粯瀹濋��娆剧姸鎬佹槧灏勫埌閫氱敤閫�娆惧钩鍙扮姸鎬侊紙Switch 鐗堟湰锛�
+ /// </summary>
+ /// <param name="alipayStatus">鏀粯瀹濋��娆剧姸鎬�</param>
+ /// <returns>閫氱敤閫�娆惧钩鍙扮姸鎬�</returns>
+ public static RefundPlatformStatusEnum MapAlipayRefundStatusToPlatformEnum(string alipayRefundStatus)
+ {
+ return alipayRefundStatus switch
+ {
+ AlipayRefundStatus.Success => RefundPlatformStatusEnum.SUCCESS,
+ _ => RefundPlatformStatusEnum.PROCESSING
+ };
+ }
+
+ /// <summary>
+ /// 寰俊閫�娆剧姸鎬佹槧灏勫埌閫氱敤閫�娆惧钩鍙扮姸鎬侊紙Switch 鐗堟湰锛�
+ /// </summary>
+ /// <param name="wxPayRefundStatus">寰俊閫�娆剧姸鎬�</param>
+ /// <returns>閫氱敤閫�娆惧钩鍙扮姸鎬�</returns>
+ public static RefundPlatformStatusEnum MapWxpayRefundStatusToPlatformEnum(string wxPayRefundStatus)
+ {
+ return wxPayRefundStatus switch
+ {
+ WxPayRefundStatus.閫�娆炬垚鍔� => RefundPlatformStatusEnum.SUCCESS,
+ WxPayRefundStatus.閫�娆惧叧闂� => RefundPlatformStatusEnum.CLOSED,
+ WxPayRefundStatus.閫�娆惧鐞嗕腑 => RefundPlatformStatusEnum.PROCESSING,
+ _ => RefundPlatformStatusEnum.ABNORMAL
+ };
+ }
/// <summary>
/// 缁熻鎵�鏈夋秷璐规祦姘�
@@ -587,6 +654,5 @@
}
#endregion
-
}
}
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 14da46e..b370b07 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -1534,6 +1534,38 @@
}
}
+ /// <summary>
+ /// 閫�娆炬垚鍔熷鐞�
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public async Task<int> LifePayRefundsSuccessHandler(AddLifePayExpensesReceiptsInput input)
+ {
+ var order = await _lifePayOrderRepository.Where(x => x.OrderNo == input.OrderNo).FirstOrDefaultAsync();
+ CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayRefundStatus != LifePayRefundStatusEnum.寰呴��娆� && order.LifePayRefundStatus != LifePayRefundStatusEnum.閫�娆句腑, "褰撳墠璁㈠崟鐘舵�佹棤娉曟煡鐪嬮��娆炬祦姘�");
+ CheckExtensions.IfTrueThrowUserFriendlyException(order.RefundOrderNo.IsNullOrEmpty(), "涓嶅瓨鍦ㄩ��娆炬祦姘磋鍗�");
+
+ await LifePayRefundsHandler(input.OrderNo, LifePayRefundStatusEnum.宸查��娆�);
+ // 鎻掑叆鏀舵敮娴佹按
+ await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
+ {
+ OrderNo = input.OrderNo,
+ OutRefundNo = input.OutRefundNo,
+ OutOrderNo = input.OutOrderNo,
+ LifePayType = input.LifePayType,
+ ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts
+ });
+
+ #region 璁板綍鏃ュ織
+
+ await LifePayOrderHistory("鏇存柊璁㈠崟閫�娆剧姸鎬�", "鏇存柊璁㈠崟閫�娆剧姸鎬�", order.Id, (int)OperateHistoryTypeEnum.LifePayRefund);
+
+ #endregion
+
+ return Constant.SUCCESS;
+ }
+
/// <summary>
/// ACOOLYO璁㈠崟閫氱煡澶勭悊
@@ -2153,7 +2185,7 @@
await _distributedEventBus.PublishAsync(recordEto, false);
}
- private async Task LifePayOrderHistory(string operateContent, string operateName, Guid relationId, int? tableType = (int)OperateHistoryTypeEnum.LifePayRefund)
+ public async Task LifePayOrderHistory(string operateContent, string operateName, Guid relationId, int? tableType = (int)OperateHistoryTypeEnum.LifePayRefund)
{
var operateHistory = new OperateHistory
{
diff --git a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
index ccdc980..5c18124 100644
--- a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
+++ b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
@@ -1,4 +1,5 @@
锘縰sing System.ComponentModel;
+using static LifePayment.Domain.Shared.LifePaymentConstant;
namespace LifePayment.Domain.Shared;
@@ -216,3 +217,18 @@
[Description("鍑洪噾")]
Out = 20,
}
+
+public enum RefundPlatformStatusEnum
+{
+ [Description("閫�娆炬垚鍔�")]
+ SUCCESS = 10,
+
+ [Description("閫�娆惧叧闂�")]
+ CLOSED = 20,
+
+ [Description("閫�娆惧鐞嗕腑")]
+ PROCESSING = 30,
+
+ [Description("閫�娆惧紓甯�")]
+ ABNORMAL = 40,
+}
diff --git a/LifePayment/LifePayment.Domain.Shared/Wallet/WalletConstant.cs b/LifePayment/LifePayment.Domain.Shared/Wallet/WalletConstant.cs
index 08969da..54550a2 100644
--- a/LifePayment/LifePayment.Domain.Shared/Wallet/WalletConstant.cs
+++ b/LifePayment/LifePayment.Domain.Shared/Wallet/WalletConstant.cs
@@ -33,4 +33,5 @@
/// </summary>
public const int NotFoundWallet = 10050;
}
+
}
diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
index f22aa14..24eade9 100644
--- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -411,6 +411,19 @@
</summary>
<returns></returns>
</member>
+ <member name="M:LifePayment.HttpApi.LifePayController.GetRefundPlatformTradeDetail(System.String)">
+ <summary>
+ 鑾峰彇閫�娆惧钩鍙版祦姘磋鎯�
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:LifePayment.HttpApi.LifePayController.LifePayRefundsSuccessHandler(LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput)">
+ <summary>
+ 閫�娆炬垚鍔熷鐞�
+ </summary>
+ <param name="input"></param>
+ <returns></returns>
+ </member>
<member name="M:LifePayment.HttpApi.LifePayController.CreateLifePayPhoneOrder(LifePayment.Application.Contracts.CreateLifePayOrderInput{LifePayment.Application.Contracts.LifePhoneData})">
<summary>
鍒涘缓鐢熸椿缂磋垂璇濊垂璁㈠崟
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 5c5cfe1..2b04e42 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -31,6 +31,12 @@
</summary>
<returns></returns>
</member>
+ <member name="M:LifePayment.Application.Contracts.ILifePayOrderService.GetRefundPlatformTradeDetail(System.String)">
+ <summary>
+ 鑾峰彇閫�娆惧钩鍙版祦姘磋鎯�
+ </summary>
+ <returns></returns>
+ </member>
<member name="M:LifePayment.Application.Contracts.ILifePayRateService.GetLifePayRateChannelPage(ZeroD.Util.PageInput)">
<summary>
鑾峰彇鎶樻墸閫氶亾閰嶇疆鍒嗛〉
@@ -118,6 +124,13 @@
</summary>
<param name="orderNo"></param>
<param name="refundStatus"></param>
+ <returns></returns>
+ </member>
+ <member name="M:LifePayment.Application.Contracts.ILifePayService.LifePayRefundsSuccessHandler(LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput)">
+ <summary>
+ 閫�娆炬垚鍔熷鐞�
+ </summary>
+ <param name="input"></param>
<returns></returns>
</member>
<member name="M:LifePayment.Application.Contracts.ILifePayService.ACOOLYOrderNotifyHandler(System.String,System.String,LifePayment.Domain.Shared.LifePayOrderStatusEnum,LifePayment.Domain.Shared.ACOOLYStatusEnum,System.Decimal,System.String,System.Nullable{System.Decimal},System.Nullable{System.Decimal})">
@@ -1067,6 +1080,36 @@
缁堟缁撶畻鏃堕棿
</summary>
</member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.OrderNo">
+ <summary>
+ 璁㈠崟鍙�
+ </summary>
+ </member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.RefundOrderNo">
+ <summary>
+ 閫�娆捐鍗曞彿
+ </summary>
+ </member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.RefundTime">
+ <summary>
+ 閫�娆剧敵璇锋椂闂�
+ </summary>
+ </member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.RefundSuccessTime">
+ <summary>
+ 閫�娆炬垚鍔熸椂闂�
+ </summary>
+ </member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.OutOrderNo">
+ <summary>
+ 娓犻亾娴佹按鍙�
+ </summary>
+ </member>
+ <member name="P:LifePayment.Application.Contracts.GetRefundPlatformTradeDetailOutput.LifePayType">
+ <summary>
+ 鏀粯娓犻亾
+ </summary>
+ </member>
<member name="P:LifePayment.Application.Contracts.LifePayIntroInfoInput.LifePayType">
<summary>
鐢熸椿缂磋垂绫诲瀷
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
index 3d5a3e4..7397570 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -684,11 +684,32 @@
{
await _lifePayOrderService.GetAllLifePayConsumption();
}
+
+ /// <summary>
+ /// 鑾峰彇閫�娆惧钩鍙版祦姘磋鎯�
+ /// </summary>
+ /// <returns></returns>
+ [HttpGet]
+ public async Task<GetRefundPlatformTradeDetailOutput> GetRefundPlatformTradeDetail(string orderNo)
+ {
+ return await _lifePayOrderService.GetRefundPlatformTradeDetail(orderNo);
+ }
#endregion
#region 鎿嶄綔
/// <summary>
+ /// 閫�娆炬垚鍔熷鐞�
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ [HttpPost]
+ public async Task<int> LifePayRefundsSuccessHandler(AddLifePayExpensesReceiptsInput input)
+ {
+ return await _lifePayService.LifePayRefundsSuccessHandler(input);
+ }
+
+ /// <summary>
/// 鍒涘缓鐢熸椿缂磋垂璇濊垂璁㈠崟
/// </summary>
/// <param name="input"></param>
--
Gitblit v1.9.1