Эх сурвалжийг харах

Merge branch 'dev/v1.1.24_wh' of BaseService/jyMicroservices into feature/v1.1.24

王浩 2 жил өмнө
parent
commit
3d5962b3e5

+ 14 - 18
jyBXSubscribe/api/internal/logic/byPushHistoryLogic.go

@@ -35,26 +35,22 @@ func (l *ByPushHistoryLogic) ByPushHistory(req *types.SubscribeReq) (resp *types
 	//关键词
 	matchkeysArr := []string{}
 	matchkeys := ""
-	if req.IsEnt {
-		for k, v := range req.Item {
-			keyArr := gconv.Strings(v)
-			if len(keyArr) == 0 {
-				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
-			} else {
-				for _, s := range keyArr {
-					matchkeysArr = append(matchkeysArr, s)
-				}
+	for k, v := range req.Item {
+		keyArr := gconv.Strings(v)
+		if len(keyArr) == 0 {
+			matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
+		} else {
+			for _, s := range keyArr {
+				matchkeysArr = append(matchkeysArr, s)
 			}
 		}
-		if len(matchitemsArr) != 0 {
-			matchitems = strings.Join(matchitemsArr, ",")
-		}
-		if len(matchkeysArr) != 0 {
-			matchkeys = strings.Join(matchkeysArr, ",")
-			matchkeys = strings.ReplaceAll(matchkeys, " ", ",")
-		}
-	} else {
-		matchkeys = req.KeyWords
+	}
+	if len(matchitemsArr) != 0 {
+		matchitems = strings.Join(matchitemsArr, ",")
+	}
+	if len(matchkeysArr) != 0 {
+		matchkeys = strings.Join(matchkeysArr, ",")
+		matchkeys = strings.ReplaceAll(matchkeys, " ", ",")
 	}
 	res, err := l.svcCtx.Suscribe.ByPushHistory(l.ctx, &bxsubscribe.SubscribeInfosReq{
 		PageNum:        req.PageNum,

+ 15 - 19
jyBXSubscribe/api/internal/logic/subscribeListLogic.go

@@ -36,27 +36,23 @@ func (l *SubscribeListLogic) SubscribeList(req *types.SubscribeReq) (resp *types
 	//关键词
 	matchkeysArr := []string{}
 	matchkeys := ""
-	if req.IsEnt {
-		for k, v := range req.Item {
-			//类型换换
-			keyArr := gconv.Strings(v)
-			if len(keyArr) == 0 {
-				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
-			} else {
-				for _, s := range keyArr {
-					matchkeysArr = append(matchkeysArr, s)
-				}
+	for k, v := range req.Item {
+		//类型换换
+		keyArr := gconv.Strings(v)
+		if len(keyArr) == 0 {
+			matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
+		} else {
+			for _, s := range keyArr {
+				matchkeysArr = append(matchkeysArr, s)
 			}
 		}
-		if len(matchitemsArr) != 0 {
-			matchitems = strings.Join(matchitemsArr, ",")
-		}
-		if len(matchkeysArr) != 0 {
-			matchkeys = strings.Join(matchkeysArr, ",")
-			matchkeys = strings.ReplaceAll(matchkeys, " ", ",")
-		}
-	} else {
-		matchkeys = req.KeyWords
+	}
+	if len(matchitemsArr) != 0 {
+		matchitems = strings.Join(matchitemsArr, ",")
+	}
+	if len(matchkeysArr) != 0 {
+		matchkeys = strings.Join(matchkeysArr, ",")
+		matchkeys = strings.ReplaceAll(matchkeys, " ", ",")
 	}
 	res, err := l.svcCtx.Suscribe.GetSubList(l.ctx, &bxsubscribe.SubscribeInfosReq{
 		PageNum:        req.PageNum,

+ 3 - 1
jyBXSubscribe/rpc/internal/logic/setreadlogic.go

@@ -35,6 +35,8 @@ func (l *SetReadLogic) SetRead(in *bxsubscribe.SetReadReq) (*bxsubscribe.StatusR
 			in.UserType = model.EntnicheFlag
 		}
 	}
-	model.NewSubscribePush(in.UserType).SetRead(in.NewUserId, in.Vsid, in.UserId, in.EntUserId, in.EntId, in.IsEnt, userType)
+	if !in.IsEnt {
+		model.NewSubscribePush(in.UserType).SetRead(in.NewUserId, in.Vsid, in.UserId, in.EntUserId, in.EntId, in.IsEnt, userType)
+	}
 	return resp, nil
 }

+ 74 - 38
jyBXSubscribe/rpc/model/push.go

@@ -513,6 +513,14 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 					find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(a.matchkeys,' ',','))", v))
 				}
 			}
+
+			if spqp.Item != "" {
+				//通过分类名搜索
+				keyArr := s.ItemToKey(spqp)
+				for _, v := range strings.Split(keyArr, ",") {
+					find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(a.matchkeys,' ',','))", v))
+				}
+			}
 		}
 		if len(find_in_set) == 1 {
 			querys = append(querys, find_in_set[0])
@@ -932,49 +940,31 @@ func (s *subscribePush) SetRead(newUserId, id int64, userId, entUserId, entId st
 	if newUserId == 0 {
 		return nil
 	}
-	if isEnt {
-		if s.ModuleFlag == EntnicheFlag {
-			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 ,visittime=now() where entid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entId, id)
-
-		} else {
-			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where entid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entId, id)
-
-		}
-	} else {
-		if s.ModuleFlag == EntnicheFlag {
-			//商机管理
-			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1,visittime=now() where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), entUserId, id)
-		} else {
-			//其他
-			IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1 where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), newUserId, id)
-		}
+	IC.BaseServiceMysql.UpdateOrDeleteBySql(fmt.Sprintf("update %s set isvisit=1,visittime=now() where userid=? and id=?", aboutDbMsg[s.ModuleFlag].MysqlTable), common.If(s.ModuleFlag == EntnicheFlag, entUserId, newUserId), id)
+	if s.ModuleFlag == EntnicheFlag {
+		userId = entUserId
 	}
-	if !isEnt {
-		if s.ModuleFlag == EntnicheFlag {
-			userId = entUserId
-		}
-		todaySubPush, err := s.GetTodayCache(userId, userType)
-		//当天数据处理
-		if err == nil && todaySubPush != nil {
-			for _, v := range todaySubPush.Datas {
-				if v.CaIndex == id {
-					v.CaIsvisit = 1
-					break
-				}
+	todaySubPush, err := s.GetTodayCache(userId, userType)
+	//当天数据处理
+	if err == nil && todaySubPush != nil {
+		for _, v := range todaySubPush.Datas {
+			if v.CaIndex == id {
+				v.CaIsvisit = 1
+				break
 			}
-			s.PutTodayCache(userId, userType, todaySubPush)
 		}
-		//全部数据处理
-		allSubPush, err := s.GetAllCache(userId, userType)
-		if err == nil && allSubPush != nil {
-			for _, v := range allSubPush.Datas {
-				if v.CaIndex == id {
-					v.CaIsvisit = 1
-					break
-				}
+		s.PutTodayCache(userId, userType, todaySubPush)
+	}
+	//全部数据处理
+	allSubPush, err := s.GetAllCache(userId, userType)
+	if err == nil && allSubPush != nil {
+		for _, v := range allSubPush.Datas {
+			if v.CaIndex == id {
+				v.CaIsvisit = 1
+				break
 			}
-			s.PutAllCache(userId, userType, allSubPush)
 		}
+		s.PutAllCache(userId, userType, allSubPush)
 	}
 	return nil
 }
@@ -1832,3 +1822,49 @@ func MergeArray(dest []interface{}, src []interface{}) (result []interface{}) {
 	}
 	return
 }
+func (s *subscribePush) ItemToKey(in *SubPushQueryParam) string {
+	spqp := KeyParam{
+		UserId:       in.UserId,
+		EntUserId:    in.EntUserId,
+		DeptId:       in.DeptId,
+		NewUserId:    in.NewUserId,
+		IsEnt:        in.IsEnt,
+		EntId:        in.EntId,
+		PositionType: in.PositionType,
+	}
+	//所有关键词获取
+	keyItemsArr := s.Keys(&spqp)
+	keyArr := []string{}
+	if len(keyItemsArr) > 0 {
+		for _, k1 := range keyItemsArr {
+			for _, k2 := range strings.Split(in.Item, ",") {
+				if k1.SItem == k2 {
+					if len(k1.AKey) > 0 {
+						for _, k3 := range k1.AKey {
+							key := ""
+							if len(k3.Key) > 0 {
+								key = strings.Join(k3.Key, " ")
+							}
+							if len(k3.Appendkey) > 0 {
+								if key != "" {
+									key += " " + strings.Join(k3.Appendkey, " ")
+								} else {
+									key = strings.Join(k3.Appendkey, " ")
+								}
+							}
+							if k3.Matchway == 1 {
+								//模糊处理
+								key = strings.ReplaceAll(key, " ", ",")
+							} else {
+								//精准处理
+								key = strings.ReplaceAll(key, " ", "+")
+							}
+							keyArr = append(keyArr, key)
+						}
+					}
+				}
+			}
+		}
+	}
+	return strings.Join(keyArr, ",")
+}

+ 5 - 10
jyBXSubscribe/rpc/model/service/pushSet.go

@@ -24,16 +24,9 @@ func (this *PushSetService) Update(item, setType, pushType string, ratemode, pus
 	set := map[string]interface{}{}
 	switch setType {
 	case "pushRoute":
-		if pushType == "i_nomsgtip" {
-			set = map[string]interface{}{
-				fmt.Sprintf("o_pushset.%s", pushType): common.IntAll(pushValue),
-			}
-		} else {
-			set = map[string]interface{}{
-				fmt.Sprintf("o_pushset.%s.%s", item, pushType): common.IntAll(pushValue),
-			}
+		set = map[string]interface{}{
+			fmt.Sprintf("o_pushset.%s.%s", item, pushType): common.IntAll(pushValue),
 		}
-
 		break
 	case "a_times":
 		if ratemode == 2 {
@@ -104,7 +97,6 @@ func (this *PushSetService) Find() map[string]*bxsubscribe.PushSet {
 	}
 	fool, o_subset := pushSetMontage(o_pushset["o_subset"], "o_subset", powerData, ShowWx)
 	if fool {
-		o_subset.INomsgtip = common.Int64All(common.If(o_pushset["i_nomsgtip"] == nil, 1, o_pushset["i_nomsgtip"]))
 		pushSet["o_subset"] = o_subset
 	}
 
@@ -159,6 +151,7 @@ func pushSetMontage(in interface{}, name string, powerData *pb.CheckResp, ShowWx
 				IMailpush: common.Int64All(common.If((*data)["i_mailpush"] == nil, 0, (*data)["i_mailpush"])),
 				IRatemode: 2,
 				IsWxShow:  1,
+				INomsgtip: common.Int64All(common.If((*data)["i_nomsgtip"] == nil, 1, (*data)["i_nomsgtip"])),
 			}
 		} else {
 			if data == nil || len(*data) == 0 {
@@ -169,6 +162,7 @@ func pushSetMontage(in interface{}, name string, powerData *pb.CheckResp, ShowWx
 					IMailpush: 0,
 					IRatemode: 2,
 					IsWxShow:  1,
+					INomsgtip: 1,
 				}
 			} else {
 				returnData = &bxsubscribe.PushSet{
@@ -178,6 +172,7 @@ func pushSetMontage(in interface{}, name string, powerData *pb.CheckResp, ShowWx
 					IMailpush: common.Int64All(common.If((*data)["i_mailpush"] == nil, 0, (*data)["i_mailpush"])),
 					IRatemode: common.Int64All(common.If((*data)["i_ratemode"] == nil, 2, (*data)["i_ratemode"])),
 					IsWxShow:  1,
+					INomsgtip: common.Int64All(common.If((*data)["i_nomsgtip"] == nil, 1, (*data)["i_nomsgtip"])),
 				}
 				if common.Int64All((*data)["i_ratemode"]) == 5 {
 					returnData.ATimes = []string{"14:00"}