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.1 KiB
191 lines
5.1 KiB
package pc
|
|
|
|
import (
|
|
"fmt"
|
|
"hudongzhuanjia/controllers"
|
|
"hudongzhuanjia/models"
|
|
ws_send_service "hudongzhuanjia/services/ws_send"
|
|
"hudongzhuanjia/utils"
|
|
"hudongzhuanjia/utils/code"
|
|
"hudongzhuanjia/utils/define"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
)
|
|
|
|
type UpperWallCtl struct {
|
|
controllers.AuthorCtl
|
|
}
|
|
type UpperWallResult struct {
|
|
models.UpperWall `xorm:"extends"`
|
|
User *models.User `json:"user" xorm:"extends"`
|
|
}
|
|
|
|
//获取所有已审核的上墙消息
|
|
func (t *UpperWallCtl) List() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
result := make([]*UpperWallResult, 0)
|
|
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
|
|
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
|
|
Where("w.is_delete=0 and w.status=3 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId).
|
|
OrderBy("w.review_time desc").Find(&result)
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"total": len(result),
|
|
"list": result,
|
|
})
|
|
}
|
|
|
|
//获取待审核列表
|
|
func (t *UpperWallCtl) WaitReview() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
//根据霸屏服务得id获取待审核得霸屏列表
|
|
result := make([]*UpperWallResult, 0)
|
|
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
|
|
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
|
|
Where("w.is_delete=0 and w.status=0 and w.activity_id=? and w.rehearsal_id=?", activityId, rehearsalId).
|
|
OrderBy("w.review_time desc").Find(&result)
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"total": len(result),
|
|
"list": result,
|
|
})
|
|
}
|
|
|
|
//审核操作
|
|
func (t *UpperWallCtl) Review() {
|
|
idList := t.MustGet("ids")
|
|
status := t.MustGetBool("status")
|
|
uid := t.MustGetUID()
|
|
|
|
ids := strings.Split(idList, "|")
|
|
|
|
customer := new(models.Customer)
|
|
exist, err := models.Get(customer, uid)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
|
|
|
|
reviewStatus := 1
|
|
if !status {
|
|
reviewStatus = 3 // 审核通过直接发送ws
|
|
}
|
|
|
|
t.CheckErr(models.Save(map[string]interface{}{
|
|
"id in": ids,
|
|
}, &models.UpperWall{
|
|
Status: reviewStatus,
|
|
ReviewTime: time.Now().Unix(),
|
|
}, "status", "review_time"))
|
|
|
|
// false 通过
|
|
if !status {
|
|
result := make([]*UpperWallResult, 0)
|
|
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
|
|
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
|
|
Where("w.is_delete=0").In("w.id", ids).
|
|
OrderBy("w.created_at asc").Find(&result)
|
|
t.CheckErr(err)
|
|
if len(result) == 0 {
|
|
t.ERROR("不存在上墙消息", code.MSG_DATA_NOT_EXIST)
|
|
return
|
|
}
|
|
|
|
for index := range result {
|
|
bi, err := utils.Gif2Base64(result[index].Img)
|
|
t.CheckErr(err)
|
|
result[index].Img = bi
|
|
}
|
|
|
|
go ws_send_service.SendUpperWall(fmt.Sprintf("%d", result[0].ActivityId),
|
|
define.TYPE_CUSTOMER, customer.Id, map[string]interface{}{
|
|
"type": "upper_wall",
|
|
"customer_id": customer.Id,
|
|
"data": map[string]interface{}{
|
|
"list": result,
|
|
"total": len(result)},
|
|
})
|
|
}
|
|
t.SUCCESS("审核成功")
|
|
}
|
|
|
|
//获取黑名单列表
|
|
func (t *UpperWallCtl) Blacklist() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
result := make([]*UpperWallResult, 0)
|
|
|
|
err := core.GetXormAuto().Table("ox_upper_wall").Alias("w").
|
|
Join("LEFT", "ox_user as u", "w.user_id=u.id and u.is_delete=0").
|
|
Where("w.is_delete=0 and w.status=1 and w.status=1 and w.rehearsal_id=? and w.activity_id=?",
|
|
rehearsalId, activityId).OrderBy("review_time desc").Find(&result)
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"total": len(result),
|
|
"list": result,
|
|
})
|
|
}
|
|
|
|
//获取目前上墙得总条数
|
|
func (t *UpperWallCtl) Total() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=3",
|
|
activityId, rehearsalId).Count(new(models.UpperWall))
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"total": total,
|
|
})
|
|
}
|
|
|
|
//二维码
|
|
// 跳到主页
|
|
func (t *UpperWallCtl) Qrcode() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
uid := t.MustGetUID()
|
|
|
|
activity := new(models.Activity)
|
|
exist, err := models.Get(activity, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动信息异常")
|
|
|
|
area := new(models.AreaStore)
|
|
exist, err = area.GetByCustomerId(uid, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "地区信息异常")
|
|
|
|
qrcode, err := utils.GenH5Qrcode(define.H5Index, map[string]interface{}{
|
|
"activity_id": activityId,
|
|
"area_id": area.Id,
|
|
"customer_id": uid,
|
|
"rehearsal_id": activity.RehearsalId,
|
|
})
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"qrcode": qrcode,
|
|
})
|
|
}
|
|
|
|
func (t *UpperWallCtl) Details() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
msgWall := new(models.MsgWallServer)
|
|
exist, err := msgWall.GetByActivityId(activityId)
|
|
t.CheckErr(err)
|
|
if !exist {
|
|
t.ERROR("上墙服务模块不存在", code.MSG_ERR)
|
|
}
|
|
t.JSON(map[string]interface{}{
|
|
"msg_wall": msgWall,
|
|
})
|
|
}
|