game/common/model/jackpot/jackpot.go
2025-06-09 23:52:18 +08:00

55 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package jackpot
import (
"context"
"fmt"
"github.com/go-redis/redis/v8"
"strconv"
)
func JackpotSet(rdb *redis.Client, gameId int, chips int64) {
key := fmt.Sprintf("Jackpot:%d", gameId)
_, _ = rdb.Set(context.Background(), key, chips, 0).Result()
}
func JackpotAdd(rdb *redis.Client, gameId int, chips int64) int64 {
key := fmt.Sprintf("Jackpot:%d", gameId)
v, _ := rdb.IncrBy(context.Background(), key, chips).Result()
return v
}
func JackpotGet(rdb *redis.Client, gameId int) int64 {
key := fmt.Sprintf("Jackpot:%d", gameId)
jp := rdb.Get(context.Background(), key).Val()
result, _ := strconv.ParseInt(jp, 10, 64)
return result
}
// jp系统池玩家部分利润进入该池重置jackpot池时从这里扣除。系统池反映系统盈亏
func JackpotSystemAdd(rdb *redis.Client, gameId int, chips int64) int64 {
key := fmt.Sprintf("JackpotSystem:%d", gameId)
value, _ := rdb.IncrBy(context.Background(), key, chips).Result()
return value
}
func JackpotSystemGet(rdb *redis.Client, gameId int) int64 {
key := fmt.Sprintf("JackpotSystem:%d", gameId)
jp := rdb.Get(context.Background(), key).Val()
result, _ := strconv.ParseInt(jp, 10, 64)
return result
}
// 玩家总赎回
func JackpotUserRepaidAdd(rdb *redis.Client, gameId int, chips int64) int64 {
key := fmt.Sprintf("JackpotUserRepaid:%d", gameId)
value, _ := rdb.IncrBy(context.Background(), key, chips).Result()
return value
}
// jp池重置次数
func JackpotInitCountAdd(rdb *redis.Client, gameId int) int64 {
key := fmt.Sprintf("JackpotInitCount:%d", gameId)
count, _ := rdb.IncrBy(context.Background(), key, 1).Result()
return count
}