This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type GoldService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 月 周 日限购检查
|
||||
func (s *GoldService) Cheak(allcount, pid, ptye uint32) bool {
|
||||
|
||||
now := time.Now()
|
||||
var va int
|
||||
switch ptye {
|
||||
case 0: //月限购
|
||||
va = int(now.Month())
|
||||
case 1: //周限购
|
||||
_, va = now.ISOWeek()
|
||||
case 2: //日限购
|
||||
va = now.Day()
|
||||
|
||||
}
|
||||
ret, err := s.dbm_fix(s.Model).WhereNotBetween("updateTime",gtime.Now().EndOfDay()).Where("year", now.Year()).Where("biz_id", pid).Wheref("consume ->> ?::integer = ?", ptye, va).Count()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if uint32(ret) < allcount {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
func (s *GoldService) Log(pid, count uint32) {
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
// 提取年份
|
||||
year := uint32(now.Year())
|
||||
// 构造消费时间数组 [月, 周, 日]
|
||||
// ISOWeek返回(年,周数),这里只取周数;Day()返回当月的第几天
|
||||
_, week := now.ISOWeek()
|
||||
consumeTime := []uint32{
|
||||
uint32(now.Month()), // 月份
|
||||
uint32(week), // 周数
|
||||
uint32(now.Day()), // 日期
|
||||
}
|
||||
|
||||
record := &model.GoldBeanConsume{
|
||||
PlayerID: uint64(s.userid),
|
||||
ConsumeNum: count,
|
||||
BizID: pid,
|
||||
Year: year, // 补充年份
|
||||
Consume: consumeTime, // 补充消费时间(月-周-日)
|
||||
}
|
||||
s.dbm(s.Model).Data(record).Insert()
|
||||
|
||||
}
|
||||
|
||||
func NewGoldService(id uint32) *GoldService {
|
||||
return &GoldService{
|
||||
|
||||
BaseService: BaseService{userid: id,
|
||||
|
||||
Service: &cool.Service{Model: model.NewGoldBeanConsume()},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func (s *TalkService) Cheak(mapid uint32, flag int) (int, bool) {
|
||||
return int(talks.Count), true //int(config.MaxDailyCnt - talks.Count)
|
||||
|
||||
}
|
||||
func (s *TalkService) Update(flag int) {
|
||||
func (s *TalkService) Update(flag int, count int) {
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
|
||||
return
|
||||
@@ -65,6 +65,6 @@ func (s *TalkService) Update(flag int) {
|
||||
s.dbm(s.Model).Data(talks).FieldsEx("id").Insert()
|
||||
}
|
||||
|
||||
s.dbm(s.Model).Where("talk_id", flag).Increment("count", 1)
|
||||
s.dbm(s.Model).Where("talk_id", flag).Increment("count", count)
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ type UserService struct {
|
||||
Cdk *CdkService //cdk
|
||||
Friend *FriendService //好友
|
||||
Egg *EggService //孵化
|
||||
GoldLog *GoldService
|
||||
|
||||
}
|
||||
|
||||
func NewUserService(id uint32) *UserService {
|
||||
@@ -40,7 +40,6 @@ func NewUserService(id uint32) *UserService {
|
||||
Cdk: NewCdkService(id),
|
||||
Friend: NewFriendService(id),
|
||||
Egg: NewEggService(id),
|
||||
GoldLog: NewGoldService(id),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user