package models import ( "time" "github.com/ouxuanserver/osmanthuswine/src/core" ) const AuctionHistoryTableName = TableNamePrefix + "auction_history" //竞拍历史 type AuctionHistory struct { Id int `json:"id" xorm:"not null pk autoincr INT(11)"` UserId int `json:"user_id" xorm:"not null comment('用户表id') INT(11)"` RehearsalId int `json:"rehearsal_id" xorm:"not null comment('彩排id, 0是正式') INT(11)"` ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"` PlayerId int `json:"player_id" xorm:"not null comment('竞拍者id') INT(11)"` ActivityId int `json:"activity_id" xorm:"not null comment('互动id') INT(11)"` AreaId int `json:"area_id" xorm:"not null comment('地区id') INT(11)"` AreaName string `json:"area_name" xorm:"not null comment('地区名字') VARCHAR(128)"` UserName string `json:"user_name" xorm:"not null comment('用户名') VARCHAR(128)"` UserPhone string `json:"user_phone" xorm:"not null comment('用户手机') VARCHAR(128)"` AuctionGoodsName string `json:"auction_goods_name" xorm:"not null comment('竞拍商品名字') VARCHAR(255)"` AuctionActivityId int `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"` PlayerCode int64 `json:"player_code" xorm:"not null comment('竞拍参与者号码') INT(11)"` Unit int `json:"unit" xorm:"not null default(1) comment('单位') TINYINT(1)"` Money float64 `json:"money" xorm:"not null comment('计算总价格') DECIMAL(20)"` Version int `json:"version" xorm:"not null default(0) 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 *AuctionHistory) TableName() string { return AuctionHistoryTableName } func (t *AuctionHistory) GetHighestMoney(rid, aid int, archId interface{}) (bool, error) { return core.GetXormAuto().Where("auction_activity_id = ? and arch_id=? and rehearsal_id=? and is_delete=0", aid, archId, rid).Desc("money").Asc("updated_at").Get(t) } func (t *AuctionHistory) CountHistory(rid, aid int) (int64, error) { return core.GetXormAuto().Where("auction_activity_id = ? and rehearsal_id=? and is_delete=0", aid, rid).Count(t) } func GetAuctionHistoriesByAuctionId(aid, rid int, orderBy string, archId interface{}) ([]*AuctionHistory, error) { histories := make([]*AuctionHistory, 0) err := core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and rehearsal_id=? and arch_id=?", aid, rid, archId).OrderBy(orderBy).Find(&histories) return histories, err } func GetAuctionHistoriesByAuctionIds(ids []int, rid int, archId interface{}) ([]*AuctionHistory, error) { histories := make([]*AuctionHistory, 0) err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and arch_id=?", rid, archId). In("auction_activity_id", ids).Desc("money").Find(&histories) return histories, err }