互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "hudongzhuanjia/utils/define"
  5. "time"
  6. )
  7. const LotteryDrawRuleLadderTableName = TableNamePrefix + "lottery_draw_rule_ladder"
  8. //抽奖活动规则阶梯
  9. type LotteryDrawRuleLadder struct {
  10. Id int64 `json:"id"`
  11. LotteryDrawRuleId int64 `json:"lottery_draw_rule_id" description:"红包轮次的id"`
  12. RollNum int `json:"roll_num" xorm:"not null default 0 comment('滚动次数') INT(11)"`
  13. PrizeName string `json:"prize_name" description:"奖品名字"`
  14. PrizeNumber int `json:"prize_number" description:"奖品数量"`
  15. Probability float64 `json:"probability" description:"概率"`
  16. PrizeImg string `json:"prize_img" description:"奖品图片"`
  17. Status string `json:"status" xorm:"not null default('未开始') comment('状态未开始进行中已结束') VARCHAR(3)"`
  18. Des string `json:"des" xorm:"-" description:"规则描述"`
  19. IsDelete bool `json:"-" xorm:"default(0)" description:"是否删除"`
  20. CreatedAt time.Time `json:"-" xorm:"created" description:"创建时间"`
  21. UpdatedAt time.Time `json:"-" xorm:"updated" description:"更新时间"`
  22. }
  23. func (t *LotteryDrawRuleLadder) TableName() string {
  24. return LotteryDrawRuleLadderTableName
  25. }
  26. func (t *LotteryDrawRuleLadder) Alias(name string) string {
  27. return AliasTableName(t, name)
  28. }
  29. func UpdateLDLadderStatusByLDRuleIds(ids []int64) (int64, error) {
  30. return core.GetXormAuto().Where("is_delete=0").
  31. In("lottery_draw_rule_id", ids).
  32. Update(&LotteryDrawRuleLadder{Status: define.StatusNotBegin})
  33. }
  34. func GetLotteryDrawLadderByRuleId(ruleId interface{}) ([]*LotteryDrawRuleLadder, error) {
  35. list := make([]*LotteryDrawRuleLadder, 0)
  36. err := core.GetXormAuto().Where("is_delete=0 and lottery_draw_rule_id=?", ruleId).Find(&list)
  37. return list, err
  38. }