refactor: 重构物品更新逻辑并添加ID为0的检查
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:
@@ -32,30 +32,27 @@ func (s *ItemService) UPDATE(id uint32, count int) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if id == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m := s.dbm(s.Model)
|
||||||
|
|
||||||
var ttt model.Item
|
if t, _ := m.Where("item_id", id).Exist(); t {
|
||||||
s.dbm(s.Model).Scan(&ttt)
|
_, err := s.dbm(s.Model).Where("item_id", id).Increment("item_cnt", count)
|
||||||
ttt.PlayerID = uint64(s.userid)
|
if err != nil {
|
||||||
ttt.ItemId = id
|
panic(err)
|
||||||
ttt.IsVip = cool.Config.ServerInfo.IsVip
|
}
|
||||||
ttt.ItemCnt += int64(count)
|
} else {
|
||||||
s.dbm(s.Model).Save(ttt)
|
m := s.dbm(s.Model)
|
||||||
// if t, _ := m.Where("item_id", id).Exist(); t {
|
data := g.Map{
|
||||||
// _, err := s.dbm(s.Model).Where("item_id", id).Increment("item_cnt", count)
|
"player_id": s.userid,
|
||||||
// if err != nil {
|
"item_id": id,
|
||||||
// panic(err)
|
"item_cnt": count,
|
||||||
// }
|
"is_vip": cool.Config.ServerInfo.IsVip,
|
||||||
// } else {
|
}
|
||||||
// m := s.dbm(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()
|
m.Data(data).Insert()
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user