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

58 lines
3.0 KiB

5 years ago
  1. package models
  2. import (
  3. "time"
  4. "github.com/ouxuanserver/osmanthuswine/src/core"
  5. )
  6. const AuctionHistoryTableName = TableNamePrefix + "auction_history"
  7. //竞拍历史
  8. type AuctionHistory struct {
  9. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  10. UserId int64 `json:"user_id" xorm:"not null comment('用户表id') INT(11)"`
  11. RehearsalId int64 `json:"rehearsal_id" xorm:"not null comment('彩排id, 0是正式') INT(11)"`
  12. PlayerId int64 `json:"player_id" xorm:"not null comment('竞拍者id') INT(11)"`
  13. ActivityId int64 `json:"activity_id" xorm:"not null comment('互动id') INT(11)"`
  14. AreaId int64 `json:"area_id" xorm:"not null comment('地区id') INT(11)"`
  15. AreaName string `json:"area_name" xorm:"not null comment('地区名字') VARCHAR(128)"`
  16. UserName string `json:"user_name" xorm:"not null comment('用户名') VARCHAR(128)"`
  17. UserPhone string `json:"user_phone" xorm:"not null comment('用户手机') VARCHAR(128)"`
  18. AuctionGoodsName string `json:"auction_goods_name" xorm:"not null comment('竞拍商品名字') VARCHAR(255)"`
  19. AuctionActivityId int64 `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"`
  20. PlayerCode int64 `json:"player_code" xorm:"not null comment('竞拍参与者号码') INT(11)"`
  21. Unit int `json:"unit" xorm:"not null default(1) comment('单位') TINYINT(1)"`
  22. Money float64 `json:"money" xorm:"not null comment('计算总价格') DECIMAL(20)"`
  23. Version int `json:"version" xorm:"not null default(0) version comment('乐观锁') INT(11)"`
  24. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
  25. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  26. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  27. }
  28. func (t *AuctionHistory) TableName() string {
  29. return AuctionHistoryTableName
  30. }
  31. func (t *AuctionHistory) GetHighestMoney(rid, aid int64) (bool, error) {
  32. return core.GetXormAuto().Where("auction_activity_id = ? and rehearsal_id=? and is_delete=0", aid, rid).
  33. Desc("money").Asc("updated_at").Get(t)
  34. }
  35. func (t *AuctionHistory) CountHistory(rid, aid int64) (int64, error) {
  36. return core.GetXormAuto().Where("auction_activity_id = ? and rehearsal_id=? and is_delete=0", aid, rid).Count(t)
  37. }
  38. func GetAuctionHistoriesByAuctionId(aid, rid int64, orderBy string) ([]*AuctionHistory, error) {
  39. histories := make([]*AuctionHistory, 0)
  40. err := core.GetXormAuto().Where("is_delete=0 and auction_activity_id=? and rehearsal_id=?", aid, rid).
  41. OrderBy(orderBy).Find(&histories)
  42. return histories, err
  43. }
  44. func GetAuctionHistoriesByAuctionIds(ids []int64, rid int64, orderBy string) ([]*AuctionHistory, error) {
  45. histories := make([]*AuctionHistory, 0)
  46. err := core.GetXormAuto().Where("is_delete=0 and rehearsal_id=?", rid).
  47. In("auction_activity_id", ids).OrderBy(orderBy).Find(&histories)
  48. return histories, err
  49. }