Browse Source

Merge branch 'cygx_10.7' of http://8.136.199.33:3000/cxzhang/hongze_clpt

xingzai 1 year ago
parent
commit
937e1de887

+ 334 - 15
controllers/activity.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
@@ -22,6 +23,8 @@ type ActivityController struct {
 // @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
 // @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
 // @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @Param   IsExternalLabel   query   int  false       "是否仅展示外部资源 1:是、0:否 默认0"
+// @Param   IsResearchPoints   query   int  false       "是否仅展示研选扣点 1:是、0:否 默认0"
 // @Success 200 {object} models.ActivityTypeListHomeResp
 // @router /labelTypeList [get]
 func (this *ActivityController) LabelTypeList() {
@@ -40,7 +43,10 @@ func (this *ActivityController) LabelTypeList() {
 	isPower, _ := this.GetInt("IsPower")
 	whichDay := this.GetString("WhichDay")
 	activeState := this.GetString("ActiveState")
+	isExternalLabel, _ := this.GetInt("IsExternalLabel")   //
+	isResearchPoints, _ := this.GetInt("IsResearchPoints") //
 	var condition string
+	var conditioninit string
 	var pars []interface{}
 
 	// 查研观向7.4-始终查询宏观的活动
@@ -48,16 +54,80 @@ func (this *ActivityController) LabelTypeList() {
 		chartPermissionIds += ",1"
 	}
 
-	condition += `AND art.activity_time > ?  `
-	pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
+	//condition += `AND art.activity_time > ?  `
+	//pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
+
+	//行业名称
+	if len(chartPermissionIds) > 0 {
+		conditioninit += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	//哪一天
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "2" {
+			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "1,2" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		} else if whichDay == "3,4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		}
+		conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+	}
+
+	//活动状态搜索
+	if activeState != "" {
+		// 默认查看未开始跟进行中
+		if activeState == "1" {
+			conditioninit += ` AND art.active_state  IN (1,2)`
+		} else {
+			conditioninit += ` AND art.active_state  IN (` + activeState + `)`
+		}
+	} else {
+		conditioninit += ` AND art.active_state  IN (1,2)`
+	}
 
-	conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
+	//是否为外部资源
+	if isExternalLabel == 1 {
+		conditioninit += ` AND art.is_external_label = 1 `
+	}
+	if isResearchPoints == 1 {
+		conditioninit += ` AND art.is_research_points = 1 `
+	}
+
+	conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
+	//conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
 		return
 	}
-	condition += `AND art.is_limit_people = 1 ` + conditionActivity
+	condition += ` AND art.is_limit_people = 1 ` + conditionActivity
 	sortTime := ` mintimesort ASC `
 	if activeState == "3" {
 		sortTime = ` timesort DESC  `
@@ -120,6 +190,8 @@ func (this *ActivityController) LabelTypeList() {
 // @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
 // @Param   ActivityId   query   int  false       "活动列表传过来的活动ID"
 // @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
+// @Param   IsExternalLabel   query   int  false       "是否仅展示外部资源 1:是、0:否 默认0"
+// @Param   IsResearchPoints   query   int  false       "是否仅展示研选扣点 1:是、0:否 默认0"
 // @Success 200 {object} models.GetCygxActivityListRep
 // @router /list [get]
 func (this *ActivityController) ActivityListNew() {
@@ -137,7 +209,7 @@ func (this *ActivityController) ActivityListNew() {
 	uid := user.UserId
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
-	source, _ := this.GetInt("Source")
+	//source, _ := this.GetInt("Source")
 	label := this.GetString("Label")
 	chartPermissionIds := this.GetString("ChartPermissionIds")
 	whichDay := this.GetString("WhichDay")
@@ -147,7 +219,10 @@ func (this *ActivityController) ActivityListNew() {
 	keyWord := this.GetString("KeyWord")
 	playBack, _ := this.GetInt("PlayBack")
 	filter, _ := this.GetInt("Filter")
-	activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
+	isPower, _ := this.GetInt("IsPower")
+	activityId, _ := this.GetInt("ActivityId")             // 仅用于判断【新】标签
+	isExternalLabel, _ := this.GetInt("IsExternalLabel")   //
+	isResearchPoints, _ := this.GetInt("IsResearchPoints") //
 
 	var startSize int
 	if pageSize <= 0 {
@@ -158,28 +233,135 @@ func (this *ActivityController) ActivityListNew() {
 	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
+	var conditioninit string //初始化搜索条件
 	var pars []interface{}
-	//var activityList []*models.ActivityDetail
-	//mapDingActivityId := make(map[int]int)
+
+	//主题
+	if label != "" {
+		conditioninit += ` AND art.label  LIKE "%` + label + `%" `
+	}
+	//行业名称
+	if len(chartPermissionIds) > 0 {
+		conditioninit += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	//哪一天
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "2" {
+			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "1,2" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		} else if whichDay == "3,4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		}
+		conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+	}
+
+	//活动状态搜索
+	if activeState != "" {
+		// 默认查看未开始跟进行中
+		if activeState == "1" {
+			conditioninit += ` AND art.active_state  IN (1,2)`
+		} else {
+			conditioninit += ` AND art.active_state  IN (` + activeState + `)`
+		}
+	} else {
+		conditioninit += ` AND art.active_state  IN (1,2)`
+	}
+
+	// 如果是分析师电话会,那么可以连同C类一起查看
+	if activityTypeId != "" {
+		if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
+			conditioninit += `  AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
+		} else {
+			conditioninit += `  AND art.activity_type_id IN (` + activityTypeId + `)`
+		}
+	}
+
+	//关键词搜索
+	if keyWord != "" {
+		conditioninit += ` AND (art.label   REGEXP '` + keyWord + `' OR art.activity_name  REGEXP '` + keyWord + `' ) `
+	}
+
+	//回放
+	if playBack == 1 {
+		//获取所有带回放的活动ID
+		playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
+	}
+
+	//音频视频  1:视频 2:音频
+	if filter > 0 {
+		videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
+	}
+	if isExternalLabel == 1 && isResearchPoints == 1 {
+		conditioninit += ` AND ( art.is_external_label = 1  OR art.is_research_points = 1 )`
+	} else {
+		//是否为外部资源
+		if isExternalLabel == 1 {
+			conditioninit += ` AND art.is_external_label = 1 `
+		}
+		// 是否为研选扣点
+		if isResearchPoints == 1 {
+			conditioninit += ` AND art.is_research_points = 1 `
+		}
+	}
+
 	condition = ""
 	//活动可见限制
-	conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
+	//conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
+	conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
 		return
 	}
-	if source == 1 {
-		condition += ` AND art.yidong_activity_id = '' `
-	}
 
-	condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
+	condition += `  AND art.publish_status = 1 ` + conditionActivity
 	total, err := models.GetActivityCount(condition, playBack, pars, filter)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	//return
 	var conditionOrder string
 	if activeState == "2" || activeState == "3" {
 		conditionOrder = ` ORDER BY art.activity_time DESC  `
@@ -415,7 +597,12 @@ func (this *ActivityController) ActivityListNew() {
 	//if keyWord != "" {
 	//	go services.AddActivitykeyWordSearch(keyWord, user)
 	//}
-
+	if len(activityList) == 0 {
+		activityList = make([]*models.ActivityListResp, 0)
+	}
+	if activityTypeId == "3" || activityTypeId == "5" {
+		resp.IsShowResearchPoints = true
+	}
 	//预处理返给前端的字段
 	resp.List = activityList
 	resp.Paging = page
@@ -476,7 +663,6 @@ func (this *ActivityController) Detail() {
 		return
 	}
 	activityInfo.SignupNum = signupCount
-
 	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -658,6 +844,22 @@ func (this *ActivityController) SignupAdd() {
 	}
 	activityId := req.ActivityId
 	signupType := req.SignupType
+	email := req.Email
+
+	//如果用户传了邮箱就绑定邮箱
+	if email != "" && user.Email == "" {
+		if !utils.ValidateEmailFormatat(req.Email) {
+			br.Msg = "邮箱格式错误,请重新输入"
+			br.ErrMsg = "邮箱格式错误,请重新输入"
+			return
+		}
+		user.Email = req.Email
+		err = models.UpdateUserEmail(email, uid)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "绑定客户邮箱失败!"
+		}
+	}
 	hasPermission := 0
 	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
 		resp.GoBindEmail = true
@@ -711,6 +913,18 @@ func (this *ActivityController) SignupAdd() {
 			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
 			return
 		}
+
+		popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
+			return
+		}
+		if popupMsg != "" {
+			br.Msg = "报名失败!"
+			br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
+			return
+		}
 		//人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
 		//如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
 		//if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
@@ -870,6 +1084,11 @@ func (this *ActivityController) SignupAdd() {
 				go services.ActivityUserRemind(user, activityInfo, 4)
 				resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
 			}
+
+			if activityInfo.IsResearchPoints {
+				resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
+			}
+			go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
 		}
 
 	} else {
@@ -982,6 +1201,12 @@ func (this *ActivityController) SignupCancel() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
+	checkTime, _ := services.CheckSiginupDeadline(activityInfo)
+	if !checkTime {
+		br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
+		br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
+		return
+	}
 	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
 	if time.Now().After(resultTime.Add(-time.Minute * 60)) {
 		if signupType == 1 {
@@ -989,6 +1214,7 @@ func (this *ActivityController) SignupCancel() {
 		} else {
 			br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
 		}
+		br.ErrMsg = br.Msg
 		return
 	}
 	total, err := models.GetActivitySignupCount(uid, activityId)
@@ -1014,6 +1240,7 @@ func (this *ActivityController) SignupCancel() {
 		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
 		return
 	}
+	go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -1721,6 +1948,8 @@ func (this *ActivityController) ActivityListSearch() {
 		item.IsYidongConduct = v.IsYidongConduct
 		item.IsCanOutboundCall = v.IsCanOutboundCall
 		item.IsLimitPeople = v.IsLimitPeople
+		item.IsResearchPoints = v.IsResearchPoints
+		item.SiginupDeadline = v.SiginupDeadline
 		// 判断是否属于研选类型的活动
 		if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 			item.IsResearch = true
@@ -2025,3 +2254,93 @@ func (this *ActivityController) ScheduleList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 活动报名之前的校验(权限、时间、点数、邮箱)
+// @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /check [post]
+func (this *ActivityController) Check() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	//这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
+	resp := new(models.ActivityCheck)
+	hasPermission := 0
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	resp.IsResearchSpecial = isResearchSpecial
+	if havePower {
+		hasPermission = 1
+		resp.CheckPermission = true
+		resp.HasPermission = hasPermission
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
+	}
+	if resp.CheckPermission {
+		//如果权限通过了校验,那么就来校验时间
+		resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
+	}
+	if resp.CheckTime {
+		// 如果时间通过校验就校验点数
+		resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
+			return
+		}
+	}
+
+	if resp.CheckPoints {
+		//如果通过点数的校验,就来校验邮箱
+		resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
+	}
+	// 判断是否属于研选类型的活动
+	if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
+		resp.IsResearch = true
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 1 - 0
controllers/config.go

@@ -35,6 +35,7 @@ func (this *ConfigController) IsShow() {
 	}
 	var resp models.IsShow
 	resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
+	resp.IsShowResearchPoints = true
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp

+ 34 - 1
models/activity.go

@@ -59,6 +59,7 @@ type CygxActivity struct {
 	IsCanAppointmentMinutes int       `description:"是否可预约纪要 1是 ,0 否 默认0 "`
 	YidongActivityId        string    `description:"易董活动ID"`
 	IsExternalLabel         int       `description:"是否为外部资源 1是,0否"`
+	IsResearchPoints        int       `description:"是否为研选扣点"`
 }
 
 // 活动详情
@@ -146,6 +147,10 @@ type ActivityDetail struct {
 	IsCanOutboundCall       int                        `description:"是否提供外呼 1:是 、0:否"`
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	IsResearchSpecial       bool                       `description:"是否属于特殊的研选"`
+	IsNeedEmail             int                        `description:"是否需要提供邮箱 1是,0否"`
+	SiginupDeadline         string                     `description:"报名截止时间"`
+	IsExternalLabel         bool                       `description:"是否为外部资源"`
+	IsResearchPoints        bool                       `description:"是否为研选扣点"`
 }
 
 // 活动详情
@@ -174,6 +179,8 @@ type ActivityListResp struct {
 	OnlineParticipation     string                     `description:"网络参会"`
 	ReportLink              string                     `description:"报告链接"`
 	LinkParticipants        string                     `description:"链接参会"`
+	AppAttendance           string                     `description:"App参会"`
+	ConferencePassword      string                     `description:"会议密码"`
 	City                    string                     `description:"城市"`
 	Address                 string                     `description:"活动地址"`
 	Highlights              string                     `description:"活动亮点"`
@@ -217,6 +224,25 @@ type ActivityListResp struct {
 	IsCanOutboundCall       int                        `description:"是否提供外呼 1:是 、0:否"`
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	IsResearchSpecial       bool                       `description:"是否属于特殊的研选"`
+	IsExternalLabel         bool                       `description:"是否为外部资源"`
+	IsResearchPoints        bool                       `description:"是否为研选扣点"`
+	SiginupDeadline         string                     `description:"报名截止时间"`
+}
+
+type ActivityCheck struct {
+	CheckPermission   bool   `description:"权限是否通过校验"`
+	HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	PopupMsg          string `description:"权限弹窗信息"`
+	SellerMobile      string `description:"销售电话"`
+	SellerName        string `description:"销售姓名"`
+	Mobile            string `description:"手机号"`
+	IsResearch        bool   `description:"是否属于研选"`
+	IsResearchSpecial bool   `description:"是否属于特殊的研选"`
+	CheckTime         bool   `description:"时间是否通过校验"`
+	CheckEmail        bool   `description:"邮箱是否通过校验"`
+	CheckPoints       bool   `description:"扣点是否通过校验"`
+	CompanyPoints     string `description:"公司剩余点数"`
+	ActivityPoints    string `description:"本场活动要扣除的点数"`
 }
 
 type ActivityArticleResp struct {
@@ -238,7 +264,7 @@ type CygxActivityResp struct {
 // 列表
 func GetCygxActivityList(condition string, pars []interface{}, sortTime string, startSize, pageSize int) (items []*CygxActivity, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT	activity_id,city, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id , activity_type_id,is_external_label
+	sql := `SELECT	activity_id,city, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id , activity_type_id,is_external_label,is_research_points
 		FROM cygx_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
@@ -347,6 +373,7 @@ type GetCygxActivityListRep struct {
 	IndustrialManagementId int    `description:"产业ID"`
 	IndustryNewLabel       bool   `description:"产业是否新标签"`
 	ChartPermissionId      int    `description:"权限id"`
+	IsShowResearchPoints   bool   `description:"是否展示研选扣点搜索"`
 }
 
 type GetCygxActivityListSearchResp struct {
@@ -399,6 +426,8 @@ func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditi
             art.is_yidong_conduct,
             art.is_can_outbound_call,
             art.city,
+            art.is_research_points,
+            art.siginup_deadline,
 			art.activity_time 
 		FROM
 			cygx_activity AS art
@@ -432,6 +461,8 @@ func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditi
 			"",
 			"",
 			"",
+			"",
+			"",
 			art.activity_time 
 		FROM
 			cygx_activity_special AS art
@@ -527,6 +558,7 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 			art.city AS city,
 			art.is_yidong_conduct,
 			art.is_can_outbound_call,
+			art.is_research_points,
 			art.host 
 		FROM
 			cygx_activity AS art
@@ -563,6 +595,7 @@ func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpe
 			art.city,
 			"",
 			"",
+			"",
 			art.host 
 		FROM
 			cygx_activity_special AS art

+ 23 - 0
models/activity_points_company.go

@@ -0,0 +1,23 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityPointsCompany struct {
+	Id          int       `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
+	CompanyId   int       `gorm:"column:company_id;default:0" json:"company_id"`  // 公司ID
+	CompanyName string    `gorm:"column:company_name" json:"company_name"`        // 公司名称
+	Points      float64   `gorm:"column:points;default:0;NOT NULL" json:"points"` // 公司剩余点数
+	CreateTime  time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"` // 创建时间
+	ModifyTime  time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"` // 更新时间
+}
+
+// 获取公司剩余点数
+func GetCompanyPoints(companyId int) (comapnyPointsNum float64, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT points FROM cygx_activity_points_company  WHERE company_id=? `
+	err = o.Raw(sql, companyId).QueryRow(&comapnyPointsNum)
+	return
+}

+ 89 - 0
models/activity_points_set.go

@@ -0,0 +1,89 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityPointsSet struct {
+	Id               int       `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
+	ActivityId       int       `gorm:"column:activity_id;NOT NULL" json:"activity_id"`                         // 活动ID
+	PointsObject     int       `gorm:"column:points_object;default:1;NOT NULL" json:"points_object"`           // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
+	CompanyId        int       `gorm:"column:company_id;default:0;NOT NULL" json:"company_id"`                 // 公司ID
+	CompanyName      string    `gorm:"column:company_name;NOT NULL" json:"company_name"`                       // 公司名称
+	UserPointsNum    string    `gorm:"column:user_points_num;default:0;NOT NULL" json:"user_points_num"`       // 参会人扣点数量
+	PointsType       int       `gorm:"column:points_type;default:0;NOT NULL" json:"points_type"`               // 扣点形式,1:报名即扣点,2:到会即扣点
+	CompanyPointsNum string    `gorm:"column:company_points_num;default:0;NOT NULL" json:"company_points_num"` // 办会人扣点数量
+	CreateTime       time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"`                         // 创建时间
+	ModifyTime       time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"`                         // 更新时间
+}
+
+type CygxActivityPointsSetRsq struct {
+	ActivityId       int    `gorm:"column:activity_id;NOT NULL" json:"ActivityId"`                        // 活动ID
+	PointsObject     int    `gorm:"column:points_object;default:1;NOT NULL" json:"PointsObject"`          // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
+	CompanyId        int    `gorm:"column:company_id;default:0;NOT NULL" json:"CompanyId"`                // 公司ID
+	CompanyName      string `gorm:"column:company_name;NOT NULL" json:"CompanyName"`                      // 公司名称
+	UserPointsNum    string `gorm:"column:user_points_num;default:0;NOT NULL" json:"UserPointsNum"`       // 参会人扣点数量
+	PointsType       int    `gorm:"column:points_type;default:0;NOT NULL" json:"PointsType"`              // 扣点形式,1:报名即扣点,2:到会即扣点
+	CompanyPointsNum string `gorm:"column:company_points_num;default:0;NOT NULL" json:"CompanyPointsNum"` // 办会人扣点数量
+}
+
+type YanXuanActivityPointsRedis struct {
+	UserId           int       `description:"用户ID"`
+	ComapnyId        int       `description:"公司ID"`
+	ActivityId       int       `description:"活动ID"`
+	PublishStatus    int       `description:"发布状态 1已发布,0未发布"`
+	SourceType       int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	AdminId          int       `description:"管理员、销售ID"`
+	Source           int       `description:" 来源,1客户端,2后台添加, 3开发人员手动添加、4定时任务"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	CreateTime       time.Time `description:"创建时间"`
+}
+
+type CygxActivityPointsSetConfigListResp struct {
+	List []*CygxActivityPointsSetConfigResp
+}
+
+type CygxActivityPointsSetConfigResp struct {
+	PointsNum string `gorm:"column:user_points_num;default:0;NOT NULL" json:"PointsNum"` // 扣点数量
+}
+
+// 通过活动ID获取详情
+func GetCygxActivityPointsSetDetail(activityId int) (item *CygxActivityPointsSetRsq, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_points_set  WHERE activity_id=? `
+	err = o.Raw(sql, activityId).QueryRow(&item)
+	return
+}
+
+// 通过活动ID获取详情
+func GetCygxActivityPointsSetUserNum(activityId int) (userPointsNum float64, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT user_points_num FROM cygx_activity_points_set  WHERE activity_id=? `
+	err = o.Raw(sql, activityId).QueryRow(&userPointsNum)
+	return
+}
+
+// 通过互动ID获取数量
+func GetCygxActivityPointsSetCountByActivityId(ActivityId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_points_set  WHERE activity_id=?   `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, ActivityId).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxActivityPointsSetList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityPointsSet, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_points_set as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize == 0 {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	} else {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	}
+	return
+}

+ 3 - 2
models/activity_signup.go

@@ -43,8 +43,9 @@ type SignupStatus struct {
 	IsResearchSpecial bool   `description:"是否属于特殊的研选"`
 }
 type ActivitySingnupRep struct {
-	ActivityId int `description:"活动id"`
-	SignupType int `description:"报名方式,,1预约外呼,2自主拨入,3我要报名"`
+	ActivityId int    `description:"活动id"`
+	SignupType int    `description:"报名方式,,1预约外呼,2自主拨入,3我要报名"`
+	Email      string `description:"邮箱号"`
 }
 
 // 我的日程

+ 1 - 0
models/activity_type.go

@@ -53,6 +53,7 @@ type CygxActivityLabelList struct {
 	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
 	YidongActivityId  int    `description:"易董活动ID"`
 	IsExternalLabel   bool   `description:"是否为外部资源"`
+	IsResearchPoints  bool   `description:"是否为研选扣点"`
 	IsShowSubjectName int    `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
 	TemporaryLabel    string `description:"临时标签"`
 	TripStatus        int    `description:"行程进行状态 1:预报名,2:确定行程"`

+ 11 - 0
models/activity_video.go

@@ -134,3 +134,14 @@ type ActivityVideoDetailResp struct {
 	VideoDetail *CygxActivityVideoDetailResp
 	AuthInfo    *UserPermissionAuthInfo
 }
+
+// 获取所有活动视频ID
+func GetActivityVideoActivityIds() (activityIds string, err error) {
+	sql := `SELECT
+				GROUP_CONCAT( DISTINCT a.activity_id SEPARATOR ',' ) AS activityids 
+			FROM
+				cygx_activity_video AS a `
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&activityIds)
+	return
+}

+ 14 - 3
models/activity_voice.go

@@ -77,7 +77,7 @@ func GetCygxActivityVoiceById(videoId int) (item *CygxActivityVoice, err error)
 	return
 }
 
-//列表
+// 列表
 func GetActivityVoiceListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT art.*  FROM cygx_activity as art  INNER JOIN cygx_activity_voice AS v ON v.activity_id = art.activity_id   WHERE 1= 1  `
@@ -89,7 +89,7 @@ func GetActivityVoiceListAll(condition string, pars []interface{}, startSize, pa
 	return
 }
 
-//列表
+// 列表
 func GetActivityVoiceList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVoiceResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -110,4 +110,15 @@ func GetCygxActivityVoiceByActivityId(activityId int) (item *CygxActivityVoice,
 	sql := `SELECT * FROM cygx_activity_voice WHERE activity_id = ? LIMIT 1`
 	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
 	return
-}
+}
+
+// 获取所有活动音频ID
+func GetActivityVoiceActivityIds() (activityIds string, err error) {
+	sql := `SELECT
+				GROUP_CONCAT( DISTINCT a.activity_id SEPARATOR ',' ) AS activityids 
+			FROM
+				cygx_activity_voice AS a `
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&activityIds)
+	return
+}

+ 2 - 1
models/config.go

@@ -86,7 +86,8 @@ type MicroRoadShowDefaultImg struct {
 }
 
 type IsShow struct {
-	IsBelongRai bool `description:"是否属于权益内部人员"`
+	IsBelongRai          bool `description:"是否属于权益内部人员"`
+	IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
 }
 
 // 关于我们

+ 3 - 0
models/resource_data.go

@@ -68,6 +68,9 @@ type CygxResourceDataResp struct {
 	IsCanOutboundCall       int                        `description:"是否提供外呼 1:是 、0:否"`
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	IsResearchSpecial       bool                       `description:"是否属于特殊的研选"`
+	IsExternalLabel         bool                       `description:"是否为外部资源"`
+	IsResearchPoints        bool                       `description:"是否为研选扣点"`
+	SiginupDeadline         string                     `description:"报名截止时间"`
 }
 
 type HomeResourceDataListResp struct {

+ 8 - 0
models/user.go

@@ -352,6 +352,14 @@ func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
 	return
 }
 
+// 更改用户邮箱号
+func UpdateUserEmail(email string, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET email = ? WHERE user_id=? `
+	_, err = o.Raw(sql, email, userId).Exec()
+	return
+}
+
 func GetArticleUserCollectCount(userId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id WHERE a.user_id=? AND art.publish_status = 1  `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)

+ 9 - 0
routers/commentsRouter.go

@@ -34,6 +34,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "Check",
+            Router: `/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
         beego.ControllerComments{
             Method: "Detail",

+ 190 - 44
services/activity.go

@@ -313,6 +313,145 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	return
 }
 
+// 根据用户身份处理活动可见
+func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower int) (conditionActivity string, err error) {
+	condition += `   AND art.publish_status = 1 `
+	conditionActivity = condition
+	//弘则可以查看所有活动
+	if GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID {
+		return
+	}
+	adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
+	if err != nil {
+		return
+	}
+	userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId)
+	if err != nil {
+		return
+	}
+	//判断客户规模是否属于可见范围的活动
+	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	isMaker := user.IsMaker
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	var permissionNameStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			//研选权限处理
+			if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+				permissionNameStr += "'" + v + "',"
+			}
+		} else {
+			permissionNameStr += "'" + v + "',"
+		}
+	}
+	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
+	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
+	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
+	slicePerZhengShi := strings.Split(permissionStrZhengShi, ",")
+	var permissionNameStrZhengShi string
+	for _, v := range slicePerZhengShi {
+		if userType == 1 {
+			//研选权限处理
+			if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+				permissionNameStrZhengShi += "'" + v + "',"
+			}
+		} else {
+			permissionNameStrZhengShi += "'" + v + "',"
+		}
+	}
+	permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(主观)", "", -1)
+	permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(客观)", "", -1)
+	permissionNameStrZhengShi = strings.TrimRight(permissionNameStrZhengShi, ",")
+
+	mapUserType, e := GetActivityCcustomerTypeList()
+	if e != nil {
+		err = e
+		return
+	}
+	var userTypeStr string
+	userTypeStr = mapUserType[userType]
+	fmt.Println("userTypeStr", userTypeStr)
+	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
+	if permissionNameStr == `` {
+		permissionNameStr = `'宏观'`
+	} else {
+		permissionNameStr += `, '宏观'`
+	}
+	var sqlExport string // 专家权限处理
+	sqlExport = ` AND (art.customer_type_ids LIKE '%` + userTypeStr + `%' `
+	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
+	}
+	sqlExport += `) `
+
+	if isPower == 1 {
+		permissionSqlStr = `  AND art.chart_permission_name  IN (` + permissionNameStr + `)`
+		condition += permissionSqlStr
+	}
+
+	var conditionOr string
+
+	//查询全部可见的数据(是否全部客户可见)
+	if adminIds != "" {
+		condition += ` 	AND ( art.visible_range != 1  OR  (	 art.admin_id IN ( ` + adminIds + ` )  AND art.visible_range = 1 ))  `
+	}
+
+	//活动仅决策人可见
+	if isMaker == 0 {
+		condition += ` AND art.is_maker_show = 0  `
+	}
+
+	//condition += `  AND art.visible_range != 1 `
+	if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
+	}
+	if (userType == 5) && strings.Contains(permissionStr, "专家") {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
+	}
+	if userType == 1 {
+		conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
+	} else {
+		conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
+	}
+	if userType == 6 || userType == 7 {
+		conditionOr += ` OR (   art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%'	 ` + condition + `) `
+	}
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
+	}
+
+	conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
+	if e != nil {
+		err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
+		return
+	}
+	// 升级客户可查看范围
+	if conditionShengji != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionShengji + condition + ` ) `
+	}
+	// 正式客户可查看范围
+	if conditionZhengshi != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionZhengshi + condition + ` ) `
+	}
+	// 行业客户可查看范围
+	if conditionHangYe != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionHangYe + condition + ` ) `
+	}
+
+	if userType == 3 {
+		condition += `  AND art.chart_permission_name  IN (` + permissionNameStrZhengShi + `) `
+	}
+	condition += `    AND  art.is_limit_people = 1  `
+	conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
+	return
+}
+
 // 获取可见的活动
 func HandleActivityPowerList(listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.CygxActivity, err error) {
 
@@ -346,9 +485,9 @@ func HandleActivityTypeHomeList(listType []*models.ActivityTypeHome, listActivit
 		if v.ActivityTypeId == 7 {
 			v.ActivityTypeId = 2
 		}
-		if v.ActivityTypeId == 1 {
-			activityIds = append(activityIds, v.ActivityId)
-		}
+		//if v.ActivityTypeId == 1 {
+		activityIds = append(activityIds, v.ActivityId)
+		//}
 	}
 
 	// 活动【新】标签Map
@@ -377,6 +516,10 @@ func HandleActivityTypeHomeList(listType []*models.ActivityTypeHome, listActivit
 		if v.IsExternalLabel > 0 {
 			item.IsExternalLabel = true
 		}
+		if v.IsResearchPoints > 0 {
+			item.IsResearchPoints = true
+		}
+
 		item.City = v.City
 		if utf8.RuneCountInString(v.City) != 2 {
 			item.City = ""
@@ -460,6 +603,9 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem, pe
 	if (articleDetail.ActivityTypeId == 3 || articleDetail.ActivityTypeId == 5) && articleDetail.YidongActivityId == "" && strings.Contains(articleDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
 		articleDetail.IsResearchSpecial = true
 	}
+	if articleDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理
+		articleDetail.SiginupDeadline = ""
+	}
 
 	activityTimeText := articleDetail.ActivityTimeText
 	activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
@@ -511,13 +657,14 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem, pe
 				}
 				articleDetail.IsShowMeetingReminder = true
 			}
-			//公司调研电话会 3
+
 			if articleDetail.ActivityTypeId == 3 {
-				if articleDetail.LimitPeopleNum == 0 {
+				//司调研电话会(3)、扣点的研选活动只展示我要报名
+				if articleDetail.IsResearchPoints || articleDetail.LimitPeopleNum > 0 {
+					articleDetail.IsShowSignup = true
+				} else {
 					articleDetail.IsShowMeetingReminder = true
 					articleDetail.IsShowOutboundCall = true
-				} else {
-					articleDetail.IsShowSignup = true
 				}
 			}
 
@@ -578,6 +725,8 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem, pe
 		ActivityName:            v.ActivityName,
 		OnlineParticipation:     v.OnlineParticipation,
 		ReportLink:              v.ReportLink,
+		AppAttendance:           v.AppAttendance,
+		ConferencePassword:      v.ConferencePassword,
 		City:                    v.City,
 		Address:                 v.Address,
 		Highlights:              v.Highlights,
@@ -617,6 +766,9 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem, pe
 		TencentConferenceNumber: v.TencentConferenceNumber,
 		IsResearchSpecial:       v.IsResearchSpecial,
 		LinkParticipants:        v.LinkParticipants,
+		IsResearchPoints:        v.IsResearchPoints,
+		IsExternalLabel:         v.IsExternalLabel,
+		SiginupDeadline:         v.SiginupDeadline,
 	}
 	au := new(models.UserPermissionAuthInfo)
 	au.SellerName = authInfo.SellerName
@@ -677,24 +829,6 @@ func ActivityDetaailShow(activityInfo *models.ActivityListResp) (itemActivity *m
 	if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
 		activityInfo.SignupNum = activityInfo.LimitPeopleNum
 	}
-	//if activityInfo.ReportLink != "" {
-	//	artList := strings.Split(activityInfo.ReportLink, "{|}")
-	//	if len(artList) > 0 {
-	//		for _, v := range artList {
-	//			artitem := new(models.ActivityArticleResp)
-	//			artitem.ReportLink = v
-	//			artIdSlice := strings.Split(v, "/")
-	//			if len(artIdSlice) > 0 {
-	//				articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
-	//				artitem.ArticleId = articleId
-	//			}
-	//			activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
-	//		}
-	//	}
-	//} else {
-	//	activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
-	//}
-
 	if activityInfo.ReportLink != "" {
 		artList, e := GetActivityReportLinkToArticleList(activityInfo)
 		if e != nil && e.Error() != utils.ErrNoRow() {
@@ -720,11 +854,10 @@ func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryN
 	if len(activityIds) == 0 {
 		return
 	}
-
 	// 获取活动关联的产业
 	var groupCond string
 	var groupPars []interface{}
-	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1  AND  a.active_state != 3 `
+	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 `
 	groupPars = append(groupPars, activityIds)
 	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
 	if e != nil {
@@ -744,7 +877,6 @@ func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryN
 		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
 		return
 	}
-
 	// 判断活动是否为新
 	for k := range industryLabelMap {
 		for k2, v2 := range activityIndustryMap {
@@ -769,9 +901,8 @@ func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryN
 		return
 	}
 	for k := range articNewLabel {
-		labelMap[k] = false
+		labelMap[k] = true
 	}
-
 	return
 }
 
@@ -791,6 +922,10 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
 		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
 		timePars = append(timePars, industryIds)
 	}
+	//只要弘则报告,不要研选报告
+	timeCond += ` AND b.article_id < ? `
+	timePars = append(timePars, utils.SummaryArticleId)
+
 	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
 	if e != nil {
 		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
@@ -825,7 +960,9 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
 func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower, isResearchSpecial bool, err error) {
 	var companyDetailStatus string
 	var userTypeStr string
-	if GetBelongingRai(user.Mobile) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
+
+	//如果是弘则的用户或者宏观的权限不做校验
+	if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
 		havePower = true
 		return
 	}
@@ -838,17 +975,26 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 	if (activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5) && activityInfo.YidongActivityId == "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 		isResearchSpecial = true
 	}
-	//如果是 公司调研电话会:3,或 专家线下沙龙:5  而且  除易董同步过来的以外的研选类型活动,必须要有研选的正式权限
-	if isResearchSpecial {
-		if !strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_YANXUAN) {
-			//如果连试用权限都没有,那么久按照普通的研选样式展示
-			isResearchSpecial = false
-		}
-		if !strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
-			havePower = false
+	//如果是 对用户的研选扣点的必须要有研选的正式权限
+	if activityInfo.IsResearchPoints {
+		//获取活动对用户要扣的点
+		userPointsNum, e := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId)
+		if e != nil {
+			err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error())
 			return
 		}
+		if userPointsNum > 0 {
+			if !strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_YANXUAN) {
+				//如果连试用权限都没有,那么久按照普通的研选样式展示
+				isResearchSpecial = false
+			}
+			if !strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
+				havePower = false
+				return
+			}
+		}
 	}
+
 	//处理决策人可见权限
 	if user.IsMaker == 0 && activityInfo.IsMakerShow == 1 {
 		havePower = false
@@ -874,16 +1020,15 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 			return
 		}
 	}
-
 	if permissionStr == "" {
 		return
 	}
-
 	//如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情
 	if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 		havePower = true
 		return
 	}
+
 	//医药消费,科技,智造四大行业,验证主客观。如果主客观校验不通过,那么直接返回
 	if strings.Contains(utils.YI_YAO_NAME+utils.XIAO_FEI_NAME+utils.KE_JI_NAME+utils.ZHI_ZAO_NAME, activityInfo.ChartPermissionName) {
 		if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 {
@@ -967,11 +1112,14 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 	} else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
 		havePower = true
 	}
+
+	fmt.Println(permissionStrZhengShi)
 	//if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
 	//	havePower = true
 	//	return
 	//}
 	if strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略" {
+
 		if strings.Contains(activityInfo.CustomerTypeIds, "5") {
 			if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
 				havePower = true
@@ -990,9 +1138,7 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 		err = errs
 		return
 	}
-	//if strings.Contains(permissionShengji, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
-	//	havePower = true
-	//}
+
 	//fmt.Println("主客观2", havePower)
 	//if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
 	//	havePower = true

+ 7 - 3
services/activity_button.go

@@ -303,6 +303,9 @@ func ActivityButtonShowSearch(item *models.ActivityDetail, user *models.WxUserIt
 	//if articleDetail.IsHideAppointment == 0 {
 	//	articleDetail.IsShowAppointment = IsShowAppointmentByactivityInfo(articleDetail, articleDetail.ChartPermissionName)
 	//}
+	if articleDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理
+		articleDetail.SiginupDeadline = ""
+	}
 
 	//articleDetail.SourceType = 1
 	activityTimeText := articleDetail.ActivityTimeText
@@ -357,11 +360,12 @@ func ActivityButtonShowSearch(item *models.ActivityDetail, user *models.WxUserIt
 
 			//公司调研电话会 3
 			if articleDetail.ActivityTypeId == 3 {
-				if articleDetail.LimitPeopleNum == 0 {
+				//司调研电话会(3)、扣点的研选活动只展示我要报名
+				if articleDetail.IsResearchPoints || articleDetail.LimitPeopleNum > 0 {
+					articleDetail.IsShowSignup = true
+				} else {
 					articleDetail.IsShowMeetingReminder = true
 					articleDetail.IsShowOutboundCall = true
-				} else {
-					articleDetail.IsShowSignup = true
 				}
 			}
 

+ 52 - 0
services/activity_points.go

@@ -0,0 +1,52 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+//func init() {
+//	GetActivityPointsAll()
+//}
+
+// 用户报名添加到处理研选扣点
+func YanXuanActivityPointsBillSignupAdd(activityId, uid int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
+			go utils.SendAlarmMsg("用户报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 1, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
+		if err != nil {
+			fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
+// 用户取消报名添加到处理研选扣点
+func YanXuanActivityPointsBillSignupCancel(activityId, uid int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
+			go utils.SendAlarmMsg("用户取消报名添加到处理研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。"`
+	log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 2, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
+		if err != nil {
+			fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}

+ 71 - 0
services/activity_signup.go

@@ -2,8 +2,10 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
+	"time"
 )
 
 // GetActivitySignupResp 处理用户的报名方式
@@ -73,3 +75,72 @@ func CheckActivitySignUpLimit(user *models.WxUserItem, activityInfo *models.Acti
 	return
 
 }
+
+// 校验报名截止时间
+func CheckSiginupDeadline(activityInfo *models.ActivityDetail) (checkTime bool, popupMsg string) {
+	checkTime = true
+	if activityInfo.SiginupDeadline != utils.FormatDateTimeInit {
+		timeResp := utils.StrTimeToTime(activityInfo.SiginupDeadline)
+		fmt.Println(timeResp)
+		if timeResp.Before(time.Now()) {
+			checkTime = false
+			popupMsg = "该活动已截止报名\n\n若想参加,请联系对口销售"
+		}
+	}
+	return
+}
+
+// 校验报名点数
+func CheckActivityPoints(activityInfo *models.ActivityDetail, wxUser *models.WxUserItem) (checkPoints bool, popupMsg, companyPoints, activityPoints string, err error) {
+	checkPoints = true
+	if activityInfo.IsResearchPoints {
+		//获取活动对用户要扣的点
+		userPointsNum, e := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId)
+		if e != nil {
+			err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error())
+			return
+		}
+		// 获取用户所在公司剩余的点
+		companyPointsNum, e := models.GetCompanyPoints(wxUser.CompanyId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetCompanyPoints, Err: " + e.Error())
+			return
+		}
+		if companyPointsNum-userPointsNum < 0 {
+			checkPoints = false
+			popupMsg = "点数不足,若想报名,\n请联系对口销售充值"
+		}
+		companyPoints = fmt.Sprint(companyPointsNum)
+		activityPoints = fmt.Sprint(userPointsNum)
+	}
+	return
+}
+
+// 校验报名是否需要绑定邮箱
+func CheckActivityUserEmail(activityInfo *models.ActivityDetail, wxUser *models.WxUserItem) (checkEmail bool, popupMsg string) {
+	checkEmail = true
+	if activityInfo.IsNeedEmail == 1 {
+		if wxUser.Email == "" {
+			checkEmail = false
+			popupMsg = "应上市公司要求,该会议报名需\n提供邮箱,请填写您的工作邮箱"
+		}
+	}
+	return
+}
+
+// 校验报名是否需要绑定邮箱
+func CheckActivityUserAll(activityInfo *models.ActivityDetail, wxUser *models.WxUserItem) (popupMsg string, err error) {
+	_, popupMsg = CheckSiginupDeadline(activityInfo)
+	if popupMsg != "" {
+		return
+	}
+	_, popupMsg, _, _, err = CheckActivityPoints(activityInfo, wxUser)
+	if popupMsg != "" {
+		return
+	}
+	_, popupMsg = CheckActivityUserEmail(activityInfo, wxUser)
+	if popupMsg != "" {
+		return
+	}
+	return
+}

+ 73 - 0
services/activity_video.go

@@ -0,0 +1,73 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+)
+
+// GetActivityPlayBackActivityIds 获取带有回放的所有的活动ID
+func GetActivityPlayBackActivityIds() (activityIds string, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
+		}
+	}()
+	//获取所有活动视频ID
+	vidoeActivityIds, e := models.GetActivityVideoActivityIds()
+	if e != nil {
+		err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
+		return
+	}
+	//如果没有就赋值为0,避免空查询报错
+	if vidoeActivityIds == "" {
+		vidoeActivityIds = "0"
+	}
+
+	//获取所有活动视频ID
+	voiceActivityIds, e := models.GetActivityVoiceActivityIds()
+	if e != nil {
+		err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
+		return
+	}
+	if voiceActivityIds == "" {
+		voiceActivityIds = "0"
+	}
+	activityIds = vidoeActivityIds + "," + voiceActivityIds
+	return
+}
+
+// GetActivityVideoOrVoiceActivityIds 获取音频或者视频的活动ID
+func GetActivityVideoOrVoiceActivityIds(filter int) (activityIds string, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
+		}
+	}()
+
+	if filter == 1 {
+		//获取所有活动视频ID
+		vidoeActivityIds, e := models.GetActivityVideoActivityIds()
+		if e != nil {
+			err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
+			return
+		}
+		//如果没有就赋值为0,避免空查询报错
+		if vidoeActivityIds == "" {
+			vidoeActivityIds = "0"
+		}
+		activityIds = vidoeActivityIds
+	} else {
+		//获取所有活动视频ID
+		voiceActivityIds, e := models.GetActivityVoiceActivityIds()
+		if e != nil {
+			err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
+			return
+		}
+		if voiceActivityIds == "" {
+			voiceActivityIds = "0"
+		}
+		activityIds = voiceActivityIds
+	}
+	return
+}

+ 0 - 1
services/article.go

@@ -260,7 +260,6 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	for _, v := range industrialList {
 		industrialIds = append(industrialIds, v.IndustrialManagementId)
 	}
-
 	// 获取活动关联的产业
 	var groupCond string
 	var groupPars []interface{}

+ 4 - 2
utils/constants.go

@@ -12,6 +12,7 @@ const (
 	HlbFormatDateTime      = "2006-01-02_15:04:05.999" //完整时间格式
 	FormatDateTimeNoSecond = "2006-01-02 15:04"        //完整时间格式
 	FormatDateTimeUnSpace  = "20060102150405"          //完整时间格式
+	FormatDateTimeInit     = "0000-00-00 00:00:00"     //为空的初始化时间格式
 	FormatYearDate         = "2006"                    //日期格式
 	PageSize15             = 15                        //列表页每页数据量
 	PageSize5              = 5
@@ -141,8 +142,9 @@ const (
 	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
 )
 const (
-	YD_TOKEN            = "yidong_token"
-	CYGX_USER_KEY_LABEL = "CYGX_USER_KEY_LABEL" //查研观向用户标签
+	YD_TOKEN                = "yidong_token"
+	CYGX_USER_KEY_LABEL     = "CYGX_USER_KEY_LABEL"     //查研观向用户标签
+	CYGX_YANXUAN_POINTS_KEY = "CYGX_YANXUAN_POINTS_KEY" //查研观向研选活动扣点KEY
 )
 
 // 邀请机构标识