This commit is contained in:
cdle 2021-08-23 10:46:39 +08:00
parent fa1fcc133d
commit 6bad0159ba
2 changed files with 6 additions and 5 deletions

View File

@ -197,7 +197,7 @@ var handleMessage = func(msgs ...interface{}) interface{} {
ck.Telegram = uid
}
if HasKey(ck.PtKey) {
sendMessagee(fmt.Sprintf("作弊,许愿币-1余额%d", RemCoin(uid)), msgs...)
sendMessagee(fmt.Sprintf("作弊,许愿币-1余额%d", RemCoin(uid, 1)), msgs...)
} else {
if nck, err := GetJdCookie(ck.PtPin); err == nil {
nck.InPool(ck.PtKey)
@ -215,7 +215,7 @@ var handleMessage = func(msgs ...interface{}) interface{} {
}
}
} else {
sendMessagee(fmt.Sprintf("无效,许愿币-1余额%d", RemCoin(uid)), msgs...)
sendMessagee(fmt.Sprintf("无效,许愿币-1余额%d", RemCoin(uid, 1)), msgs...)
}
}
go func() {
@ -277,7 +277,8 @@ var handleMessage = func(msgs ...interface{}) interface{} {
return "许愿币不足需要5个许愿币。"
} else {
(&JdCookie{}).Push(fmt.Sprintf("%d许愿%s许愿币余额%d。", uid, v, b))
return "收到许愿愿望达成后会自动扣除5个许愿币。"
RemCoin(uid, 5)
return "收到许愿已扣除5个许愿币。"
}
case "扣除许愿币":
id, _ := strconv.Atoi(v)

View File

@ -89,11 +89,11 @@ func AddCoin(uid int) int {
return u.Coin
}
func RemCoin(uid int) int {
func RemCoin(uid int, num int) int {
var u User
db.Where("number = ?", uid).First(&u)
db.Model(u).Updates(map[string]interface{}{
"coin": gorm.Expr("coin-1"),
"coin": gorm.Expr(fmt.Sprintf("coin-%d", num)),
})
u.Coin--
return u.Coin