|
|
@ -2,6 +2,7 @@ package client |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core" |
|
|
|
"hudongzhuanjia/controllers" |
|
|
|
"hudongzhuanjia/libs/filter" |
|
|
|
"hudongzhuanjia/libs/im" |
|
|
@ -11,6 +12,7 @@ import ( |
|
|
|
red_envelope_service "hudongzhuanjia/services/red_envelope" |
|
|
|
"hudongzhuanjia/utils" |
|
|
|
"hudongzhuanjia/utils/code" |
|
|
|
"hudongzhuanjia/utils/define" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@ -29,25 +31,35 @@ type LiveCtl struct { |
|
|
|
// 详情
|
|
|
|
func (t *LiveCtl) Detail() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
areaId, exist := t.GetInt64("area_id") |
|
|
|
|
|
|
|
if !exist { // 假设不存地区,那就设置为主地区
|
|
|
|
area := new(models.AreaStore) |
|
|
|
exist, err := area.GetMainAreaById(activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|
|
|
areaId = area.Id |
|
|
|
} |
|
|
|
|
|
|
|
areaId := t.MustGetInt64("area_id") |
|
|
|
userId := t.MustGetUID() |
|
|
|
|
|
|
|
err := new(models.LiveViewer).Record(userId, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
live := new(models.LiveConfig) |
|
|
|
exist, err = live.GetByActivityId(activityId) |
|
|
|
exist, err := live.GetByActivityId(activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在") |
|
|
|
t.Assert(exist, code.MSG_LIVE_CONFIG_NOT_EXIST, "直播活动不存在") |
|
|
|
|
|
|
|
fs := make(map[string]int, 0) |
|
|
|
fs["is_shake"] = 0 |
|
|
|
fs["is_reward"] = 0 |
|
|
|
fs["is_order"] = 0 |
|
|
|
if live.AdaptationFunc != nil && len(live.AdaptationFunc) != 0 { |
|
|
|
modules := make([]*models.ModuleService, 0) |
|
|
|
err = core.GetXormAuto().Where("is_delete=0").In("id", live.AdaptationFunc).Find(&modules) |
|
|
|
t.CheckErr(err) |
|
|
|
for _, module := range modules { |
|
|
|
if module.Name == define.MODULE_ORDER { |
|
|
|
fs["is_order"] = 1 |
|
|
|
} else if module.Name == define.MODULE_SHAKRB { |
|
|
|
fs["is_shake"] = 1 |
|
|
|
} else if module.Name == define.MODULE_REWARD { |
|
|
|
fs["is_reward"] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
config := new(models.LiveConfigArea) |
|
|
|
exist, err = config.GetByActivityIdAndAreaId(activityId, areaId) |
|
|
@ -58,13 +70,12 @@ func (t *LiveCtl) Detail() { |
|
|
|
|
|
|
|
live.AdminLiveUrl = "" |
|
|
|
live.AreaId = areaId |
|
|
|
live.Adaptation = fs |
|
|
|
t.JSON(live) |
|
|
|
} |
|
|
|
|
|
|
|
func (t *LiveCtl) Like() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
//userId := t.MustGetUID()
|
|
|
|
|
|
|
|
_, err := new(models.LiveConfig).Like(activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|