ソースを参照

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

李广朋 9 年 前
コミット
8f856a006d

+ 1 - 1
core/src/qfw/search/searchService.go

@@ -303,7 +303,7 @@ func searhWebContentent(querymap map[string]string, n *Search, reqType string) (
 		tn, er := ip.Find(n.Protocol())
 		if nil == er {
 			switch tn.Region {
-			case "河南", "广西", "黑龙江", "青海", "西藏", "安徽", "山西":
+			case "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林", "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西", "山东", "广东", "广西", "海南", "河南", "湖北", "湖南", "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃", "青海", "宁夏", "新疆":
 				ipcity = consts.Scode[tn.Region]
 				if len(ipcity) > 0 {
 					tmp_res := redis.Get("enterprise", "ipcity_"+ipcity+"_1")

+ 29 - 8
core/src/qfw/search/wxsearchservice.go

@@ -6,11 +6,12 @@ import (
 	"github.com/go-xweb/xweb"
 	"github.com/p/mahonia"
 	"html/template"
-	"log"
 	"qfw/coreutil"
 	"qfw/mobile"
 	. "qfw/util"
+	"qfw/util/consts"
 	"qfw/util/elastic"
+	ip "qfw/util/ip17mon"
 	. "qfw/util/mongodb"
 	"strconv"
 	"strings"
@@ -28,11 +29,9 @@ func (n *Wxsearch) WxIndex() error {
 func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
 	n.T["signature"] = mobile.GetSignature(n.Url())
 	i_mingpian := n.GetString("i_mingpian") //是否走名片查询
-	log.Println(n.Method())
 	if n.Method() == "POST" {
 		//请求是表单提交,走的查询
 		//拼装查询对象
-		log.Println("进入POST查找")
 		querymap := map[string]string{ //"words": n.GetString("s_value"),
 			"perPage":     "20",
 			"currentPage": n.GetString("currentPage"),
@@ -44,7 +43,6 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
 			"c_author":    n.GetString("c_author"),
 			"cityNo":      n.GetString("cityNo"), //是否是第一次查询并且没有选择地市,自动根据IP来设
 		}
-		log.Println(querymap, "---------------------------", n, reqType)
 		//查询生成列表数据
 		var data *[]map[string]interface{}
 		if i_mingpian != "" {
@@ -52,9 +50,7 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
 		} else {
 			data = wxsearhWebContentent(querymap, n, reqType)
 		}
-		log.Println(data)
 		rs := FormatData(data)
-		log.Println(rs)
 		querymap["entcard"] = n.GetString("mingpian")
 		if n.GetString("currentPage") != "" {
 			n.SetHeader("Pragma", "No-cache")
@@ -126,8 +122,34 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 	city := querymap["city"]
 	var tempQuery = ""
 	var query = ""
+	cityNo := querymap["cityNo"]
 	tempBisOne := false
-
+	ipcity := ""
+	if cityNo == "" && len(queryStr) == 0 {
+		querymap["cityNo"] = "1"
+		tn, er := ip.Find(n.Protocol())
+		if nil == er {
+			switch tn.Region {
+			case "北京", "天津", "河北", "山西", "内蒙古", "辽宁", "吉林", "黑龙江", "上海", "江苏", "浙江", "安徽", "福建", "江西", "山东", "广东", "广西", "海南", "河南", "湖北", "湖南", "重庆", "四川", "贵州", "云南", "西藏", "陕西", "甘肃", "青海", "宁夏", "新疆":
+				ipcity = consts.Scode[tn.Region]
+				if len(ipcity) > 0 {
+					tempBisOne = true
+					query = `{"query": {
+					"function_score": {
+						      "script_score": {
+						        "script": "if(doc['OpLocDistrict'].value&&doc['OpLocDistrict'].value.substring(0,2)=='` + ipcity + `') return 1 else return 0"
+						      }
+						    }
+						  }
+						,"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","RegCap","OpStateName","OpState","s_servicenames","s_action","OpLocDistrict","RegCapCurName","s_avatar"]
+						,"from": ` + fmt.Sprintf("%v", ((currentPage-1)*perPage)) + `,
+						"size":` + fmt.Sprintf("%v", perPage) + `,
+						  "sort": [{"_score": "desc"},{"OpSint":"desc"},{"RegCap":"desc"}]
+						}`
+				}
+			}
+		}
+	}
 	if !tempBisOne {
 		if city != "" && city != "0" {
 			//fmt.Println("city:", city)
@@ -265,7 +287,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 	"size":` + fmt.Sprintf("%v", perPage) +
 			`,"sort":[` + sort + `] }`
 	}
-
 	//查询列表数据
 	client := elastic.GetEsConn()
 	defer elastic.DestoryEsConn(client)