|
|
@@ -67,9 +67,9 @@ func GetDistributedLockRequestId(prefix string) string { |
|
|
|
} |
|
|
|
|
|
|
|
// HandleDistributedLock 处理余额更新时获取锁和释放锁 如果加锁成功,使用语句 ` defer cb() ` 释放锁 |
|
|
|
func HandleDistributedLock(masterId, uid, requestIdPrefix string) (cb func(), err error) { |
|
|
|
func HandleDistributedLock(masterId, uid, coinId, requestIdPrefix string) (cb func(), err error) { |
|
|
|
// 获取余额更新锁 |
|
|
|
balanceLockKey := fmt.Sprintf(md.UserVirtualAmountUpdateLock, masterId, uid) |
|
|
|
balanceLockKey := fmt.Sprintf(md.UserVirtualAmountUpdateLock, masterId, uid, coinId) |
|
|
|
requestId := GetDistributedLockRequestId(requestIdPrefix) |
|
|
|
balanceLockOk := TryGetDistributedLock(balanceLockKey, requestId, true) |
|
|
|
if !balanceLockOk { |
|
|
|