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.
107 lines
3.0 KiB
107 lines
3.0 KiB
package client
|
|
|
|
import (
|
|
"hudongzhuanjia/controllers"
|
|
"hudongzhuanjia/libs/filter"
|
|
"hudongzhuanjia/models"
|
|
bully_screen_service "hudongzhuanjia/services/bully_screen"
|
|
"hudongzhuanjia/services/pay"
|
|
"hudongzhuanjia/utils/code"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
)
|
|
|
|
//霸屏
|
|
type BullyScreenCtl struct {
|
|
controllers.AuthorCtl
|
|
}
|
|
|
|
//用户霸屏
|
|
// todo: 支付接口
|
|
func (t *BullyScreenCtl) PaScreen() {
|
|
activityId := t.MustGetActivityId()
|
|
uid := t.MustGetUID()
|
|
content := t.MustGet("content")
|
|
second := t.MustGetDouble("second")
|
|
style := t.MustGetInt("style")
|
|
|
|
activity := new(models.Activity)
|
|
exist, err := models.GetById(activity, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
|
|
t.CheckRunning(activity.Status)
|
|
|
|
//检查内容是否包含敏感
|
|
//if models.IsSensitive(content) {
|
|
// t.ERROR("内容包含敏感字", code.MSG_ERR)
|
|
//}
|
|
content = filter.Replace(content)
|
|
|
|
//查询该活动的的霸屏服务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.GetById(user, uid)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
|
|
|
|
//扣除用户的金额
|
|
// todo:微信直接付款
|
|
// 调用微信统一下单接口
|
|
amount := bullyScreenServer.Price * second
|
|
ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":")
|
|
res, err := pay_service.Order("欧轩互动-霸屏支付", ip[0], user.Openid, int(amount*100), 1, user.Id, activityId)
|
|
t.CheckErr(err)
|
|
|
|
history := &models.BullyScreenHistory{
|
|
UserOrderId: res["user_order_id"].(int64),
|
|
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,
|
|
IsDelete: false,
|
|
CreatedAt: time.Now(),
|
|
UpdatedAt: time.Now(),
|
|
}
|
|
_, err = core.GetXormAuto().InsertOne(history)
|
|
t.CheckErr(err)
|
|
delete(res, "out_trade_no")
|
|
delete(res, "user_order_id")
|
|
t.JSON(res)
|
|
}
|
|
|
|
// 审核列表 [未审核,未通过,已通过]
|
|
func (t *BullyScreenCtl) List() {
|
|
uid := t.MustGetUID()
|
|
activityId := t.MustGetActivityId()
|
|
|
|
bss := new(models.BullyScreenServer)
|
|
exist, err := bss.GetByActivityId(activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_BULLY_SCREEN_SERVER_NOT_EXIST, "霸屏不存在")
|
|
|
|
// 查询是否已经付款
|
|
t.CheckErr(pay_service.BatchQueryByUserId(uid))
|
|
t.CheckErr(pay_service.BatchQueryRefundByUserId(uid))
|
|
|
|
list, err := bully_screen_service.GetReviewList(uid, bss.Id)
|
|
t.CheckErr(err)
|
|
t.JSON(map[string]interface{}{
|
|
"total": len(list),
|
|
"list": list,
|
|
})
|
|
}
|