2025-08-31 00:27:07 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/modules/blazing/model"
|
2025-11-02 18:56:16 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
2025-08-31 00:27:07 +08:00
|
|
|
)
|
|
|
|
|
|
2025-11-02 18:56:16 +08:00
|
|
|
func (s *UserService) Item(min, max uint32) []model.Item {
|
2025-09-11 01:07:00 +08:00
|
|
|
|
|
|
|
|
//todo待测试
|
2025-11-02 18:56:16 +08:00
|
|
|
var ttt []model.Item
|
|
|
|
|
s.Model(s.item.Model).Where(g.Map{
|
|
|
|
|
"item_id <=": max,
|
|
|
|
|
"item_id >=": min,
|
|
|
|
|
}).Scan(&ttt)
|
2025-09-11 01:07:00 +08:00
|
|
|
|
2025-11-02 18:56:16 +08:00
|
|
|
return ttt
|
2025-09-11 01:07:00 +08:00
|
|
|
|
2025-11-02 18:56:16 +08:00
|
|
|
}
|
|
|
|
|
func (s *UserService) AddItem(id, count uint32) {
|
|
|
|
|
if t, _ := s.Model(s.item.Model).Where("item_id", id).Count(); t != 0 {
|
|
|
|
|
s.Model(s.item.Model).Where("item_id", id).Increment("item_cnt", count)
|
|
|
|
|
} else {
|
|
|
|
|
s.Model(s.item.Model).Data(g.Map{
|
|
|
|
|
"player_id": s.userid,
|
|
|
|
|
"item_id": id,
|
|
|
|
|
"item_cnt": count,
|
|
|
|
|
}).Insert()
|
2025-09-11 01:07:00 +08:00
|
|
|
}
|
2025-11-02 18:56:16 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
func (s *UserService) SubItem(id, count uint32) {
|
|
|
|
|
|
|
|
|
|
s.Model(s.item.Model).Where("item_id", id).Decrement("item_cnt", count)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
func (s *UserService) CheakItem(id uint32) uint32 {
|
|
|
|
|
var ttt model.Item
|
|
|
|
|
s.Model(s.item.Model).Where("item_id", id).Scan(&ttt)
|
|
|
|
|
return ttt.ItemCnt
|
2025-09-23 15:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-25 15:06:05 +08:00
|
|
|
// /添加进来的物品一定是保证存在的
|