fix(player): 修复金币兑换计算逻辑错误 移除未使用的getgold变量计算,修正兑换金币数量计算公式, 避免因变量未定义导致的潜在运行时错误,确保兑换功能正常工作。 ```
This commit is contained in:
@@ -44,7 +44,7 @@ func (c *GoldListController) DuihuanGold(ctx context.Context, req *DuihuanGoldAd
|
||||
}
|
||||
|
||||
costfree := r.Rate * float64(r.ExchangeNum)
|
||||
getgold := 1 / r.Rate * float64(r.ExchangeNum)
|
||||
|
||||
if base.NewBaseSysUserService().GetFreeGold(t.UserId) < int64(costfree*100) {
|
||||
err = fmt.Errorf("余额不足")
|
||||
return
|
||||
@@ -54,7 +54,7 @@ func (c *GoldListController) DuihuanGold(ctx context.Context, req *DuihuanGoldAd
|
||||
return
|
||||
}
|
||||
base.NewBaseSysUserService().DuihuanFreeGold(uint32(r.PlayerID), int64(r.ExchangeNum*100), int64(costfree*95))
|
||||
base.NewBaseSysUserService().DuihuanGold(uint32(t.UserId), int64(getgold*95), int64(costfree*100))
|
||||
base.NewBaseSysUserService().DuihuanGold(uint32(t.UserId), int64(r.ExchangeNum*95), int64(costfree*100))
|
||||
res = cool.Ok(nil)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user