互动
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
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "hudongzhuanjia/utils/define"
  5. "time"
  6. )
  7. const OrderDrawRuleTableName = TableNamePrefix + "order_draw_rule"
  8. //订单抽奖抽奖规则
  9. type OrderDrawRule struct {
  10. Id int64 `json:"id"`
  11. OrderDrawActivityId int64 `json:"order_lottery_draw_activity_id" description:"订单抽奖活动的的id"`
  12. OrderDrawRuleLadders []*OrderDrawRuleLadder `json:"order_draw_rule_ladders" xorm:"-"`
  13. AreaId int64 `json:"area_id" description:"地区id"`
  14. UseTimes int `json:"use_times" description:"使用次数"`
  15. Name string `json:"name"`
  16. OrderDrawStatus string `json:"order_draw_status"`
  17. PrizeNum int `json:"prize_num" xorm:"-"`
  18. HaveEditRule bool `json:"have_edit_rule"`
  19. IsDelete bool `json:"is_delete" xorm:"default(0)" description:"是否删除"`
  20. CreatedAt time.Time `json:"-" xorm:"created" description:"创建时间"`
  21. UpdatedAt time.Time `json:"-" xorm:"updated" description:"更新时间"`
  22. }
  23. func (t *OrderDrawRule) TableName() string {
  24. return OrderDrawRuleTableName
  25. }
  26. func (t *OrderDrawRule) Alias(name string) string {
  27. return AliasTableName(t, name)
  28. }
  29. func GetODRuleIdsByODActivityIds(ids []int64) ([]int64, error) {
  30. ruleIds := make([]int64, 0)
  31. err := core.GetXormAuto().Table(new(OrderDrawRule)).Select("id").
  32. Where("is_delete=0").In("order_draw_activity_id", ids).Find(&ruleIds)
  33. return ruleIds, err
  34. }
  35. func UpdateODRuleStatusByODActivityIds(ids []int64) (int64, error) {
  36. return core.GetXormAuto().Where("is_delete=0").In("order_draw_activity_id", ids).
  37. Update(&OrderDrawRule{OrderDrawStatus: define.StatusNotBegin})
  38. }