diff --git a/controllers/client/live.go b/controllers/client/live.go index 75168cd..de92aff 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -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) diff --git a/controllers/client/sign.go b/controllers/client/sign.go index fe8ac9c..c9aa0e0 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -62,6 +62,34 @@ func (t *SignCtl) CheckSign() { t.JSON(signExist) } +func (t *SignCtl) Setting() { + activityId := t.MustGetInt64("activity_id") + + service := new(models.ModuleService) + exist, err := service.GetByName(define.MODULE_SIGNIN) + t.CheckErr(err) + t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "签到模块不存在") + histories := make([]*models.ModuleServiceHistory, 0) + err = core.GetXormAuto().Where("is_delete=0 and service_module_id=? and name=?", service.Id, service.Name).Find(&histories) + t.CheckErr(err) + historyIds := make([]int64, 0) + for _, history := range histories { + historyIds = append(historyIds, history.Id) + } + module := new(models.ActivityModuleService) + exist, err = core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).In("service_module_history_id", historyIds).Get(module) + t.CheckErr(err) + t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "签到模块不存在") + + phoneBg := "" + if module.PhoneBgSwitch == define.StatusOpen { + phoneBg = module.PhoneBgUrl + } + t.JSON(map[string]interface{}{ + "phone_bg": phoneBg, + }) +} + //签到动作 func (t *SignCtl) Sign() { uid := t.MustGetUID() diff --git a/models/live_config.go b/models/live_config.go index df11558..b382e4c 100644 --- a/models/live_config.go +++ b/models/live_config.go @@ -40,6 +40,8 @@ type LiveConfig struct { LikeNum int `json:"like_num" xorm:"not null default 0 comment('点赞数') INT(11)"` ImGroupId string `json:"im_group_id" xorm:"not null default '' comment('腾讯im聊天群id') VARCHAR(255)"` ImGroupName string `json:"im_group_name" xorm:"not null default '' comment('聊天群名称') VARCHAR(255)"` + // live adaptation + Adaptation interface{} `json:"adaptation" xorm:"-"` } func (t *LiveConfig) TableName() string { diff --git a/utils/code/code.go b/utils/code/code.go index 1de23bf..c3c5ec1 100644 --- a/utils/code/code.go +++ b/utils/code/code.go @@ -12,6 +12,7 @@ const ( MSG_CUSTOMER_NOT_EXIST = 700 MSG_AREASTORE_NOT_EXIST = 800 MSG_ENTRYPEOPLE_NOT_EXIST = 900 + MSG_LIVE_CONFIG_NOT_EXIST = 999 // 直播不存在 MSG_ACTIVITY_NOT_EXIST = 1000 // 互动不存在 MSG_MODULE_NOT_EXIST = 1001 // 模块活动不存在 MSG_MODULE_STATUS_END = 1002 // 该模块活动已结束 @@ -38,6 +39,7 @@ const ( MSG_SIGN_HISTORY_EXIST = 5001 // 签到存在 MSG_SIGN_UP_REHEARSAL_LIMIT = 5002 // 签到彩排人数限制 MSG_SIGN_REAL_NOT_EXIST = 5004 // 实名签到json_list 不存在 + MSG_SIGN_MODULE_NOT_EXIST = 5005 // 签到模块 MSG_BULLY_SCREEN_SERVER_NOT_EXIST = 6000 // 霸屏 不存在 MSG_BARRAGE_SERVER_NOT_EXIST = 6001 // 弹幕 不存在 MSG_REWARD_NOT_EXIST = 6002 // 打赏不存