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

51 lines
3.3 KiB

5 years ago
5 years ago
5 years ago
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. "time"
  5. )
  6. const LotteryDrawRecordTableName = TableNamePrefix + "lottery_draw_record"
  7. type LotteryDrawRecord struct {
  8. Id int64 `json:"id" xorm:"pk autoincr"`
  9. ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动id')"`
  10. RehearsalId int64 `json:"rehearsal_id" xorm:"not null comment('彩排id/0正式')"`
  11. UserPrizeId int64 `json:"user_prize_id" xorm:"not null comment('用户奖品id') INT(11)"`
  12. LotteryDrawActivityId int64 `json:"lottery_draw_activity_id" xorm:"not null comment('抽奖活动id')"`
  13. LotteryDrawRuleId int64 `json:"lottery_draw_rule_id" xorm:"not null comment('抽奖规则id') BIGINT(20)"`
  14. LotteryDrawRuleLadder *LotteryDrawRuleLadder `json:"lottery_draw_rule_ladder" xorm:"-"`
  15. UserId int64 `json:"user_id" xorm:"not null comment('用户id')"`
  16. User *User `json:"user" xorm:"-"`
  17. UserName string `json:"user_name" description:"用户名" xorm:"not null comment('用户名')"`
  18. UserPhone string `json:"user_phone" description:"电话" xorm:"not null comment('电话号码')"`
  19. LotteryDrawRuleLadderId int64 `json:"lottery_draw_rule_ladder_id" xorm:"not null comment('规则阶梯id')"`
  20. PrizeName string `json:"prize_name" description:"奖品名字" xorm:"not null comment('奖品名字')"`
  21. AreaName string `json:"area_name" description:"名字" xorm:"not null comment('地区名字')"`
  22. AreaId int64 `json:"area_id" xorm:"not null default(0) comment('地区id')"`
  23. Status int `json:"status" xorm:"not null default 0 comment('是否已经兑奖0否1是') TINYINT(1)"`
  24. Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(128)"`
  25. Phone string `json:"phone" xorm:"not null default '' comment('电话号码') VARCHAR(128)"`
  26. WxNo string `json:"wx_no" xorm:"not null default '' comment('微信号') VARCHAR(128)"`
  27. Address string `json:"address" xorm:"not null default '' comment('地址') VARCHAR(128)"`
  28. IsDelete bool `json:"-" xorm:"default(0)"`
  29. CreatedAt time.Time `json:"-" xorm:"created"`
  30. UpdatedAt time.Time `json:"-" xorm:"updated"`
  31. }
  32. func (t *LotteryDrawRecord) TableName() string {
  33. return LotteryDrawRecordTableName
  34. }
  35. func (t *LotteryDrawRecord) GetByUserIdAndLadderId(userId, ladderId interface{}) (bool, error) {
  36. return core.GetXormAuto().Where("is_delete=0 and user_id=? and lottery_draw_rule_ladder_id=?", userId, ladderId).Get(t)
  37. }
  38. func (t *LotteryDrawRecord) GetByUserPrizeId(upId int64) (bool, error) {
  39. return core.GetXormAuto().Where("is_delete=0 and user_prize_id=?", upId).Get(t)
  40. }
  41. func (t *LotteryDrawRecord) Update(id interface{}, field ...string) (int64, error) {
  42. t.Id = 0
  43. return core.GetXormAuto().Where("id=?", id).Update(t)
  44. }