``feat(item): 新增物品出售价格属性(SellPrice)并实现物品出售功能,优化宠物面板计算和时区判断逻辑``
This commit is contained in:
@@ -39,12 +39,7 @@ func (s *InfoService) Reg(nick string, color uint32) {
|
||||
//设置用户信息
|
||||
t.Data = model.NewPlayerInfo()
|
||||
t.Data.Nick = nick
|
||||
|
||||
// for i := 0; i < 80; i++ { //超NO芯片填充
|
||||
|
||||
// t.Data.NonoChipList[i] = 255
|
||||
// }
|
||||
|
||||
t.Data.UserID = s.userid
|
||||
t.Data.Color = color
|
||||
t.Data.RegisterTime = uint32(time.Now().Unix()) //写入注册时间
|
||||
|
||||
@@ -76,6 +71,8 @@ func (s *InfoService) Personself() *model.PlayerInfo {
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
tt.Data.AllPetNumber = uint32(NewPetService(s.userid).PetCount(0))
|
||||
|
||||
if !IsToday(tt.LastResetTime) { //判断是否是今天
|
||||
|
||||
//每天login时候检查重置时间,然后把电池,任务,挖矿重置
|
||||
|
||||
@@ -25,6 +25,17 @@ func (s *PetService) PetInfo(flag int) []model.PetEX {
|
||||
|
||||
return tt
|
||||
|
||||
}
|
||||
func (s *PetService) PetCount(flag int) int {
|
||||
|
||||
ret, err := cool.DBM(s.Model).Where("player_id", s.userid).Where("free", flag).Count()
|
||||
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
func (s *PetService) PetInfo_One_exec(cachetime uint32, t func(*model.PetEX)) {
|
||||
|
||||
@@ -59,15 +59,14 @@ func IsToday(t1 *gtime.Time) bool {
|
||||
if t1 == nil {
|
||||
return false
|
||||
}
|
||||
t := t1.Time
|
||||
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
// 统一转换为 UTC 时区
|
||||
tUTC := t1.Time.UTC()
|
||||
// 截断 UTC 时间到当天 00:00:00
|
||||
nowUTC := time.Now().UTC().Truncate(24 * time.Hour)
|
||||
tTrunc := tUTC.Truncate(24 * time.Hour)
|
||||
|
||||
// 比较年、月、日是否相同
|
||||
return t.Year() == now.Year() &&
|
||||
t.Month() == now.Month() &&
|
||||
t.Day() == now.Day()
|
||||
return nowUTC.Equal(tTrunc)
|
||||
}
|
||||
|
||||
type TaskService struct {
|
||||
|
||||
Reference in New Issue
Block a user