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

192 lines
5.4 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
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
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
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 pc
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. bully_reward_service "hudongzhuanjia/services/bully_reward"
  6. "hudongzhuanjia/services/pay"
  7. "hudongzhuanjia/utils"
  8. "hudongzhuanjia/utils/code"
  9. "strings"
  10. "time"
  11. )
  12. type BullyScreenCtl struct {
  13. controllers.AuthorCtl
  14. }
  15. //获取待审核列表
  16. func (t *BullyScreenCtl) WaitReview() {
  17. activityId := t.MustGetInt64("activity_id")
  18. activity := new(models.Activity)
  19. exist, err := models.Get(activity, activityId)
  20. t.CheckErr(err)
  21. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  22. //获取霸屏服务得id
  23. bullyScreenServer := new(models.BullyScreenServer)
  24. exist, err = bullyScreenServer.GetByActivityId(activityId)
  25. t.CheckErr(err)
  26. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  27. //根据霸屏服务得id获取待审核得霸屏列表
  28. t.CheckErr(bully_reward_service.CheckBullyScreenStatus(bullyScreenServer.Id))
  29. result, err := bully_reward_service.GetBullyScreenReview(bullyScreenServer.Id, activity.RehearsalId)
  30. t.CheckErr(err)
  31. t.JSON(map[string]interface{}{
  32. "total": len(result),
  33. "list": result,
  34. })
  35. }
  36. //审核操作
  37. func (t *BullyScreenCtl) Review() {
  38. customerId := t.MustGetUID()
  39. status := t.MustGetBool("status")
  40. ids := strings.Split(t.MustGet("ids"), "|")
  41. activityId := t.MustGetInt64("activity_id")
  42. //rehearsalId := t.MustGetInt64("rehearsal_id")
  43. activity := new(models.Activity)
  44. exist, err := models.Get(activity, activityId)
  45. t.CheckErr(err)
  46. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  47. //将金额退回给用户
  48. result, err := models.GetBullyScreenHistoryByIds(ids)
  49. t.CheckErr(err)
  50. for _, v := range result {
  51. if status { // true 失败 、、 false 成功
  52. v.Status = 1
  53. _, err = models.Update(v.Id, v, "status")
  54. t.CheckErr(err)
  55. if activity.RehearsalId != 0 { // 彩排
  56. continue
  57. }
  58. _, err = pay_service.Refund("欧轩互动-霸屏拉黑", v.OutTradeNo)
  59. t.CheckErr(err)
  60. } else {
  61. v.Status = 2
  62. _, err = models.Update(v.Id, v, "status")
  63. t.CheckErr(err)
  64. if activity.RehearsalId != 0 {
  65. continue
  66. }
  67. // 订单宣告完成
  68. _, err = new(models.UserOrder).UpdateStatusByOutTradeNo(v.OutTradeNo, 2)
  69. t.CheckErr(err)
  70. wallet := new(models.BullyScreenWallet)
  71. _, err = wallet.IncrBalance(customerId, v.Amount)
  72. t.CheckErr(err)
  73. history := models.BullyScreenWalletHistory{
  74. CustomerId: customerId,
  75. UserId: v.UserId,
  76. Money: v.Amount,
  77. Type: "霸屏",
  78. Status: "交易成功",
  79. Mark: "霸屏金额",
  80. CreatedAt: time.Now(),
  81. UpdatedAt: time.Now(),
  82. }
  83. _, err = models.Add(history)
  84. t.CheckErr(err)
  85. }
  86. }
  87. t.SUCCESS("审核成功")
  88. }
  89. //获取黑名单列表
  90. func (t *BullyScreenCtl) Blacklist() {
  91. activityId := t.MustGetInt64("activity_id")
  92. activity := new(models.Activity)
  93. exist, err := models.Get(activity, activityId)
  94. t.CheckErr(err)
  95. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  96. //获取霸屏服务得id
  97. bullyScreenServer := new(models.BullyScreenServer)
  98. exist, err = bullyScreenServer.GetByActivityId(activityId)
  99. t.CheckErr(err)
  100. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏活动不存在")
  101. //根据霸屏服务得id获取待审核得霸屏列表
  102. result, err := bully_reward_service.GetBullyScreenBlacklist(bullyScreenServer.Id, activity.RehearsalId)
  103. t.CheckErr(err)
  104. t.DisplayByData(map[string]interface{}{
  105. "total": len(result),
  106. "list": result,
  107. })
  108. }
  109. //获取目前霸屏得总金额
  110. func (t *BullyScreenCtl) Amount() {
  111. activityId := t.MustGetInt64("activity_id")
  112. activity := new(models.Activity)
  113. exist, err := models.Get(activity, activityId)
  114. t.CheckErr(err)
  115. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  116. //获取霸屏服务得id
  117. bullyScreenServer := new(models.BullyScreenServer)
  118. exist, err = bullyScreenServer.GetByActivityId(activityId)
  119. t.CheckErr(err)
  120. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  121. totalSecond, err := new(models.BullyScreenHistory).SumSecond(bullyScreenServer.Id, activity.RehearsalId)
  122. t.CheckErr(err)
  123. t.JSON(map[string]interface{}{
  124. "amount": utils.Float64CusDecimal(totalSecond*bullyScreenServer.Price, 2),
  125. })
  126. }
  127. //获取最新得霸屏记录
  128. func (t *BullyScreenCtl) Latest() {
  129. activityId := t.MustGetInt64("activity_id")
  130. activity := new(models.Activity)
  131. exist, err := models.Get(activity, activityId)
  132. t.CheckErr(err)
  133. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  134. //获取霸屏服务得id
  135. bullyScreenServer := new(models.BullyScreenServer)
  136. exist, err = bullyScreenServer.GetByActivityId(activityId)
  137. t.CheckErr(err)
  138. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  139. result, err := bully_reward_service.GetBullyScreenLatest(bullyScreenServer.Id, activity.RehearsalId)
  140. t.CheckErr(err)
  141. if result == nil || result.Id == 0 {
  142. t.JSON(result)
  143. }
  144. //更改推送状态
  145. result.BullyScreenHistory.Status = 3
  146. result.BullyScreenHistory.UpdatedAt = time.Now()
  147. _, err = models.Update(result.BullyScreenHistory.Id, &result.BullyScreenHistory, "status")
  148. t.CheckErr(err)
  149. t.JSON(result)
  150. }
  151. // 霸屏服务器开关
  152. func (t *BullyScreenCtl) Details() {
  153. activityId := t.MustGetInt64("activity_id")
  154. server := new(models.BullyScreenServer)
  155. exist, err := server.GetByActivityId(activityId)
  156. t.CheckErr(err)
  157. t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
  158. t.JSON(map[string]interface{}{
  159. "server": server,
  160. })
  161. }