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

37 lines
1.5 KiB

5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const CustomerOrderOptionTableName = TableNamePrefix + "customer_order_option"
  7. type CustomerOrderOption struct {
  8. Id int64 `json:"id" xorm:"not null pk INT(11)"`
  9. ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
  10. SettingBox string `json:"setting_box" xorm:"not null comment('json格式 选中的表单项') TEXT"`
  11. SelfBox string `json:"self_box" xorm:"not null comment('json格式 邀请函选中的表单项') TEXT"`
  12. Status int `json:"status" xorm:"not null default 0 comment('订单活动的开启1|关闭0') TINYINT(1)"`
  13. IsDelete int `json:"-" xorm:"not null default 0 comment('删除') TINYINT(1)"`
  14. CreatedAt time.Time `json:"-" xorm:"created"`
  15. UpdatedAt time.Time `json:"-" xorm:"updated"`
  16. }
  17. func (t *CustomerOrderOption) TableName() string {
  18. return CustomerOrderOptionTableName
  19. }
  20. func (t *CustomerOrderOption) GetByActivityId(aid int64) (bool, error) {
  21. return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Get(t)
  22. }
  23. func (t *CustomerOrderOption) GetOpen(aid int64) (bool, error) {
  24. return core.GetXormAuto().Where("is_delete=0 and activity_id=? and status=?", aid, 1).
  25. Desc("created_at").Get(t)
  26. }
  27. func (t *CustomerOrderOption) Switch(aid int64, status int) (int64, error) {
  28. t.Status = status
  29. return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Cols("status").Update(t)
  30. }