From 182c7edd7c70eddbf33e2358f1f1aba96eb58cb3 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 28 三月 2025 15:43:46 +0800
Subject: [PATCH] fix:查询优化
---
LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs | 20 +++++++++++++++++++-
LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs | 2 +-
LifePayment/LifePayment.HttpApi/LifePay/ChannelFilterAttribute.cs | 4 ++++
LifePayment/LifePayment.Domain/Ali/AliPayApi.cs | 8 +++++---
LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs | 3 ++-
LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs | 9 +++++++++
6 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
index 6eb97db..5f7f622 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
@@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore;
using ZeroD.Util;
using LifePayment.Domain;
+using static LifePayment.Domain.Shared.LifePaymentConstant;
namespace LifePayment.Application.LifePay
{
@@ -140,7 +141,24 @@
}
}
break;
- case LifePayTypeEnum.WxPay: break;
+ case LifePayTypeEnum.WxPay:
+ if (input.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses)
+ {
+ var query = await _wxPayApi.WxPayTradeQuery(input.OrderNo);
+ if (query.Code == AlipayResultCode.Success && query.Status == WxPayStatus.鏀粯鎴愬姛)
+ {
+ await _lifePayExpensesReceiptsRepository.InsertAsync(data);
+ }
+ }
+ else
+ {
+ var query = await _wxPayApi.WxPayDomesticRefundsQuery(input.OrderNo);
+ if (query.Code == AlipayResultCode.Success && query.RefundStatus == WxPayRefundStatus.閫�娆炬垚鍔�)
+ {
+ await _lifePayExpensesReceiptsRepository.InsertAsync(data);
+ }
+ }
+ break;
default: break;
}
diff --git a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
index ec9af73..9c8ac08 100644
--- a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
+++ b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
@@ -810,6 +810,7 @@
/// </summary>
[JsonProperty("code")]
public string Code { get; set; }
+
/// <summary>
/// 杩斿洖淇℃伅
/// </summary>
@@ -821,6 +822,14 @@
/// </summary>
[JsonProperty("refund_id ")]
public string RefundId { get; set; }
+
+
+ /// <summary>
+ /// 寰俊鏀粯閫�娆剧姸鎬�
+ /// </summary>
+ [JsonProperty("refund_status ")]
+ public string RefundStatus { get; set; }
+
/// <summary>
/// 鍟嗘埛閫�娆惧崟鍙�
/// </summary>
diff --git a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
index 1a5ec58..15e591c 100644
--- a/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
+++ b/LifePayment/LifePayment.Domain/Ali/AliPayApi.cs
@@ -5,6 +5,7 @@
using LifePayment.Domain.Shared;
using Microsoft.Extensions.Options;
using Nest;
+using Spire.Pdf;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -17,12 +18,14 @@
{
private readonly Config _options;
+ public const string SDKVERSION = "alipay-easysdk-net-2.0.0";
protected Alipay.EasySDK.Kernel.Client _kernel;
public AliPayApi(
- IOptionsMonitor<Config> optionsMonitor, Client kernel)
+ IOptionsMonitor<Config> optionsMonitor, string optionsName = null)
{
+ Alipay.EasySDK.Kernel.Context context = new Alipay.EasySDK.Kernel.Context(optionsName.IsNullOrEmpty() ? optionsMonitor.CurrentValue : optionsMonitor.Get(optionsName), SDKVERSION);
_options = optionsMonitor.CurrentValue;
- _kernel = kernel;
+ this._kernel = new Client(context);
}
public async Task<AlipayTradePrecreateResponse> GetAliPayQRCode(GetPayQrCodeInput input)
@@ -45,7 +48,6 @@
AlipayTradeQueryResponse response = Factory.Payment.Common().Query(input.OutTradeNo);
return response;
}
-
/// <summary>
/// 鏌ヨ鏀粯瀹濋��娆捐鍗曚俊鎭�
diff --git a/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs b/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
index 71a8a56..def0a92 100644
--- a/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/IWxPayApi.cs
@@ -26,7 +26,7 @@
Task<WxPayDomesticRefundsQueryReponse> WxPayDomesticRefundsQuery(string outTradeNo);
- Task WxPayTradeQuery(string outTradeNo);
+ Task<WxPayDomesticRefundsQueryReponse> WxPayTradeQuery(string outTradeNo);
Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input);
diff --git a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
index 6293c95..d6f6097 100644
--- a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
@@ -43,10 +43,11 @@
return result;
}
- public async Task WxPayTradeQuery(string outTradeNo)
+ public async Task<WxPayDomesticRefundsQueryReponse> WxPayTradeQuery(string outTradeNo)
{
var url = $"{string.Format(LifePaymentConstant.WxPayTradeQyery, outTradeNo)}";
var result = await Certificates<WxPayDomesticRefundsQueryReponse>(url);
+ return result;
}
public async Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input)
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/ChannelFilterAttribute.cs b/LifePayment/LifePayment.HttpApi/LifePay/ChannelFilterAttribute.cs
index 9e37374..4ee10b5 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/ChannelFilterAttribute.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/ChannelFilterAttribute.cs
@@ -48,6 +48,10 @@
}
}
+ else
+ {
+ throw new UserFriendlyException("娌℃湁瀵瑰簲鐨勬笭閬�");
+ }
}
}
--
Gitblit v1.9.1