互动
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
4 years ago
4 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
4 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
4 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.MustGetInt("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.MustGetInt("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.GetAccountId()
  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(&models.UpperWall{}).Alias("w").
  84. Join("LEFT", (&models.User{}).Alias("u"), "w.user_id=u.id and u.is_delete=0").
  85. Where("w.is_delete=0").In("w.id", ids).Asc("w.created_at").Find(&result)
  86. t.CheckErr(err)
  87. if len(result) == 0 {
  88. t.ERROR("不存在上墙消息", code.MSG_DATA_NOT_EXIST)
  89. return
  90. }
  91. for index := range result {
  92. bi, err := utils.Gif2Base64(result[index].Img)
  93. t.CheckErr(err)
  94. result[index].Img = bi
  95. }
  96. go ws_send_service.SendUpperWall(fmt.Sprintf("%d", result[0].ActivityId),
  97. define.TYPE_CUSTOMER, customer.Id, map[string]interface{}{
  98. "type": "upper_wall",
  99. "customer_id": customer.Id,
  100. "data": map[string]interface{}{
  101. "list": result,
  102. "total": len(result)},
  103. })
  104. }
  105. t.SUCCESS("审核成功")
  106. }
  107. //获取黑名单列表
  108. func (t *UpperWallCtl) Blacklist() {
  109. activityId := t.MustGetInt("activity_id")
  110. activity := new(models.Activity)
  111. exist, err := models.Get(activity, activityId)
  112. t.CheckErr(err)
  113. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  114. result := make([]*UpperWallResult, 0)
  115. err = core.GetXormAuto().Table("ox_upper_wall").Alias("w").
  116. Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
  117. Where("w.is_delete=0 and w.status=1 and w.rehearsal_id=? and w.activity_id=? and w.arch_id=?",
  118. activity.RehearsalId, activity.Id, activity.ArchId).Desc("w.review_time").Find(&result)
  119. t.CheckErr(err)
  120. t.JSON(map[string]interface{}{
  121. "total": len(result),
  122. "list": result,
  123. })
  124. }
  125. //获取目前上墙得总条数
  126. func (t *UpperWallCtl) Total() {
  127. activityId := t.MustGetInt("activity_id")
  128. activity := new(models.Activity)
  129. exist, err := models.Get(activity, activityId)
  130. t.CheckErr(err)
  131. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  132. total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=? and status=3",
  133. activityId, activity.RehearsalId, activity.ArchId).Count(new(models.UpperWall))
  134. t.CheckErr(err)
  135. t.JSON(map[string]interface{}{
  136. "total": total,
  137. })
  138. }
  139. //二维码
  140. // 跳到主页
  141. func (t *UpperWallCtl) Qrcode() {
  142. activityId := t.MustGetInt("activity_id")
  143. uid := t.GetAccountId()
  144. activity := new(models.Activity)
  145. exist, err := models.Get(activity, activityId)
  146. t.CheckErr(err)
  147. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动信息异常")
  148. area := new(models.AreaStore)
  149. exist, err = area.GetByCustomerId(uid, activityId)
  150. t.CheckErr(err)
  151. t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "地区信息异常")
  152. qrcode, err := utils.GenH5Qrcode(define.H5Index, map[string]interface{}{
  153. "activity_id": activityId,
  154. "area_id": area.Id,
  155. "customer_id": uid,
  156. "rehearsal_id": activity.RehearsalId,
  157. })
  158. t.CheckErr(err)
  159. t.JSON(map[string]interface{}{
  160. "qrcode": qrcode,
  161. })
  162. }
  163. func (t *UpperWallCtl) Details() {
  164. activityId := t.MustGetInt("activity_id")
  165. msgWall := new(models.MsgWallServer)
  166. exist, err := msgWall.GetByActivityId(activityId)
  167. t.CheckErr(err)
  168. if !exist {
  169. t.ERROR("上墙服务模块不存在", code.MSG_ERR)
  170. return
  171. }
  172. t.JSON(map[string]interface{}{
  173. "msg_wall": msgWall,
  174. })
  175. }