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

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