tg_red_packet_config.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package entity
  2. import (
  3. "github.com/shopspring/decimal"
  4. "time"
  5. )
  6. // TgRedPacketConfig Telegram红包配置表(定时红包、管理员配置)
  7. type TgRedPacketConfig struct {
  8. MysqlBaseModel
  9. ConfigName string `json:"configName" gorm:"type:varchar(128);comment:配置名称;NOT NULL"`
  10. ConfigType int `json:"configType" gorm:"type:tinyint;comment:配置类型: 1=定时红包, 2=手动触发;NOT NULL"`
  11. GroupId string `json:"groupId" gorm:"type:varchar(128);index;comment:Telegram群组ID;NOT NULL"`
  12. GroupName string `json:"groupName" gorm:"type:varchar(255);comment:群组名称"`
  13. PacketType int `json:"packetType" gorm:"type:tinyint;comment:红包类型: 1=普通红包, 2=手气红包;NOT NULL"`
  14. TotalAmount decimal.Decimal `json:"totalAmount" gorm:"type:decimal(25,8);comment:红包总金额;NOT NULL"`
  15. TotalCount int `json:"totalCount" gorm:"type:int;comment:红包总个数;NOT NULL"`
  16. Symbol string `json:"symbol" gorm:"type:varchar(20);default:'VND';comment:币种"`
  17. ExpireMinutes int `json:"expireMinutes" gorm:"type:int;default:10;comment:红包过期时间(分钟)"`
  18. MaxGrabAmount decimal.Decimal `json:"maxGrabAmount" gorm:"type:decimal(25,8);default:0;comment:单人最大可领取金额(0=不限制)"`
  19. Lang string `json:"lang" gorm:"type:varchar(10);default:'vi';comment:消息语言: vi=越南语, id=印尼语, en=英语, zh=中文"`
  20. BlessingWords string `json:"blessingWords" gorm:"type:varchar(255);comment:祝福语"`
  21. // 定时任务相关字段(仅 configType=1 时使用)
  22. CronExpr string `json:"cronExpr" gorm:"type:varchar(128);comment:Cron表达式(如: 0 0 12 * * *)"`
  23. TimeZone string `json:"timeZone" gorm:"type:varchar(64);default:'Asia/Ho_Chi_Minh';comment:时区"`
  24. StartDate *time.Time `json:"startDate" gorm:"type:timestamp;comment:开始日期"`
  25. EndDate *time.Time `json:"endDate" gorm:"type:timestamp;comment:结束日期"`
  26. // 状态控制
  27. Status int `json:"status" gorm:"type:tinyint;default:1;index;comment:状态: 1=启用, 2=禁用, 3=已删除"`
  28. LastExecTime *time.Time `json:"lastExecTime" gorm:"type:timestamp;comment:上次执行时间"`
  29. NextExecTime *time.Time `json:"nextExecTime" gorm:"type:timestamp;comment:下次执行时间"`
  30. ExecCount int `json:"execCount" gorm:"type:int;default:0;comment:已执行次数"`
  31. // 创建者信息
  32. CreatorId int64 `json:"creatorId" gorm:"comment:创建者ID"`
  33. CreatorName string `json:"creatorName" gorm:"type:varchar(128);comment:创建者名称"`
  34. Remark string `json:"remark" gorm:"type:varchar(500);comment:备注"`
  35. }
  36. func (*TgRedPacketConfig) TableName() string {
  37. return ModelPrefix + "tg_red_packet_config"
  38. }
  39. func (*TgRedPacketConfig) Comment() string {
  40. return "Telegram红包配置表"
  41. }
  42. func NewTgRedPacketConfig() *TgRedPacketConfig {
  43. return &TgRedPacketConfig{}
  44. }