【优化】用户支付api增加redis锁,防止出现多次点击可能存在二次支付的问题。

This commit is contained in:
大灰灰
2022-10-15 00:04:59 +08:00
parent 1ebbe31894
commit 481dbe3ce5
2 changed files with 41 additions and 19 deletions

View File

@@ -67,11 +67,9 @@ namespace CoreCms.Net.Services
{
try
{
_unitOfWork.BeginTran();
//取用户实际余额
//(会员陌小北提供)
var userInfo = await userServices.QueryByClauseWithTranLockAsync(p => p.id == userId, p => p.id, OrderByType.Desc, true);
var userInfo = await userServices.QueryByClauseAsync(p => p.id == userId, p => p.id, OrderByType.Desc, true);
if (userInfo == null)
{
@@ -90,7 +88,6 @@ namespace CoreCms.Net.Services
if (type != (int)GlobalEnumVars.UserBalanceSourceTypes.Admin)
{
//后台充值或调不改绝对值
}
//如果是减余额的操作,还是加余额操作
if (type is (int)GlobalEnumVars.UserBalanceSourceTypes.Pay or (int)GlobalEnumVars.UserBalanceSourceTypes.Tocash)
@@ -117,6 +114,9 @@ namespace CoreCms.Net.Services
balanceModel.sourceId = sourceId;
balanceModel.memo = memo;
balanceModel.createTime = DateTime.Now;
_unitOfWork.BeginTran();
//增加记录
var balanceModelId = await _dal.InsertAsync(balanceModel);
balanceModel.id = balanceModelId;