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

50 lines
2.9 KiB

package models
import (
"time"
"github.com/ouxuanserver/osmanthuswine/src/core"
)
const AuctionResultRecordTableName = TableNamePrefix + "auction_result_record"
type AuctionResultRecord struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
ActivityId int `json:"activity_id" xorm:"not null default(0) comment('主活动id') INT(11)"`
RehearsalId int `json:"rehearsal_id" xorm:"not null default(0) comment('0正式/!0彩排id') INT(11)"` // 增加彩排功能
AuctionActivityId int `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default('0') comment('地区id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
AreaName string `json:"area_name" xorm:"not null default('') comment('地区名字') VARCHAR(255)"`
UserId int `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 int, archId interface{}) (int64, error) {
return core.GetXormAuto().Where("auction_activity_id=? and arch_id=? and rehearsal_id=? and is_delete=0",
aid, archId, rid).Count(t)
}
func GetAuctionRecordsByAuctionId(id, rid int, archId interface{}) ([]*AuctionResultRecord, error) {
records := make([]*AuctionResultRecord, 0)
err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and auction_activity_id=? and arch_id=?", rid, id, archId).
Desc("created_at").Find(&records)
return records, err
}
func (t *AuctionResultRecord) GetByUserIdAndAuctionId(userId, auctionId, archId, rehearsalId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and arch_id=? and rehearsal_id=?",
userId, auctionId, archId, rehearsalId).Get(t)
}