Browse Source

用户勾选某行业全部赛道的时候的额处理

xingzai 2 years ago
parent
commit
5ed717eda2
3 changed files with 65 additions and 3 deletions
  1. 40 1
      controllers/user.go
  2. 12 0
      models/xzs_choose_send.go
  3. 13 2
      utils/constants.go

+ 40 - 1
controllers/user.go

@@ -213,7 +213,7 @@ func (this *UserController) ChooseSubmit() {
 	}
 	var itemsFllow []*models.CygxIndustryFllow
 	var itemsCategory []*models.CygxXzsChooseCategory
-
+	industrialFllowNum := make(map[int]int) // 提交过来的不同行业的下对应的产业数量
 	//如果为1 则不做任何推送 ,主观客观默认改成0
 	if isRefuse == 1 {
 		isSubjective = 0
@@ -229,6 +229,7 @@ func (this *UserController) ChooseSubmit() {
 			} else {
 				categoryIds += v.IndustrialManagementIds + ","
 			}
+			industrialFllowNum[v.ChartPermissionId] = strings.Count(v.IndustrialManagementIds, ",") + 1
 		}
 
 		industrialManagementIds = strings.TrimRight(industrialManagementIds, ",")
@@ -273,6 +274,25 @@ func (this *UserController) ChooseSubmit() {
 			}
 		}
 	}
+
+	//医药、消费、科技、智造、研选下的产业赛道
+	mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
+	industrialList, err := models.GetindustrialManagement()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range industrialList {
+		mapIndustrial[v.ChartPermissionId] = append(mapIndustrial[v.ChartPermissionId], v)
+	}
+	//策略下的产业赛道
+	celueList, err := models.GetReportMappingStrategyAll()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
+		return
+	}
 	mobile := user.Mobile
 	item := new(models.CygxXzsChooseSend)
 	item.UserId = user.UserId
@@ -286,6 +306,25 @@ func (this *UserController) ChooseSubmit() {
 	item.IsRefuse = req.IsRefuse
 	item.IsSubjective = isSubjective
 	item.IsObjective = isObjective
+
+	if industrialFllowNum[utils.YI_YAO_ID] == len(mapIndustrial[utils.YI_YAO_ID]) {
+		item.AllInYiYao = 1 //如果医药全选则设为1
+	}
+	if industrialFllowNum[utils.XIAO_FEI_ID] == len(mapIndustrial[utils.XIAO_FEI_ID]) {
+		item.AllInXiaoFei = 1 //如果消费全选则设为1
+	}
+	if industrialFllowNum[utils.KE_JI_ID] == len(mapIndustrial[utils.KE_JI_ID]) {
+		item.AllInKeJi = 1 //如果科技全选则设为1
+	}
+	if industrialFllowNum[utils.ZHI_ZAO_ID] == len(mapIndustrial[utils.ZHI_ZAO_ID]) {
+		item.AllInZhiZao = 1 //如果智造全选则设为1
+	}
+	if industrialFllowNum[utils.CHART_PERMISSION_ID_YANXUAN] == len(mapIndustrial[utils.CHART_PERMISSION_ID_YANXUAN]) {
+		item.AllInYanXuan = 1 //如果研选全选则设为1
+	}
+	if industrialFllowNum[utils.CE_LUE_ID] == len(celueList) {
+		item.AllInCeLue = 1 //如果策略全选则设为1
+	}
 	count, err := models.GetXzsChooseSendCountByMobile(mobile)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 12 - 0
models/xzs_choose_send.go

@@ -18,6 +18,12 @@ type CygxXzsChooseSend struct {
 	IsObjective  int       `description:"是否选择客观推送, 1 是 、 0否"`
 	CreateTime   time.Time `description:"创建时间"`
 	ModifyTime   time.Time `description:"更新时间"`
+	AllInYiYao   int       `description:"是否选择医药全部赛道"`
+	AllInXiaoFei int       `description:"是否选择消费全部赛道"`
+	AllInKeJi    int       `description:"是否选择科技全部赛道"`
+	AllInZhiZao  int       `description:"是否选择智造全部赛道"`
+	AllInCeLue   int       `description:"是否选择策略全部赛道"`
+	AllInYanXuan int       `description:"是否选择研选全部赛道"`
 }
 
 type CygxXzsChooseSendResp struct {
@@ -158,6 +164,12 @@ func UpdateCygxXzsChooseSend(item *CygxXzsChooseSend, itemsFllow []*CygxIndustry
 	updateParams["IsRefuse"] = item.IsRefuse
 	updateParams["IsSubjective"] = item.IsSubjective
 	updateParams["IsObjective"] = item.IsObjective
+	updateParams["AllInYiYao"] = item.AllInYiYao
+	updateParams["AllInXiaoFei"] = item.AllInXiaoFei
+	updateParams["AllInKeJi"] = item.AllInKeJi
+	updateParams["AllInZhiZao"] = item.AllInZhiZao
+	updateParams["AllInCeLue"] = item.AllInCeLue
+	updateParams["AllInYanXuan"] = item.AllInYanXuan
 	whereParam := map[string]interface{}{"mobile": item.Mobile}
 	err = UpdateByExpr(CygxXzsChooseSend{}, whereParam, updateParams)
 	return

+ 13 - 2
utils/constants.go

@@ -56,6 +56,17 @@ var (
 )
 
 const (
-	CE_LUE_NAME string = "策略"
-	CE_LUE_ID   int    = 23
+	CE_LUE_NAME                      string = "策略"
+	CE_LUE_ID                        int    = 23
+	CHART_PERMISSION_NAME_YANXUAN    string = "研选"
+	CHART_PERMISSION_NAME_MF_YANXUAN string = "买方研选"
+	CHART_PERMISSION_ID_YANXUAN      int    = 31
+	YI_YAO_NAME                      string = "医药"
+	YI_YAO_ID                        int    = 22
+	XIAO_FEI_NAME                    string = "消费"
+	XIAO_FEI_ID                      int    = 21
+	KE_JI_NAME                       string = "科技"
+	KE_JI_ID                         int    = 20
+	ZHI_ZAO_NAME                     string = "智造"
+	ZHI_ZAO_ID                       int    = 19
 )