```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

fix(player): 修复金币兑换计算逻辑错误

移除未使用的getgold变量计算,修正兑换金币数量计算公式,
避免因变量未定义导致的潜在运行时错误,确保兑换功能正常工作。
```
This commit is contained in:
昔念
2026-03-19 19:01:23 +08:00
parent bd5cd9393a
commit 8929a17c97

View File

@@ -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
}