This commit is contained in:
@@ -20,11 +20,13 @@ using System.Linq;
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
|
|
||||||
namespace Hncore.Pass.BaseInfo.Service
|
namespace Hncore.Pass.BaseInfo.Service
|
||||||
{
|
{
|
||||||
public class UserService : ServiceBase<User>, IFindService
|
public class UserService : ServiceBase<User>, IFindService
|
||||||
{
|
{
|
||||||
|
private static readonly AsyncLock _mutex1 = new AsyncLock();
|
||||||
private static string _secret = "hncore_yh_lzh_20f_2020_READY";
|
private static string _secret = "hncore_yh_lzh_20f_2020_READY";
|
||||||
|
|
||||||
private UserDbContext _dbContext;
|
private UserDbContext _dbContext;
|
||||||
@@ -246,6 +248,8 @@ namespace Hncore.Pass.BaseInfo.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResult> UpdateAmount(UpdateAmountRequest request)
|
public async Task<ApiResult> UpdateAmount(UpdateAmountRequest request)
|
||||||
|
{
|
||||||
|
using (await _mutex1.LockAsync())
|
||||||
{
|
{
|
||||||
var entity = await this.GetById(request.UserId);
|
var entity = await this.GetById(request.UserId);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
@@ -254,6 +258,7 @@ namespace Hncore.Pass.BaseInfo.Service
|
|||||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "金额必须大于0");
|
return new ApiResult(ResultCode.C_INVALID_ERROR, "金额必须大于0");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var userScore = new UserScore()
|
var userScore = new UserScore()
|
||||||
{
|
{
|
||||||
UserId = request.UserId,
|
UserId = request.UserId,
|
||||||
@@ -299,6 +304,8 @@ namespace Hncore.Pass.BaseInfo.Service
|
|||||||
return new ApiResult(ResultCode.C_INVALID_ERROR);
|
return new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> RandomAssignManager(int userId)
|
public async Task<bool> RandomAssignManager(int userId)
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ using Hncore.Pass.BaseInfo.Request.User;
|
|||||||
using Hncore.Pass.BaseInfo.Models;
|
using Hncore.Pass.BaseInfo.Models;
|
||||||
using ScoreType = Hncore.Pass.BaseInfo.Models.ScoreType;
|
using ScoreType = Hncore.Pass.BaseInfo.Models.ScoreType;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
|
|
||||||
namespace Hncore.Pass.Vpn.Service
|
namespace Hncore.Pass.Vpn.Service
|
||||||
{
|
{
|
||||||
public partial class ProductOrderService : ServiceBase<ProductOrderEntity>, IFindService
|
public partial class ProductOrderService : ServiceBase<ProductOrderEntity>, IFindService
|
||||||
{
|
{
|
||||||
|
private static readonly AsyncLock _mutex1 = new AsyncLock();
|
||||||
CourseContext m_DbContext;
|
CourseContext m_DbContext;
|
||||||
ProductService m_ProductService;
|
ProductService m_ProductService;
|
||||||
ProductPackageService m_ProductPackageService;
|
ProductPackageService m_ProductPackageService;
|
||||||
@@ -269,6 +271,7 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
|||||||
await CheckRequest(order);
|
await CheckRequest(order);
|
||||||
|
|
||||||
var ret = await CaclePaymentAmount(order, request.UseAccountAmount);
|
var ret = await CaclePaymentAmount(order, request.UseAccountAmount);
|
||||||
|
|
||||||
if (ret.Code != ResultCode.C_SUCCESS) return ret;
|
if (ret.Code != ResultCode.C_SUCCESS) return ret;
|
||||||
using (var tran = await m_DbContext.Database.BeginTransactionAsync())
|
using (var tran = await m_DbContext.Database.BeginTransactionAsync())
|
||||||
{
|
{
|
||||||
@@ -291,6 +294,8 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResult<ProductOrderEntity>> CaclePaymentAmount(ProductOrderEntity order, int useAccountAmount)
|
public async Task<ApiResult<ProductOrderEntity>> CaclePaymentAmount(ProductOrderEntity order, int useAccountAmount)
|
||||||
|
{
|
||||||
|
using (await _mutex1.LockAsync())
|
||||||
{
|
{
|
||||||
var userEntity = await m_UserService.GetById(order.UserId);
|
var userEntity = await m_UserService.GetById(order.UserId);
|
||||||
//使用优惠券
|
//使用优惠券
|
||||||
@@ -324,6 +329,7 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
order.OtherPayAmount = order.PaymentAmount - order.AccountPayAmount;
|
order.OtherPayAmount = order.PaymentAmount - order.AccountPayAmount;
|
||||||
|
}
|
||||||
return new ApiResult<ProductOrderEntity>(order);
|
return new ApiResult<ProductOrderEntity>(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +346,11 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
|||||||
AttchInfo = order.OrderNo,
|
AttchInfo = order.OrderNo,
|
||||||
OperateUserName = order.UserName,
|
OperateUserName = order.UserName,
|
||||||
};
|
};
|
||||||
await m_BaseUserService.UpdateAmount(amountInfo);
|
var ret = await m_BaseUserService.UpdateAmount(amountInfo);
|
||||||
|
if (ret.Code != ResultCode.C_SUCCESS)
|
||||||
|
{
|
||||||
|
order.OtherPayAmount = order.PaymentAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//全是余额支付
|
//全是余额支付
|
||||||
if (order.OtherPayAmount == 0)
|
if (order.OtherPayAmount == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user