|
@@ -1,7 +1,6 @@
|
|
|
package search
|
|
|
|
|
|
import (
|
|
|
- "encoding/base64"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/go-xweb/xweb"
|
|
@@ -14,9 +13,9 @@ import (
|
|
|
"qfw/util/elastic"
|
|
|
ip "qfw/util/ip17mon"
|
|
|
. "qfw/util/mongodb"
|
|
|
- "qfw/util/redis"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
//企业社区首页
|
|
@@ -30,7 +29,7 @@ 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") //是否走名片查询
|
|
|
- if len(param) == 0 {
|
|
|
+ if n.Method() == "POST" {
|
|
|
//请求是表单提交,走的查询
|
|
|
//拼装查询对象
|
|
|
querymap := map[string]string{ //"words": n.GetString("s_value"),
|
|
@@ -44,7 +43,6 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
"c_author": n.GetString("c_author"),
|
|
|
"cityNo": n.GetString("cityNo"), //是否是第一次查询并且没有选择地市,自动根据IP来设
|
|
|
}
|
|
|
-
|
|
|
//查询生成列表数据
|
|
|
var data *[]map[string]interface{}
|
|
|
if i_mingpian != "" {
|
|
@@ -55,15 +53,15 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
rs := FormatData(data)
|
|
|
querymap["entcard"] = n.GetString("mingpian")
|
|
|
if n.GetString("currentPage") != "" {
|
|
|
+ n.SetHeader("Pragma", "No-cache")
|
|
|
+ n.SetHeader("Cache-Control", "no-cache")
|
|
|
+ n.SetHeader("Expires", "0")
|
|
|
return n.Write(rs)
|
|
|
}
|
|
|
n.Render("/member/incmobile/list.html", &xweb.T{"data": rs, "querymap": querymap})
|
|
|
} else {
|
|
|
//反转生成map
|
|
|
- paramstr := param[1:]
|
|
|
- bs, _ := base64.StdEncoding.DecodeString(paramstr)
|
|
|
querymap := map[string]string{}
|
|
|
- json.Unmarshal(bs, &querymap)
|
|
|
data := wxsearhWebContentent(querymap, n, reqType)
|
|
|
rs := FormatData(data)
|
|
|
n.Render("/member/incmobile/list.html", &xweb.T{"data": rs, "querymap": querymap})
|
|
@@ -77,13 +75,18 @@ func FormatData(data *[]map[string]interface{}) string {
|
|
|
return ""
|
|
|
}
|
|
|
for _, v := range *data {
|
|
|
+ estDate := fmt.Sprint(v["EstDate"])
|
|
|
+ if strings.Index(estDate, "-") == -1 {
|
|
|
+ unix, _ := strconv.Atoi(estDate)
|
|
|
+ estDate = time.Unix(int64(unix), 0).Format("2006-01-02")
|
|
|
+ }
|
|
|
tmp := map[string]string{
|
|
|
"_id": fmt.Sprint(v["_id"]),
|
|
|
"EntName": fmt.Sprint(v["EntName"]),
|
|
|
"RegNo": fmt.Sprint(v["RegNo"]),
|
|
|
"LeRep": fmt.Sprint(v["LeRep"]),
|
|
|
"OpLocDistrict": fmt.Sprint(v["OpLocDistrictName"]),
|
|
|
- "EstDate": fmt.Sprint(v["EstDate"]),
|
|
|
+ "EstDate": estDate,
|
|
|
"OpStateName": fmt.Sprint(v["OpStateName"]),
|
|
|
}
|
|
|
entinfos = append(entinfos, tmp)
|
|
@@ -127,24 +130,9 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
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", "wx_ipcity_"+ipcity+"_1")
|
|
|
- if nil != tmp_res {
|
|
|
- tmp_res1, oks1 := tmp_res.([]interface{})
|
|
|
-
|
|
|
- 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
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //str += `{"prefix":{"OpLocDistrict":"` + ipcity + `"}}`
|
|
|
tempBisOne = true
|
|
|
query = `{"query": {
|
|
|
"function_score": {
|
|
@@ -154,7 +142,7 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
}
|
|
|
}
|
|
|
,"_source":["_id","EntName","RegOrgName","RegNo","EntType","LeRep","EstDate","OpLocDistrictName","RegCap","OpStateName","OpState","s_servicenames","s_action","OpLocDistrict","RegCapCurName","s_avatar"]
|
|
|
- ,"from":0,
|
|
|
+ ,"from": ` + fmt.Sprintf("%v", ((currentPage-1)*perPage)) + `,
|
|
|
"size":` + fmt.Sprintf("%v", perPage) + `,
|
|
|
"sort": [{"_score": "desc"},{"OpSint":"desc"},{"RegCap":"desc"}]
|
|
|
}`
|
|
@@ -299,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)
|
|
@@ -392,10 +379,6 @@ func wxsearhWebContentent(querymap map[string]string, n *Wxsearch, reqType strin
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if tempBisOne && len(ipcity) > 0 {
|
|
|
- redis.Put("enterprise", "wx_ipcity_"+ipcity+"_1", res, 5*86400)
|
|
|
- }
|
|
|
return &res
|
|
|
}
|
|
|
|
|
@@ -407,7 +390,7 @@ func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType str
|
|
|
var query = `{
|
|
|
"query": {
|
|
|
"bool": {
|
|
|
- "must": ["match": {"enterprise.EntName": {"query": "` + keyword + `","operator": "and"}}}],
|
|
|
+ "must": [{"match": {"enterprise.EntName": {"query": "` + keyword + `","operator": "and"}}}],
|
|
|
"must_not": {"terms": {"SourceType": ["03", "04"]}},
|
|
|
"should": [],
|
|
|
"minimum_should_match": 1
|