Răsfoiți Sursa

Merge branch 'dev4.5' of ssh://192.168.3.207:10022/qmx/jy into dev4.5

yangfeng 4 ani în urmă
părinte
comite
505b32c6a9

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

@@ -268,10 +268,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 		timeslot = util.ObjToString(p.GetSession("Echo_timeslot"))
 		hasBuyerTel = util.ObjToString(p.GetSession("Echo_hasBuyertel"))
 		hasWinnerTel = util.ObjToString(p.GetSession("Echo_hasWinnertel"))
-
-		if vipData.Status > 0 || vipData.VipStatus > 0 {
-			industry = util.ObjToString(p.GetSession("Echo_industry"))
-		}
+		industry = util.ObjToString(p.GetSession("Echo_industry"))
 	}
 	b_word, s_word := "", ""
 	if keywords != "" {

+ 25 - 1
src/jfw/modules/publicapply/src/config.json

@@ -14,5 +14,29 @@
             "user": "public03@topnet.net.cn"
         }
     ],
-    "industry": "分类综合测试"
+    "industry": "分类综合测试",
+    "defaultEntList": [
+        "744fb1d7cc3561e11c639fcc2ad955c0",
+        "d47dc00fc4453115d4562ab7ce3144c2",
+        "eb1998800775782e1e80e55a325a42ca",
+        "118b315754f688151b1b2b82c2fb7511",
+        "dd049424278d809c5f5ebc1980c254bf",
+        "5e79625afc8952e7123459e9826ed3c1",
+        "372fd29ec10178affd656996ced9480f",
+        "11c4fe5273ab36ee4ee1a5b1a779d543",
+        "66264174942f9e958ee65b98bcd63f1b",
+        "bf2d5bb853e7935d9e8714a34b53cae1",
+        "8945af2c1a25e9138cb64774cf66fa4b",
+        "971ee9b68eb80fc001258d6bd0bbc57a",
+        "8426311c8e40dc50e5583ce686d4d5bc",
+        "434ab2c08bd8b8c84f2946dc9bae3630",
+        "899ba5bb52a17a92bb9b1868fe30cf08",
+        "c882c88dcb108f2445773b0aad030edc",
+        "ddb4a8abeebd2702a64d0aa4e9172e4a",
+        "ea5547e5826dac4253c00901019a31c5",
+        "9ae1bcd5e1c5c24631515a1193073fa5",
+        "4c9a591604f1a3eb74857fc9de35e9ff",
+        "3613232bc702d011232ed57f0027af1c"
+
+    ]
 }

+ 2 - 1
src/jfw/modules/publicapply/src/config/config.go

@@ -12,7 +12,8 @@ type config struct {
 		Pwd  string
 		User string
 	}
-	Industry string
+	Industry       string
+	DefaultEntList []string //企业查询默认展示企业
 }
 type BidColl struct {
 	PayUserCollLimit      int    //付费用户收藏数量最大限制

+ 5 - 6
src/jfw/modules/publicapply/src/enterpriseSearch/entity/entQuery.go

@@ -30,6 +30,7 @@ const (
 	freeSearchNum  = 5   //免费查询数量限制
 
 	index, itype = "qyxy", "qyxy"
+	entQuery     = `{"query":{"bool":{"must":[%s]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address"]}`
 )
 
 var (
@@ -106,7 +107,7 @@ func (es *EnterpriseSearch) Check() (*EnterpriseSearch, error) {
 //return  company_name、company_status、legal_person、capital、company_address、id
 //返回字段 企业名称、企业状态、法人、注册资本、地址、企业id
 func (es *EnterpriseSearch) GetQuerySql() string {
-	query := `{"query":{"bool":{"must":[%s]}},"_source":["_id","company_name","company_status","legal_person","capital","company_address"]}`
+
 	musts := make([]string, 0, 0)
 	//输入查询
 	if es.Match != "" { //或关系 仅需满足一个
@@ -118,10 +119,8 @@ func (es *EnterpriseSearch) GetQuerySql() string {
 					thisQuery = append(thisQuery, fmt.Sprintf(q, es.Match))
 				}
 			}
-		} else { //查询全部
-			for _, q := range AllMatchType {
-				thisQuery = append(thisQuery, fmt.Sprintf(q, es.Match))
-			}
+		} else { //默认查询企业名称
+			thisQuery = append(thisQuery, fmt.Sprintf(AllMatchType["A"], es.Match))
 		}
 		musts = append(musts, fmt.Sprintf(`{"bool":{"should":[%s],"minimum_should_match": 1}}`, strings.Join(thisQuery, ",")))
 	}
@@ -184,7 +183,7 @@ func (es *EnterpriseSearch) GetQuerySql() string {
 	if es.EntContact != "" && es.IsVip {
 		musts = append(musts, fmt.Sprintf(`{"term":{"bid_contracttype":"%s"}}`, es.EntContact))
 	}
-	return fmt.Sprintf(query, strings.Join(musts, ","))
+	return fmt.Sprintf(entQuery, strings.Join(musts, ","))
 }
 
 //DoQuery 根据EnterpriseSearch参数进行企业相关查询

+ 33 - 0
src/jfw/modules/publicapply/src/enterpriseSearch/entity/indexShow.go

@@ -0,0 +1,33 @@
+package entity
+
+import (
+	"encoding/json"
+	"fmt"
+	"jfw/modules/publicapply/src/config"
+	"log"
+	"qfw/util/elastic"
+	"qfw/util/redis"
+	"strings"
+)
+
+const (
+	entSearchCacheDB  = "other"
+	entSearchCacheKey = "entSearchIndexCache"
+)
+
+func GetEntIndexShow() (list []map[string]interface{}) {
+	bytes, err := redis.GetBytes(entSearchCacheDB, entSearchCacheKey)
+	if err == nil {
+		if err = json.Unmarshal(*bytes, &list); err == nil && len(list) > 0 {
+			return
+		}
+	}
+	sql := fmt.Sprintf(entQuery, fmt.Sprintf(`{"terms":{"_id":["%s"]}}`, strings.Join(config.Config.DefaultEntList, "\",\"")))
+	log.Println("sql", sql)
+	listTmp := elastic.Get(index, itype, sql)
+	if listTmp != nil && len(*listTmp) > 0 {
+		list = *listTmp
+		redis.Put(entSearchCacheDB, entSearchCacheKey, list, 60*60*10)
+	}
+	return
+}

+ 16 - 1
src/jfw/modules/publicapply/src/enterpriseSearch/service/search.go

@@ -12,7 +12,8 @@ import (
 
 type EnterpriseSearchAction struct {
 	*xweb.Action
-	doEntSearch xweb.Mapper `xweb:"/enterpriseSearch/doQuery"` //企业搜索
+	doEntSearch     xweb.Mapper `xweb:"/enterpriseSearch/doQuery"` //企业搜索
+	defaultEntIndex xweb.Mapper `xweb:"/enterpriseSearch/index"`   //企业搜索-默认展示
 }
 
 //企业搜索
@@ -58,3 +59,17 @@ func (esa *EnterpriseSearchAction) DoEntSearch() {
 	}
 	esa.ServeJson(NewResult(rData, errMsg))
 }
+
+//首页默认展示企业
+func (esa *EnterpriseSearchAction) DefaultEntIndex() {
+	userId, _ := esa.GetSession("userId").(string)
+	rData, errMsg := func() (interface{}, error) {
+		return map[string]interface{}{
+			"list": entity.GetEntIndexShow(),
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("%s EnterpriseSearchAction DefaultEntIndex:%s\n", userId, errMsg.Error())
+	}
+	esa.ServeJson(NewResult(rData, errMsg))
+}

+ 1 - 1
src/web/staticres/js/wxSupersearch.js

@@ -353,7 +353,7 @@ var SuperSearch = {
 			if(localStorage){
 				localStorage.removeItem("superSearch_history");
 			}
-			if(userId != "" && $("#supersearchPage .search-one-box ul.history-list-box").find("li").length >0){
+			if($("#supersearchPage .search-one-box ul.history-list-box").find("li").length >0){
 				$.ajax({
 					type:"post",
 					url:"/swordfish/delWxHistorySearch",