speical_award.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. package model
  2. import (
  3. "strconv"
  4. "time"
  5. )
  6. /* 奖项信息 */
  7. // SaveAwardArg for saving an award
  8. type SaveAwardArg struct {
  9. // identity
  10. AwardID int64 `json:"award_id"`
  11. // properties
  12. AddAwardArg
  13. }
  14. // AddAwardArg for adding an award
  15. type AddAwardArg struct {
  16. AwardName string `json:"award_name"` // 专项奖名称
  17. DisplayStatus int `json:"display_status"` // 信息是否完整 1=不完整,不前台展示 2=完整,前台展示
  18. CycleStart int64 `json:"cycle_start" ` // 评选开始
  19. CycleEnd int64 `json:"cycle_end"` // 评选结束
  20. AnnounceDate int64 `json:"announce_date"` // 公示日期
  21. Divisions []*AwardDivision `json:"divisions"` // 赛区
  22. Prizes []*AwardPrize `json:"prizes"` // 奖项
  23. Resources *AwardResource `json:"resources"` // 物料
  24. }
  25. // AwardResource model
  26. type AwardResource struct {
  27. Rule string `json:"rule"`
  28. Detail string `json:"detail"`
  29. QA []*AwardQA `json:"qa"`
  30. }
  31. // AwardQA model
  32. type AwardQA struct {
  33. Index int `json:"-"`
  34. Q string `json:"q"`
  35. A string `json:"a"`
  36. }
  37. // AwardDivision model
  38. type AwardDivision struct {
  39. // identity
  40. AwardID int64 `json:"-"`
  41. DivisionID int64 `json:"-"`
  42. // properties
  43. DivisionName string `json:"division_name"`
  44. TagID int64 `json:"tag_id"`
  45. Tag string `json:"tag"`
  46. }
  47. // AwardPrize model
  48. type AwardPrize struct {
  49. // identity
  50. AwardID int64 `json:"-"`
  51. PrizeID int64 `json:"-"`
  52. // properties
  53. Bonus int `json:"bonus"`
  54. Quota int `json:"quota"`
  55. }
  56. // AwardListModel .
  57. type AwardListModel struct {
  58. ID int64 `json:"id"`
  59. AwardID int64 `json:"award_id"` // 专项奖ID
  60. AwardName string `json:"award_name"` // 专项奖名称
  61. //DisplayStatus int `json:"display_status"` // 是否前台展示(1不展示,2展示)
  62. CycleStart int64 `json:"cycle_start"` // 评选开始
  63. CycleEnd int64 `json:"cycle_end"` // 评选结束
  64. TotalQuota int `json:"total_quota"` // 总中奖名额
  65. TotalBonus int `json:"total_bonus"` // 奖金总金额
  66. AnnounceDate int64 `json:"announce_date"` // 公示时间
  67. OpenStatus int `json:"deliver_status"` // 发奖情况(1未发奖,2已发奖)
  68. OpenTime int64 `json:"deliver_time"` // 发奖时间
  69. CTime int64 `json:"created_at"` // 创建时间
  70. CreatedBy string `json:"created_by"` // 创建人
  71. SelectionStatus int `json:"selection_status"` // 评奖状态(1未评奖,2已评奖)
  72. DivisionNames []string `json:"division_names"` // 分赛区名称列表
  73. Tags []string `json:"tags"` // 分区名称列表
  74. }
  75. // Award model
  76. type Award struct {
  77. ID int64 `json:"id"`
  78. AwardID int64 `json:"award_id"` // 专项奖ID
  79. AwardName string `json:"award_name"` // 专项奖名称
  80. DisplayStatus int `json:"display_status"` // 是否前台展示(1不展示,2展示)
  81. CycleStart time.Time `json:"-"` // 评选周期开始
  82. CycleEnd time.Time `json:"-"` // 评选周期结束
  83. CycleStartTS int64 `json:"cycle_start"` // 评选开始
  84. CycleEndTS int64 `json:"cycle_end"` // 评选结束
  85. TotalQuota int `json:"total_quota"` // 总中奖名额
  86. TotalBonus int `json:"total_bonus"` // 奖金总金额
  87. AnnounceDate time.Time `json:"-"` // 公示日期
  88. AnnounceDateTS int64 `json:"announce_date"` // 公示时间
  89. OpenStatus int `json:"deliver_status"` // 发奖情况(1未发奖,2已发奖)
  90. OpenTime time.Time `json:"-"` // 开奖时间
  91. OpenTimeTS int64 `json:"deliver_time"` // 发奖时间
  92. CTime time.Time `json:"-"` // 创建时间
  93. CTimeTS int64 `json:"created_at"` // 创建时间
  94. CreatedBy string `json:"created_by"` // 创建人
  95. SelectionStatus int `json:"selection_status"` // 评奖状态(1未评奖,2已评奖)
  96. IncentiveStart int64 `json:"incentive_start"`
  97. IncentiveEnd int64 `json:"incentive_end"`
  98. }
  99. // GenStr .
  100. func (v *Award) GenStr() {
  101. v.CycleStartTS = v.CycleStart.Unix()
  102. v.CycleEndTS = v.CycleEnd.Unix()
  103. v.AnnounceDateTS = v.AnnounceDate.Unix()
  104. v.OpenTimeTS = v.OpenTime.Unix()
  105. v.CTimeTS = v.CTime.Unix()
  106. v.IncentiveStart = time.Date(v.CycleEnd.Year(), time.Month(v.CycleEnd.Month()+1), 15, 0, 0, 0, 0, time.Local).Unix()
  107. v.IncentiveEnd = time.Date(v.CycleEnd.Year(), time.Month(v.CycleEnd.Month()+1), 29, 0, 0, 0, 0, time.Local).Unix()
  108. }
  109. // AwardDetail wrapper
  110. type AwardDetail struct {
  111. Award *Award `json:"award"`
  112. Divisions []*AwardDivision `json:"divisions"`
  113. Prizes []*AwardPrize `json:"prizes"`
  114. Resources *AwardResource `json:"resources"`
  115. }
  116. // AwardResult .
  117. type AwardResult struct {
  118. AwardID int64 `json:"award_id"`
  119. OpenTime int64 `json:"deliver_time"`
  120. AnnounceDate int64 `json:"announce_date"`
  121. CycleEnd int64 `json:"cycle_end"`
  122. Divisions []*AwardDivisionResult `json:"divisions"`
  123. }
  124. // AwardDivisionResult .
  125. type AwardDivisionResult struct {
  126. DivisionID int64 `json:"-"`
  127. DivisionName string `json:"division_name"`
  128. Prizes []*AwardPrizeResult `json:"prizes"`
  129. }
  130. // AwardPrizeResult .
  131. type AwardPrizeResult struct {
  132. PrizeID int64 `json:"-"`
  133. MIDs []int64 `json:"mids"`
  134. }
  135. // AwardRecord model
  136. type AwardRecord struct {
  137. // identity
  138. AwardID int64
  139. MID int64
  140. // properties
  141. TagID int64
  142. }
  143. // AwardWinner model
  144. type AwardWinner struct {
  145. // identity
  146. AwardID int64 `json:"award_id"`
  147. MID int64 `json:"mid"`
  148. // properties
  149. DivisionID int64 `json:"division_id"` //赛区ID
  150. PrizeID int64 `json:"prize_id"` //专项奖奖项ID
  151. TagID int64 `json:"-"` //分区ID
  152. // derived
  153. Tag string `json:"tag"` //分区
  154. Nickname string `json:"nickname"` //昵称
  155. Bonus int `json:"bonus"` //专项奖奖项奖金
  156. DivisionName string `json:"division"` //专项奖赛区
  157. }
  158. // QueryAwardWinnerArg .
  159. type QueryAwardWinnerArg struct {
  160. AwardID int64 `form:"award_id" validate:"required"`
  161. MID int64 `form:"mid"`
  162. Nickname string `form:"nickname"`
  163. TagID int64 `form:"tag_id"`
  164. From int `form:"from" validate:"min=0" default:"0"`
  165. Limit int `form:"limit" validate:"min=1" default:"20"`
  166. }
  167. // AwardWinnerExportFields .
  168. func AwardWinnerExportFields() []string {
  169. return []string{"UID", "昵称", "分赛区", "奖项类型", "奖金", "分区"}
  170. }
  171. // ExportStrings of an AwardWinner
  172. func (v *AwardWinner) ExportStrings() []string {
  173. return []string{
  174. strconv.FormatInt(v.MID, 10),
  175. v.Nickname,
  176. v.DivisionName,
  177. "奖项" + strconv.FormatInt(v.PrizeID, 10),
  178. strconv.FormatInt(int64(v.Bonus/100), 10),
  179. v.Tag,
  180. }
  181. }