feat: 添加金豆消费记录功能
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:
@@ -55,12 +55,6 @@ func (s *BaseSysUserService) SetdepartmentId(userId, departmentId uint32) (res *
|
||||
|
||||
// 单位是分
|
||||
func (s *BaseSysUserService) UpdateGold(userId uint32, gold int64) {
|
||||
// updateData := g.Map{
|
||||
// "views": &gdb.Counter{
|
||||
// Field: "goldbean",
|
||||
// Value: 1,
|
||||
// },
|
||||
// }
|
||||
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
cool.Logger.Info(context.TODO(), "测试服不操作金币")
|
||||
@@ -68,10 +62,6 @@ func (s *BaseSysUserService) UpdateGold(userId uint32, gold int64) {
|
||||
}
|
||||
m := cool.DBM(s.Model).Where("id", userId)
|
||||
m.Increment("goldbean", gold)
|
||||
// // UPDATE `article` SET `views`=`views`+1 WHERE `id`=1
|
||||
// result, err := db.Update("article", updateData, "id", 1)
|
||||
|
||||
//res.GoldBean, _ = alpacadecimal.NewFromFloat(float64(gold)).Div(alpacadecimal.NewFromFloat(100)).Float64()
|
||||
|
||||
}
|
||||
func (s *BaseSysUserService) GetGold(userId uint) (res int64) {
|
||||
|
||||
@@ -12,9 +12,9 @@ const (
|
||||
// 通过金豆消费时间来确认金豆物品的购买重置周期
|
||||
// GoldBeanConsume 金豆消费核心模型(与数据库表字段一一对应,存储消费明细)
|
||||
type GoldBeanConsume struct {
|
||||
Base
|
||||
*cool.Model
|
||||
|
||||
UID uint32 `gorm:"not null;default:0;index;comment:'玩家唯一ID,关联玩家表主键'" json:"uid" description:"玩家ID"`
|
||||
PlayerID uint64 `gorm:"not null;uniqueIndex;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"`
|
||||
///消费年份
|
||||
@@ -40,7 +40,7 @@ func (*GoldBeanConsume) GroupName() string {
|
||||
// NewGoldBeanConsume 创建金豆消费记录实例(初始化通用Model及默认值)
|
||||
func NewGoldBeanConsume() *GoldBeanConsume {
|
||||
return &GoldBeanConsume{
|
||||
Base: *NewBase(),
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
21
modules/player/service/gold_log.go
Normal file
21
modules/player/service/gold_log.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type GoldService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func NewGoldService(id uint32) *GoldService {
|
||||
return &GoldService{
|
||||
|
||||
BaseService: BaseService{userid: id,
|
||||
|
||||
Service: &cool.Service{Model: model.NewGoldBeanConsume()},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ type UserService struct {
|
||||
Cdk *CdkService //cdk
|
||||
Friend *FriendService //好友
|
||||
Egg *EggService //孵化
|
||||
GoldLog *GoldService
|
||||
}
|
||||
|
||||
func NewUserService(id uint32) *UserService {
|
||||
@@ -39,6 +40,7 @@ func NewUserService(id uint32) *UserService {
|
||||
Cdk: NewCdkService(id),
|
||||
Friend: NewFriendService(id),
|
||||
Egg: NewEggService(id),
|
||||
GoldLog: NewGoldService(id),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user