offlineactivity.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package offlineactivity
  2. import (
  3. "go-common/library/time"
  4. "strconv"
  5. )
  6. const (
  7. //BonusTypeThing 奖品
  8. BonusTypeThing = 0
  9. //BonusTypeMoney 奖金
  10. BonusTypeMoney = 1
  11. )
  12. //ActivityState activity state
  13. type ActivityState int8
  14. const (
  15. //StateDelete 删除了
  16. StateDelete = 100
  17. // 用来转换 float * moneyCont -> int
  18. moneyConst = 1000
  19. )
  20. const (
  21. //ActivityStateInit 初始状态
  22. ActivityStateInit ActivityState = 0
  23. //ActivityStateSending 发送状态
  24. ActivityStateSending ActivityState = 1
  25. //ActivityStateWaitResult 等待审核结果
  26. ActivityStateWaitResult ActivityState = 2
  27. //ActivityStateSucess 成功
  28. ActivityStateSucess ActivityState = 10
  29. //ActivityStateFail 发送失败
  30. ActivityStateFail ActivityState = 11
  31. //ActivityStateCreateFail 创建失败
  32. ActivityStateCreateFail ActivityState = 12
  33. )
  34. const (
  35. //TableOfflineActivityInfo info name
  36. TableOfflineActivityInfo = "offline_activity_info"
  37. //TableOfflineActivityBonus bonus name
  38. TableOfflineActivityBonus = "offline_activity_bonus"
  39. //TableOfflineActivityResult result name
  40. TableOfflineActivityResult = "offline_activity_result"
  41. //TableOfflineActivityShellOrder shell order name
  42. TableOfflineActivityShellOrder = "offline_activity_shell_order"
  43. )
  44. //OfflineActivityInfo table info
  45. type OfflineActivityInfo struct {
  46. ID int64 `json:"id" gorm:"column:id"`
  47. Title string `json:"title" gorm:"column:title"`
  48. Link string `json:"link" gorm:"column:link"`
  49. BonusType int8 `json:"bonus_type" gorm:"column:bonus_type"`
  50. Memo string `json:"memo" gorm:"column:memo"`
  51. Creator string `json:"creator" gorm:"column:creator"`
  52. State int8 `json:"state" gorm:"column:state"`
  53. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  54. MTime time.Time `json:"-" gorm:"column:mtime"`
  55. }
  56. //TableName get table name
  57. func (o *OfflineActivityInfo) TableName() string {
  58. return TableOfflineActivityInfo
  59. }
  60. //BonusState bonus state
  61. type BonusState int8
  62. const (
  63. //BonusStateInit init state
  64. BonusStateInit BonusState = 0
  65. )
  66. //OfflineActivityBonus table bonus
  67. type OfflineActivityBonus struct {
  68. ID int64 `json:"id" gorm:"column:id"`
  69. ActivityID int64 `json:"activity_id" gorm:"column:activity_id"`
  70. TotalMoney int64 `json:"total_money" gorm:"column:total_money"`
  71. MemberCount uint32 `json:"member_count" gorm:"column:member_count"`
  72. State int8 `json:"state" gorm:"column:state"`
  73. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  74. MTime time.Time `json:"mtime" gorm:"column:mtime"`
  75. }
  76. //TableName tablename
  77. func (o *OfflineActivityBonus) TableName() string {
  78. return TableOfflineActivityBonus
  79. }
  80. //OfflineActivityResult table result
  81. type OfflineActivityResult struct {
  82. ID int64 `json:"id" gorm:"column:id;primary_key"`
  83. ActivityID int64 `json:"activity_id" gorm:"column:activity_id"`
  84. BonusID int64 `json:"bonus_id" gorm:"column:bonus_id"`
  85. BonusType int8 `json:"bonus_type" gorm:"column:bonus_type"`
  86. Mid int64 `json:"mid" gorm:"column:mid"`
  87. BonusMoney int64 `json:"bonus_money" gorm:"column:bonus_money"`
  88. OrderID string `json:"order_id" gorm:"column:order_id"`
  89. State int8 `json:"state" gorm:"column:state"`
  90. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  91. MTime time.Time `json:"mtime" gorm:"column:mtime"`
  92. }
  93. //TableName table name
  94. func (o *OfflineActivityResult) TableName() string {
  95. return TableOfflineActivityResult
  96. }
  97. //OfflineActivityShellOrder table shell order, order for shell system
  98. type OfflineActivityShellOrder struct {
  99. ID int64 `json:"id" gorm:"column:id"`
  100. ResultID int64 `json:"result_id" gorm:"column:result_id"`
  101. OrderID string `json:"order_id" gorm:"column:order_id"`
  102. OrderStatus string `json:"order_status" gorm:"column:order_status"`
  103. CTime time.Time `json:"ctime" gorm:"column:ctime"`
  104. MTime time.Time `json:"mtime" gorm:"column:mtime"`
  105. }
  106. //TableName table name
  107. func (o *OfflineActivityShellOrder) TableName() string {
  108. return TableOfflineActivityShellOrder
  109. }
  110. //GetMoneyFromDb get money from db
  111. func GetMoneyFromDb(dbmoney int64) float64 {
  112. return float64(dbmoney) / moneyConst
  113. }
  114. //GetMoneyForDb set money to db
  115. func GetMoneyForDb(realmoney float64) int64 {
  116. return int64(realmoney * moneyConst)
  117. }
  118. //StateToString State to string
  119. func StateToString(state int) string {
  120. switch state {
  121. case int(ActivityStateInit):
  122. return "初始"
  123. case int(ActivityStateSending):
  124. return "发送贝壳中"
  125. case int(ActivityStateWaitResult):
  126. return "等待审核结果"
  127. case int(ActivityStateSucess):
  128. return "成功"
  129. case int(ActivityStateFail):
  130. return "失败"
  131. case int(ActivityStateCreateFail):
  132. return "创建失败"
  133. case StateDelete:
  134. return "已删除"
  135. default:
  136. return strconv.Itoa(state)
  137. }
  138. }