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

42 lines
2.4 KiB

5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const ShakeRedEnvelopeActivityTableName = TableNamePrefix + "shake_red_envelope_activity"
  7. //摇红包活动
  8. type ShakeRedEnvelopeActivity struct {
  9. Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
  10. ActivityId int64 `json:"activity_id" xorm:"not null comment('主活动id') BIGINT(20)" description:"活动的id"`
  11. RedEnvelopeActivityName string `json:"red_envelope_activity_name" xorm:"not null default('') comment('红包活动名字') VARCHAR(255)"`
  12. ShakeRedEnvelopeRule *ShakeRedEnvelopeRule `json:"shake_red_envelope_rule" xorm:"-" description:"规则"`
  13. MoreAreaMode string `json:"more_area_mode" xorm:"not null default('') comment('多地区') VARCHAR(125)"`
  14. IsPay int `json:"is_pay" xorm:"not null default(0) comment('1支付0未支付') TINYINT(1)"`
  15. TotalMoney float64 `json:"total_money" xorm:"not null comment('轮次的总金额') DECIMAL"`
  16. EditTotalMoney float64 `json:"edit_total_money" xorm:"not null comment('修改后的总额') DECIMAL"`
  17. FinalTotalMoney float64 `json:"final_total_money" xorm:"not null comment('最后总金额') DECIMAL" description:"最后总额"`
  18. IsDelete bool `json:"is_delete" xorm:"default(0) comment('软删除') TINYINT(1)" description:"是否已删除"`
  19. CreatedAt time.Time `json:"create_at" xorm:"not null created comment('创建时间') DATETIME"`
  20. UpdatedAt time.Time `json:"update_at" xorm:"not null updated comment('更新时间') DATETIME"`
  21. }
  22. func (t *ShakeRedEnvelopeActivity) TableName() string {
  23. return ShakeRedEnvelopeActivityTableName
  24. }
  25. func (t *ShakeRedEnvelopeActivity) Alias(name string) string {
  26. return AliasTableName(t, name)
  27. }
  28. func (t *ShakeRedEnvelopeActivity) GetPayedById(id int64) (bool, error) {
  29. return core.GetXormAuto().Where("is_delete=0 and is_pay=1 and id=?", id).Get(t)
  30. }
  31. func GetSREActivityIdsByActivityId(aid int64) ([]int64, error) {
  32. shakeRbIds := make([]int64, 0)
  33. err := core.GetXormAuto().Table(new(ShakeRedEnvelopeActivity)).Select("id").
  34. Where("is_delete=0 and activity_id=?", aid).Find(&shakeRbIds)
  35. return shakeRbIds, err
  36. }