Procházet zdrojové kódy

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

wangshan před 9 roky
rodič
revize
681cf91976

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

@@ -13,7 +13,6 @@ type Search struct {
 	sim               xweb.Mapper `xweb:"POST /search/sim"`                          //即时搜索
 	searchEntSer      xweb.Mapper `xweb:"/searchEntSer/(.*)"`                        //获取企业的服务列表
 	entCommunity      xweb.Mapper `xweb:"/front/entCommunity.html"`
-	wxMingpian        xweb.Mapper `xweb:"/wx/search/enterprise/mingpian"` //获取名片
 }
 
 func init() {

+ 0 - 29
core/src/qfw/search/searchService.go

@@ -8,7 +8,6 @@ import (
 	"gopkg.in/mgo.v2/bson"
 	"html/template"
 	"log"
-	"qfw/coreutil"
 	"qfw/front"
 	. "qfw/member"
 	"qfw/mobile"
@@ -766,31 +765,3 @@ func searhWebContententMp(querymap map[string]string, n *Search, reqType string,
 	pagination := front.MakePagination(1, 1, 1, querymap, "/wx/search/enterprise/"+reqType+"ent_%s.html")
 	return &res, &pagination, has
 }
-
-//获取名片名称
-func (s *Search) WxMingpian() error {
-	res := make(map[string]string)
-	res["name"] = ""
-	res["on"] = "y"
-	if s.GetSession("s_m_openid") != nil {
-		serverId := s.GetString("serverId")
-		ret := coreutil.WxDownloadImg(serverId)
-		if len(ret) > 1 {
-			log.Println("picpath", ret[1])
-			res["on"] = ret[0]
-			names := coreutil.CardRecognition(ret[1])
-			for k, v := range names {
-				name := fmt.Sprint(v)
-				if mpian_reg.MatchString(name) {
-					res["name"] = name
-					break
-				}
-				if k == len(names)-1 {
-					res["name"] = name
-				}
-			}
-		}
-	}
-	s.ServeJson(&res)
-	return nil
-}

+ 3 - 2
core/src/qfw/search/wxsearch.go

@@ -10,8 +10,9 @@ import (
 
 type Wxsearch struct {
 	*xweb.Action
-	wxgetEnterpriseList xweb.Mapper `xweb:"/wx/search/enterprise/([^.]*)ent([^.]*).html"` //查询企业列表
-	wxsearchEntSer      xweb.Mapper `xweb:"/wx/searchEntSer/(.*)"`                        //获取企业的服务列表
+	wxIndex             xweb.Mapper `xweb:"/wx/search/enterprise/index.html"` //查询企业列表
+	wxMingpian          xweb.Mapper `xweb:"/wx/search/enterprise/mingpian"`   //获取名片
+	wxgetEnterpriseList xweb.Mapper `xweb:"/wx/search/enterprise/list.html"`  //查询企业列表
 }
 
 var mpian_reg *regexp.Regexp //名片

+ 83 - 121
core/src/qfw/search/wxsearchservice.go

@@ -7,8 +7,8 @@ import (
 	"github.com/go-xweb/xweb"
 	"html/template"
 	"log"
-	"qfw/front"
-	. "qfw/member"
+	"qfw/coreutil"
+	"qfw/mobile"
 	. "qfw/util"
 	"qfw/util/consts"
 	"qfw/util/elastic"
@@ -19,69 +19,15 @@ import (
 	"strings"
 )
 
-//获取某个企业服务列表数据
-func (search *Wxsearch) WxsearchEntSer(id string) error {
-	if search.Method() == "POST" {
-		//分页
-		currentPage, _ := strconv.Atoi(search.GetString("currentPage"))
-		perPage, _ := strconv.Atoi(search.GetString("perPage"))
-		if perPage == 0 {
-			perPage = 10
-		}
-		mustnot := `{"term" : {"i_status" : 1 }}`
-		var fields, collection, query, tempstrquery string
-		collection = "service"
-		tempstrquery = `{"query_string":{"default_field": "s_enterpriseid","query":"` + id + `"}}`
-		servicequery := ""
-		if search.GetSession("entid") == nil || search.GetSession("entid").(string) != id {
-			servicequery = `,"must_not" : [` + mustnot + `]`
-		} else {
-
-		}
-		query = `{"query": {
-		    "bool": {
-			  "must":[` + tempstrquery + `]` + servicequery + `
-		    }
-		  }}`
-		//需要查到的字段信息
-		fields = `"_id","s_name","s_introduction","s_images","s_enterpriseid","s_isshow","i_status"`
-		res := map[string]interface{}{}
-		res["totalRows"] = elastic.Count("service", collection, query)
-		//查询服务列表数据
-		result := elastic.Get("service", collection, `{"query":{"bool": {"must":[`+tempstrquery+`]`+servicequery+`}},
-		_source:[`+fields+`],
-		sort:{"l_createdate":"desc"},
-		from:`+fmt.Sprintf("%v", ((currentPage-1)*perPage))+`,
-		size:`+fmt.Sprintf("%v", perPage)+`
-		}`)
-		//result := elastic.GetPage("service", collection, query, order_str, fields, (currentPage-1)*perPage, perPage)
-
-		for _, v := range *result {
-			b, _ := CheckAuth(v)
-			if b {
-				v["s_isEdit"] = "1"
-			} else {
-				v["s_isEdit"] = "0"
-			}
-			if IntAll(v["i_status"]) == 1 {
-				v["s_remove"] = 1
-			} else {
-				v["s_remove"] = 0
-			}
-		}
-
-		res["data"] = result
-		res["currentPage"] = currentPage
-		search.ServeJson(&res)
-	}
+//企业社区首页
+func (n *Wxsearch) WxIndex() error {
+	n.T["signature"] = mobile.GetSignature(n.Url())
+	n.Render("/member/incmobile/index.html", &n.T)
 	return nil
 }
 
 //企业列表
 func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
-	//必须是登录之后的已认证用户才可以进入企业社区
-	//if ui, _ := (n.GetSession("userInfo")).(*map[string]interface{}); reqType == "m_" || (n.GetSession("userType") != nil && IntAll(n.GetSession("userType")) > 0) && ((n.GetSession("identWay") != nil && IntAll(n.GetSession("identWay")) == 1) || ((*ui)["s_pid"] != nil && (*ui)["s_pid"].(string) != "")) {
-	//n.T["uri"] = n.Uri()
 	i_mingpian := n.GetString("i_mingpian") //是否走名片查询
 	if len(param) == 0 {
 		//请求是表单提交,走的查询
@@ -98,17 +44,18 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
 			"cityNo":      n.GetString("cityNo"), //是否是第一次查询并且没有选择地市,自动根据IP来设
 		}
 		//查询生成列表数据
+		var data *[]map[string]interface{}
+
+		var has bool = false
 		if i_mingpian != "" {
-			data, pagination, has := wxsearhWebContententMp(querymap, n, reqType, false)
-			n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+			data, has = wxsearhWebContententMp(querymap, n, reqType, false)
 			if !has {
-				data, pagination := wxsearhWebContentent(querymap, n, reqType)
-				n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+				data = wxsearhWebContentent(querymap, n, reqType)
 			}
 		} else {
-			data, pagination := wxsearhWebContentent(querymap, n, reqType)
-			n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+			data = wxsearhWebContentent(querymap, n, reqType)
 		}
+		n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data})
 	} else {
 		//反转生成map
 		paramstr := param[1:]
@@ -117,14 +64,14 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
 
 		json.Unmarshal(bs, &querymap)
 		log.Println(querymap)
-		data, pagination := wxsearhWebContentent(querymap, n, reqType)
-		n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+		data := wxsearhWebContentent(querymap, n, reqType)
+		n.Render("/member/incombile/list.html", &xweb.T{"querymap": querymap, "data": data})
 	}
 	return nil
 }
 
 //实际的查询企业社区业务逻辑
-func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType string) (*[]map[string]interface{}, *[]interface{}) {
+func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType string) *[]map[string]interface{} {
 	perPage, _ := strconv.Atoi(querymap["perPage"])
 	currentPage, _ := strconv.Atoi(querymap["currentPage"])
 	//修复
@@ -134,16 +81,16 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 	if currentPage < 1 {
 		currentPage = 1
 	}
-
+	if currentPage > 20 {
+		currentPage = 20
+	}
 	queryStr := querymap["query"]
 	fmt.Println("检索条件:", queryStr)
 	str := ``
 	//查询词
 	keyword := queryStr
 	//排序
-
 	sort := ""
-
 	//地区
 	city := querymap["city"]
 	var tempQuery = ""
@@ -151,7 +98,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 	cityNo := querymap["cityNo"]
 	tempBisOne := false
 	ipcity := ""
-	var total int64 = 500
 	if cityNo == "" && len(queryStr) == 0 {
 		querymap["cityNo"] = "1"
 		tn, er := ip.Find(n.Protocol())
@@ -160,18 +106,17 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 			case "河南", "广西", "黑龙江", "青海", "西藏", "安徽", "山西":
 				ipcity = consts.Scode[tn.Region]
 				if len(ipcity) > 0 {
-					tmp_res := redis.Get("enterprise", "wx_"+ipcity+"_1")
-					tmp_pag := redis.Get("enterprise", "wx_"+ipcity+"_2")
-					if nil != tmp_res && nil != tmp_pag {
+					tmp_res := redis.Get("enterprise", "wx_ipcity_"+ipcity+"_1")
+					if nil != tmp_res {
 						tmp_res1, oks1 := tmp_res.([]interface{})
-						tmp_pag1, oks2 := tmp_pag.([]interface{})
-						if tmp_res1 != nil && tmp_pag1 != nil && oks1 && oks2 {
+
+						if tmp_res1 != nil && oks1 {
 							tmp_resn := make([]map[string]interface{}, len(tmp_res1))
 							for k := 0; k < len(tmp_res1); k++ {
 								tmp_resn1, _ := tmp_res1[k].(map[string]interface{})
 								tmp_resn[k] = tmp_resn1
 							}
-							return &tmp_resn, &tmp_pag1
+							return &tmp_resn
 						}
 					}
 
@@ -184,7 +129,7 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 						      }
 						    }
 						  }
-						,"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","OpStateName","s_servicenames","s_action","OpLocDistrict"]
+						,"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","RegCap","OpStateName","OpState","s_servicenames","s_action","OpLocDistrict","RegCapCurName","s_avatar"]
 						,"from":0,
 						"size":` + fmt.Sprintf("%v", perPage) + `,
 						  "sort": [{"_score": "desc"},{"OpSint":"desc"},{"RegCap":"desc"}]
@@ -233,7 +178,14 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 			}
 			str += `{"term":{"EntType":"` + c_qfl + `"}}`
 		}
-
+		//存续/在营
+		OpState := querymap["OpState"]
+		if OpState != "" {
+			if len(str) > 0 {
+				str += ","
+			}
+			str += `{"term":{"OpState":"` + OpState + `"}}`
+		}
 		//认证
 		c_author := querymap["c_author"]
 		if c_author == "Y" {
@@ -243,17 +195,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 			str += `{
 				"terms":{"enterprise.s_action":["01"]}
 			}`
-
-			/**
-					str += `{
-			          "match": {
-			            "enterprise.s_action": {
-			              "query":"` + "01" + `",
-			              "operator": "and"
-			            }
-			          }
-			        }`
-					**/
 		}
 		queryShould := ""
 
@@ -329,25 +270,21 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 			"s_synopsis":{"force_source": true},
 			"stock":{"force_source": true}
         }
-    },"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","OpStateName","s_servicenames","s_action","OpLocDistrict","s_submitid"]
+    },"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","RegCap","OpStateName","OpState","s_servicenames","s_action","OpLocDistrict","s_submitid","RegCapCurName","s_avatar"]
 	,"from":` + fmt.Sprintf("%v", ((currentPage-1)*perPage)) + `,
 	"size":` + fmt.Sprintf("%v", perPage) +
 			`,"sort":[` + sort + `] }`
-
-		total = elastic.Count("enterprise", "enterprise", tempQuery)
-	}
-	if total > 500 {
-		total = 500
 	}
+
 	//查询列表数据
 	client := elastic.GetEsConn()
 	defer elastic.DestoryEsConn(client)
 	if client == nil {
-		return nil, nil
+		return nil
 	}
 	searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
 	if err != nil {
-		return nil, nil
+		return nil
 	}
 	var res []map[string]interface{}
 	if searchResult.Hits != nil {
@@ -362,13 +299,24 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 
 			EntName, _ := res[i]["EntName"].(string)
 			tmpNo := res[i]["EntType"]
+			res[i]["RegCapEntType"] = tmpNo
 			if tmpNo != nil {
 				switch tmpNo.(string) {
 				case "4500", "6800", "6810", "6820", "7100", "7110", "7120", "7130", "7190", "9200", "6840", "2100", "2110", "2120", "2121", "2122", "2123", "2130", "2140", "2150", "2151", "2152", "2190", "2200", "2210", "2211", "2212", "2213", "2219", "2220", "2221", "2222", "2223", "2229", "4000", "4300", "4310", "4320", "4330", "4340", "4550", "4551", "4552", "4553", "4560", "5800", "5810", "5820":
 					res[i]["EntType"] = "5810"
 				}
 			}
-
+			//处理分公司
+			if res[i]["RegCapEntType"] != nil && res[i]["RegCapEntType"].(string) != "" {
+				RegCapEntType := res[i]["RegCapEntType"].(string)
+				if RegCapEntType == "5810" || RegCapEntType == "6810" || RegCapEntType == "7310" || RegCapEntType == "3200" || RegCapEntType == "3100" {
+					res[i]["RegCapEntType"] = "5810"
+				} else if len(RegCapEntType) > 1 {
+					if RegCapEntType[:1] == "2" {
+						res[i]["RegCapEntType"] = "5810"
+					}
+				}
+			}
 			entlerp, _ := res[i]["LeRep"].(string)
 			tmpentno, _ := res[i]["RegNo"].(string)
 			if len(keyword) < 1 {
@@ -381,13 +329,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 			} else {
 				res[i]["EntName"] = template.HTML(EntName)
 			}
-			//当企业名称为空获取企业法人的名称
-			/**ename := template.HTML(EntName)
-			if res[i]["EntName"] == nil || len(ename) == 0 {
-				res[i]["EntName"] = res[i]["LeRep"]
-			}
-			**/
-			//
 
 			id := res[i]["s_submitid"]
 			if id != nil {
@@ -427,20 +368,15 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
 
 		}
 	}
-	//log.Println(total)
-	//生成分页
-	pagination := front.MakePagination(perPage, currentPage, int(total), querymap, "/wx/search/enterprise/"+reqType+"ent_%s.html")
 
 	if tempBisOne && len(ipcity) > 0 {
-		redis.Put("enterprise", "wx_"+ipcity+"_1", res, 5*86400)
-		redis.Put("enterprise", "wx_"+ipcity+"_2", pagination, 5*86400)
+		redis.Put("enterprise", "wx_ipcity_"+ipcity+"_1", res, 5*86400)
 	}
-	return &res, &pagination
-
+	return &res
 }
 
 //通过企业名片查询
-func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType string, has bool) (*[]map[string]interface{}, *[]interface{}, bool) {
+func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType string, has bool) (*[]map[string]interface{}, bool) {
 	queryStr := querymap["query"]
 	fmt.Println("检索条件:", queryStr)
 	keyword := queryStr
@@ -478,11 +414,11 @@ func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType str
 	client := elastic.GetEsConn()
 	defer elastic.DestoryEsConn(client)
 	if client == nil {
-		return nil, nil, false
+		return nil, false
 	}
 	searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
 	if err != nil {
-		return nil, nil, false
+		return nil, false
 	}
 	var res []map[string]interface{}
 	if searchResult.Hits != nil {
@@ -554,7 +490,33 @@ func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType str
 			}
 		}
 	}
-	//生成分页
-	pagination := front.MakePagination(1, 1, 1, querymap, "/wx/search/enterprise/"+reqType+"ent_%s.html")
-	return &res, &pagination, has
+	return &res, has
+}
+
+//获取名片名称
+func (n *Wxsearch) WxMingpian() error {
+	res := make(map[string]string)
+	res["name"] = ""
+	res["on"] = "y"
+	if n.GetSession("s_m_openid") != nil {
+		serverId := n.GetString("serverId")
+		ret := coreutil.WxDownloadImg(serverId)
+		if len(ret) > 1 {
+			log.Println("picpath", ret[1])
+			res["on"] = ret[0]
+			names := coreutil.CardRecognition(ret[1])
+			for k, v := range names {
+				name := fmt.Sprint(v)
+				if mpian_reg.MatchString(name) {
+					res["name"] = name
+					break
+				}
+				if k == len(names)-1 {
+					res["name"] = name
+				}
+			}
+		}
+	}
+	n.ServeJson(&res)
+	return nil
 }