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

74 lines
3.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const BullyScreenHistoryTableName = TableNamePrefix + "bully_screen_history"
  7. //霸屏历史表
  8. type BullyScreenHistory struct {
  9. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  10. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
  11. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  12. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  13. BullyScreenServerId int64 `json:"bully_screen_server_id" xorm:"not null default 0 comment('霸屏服务得id') INT(11)"`
  14. OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('微信订单号') VARCHAR(128)"`
  15. CustomerId int64 `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
  16. ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
  17. UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户得id') INT(11)"`
  18. Nickname string `json:"nickname" xorm:"not null default '' comment('发送者昵称') VARCHAR(128)"`
  19. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0是正式') INT(11)"`
  20. Style int `json:"style" xorm:"not null default 0 comment('服务样式') INT(11)"`
  21. Second int `json:"second" xorm:"not null default 0 comment('霸屏时间(秒)') INT(11)"`
  22. Content string `json:"content" xorm:"not null comment('内容') TEXT"`
  23. Status int `json:"status" xorm:"not null default(0) comment('[-1未支付,0未审核,1未通过,2已通过,3已推送,4已作废]') INT(11)"`
  24. Amount float64 `json:"amount" xorm:"not null default 0.00 comment('霸屏金额') DECIMAL(18)"`
  25. ReviewTime int64 `json:"review_time" xorm:"not null default 0 comment('审核的时间') INT(11)"`
  26. Version int64 `json:"version" xorm:"not null version comment('乐观锁') INT(11)"`
  27. }
  28. func (t *BullyScreenHistory) TableName() string {
  29. return BullyScreenHistoryTableName
  30. }
  31. func (t *BullyScreenHistory) GetByOutTradeNo(outTradeNo string) (bool, error) {
  32. return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
  33. }
  34. func (t *BullyScreenHistory) UpdateStatus(id int64, status int) (int64, error) {
  35. t.Status = status
  36. return core.GetXormAuto().ID(id).Cols("status").Update(t)
  37. }
  38. // 更改未支付状态
  39. func (t *BullyScreenHistory) UpdateStatusByOutTradeNo(outTradeNo string, status int) (int64, error) {
  40. t.Status = status
  41. return core.GetXormAuto().Where("is_delete=0 and status=-1 and out_trade_no=?", outTradeNo).
  42. Cols("status").Update(t)
  43. }
  44. func (t *BullyScreenHistory) UpdateStatusByIds(ids []int64, status int) error {
  45. if len(ids) > 0 {
  46. t.Status = status
  47. _, err := core.GetXormAuto().In("id", ids).Cols("status").
  48. Update(&BullyScreenHistory{Status: status})
  49. return err
  50. }
  51. return nil
  52. }
  53. func GetBullyScreenHistoryByIds(ids interface{}) ([]*BullyScreenHistory, error) {
  54. result := make([]*BullyScreenHistory, 0)
  55. err := core.GetXormAuto().Where("is_delete=0 and status=0").In("id", ids).Find(&result)
  56. return result, err
  57. }
  58. func (t *BullyScreenHistory) SumSecond(serverId, rehearsalId interface{}) (float64, error) {
  59. totalSecond, err := core.GetXormAuto().Where("bully_screen_server_id=? and status=3 and "+
  60. " is_delete=false and rehearsal_id=?", serverId, rehearsalId).
  61. Sum(new(BullyScreenHistory), "second")
  62. return totalSecond, err
  63. }