印度包网
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.

93 lines
2.2 KiB

1 year ago
package guser
import (
"fmt"
"gorm.io/gorm"
1 year ago
"server/call"
"server/common"
"server/db"
1 year ago
"server/modules/backend/app"
"server/modules/backend/values"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
)
// 修改玩家金币
func EditGameUserGold(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.EditGameUserGoldReq)
if !a.S(req) {
return
}
user, _ := call.GetUserXInfo(req.UID, "channel_id")
update := &common.UpdateCurrency{
CurrencyBalance: &common.CurrencyBalance{
UID: req.UID,
Type: req.CurrencyType,
Value: req.Amount,
Event: common.CurrencyEventGM,
ChannelID: user.ChannelID,
Exs1: "后台操作修改玩家金币",
},
}
err := call.MineCurrencyProReal(update).Err
if err != nil {
log.Error("err:%v", err)
a.Code = values.CodeRetry
return
}
a.RecordEdit(values.PowerGUser, fmt.Sprintf("修改玩家%v金币:%v", req.UID, req.Amount))
}
func EditGameUserBet(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.EditGameUserBetReq)
if !a.S(req) {
return
}
err := db.Mysql().C().Model(&common.PlayerProfile{}).Where("uid = ?", req.UID).Updates(map[string]interface{}{
"need_bet": gorm.Expr("CASE WHEN need_bet + ? < 0 THEN 0 ELSE need_bet + ? END", req.BetAmount, req.BetAmount),
}).Error
if err != nil {
log.Error("err: %s", err.Error())
a.Code = values.CodeRetry
return
}
log.Debug("修改玩家打码量,user:%s uid:%d betAmount:%d", a.User.Name, req.UID, req.BetAmount)
a.RecordEdit(values.PowerGUser, fmt.Sprintf("修改玩家%v打码量:%v", req.UID, req.BetAmount))
}
func EditGameUserRtp(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.EditGameUserRtpReq)
if !a.S(req) {
return
}
rtpData := &common.PlayerRtpData{Uid: req.UID}
db.Mysql().Get(rtpData)
if rtpData.Id == 0 {
rtpData.Rtp = req.Val
db.Mysql().Create(rtpData)
} else {
err := db.Mysql().Update(&common.PlayerRtpData{Uid: req.UID}, map[string]interface{}{
"rtp": req.Val,
})
if err != nil {
a.Code = values.CodeRetry
a.Msg = "modify rtp error"
}
}
a.RecordEdit(values.PowerGUser, fmt.Sprintf("修改玩家%vRtp:%v", req.UID, req.Val))
}