dengbiao преди 4 месеца
родител
ревизия
3bb4f991c4
променени са 7 файла, в които са добавени 10 реда и са изтрити 10 реда
  1. +2
    -2
      md/app_redis_key.go
  2. +1
    -1
      rule/block_green_chain_settlement.go
  3. +1
    -1
      rule/integral_release_settlement.go
  4. +1
    -1
      rule/niu_bei_release_settlement.go
  5. +1
    -1
      rule/user_amount.go
  6. +2
    -2
      svc/svc_block_star_chain_settlement.go
  7. +2
    -2
      svc/svc_redis_mutex_lock.go

+ 2
- 2
md/app_redis_key.go Целия файл

@@ -7,8 +7,8 @@ const (
PlanRewardCfgCacheKey = "%s:plan_reward_cfg"
UnionSetCacheCfg = "%s:union_set_cfg:%s" // 联盟设置缓存key

UserFinValidUpdateLock = "%s:user_fin_valid_update_lock:%s" // 用户余额更新锁(能拿到锁才能更新余额)
UserVirtualAmountUpdateLock = "%s:user_virtual_amount_update_lock:%s" // 用户虚拟币更新锁(能拿到锁才能更新余额)
UserFinValidUpdateLock = "%s:user_fin_valid_update_lock:%s" // 用户余额更新锁(能拿到锁才能更新余额)
UserVirtualAmountUpdateLock = "%s:user_virtual_amount_update_lock:%s:%s" // 用户虚拟币更新锁(能拿到锁才能更新余额)

WithdrawApplyQueueListKey = "withdraw_apply_queue" // 提现队列



+ 1
- 1
rule/block_green_chain_settlement.go Целия файл

@@ -563,7 +563,7 @@ func DealUserCoinForGreen(session *xorm.Session, req md.DealUserCoinReq) (err er
}
//1、分布式锁阻拦
requestIdPrefix := fmt.Sprintf(md.DealUserCoinForGreenRequestIdPrefix, req.Mid, req.CoinId, req.Uid)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix, strconv.Itoa(req.CoinId))
if err != nil {
return err
}


+ 1
- 1
rule/integral_release_settlement.go Целия файл

@@ -352,7 +352,7 @@ func DealUserCoinForIntegralRelease(session *xorm.Session, req md.DealUserCoinRe
}
//1、分布式锁阻拦
requestIdPrefix := fmt.Sprintf(DealUserCoinForIntegralReleaseRequestIdPrefix, req.Mid, req.CoinId, req.Uid)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix, strconv.Itoa(req.CoinId))
if err != nil {
return err
}


+ 1
- 1
rule/niu_bei_release_settlement.go Целия файл

@@ -365,7 +365,7 @@ func DealUserCoinForNiuBeiRelease(session *xorm.Session, req md.DealUserCoinReq)
}
//1、分布式锁阻拦
requestIdPrefix := fmt.Sprintf(DealUserCoinForIntegralReleaseRequestIdPrefix, req.Mid, req.CoinId, req.Uid)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix, strconv.Itoa(req.CoinId))
if err != nil {
return err
}


+ 1
- 1
rule/user_amount.go Целия файл

@@ -21,7 +21,7 @@ func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) {
}
//1、分布式锁阻拦
requestIdPrefix := fmt.Sprintf(md.DealUserCoinRequestIdPrefix, req.Mid, req.CoinId, req.Uid)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix, strconv.Itoa(req.CoinId))
if err != nil {
return err
}


+ 2
- 2
svc/svc_block_star_chain_settlement.go Целия файл

@@ -48,8 +48,8 @@ func SetCacheUserVirtualAmount(session *xorm.Session, masterId, amount string, c
}
}
//_, err := cache.Set(redisKey, int64(utils.StrToFloat64(amount)))
//TODO::默认缓存1小时 (先调整为 2 min)
_, err := cache.SetEx(redisKey, zhios_order_relate_utils.StrToFloat64(amount), 60*2)
//TODO::默认缓存1小时 (先调整为 20 min)
_, err := cache.SetEx(redisKey, zhios_order_relate_utils.StrToFloat64(amount), 60*20)
if err != nil {
return err
}


+ 2
- 2
svc/svc_redis_mutex_lock.go Целия файл

@@ -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 {


Зареждане…
Отказ
Запис