mirror of
https://github.com/CoreUnion/CoreShop.git
synced 2026-10-17 05:12:39 +08:00
领取优惠券开启事务,并在查询优惠券信息时加update锁解决并发领优惠券产生超买问题。
修复优惠券领取数量设置为0时,没有返回错误
This commit is contained in:
@@ -331,12 +331,16 @@ namespace CoreCms.Net.Repository
|
||||
/// </summary>
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
||||
/// <param name="blUseTranLock">是否使用事务锁</param>
|
||||
/// <param name="dbLockType">事务锁类型</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false)
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false,bool blUseTranLock = false,
|
||||
DbLockType dbLockType = DbLockType.Wait)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().With(SqlWith.NoLock).FirstAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().FirstAsync(predicate);
|
||||
: (blUseTranLock? await DbBaseClient.Queryable<T>().TranLock(dbLockType).FirstAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().FirstAsync(predicate));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user