feat: 新增金豆挂单管理模块及优化购买提示
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
44
modules/player/service/gold_list.go
Normal file
44
modules/player/service/gold_list.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type GoldListService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func (s *GoldListService) ModifyBefore(ctx context.Context, method string, param map[string]interface{}) (err error) {
|
||||
admin := cool.GetAdmin(ctx)
|
||||
userId := admin.UserId
|
||||
s.userid = uint32(userId)
|
||||
|
||||
if method == "Add" {
|
||||
t, _ := s.dbm_fix(s.Model).Count()
|
||||
if t > 0 {
|
||||
return fmt.Errorf("不允许多挂单")
|
||||
}
|
||||
} else {
|
||||
if userId != gconv.Uint(param["player_id"]) {
|
||||
err = fmt.Errorf("修改失败")
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func NewGoldListService(id uint32) *GoldListService {
|
||||
return &GoldListService{
|
||||
|
||||
BaseService: BaseService{userid: id,
|
||||
|
||||
Service: &cool.Service{Model: model.NewGoldBeanOrder()},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func (s *PetService) BuyPet(pid uint32) error {
|
||||
return fmt.Errorf("未设置价格")
|
||||
}
|
||||
if !tt.UpdateTime.AddDate(0, 0, 1).Before(gtime.Now()) {
|
||||
return fmt.Errorf("数据异常")
|
||||
return fmt.Errorf("未到购买时间")
|
||||
}
|
||||
return g.DB().Transaction(context.TODO(), func(ctx context.Context, tx gdb.TX) error {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user