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

46 lines
2.7 KiB

5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const AuctionResultRecordTableName = TableNamePrefix + "auction_result_record"
  7. type AuctionResultRecord struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. ActivityId int64 `json:"activity_id" xorm:"not null default(0) comment('主活动id') INT(11)"`
  10. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('0正式/!0彩排id') INT(11)"` // 增加彩排功能
  11. AuctionActivityId int64 `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"`
  12. AreaId int64 `json:"area_id" xorm:"not null default('0') comment('地区id') INT(11)"`
  13. AreaName string `json:"area_name" xorm:"not null default('') comment('地区名字') VARCHAR(255)"`
  14. UserId int64 `json:"user_id" xorm:"not null comment('用户id') INT(11)"`
  15. UserName string `json:"user_name" xorm:"not null comment('用户名字') VARCHAR(255)"`
  16. UserPhone string `json:"user_phone" xorm:"not null comment('用户手机号码') VARCHAR(128)"`
  17. PlayerCode int64 `json:"player_code" xorm:"not null default(0) comment('竞拍编号') INT(11)"`
  18. AuctionGoodsName string `json:"auction_goods_name" xorm:"not null comment('商品名字') VARCHAR(255)"`
  19. DealPrice float64 `json:"deal_price" xorm:"not null comment('成交价格') DECIMAL(20)"`
  20. Unit int `json:"unit" xorm:"not null default(1) comment('单位') TINYINT(1)"`
  21. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('软删除') TINYINT(1)"`
  22. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  23. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  24. }
  25. func (t *AuctionResultRecord) TableName() string {
  26. return AuctionResultRecordTableName
  27. }
  28. func (t *AuctionResultRecord) CountHistory(rid, aid int64) (int64, error) {
  29. return core.GetXormAuto().Where("auction_activity_id=? and rehearsal_id=? and is_delete=0", aid, rid).Count(t)
  30. }
  31. func GetAuctionRecordsByAuctionId(id, rid int64, orderBy string) ([]*AuctionResultRecord, error) {
  32. records := make([]*AuctionResultRecord, 0)
  33. err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=? and auction_activity_id=?", rid, id).
  34. OrderBy(orderBy).Find(&records)
  35. return records, err
  36. }
  37. func (t *AuctionResultRecord) GetByUserIdAndAuctionId(userId, auctionId, rehearsalId interface{}) (bool, error) {
  38. return core.GetXormAuto().Where("is_delete=0 and user_id=? and auction_activity_id=? and rehearsal_id=?", userId, auctionId, rehearsalId).Get(t)
  39. }