package models import ( "github.com/ouxuanserver/osmanthuswine/src/core" "time" ) const BullyScreenHistoryTableName = TableNamePrefix + "bully_screen_history" //霸屏历史表 type BullyScreenHistory struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` BullyScreenServerId int64 `json:"bully_screen_server_id" xorm:"not null comment('霸屏服务得id') INT(11)"` OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('微信订单号') VARCHAR(128)"` CustomerId int64 `json:"customer_id" xorm:"not null comment('客户id') INT(11)"` ActivityId int64 `json:"activity_id" xorm:"not null comment('互动id') INT(11)"` UserId int64 `json:"user_id" xorm:"not null comment('用户得id') INT(11)"` Nickname string `json:"nickname" xorm:"not null default('') comment('发送者昵称') VARCHAR(128)"` RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/ 0是正式') INT(11)"` Style int `json:"style" xorm:"not null comment('服务样式') INT(11)"` Second int `json:"second" xorm:"not null comment('霸屏时间(秒)') INT(11)"` Content string `json:"content" xorm:"not null comment('内容') TEXT"` Status int `json:"status" xorm:"not null default(0) comment('[-1未支付,0未审核,1未通过,2已通过,3已推送,4已作废]') INT(11)"` Amount float64 `json:"amount" xorm:"not null default 0.00 comment('霸屏金额') DECIMAL(10)"` ReviewTime int64 `json:"review_time" xorm:"not null comment('审核的时间') INT(11)"` Version int64 `json:"version" xorm:"not null version comment('乐观锁') INT(11)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"` CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"` } func (t *BullyScreenHistory) TableName() string { return BullyScreenHistoryTableName } func (t *BullyScreenHistory) UpdateStatus(id int64, status int) (int64, error) { t.Status = status return core.GetXormAuto().ID(id).Cols("status").Update(t) } // 更改未支付状态 func (t *BullyScreenHistory) UpdateStatusByOutTradeNo(outTradeNo string, status int) (int64, error) { t.Status = status return core.GetXormAuto().Where("is_delete=0 and status=-1 and out_trade_no=?", outTradeNo). Cols("status").Update(t) } func (t *BullyScreenHistory) UpdateStatusByIds(ids []int64, status int) error { if len(ids) > 0 { t.Status = status _, err := core.GetXormAuto().In("id", ids).Cols("status"). Update(&BullyScreenHistory{Status: status}) return err } return nil }