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

41 lines
2.2 KiB

5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const ReWardHistoryTableName = TableNamePrefix + "reward_history"
  7. //打赏历史
  8. type RewardHistory struct {
  9. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  10. UserOrderId int64 `json:"user_order_id" xorm:"not null default(0) comment('用户订单id') INT(11)"`
  11. CustomerId int64 `json:"customer_id" xorm:"not null comment('客户id') INT(11)"`
  12. RewardServerId int64 `json:"reward_server_id" xorm:"not null comment('打赏服务id') INT(11)"`
  13. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
  14. UserId int64 `json:"user_id" xorm:"not null comment('用户得id') INT(11)"`
  15. User *User `json:"user" xorm:"-" description:"用户信息"`
  16. Content string `json:"content" xorm:"not null comment('内容') text"`
  17. Amount float64 `json:"amount" xorm:"not null default(0.0) comment('金额') DECIMAL"`
  18. RewardAmount string `json:"reward_amount" xorm:"-" description:"同上, 字符串"`
  19. Status int `json:"status" xorm:"not null default(0) comment('-1未支付 0未审核,1未通过,2已通过,3已推送') INT(11)"`
  20. ReviewTime int64 `json:"review_time" xorm:"not null default(0) comment('审核时间') INT(11)"`
  21. Version int64 `json:"version" xorm:"not null version comment('乐观锁') INT(11)"`
  22. IsDelete bool `json:"is_delete" xorm:"not null default(0)"`
  23. CreatedAt time.Time `json:"create_at" xorm:"not null default(CURRENT_TIMESTAMP) created comment('创建时间') TIMESTAMP"`
  24. UpdatedAt time.Time `json:"update_at" xorm:"not null default(CURRENT_TIMESTAMP) updated comment('更新时间') TIMESTAMP"`
  25. }
  26. func (t *RewardHistory) TableName() string {
  27. return ReWardHistoryTableName
  28. }
  29. func (t *RewardHistory) GetByUserOrderId(userOrderId int64) (bool, error) {
  30. return core.GetXormAuto().Where("is_delete=0 and user_order_id=?", userOrderId).Get(t)
  31. }
  32. func (t *RewardHistory) UpdateStatus(id int64, status int) (int64, error) {
  33. t.Status = status
  34. return core.GetXormAuto().Id(id).Cols("status").Update(t)
  35. }