|
|
|
|
@ -24,14 +24,14 @@ func LuckyWheelCfg(c *gin.Context) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
uid := a.UID |
|
|
|
|
|
|
|
|
|
if !db.Redis().Lock(common.GetRedisKeyLuckyWheel(uid)) { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
defer func() { |
|
|
|
|
db.Redis().UnLock(common.GetRedisKeyLuckyWheel(uid)) |
|
|
|
|
}() |
|
|
|
|
call.CheckLuckyWheel(uid, true) |
|
|
|
|
//if !db.Redis().Lock(common.GetRedisKeyLuckyWheel(uid)) {
|
|
|
|
|
// a.Code = values.CodeRetry
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//defer func() {
|
|
|
|
|
// db.Redis().UnLock(common.GetRedisKeyLuckyWheel(uid))
|
|
|
|
|
//}()
|
|
|
|
|
|
|
|
|
|
resp := &values.LuckyWheelCfgResp{} |
|
|
|
|
a.Data = resp |
|
|
|
|
@ -44,9 +44,9 @@ func LuckyWheelCfg(c *gin.Context) { |
|
|
|
|
if rechargeInfo.TotalRechargeCount < int64(luckyWheel.RechargeCount) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
var ( |
|
|
|
|
update bool |
|
|
|
|
) |
|
|
|
|
//var (
|
|
|
|
|
// update bool
|
|
|
|
|
//)
|
|
|
|
|
for _, wheelCfg := range luckyWheel.WheelCfgStr { |
|
|
|
|
//if wheelCfg.LuckyType == 4 &&
|
|
|
|
|
// rechargeInfo.TotalRecharge < int64(wheelCfg.RechargeAmount[0]*common.DecimalDigits) { // 特殊转盘达到了才能看见
|
|
|
|
|
@ -57,35 +57,35 @@ func LuckyWheelCfg(c *gin.Context) { |
|
|
|
|
if rechargeAmount == 0 { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
freeKey := fmt.Sprintf("f%d_%d", wheelCfg.LuckyType, rechargeAmount) |
|
|
|
|
if rechargeInfo.TotalRecharge >= int64(rechargeAmount)*common.DecimalDigits && |
|
|
|
|
playerData.LuckyWheelMap[freeKey] == 0 { |
|
|
|
|
playerData.LuckyWheelMap[freeKey] = 1 |
|
|
|
|
playerData.LuckyWheelMap[lessKey] += 1 |
|
|
|
|
update = true |
|
|
|
|
} |
|
|
|
|
//freeKey := fmt.Sprintf("f%d_%d", wheelCfg.LuckyType, rechargeAmount)
|
|
|
|
|
//if rechargeInfo.TotalRecharge >= int64(rechargeAmount)*common.DecimalDigits &&
|
|
|
|
|
// playerData.LuckyWheelMap[freeKey] == 0 {
|
|
|
|
|
// playerData.LuckyWheelMap[freeKey] = 1
|
|
|
|
|
// playerData.LuckyWheelMap[lessKey] += 1
|
|
|
|
|
// update = true
|
|
|
|
|
//}
|
|
|
|
|
} |
|
|
|
|
resp.LuckyWheel = append(resp.LuckyWheel, values.LuckyWheel{ |
|
|
|
|
LuckyWheel: wheelCfg, |
|
|
|
|
LessDrawCount: playerData.LuckyWheelMap[lessKey], |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if update { |
|
|
|
|
luckyWheelBytes, err := json.Marshal(playerData.LuckyWheelMap) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("marshal err, %s", err.Error()) |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
err = db.Mysql().C().Model(&common.PlayerData{}).Where("uid = ?", uid).Updates(map[string]interface{}{ |
|
|
|
|
"lucky_wheel": string(luckyWheelBytes), |
|
|
|
|
}).Error |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("update err, %s", err.Error()) |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//if update {
|
|
|
|
|
// luckyWheelBytes, err := json.Marshal(playerData.LuckyWheelMap)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// log.Error("marshal err, %s", err.Error())
|
|
|
|
|
// a.Code = values.CodeRetry
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
// err = db.Mysql().C().Model(&common.PlayerData{}).Where("uid = ?", uid).Updates(map[string]interface{}{
|
|
|
|
|
// "lucky_wheel": string(luckyWheelBytes),
|
|
|
|
|
// }).Error
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// log.Error("update err, %s", err.Error())
|
|
|
|
|
// a.Code = values.CodeRetry
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
a.Data = resp |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|