2026-03-17 16:56:55 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 表名常量定义:金豆挂单表(金豆↔金币互换)
|
|
|
|
|
|
const (
|
|
|
|
|
|
TableNameGoldBeanOrder = "player_gold_bean_order" // 金豆挂单表(记录玩家金豆与金币互换的挂单、完成、取消等状态)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// GoldBeanOrder 金豆挂单核心模型(与数据库表字段一一对应,存储互换明细)
|
|
|
|
|
|
type GoldBeanOrder struct {
|
|
|
|
|
|
*cool.Model // 复用通用Model(包含ID、CreatedAt、UpdatedAt等字段)
|
|
|
|
|
|
|
2026-03-19 14:50:11 +08:00
|
|
|
|
PlayerID uint64 `gorm:"not null;index:idx_order_player_id;comment:'所属玩家ID'" json:"player_id" description:"所属玩家ID"`
|
|
|
|
|
|
ExchangeNum uint32 `gorm:"not null;default:0;comment:'兑换数量(金豆/金币)'" json:"exchange_num" description:"兑换数量"`
|
|
|
|
|
|
Rate float64 `gorm:"not null;default:0;comment:'兑换比例'" json:"rate" description:"兑换比例"`
|
|
|
|
|
|
Status uint32 `gorm:"not null;default:0;comment:'状态(0待处理 1完成)'" json:"status" description:"状态"`
|
2026-03-17 16:56:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 核心配套方法 --------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// TableName 指定GoldBeanOrder对应的数据库表名(遵循项目规范)
|
|
|
|
|
|
func (*GoldBeanOrder) TableName() string {
|
|
|
|
|
|
return TableNameGoldBeanOrder
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GroupName 指定表所属分组(与金豆消费表保持一致)
|
|
|
|
|
|
func (*GoldBeanOrder) GroupName() string {
|
|
|
|
|
|
return "default"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewGoldBeanOrder 创建金豆挂单记录实例(初始化通用Model及默认值)
|
|
|
|
|
|
func NewGoldBeanOrder() *GoldBeanOrder {
|
|
|
|
|
|
return &GoldBeanOrder{
|
|
|
|
|
|
Model: cool.NewModel(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 表结构自动同步 --------------------------
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
// 程序启动时自动创建/同步金豆挂单表
|
|
|
|
|
|
cool.CreateTable(&GoldBeanOrder{})
|
|
|
|
|
|
}
|