mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:13:26 +08:00
【新增】增加支付宝支付功能,方便APP调用。
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Essensoft.Paylink.Alipay" Version="4.0.12" />
|
||||
<PackageReference Include="Essensoft.Paylink.WeChatPay" Version="4.0.12" />
|
||||
<PackageReference Include="InitQ" Version="1.0.0.12" />
|
||||
<PackageReference Include="Qc.YilianyunSdk" Version="1.0.7" />
|
||||
|
||||
76
CoreCms.Net.RedisMQ/Subscribe/AliPayNoticeSubscribe.cs
Normal file
76
CoreCms.Net.RedisMQ/Subscribe/AliPayNoticeSubscribe.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Loging;
|
||||
using Essensoft.Paylink.Alipay;
|
||||
using Essensoft.Paylink.Alipay.Notify;
|
||||
using InitQ.Abstractions;
|
||||
using InitQ.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CoreCms.Net.RedisMQ.Subscribe
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付宝支付成功后推送到接口进行数据处理
|
||||
/// </summary>
|
||||
public class AliPayNoticeSubscribe : IRedisSubscribe
|
||||
{
|
||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||
|
||||
public AliPayNoticeSubscribe(ICoreCmsBillPaymentsServices billPaymentsServices)
|
||||
{
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 支付宝支付成功后推送到接口进行数据处理
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
[Subscribe(RedisMessageQueueKey.AliPayNotice)]
|
||||
private async Task AliPayNotice(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
var notify = JsonConvert.DeserializeObject<AlipayTradeAppPayNotify>(msg);
|
||||
if (notify is { TradeStatus: AlipayTradeStatus.Success })
|
||||
{
|
||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||
{
|
||||
var money = decimal.Parse(notify.TotalAmount);
|
||||
await _billPaymentsServices.ToUpdate(notify.OutTradeNo,
|
||||
(int)GlobalEnumVars.BillPaymentsStatus.Payed,
|
||||
GlobalEnumVars.PaymentsTypes.alipay.ToString(), money, notify.TradeStatus,notify.TradeNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
var money = decimal.Parse(notify.TotalAmount);
|
||||
var message = notify.TradeStatus;
|
||||
await _billPaymentsServices.ToUpdate(notify.OutTradeNo,
|
||||
(int)GlobalEnumVars.BillPaymentsStatus.Other,
|
||||
GlobalEnumVars.PaymentsTypes.alipay.ToString(), money, message, notify.TradeNo);
|
||||
}
|
||||
}
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Info, LogType.RedisMessageQueue, "支付宝支付成功后推送到接口进行数据处理", msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "支付宝支付成功后推送到接口进行数据处理", msg, ex);
|
||||
throw;
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user