|
@@ -5,6 +5,7 @@ import (
|
|
|
"container/list"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/go-xweb/httpsession"
|
|
|
_ "github.com/go-xweb/xweb"
|
|
|
mgo "gopkg.in/mgo.v2"
|
|
|
. "gopkg.in/mgo.v2/bson"
|
|
@@ -14,6 +15,7 @@ import (
|
|
|
"qfw/mobile"
|
|
|
"qfw/util"
|
|
|
"qfw/util/credit"
|
|
|
+ elastic "qfw/util/elastic"
|
|
|
. "qfw/util/mongodb"
|
|
|
"qfw/util/redis"
|
|
|
"strconv"
|
|
@@ -42,7 +44,7 @@ func FormatDate(src *interface{}) string {
|
|
|
}
|
|
|
|
|
|
func GetEntInfo(id string) map[string]interface{} {
|
|
|
- res := FindById("enterprise", id, `{"RegNo":1, "EntName":1, "EntType":1, "EntTypeName":1, "OpLocDistrict":1, "LeRep":1, "LegCerNO":1, "Tel":1, "Dom":1, "OpScope":1, "OpFrom":1, "OpTo":1, "RegCap":1, "EstDate":1, "CompForm":1, "CompFormName":1, "OpState":1, "OpStateName":1, "RegOrgName":1, "IssBLicDate":1, "Timestamp":1, "s_synopsis":1, "SourceType":1, "Nb_email":1,"IndustryPhyName":1,"investor":1,"alterInfo":1, "s_enturl, "i_province":1, "i_city":1, "i_area":1,"s_action":1,"s_persion":1,"s_mobile":1,"s_address":1,"s_avatar":1,"s_microwebsite":1,"s_qq":1,"s_submitid":1,"s_email":1,"staffinfo":1}`)
|
|
|
+ res := FindById("enterprise", id, `{"RegNo":1, "EntName":1, "EntType":1, "EntTypeName":1, "OpLocDistrict":1, "LeRep":1, "LegCerNO":1, "Tel":1, "Dom":1, "OpScope":1, "OpFrom":1, "OpTo":1, "RegCap":1, "EstDate":1, "CompForm":1, "CompFormName":1, "OpState":1, "OpStateName":1, "RegOrgName":1, "IssBLicDate":1, "Timestamp":1, "s_synopsis":1, "SourceType":1, "Nb_email":1,"IndustryPhyName":1,"investor":1,"alterInfo":1, "s_enturl, "i_province":1, "i_city":1, "i_area":1,"s_action":1,"s_persion":1,"s_mobile":1,"s_address":1,"s_avatar":1,"s_microwebsite":1,"s_qq":1,"s_submitid":1,"s_email":1,"staffinfo":1,"RegCapCurName":1}`)
|
|
|
if res != nil && len(*res) > 0 {
|
|
|
id := (*res)["s_submitid"]
|
|
|
if id != nil {
|
|
@@ -261,33 +263,38 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
|
|
|
yp.T["res"] = info
|
|
|
regNo, _ := info["RegNo"].(string)
|
|
|
entName, _ := info["EntName"].(string)
|
|
|
- relation := redis.Get("enterprise", "relation-"+regNo)
|
|
|
- if relation == nil {
|
|
|
- relation = makeRelation(regNo, entName)
|
|
|
- redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
- }
|
|
|
- var nodes *[]map[string]interface{}
|
|
|
- if d, err := json.Marshal(relation.(map[string]interface{})["nodes"]); err == nil && json.Unmarshal(d, &nodes) == nil && len(*nodes) > 0 {
|
|
|
- var regNos []string
|
|
|
- for _, v := range *nodes {
|
|
|
- if v["type"] == "e" {
|
|
|
- regNos = append(regNos, v["name"].(string))
|
|
|
- }
|
|
|
- if len(regNos) == 6 {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- if len(regNos) > 0 {
|
|
|
- relevantEnts := Find("enterprise", M{"RegNo": M{"$in": regNos}}, nil, `{"s_avatar":1,"RegNo":1,"EntName":1}`, false, -1, -1)
|
|
|
- if relevantEnts != nil && len(*relevantEnts) > 0 {
|
|
|
- for _, relevantEnt := range *relevantEnts {
|
|
|
- relevantEnt["_id"] = util.BsonIdToSId(relevantEnt["_id"])
|
|
|
+ //相关企业
|
|
|
+ relation := getRelation(regNo, entName)
|
|
|
+ if relation != nil {
|
|
|
+ var nodes *[]map[string]interface{}
|
|
|
+ if d, err := json.Marshal(relation.(map[string]interface{})["nodes"]); err == nil && json.Unmarshal(d, &nodes) == nil && len(*nodes) > 0 {
|
|
|
+ var regNos []string
|
|
|
+ for _, v := range *nodes {
|
|
|
+ if v["type"] == "e" {
|
|
|
+ regNos = append(regNos, v["name"].(string))
|
|
|
+ }
|
|
|
+ if len(regNos) == 6 {
|
|
|
break
|
|
|
}
|
|
|
- yp.T["relevantEnts"] = relevantEnts
|
|
|
+ }
|
|
|
+ if len(regNos) > 0 {
|
|
|
+ relevantEnts := Find("enterprise", M{"RegNo": M{"$in": regNos}}, nil, `{"s_avatar":1,"RegNo":1,"EntName":1}`, false, -1, -1)
|
|
|
+ if relevantEnts != nil && len(*relevantEnts) > 0 {
|
|
|
+ for _, relevantEnt := range *relevantEnts {
|
|
|
+ relevantEnt["_id"] = util.BsonIdToSId(relevantEnt["_id"])
|
|
|
+ break
|
|
|
+ }
|
|
|
+ yp.T["relevantEnts"] = relevantEnts
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //失信信息第一页数据
|
|
|
+ yp.T["dishonesty"] = getDishonesty(util.If(info["LegCerNO"] != nil, info["LegCerNO"], "").(string), 1)
|
|
|
+ //服务列表第一页数据
|
|
|
+ yp.T["service"] = findServiceByEntId(id, 1, yp.Session())
|
|
|
+ //关系网数据
|
|
|
+ yp.T["relation"] = relation
|
|
|
contentuser, erruser := yp.Render4Cache("/yellowpage/enterpriseinfo.html", &yp.T)
|
|
|
if erruser == nil {
|
|
|
redis.PutBytes("enterprise", "enterpriseInfo_"+id, &contentuser, 7*ONEDAY)
|
|
@@ -395,7 +402,11 @@ func storeNode(data *map[string]interface{}, ls *list.List, dir /*方向反转*/
|
|
|
if (*data)["invopstate"] != nil {
|
|
|
invopstate = (*data)["invopstate"].(string)
|
|
|
}
|
|
|
- ls.PushBack([]string{invtype, invcerno, invname, entregno, entname, strconv.Itoa(level), fmt.Sprint(invweight), invacconam, fmt.Sprint(regcap), fmt.Sprint(invregcap), legcerno, opstate, invopstate})
|
|
|
+ regcapcurname := ""
|
|
|
+ if (*data)["regcapcurname"] != nil {
|
|
|
+ regcapcurname = (*data)["regcapcurname"].(string)
|
|
|
+ }
|
|
|
+ ls.PushBack([]string{invtype, invcerno, invname, entregno, entname, strconv.Itoa(level), fmt.Sprint(invweight), invacconam, fmt.Sprint(regcap), fmt.Sprint(invregcap), legcerno, opstate, invopstate, regcapcurname})
|
|
|
}
|
|
|
|
|
|
func findIndex(code string, arr []interface{}) (index int, mtType string) {
|
|
@@ -425,11 +436,7 @@ func (yp *Yellowpage) GetRelation() error {
|
|
|
if regNo == "" || entName == "" {
|
|
|
return nil
|
|
|
}
|
|
|
- relation := redis.Get("enterprise", "relation-"+regNo)
|
|
|
- if relation == nil {
|
|
|
- relation = makeRelation(regNo, entName)
|
|
|
- redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
- }
|
|
|
+ relation := getRelation(regNo, entName)
|
|
|
yp.ServeJson(M{"flag": true, "relation": relation})
|
|
|
r := relation.(map[string]interface{})
|
|
|
var links *[]map[string]interface{}
|
|
@@ -443,6 +450,17 @@ func (yp *Yellowpage) GetRelation() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+func getRelation(regNo, entName string) interface{} {
|
|
|
+ if regNo == "" || entName == "" {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ relation := redis.Get("enterprise", "relation-"+regNo)
|
|
|
+ if relation == nil {
|
|
|
+ relation = makeRelation(regNo, entName)
|
|
|
+ redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
+ }
|
|
|
+ return relation
|
|
|
+}
|
|
|
|
|
|
//生成图用的结果
|
|
|
func makeRelation(mnregno, mnname string) interface{} {
|
|
@@ -479,25 +497,27 @@ func makeRelation(mnregno, mnname string) interface{} {
|
|
|
//加投资人
|
|
|
if _, ok := node[v[1]]; !ok {
|
|
|
node[v[1]] = map[string]string{
|
|
|
- "name": v[1],
|
|
|
- "text": v[2],
|
|
|
- "type": v[0],
|
|
|
- "regcap": v[9],
|
|
|
- "level": v[5],
|
|
|
- "legcerno": v[10],
|
|
|
- "opstate": v[12],
|
|
|
+ "name": v[1],
|
|
|
+ "text": v[2],
|
|
|
+ "type": v[0],
|
|
|
+ "regcap": v[9],
|
|
|
+ "level": v[5],
|
|
|
+ "legcerno": v[10],
|
|
|
+ "opstate": v[12],
|
|
|
+ "regcapcurname": v[13],
|
|
|
}
|
|
|
}
|
|
|
//加企业
|
|
|
if _, ok := node[v[3]]; !ok {
|
|
|
node[v[3]] = map[string]string{
|
|
|
- "name": v[3],
|
|
|
- "text": v[4],
|
|
|
- "type": "e",
|
|
|
- "regcap": v[8],
|
|
|
- "level": v[5],
|
|
|
- "legcerno": v[10],
|
|
|
- "opstate": v[11],
|
|
|
+ "name": v[3],
|
|
|
+ "text": v[4],
|
|
|
+ "type": "e",
|
|
|
+ "regcap": v[8],
|
|
|
+ "level": v[5],
|
|
|
+ "legcerno": v[10],
|
|
|
+ "opstate": v[11],
|
|
|
+ "regcapcurname": v[13],
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -535,18 +555,104 @@ func (yp *Yellowpage) GetDishonesty() error {
|
|
|
if yp.Method() == "POST" {
|
|
|
legcerNo := yp.GetString("legcerNo")
|
|
|
currentPage, _ := yp.GetInteger("currentPage")
|
|
|
- var res map[string]interface{}
|
|
|
- if ret := redis.Get("enterprise", "dishonesty-"+legcerNo+"-"+fmt.Sprint(currentPage)); ret != nil {
|
|
|
- res = ret.(map[string]interface{})
|
|
|
- } else {
|
|
|
- limit, _ := yp.GetInteger("pageSize")
|
|
|
- start := (currentPage - 1) * limit
|
|
|
- count := Count("laolai", `{"s_cardnum":"`+legcerNo+`"}`)
|
|
|
- r := Find("laolai", `{"s_cardnum":"`+legcerNo+`"}`, `{"l_date":-1}`, `{"l_date":1,"iname":1,"court_name":1,"case_code":1,"performance":1}`, false, start, limit)
|
|
|
- res = map[string]interface{}{"list": r, "count": count}
|
|
|
- redis.Put("enterprise", "dishonesty-"+legcerNo+"-"+fmt.Sprint(currentPage), res, 7*24*60*60)
|
|
|
- }
|
|
|
- yp.ServeJson(res)
|
|
|
+ yp.ServeJson(getDishonesty(legcerNo, currentPage))
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+func getDishonesty(legcerNo string, currentPage int) map[string]interface{} {
|
|
|
+ var res map[string]interface{}
|
|
|
+ if ret := redis.Get("enterprise", "dishonesty-"+legcerNo+"-"+fmt.Sprint(currentPage)); ret != nil {
|
|
|
+ res = ret.(map[string]interface{})
|
|
|
+ } else {
|
|
|
+ limit := 10
|
|
|
+ start := (currentPage - 1) * limit
|
|
|
+ count := Count("laolai", `{"s_cardnum":"`+legcerNo+`"}`)
|
|
|
+ r := Find("laolai", `{"s_cardnum":"`+legcerNo+`"}`, `{"l_date":-1}`, `{"l_date":1,"iname":1,"court_name":1,"case_code":1,"performance":1}`, false, start, limit)
|
|
|
+ res = map[string]interface{}{"list": r, "count": count, "pageSize": limit}
|
|
|
+ redis.Put("enterprise", "dishonesty-"+legcerNo+"-"+fmt.Sprint(currentPage), res, 7*24*60*60)
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+func (yp *Yellowpage) FindServiceByEntId() error {
|
|
|
+ if yp.Method() == "POST" {
|
|
|
+ id := yp.GetString("entId")
|
|
|
+ currentPage, _ := yp.GetInteger("currentPage")
|
|
|
+ yp.ServeJson(findServiceByEntId(id, currentPage, yp.Session()))
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+func findServiceByEntId(id string, currentPage int, session *httpsession.Session) map[string]interface{} {
|
|
|
+ var res map[string]interface{}
|
|
|
+ if ret := redis.Get("enterprise", "service-"+id+"-"+fmt.Sprint(currentPage)); ret != nil {
|
|
|
+ res = ret.(map[string]interface{})
|
|
|
+ } else {
|
|
|
+ limit := 10
|
|
|
+ start := (currentPage - 1) * limit
|
|
|
+ var count int64
|
|
|
+ //分页
|
|
|
+ mustnot := `{"term" : {"i_status" : 1 }}`
|
|
|
+ var fields, collection, query, tempstrquery string
|
|
|
+ collection = "service"
|
|
|
+ tempstrquery = `{"query_string":{"default_field": "s_enterpriseid","query":"` + id + `"}}`
|
|
|
+ servicequery := ""
|
|
|
+ if session.Get("entid") == nil || session.Get("entid").(string) != id {
|
|
|
+ servicequery = `,"must_not" : [` + mustnot + `]`
|
|
|
+ }
|
|
|
+ query = `{"query": {
|
|
|
+ "bool": {
|
|
|
+ "must":[` + tempstrquery + `]` + servicequery + `
|
|
|
+ }
|
|
|
+ }}`
|
|
|
+ //需要查到的字段信息
|
|
|
+ fields = `"_id","s_name","s_introduction","s_images","s_enterpriseid","s_isshow","i_status","s_pricemy","i_comments","f_price","i_sales"`
|
|
|
+ if currentPage == 1 {
|
|
|
+ count = 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", start)+`,
|
|
|
+ size:`+fmt.Sprintf("%v", limit)+`
|
|
|
+ }`)
|
|
|
+ for _, v := range *result {
|
|
|
+ b, _ := checkAuth(v)
|
|
|
+ if b {
|
|
|
+ v["s_isEdit"] = "1"
|
|
|
+ } else {
|
|
|
+ v["s_isEdit"] = "0"
|
|
|
+ }
|
|
|
+ if util.IntAll(v["i_status"]) == 1 {
|
|
|
+ v["s_remove"] = 1
|
|
|
+ } else {
|
|
|
+ v["s_remove"] = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res = map[string]interface{}{"list": result, "count": count, "pageSize": limit}
|
|
|
+ redis.Put("enterprise", "service-"+id+"-"+fmt.Sprint(currentPage), res, 7*24*60*60)
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+func checkAuth(obj map[string]interface{}) (b bool, err string) {
|
|
|
+ if len(obj) > 0 {
|
|
|
+ //判断有没有预约的情况
|
|
|
+ orders := *(Find("serviceorder", `{"s_serviceid":"`+obj["_id"].(string)+`","i_status":{"$ne":2}}`, nil, `{"i_status":1}`, false, -1, -1))
|
|
|
+ //如果有记录的话,判断是已预约还是已接受
|
|
|
+ if len(orders) != 0 {
|
|
|
+ //判断是否有接受的
|
|
|
+ for _, v := range orders {
|
|
|
+ if util.IntAll(v["i_status"]) == 1 {
|
|
|
+ b = false
|
|
|
+ err = "start"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if util.IntAll(v["i_status"]) == 3 {
|
|
|
+ b = false
|
|
|
+ err = "comment"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true, ""
|
|
|
+}
|