mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:23:26 +08:00
后端【新增】新增商家转账功能后台处理及接口回调获取。
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user