From 83971e864fbee9e1a12d25239fbf005760ee983f Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期五, 28 三月 2025 14:22:59 +0800 Subject: [PATCH] fix:支付查询 --- LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs | 8 + LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs | 21 ++ LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 25 +++ LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs | 67 ++++++++ LifePayment/LifePayment.Domain/LifePay/LifePayRechargeReceipts.cs | 3 LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs | 3 LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs | 2 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs | 27 +++ LifePayment/LifePayment.Domain/Ali/AlipayApiConstant.cs | 32 ++++ LifePayment/LifePayment.Domain/LifePay/LifePayExpensesReceipts.cs | 56 ++++++++ LifePayment/LifePayment.Domain/Ali/AliPayApi.cs | 141 +++++++++++++++++++ LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs | 14 + LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml | 7 + LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 2 LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs | 8 + 15 files changed, 400 insertions(+), 16 deletions(-) diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs index e465c85..788c88e 100644 --- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs +++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayOrderService.cs @@ -12,6 +12,7 @@ { Task<LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput>> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input); - Task AddUpdatePayRechargeReceipts(AddUpdatePayRechargeReceiptsInput input); + + Task AddLifePayExpensesReceipts(AddLifePayExpensesReceiptsInput input); } \ 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 cf63147..0d32b8a 100644 --- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs +++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs @@ -643,4 +643,31 @@ public decimal PayAmount { get; set; } public LifePayTypeEnum LifePayType { get; set; } +} +public class AddLifePayExpensesReceiptsInput +{ + /// <summary> + /// 骞冲彴璁㈠崟鍙� + /// </summary> + public string OrderNo { get; set; } + + /// <summary> + /// 娓犻亾娴佹按鍙� + /// </summary> + public string OutOrderNo { get; set; } + + /// <summary> + /// 鏀粯娓犻亾 + /// </summary> + public LifePayTypeEnum LifePayType { get; set; } + + /// <summary> + /// 鏀舵敮绫诲瀷 + /// </summary> + public ExpensesReceiptsTypeEnum ExpensesReceiptsType { get; set; } + + /// <summary> + /// 浜ゆ槗閲戦 + /// </summary> + public decimal Amount { 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 3f02652..6eb97db 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs @@ -11,17 +11,27 @@ using Volo.Abp.Domain.Repositories; using Microsoft.EntityFrameworkCore; using ZeroD.Util; +using LifePayment.Domain; namespace LifePayment.Application.LifePay { public class LifePayOrderService : ApplicationService, ILifePayOrderService { private readonly IRepository<LifePayRechargeReceipts, Guid> _lifePayRechargeReceiptsRepository; + private readonly IRepository<LifePayExpensesReceipts, Guid> _lifePayExpensesReceiptsRepository; + private readonly IAliPayApi _aliPayApi; + private readonly IWxPayApi _wxPayApi; public LifePayOrderService( - IRepository<LifePayRechargeReceipts, Guid> lifePayRechargeReceiptsRepository) + IRepository<LifePayRechargeReceipts, Guid> lifePayRechargeReceiptsRepository, + IRepository<LifePayExpensesReceipts, Guid> lifePayExpensesReceiptsRepository, + IAliPayApi aliPayApi, + IWxPayApi wxPayApi) { _lifePayRechargeReceiptsRepository = lifePayRechargeReceiptsRepository; + _lifePayExpensesReceiptsRepository = lifePayExpensesReceiptsRepository; + _aliPayApi = aliPayApi; + _wxPayApi = wxPayApi; } /// <summary> @@ -53,11 +63,7 @@ return result; } - //public async Task<decimal> GetTotalLifePayRechargeReceipts() - //{ - // var result = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount); - // return result; - //} + /// <summary> /// 缂栬緫鍏呭�兼祦姘� @@ -92,5 +98,54 @@ await _lifePayRechargeReceiptsRepository.InsertAsync(payRechargeReceipts); } } + + /// <summary> + /// 鎻掑叆鏀舵敮娴佹按 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task AddLifePayExpensesReceipts(AddLifePayExpensesReceiptsInput input) + { + var repeat = await _lifePayExpensesReceiptsRepository.Where(x => x.ExpensesReceiptsType == input.ExpensesReceiptsType + && x.OrderNo == input.OrderNo).FirstOrDefaultAsync(); + if (repeat == null) + { + var data = new LifePayExpensesReceipts() + { + Id = Guid.NewGuid(), + OrderNo = input.OrderNo, + OutOrderNo = input.OutOrderNo, + LifePayType = input.LifePayType, + ExpensesReceiptsType = input.ExpensesReceiptsType, + Amount = input.Amount + }; + + switch (input.LifePayType) + { + case LifePayTypeEnum.AliPay: + if (input.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses) + { + var query = await _aliPayApi.OrderInQuiry(new OrderInQuiryInput() { OutTradeNo = input.OrderNo }); + if (query.Code == AlipayResultCode.Success && query.TradeStatus == AlipayStatus.TRADESUCCESS) + { + await _lifePayExpensesReceiptsRepository.InsertAsync(data); + } + } + else + { + var query = await _aliPayApi.QueryAlipayTradeRefund(new OrderInQuiryInput() { OutTradeNo = input.OrderNo }); + if (query.Code == AlipayResultCode.Success && query.RefundStatus == AlipayRefundStatus.Success) + { + await _lifePayExpensesReceiptsRepository.InsertAsync(data); + } + } + break; + case LifePayTypeEnum.WxPay: break; + default: break; + } + + + } + } } } diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 9144d0f..e847711 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -1418,7 +1418,7 @@ break; case LifePayTypeEnum.AliPay: - var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = input.RefundPrice.ToString() }); + var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, OutRefundNo = outRefundNo, RefundAmount = input.RefundPrice.ToString() }); if (aliRefundResult.Code != AlipayResultCode.Success) { throw new UserFriendlyException("閫�娆惧け璐�:" + aliRefundResult.SubMsg); diff --git a/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs b/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs index d8f195a..b98c786 100644 --- a/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs +++ b/LifePayment/LifePayment.Domain.Shared/Ali/GetPayQrCodeInput.cs @@ -33,6 +33,14 @@ /// </summary> public string OutTradeNo { get; set; } + /// <summary> + /// 閫�娆鹃噾棰� + /// </summary> public string RefundAmount { get; set; } + + /// <summary> + /// 閫�娆捐鍗曞彿 + /// </summary> + public string OutRefundNo { get; set; } } } \ No newline at end of file diff --git a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs index fa91acf..a7c1146 100644 --- a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs +++ b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs @@ -11,6 +11,8 @@ AliPay = 20 } + + public enum LifePayOrderTypeEnum { [Description("璇濊垂璁㈠崟")] @@ -185,4 +187,14 @@ [Description("閮ㄥ垎閫�娆�")] 閮ㄥ垎閫�娆� = 20 -} \ No newline at end of file +} + +public enum ExpensesReceiptsTypeEnum +{ + [Description("鏀跺叆")] + Expenses = 10, + + [Description("鏀嚭")] + Receipts = 20, + +} diff --git a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs index cdeb515..1a5ec58 100644 --- a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs +++ b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs @@ -5,7 +5,11 @@ using LifePayment.Domain.Shared; using Microsoft.Extensions.Options; using Nest; +using System; +using System.Collections; +using System.Collections.Generic; using System.Threading.Tasks; +using Tea; namespace LifePayment.Domain { @@ -13,10 +17,12 @@ { private readonly Config _options; + protected Alipay.EasySDK.Kernel.Client _kernel; public AliPayApi( - IOptionsMonitor<Config> optionsMonitor) + IOptionsMonitor<Config> optionsMonitor, Client kernel) { _options = optionsMonitor.CurrentValue; + _kernel = kernel; } public async Task<AlipayTradePrecreateResponse> GetAliPayQRCode(GetPayQrCodeInput input) @@ -40,6 +46,7 @@ return response; } + /// <summary> /// 鏌ヨ鏀粯瀹濋��娆捐鍗曚俊鎭� /// </summary> @@ -53,9 +60,139 @@ public async Task<AlipayTradeRefundResponse> TradeRefund(AlipayTradeRefundRequest input) { - AlipayTradeRefundResponse response = await Factory.Payment.Common().RefundAsync(input.OutTradeNo,input.RefundAmount); + AlipayTradeRefundResponse response = await TradeRefund(input.OutTradeNo,input.OutRefundNo, input.RefundAmount); return response; } + private async Task<AlipayTradeRefundResponse> TradeRefund(string outTradeNo, string outRefundNo, string refundAmount) + { + Dictionary<string, object> runtime_ = new Dictionary<string, object> + { + { + "ignoreSSL", + _kernel.GetConfig("ignoreSSL") + }, + { + "httpProxy", + _kernel.GetConfig("httpProxy") + }, + { "connectTimeout", 15000 }, + { "readTimeout", 15000 }, + { + "retry", + new Dictionary<string, int?> { { "maxAttempts", 0 } } + } + }; + TeaRequest _lastRequest = null; + Exception innerException = null; + long _now = DateTime.Now.Millisecond; + int _retryTimes = 0; + while (TeaCore.AllowRetry((IDictionary)runtime_["retry"], _retryTimes, _now)) + { + if (_retryTimes > 0) + { + int backoffTime = TeaCore.GetBackoffTime((IDictionary)runtime_["backoff"], _retryTimes); + if (backoffTime > 0) + { + TeaCore.Sleep(backoffTime); + } + } + + _retryTimes++; + try + { + TeaRequest teaRequest = new TeaRequest(); + Dictionary<string, string> dictionary = new Dictionary<string, string> + { + { "method", "alipay.trade.refund" }, + { + "app_id", + _kernel.GetConfig("appId") + }, + { + "timestamp", + _kernel.GetTimestamp() + }, + { "format", "json" }, + { "version", "1.0" }, + { + "alipay_sdk", + _kernel.GetSdkVersion() + }, + { "charset", "UTF-8" }, + { + "sign_type", + _kernel.GetConfig("signType") + }, + { + "app_cert_sn", + _kernel.GetMerchantCertSN() + }, + { + "alipay_root_cert_sn", + _kernel.GetAlipayRootCertSN() + } + }; + Dictionary<string, object> bizParams = new Dictionary<string, object> + { + { "out_trade_no", outTradeNo }, + { "out_request_no", outRefundNo }, + { "refund_amount", refundAmount } + }; + Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); + teaRequest.Protocol = _kernel.GetConfig("protocol"); + teaRequest.Method = "POST"; + teaRequest.Pathname = "/gateway.do"; + teaRequest.Headers = new Dictionary<string, string> + { + { + "host", + _kernel.GetConfig("gatewayHost") + }, + { "content-type", "application/x-www-form-urlencoded;charset=utf-8" } + }; + teaRequest.Query = _kernel.SortMap(TeaConverter.merge<string>(new object[3] + { + new Dictionary<string, string> { + { + "sign", + _kernel.Sign(dictionary, bizParams, dictionary2, _kernel.GetConfig("merchantPrivateKey")) + } }, + dictionary, + dictionary2 + })); + teaRequest.Body = TeaCore.BytesReadable(_kernel.ToUrlEncodedRequestBody(bizParams)); + _lastRequest = teaRequest; + TeaResponse response = await TeaCore.DoActionAsync(teaRequest, runtime_); + Dictionary<string, object> respMap = await _kernel.ReadAsJsonAsync(response, "alipay.trade.refund"); + if (_kernel.IsCertMode()) + { + if (_kernel.Verify(respMap, _kernel.ExtractAlipayPublicKey(_kernel.GetAlipayCertSN(respMap)))) + { + return TeaModel.ToObject<AlipayTradeRefundResponse>(_kernel.ToRespModel(respMap)); + } + } + else if (_kernel.Verify(respMap, _kernel.GetConfig("alipayPublicKey"))) + { + return TeaModel.ToObject<AlipayTradeRefundResponse>(_kernel.ToRespModel(respMap)); + } + + throw new TeaException(new Dictionary<string, string> { { "message", "楠岀澶辫触锛岃妫�鏌ユ敮浠樺疂鍏挜璁剧疆鏄惁姝g‘銆�" } }); + } + catch (Exception ex) + { + if (TeaCore.IsRetryable(ex)) + { + innerException = ex; + continue; + } + + throw ex; + } + } + + throw new TeaUnretryableException(_lastRequest, innerException); + } + } } \ No newline at end of file diff --git a/LifePayment/LifePayment.Domain/Ali/AlipayApiConstant.cs b/LifePayment/LifePayment.Domain/Ali/AlipayApiConstant.cs index d4a5d6d..aa1a442 100644 --- a/LifePayment/LifePayment.Domain/Ali/AlipayApiConstant.cs +++ b/LifePayment/LifePayment.Domain/Ali/AlipayApiConstant.cs @@ -29,7 +29,39 @@ } + public class AlipayStatus + { + /// <summary> + /// 浜ゆ槗鍒涘缓锛岀瓑寰呬拱瀹朵粯娆� + /// </summary> + public const string WAITBUYERPAY = "WAIT_BUYER_PAY"; + /// <summary> + /// 鏈粯娆句氦鏄撹秴鏃跺叧闂紝鎴栨敮浠樺畬鎴愬悗鍏ㄩ閫�娆� + /// </summary> + public const string TRADECLOSED = "TRADE_CLOSED"; + + /// <summary> + /// 浜ゆ槗鏀粯鎴愬姛 + /// </summary> + public const string TRADESUCCESS = "TRADE_SUCCESS"; + + /// <summary> + /// 浜ゆ槗缁撴潫锛屼笉鍙��娆� + /// </summary> + public const string TRADEFINISHED = "TRADE_FINISHED"; + } + + /// <summary> + /// 浜ゆ槗鐘舵�� + /// </summary> + public class AlipayRefundStatus + { + /// <summary> + /// 閫�娆惧鐞嗘垚鍔�:REFUND_SUCCESS 鏈繑鍥炶瀛楁琛ㄧず閫�娆捐姹傛湭鏀跺埌鎴栬�呴��娆惧け璐� + /// </summary> + public const string Success = "REFUND_SUCCESS"; + } public class AlipayResultCode { public const string Success = "10000"; diff --git a/LifePayment/LifePayment.Domain/LifePay/LifePayExpensesReceipts.cs b/LifePayment/LifePayment.Domain/LifePay/LifePayExpensesReceipts.cs new file mode 100644 index 0000000..b96167f --- /dev/null +++ b/LifePayment/LifePayment.Domain/LifePay/LifePayExpensesReceipts.cs @@ -0,0 +1,56 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp; +using LifePayment.Domain.Shared; + +namespace LifePayment.Domain.LifePay +{ + /// <summary> + /// 鏀舵敮娴佹按 + /// </summary> + public class LifePayExpensesReceipts : FullAuditedEntity<Guid>, IDataUserFilter + { + public LifePayExpensesReceipts() + { + } + + /// <summary> + /// 骞冲彴璁㈠崟鍙� + /// </summary> + public string OrderNo { get; set; } + + /// <summary> + /// 娓犻亾娴佹按鍙� + /// </summary> + public string OutOrderNo { get; set; } + + /// <summary> + /// 鏀粯娓犻亾 + /// </summary> + public LifePayTypeEnum LifePayType { get; set; } + + /// <summary> + /// 鏀舵敮绫诲瀷 + /// </summary> + public ExpensesReceiptsTypeEnum ExpensesReceiptsType { get; set; } + + /// <summary> + /// 浜ゆ槗閲戦 + /// </summary> + public decimal Amount { get; set; } + + /// <summary> + /// 浜ゆ槗鏃堕棿 + /// </summary> + public DateTime FinishTime { get; set; } + + /// <summary> + /// 鎷撳睍鐔熸倝 + /// </summary> + public string ExtraProperties { get; set; } + } +} diff --git a/LifePayment/LifePayment.Domain/LifePay/LifePayRechargeReceipts.cs b/LifePayment/LifePayment.Domain/LifePay/LifePayRechargeReceipts.cs index 5953b75..3a33843 100644 --- a/LifePayment/LifePayment.Domain/LifePay/LifePayRechargeReceipts.cs +++ b/LifePayment/LifePayment.Domain/LifePay/LifePayRechargeReceipts.cs @@ -8,6 +8,9 @@ namespace LifePayment.Domain.LifePay { + /// <summary> + /// 鍏呭�兼祦姘� + /// </summary> public class LifePayRechargeReceipts : FullAuditedEntity<Guid>, IDataUserFilter { public LifePayRechargeReceipts() diff --git a/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs b/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs index 7ca62cf..af9e688 100644 --- a/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs +++ b/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs @@ -27,6 +27,8 @@ public virtual DbSet<LifePayRechargeReceipts> LifePayRechargeReceipts { get; set; } + public virtual DbSet<LifePayExpensesReceipts> LifePayExpensesReceipts { get; set; } + public virtual DbSet<Area> Area { get; set; } public virtual DbSet<User> Users { get; set; } diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml index b06badd..348afee 100644 --- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml +++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml @@ -508,5 +508,12 @@ <param name="input"></param> <returns></returns> </member> + <member name="M:LifePayment.HttpApi.WxPayNotifyController.WxPayDomesticRefundsNotify(LifePayment.Application.Contracts.WxRechargeNotifyInput)"> + <summary> + 寰俊閫�娆鹃�氱煡鍥炶皟 + </summary> + <param name="input"></param> + <returns></returns> + </member> </members> </doc> diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml index 95c97c8..730e795 100644 --- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml +++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml @@ -751,6 +751,31 @@ 鍏呭�煎嚟璇� </summary> </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.OrderNo"> + <summary> + 骞冲彴璁㈠崟鍙� + </summary> + </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.OutOrderNo"> + <summary> + 娓犻亾娴佹按鍙� + </summary> + </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.LifePayType"> + <summary> + 鏀粯娓犻亾 + </summary> + </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.ExpensesReceiptsType"> + <summary> + 鏀舵敮绫诲瀷 + </summary> + </member> + <member name="P:LifePayment.Application.Contracts.AddLifePayExpensesReceiptsInput.Amount"> + <summary> + 浜ゆ槗閲戦 + </summary> + </member> <member name="P:LifePayment.Application.Contracts.LifePayIntroInfoInput.LifePayType"> <summary> 鐢熸椿缂磋垂绫诲瀷 diff --git a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs index 300150a..37a922e 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs @@ -22,6 +22,7 @@ { private readonly ILifePayService _lifePayService; + private readonly ILifePayOrderService _lifePayOrderService; private readonly ILogger<AliPayNotifyController> _logger; @@ -29,10 +30,12 @@ ILogger<AliPayNotifyController> logger, - ILifePayService lifePayService) + ILifePayService lifePayService, + ILifePayOrderService lifePayOrderService) { _logger = logger; _lifePayService = lifePayService; + _lifePayOrderService = lifePayOrderService; } /// <summary> @@ -57,6 +60,9 @@ if (input.TradeStatus == LifePaymentConstant.AliPayStatus.鏀粯鎴愬姛) { await _lifePayService.LifePaySuccessHandler(input.OutTradeNo, input.TradeNo); + await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { OrderNo = input.OutTradeNo, + OutOrderNo = input.TradeNo ,LifePayType = LifePayTypeEnum.AliPay,ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses, + Amount = input.ReceiptAmount.Value }); } } else diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs index 454dc62..5411b49 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs @@ -21,16 +21,19 @@ private readonly IWxPayApi _wxPayApi; private readonly ILifePayService _lifePayService; + private readonly ILifePayOrderService _lifePayOrderService; private readonly ILogger<WxPayNotifyController> _logger; public WxPayNotifyController( IWxPayApi wxPayApi, ILogger<WxPayNotifyController> logger, - ILifePayService lifePayService) + ILifePayService lifePayService, + ILifePayOrderService lifePayOrderService) { _wxPayApi = wxPayApi; _logger = logger; _lifePayService = lifePayService; + _lifePayOrderService = lifePayOrderService; } /// <summary> @@ -53,6 +56,14 @@ if (wxPayNotice.TradeState == LifePaymentConstant.WxPayStatus.鏀粯鎴愬姛) { await _lifePayService.LifePaySuccessHandler(wxPayNotice.OutTradeNo, wxPayNotice.TransactionId); + await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() + { + OrderNo = wxPayNotice.OutTradeNo, + OutOrderNo = wxPayNotice.TransactionId, + LifePayType = LifePayTypeEnum.WxPay, + ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses, + Amount = wxPayNotice.Amount.Total + }); } } } @@ -72,7 +83,11 @@ }; } - + /// <summary> + /// 寰俊閫�娆鹃�氱煡鍥炶皟 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> [HttpPost] [UnitOfWork] public async Task<WxRechargeNotifyResult> WxPayDomesticRefundsNotify(WxRechargeNotifyInput input) @@ -92,8 +107,6 @@ switch (wxPayNotice.RefundStatus) { case LifePaymentConstant.WxPayRefundStatus.閫�娆炬垚鍔�: - await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.宸查��娆�); - break; case LifePaymentConstant.WxPayRefundStatus.閫�娆惧叧闂�: await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.宸查��娆�); break; -- Gitblit v1.9.1