Procházet zdrojové kódy

物业搜索修改

WH01243 před 1 rokem
rodič
revize
7702362715

+ 87 - 5
src/jfw/front/searchOptimize.go

@@ -96,12 +96,23 @@ type SearchOptimize struct {
 	Period              int           `json:"period"`         //合同周期
 	Changehand          int           `json:"changehand"`     //价格区间
 	Scale               int           `json:"scale"`          //换手率
+	Isfile              int           `json:"isfile"`         //有无附件
+
 }
 
 // NewSearchOptimize  初始化
 func NewSearchOptimize(userId, phone, province, city, district, subtype, topType, publishTime, selectType, price, industry, buyerClass, buyerTel, winnerTel, fileExists, keyWords, additionalWords, exclusionWords, platform, territorialization, expireTime, propertyForm, subinformation string,
-	pageNum, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand int,
-	userInfo jy.VipState, searchTypeSwitch bool, r *http.Request) *SearchOptimize {
+	pageNum, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile int,
+	userInfo jy.VipState, searchTypeSwitch bool, r *http.Request, accountId, entAccountId, entId, entUserId int64) *SearchOptimize {
+	IsPay := userInfo.IsPayedUser()
+	if territorialization == "BIProperty" {
+		res := config.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
+		for _, pCode := range res.Powers {
+			if pCode == "bi_yx_wyzb" {
+				IsPay = true
+			}
+		}
+	}
 	var so = &SearchOptimize{
 		AppId:            "10000",
 		UserId:           userId,
@@ -127,7 +138,7 @@ func NewSearchOptimize(userId, phone, province, city, district, subtype, topType
 		AdditionalWords:  additionalWords,
 		ExclusionWords:   exclusionWords,
 		Platform:         platform,
-		IsPay:            userInfo.IsPayedUser(),
+		IsPay:            IsPay,
 		BidField:         territorialization,
 		SearchTypeSwitch: searchTypeSwitch,
 		IsOldVip:         userInfo.VipState > 0 && userInfo.RegisterData < util.Int64All(config.Sysconfig["contextOldVipLimit"]),
@@ -340,7 +351,7 @@ func (so *SearchOptimize) GetBidSearchList(isCache bool) (count, total int64, li
 		total, repl = biddingSearch.GetAllByNgramWithCount()
 		if repl != nil && *repl != nil && len(*repl) > 0 {
 			//格式化查询结果
-			list = SearchListFormat(so.Industry, *repl, strings.Contains(so.SelectType, "detail"))
+			list = SearchListFormat(so.Industry, *repl, strings.Contains(so.SelectType, "detail"), so.BidField)
 			count = util.If(so.IsPay, int64(bidsearch.SearchMaxPageCount_PAYED), int64(bidsearch.SearchMaxPageCount_PC)).(int64)
 			//数据如果>最大数据结果量 total==count,否则count = 付费:5000;免费:500;
 			count = util.If(count > total, total, count).(int64)
@@ -544,6 +555,9 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
 	if so.Changehand != 0 && isLogin {
 		musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_set.wuye.changehand", `"`+gconv.String(so.Changehand)+`"`))
 	}
+	if so.Isfile != 0 && isLogin {
+		musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_set.wuye.isfile", `"`+gconv.String(so.Isfile)+`"`))
+	}
 	//价格
 	if so.Price != "" && len(strings.Split(so.Price, "-")) > 1 && isLogin {
 		minPrice, maxPrice := strings.Split(so.Price, "-")[0], strings.Split(so.Price, "-")[1]
@@ -707,6 +721,51 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
 		}
 		query += `}}}`
 	}
+	if so.ExpireTime != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		startTime, endTime := "", ""
+		now := time.Now()
+		if publishTime == "1" { //本月到期
+			startTime = fmt.Sprint(now.Unix())
+			first := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local)
+			endTime = fmt.Sprint(first.AddDate(0, 0, -1).Unix())
+			/* endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local).Unix())*/
+		} else if publishTime == "1-3" { //1-3个月到期
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+		} else if publishTime == "3-6" { //3-6个月到期
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+		} else if publishTime == "6-12" { //6-12个月到期
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+		} else if publishTime == "12" { //12个月以后
+			startTime = fmt.Sprint(now.Unix())
+			startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
+		} else if len(strings.Split(publishTime, "_")) > 1 {
+			startTime = strings.Split(publishTime, "_")[0]
+			endTime = strings.Split(publishTime, "_")[1]
+			etTime := time.Now()
+			if endTime != "" {
+				et, _ := strconv.ParseInt(endTime, 0, 64)
+				etTime = time.Unix(et, 0)
+			}
+			endTime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
+		}
+		query += `{"range":{"expiredate":{`
+		if startTime != "" {
+			query += `"gte":` + startTime
+		}
+		if startTime != "" && endTime != "" {
+			query += `,`
+		}
+		if endTime != "" {
+			query += `"lt":` + endTime
+		}
+		query += `}}}`
+	}
 	//信息类型-二级
 	subtype := so.Subtype
 	topType := util.If(so.TopType != "", strings.Split(so.TopType, ","), []string{}).([]string)
@@ -888,7 +947,7 @@ func (e *SearchByES) GetAllByNgramWithCount() (int64, *[]map[string]interface{})
 }
 
 // SearchListFormat  格式化数据
-func SearchListFormat(industry string, repl []map[string]interface{}, b bool) (list []*map[string]interface{}) {
+func SearchListFormat(industry string, repl []map[string]interface{}, b bool, bidField string) (list []*map[string]interface{}) {
 	for _, v := range repl {
 		//正文
 		if b {
@@ -966,6 +1025,29 @@ func SearchListFormat(industry string, repl []map[string]interface{}, b bool) (l
 				})
 			}
 			v["winnerInfo"] = winnerInfo
+
+		}
+		if bidField == "BIProperty" {
+			//物业数据处理
+			subinformationArr := gconv.SliceStr(v["tag_subinformation"])
+			if len(subinformationArr) > 0 {
+				for i, value := range subinformationArr {
+					subinformationArr[i] = strings.Split(value, "_")[1]
+				}
+				v["tag_subinformation"] = subinformationArr
+			}
+			//是否有附件
+			tag := gconv.Map(v["tag_set"])
+			if tag != nil {
+				wuye := gconv.Map(tag["wuye"])
+				if tag != nil {
+					isFile := gconv.Int64(wuye["isfile"])
+					if isFile == 63 {
+						v["fileExists"] = true
+					}
+				}
+			}
+			delete(v, "tag_set")
 		}
 		tmp := v
 		list = append(list, &tmp)

+ 5 - 1
src/jfw/front/supsearch.go

@@ -330,6 +330,10 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	if pageSize == 0 {
 		pageSize = 50
 	}
+	accountId := util.Int64All(sessVal["accountId"])
+	entAccountId := util.Int64All(sessVal["entAccountId"])
+	entId := util.Int64All(sessVal["entId"])
+	entUserId := util.Int64All(sessVal["entUserId"])
 	keywords := p.GetString("keywords")
 	industry := strings.TrimSpace(p.GetString("industry")) //选中的行业
 	area := p.GetString("area")                            //地区
@@ -512,7 +516,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	if isSearch {
 		searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
 		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, "", "", "",
-			0, pageSize, searchGroup, searchMode, wordsMode, 0, 0, 0,
+			0, pageSize, searchGroup, searchMode, wordsMode, 0, 0, 0, 0,
 			*userInfo, searchTypeSwitch, p.Request)
 		heightKeys = so.HeightKeys //主关键词和附加词合并,多组空格隔开,作为前端渲染高亮关键词使用
 		//关键词  行业 附加词

+ 9 - 6
src/jfw/front/swordfish.go

@@ -41,7 +41,7 @@ var (
 	BidSearchFieldOfVip    = BidSearchFieldBase + `,"buyertel","buyerperson","agency","agencytel","agencyperson","s_winner","winnertel","winnerperson","signendtime","bidendtime","projectinfo","entidlist","district","sinendtime","buyeraddr"`    //付费列表字段
 	BidSearchFieldFile     = `,"isValidFile"`
 	BidSearchDomainField   = BidSearchFieldOfVip + `,"purchasing"` //领域数据字段基本字段
-	BidSearchFieldProperty = BidSearchFieldBase + `"tag_topinformation","tag_subinformation","tag set.wuyeisfile"`
+	BidSearchFieldProperty = BidSearchFieldBase + `,"tag_topinformation","tag_subinformation","tag_set.wuye.isfile"`
 )
 
 // Praise 剑鱼标讯推送三级页点赞暂弃 改成剑鱼标讯实验室点赞功能
@@ -84,6 +84,10 @@ func (m *Front) PcAjaxReq() {
 	tabularflag := m.GetString("tabularflag")
 	sessVal := m.Session().GetMultiple()
 	userId := util.ObjToString(sessVal["userId"])
+	accountId := util.Int64All(sessVal["accountId"])
+	entAccountId := util.Int64All(sessVal["entAccountId"])
+	entId := util.Int64All(sessVal["entId"])
+	entUserId := util.Int64All(sessVal["entUserId"])
 	phone := util.ObjToString(sessVal["phone"])
 	currentPage, _ := m.GetInteger("pageNumber")
 	pageSize, _ := m.GetInteger("pageSize")
@@ -127,6 +131,8 @@ func (m *Front) PcAjaxReq() {
 	period, _ := m.GetInteger("period")
 	//价格区间 scale
 	scale, _ := m.GetInteger("scale")
+	//价格区间 scale
+	isfile, _ := m.GetInteger("isfile")
 	//换手率 changehand
 	changehand, _ := m.GetInteger("changehand")
 	if userId == "" {
@@ -146,7 +152,6 @@ func (m *Front) PcAjaxReq() {
 				subtype = "招标预告,招标公告,招标结果,招标信用信息"
 			}
 		}
-
 		//未登录用户搜索范围 标题和 正文
 		var selectTypeArr []string
 		selectTypeSplit := strings.Split(selectType, ",")
@@ -191,14 +196,12 @@ func (m *Front) PcAjaxReq() {
 		notkey = m.GetString("notkey")
 		city = m.GetString("city")
 	}
-
 	// p329  非反爬白名单用户不放开  需要处理通用词
 	onList, _ := jyutil.IsOnTheWhitelist(m.Session())
 	searchValueString := m.GetString("searchvalue")
 	if !onList && len(industry) == 0 {
 		searchValueString = jyutil.FilterGeneric(searchValueString)       // 关键词处理通用词
 		additionalWords = jyutil.AdditionalFilterGeneric(additionalWords) // 附加词处理通用词
-
 	}
 	b_word, a_word, s_word := jy.InterceptSearchKW(searchValueString, util.IntAllDef(config.Sysconfig["keywordsLimit"], 35), len(industry) == 0)
 	//放开用户不输入关键词可搜索 --P297需求
@@ -220,7 +223,7 @@ func (m *Front) PcAjaxReq() {
 		}
 		if isLimit == 1 {
 			searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
-			so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, *userInfo, searchTypeSwitch, m.Request)
+			so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId)
 			if so.PageNum < 0 && so.PageSize < 0 {
 				log.Printf("查询参数超出范围,有可能是异常请求; 用户id:%s;用户手机号:%s \n", userId, phone)
 			} else {
@@ -231,7 +234,7 @@ func (m *Front) PcAjaxReq() {
 		}
 	} else {
 		searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
-		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, *userInfo, searchTypeSwitch, m.Request)
+		so := NewSearchOptimize(userId, phone, area, city, district, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, expireTime, propertyForm, subinformation, currentPage, pageSize, searchGroup, searchMode, wordsMode, period, scale, changehand, isfile, *userInfo, searchTypeSwitch, m.Request, accountId, entAccountId, entId, entUserId)
 		list, count, total = so.GetBidSearchListByCache()
 
 	}