|
@@ -1,3 +1,5 @@
|
|
|
+using System.Collections.Concurrent;
|
|
|
+using System.Text;
|
|
|
using System;
|
|
|
using System.Web;
|
|
|
using WingServerCommon.Service;
|
|
@@ -25,6 +27,7 @@ namespace WingPaymentService.Service
|
|
|
private IPaymentDBService _paymentDBService;
|
|
|
private AlipayCommon _alipayCommon;
|
|
|
private WeChatCommon _weChatCommon;
|
|
|
+ private ConcurrentDictionary<string, string> _recordRelation = new();
|
|
|
public override void Load(JsonRpcClientPool jsonRpcClientPool)
|
|
|
{
|
|
|
_alipayCommon = new AlipayCommon();
|
|
@@ -99,14 +102,16 @@ namespace WingPaymentService.Service
|
|
|
if (orderInfo != null && orderInfo.OrderAmount > 0)
|
|
|
{
|
|
|
string recordCode = Guid.NewGuid().ToString("N");
|
|
|
- (string payUrl, string recordContent) payContent = (string.Empty,string.Empty);
|
|
|
+ (string payUrl, string recordContent) payContent = (string.Empty, string.Empty);
|
|
|
switch (request.PayType)
|
|
|
{
|
|
|
case PayTypeEnum.Alipay_PAGE:
|
|
|
- payContent = _alipayCommon.AlipayPagePay(orderInfo.OrderTitle, orderInfo.OrderAmount, orderInfo.Code, recordCode);
|
|
|
+ _recordRelation.AddOrUpdate(recordCode, request.OrderCode, (a,b)=> { return request.OrderCode; });
|
|
|
+ payContent = _alipayCommon.AlipayPagePay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode);
|
|
|
break;
|
|
|
case PayTypeEnum.Alipay_WAP:
|
|
|
- payContent = _alipayCommon.AlipayWapPay(orderInfo.OrderTitle, orderInfo.OrderAmount, orderInfo.Code, recordCode);
|
|
|
+ _recordRelation.AddOrUpdate(recordCode, request.OrderCode, (a,b)=> { return request.OrderCode; });
|
|
|
+ payContent = _alipayCommon.AlipayWapPay(orderInfo.OrderTitle, orderInfo.OrderAmount, recordCode);
|
|
|
break;
|
|
|
case PayTypeEnum.WeChat_PAGE:
|
|
|
payContent = await _weChatCommon.GetWebPayUrlAsync(orderInfo.OrderTitle, orderInfo.OrderAmount, orderInfo.Code, recordCode, string.Empty, string.Empty);
|
|
@@ -183,12 +188,12 @@ namespace WingPaymentService.Service
|
|
|
keyValuePairs.Add(key, value);
|
|
|
}
|
|
|
}
|
|
|
- var payOutTradeNo = keyValuePairs.GetValueOrDefault("out_trade_no");
|
|
|
+ var recordCode = keyValuePairs.GetValueOrDefault("out_trade_no");
|
|
|
+ _recordRelation.TryGetValue(recordCode, out string orderCode);
|
|
|
var totalAmount = keyValuePairs.GetValueOrDefault("total_amount");
|
|
|
- var payRecordCode = keyValuePairs.GetValueOrDefault("pay_record_code");
|
|
|
var payStatus = keyValuePairs.GetValueOrDefault("trade_status") == "TRADE_SUCCESS" ? WingInterfaceLibrary.Enum.PayStatusEnum.Paid : WingInterfaceLibrary.Enum.PayStatusEnum.NoPay;
|
|
|
var payTime = DateTime.UtcNow;
|
|
|
- return await PayRecordWriteRes(payOutTradeNo, payRecordCode, totalAmount, payStatus, payTime, request);
|
|
|
+ return await PayRecordWriteRes(orderCode, recordCode, totalAmount, payStatus, payTime, request);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|