Files
bl/modules/blazing/service/item.go
昔念 4cd34f5009 ```
feat(config): 更新服务器配置字段注释并修复VIP标识逻辑

- 修改config.go中IsVip字段注释,明确其表示测试服状态
- 添加isdebug字段注释说明本地服标识
- 从.gitignore添加login-login-linux-amd64到忽略列表
- 移除已废弃的coolconfig.SetTest函数

fix(item_buy): 注释掉金币购买功能代码

- 将BuyGoldItem方法注释掉,暂时禁用金币购买商品功能
- 移除未使用的gconv导入包

fix(server): 修正调试模式判断条件

- 将server.go中的IsVip判断改为IsDebug,确保调试模式正确启用

refactor(item_service): 优化模型调用并添加VIP标识

- 修复ItemService.UPDATE方法中模型调用的一致性问题
- 添加is_vip字段到数据记录中用于区分服务器类型

feat(pet_service): 为宠物数据添加VIP标识

- 在宠物服务中为新捕捉的宠物添加IsVip字段设置

```
2026-01-10 02:01:17 +08:00

86 lines
1.7 KiB
Go

package service
import (
"blazing/cool"
"blazing/modules/blazing/model"
"context"
"github.com/gogf/gf/v2/frame/g"
)
func (s *ItemService) Get(min, max uint32) []model.Item {
m := s.TestModel(s.Model).Where(g.Map{
"item_id <=": max,
"item_id >=": min,
})
var ttt []model.Item
m.Scan(&ttt)
return ttt
}
func (s *ItemService) UPDATE(id uint32, count int) {
if cool.Config.ServerInfo.IsVip != 0 && count < 0 {
cool.Logger.Info(context.TODO(), "测试服不消耗物品玩家数据", s.userid)
return
}
m := s.TestModel(s.Model)
if t, _ := m.Where("item_id", id).Exist(); t {
_, err := s.TestModel(s.Model).Where("item_id", id).Increment("item_cnt", count)
if err != nil {
panic(err)
}
} else {
m := s.TestModel(s.Model)
data := g.Map{
"player_id": s.userid,
"item_id": id,
"item_cnt": count,
"is_vip": cool.Config.ServerInfo.IsVip,
}
m.Data(data).Insert()
}
}
func (s *ItemService) CheakItem(id uint32) uint32 {
var ttt model.Item
m := s.TestModel(s.Model)
m.Where("item_id", id).Scan(&ttt)
return ttt.ItemCnt
}
// /添加进来的物品一定是保证存在的
type ItemService struct {
BaseService
}
func NewItemService(id uint32) *ItemService {
return &ItemService{
BaseService: BaseService{userid: id,
Service: &cool.Service{Model: model.NewPlayerBag(), UniqueKey: map[string]string{
"player_id": "角色名称不能重复",
}, PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"player_id"},
Where: func(ctx context.Context) [][]interface{} {
var (
//admin = cool.GetAdmin(ctx)
//userId = admin.UserId
)
return [][]interface{}{
// {"player_id", userId, true},
// {"free", 0, true},
}
},
}},
},
}
}