This commit is contained in:
@@ -24,12 +24,12 @@ type ShopConfig struct {
|
||||
JindouPrice int32 `gorm:"not null;default:0;comment:'金豆价格'" json:"jindou_price" description:"金豆价格"`
|
||||
|
||||
// 库存信息
|
||||
Stock uint32 `gorm:"not null;default:0;comment:'商品库存数量(0表示无限库存)'" json:"stock" description:"库存数量"`
|
||||
//Stock uint32 `gorm:"not null;default:0;comment:'商品库存数量(0表示无限库存)'" json:"stock" description:"库存数量"`
|
||||
|
||||
// 限购信息
|
||||
QuotaLimit uint32 `gorm:"not null;default:0;comment:'单位时间内的限购数量'" json:"quota_limit" description:"限购数量"`
|
||||
//限购类型
|
||||
QuotaType uint32 `gorm:"not null;default:0;comment:'限购类型(0-不限购 1-每日限购 2-每周限购 3-每月限购)'" json:"quota_type" description:"限购类型"`
|
||||
// // 限购信息
|
||||
// QuotaLimit uint32 `gorm:"not null;default:0;comment:'单位时间内的限购数量'" json:"quota_limit" description:"限购数量"`
|
||||
// //限购类型
|
||||
// QuotaType uint32 `gorm:"not null;default:0;comment:'限购类型(0-不限购 1-每日限购 2-每周限购 3-每月限购)'" json:"quota_type" description:"限购类型"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
|
||||
@@ -20,9 +20,9 @@ func NewTalkConfigService() *TalkConfigService {
|
||||
|
||||
}
|
||||
|
||||
func (s *TalkConfigService) GetCache(flag int) model.MineralCollectionConfig {
|
||||
func (s *TalkConfigService) GetCache(flag int) *model.MineralCollectionConfig {
|
||||
|
||||
var config model.MineralCollectionConfig
|
||||
var config *model.MineralCollectionConfig
|
||||
dbm_enable(s.Model).Where("type", flag).Scan(&config)
|
||||
return config
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量定义:金豆消费记录表
|
||||
const (
|
||||
TableNameGoldBeanConsume = "player_gold_log" // 金豆消费记录表(记录用户金豆消耗的明细、类型、关联业务等信息)
|
||||
)
|
||||
|
||||
// 通过金豆消费时间来确认金豆物品的购买重置周期
|
||||
// GoldBeanConsume 金豆消费核心模型(与数据库表字段一一对应,存储消费明细)
|
||||
type GoldBeanConsume struct {
|
||||
*cool.Model
|
||||
|
||||
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
ConsumeNum uint32 `gorm:"not null;default:0;comment:'消费数量'" json:"consume_num" description:"消费数量"`
|
||||
BizID uint32 `gorm:"not null;default:0;comment:'关联业务ID(如道具ID/扭蛋池ID,无则填0)'" json:"biz_id" description:"关联业务ID"`
|
||||
///消费年份
|
||||
Year uint32 `gorm:"not null;default:0;comment:'消费年份'" json:"year" description:"消费年份"`
|
||||
//消费时间,由月-周-日组成,判断金豆物品的购买重置周期
|
||||
Consume []uint32 `gorm:"type:jsonb; comment:'消费时间'" json:"consume" description:"消费时间"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法 --------------------------
|
||||
|
||||
// TableName 指定GoldBeanConsume对应的数据库表名(遵循项目规范)
|
||||
func (*GoldBeanConsume) TableName() string {
|
||||
return TableNameGoldBeanConsume
|
||||
}
|
||||
|
||||
// GroupName 指定表所属分组(与其他精灵/玩家相关表保持一致)
|
||||
func (*GoldBeanConsume) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewGoldBeanConsume 创建金豆消费记录实例(初始化通用Model及默认值)
|
||||
func NewGoldBeanConsume() *GoldBeanConsume {
|
||||
return &GoldBeanConsume{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- 表结构自动同步 --------------------------
|
||||
func init() {
|
||||
// 程序启动时自动创建/同步金豆消费记录表
|
||||
cool.CreateTable(&GoldBeanConsume{})
|
||||
}
|
||||
@@ -17,6 +17,7 @@ func NewTalk() *Talk {
|
||||
type Talk struct {
|
||||
Base
|
||||
PlayerID uint64 `gorm:"not null;index:idx_player_resource;comment:'所属玩家ID'" json:"player_id"`
|
||||
Type
|
||||
TalkID uint32 `gorm:"not null;comment:'资源ID'" json:"talk_id"`
|
||||
Count uint32 `gorm:"not null;comment:'采集计数'" json:"count"`
|
||||
}
|
||||
|
||||
@@ -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