mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 19:13:26 +08:00
构建回调请求处理。
This commit is contained in:
@@ -34,21 +34,26 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||||
private readonly ICoreCmsBillRefundServices _billRefundServices;
|
private readonly ICoreCmsBillRefundServices _billRefundServices;
|
||||||
private readonly IWeChatPayNotifyClient _client;
|
private readonly IWeChatPayNotifyClient _client;
|
||||||
private readonly IOptions<WeChatPayOptions> _optionsAccessor;
|
//private readonly IOptions<WeChatPayOptions> _optionsAccessor;
|
||||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||||
|
|
||||||
|
private readonly IWeChatPayConfigServices _weChatPayConfigServices;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WeChatPayController(
|
public WeChatPayController(
|
||||||
IWeChatPayNotifyClient client
|
IWeChatPayNotifyClient client
|
||||||
, IOptions<WeChatPayOptions> optionsAccessor
|
//, IOptions<WeChatPayOptions> optionsAccessor
|
||||||
, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository)
|
, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository, IWeChatPayConfigServices weChatPayConfigServices)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_optionsAccessor = optionsAccessor;
|
//_optionsAccessor = optionsAccessor;
|
||||||
_billPaymentsServices = billPaymentsServices;
|
_billPaymentsServices = billPaymentsServices;
|
||||||
_billRefundServices = billRefundServices;
|
_billRefundServices = billRefundServices;
|
||||||
_redisOperationRepository = redisOperationRepository;
|
_redisOperationRepository = redisOperationRepository;
|
||||||
|
_weChatPayConfigServices = weChatPayConfigServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -59,7 +64,23 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, _optionsAccessor.Value);
|
|
||||||
|
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new WeChatPayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
MchId = config.mchId,
|
||||||
|
APIKey = config.apiKey,
|
||||||
|
APIv3Key = config.apiV3Key,
|
||||||
|
Certificate = config.certificate,
|
||||||
|
RsaPublicKey = config.rsaPublicKey,
|
||||||
|
SubAppId = config.subAppId,
|
||||||
|
SubMchId = config.subMchId
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, payOptions);
|
||||||
if (notify.ReturnCode == WeChatPayCode.Success)
|
if (notify.ReturnCode == WeChatPayCode.Success)
|
||||||
{
|
{
|
||||||
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayNotice,
|
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayNotice,
|
||||||
@@ -84,7 +105,24 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.ExecuteAsync<WeChatPayRefundNotify>(Request, _optionsAccessor.Value);
|
|
||||||
|
|
||||||
|
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new WeChatPayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
MchId = config.mchId,
|
||||||
|
APIKey = config.apiKey,
|
||||||
|
APIv3Key = config.apiV3Key,
|
||||||
|
Certificate = config.certificate,
|
||||||
|
RsaPublicKey = config.rsaPublicKey,
|
||||||
|
SubAppId = config.subAppId,
|
||||||
|
SubMchId = config.subMchId
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var notify = await _client.ExecuteAsync<WeChatPayRefundNotify>(Request, payOptions);
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信退款结果通知", JsonConvert.SerializeObject(notify));
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信退款结果通知", JsonConvert.SerializeObject(notify));
|
||||||
|
|
||||||
if (notify.ReturnCode == WeChatPayCode.Success)
|
if (notify.ReturnCode == WeChatPayCode.Success)
|
||||||
|
|||||||
Reference in New Issue
Block a user