소스 검색

推送结果预览

zhangxinlei1996 3 년 전
부모
커밋
1fccf60ef1

+ 45 - 50
src/jfw/modules/publicapply/src/subscribe/entity/entity.go

@@ -88,6 +88,7 @@ type UserSubMsg struct {
 	Ppendtime   int64                  `json:"ppend"`       //省份订阅包结束时间
 }
 
+//推送预览总数
 func DataCount(uid, item string, index int) int64 {
 	sql := GetSqlObjFromFreeId(uid, item, index)
 	if item != "" && index >= 0 && (sql.Keyword == nil || len(sql.Keyword) == 0) {
@@ -98,30 +99,20 @@ func DataCount(uid, item string, index int) int64 {
 	return elastic.Count(INDEX, TYPE, qstr)
 }
 
+//match 默认精准 0
 func KeysetDataCount(userId, key, notkey string, matchway int) int64 {
 	key = strings.TrimSpace(key)
 	notkey = strings.TrimSpace(notkey)
 	if key == "" {
 		return 0
 	}
-	// sql := GetSqlObjFromId(userId, "", -1)
 	sql := GetSqlObjFromFreeId(userId, "", -1)
 	viewKeyWords := []ViewKeyWord{}
-	if matchway == 0 {
-		viewKeyWords = append(viewKeyWords, ViewKeyWord{
-			Keyword:  strings.Split(key, " "),
-			Exclude:  strings.Split(notkey, " "),
-			MatchWay: matchway,
-		})
-	} else {
-		for _, v := range strings.Split(key, " ") {
-			viewKeyWords = append(viewKeyWords, ViewKeyWord{
-				Keyword:  []string{v},
-				Exclude:  strings.Split(notkey, " "),
-				MatchWay: matchway,
-			})
-		}
-	}
+	viewKeyWords = append(viewKeyWords, ViewKeyWord{
+		Keyword:  strings.Split(key, " "),
+		Exclude:  strings.Split(notkey, " "),
+		MatchWay: matchway,
+	})
 	sql.Keyword = viewKeyWords
 	qstr := GetVIPViewSql(userId, sql)
 	return elastic.Count(INDEX, TYPE, qstr)
@@ -144,6 +135,7 @@ func SubViewDatas(userId, allquery string, pageNum int) (keys []interface{}, lis
 		keys = append(keys, strings.Join(keys_one, "++"))
 	}
 	qstr := GetVIPViewSql(userId, sql)
+	log.Println("qstr:", qstr)
 	list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, (pageNum-1)*view_pageSize, view_pageSize, 0, false)
 	if list != nil {
 		for _, v := range *list {
@@ -219,8 +211,7 @@ func (pi *ParamInfo) GetSubMsg() UserSubMsg {
 	return res
 }
 
-//
-//member_jy
+//免费用户对象
 func GetSqlObjFromFreeId(_id, item string, index int) *ViewCondition {
 	var (
 		query *map[string]interface{}
@@ -237,33 +228,34 @@ func GetSqlObjFromFreeId(_id, item string, index int) *ViewCondition {
 	//关键词组
 	a_items := []interface{}{}
 	a_items = append(a_items, o_jy["a_key"])
-	// fmt.Println(a_items)
 	//采购单位类型
 	a_buyerclass := []interface{}{}
 	//信息类型
-	a_infotype := []interface{}{}
+	a_infotype := []string{}
+	infotypeArr := ""
+	if o_jy["a_infotype"] != nil {
+		a_infotype = qutil.ObjArrToStringArr(o_jy["a_infotype"].([]interface{}))
+		for k, v := range a_infotype {
+			infotype := v
+			infotypeArr += getstype(infotype)
+			if k != len(a_infotype)-1 {
+				infotypeArr += ","
+			}
+		}
+	}
+	if infotypeArr != "" {
+		a_infotype = strings.Split(infotypeArr, ",")
+	}
 	//省份
-	o_area := map[string]interface{}{}
-	//未升级版免费订阅
-	// isUpgrade := true
-	// if o_jy["o_area"] == nil {
-	// 	isUpgrade = false
-	// }
-	// if o_member_jy["a_items"] != nil {
-	// 	a_items = o_member_jy["a_items"].([]interface{})
-	// }
-	// if o_member_jy["a_infotype"] != nil {
-	// 	a_infotype = o_member_jy["a_infotype"].([]interface{})
-	// }
-	// if o_member_jy["o_area"] != nil {
-	// 	o_area = o_member_jy["o_area"].(map[string]interface{})
-	// }
+	o_area := qutil.ObjToMap(o_jy["o_area"])
+	if qutil.IntAllDef(o_jy["i_ppstatus"], 0) == 1 && o_jy["o_area_p"] != nil {
+		o_area = qutil.ObjToMap(o_jy["o_area_p"])
+	}
 	return &ViewCondition{
 		Keyword:    getKeyWordArrFromDbResult(a_items, item, index), //关键词
 		Buyerclass: qutil.ObjArrToStringArr(a_buyerclass),           //采购单位类型
-		Subtype:    qutil.ObjArrToStringArr(a_infotype),             //信息类型
-		Area:       getStringArrFromDbResult(o_area, 1),             //省份
-		City:       getStringArrFromDbResult(o_area, 2),             //城市
+		Subtype:    a_infotype,                                      //信息类型
+		Area:       getStringArrFromDbResult(*o_area, 1),            //省份
 		SelectType: strconv.Itoa(qutil.IntAll(o_jy["i_matchway"])),  //匹配方式
 	}
 }
@@ -276,23 +268,11 @@ func getKeyWordArrFromDbResult(a_items []interface{}, item string, index int) (a
 	for _, v := range a_items {
 		vmr, _ := v.([]interface{})
 		vm, _ := vmr[0].(map[string]interface{})
-		// vm, _ := v.(map[string]interface{})
-		// b, _ := json.Marshal(vm)
-		// fmt.Println("vm", string(b), reflect.TypeOf(vm))
 		if item != "" && index >= 0 && item != qutil.ObjToString(vm["s_item"]) {
 			continue
 		}
-		// b, _ = json.Marshal(a_items)
-		// fmt.Println("a_items", string(b), reflect.TypeOf(a_items))
-		// b, _ = json.Marshal(v)
-		// fmt.Println("v", string(b), reflect.TypeOf(v))
-		// // kwsArr := vm["a_key"]
 		kwsArr := vmr
-		// fmt.Println(kwsArr)
-		// kwsArr, _ := vm.([]interface{})
-		// for i, k := range kwsArr.([]interface{}) {
 		for i, k := range kwsArr {
-			// for i, k := range kwsArr {
 			if item != "" && index >= 0 && i != index {
 				continue
 			}
@@ -383,3 +363,18 @@ func (pi *ParamInfo) UpdateAreaPackTip() bool {
 		},
 	})
 }
+
+//
+func getstype(stype string) string {
+	switch stype {
+	case "招标":
+		stype = "招标,邀标,询价,竞谈,单一,竞价,变更"
+	case "结果":
+		stype = "中标,成交,废标,流标,结果变更"
+	case "其它":
+		stype = "合同,验收,违规"
+	case "预告":
+		stype = "预告,需求公示,预审,论证意见,预审结果"
+	}
+	return stype
+}

+ 0 - 4
src/jfw/modules/publicapply/src/subscribe/service/service.go

@@ -42,7 +42,6 @@ func (this *ServiceStruct) GetPushView() {
 	userId, _ := this.GetSession("userId").(string)
 	if userId != "" {
 		pageNum, _ := this.GetInteger("pageNum")
-		// keys, list, hasNextPage := util.SubViewDatas(userId, "", pageNum)
 		keys, list, hasNextPage := entity.SubViewDatas(userId, "", pageNum)
 		this.ServeJson(map[string]interface{}{
 			"keys":        strings.Replace(strings.Trim(fmt.Sprint(keys), "[]"), " ", ",", -1),
@@ -54,14 +53,11 @@ func (this *ServiceStruct) GetPushView() {
 
 //
 func (this *ServiceStruct) GetPushCount() {
-	// fmt.Println(1)
 	defer qu.Catch()
 	userId, _ := this.GetSession("userId").(string)
-	// fmt.Println(userId)
 	if userId != "" {
 		index, _ := this.GetInteger("index")
 		this.ServeJson(map[string]interface{}{
-			// "count": util.SubViewDatasCount(userId, this.GetString("item"), index),
 			"count": entity.DataCount(userId, this.GetString("item"), index),
 		})
 	}

+ 114 - 1
src/jfw/modules/publicapply/src/subscribePush/entity/vrew.go

@@ -48,7 +48,13 @@ func KeysetViewDatasCount(userId, vType, key, notkey string, matchway int) int64
 	if key == "" {
 		return 0
 	}
-	sql := GetSqlObjFromId(userId, vType, "", -1)
+	sql := &ViewCondition{}
+	if vType == "" {
+		sql = GetSqlObjFromFreeId(userId, "", -1)
+	} else {
+		sql = GetSqlObjFromId(userId, vType, "", -1)
+	}
+
 	viewKeyWords := []ViewKeyWord{}
 	if matchway == 0 {
 		viewKeyWords = append(viewKeyWords, ViewKeyWord{
@@ -297,3 +303,110 @@ func getKeyWordArrFromDbResult(a_items []interface{}, item string, index int) (a
 	}
 	return
 }
+
+//免费用户对象
+func GetSqlObjFromFreeId(_id, item string, index int) *ViewCondition {
+	var (
+		query *map[string]interface{}
+		ok    bool
+	)
+	if query, ok = db.Mgo.FindById("user", _id, `{"o_jy":1}`); !ok && (*query)["o_jy"] == nil {
+		return nil
+	}
+	o_jy, _ := (*query)["o_jy"].(map[string]interface{})
+
+	if o_jy["a_key"] == nil {
+		return nil
+	}
+	//关键词组
+	a_items := []interface{}{}
+	a_items = append(a_items, o_jy["a_key"])
+	//采购单位类型
+	a_buyerclass := []interface{}{}
+	//信息类型
+	a_infotype := []string{}
+	infotypeArr := ""
+	if o_jy["a_infotype"] != nil {
+		a_infotype = qutil.ObjArrToStringArr(o_jy["a_infotype"].([]interface{}))
+		for k, v := range a_infotype {
+			infotype := v
+			infotypeArr += getstype(infotype)
+			if k != len(a_infotype)-1 {
+				infotypeArr += ","
+			}
+		}
+	}
+	if infotypeArr != "" {
+		a_infotype = strings.Split(infotypeArr, ",")
+	}
+	//省份
+	o_area := qutil.ObjToMap(o_jy["o_area"])
+	if qutil.IntAllDef(o_jy["i_ppstatus"], 0) == 1 && o_jy["o_area_p"] != nil {
+		o_area = qutil.ObjToMap(o_jy["o_area_p"])
+	}
+	return &ViewCondition{
+		Keyword:    getKeyWordArrFromDbResultByFree(a_items, item, index), //关键词
+		Buyerclass: qutil.ObjArrToStringArr(a_buyerclass),                 //采购单位类型
+		Subtype:    a_infotype,                                            //信息类型
+		Area:       getStringArrFromDbResult(*o_area, 1),                  //省份
+		SelectType: strconv.Itoa(qutil.IntAll(o_jy["i_matchway"])),        //匹配方式
+	}
+}
+
+//
+func getstype(stype string) string {
+	switch stype {
+	case "招标":
+		stype = "招标,邀标,询价,竞谈,单一,竞价,变更"
+	case "结果":
+		stype = "中标,成交,废标,流标,结果变更"
+	case "其它":
+		stype = "合同,验收,违规"
+	case "预告":
+		stype = "预告,需求公示,预审,论证意见,预审结果"
+	}
+	return stype
+}
+
+// //关键词 附加词 排除词  省份订阅包
+func getKeyWordArrFromDbResultByFree(a_items []interface{}, item string, index int) (arr []ViewKeyWord) {
+	if a_items == nil {
+		return
+	}
+	for _, v := range a_items {
+		vmr, _ := v.([]interface{})
+		vm, _ := vmr[0].(map[string]interface{})
+		if item != "" && index >= 0 && item != qutil.ObjToString(vm["s_item"]) {
+			continue
+		}
+		kwsArr := vmr
+		for i, k := range kwsArr {
+			if item != "" && index >= 0 && i != index {
+				continue
+			}
+			kw := ViewKeyWord{}
+			b, e := json.Marshal(k)
+			if e != nil {
+				log.Println(e.Error())
+			}
+			json.Unmarshal(b, &kw)
+			if kw.MatchWay == 1 {
+				for _, kk := range kw.Keyword {
+					arr = append(arr, ViewKeyWord{
+						Keyword: []string{kk},
+						Exclude: kw.Exclude,
+					})
+				}
+				for _, kk := range kw.Appended {
+					arr = append(arr, ViewKeyWord{
+						Keyword: []string{kk},
+						Exclude: kw.Exclude,
+					})
+				}
+			} else {
+				arr = append(arr, kw)
+			}
+		}
+	}
+	return
+}