zhangchuanxing пре 3 месеци
родитељ
комит
d2103c5e39

+ 520 - 20
controllers/report.go

@@ -122,6 +122,7 @@ func (this *ReportController) TradeList() {
 // @Param   OrderColumn   query   int  true       "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
 // @Param   DeepCover   query   int  false       "深度覆盖:0-否;1-是"
 // @Param   RecommendFocus   query   int  false       "推荐关注:0-否;1-是"
+// @Param   IsOpen   query   int  true       "是否展开:0-否;1-是,默认0"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.IndustrialManagementList
@@ -151,6 +152,7 @@ func (this *ReportController) IndustryList() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	deepCover, _ := this.GetInt("DeepCover")
 	recommendFocus, _ := this.GetInt("RecommendFocus")
+	isOpen, _ := this.GetInt("IsOpen")
 	var orderSrt string
 	var condition string
 	var startSize int
@@ -208,6 +210,28 @@ func (this *ReportController) IndustryList() {
 	if recommendFocus == 1 {
 		condition += ` AND man.recommended_index >= 80`
 	}
+	var industrialFollow []string                                                  //重点关注ID
+	var industrialUninterested []string                                            //重点关注ID
+	followTypeMap := services.GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
+	for k, v := range followTypeMap {
+		if v == 1 {
+			industrialFollow = append(industrialFollow, strconv.Itoa(k))
+		}
+		if v == 3 {
+			industrialUninterested = append(industrialUninterested, strconv.Itoa(k))
+		}
+	}
+	//如果不感兴趣有值,而且展开按钮没有展开,就放出展开按钮
+	if len(industrialUninterested) > 0 && isOpen == 0 {
+		resp.IsShowOpen = true
+	}
+	industrialUninterested = append(industrialUninterested, "0")
+	//是否展开,展开部分仅展示,不感兴趣的
+	if isOpen == 0 {
+		condition += ` AND man.industrial_management_id  NOT IN (` + strings.Join(industrialUninterested, ",") + `)  `
+	} else {
+		condition += ` AND man.industrial_management_id  IN (` + strings.Join(industrialUninterested, ",") + `)  `
+	}
 
 	// 列表总数据量
 	var list []*models.IndustrialManagement
@@ -869,6 +893,7 @@ func (this *ReportController) Fllow() {
 		return
 	}
 	industrialManagementId := req.IndustrialManagementId
+	followType := req.FollowType
 	var condition string
 	countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
 	if err != nil {
@@ -894,6 +919,7 @@ func (this *ReportController) Fllow() {
 	}
 	item := new(models.CygxIndustryFllow)
 	item.IndustrialManagementId = industrialManagementId
+	item.FollowType = followType
 	item.UserId = uid
 	item.Email = user.Email
 	item.Mobile = user.Mobile
@@ -901,28 +927,21 @@ func (this *ReportController) Fllow() {
 	item.Source = utils.REGISTER_PLATFORM
 	item.CompanyId = user.CompanyId
 	item.CompanyName = user.CompanyName
-	if count == 0 {
-		item.Type = 1
-		item.CreateTime = time.Now()
-		item.ModifyTime = time.Now()
-		_, err = models.AddCygxIndustryFllow(item)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "操作失败,Err:" + err.Error()
-			return
-		}
-		resp.Status = 1
-	} else {
-		item.Type = 2
-		err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "取消关注失败,Err:" + err.Error()
-			return
-		}
+
+	//if count == 0 {
+	item.Type = 1
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	_, err = models.AddCygxIndustryFllow(item)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
 	}
+	resp.Status = followType
+	br.Msg = "操作成功"
 
-	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)       //处理是否关注全部赛道字段
+	//go services.IndustryFllowWithTrack(industrialManagementId, count, uid)       //处理是否关注全部赛道字段
 	go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
 	go services.AddCygxIndustryFllowLog(item)                                    //添加操作日志记录
 	br.Msg = "操作成功"
@@ -4103,3 +4122,484 @@ func (this *ReportController) ZhouqiTacticsList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 获取用户的选择详情
+// @Description 获取用户的选择详情接口
+// @Success 200 {object}  models.CygxXzsChooseSendResp
+// @router /choose/detail [get]
+func (this *ReportController) ChooseDetail() {
+	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
+	}
+	resp := new(models.CygxXzsChooseSendResp)
+	var condition string
+	var pars []interface{}
+	mobile := user.Mobile
+	if mobile == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+	}
+	permissionId, err := models.GetCompanyPermissionId(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetCompanyPermissionId,Err:" + err.Error()
+		return
+	}
+	if permissionId == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+	}
+	//mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
+	mapIndustrialFollow := make(map[int][]*models.IndustrialManagementRep)       // 重点关注的行业下的数组结构
+	mapIndustrialPush := make(map[int][]*models.IndustrialManagementRep)         // 接受推送的行业下的数组结构
+	mapIndustrialUninterested := make(map[int][]*models.IndustrialManagementRep) // 不感兴趣的行业下的数组结构
+	//mapFllow := make(map[int]int)
+	checkListFollow := make(map[int]int)       // 重点关注的ID
+	checkListPush := make(map[int]int)         // 接受推送的ID
+	checkListUninterested := make(map[int]int) // 不感兴趣的ID
+	mapCategory := make(map[int]int)
+	//ampCheckList := make(map[int][]int, 0)
+	ampCheckListFollow := make(map[int][]int, 0)       // 重点关注的ID
+	ampCheckListPush := make(map[int][]int, 0)         // 接受推送的ID
+	ampCheckListUninterested := make(map[int][]int, 0) // 不感兴趣的ID
+	//permissionIdList := make([]string, 0)
+	fllowList, err := models.GetCygxIndustryFllowListByMobile(mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range fllowList {
+		switch v.FollowType {
+		case 1:
+			checkListFollow[v.IndustrialManagementId] = v.IndustrialManagementId
+		case 0:
+			checkListPush[v.IndustrialManagementId] = v.IndustrialManagementId
+		case 3:
+			checkListUninterested[v.IndustrialManagementId] = v.IndustrialManagementId
+		}
+	}
+
+	industrialList, err := models.GetindustrialManagement()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range industrialList {
+		if v.ChartPermissionId == utils.ZHOU_QI_ID {
+			continue
+		}
+		v.IsFllow = true
+		if checkListFollow[v.IndustrialManagementId] > 0 {
+			//添加重点关注的行业赛道
+			ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
+		} else if checkListUninterested[v.IndustrialManagementId] > 0 {
+			//添加不感兴趣的行业赛道
+			ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
+		} else {
+			//添加接受推送的行业赛道
+			mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
+			ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
+		}
+	}
+
+	slicepermissionId := strings.Split(permissionId, ",")
+
+	permissionList, err := models.GetChartPermissionAllXzs(condition, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
+
+	//策略固收的处理
+	categoryListFollow, err := models.GetCygxXzsChooseCategoryList(mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+	checkListCelueFollow := make(map[int]int)       // 重点关注的ID
+	checkListCeluePush := make(map[int]int)         // 接受推送的ID
+	checkListCelueUninterested := make(map[int]int) // 不感兴趣的ID
+	for _, v := range categoryListFollow {
+		//mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
+		switch v.FollowType {
+		case 1:
+			checkListCelueFollow[v.CategoryId] = v.CategoryId
+		case 0:
+			checkListCeluePush[v.CategoryId] = v.CategoryId
+		case 3:
+			checkListCelueUninterested[v.CategoryId] = v.CategoryId
+		}
+	}
+
+	for _, v := range categoryListFollow {
+		mapCategory[v.CategoryId] = v.CategoryId
+	}
+	celueList, err := models.GetReportMappingStrategyAllXzs()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range celueList {
+		v.IsFllow = true
+		if checkListCelueFollow[v.IndustrialManagementId] > 0 {
+			//添加重点关注的行业赛道
+			ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
+		} else if checkListCelueUninterested[v.IndustrialManagementId] > 0 {
+			//添加不感兴趣的行业赛道
+			ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
+		} else {
+			//添加接受推送的行业赛道
+			mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
+			ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
+		}
+	}
+	//策略、固收的处理 end
+
+	//周期的处理
+	zhouqiListFollow, err := models.GetCygxXzsChooseCategoryZhouqiList(mobile)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+	checkListZhouqiFollow := make(map[int]int)       // 重点关注的ID
+	checkListZhouqiPush := make(map[int]int)         // 接受推送的ID
+	checkListZhouqiUninterested := make(map[int]int) // 不感兴趣的ID
+	for _, v := range zhouqiListFollow {
+		//mapFllow[v.IndustrialManagementId] = v.IndustrialManagementId
+		switch v.FollowType {
+		case 1:
+			checkListZhouqiFollow[v.CategoryId] = v.CategoryId
+		case 0:
+			checkListZhouqiPush[v.CategoryId] = v.CategoryId
+		case 3:
+			checkListZhouqiUninterested[v.CategoryId] = v.CategoryId
+		}
+	}
+
+	zhouqiList, err := models.GetCygxZhouqiArticleMapFirst()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
+
+	for _, vZhouqi := range zhouqiList {
+		v := new(models.IndustrialManagementRep)
+		v.IsFllow = true
+		v.IndustrialManagementId = vZhouqi.CategoryId
+		v.IndustryName = vZhouqi.MatchTypeName
+		v.ChartPermissionId = utils.ZHOU_QI_ID
+		if checkListZhouqiFollow[v.IndustrialManagementId] > 0 {
+			//添加重点关注的行业赛道
+			ampCheckListFollow[v.ChartPermissionId] = append(ampCheckListFollow[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialFollow[v.ChartPermissionId] = append(mapIndustrialFollow[v.ChartPermissionId], v)
+		} else if checkListZhouqiUninterested[v.IndustrialManagementId] > 0 {
+			//添加不感兴趣的行业赛道
+			ampCheckListUninterested[v.ChartPermissionId] = append(ampCheckListUninterested[v.ChartPermissionId], v.IndustrialManagementId)
+			mapIndustrialUninterested[v.ChartPermissionId] = append(mapIndustrialUninterested[v.ChartPermissionId], v)
+		} else {
+			//添加接受推送的行业赛道
+			mapIndustrialPush[v.ChartPermissionId] = append(mapIndustrialPush[v.ChartPermissionId], v)
+			ampCheckListPush[v.ChartPermissionId] = append(ampCheckListPush[v.ChartPermissionId], v.IndustrialManagementId)
+		}
+	}
+	//周期的处理end
+
+	for k, v := range permissionList {
+		if len(mapIndustrialFollow[v.ChartPermissionId]) == 0 {
+			permissionList[k].ListFollow = make([]*models.IndustrialManagementRep, 0)
+		} else {
+			permissionList[k].ListFollow = mapIndustrialFollow[v.ChartPermissionId]
+		}
+
+		if len(mapIndustrialPush[v.ChartPermissionId]) == 0 {
+			permissionList[k].ListPush = make([]*models.IndustrialManagementRep, 0)
+		} else {
+			permissionList[k].ListPush = mapIndustrialPush[v.ChartPermissionId]
+		}
+
+		if len(mapIndustrialUninterested[v.ChartPermissionId]) == 0 {
+			permissionList[k].ListUninterested = make([]*models.IndustrialManagementRep, 0)
+		} else {
+			permissionList[k].ListUninterested = mapIndustrialUninterested[v.ChartPermissionId]
+		}
+
+		if len(ampCheckListFollow[v.ChartPermissionId]) == 0 {
+			permissionList[k].CheckListFollow = make([]int, 0)
+		} else {
+			permissionList[k].CheckListFollow = ampCheckListFollow[v.ChartPermissionId]
+		}
+
+		if len(ampCheckListPush[v.ChartPermissionId]) == 0 {
+			permissionList[k].CheckListPush = make([]int, 0)
+		} else {
+			permissionList[k].CheckListPush = ampCheckListPush[v.ChartPermissionId]
+		}
+
+		if len(ampCheckListUninterested[v.ChartPermissionId]) == 0 {
+			permissionList[k].CheckListUninterested = make([]int, 0)
+		} else {
+			permissionList[k].CheckListUninterested = ampCheckListUninterested[v.ChartPermissionId]
+		}
+
+		v.HasCheck = utils.InArrayByStr(slicepermissionId, strconv.Itoa(v.ChartPermissionId))
+	}
+	count, err := models.GetXzsChooseSendCountByMobile(mobile)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
+		return
+	}
+	if count == 0 {
+		resp.IsObjective = 1
+		resp.IsSubjective = 1
+	} else {
+		detail, err := models.GetCygxXzsChooseSendByMobile(mobile)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetCygxXzsChooseSendByMobile,Err:" + err.Error()
+			return
+		}
+		resp.IsObjective = detail.IsObjective
+		resp.IsSubjective = detail.IsSubjective
+		resp.IsRefuse = detail.IsRefuse
+	}
+
+	resp.IsPush = 1 - resp.IsRefuse
+	resp.List = permissionList
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 提交用户的选择关注的类型
+// @Description 提交用户的选择关注的类型接口
+// @Param	request	body models.SubmitChooseSendResp true "type json string"
+// @Success 200 {object}  models.CygxXzsChooseSendResp
+// @router /choose/submit_follow_type [post]
+func (this *ReportController) ChooseSubmitFollowType() {
+	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
+	}
+	if user.Mobile == "" {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "提交失败,手机号不能为空"
+		return
+	}
+	var req models.SubmitChooseSendFollowTypeResp
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	listMap, err := models.GetCygxXzsChooseCategoryMapList()
+	if err != nil {
+		br.Msg = "操作失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	mapReport := make(map[int]int)
+	for _, v := range listMap {
+		mapReport[v.CategoryId] = v.Id
+	}
+
+	followType := req.FollowType
+	listReq := req.List
+
+	var itemsFllow []*models.CygxIndustryFllow
+	var itemsCategory []*models.CygxXzsChooseCategory
+	var itemsZhouqi []*models.CygxXzsChooseCategoryZhouqi
+
+	var zhouqiIds []int
+	var celueIds []int
+	var industryIds []int
+	for _, vChartPermissionn := range listReq {
+		if vChartPermissionn.ChartPermissionName == utils.CE_LUE_NAME || vChartPermissionn.ChartPermissionName == utils.GU_SHOU_NAME {
+			//策略与固收
+			for _, v := range vChartPermissionn.CheckList {
+				item := new(models.CygxXzsChooseCategory)
+				categoryId := v
+				item.CategoryId = v
+				item.IdCygx = mapReport[categoryId]
+				item.UserId = user.UserId
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.RealName = user.RealName
+				item.FollowType = followType
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				itemsCategory = append(itemsCategory, item)
+				celueIds = append(celueIds, v)
+			}
+		} else if vChartPermissionn.ChartPermissionName == utils.ZHOU_QI_NAME {
+			//周期
+			for _, v := range vChartPermissionn.CheckList {
+				item := new(models.CygxXzsChooseCategoryZhouqi)
+				item.CategoryId = v
+				item.UserId = user.UserId
+				item.Email = user.Email
+				item.Mobile = user.Mobile
+				item.RealName = user.RealName
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.FollowType = followType
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				itemsZhouqi = append(itemsZhouqi, item)
+				zhouqiIds = append(zhouqiIds, v)
+			}
+		} else {
+			//正常带有产业的行业
+			for _, v := range vChartPermissionn.CheckList {
+				item := new(models.CygxIndustryFllow)
+				item.IndustrialManagementId = v
+				item.UserId = user.UserId
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.RealName = user.RealName
+				item.Type = 1
+				item.FollowType = followType
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				item.Source = 2
+				itemsFllow = append(itemsFllow, item)
+				industryIds = append(industryIds, v)
+			}
+		}
+	}
+
+	err = models.AddCygxXzsChooseSendFollow(user.Mobile, itemsFllow, itemsCategory, itemsZhouqi, industryIds, celueIds, zhouqiIds)
+	if err != nil {
+		br.Msg = "保存失败!"
+		br.ErrMsg = "保存失败!,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 推送更新内容
+// @Description 推送更新内容接口
+// @Param	request	body models.SubmitChooseSendResp true "type json string"
+// @Success 200 {object}  models.CygxXzsChooseSendResp
+// @router /choose/submit_push [post]
+func (this *ReportController) ChooseSubmitPush() {
+	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
+	}
+	if user.Mobile == "" {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "提交失败,手机号不能为空"
+		return
+	}
+	var req models.SubmitChooseSendResp
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	isPush := req.IsPush // 是否接受推送
+	isRefuse := req.IsRefuse
+	isSubjective := req.IsSubjective
+	isObjective := req.IsObjective
+
+	isRefuse = 1 - isPush // 是否拒绝推送,与是否接收推送进行取反(兼容老的数据库字段)
+	if isRefuse == 0 && isSubjective == 0 && isObjective == 0 {
+		br.Msg = "请至少选择一项主客观内容"
+		return
+	}
+
+	//如果为1 则不做任何推送 ,主观客观默认改成0
+	if isRefuse == 1 {
+		isSubjective = 0
+		isObjective = 0
+	}
+	mobile := user.Mobile
+	item := new(models.CygxXzsChooseSend)
+	item.UserId = user.UserId
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.RealName = user.RealName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.IsRefuse = req.IsRefuse
+	item.IsSubjective = isSubjective
+	item.IsObjective = isObjective
+	count, err := models.GetXzsChooseSendCountByMobile(mobile)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
+		return
+	}
+
+	//如果有记录就新增,没有记录就修改
+	if count == 0 {
+		err = models.AddCygxXzsChooseSendPush(item)
+	} else {
+		err = models.UpdateCygxXzsChooseSendPush(item)
+	}
+	if err != nil {
+		br.Msg = "保存失败!"
+		br.ErrMsg = "保存失败!,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}

+ 4 - 0
controllers/research.go

@@ -244,10 +244,12 @@ func (this *ResearchController) HotList() {
 		br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
 		return
 	}
+	followTypeMap := services.GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
 	//}
 	for k, v := range list {
 		list[k].IsNew = mapNew[v.IndustrialManagementId]
 		list[k].IsHot = mapHot[v.IndustrialManagementId]
+		list[k].FollowType = followTypeMap[v.IndustrialManagementId]
 		if v.FllowNum > 0 {
 			list[k].IsFollw = true
 		}
@@ -445,6 +447,7 @@ func (this *ResearchController) ThemeDetail() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	followTypeMap := services.GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
 	for _, v2 := range list {
 		item := new(models.GetThemeAericleListResp)
 		item.ArticleId = v2.ArticleId
@@ -478,6 +481,7 @@ func (this *ResearchController) ThemeDetail() {
 			resp.ListSubject = append(resp.ListSubject, itemSubJect)
 		}
 	}
+	resp.FollowType = followTypeMap[industrialManagementId]
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 20 - 0
models/chart_permission.go

@@ -48,6 +48,13 @@ func GetChartPermissionAll(condition string) (items []*ChartPermission, err erro
 	return
 }
 
+func GetChartPermissionAllXzs(condition string, pars []interface{}) (items []*ChartPermissionXzsResp, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1  AND permission_type!=2  AND chart_permission_id != 52  ` + condition + ` ORDER BY sort ASC `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 func GetChartPermissionListRai() (items []*ChartPermission, err error) {
 	o := orm.NewOrmUsingDB("weekly_report")
 	sql := `SELECT * FROM chart_permission WHERE product_id=2  ORDER BY sort ASC `
@@ -179,3 +186,16 @@ func GetChartPermissionIdByName(condition string, pars []interface{}) (chartperm
 	err = o.Raw(sql, pars).QueryRow(&chartpermissionids)
 	return
 }
+
+type ChartPermissionXzsResp struct {
+	ChartPermissionId     int                        `description:"权限id"`
+	PermissionName        string                     `description:"权限名称"`
+	HasCheck              bool                       `description:"是否有权限"`
+	AllTracks             string                     `default:"全部赛道";description:"全部赛道"`
+	ListFollow            []*IndustrialManagementRep // 重点关注
+	CheckListFollow       []int                      // 重点关注的ID
+	ListPush              []*IndustrialManagementRep // 接受推送
+	CheckListPush         []int                      // 接受推送的ID
+	ListUninterested      []*IndustrialManagementRep // 不感兴趣
+	CheckListUninterested []int                      // 不感兴趣的ID
+}

+ 1 - 0
models/db.go

@@ -145,6 +145,7 @@ func init() {
 		new(CygxReportSelectionVoiceHistory),
 		new(CygxActivitySpecialTripBill),
 		new(CygxXzsChooseCategory),
+		new(CygxXzsChooseCategoryZhouqi), //周期的关注系列
 		new(CygxReportSelectionSubjectHistory),
 		new(CygxTacticsTimeLineHistory),
 		new(CygxActivitySignin),

+ 1 - 0
models/industrial_management.go

@@ -19,6 +19,7 @@ type IndustrialManagementRep struct {
 	IsResearch             bool   `description:"是否属于研选"`
 	IsJump                 bool   `description:"是否跳转"`
 	IndustryNewLabel       bool   `description:"是否产业新标签"`
+	IsFllow                bool   `description:"是否关注"`
 }
 
 // 列表

+ 10 - 0
models/industry_fllow.go

@@ -20,10 +20,12 @@ type CygxIndustryFllow struct {
 	ModifyTime             time.Time `description:"更新时间"`
 	RealName               string    `description:"用户实际名称"`
 	Source                 int       `description:"来源1查研观向,2查研观向小助手,3勾选全部赛道的用户进行自动关注"`
+	FollowType             int       `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 }
 
 type CygxIndustryFllowRep struct {
 	IndustrialManagementId int `description:"产业D"`
+	FollowType             int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 }
 
 type IndustryFllowArryReq struct {
@@ -94,6 +96,14 @@ func GetCygxIndustryFllowList(condition string) (items []*CygxIndustryFllow, err
 	return
 }
 
+// 根据手机号获取用户关注的产业
+func GetCygxIndustryFllowListByMobile(mobile string) (items []*CygxIndustryFllow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industry_fllow WHERE mobile = ?`
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
+	return
+}
+
 // 获取列表信息根据手机号分组
 func GetCygxIndustryFllowListByUserId(condition string) (items []*CygxIndustryFllow, err error) {
 	o := orm.NewOrm()

+ 6 - 2
models/report.go

@@ -9,8 +9,9 @@ import (
 )
 
 type IndustrialManagementList struct {
-	Paging *paging.PagingItem
-	List   []*IndustrialManagement
+	Paging     *paging.PagingItem
+	List       []*IndustrialManagement
+	IsShowOpen bool `description:"是否展示展开字段"`
 }
 
 type IndustrialManagement struct {
@@ -25,6 +26,7 @@ type IndustrialManagement struct {
 	IsTop                  bool                 `description:"是否置顶"`
 	IsHot                  bool                 `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
 	IsFollow               int                  `description:"是否关注"`
+	FollowType             int                  `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 	IsNew                  bool                 `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
 	Analyst                string               `description:"分析师"`
 	ArticleReadNum         int                  `description:"文章阅读数量"`
@@ -874,6 +876,7 @@ type IndustrialManagementHotResp struct {
 	IndustrialManagementId int                   `orm:"column(industrial_management_id);pk" description:"产业id"`
 	IndustryName           string                `description:"产业名称"`
 	IsFollw                bool                  `description:"是否关注"`
+	FollowType             int                   `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 	FllowNum               int                   `description:"关注数量"`
 	IsNew                  bool                  `description:"是否新标签"`
 	IsHot                  bool                  `description:"是否新标签"`
@@ -1088,6 +1091,7 @@ type GetThemeDetailResp struct {
 	IndustrialManagementId int                  `description:"产业Id"`
 	IndustryName           string               `description:"产业名称"`
 	IsFollw                bool                 `description:"是否关注"`
+	FollowType             int                  `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 	ListSubject            []*IndustrialSubject `description:"标的列表"`
 	List                   []*GetThemeAericleListResp
 }

+ 19 - 0
models/report_mapping.go

@@ -35,6 +35,7 @@ type ReportMapping struct {
 	PermissionType      int    `description:"1主观,2客观"`
 	PolymerizationId    string `description:"分类聚合ID"`
 	CeLueFieldId        string `description:"策略平台领域ID"`
+	IsFllow             bool   `description:"是否关注"`
 }
 
 type ReportMappingHome struct {
@@ -80,6 +81,24 @@ func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
 	return
 }
 
+// 获取策略下面的所有分类
+func GetReportMappingStrategyAllXzs() (items []*IndustrialManagementRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			match_type_name AS industry_name,
+			category_id AS industrial_management_id,
+			chart_permission_id
+			FROM
+				cygx_report_mapping 
+			WHERE
+				report_type = 1 
+				AND chart_permission_name IN ('策略','固收')
+			ORDER BY
+				sort ASC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 获取策略下面的所有分类
 func GetReportMappingStrategyHomeAll(chartPermissionId int) (items []*ReportMappingHome, err error) {
 	o := orm.NewOrm()

+ 15 - 0
models/user.go

@@ -570,3 +570,18 @@ func GetUserMicroRoadshowCollectcount(userId int) (count int, err error) {
 	err = o.Raw(sqlCount, userId).QueryRow(&count)
 	return
 }
+
+func GetCompanyPermissionId(companyId int) (permissionId string, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_id  ORDER BY b.sort ASC SEPARATOR ',') AS permissionId
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			WHERE  a.company_id=?
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+			AND c.status IN('正式','试用','永续')
+			AND a.status IN('正式','试用','永续') `
+	err = o.Raw(sql, companyId).QueryRow(&permissionId)
+	return
+}

+ 1 - 0
models/xzs_choose_category.go

@@ -17,6 +17,7 @@ type CygxXzsChooseCategory struct {
 	CreateTime  time.Time `description:"创建时间"`
 	ModifyTime  time.Time `description:"更新时间"`
 	IdCygx      int       `description:"cygx_report_mapping_cygx 表主键ID"`
+	FollowType  int       `description:"1,重点关注,3不感兴趣,0默认接受推送"`
 }
 
 // 根据手机号获取用户关注的产业

+ 28 - 0
models/xzs_choose_category_zhouqi.go

@@ -0,0 +1,28 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxXzsChooseCategoryZhouqi struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户ID"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	CategoryId  int       `description:"cygx_zhouqi_article_map 表主键"`
+	CreateTime  time.Time `description:"创建时间"`
+	ModifyTime  time.Time `description:"更新时间"`
+	FollowType  int       `description:"1,重点关注,3不感兴趣,0默认接受推送"`
+}
+
+// 根据手机号获取用户关注的产业
+func GetCygxXzsChooseCategoryZhouqiList(mobile string) (items []*CygxXzsChooseCategoryZhouqi, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category_zhouqi WHERE mobile = ?`
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
+	return
+}

+ 156 - 3
models/xzs_choose_send.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -26,7 +27,7 @@ type CygxXzsChooseSend struct {
 	AllInYanXuan int       `description:"是否选择研选全部赛道"`
 }
 
-//获取提交过推送规则用户的userId
+// 获取提交过推送规则用户的userId
 func GetCygxXzsChooseSend() (items []*CygxXzsChooseSend, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_xzs_choose_send `
@@ -34,7 +35,7 @@ func GetCygxXzsChooseSend() (items []*CygxXzsChooseSend, err error) {
 	return
 }
 
-//获取某个行业勾选全部赛道的用户
+// 获取某个行业勾选全部赛道的用户
 func GetCygxXzsChooseSendByAllIn(allIn string) (items []*CygxXzsChooseSend, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_xzs_choose_send  WHERE ` + allIn + ` = 1	`
@@ -42,10 +43,162 @@ func GetCygxXzsChooseSendByAllIn(allIn string) (items []*CygxXzsChooseSend, err
 	return
 }
 
-//修改某个用户的行业是否勾选全部赛道
+// 修改某个用户的行业是否勾选全部赛道
 func UpdateCygxXzsChooseSendIsAllIn(allIn string, isAllIn, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_xzs_choose_send SET ` + allIn + ` = ? WHERE user_id = ?`
 	_, err = o.Raw(sql, isAllIn, userId).Exec()
 	return
 }
+
+type CygxXzsChooseSendResp struct {
+	IsRefuse     int `description:"是否拒绝推送,0否、1是  如果为1 则不做任何推送"`
+	IsSubjective int `description:"是否选择主观推送, 1 是 、 0否"`
+	IsObjective  int `description:"是否选择客观推送, 1 是 、 0否"`
+	IsPush       int `description:"是否接受推送,1是,0否"`
+	List         []*ChartPermissionXzsResp
+}
+
+// 获取数量
+func GetXzsChooseSendCountByMobile(mobile string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT  COUNT(1) AS count  FROM cygx_xzs_choose_send WHERE mobile = ? `
+	err = o.Raw(sql, mobile).QueryRow(&count)
+	return
+}
+
+// 根据用户openid获取token
+func GetCygxXzsChooseSendByMobile(mobile string) (item *CygxXzsChooseSend, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_send WHERE mobile=?  LIMIT 1 `
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
+type SubmitChooseSendFollowTypeResp struct {
+	FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
+	List       []*SubmitChooseSendFollowTypeList
+}
+
+type SubmitChooseSendFollowTypeList struct {
+	ChartPermissionName string `description:"权限名称"`
+	CheckList           []int  `description:"所选择的ID"`
+}
+
+// 添加
+func AddCygxXzsChooseSendFollow(mobile string, itemsFllow []*CygxIndustryFllow, itemsCategory []*CygxXzsChooseCategory, itemsZhouqi []*CygxXzsChooseCategoryZhouqi, industryIds, celueIds, zhouqiIds []int) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+
+	var sql string
+
+	if len(industryIds) > 0 {
+		//删除原有的关注记录
+		sql = `DELETE FROM cygx_industry_fllow WHERE mobile = ?  AND  industrial_management_id IN  (` + utils.GetOrmInReplace(len(industryIds)) + `)`
+		_, err = o.Raw(sql, mobile, industryIds).Exec()
+		if err != nil {
+			return err
+		}
+	}
+
+	if len(itemsFllow) > 0 {
+		//批量添加新的关注记录
+		_, err = o.InsertMulti(len(itemsFllow), itemsFllow)
+		if err != nil {
+			return err
+		}
+	}
+
+	if len(celueIds) > 0 {
+		//删除原有策略报告的关注记录
+		sql = `DELETE FROM cygx_xzs_choose_category WHERE mobile = ? AND   category_id IN  (` + utils.GetOrmInReplace(len(celueIds)) + `) `
+		_, err = o.Raw(sql, mobile, celueIds).Exec()
+		if err != nil {
+			return err
+		}
+	}
+
+	if len(itemsCategory) > 0 {
+		//批量添加新的关注记录
+		_, err = o.InsertMulti(len(itemsCategory), itemsCategory)
+		if err != nil {
+			return err
+		}
+	}
+
+	if len(zhouqiIds) > 0 {
+		//删除原有周期的关注记录
+		sql = `DELETE FROM cygx_xzs_choose_category_zhouqi WHERE mobile = ?  AND   category_id IN  (` + utils.GetOrmInReplace(len(zhouqiIds)) + `) `
+		_, err = o.Raw(sql, mobile, zhouqiIds).Exec()
+		if err != nil {
+			return err
+		}
+	}
+
+	if len(itemsZhouqi) > 0 {
+		//批量添加新的关注记录
+		_, err = o.InsertMulti(len(itemsZhouqi), itemsZhouqi)
+		if err != nil {
+			return err
+		}
+	}
+
+	return
+}
+
+type SubmitChooseSendResp struct {
+	IsRefuse                int `description:"是否拒绝推送,0否、1是  如果为1 则不做任何推送"`
+	IsPush                  int `description:"是否接受推送,1是,0否"`
+	IsSubjective            int `description:"是否选择主观推送, 1 是 、 0否"`
+	IsObjective             int `description:"是否选择客观推送, 1 是 、 0否"`
+	IndustrialManagementIds []*IndustrialManagementIdResp
+}
+
+type IndustrialManagementIdResp struct {
+	IndustrialManagementIds string `description:"产业ID 多个用 ,隔开"`
+	ChartPermissionId       int    `description:"权限id"`
+}
+
+// 添加
+func AddCygxXzsChooseSendPush(item *CygxXzsChooseSend) (err error) {
+	o := orm.NewOrm()
+	//添加所勾选的消息类型
+	_, err = o.Insert(item)
+	return
+}
+
+// 修改
+func UpdateCygxXzsChooseSendPush(item *CygxXzsChooseSend) (err error) {
+	o := orm.NewOrm()
+
+	//修改现有的类型
+	updateParams := make(map[string]interface{})
+	updateParams["UserId"] = item.UserId
+	updateParams["Mobile"] = item.Mobile
+	updateParams["Email"] = item.Email
+	updateParams["CompanyId"] = item.CompanyId
+	updateParams["CompanyName"] = item.CompanyName
+	updateParams["RealName"] = item.RealName
+	updateParams["ModifyTime"] = time.Now()
+	updateParams["IsRefuse"] = item.IsRefuse
+	updateParams["IsSubjective"] = item.IsSubjective
+	updateParams["IsObjective"] = item.IsObjective
+
+	ptrStructOrTableName := "cygx_xzs_choose_send"
+	whereParam := map[string]interface{}{"mobile": item.Mobile}
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -997,6 +997,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ChooseDetail",
+            Router: `/choose/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ChooseSubmitFollowType",
+            Router: `/choose/submit_follow_type`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ChooseSubmitPush",
+            Router: `/choose/submit_push`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "CommentAdd",

+ 29 - 0
services/industrial_management.go

@@ -413,6 +413,7 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 		err = e
 		return
 	}
+	followTypeMap := GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
 	//合并产业关联的标的
 	listSubjcet, err := models.GetThemeHeatSubjectList("")
 	if err != nil {
@@ -424,6 +425,7 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			list[k].IsFollow = 1
 		}
+		list[k].FollowType = followTypeMap[v.IndustrialManagementId]
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
 		if _, ok := mapindustrialId[v.IndustrialManagementId]; !ok {
 			continue
@@ -852,3 +854,30 @@ func UpdateIndustrialManagementOneMonthFollowNum(cont context.Context) (err erro
 	}
 	return
 }
+
+// GetCygxIndustryFllowListTypeMapByMobile 根据手机号获取产业关注的信息
+func GetCygxIndustryFllowListTypeMapByMobile(mobile string) (mapFollowTypeResp map[int]int) {
+	if mobile == "" {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg(fmt.Sprint("根据手机号获取产业关注的信息 失败,GetCygxIndustryFllowListTypeMapByMobile Err:"+err.Error()+"mobile", mobile), 3)
+		}
+	}()
+
+	mapFollowTypeResp = make(map[int]int, 0)
+	fllowList, e := models.GetCygxIndustryFllowList(mobile)
+	//策略的处理
+	if e != nil {
+		err = errors.New("GetUserFllowIndustrialList, Err: " + err.Error())
+		return
+	}
+	for _, v := range fllowList {
+		mapFollowTypeResp[v.IndustrialManagementId] = v.FollowType
+	}
+
+	return
+}