印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

1 year ago
package call
import (
"fmt"
"server/common"
"server/db"
"server/util"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
)
func UpdateJackpot(t, tid int, amount int64) {
if err := db.Mysql().C().Exec(fmt.Sprintf("call jackpot(%v,%v,%v)", t, tid, amount)).Error; err != nil {
log.Error("err:%v", err)
}
}
func GetJackpot(t, tid int) int64 {
data := &common.Jackpot{Type: t, TypeID: tid}
db.Mysql().Get(data)
return data.Amount
}
func GetJack(t, tid int) *common.Jackpot {
data := &common.Jackpot{Type: t, TypeID: tid}
db.Mysql().Get(data)
return data
}
func UpdateGameJackpot(t, tid int, amount, playerAmount int64) {
jack := GetJack(t, tid)
u := map[string]interface{}{"player_amount": gorm.Expr("player_amount + ?", playerAmount)}
if jack.Amount+amount >= jack.Max {
u["amnout"] = jack.Max
} else {
u["amount"] = gorm.Expr("amount + ?", amount)
}
db.Mysql().Update(&common.Jackpot{Type: t, TypeID: tid}, u)
}
func UpdateGameSort(provider, gameID int) {
util.Go(func() {
db.Mysql().Update(&common.ConfigGameList{GameProvider: provider, GameID: gameID}, map[string]interface{}{"sort": gorm.Expr("sort + 1")})
})
}