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

207 lines
5.7 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
  1. package pc
  2. import (
  3. "fmt"
  4. "hudongzhuanjia/controllers"
  5. "hudongzhuanjia/models"
  6. ws_send_service "hudongzhuanjia/services/ws_send"
  7. "hudongzhuanjia/utils"
  8. "hudongzhuanjia/utils/code"
  9. "hudongzhuanjia/utils/define"
  10. "strings"
  11. "time"
  12. "github.com/ouxuanserver/osmanthuswine/src/core"
  13. )
  14. type UpperWallCtl struct {
  15. controllers.AuthorCtl
  16. }
  17. type UpperWallResult struct {
  18. models.UpperWall `xorm:"extends"`
  19. User *models.User `json:"user" xorm:"extends"`
  20. }
  21. //获取所有已审核的上墙消息
  22. func (t *UpperWallCtl) List() {
  23. activityId := t.MustGetInt64("activity_id")
  24. activity := new(models.Activity)
  25. exist, err := models.Get(activity, activityId)
  26. t.CheckErr(err)
  27. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  28. result := make([]*UpperWallResult, 0)
  29. err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
  30. Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
  31. Where("w.is_delete=0 and w.status=3 and w.activity_id=? and w.rehearsal_id=? and arch_id=?",
  32. activityId, activity.RehearsalId, activity.ArchId).
  33. OrderBy("w.review_time desc").Find(&result)
  34. t.CheckErr(err)
  35. t.JSON(map[string]interface{}{
  36. "total": len(result),
  37. "list": result,
  38. })
  39. }
  40. //获取待审核列表
  41. func (t *UpperWallCtl) WaitReview() {
  42. activityId := t.MustGetInt64("activity_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. //根据霸屏服务得id获取待审核得霸屏列表
  48. result := make([]*UpperWallResult, 0)
  49. err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
  50. Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
  51. Where("w.is_delete=0 and w.status=0 and w.activity_id=? and w.rehearsal_id=? and arch_id=?",
  52. activityId, activity.RehearsalId, activity.ArchId).
  53. OrderBy("w.review_time desc").Find(&result)
  54. t.CheckErr(err)
  55. t.JSON(map[string]interface{}{
  56. "total": len(result),
  57. "list": result,
  58. })
  59. }
  60. //审核操作
  61. func (t *UpperWallCtl) Review() {
  62. idList := t.MustGet("ids")
  63. status := t.MustGetBool("status")
  64. uid := t.MustGetUID()
  65. ids := strings.Split(idList, "|")
  66. customer := new(models.Customer)
  67. exist, err := models.Get(customer, uid)
  68. t.CheckErr(err)
  69. t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
  70. reviewStatus := 1
  71. if !status {
  72. reviewStatus = 3 // 审核通过直接发送ws
  73. }
  74. t.CheckErr(models.Save(map[string]interface{}{
  75. "id in": ids,
  76. }, &models.UpperWall{
  77. Status: reviewStatus,
  78. ReviewTime: time.Now().Unix(),
  79. }, "status", "review_time"))
  80. // false 通过
  81. if !status {
  82. result := make([]*UpperWallResult, 0)
  83. err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
  84. Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
  85. Where("w.is_delete=0").In("w.id", ids).
  86. OrderBy("w.created_at asc").Find(&result)
  87. t.CheckErr(err)
  88. if len(result) == 0 {
  89. t.ERROR("不存在上墙消息", code.MSG_DATA_NOT_EXIST)
  90. return
  91. }
  92. for index := range result {
  93. bi, err := utils.Gif2Base64(result[index].Img)
  94. t.CheckErr(err)
  95. result[index].Img = bi
  96. }
  97. go ws_send_service.SendUpperWall(fmt.Sprintf("%d", result[0].ActivityId),
  98. define.TYPE_CUSTOMER, customer.Id, map[string]interface{}{
  99. "type": "upper_wall",
  100. "customer_id": customer.Id,
  101. "data": map[string]interface{}{
  102. "list": result,
  103. "total": len(result)},
  104. })
  105. }
  106. t.SUCCESS("审核成功")
  107. }
  108. //获取黑名单列表
  109. func (t *UpperWallCtl) Blacklist() {
  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. result := make([]*UpperWallResult, 0)
  116. err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
  117. Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
  118. Where("w.is_delete=0 and w.status=1 and w.rehearsal_id=? and w.activity_id=? and w.arch_id=?",
  119. activity.RehearsalId, activity.Id, activity.ArchId).OrderBy("review_time desc").Find(&result)
  120. t.CheckErr(err)
  121. t.JSON(map[string]interface{}{
  122. "total": len(result),
  123. "list": result,
  124. })
  125. }
  126. //获取目前上墙得总条数
  127. func (t *UpperWallCtl) Total() {
  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. total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=? and status=3",
  134. activityId, activity.RehearsalId, activity.ArchId).Count(new(models.UpperWall))
  135. t.CheckErr(err)
  136. t.JSON(map[string]interface{}{
  137. "total": total,
  138. })
  139. }
  140. //二维码
  141. // 跳到主页
  142. func (t *UpperWallCtl) Qrcode() {
  143. activityId := t.MustGetInt64("activity_id")
  144. uid := t.MustGetUID()
  145. activity := new(models.Activity)
  146. exist, err := models.Get(activity, activityId)
  147. t.CheckErr(err)
  148. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动信息异常")
  149. area := new(models.AreaStore)
  150. exist, err = area.GetByCustomerId(uid, activityId)
  151. t.CheckErr(err)
  152. t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "地区信息异常")
  153. qrcode, err := utils.GenH5Qrcode(define.H5Index, map[string]interface{}{
  154. "activity_id": activityId,
  155. "area_id": area.Id,
  156. "customer_id": uid,
  157. "rehearsal_id": activity.RehearsalId,
  158. })
  159. t.CheckErr(err)
  160. t.JSON(map[string]interface{}{
  161. "qrcode": qrcode,
  162. })
  163. }
  164. func (t *UpperWallCtl) Details() {
  165. activityId := t.MustGetInt64("activity_id")
  166. msgWall := new(models.MsgWallServer)
  167. exist, err := msgWall.GetByActivityId(activityId)
  168. t.CheckErr(err)
  169. if !exist {
  170. t.ERROR("上墙服务模块不存在", code.MSG_ERR)
  171. }
  172. t.JSON(map[string]interface{}{
  173. "msg_wall": msgWall,
  174. })
  175. }