package models import ( "github.com/ouxuanserver/osmanthuswine/src/core" "time" ) const CustomerOrderOptionTableName = TableNamePrefix + "customer_order_option" type CustomerOrderOption struct { Id int64 `json:"id" xorm:"not null pk INT(11)"` ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` SettingBox string `json:"setting_box" xorm:"not null comment('json格式 选中的表单项') TEXT"` SelfBox string `json:"self_box" xorm:"not null comment('json格式 邀请函选中的表单项') TEXT"` Status int `json:"status" xorm:"not null default 0 comment('订单活动的开启1|关闭0') TINYINT(1)"` IsDelete int `json:"-" xorm:"not null default 0 comment('删除') TINYINT(1)"` CreatedAt time.Time `json:"-" xorm:"created"` UpdatedAt time.Time `json:"-" xorm:"updated"` } func (t *CustomerOrderOption) TableName() string { return CustomerOrderOptionTableName } func (t *CustomerOrderOption) GetByActivityId(aid int64) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Get(t) } func (t *CustomerOrderOption) GetOpen(aid int64) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and activity_id=? and status=?", aid, 1). Desc("created_at").Get(t) } func (t *CustomerOrderOption) Switch(aid int64, status int) (int64, error) { t.Status = status return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Cols("status").Update(t) }