package savingpot import ( "encoding/json" "bet24.com/log" "bet24.com/servers/common" ) func Run() { getManager() } func Dump(cmd, param1 string) { switch cmd { case "sys": getManager().dumpSys() case "user": getManager().dumpUser(param1) default: log.Debug("savingPot.Dump unhandled cmd %s", cmd) } } // 获取存钱罐 func GetBuyAmount(userId int, isOld bool) int { // 存钱罐信息 return getManager().getBuyAmount(userId, isOld) } // 获取存钱罐 func GetUserSavingPot(userId int) string { var ret struct { BuyAmount int // 存钱罐额度 Level int // 当前等级 IsMultiplyStatus int // 是否购买翻三倍 LeftTimeSec int // 限时购买剩余时间(S) AccumulateLimit int // 满额限制 BuyLimit int // 每天购买上限 BuyCount int // 已购买次数 } var retOld struct { BuyTimesLimit int // 购买次数上限 BuyTimes int // 已购买次数 AccumulateLimit int // 累计上限 } u := getManager().getUser(userId) if u.isOld { retOld.BuyTimesLimit = getManager().MaxCount retOld.BuyTimes = getManager().getUserBuyCount(userId) retOld.AccumulateLimit = 150000 buf, _ := json.Marshal(retOld) return string(buf) } // 获取用户存钱罐信息 info := getManager().getUserSavingPot(userId) ret.BuyAmount = info.BuyAmount ret.Level = info.CurrentLevel ret.IsMultiplyStatus = info.IsMultiplyStatus ret.LeftTimeSec = 0 if info.IsMultiplyStatus != 0 { sec := info.DuringTimeSec - common.GetDifferSec(info.UpdateTime) if sec < 0 { sec = 0 } ret.LeftTimeSec = sec } ret.AccumulateLimit = getManager().getConfigInfo(info.CurrentLevel).AccumulateLimit ret.BuyLimit = getManager().MaxCount ret.BuyCount = getManager().getUserBuyCount(userId) buf, _ := json.Marshal(ret) return string(buf) } func GetUserNewSavingPot(userId int) string { var ret struct { BuyAmount int // 存钱罐额度 Level int // 当前等级 IsMultiplyStatus int // 是否购买翻三倍 LeftTimeSec int // 限时购买剩余时间(S) AccumulateLimit int // 满额限制 BuyLimit int // 每天购买上限 BuyCount int // 已购买次数 } // 获取用户存钱罐信息 info := getManager().getUserSavingPot(userId) ret.BuyAmount = info.BuyAmount ret.Level = info.CurrentLevel ret.IsMultiplyStatus = info.IsMultiplyStatus ret.LeftTimeSec = 0 if info.IsMultiplyStatus != 0 { sec := info.DuringTimeSec - common.GetDifferSec(info.UpdateTime) if sec < 0 { sec = 0 } ret.LeftTimeSec = sec } ret.AccumulateLimit = getManager().getConfigInfo(info.CurrentLevel).AccumulateLimit ret.BuyLimit = getManager().MaxCount ret.BuyCount = getManager().getUserBuyCount(userId) buf, _ := json.Marshal(ret) return string(buf) } // 触发存钱罐 func TriggerSavingPot(userId, gameId, winAmount int) { getManager().addAccumulateAmount(userId, gameId, winAmount) return } // 存钱罐购买 func SavingPotBuy(userId int, isOld bool) bool { return getManager().buy(userId, isOld) } // 检查触发多倍领取 func CheckMultiplyReceive(userId int) { getManager().checkUserMultiplyReceive(userId) } func SetIsOldSavingPot(userId int) { getManager().setIsOldSavingPot(userId) }