|
|
package client
import ( "hudongzhuanjia/controllers" "hudongzhuanjia/libs/filter" "hudongzhuanjia/models" bully_screen_service "hudongzhuanjia/services/bully_reward" "hudongzhuanjia/services/pay" "hudongzhuanjia/utils/code" "time" )
//霸屏
type BullyScreenCtl struct { controllers.AuthorCtl }
//用户霸屏
func (t *BullyScreenCtl) PaScreen() { activityId := t.MustGetInt64("activity_id") uid := t.MustGetUID() content := t.MustGet("content") second := t.MustGetDouble("second") style := t.MustGetInt("style")
activity := new(models.Activity) exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.CheckRunning(activity.Status)
//检查内容是否包含敏感
if ok, _ := filter.Validate(content); !ok { t.ERROR("内容包含敏感字", code.MSG_ERR) }
//查询该活动的的霸屏服务id
bullyScreenServer := new(models.BullyScreenServer) exist, err = bullyScreenServer.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
//查询用户信息
user := new(models.User) exist, err = models.Get(user, uid) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
amount := bullyScreenServer.Price * second var res = make(map[string]interface{}, 0) res["out_trade_no"] = "" if activity.RehearsalId == 0 { res, err = pay_service.UnifiedOrder("欧轩互动-霸屏支付", user.Openid, int64(amount*100), 1, user.Id, activityId, time.Now().Add(1*time.Hour).Unix()) t.CheckErr(err) }
history := models.BullyScreenHistory{ OutTradeNo: res["out_trade_no"].(string), BullyScreenServerId: bullyScreenServer.Id, ActivityId: activityId, UserId: user.Id, Nickname: user.Nickname, CustomerId: t.MustGetCustomerId(), RehearsalId: activity.RehearsalId, Second: int(second), Amount: amount, Style: style, ReviewTime: 0, Status: -1, Content: content, } if activity.RehearsalId != 0 { history.Status = 0 } _, err = models.Add(&history) t.CheckErr(err) t.JSON(res) }
// 审核列表 [未审核,未通过,已通过]
func (t *BullyScreenCtl) List() { uid := t.MustGetUID() activityId := t.MustGetInt64("activity_id")
bss := new(models.BullyScreenServer) exist, err := bss.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
list, err := bully_screen_service.GetBullyList(uid, bss.Id) t.CheckErr(err) t.JSON(map[string]interface{}{ "total": len(list), "list": list, }) }
|