elec_db.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package model
  2. import (
  3. "time"
  4. "go-common/library/log"
  5. )
  6. // DBOldElecPayTradeInfo .
  7. type DBOldElecPayTradeInfo struct {
  8. ID int64
  9. OrderID string
  10. AVID string
  11. }
  12. // DBOldElecPayOrder .
  13. type DBOldElecPayOrder struct {
  14. ID int64 `json:"id"`
  15. APPID int `json:"app_id"`
  16. UPMID int64 `json:"mid"`
  17. PayMID int64 `json:"pay_mid"`
  18. OrderID string `json:"order_no"`
  19. ElecNum int64 `json:"elec_num"`
  20. Status int `json:"status"` // 订单状态,1.消费中 2.消费成功 3.消费失败
  21. CTimeStr string `json:"ctime"`
  22. MTimeStr string `json:"mtime"`
  23. CTime time.Time
  24. MTime time.Time
  25. }
  26. // IsPaid .
  27. func (d *DBOldElecPayOrder) IsPaid() bool {
  28. return d.Status == 2
  29. }
  30. // IsHiddnRank .
  31. func (d *DBOldElecPayOrder) IsHiddnRank() bool {
  32. return d.APPID == 19 // 动态互推
  33. }
  34. // ParseCTime .
  35. func (d *DBOldElecPayOrder) ParseCTime() (t time.Time) {
  36. if !d.CTime.IsZero() {
  37. return d.CTime
  38. }
  39. var err error
  40. if t, err = time.ParseInLocation("2006-01-02 15:04:05", d.CTimeStr, time.Local); err != nil {
  41. log.Error("DBOldElecPayOrder ctime parse failed: %s, err: %+v", d.CTimeStr, err)
  42. t = time.Now()
  43. }
  44. return
  45. }
  46. // ParseMTime .
  47. func (d *DBOldElecPayOrder) ParseMTime() (t time.Time) {
  48. if !d.MTime.IsZero() {
  49. return d.MTime
  50. }
  51. var err error
  52. if t, err = time.ParseInLocation("2006-01-02 15:04:05", d.MTimeStr, time.Local); err != nil {
  53. log.Error("DBOldElecPayOrder mtime parse failed: %s, err: %+v", d.MTimeStr, err)
  54. t = time.Now()
  55. }
  56. return
  57. }
  58. // DBOldElecMessage .
  59. type DBOldElecMessage struct {
  60. ID int64 `json:"id"`
  61. MID int64 `json:"mid"`
  62. RefMID int64 `json:"ref_mid"`
  63. RefID int64 `json:"ref_id"`
  64. Message string `json:"message"`
  65. AVID string `json:"av_no"`
  66. DateVer string `json:"date_version"` // yyyy-MM格式,年-月
  67. Type int `json:"type"` // 留言类型, 1.用户对up主留言 2.up回复用户留言
  68. State int `json:"state"` // 留言状态 0.未回复 1.已回复 2 已屏蔽
  69. CTimeStr string `json:"ctime"`
  70. MTimeStr string `json:"mtime"`
  71. CTime time.Time
  72. MTime time.Time
  73. }
  74. // ParseCTime .
  75. func (d *DBOldElecMessage) ParseCTime() (t time.Time) {
  76. if !d.CTime.IsZero() {
  77. return d.CTime
  78. }
  79. var err error
  80. if t, err = time.ParseInLocation("2006-01-02 15:04:05", d.CTimeStr, time.Local); err != nil {
  81. log.Error("DBOldElecMessage ctime parse failed: %s, err: %+v", d.CTimeStr, err)
  82. t = time.Now()
  83. }
  84. return
  85. }
  86. // ParseMTime .
  87. func (d *DBOldElecMessage) ParseMTime() (t time.Time) {
  88. if !d.MTime.IsZero() {
  89. return d.MTime
  90. }
  91. var err error
  92. if t, err = time.ParseInLocation("2006-01-02 15:04:05", d.MTimeStr, time.Local); err != nil {
  93. log.Error("DBOldElecMessage mtime parse failed: %s, err: %+v", d.MTimeStr, err)
  94. t = time.Now()
  95. }
  96. return
  97. }
  98. // DBOldElecUserSetting .
  99. type DBOldElecUserSetting struct {
  100. ID int64 `json:"id"`
  101. MID int64 `json:"mid"`
  102. SettingID int `json:"setting_id"`
  103. Status int `json:"status"`
  104. }
  105. // BitValue 返回该配置位==1的数值
  106. func (d *DBOldElecUserSetting) BitValue() int32 {
  107. switch d.SettingID {
  108. case 1:
  109. return 0x1
  110. case 2:
  111. return 0x2
  112. default:
  113. log.Error("DBOldElecUserSetting unknown SettingID:%d, %+v", d.SettingID, d)
  114. }
  115. return 0
  116. }
  117. // DBElecMessage .
  118. type DBElecMessage struct {
  119. ID int64
  120. Ver int64
  121. AVID int64
  122. UPMID int64
  123. PayMID int64
  124. Message string
  125. Replied bool
  126. Hidden bool
  127. CTime time.Time
  128. MTime time.Time
  129. }
  130. // DBElecReply .
  131. type DBElecReply struct {
  132. ID int64
  133. MSGID int64
  134. Reply string
  135. Hidden bool
  136. CTime time.Time
  137. MTime time.Time
  138. }