后端【新增】新增商家转账功能后台处理及接口回调获取。

This commit is contained in:
jianweie code
2025-07-29 00:51:57 +08:00
parent 596225acb1
commit c8b4bbd78d
38 changed files with 3385 additions and 436 deletions

View File

@@ -8,20 +8,21 @@
* Description: 暂无
***********************************************************************/
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.Configuration;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.FromBody;
using Essensoft.Paylink.WeChatPay;
using Essensoft.Paylink.WeChatPay.V2;
using Essensoft.Paylink.WeChatPay.V2.Notify;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using NLog;
using System;
using System.Threading.Tasks;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using Essensoft.Paylink.WeChatPay;
using Essensoft.Paylink.WeChatPay.V2;
using Essensoft.Paylink.WeChatPay.V2.Notify;
namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
{
@@ -31,26 +32,25 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
[Route("Notify/[controller]/[action]")]
public class WeChatPayController : ControllerBase
{
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
private readonly ICoreCmsBillRefundServices _billRefundServices;
private readonly IWeChatPayNotifyClient _client;
private readonly IRedisOperationRepository _redisOperationRepository;
private readonly IWeChatPayConfigServices _weChatPayConfigServices;
private readonly ICoreCmsUserTocashWeChatNotifyServices _userTocashWeChatNotifyServices;
/// <summary>
/// 构造函数
/// </summary>
public WeChatPayController(
IWeChatPayNotifyClient client
, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository, IWeChatPayConfigServices weChatPayConfigServices)
IWeChatPayNotifyClient client, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository, IWeChatPayConfigServices weChatPayConfigServices, ICoreCmsUserTocashWeChatNotifyServices userTocashWeChatNotifyServices)
{
_client = client;
_billPaymentsServices = billPaymentsServices;
_billRefundServices = billRefundServices;
_redisOperationRepository = redisOperationRepository;
_weChatPayConfigServices = weChatPayConfigServices;
_userTocashWeChatNotifyServices = userTocashWeChatNotifyServices;
}
/// <summary>
@@ -146,5 +146,55 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
return NoContent();
}
}
/// <summary>
/// 商家转账回调通知
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> TransferBillsCallBack([FromBody] FMTransferBillsCallBack entity)
{
try
{
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "商家转账回调通知", JsonConvert.SerializeObject(entity));
if (entity == null)
{
var obj = new
{
code = "FAIL",
message = "失败"
};
return new JsonResult(obj);
}
var log = new CoreCmsUserTocashWeChatNotify();
log.callBackId = entity.id;
log.create_time = entity.create_time;
log.resource_type = entity.resource_type;
log.event_type = entity.event_type;
log.summary = entity.summary;
log.resource = JsonConvert.SerializeObject(entity.resource);
log.createTime = DateTime.Now;
await _userTocashWeChatNotifyServices.InsertAsync(log);
return NoContent();
}
catch (Exception ex)
{
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "商家转账回调通知", "结果通知", ex);
var obj = new
{
code = "FAIL",
message = "失败"
};
return new JsonResult(obj);
}
}
}
}

View File

@@ -839,7 +839,7 @@
微信支付异步通知
</summary>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.#ctor(Essensoft.Paylink.WeChatPay.V2.IWeChatPayNotifyClient,CoreCms.Net.IServices.ICoreCmsBillPaymentsServices,CoreCms.Net.IServices.ICoreCmsBillRefundServices,CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository,CoreCms.Net.IServices.IWeChatPayConfigServices)">
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.#ctor(Essensoft.Paylink.WeChatPay.V2.IWeChatPayNotifyClient,CoreCms.Net.IServices.ICoreCmsBillRefundServices,CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository,CoreCms.Net.IServices.IWeChatPayConfigServices,CoreCms.Net.IServices.ICoreCmsUserTocashWeChatNotifyServices)">
<summary>
构造函数
</summary>
@@ -854,6 +854,12 @@
退款结果通知
</summary>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.TransferBillsCallBack(CoreCms.Net.Model.FromBody.FMTransferBillsCallBack)">
<summary>
商家转账回调通知
</summary>
<returns></returns>
</member>
<member name="T:CoreCms.Net.Web.WebApi.Controllers.PinTuanController">
<summary>
拼团接口