|
@@ -7,11 +7,8 @@ import (
|
|
|
"github.com/go-xweb/xweb"
|
|
|
"github.com/p/mahonia"
|
|
|
"html/template"
|
|
|
- "log"
|
|
|
"qfw/coreutil"
|
|
|
- "qfw/front"
|
|
|
- . "qfw/member"
|
|
|
- "qfw/mobile"
|
|
|
+ // "qfw/mobile"
|
|
|
. "qfw/util"
|
|
|
"qfw/util/consts"
|
|
|
"qfw/util/elastic"
|
|
@@ -22,99 +19,15 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
-//微信企业查询首页
|
|
|
-func (s *Wxsearch) WxEnterprise() error {
|
|
|
- s.T["signature"] = mobile.GetSignature(s.Url())
|
|
|
- return s.Render("/member/incombile/index.html", &s.T)
|
|
|
-}
|
|
|
-
|
|
|
-//获取名片名称
|
|
|
-func (s *Wxsearch) WxMingpian() error {
|
|
|
- res := make(map[string]string)
|
|
|
- if s.GetSession("s_m_openid") != nil {
|
|
|
- serverId := s.GetString("serverId")
|
|
|
- picpath := coreutil.WxDownloadImg(serverId)
|
|
|
- log.Println("picpath", picpath)
|
|
|
- names := coreutil.CardRecognition(picpath)
|
|
|
- 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
|
|
|
-}
|
|
|
-
|
|
|
-//获取某个企业服务列表数据
|
|
|
-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()
|
|
|
- log.Println(n.Header("User-Agent"))
|
|
|
i_mingpian := n.GetString("i_mingpian") //是否走名片查询
|
|
|
if len(param) == 0 {
|
|
|
//请求是表单提交,走的查询
|
|
@@ -130,29 +43,29 @@ func (n *Wxsearch) WxgetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
"c_author": n.GetString("c_author"),
|
|
|
"cityNo": n.GetString("cityNo"), //是否是第一次查询并且没有选择地市,自动根据IP来设
|
|
|
}
|
|
|
+
|
|
|
//查询生成列表数据
|
|
|
var data *[]map[string]interface{}
|
|
|
var has bool
|
|
|
if i_mingpian != "" {
|
|
|
- data, _, has = wxsearhWebContententMp(querymap, n, reqType, false)
|
|
|
+ data, has = wxsearhWebContententMp(querymap, n, reqType, false)
|
|
|
if !has {
|
|
|
- data, _ = wxsearhWebContentent(querymap, n, reqType)
|
|
|
+ data = wxsearhWebContentent(querymap, n, reqType)
|
|
|
}
|
|
|
} else {
|
|
|
- data, _ = wxsearhWebContentent(querymap, n, reqType)
|
|
|
+ data = wxsearhWebContentent(querymap, n, reqType)
|
|
|
}
|
|
|
rs := FormatData(data)
|
|
|
- log.Println("阿斯顿发送到发送到发的", string(rs))
|
|
|
- n.Render("/member/incmobile/list.html", &xweb.T{"data": 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)
|
|
|
+ data := wxsearhWebContentent(querymap, n, reqType)
|
|
|
rs := FormatData(data)
|
|
|
- n.Render("/member/incmobile/list.html", &xweb.T{"data": rs})
|
|
|
+ n.Render("/member/incmobile/list.html", &xweb.T{"data": rs, "querymap": querymap})
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
@@ -178,7 +91,7 @@ func FormatData(data *[]map[string]interface{}) string {
|
|
|
}
|
|
|
|
|
|
//实际的查询企业社区业务逻辑
|
|
|
-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"])
|
|
|
//修复
|
|
@@ -188,16 +101,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 = ""
|
|
@@ -205,7 +118,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())
|
|
@@ -214,18 +126,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
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -238,7 +149,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"}]
|
|
@@ -287,7 +198,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" {
|
|
@@ -297,17 +215,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 := ""
|
|
|
|
|
@@ -383,25 +290,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 {
|
|
@@ -416,13 +319,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 {
|
|
@@ -435,13 +349,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 {
|
|
@@ -481,20 +388,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
|
|
@@ -532,11 +434,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 {
|
|
@@ -608,7 +510,32 @@ 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 {
|
|
|
+ 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
|
|
|
}
|