package models import ( "github.com/ouxuanserver/osmanthuswine/src/core" "time" ) const AuctionResultRecordTableName = TableNamePrefix + "auction_result_record" type AuctionResultRecord struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` ActivityId int64 `json:"activity_id" xorm:"not null default(0) comment('主活动id') INT(11)"` RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('0正式/!0彩排id') INT(11)"` // 增加彩排功能 AuctionActivityId int64 `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"` AreaId int64 `json:"area_id" xorm:"not null default('0') comment('地区id') INT(11)"` AreaName string `json:"area_name" xorm:"not null default('') comment('地区名字') VARCHAR(255)"` UserId int64 `json:"user_id" xorm:"not null comment('用户id') INT(11)"` UserName string `json:"user_name" xorm:"not null comment('用户名字') VARCHAR(255)"` UserPhone string `json:"user_phone" xorm:"not null comment('用户手机号码') VARCHAR(128)"` PlayerCode int64 `json:"player_code" xorm:"not null default(0) comment('竞拍编号') INT(11)"` AuctionGoodsName string `json:"auction_goods_name" xorm:"not null comment('商品名字') VARCHAR(255)"` DealPrice float64 `json:"deal_price" xorm:"not null comment('成交价格') DECIMAL(20)"` Unit int `json:"unit" xorm:"not null default(1) comment('单位') TINYINT(1)"` 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 *AuctionResultRecord) TableName() string { return AuctionResultRecordTableName } func (t *AuctionResultRecord) CountHistory(rid, aid int64) (int64, error) { return core.GetXormAuto().Where("auction_activity_id=? and rehearsal_id=? and is_delete=0", aid, rid).Count(t) } func GetAuctionRecordsByAuctionId(id, rid int64, orderBy string) ([]*AuctionResultRecord, error) { records := make([]*AuctionResultRecord, 0) err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and auction_activity_id=?", rid, id). OrderBy(orderBy).Find(&records) return records, err } func (t *AuctionResultRecord) GetByUserIdAndAuctionId(userId, auctionId, rehearsalId interface{}) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and rehearsal_id=?", userId, auctionId, rehearsalId).Get(t) }