互动
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.

40 lines
1.9 KiB

5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "hudongzhuanjia/utils/define"
  5. "time"
  6. )
  7. const LotteryDrawRuleTableName = TableNamePrefix + "lottery_draw_rule"
  8. //抽奖活动规则
  9. type LotteryDrawRule struct {
  10. Id int64 `json:"id"`
  11. LotteryDrawActivityId int64 `json:"lottery_draw_activity_id" description:"红包轮次的id"`
  12. LotteryDrawRuleLadders []*LotteryDrawRuleLadder `json:"lottery_draw_rule_ladder" xorm:"-" description:"阶梯"`
  13. AreaId int64 `json:"area_id" description:"地区id"`
  14. AreaStatus string `json:"area_status" description:"多地区[开启,关闭]"`
  15. UseTimes int64 `json:"use_times" description:"使用次数"`
  16. LotteryDrawStatus string `json:"lottery_draw_status" description:"抽奖活动状态 [未开始/进行中/已结束]"` // 废弃字段
  17. PrizeNum int `json:"prize_num" xorm:"-" description:"奖品总数"`
  18. IsDelete bool `json:"is_delete" xorm:"default(0)" description:"是否删除"`
  19. CreatedAt time.Time `json:"-" xorm:"created" description:"创建时间"`
  20. UpdatedAt time.Time `json:"-" xorm:"updated" description:"更新时间"`
  21. }
  22. func (t *LotteryDrawRule) TableName() string {
  23. return LotteryDrawRuleTableName
  24. }
  25. func GetLDRuleIdsByLDActivityId(ids []int64) ([]int64, error) {
  26. ruleIds := make([]int64, 0)
  27. err := core.GetXormAuto().Table(new(LotteryDrawRule)).Select("id").
  28. Where("is_delete=0").In("lottery_draw_activity_id", ids).Find(&ruleIds)
  29. return ruleIds, err
  30. }
  31. func UpdateLDRuleStatusByLDActiviytIds(ids []int64) (int64, error) {
  32. return core.GetXormAuto().Where("is_delete=0").In("lottery_draw_activity_id", ids).
  33. Update(&LotteryDrawRule{LotteryDrawStatus: define.StatusNotBegin})
  34. }