1
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
昔念
2026-04-21 01:56:06 +08:00
parent dcbd9950d3
commit 808da76bd0
2 changed files with 132 additions and 25 deletions

View File

@@ -2,14 +2,10 @@ package admin
import (
"blazing/cool"
base "blazing/modules/base/service"
"blazing/modules/player/service"
"context"
"fmt"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
type GoldListController struct {
@@ -38,23 +34,10 @@ type DuihuanGoldAddReq struct {
func (c *GoldListController) DuihuanGold(ctx context.Context, req *DuihuanGoldAddReq) (res *cool.BaseRes, err error) {
t := cool.GetAdmin(ctx)
r, err := service.NewGoldListService(0).Done(req.ID)
_, err = service.NewGoldListService(0).Trade(ctx, req.ID, t.UserId)
if err != nil {
return
}
costfree := r.Rate * float64(r.ExchangeNum)
if base.NewBaseSysUserService().GetFreeGold(t.UserId) < int64(costfree*100) {
err = fmt.Errorf("余额不足")
return
}
if !r.UpdateTime.Add(1 * time.Hour).Before(gtime.Now()) {
err = fmt.Errorf("未到购买时间")
return
}
base.NewBaseSysUserService().DuihuanFreeGold(uint32(r.PlayerID), int64(r.ExchangeNum*100), int64(costfree*95))
base.NewBaseSysUserService().DuihuanGold(uint32(t.UserId), int64(r.ExchangeNum*95), int64(costfree*100))
res = cool.Ok(nil)
return
}