Переглянути джерело

fix:拟在建列表毫秒时间戳转换修改

duxin 1 рік тому
батько
коміт
6c842636d7
3 змінених файлів з 323 додано та 148 видалено
  1. 86 0
      src/jfw/front/classificationTag.go
  2. 226 142
      src/jfw/front/nzjProject.go
  3. 11 6
      src/jfw/front/shorturl.go

+ 86 - 0
src/jfw/front/classificationTag.go

@@ -208,6 +208,92 @@ func getWinnerSeoIdByName(winners ...string) (res []map[string]interface{}) {
 	return
 	return
 }
 }
 
 
+// 根据企业名称获取seoid
+// query: company_name 根据名字匹配
+// query: _id 根据entid匹配
+func getWinnerSeoIdByNameNew(query string, fullData bool, winners ...string) (res []map[string]interface{}) {
+	if len(winners) == 0 {
+		return
+	}
+	var fields string = `"nseo_id","company_name","_id"`
+	if fullData {
+		fields = `"nseo_id","company_name","legal_person","capital","company_address","company_status"`
+	}
+	winnerMap := map[string]map[string]interface{}{}
+	winnerRes := elastic.GetNoLimit(qyxy, qyxy, fmt.Sprintf(`{"query":{"terms":{"%s":["%s"]}},"_source":[%s],"size":%d}`, query, strings.Join(winners, `","`), fields, len(winners)))
+	if winnerRes != nil && len(*winnerRes) > 0 {
+		for _, m := range *winnerRes {
+			name := gconv.String(m["company_name"])
+			sid := gconv.String(m["nseo_id"])
+			entId := gconv.String(m["_id"])
+			if name != "" && sid != "" && entId != "" {
+				row := map[string]interface{}{
+					"name":  name,
+					"seoId": sid,
+					"url":   fmt.Sprintf("/qy/%s.html", sid),
+				}
+				if fullData {
+					row["legal_person"] = m["legal_person"]
+					row["capital"] = m["capital"]
+					//if dataStamp := gconv.Int64(m["establish_date"]); dataStamp > 0 {
+					//	row["establish_date"] = gtime.New(dataStamp).Format("Y-m-d")
+					//}
+					//row["company_phone"] = m["company_phone"]
+					row["address"] = m["company_address"]
+					if state := gconv.String(m["company_status"]); state != "" {
+						row["company_status"] = strings.Split(state, "(")[0]
+					}
+				}
+				winnerMap[entId] = row
+			}
+		}
+	}
+	for _, winner := range winners {
+		if m := winnerMap[winner]; m != nil {
+			res = append(res, m)
+		}
+	}
+	return
+}
+
+// 根据采购单位名字获取seoid
+func getBuyerSeoIdByNameNew(fullData bool, buyers ...string) (res []map[string]interface{}) {
+	if len(buyers) == 0 {
+		return
+	}
+	var fields string = `"seo_id","name"`
+	if fullData {
+		fields = `"seo_id","name","province","city","buyerclass"`
+	}
+	buyerMap := map[string]map[string]interface{}{}
+	buyerRes := elastic.GetNoLimit("buyer", "buyer", fmt.Sprintf(`{"query":{"terms":{"buyer_name":["%s"]}},"_source":[%s],"size":%d}`, strings.Join(buyers, `","`), fields, len(buyers)))
+	if buyerRes != nil && len(*buyerRes) > 0 {
+		for _, m := range *buyerRes {
+			name := gconv.String(m["name"])
+			sid := gconv.String(m["seo_id"])
+			if name != "" && sid != "" {
+				row := map[string]interface{}{
+					"name":  name,
+					"seoId": sid,
+					"url":   fmt.Sprintf("/dw/%s.html", sid),
+				}
+				if fullData {
+					row["buyerclass"] = m["buyerclass"]
+					row["area"] = m["province"]
+					row["city"] = m["city"]
+				}
+				buyerMap[name] = row
+			}
+		}
+	}
+	for _, buyer := range buyers {
+		if m := buyerMap[buyer]; m != nil {
+			res = append(res, m)
+		}
+	}
+	return
+}
+
 // 根据采购单位名字获取seoid
 // 根据采购单位名字获取seoid
 func getBuyerSeoIdByName(buyer ...string) (res []map[string]interface{}) {
 func getBuyerSeoIdByName(buyer ...string) (res []map[string]interface{}) {
 	if len(buyer) == 0 {
 	if len(buyer) == 0 {

+ 226 - 142
src/jfw/front/nzjProject.go

@@ -13,6 +13,7 @@ import (
 	"fmt"
 	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/config"
 	"math/rand"
 	"math/rand"
+	"strconv"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
@@ -25,11 +26,13 @@ var (
 
 
 type ClaimProject struct {
 type ClaimProject struct {
 	*xweb.Action
 	*xweb.Action
-	nzjSearch        xweb.Mapper `xweb:"/front/project/nzj/search"`      //拟在建工作桌面外列表页
-	nzjDetails       xweb.Mapper `xweb:"/front/project/nzj/details"`     //拟在建工作桌面外详情页
+	nzjSearch     xweb.Mapper `xweb:"/front/project/nzj/search"`     //拟在建工作桌面外列表页
+	nzjDetails    xweb.Mapper `xweb:"/front/project/nzj/details"`    //拟在建工作桌面外详情页
+	nzjConditions xweb.Mapper `xweb:"/front/project/nzj/conditions"` //工作台引导说明
+
 	analyzeWord      xweb.Mapper `xweb:"/homePage/analyzeWord"`          //首页定制化分析报告词收集
 	analyzeWord      xweb.Mapper `xweb:"/homePage/analyzeWord"`          //首页定制化分析报告词收集
 	analysisRegional xweb.Mapper `xweb:"/homePage/analysisRegional"`     //首页区域分析
 	analysisRegional xweb.Mapper `xweb:"/homePage/analysisRegional"`     //首页区域分析
-	specification    xweb.Mapper `xweb:"/front/bootstrap/specification"` //工作台引导说明
+	specification    xweb.Mapper `xweb:"/front/bootstrap/specification"` //拟在建工作桌面外搜索
 }
 }
 
 
 func init() {
 func init() {
@@ -65,6 +68,84 @@ func (l *ClaimProject) AnalyzeWord() {
 	}
 	}
 }
 }
 
 
+func (l *ClaimProject) NzjConditions() {
+	var (
+		data                           []map[string]interface{}
+		projectStageArr, ownerclassArr []string
+		areaArr                        = []string{"全国"}
+	)
+	redisKey := "nzj_search_criteria"
+	redisData := redis.Get(RedisNameNew, redisKey)
+	if redisData != nil {
+		rData := redisData.([]interface{})
+		data = common.ObjArrToMapArr(rData)
+	} else {
+		area := public.GlobalCommonMysql.SelectBySql(`SELECT
+    name
+FROM
+	Jianyu_subjectdb.d_area_code where level = 1 and name != '其它'`)
+		if area != nil {
+			for _, m := range *area {
+				areaArr = append(areaArr, common.InterfaceToStr(m["name"]))
+			}
+		}
+		data = append(data, map[string]interface{}{"地区": areaArr})
+
+		categoryCode := public.GlobalCommonMysql.SelectBySql(`SELECT
+    name, code
+FROM
+    Jianyu_subjectdb.d_nzj_category_code WHERE name != '其它工程' and pcode = ""
+ ORDER BY id asc`)
+		if categoryCode != nil {
+			for _, m := range *categoryCode {
+				category := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT
+    name
+FROM
+    Jianyu_subjectdb.d_nzj_category_code WHERE pcode = '%s'
+ ORDER BY id asc`, common.InterfaceToStr(m["code"])))
+				if category != nil {
+					var names []string
+					for _, m2 := range *category {
+						names = append(names, common.InterfaceToStr(m2["name"]))
+					}
+					data = append(data, map[string]interface{}{common.InterfaceToStr(m["name"]): names})
+				}
+			}
+		}
+
+		project_stage := public.GlobalCommonMysql.SelectBySql(`SELECT
+    name
+FROM
+    Jianyu_subjectdb.d_nzj_project_stage_code
+ ORDER BY id asc
+ `)
+		if project_stage != nil {
+			for _, m := range *project_stage {
+				projectStageArr = append(projectStageArr, common.InterfaceToStr(m["name"]))
+			}
+		}
+		data = append(data, map[string]interface{}{"项目阶段": projectStageArr})
+
+		ownerclass := public.GlobalCommonMysql.SelectBySql(`SELECT
+    name
+FROM
+	Jianyu_subjectdb.d_nzj_ownerclass_code ORDER BY id asc`)
+		if area != nil {
+			for _, m := range *ownerclass {
+				ownerclassArr = append(ownerclassArr, common.InterfaceToStr(m["name"]))
+			}
+		}
+		data = append(data, map[string]interface{}{"业主类型": ownerclassArr})
+		redis.Put(RedisNameNew, redisKey, data, 3600*24*30)
+	}
+
+	l.ServeJson(map[string]interface{}{
+		"error_code": 0,
+		"error_msg":  nil,
+		"data":       data,
+	})
+}
+
 func (l *ClaimProject) NzjSearch() {
 func (l *ClaimProject) NzjSearch() {
 	pageNum, _ := l.GetInt("pageNum")
 	pageNum, _ := l.GetInt("pageNum")
 	pageSize, _ := l.GetInt("pageSize")
 	pageSize, _ := l.GetInt("pageSize")
@@ -112,17 +193,30 @@ type ProjectConnection struct {
 func getDetail(pid string, equity int) map[string]interface{} {
 func getDetail(pid string, equity int) map[string]interface{} {
 	var codeContent string
 	var codeContent string
 	detail := make(map[string]interface{})
 	detail := make(map[string]interface{})
+	if pid == "" {
+		return detail
+	}
 	if equity < 3 {
 	if equity < 3 {
 		codeContent = common.If(equity == 1, "登陆后解锁会员查看", "(付费展示)").(string)
 		codeContent = common.If(equity == 1, "登陆后解锁会员查看", "(付费展示)").(string)
 	}
 	}
+	detail = BasicInfo(pid, codeContent, equity)
+	detail["follRecord"] = ProjectProgress(pid, equity)
+	detail["contact"] = EntConnection(pid, codeContent, equity)
+	return detail
+}
+
+// BasicInfo 基本信息
+func BasicInfo(pid, codeContent string, equity int) map[string]interface{} {
 	//基本信息
 	//基本信息
-	dataDetail := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT
+	detail := make(map[string]interface{})
+	dataDetail := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT
     a.projectname,
     a.projectname,
     DATE_FORMAT(a.lasttime, '%s') AS lasttime,
     DATE_FORMAT(a.lasttime, '%s') AS lasttime,
     DATE_FORMAT(a.firsttime, '%s') AS firsttime,
     DATE_FORMAT(a.firsttime, '%s') AS firsttime,
     a.proposed_number,
     a.proposed_number,
     CONCAT('进展', a.follow_num) AS follow,
     CONCAT('进展', a.follow_num) AS follow,
     b.name AS project_stage,
     b.name AS project_stage,
+    g.name AS area,
     c.name AS nature,
     c.name AS nature,
     d.name AS category,
     d.name AS category,
     a.owner,
     a.owner,
@@ -142,12 +236,17 @@ FROM
 	LEFT JOIN Jianyu_subjectdb.d_nzj_category_code d on a.category_code = d.code
 	LEFT JOIN Jianyu_subjectdb.d_nzj_category_code d on a.category_code = d.code
 	LEFT JOIN Jianyu_subjectdb.d_nzj_ownerclass_code e on a.ownerclass_code = e.code
 	LEFT JOIN Jianyu_subjectdb.d_nzj_ownerclass_code e on a.ownerclass_code = e.code
     LEFT JOIN Jianyu_subjectdb.d_topsubtype_code f on a.industry_code = f.code
     LEFT JOIN Jianyu_subjectdb.d_topsubtype_code f on a.industry_code = f.code
+    LEFT JOIN Jianyu_subjectdb.d_area_code g ON a.area_code = g.CODE
 WHERE
 WHERE
 	proposed_id = '%s'`, "%Y-%m-%d", "%Y-%m-%d", pid))
 	proposed_id = '%s'`, "%Y-%m-%d", "%Y-%m-%d", pid))
+	if dataDetail == nil || len(*dataDetail) == 0 {
+		//tidi缺失 查询es
+		dataDetail = elastic.GetById(proposed, proposed, pid)
+	}
 	if dataDetail != nil && len(*dataDetail) > 0 {
 	if dataDetail != nil && len(*dataDetail) > 0 {
 		detail = (*dataDetail)[0]
 		detail = (*dataDetail)[0]
 		//拼接项目概况
 		//拼接项目概况
-		if equity < 3 {
+		if equity < 3 { //非会员打码
 			projectname := common.InterfaceToStr(detail["projectname"])
 			projectname := common.InterfaceToStr(detail["projectname"])
 			detail["generalSituation"] = fmt.Sprintf("项目概况:%s项目是剑鱼标讯网站%s发布的%s行业项目信息,该项目投资总额%f万元,建设周期为%s至%s,且目前处于%s阶段。我们将持续跟踪并发布%s进展信息,感兴趣的用户开通大会员查看项目详情。",
 			detail["generalSituation"] = fmt.Sprintf("项目概况:%s项目是剑鱼标讯网站%s发布的%s行业项目信息,该项目投资总额%f万元,建设周期为%s至%s,且目前处于%s阶段。我们将持续跟踪并发布%s进展信息,感兴趣的用户开通大会员查看项目详情。",
 				projectname, timeFmt(common.InterfaceToStr(detail["createtime"])), common.InterfaceToStr(detail["industry"]), common.Float64All(detail["total_investment"]),
 				projectname, timeFmt(common.InterfaceToStr(detail["createtime"])), common.InterfaceToStr(detail["industry"]), common.Float64All(detail["total_investment"]),
@@ -159,134 +258,82 @@ WHERE
 			// 拟在建项目是指尚在规划、报批、立项、环评、设计等阶段的项目,一般由发改委和各部委提供,且项目规模和投资额都较大。剑鱼标讯一般会在项目正式招标前3-12个月就通知付费客户,让客户有足够的时间和空间和业主联系,做好前期准备工作。
 			// 拟在建项目是指尚在规划、报批、立项、环评、设计等阶段的项目,一般由发改委和各部委提供,且项目规模和投资额都较大。剑鱼标讯一般会在项目正式招标前3-12个月就通知付费客户,让客户有足够的时间和空间和业主联系,做好前期准备工作。
 			detail["project_scale"] = config.Seoconfig["nzjConstructionContent"]
 			detail["project_scale"] = config.Seoconfig["nzjConstructionContent"]
 		}
 		}
-		//项目进展
-		follRecord := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT DATE_FORMAT(a.publishtime, '%s') as publishtime,CONCAT('进展', a.follow_num) AS follow,b.name as project_stage,a.title,a.jybxhref FROM Jianyu_subjectdb.dwd_f_nzj_follw_record a
+	}
+
+	return detail
+}
+
+func ProjectProgress(pid string, equity int) *[]map[string]interface{} {
+	//项目进展
+	follRecord := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT DATE_FORMAT(a.publishtime, '%s') as publishtime,CONCAT('进展', a.follow_num) AS follow,b.name as project_stage,a.title,a.jybxhref FROM Jianyu_subjectdb.dwd_f_nzj_follw_record a
 LEFT JOIN Jianyu_subjectdb.d_nzj_project_stage_code b on a.project_stage_code =  b.code WHERE a.proposed_id = '%s'
 LEFT JOIN Jianyu_subjectdb.d_nzj_project_stage_code b on a.project_stage_code =  b.code WHERE a.proposed_id = '%s'
 ORDER BY a.publishtime DESC `, "%Y-%m-%d", pid))
 ORDER BY a.publishtime DESC `, "%Y-%m-%d", pid))
-		if follRecord != nil && len(*follRecord) > 0 {
-			if equity < 3 {
-				// 进展备注是剑鱼标讯通过一定渠道获得的项目进度计划,帮您提前把握商机!开通大会员即可享受此权益。
-				for _, v := range *follRecord {
-					v["title"] = config.Seoconfig["nzjProgressRemark"]
-					delete(v, "jybxhref")
-				}
+	if follRecord != nil && len(*follRecord) > 0 {
+		if equity < 3 {
+			// 进展备注是剑鱼标讯通过一定渠道获得的项目进度计划,帮您提前把握商机!开通大会员即可享受此权益。
+			for _, v := range *follRecord {
+				v["title"] = config.Seoconfig["nzjProgressRemark"]
+				delete(v, "jybxhref")
 			}
 			}
-			detail["follRecord"] = follRecord
 		}
 		}
+	}
+	return follRecord
+}
 
 
-		//获取企业主题id
-		entId := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT name_id,name,address,identity_type FROM Jianyu_subjectdb.dwd_f_nzj_ent WHERE proposed_id = '%s' GROUP BY name_id ORDER BY identity_type DESC , createtime ASC`, pid))
-		if entId != nil && len(*entId) > 0 {
-			pool := make(chan bool, 10)
-			wait := &sync.WaitGroup{}
-			var (
-				lock    sync.Mutex
-				contact = make([]ProjectConnection, len(*entId))
-			)
-			for k, nameMap := range *entId {
-				pool <- true
-				wait.Add(1)
-				go func(nameMaps map[string]interface{}, ks int) {
-					defer func() {
-						wait.Done()
-						<-pool
-					}()
-					nameId := common.InterfaceToStr(nameMaps["name_id"])
-					person := ProjectConnection{
-						endName:      common.InterfaceToStr(nameMaps["name"]),
-						address:      common.InterfaceToStr(nameMaps["address"]),
-						identityType: common.InterfaceToStr(nameMaps["identity_type"]),
-					}
+func EntConnection(pid, codeContent string, equity int) []ProjectConnection {
+	//获取企业主题id
+	entId := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT name_id,name,address,identity_type FROM Jianyu_subjectdb.dwd_f_nzj_ent WHERE proposed_id = '%s' GROUP BY name_id ORDER BY identity_type DESC , createtime ASC`, pid))
+	if entId != nil && len(*entId) > 0 {
+		pool := make(chan bool, 10)
+		wait := &sync.WaitGroup{}
+		var (
+			lock    sync.Mutex
+			contact = make([]ProjectConnection, len(*entId))
+		)
+		for k, nameMap := range *entId {
+			pool <- true
+			wait.Add(1)
+			go func(nameMaps map[string]interface{}, ks int) {
+				defer func() {
+					wait.Done()
+					<-pool
+				}()
+				nameId := common.InterfaceToStr(nameMaps["name_id"])
+				person := ProjectConnection{
+					endName:      common.InterfaceToStr(nameMaps["name"]),
+					address:      common.InterfaceToStr(nameMaps["address"]),
+					identityType: common.InterfaceToStr(nameMaps["identity_type"]),
+				}
 
 
-					company := public.BaseMysql.FindOne("dws_f_ent_baseinfo", map[string]interface{}{"name_id": nameId, "name": person.endName}, "company_id", "")
-					if company != nil {
-						person.endId = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr((*company)["company_id"]))
+				data := make(map[string]interface{})
+				if equity != 3 {
+					person.endName = codeContent
+					dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT contact_name, contact_tel, 1 AS source_type, createtime AS lasttime FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" ORDER BY lasttime DESC LIMIT 1`, nameId))
+					if dataArr != nil {
+						data = (*dataArr)[0]
 					}
 					}
-					data := make(map[string]interface{})
-					if equity != 3 {
-						dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT contact_name, contact_tel, 1 AS source_type, createtime AS lasttime FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" lasttime DESC `, nameId))
-						if dataArr != nil {
-							data = (*dataArr)[0]
-						}
-					} else {
-						dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM (( SELECT contact_name, contact_tel, 1 AS source_type, createtime AS lasttime FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" ORDER BY lasttime DESC LIMIT 1) UNION ALL
+				} else {
+					dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM (( SELECT contact_name, contact_tel, 1 AS source_type, createtime AS lasttime FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" ORDER BY lasttime DESC LIMIT 1) UNION ALL
 	( SELECT contact_name, contact_tel, source_type, CASE WHEN updatetime IS NOT NULL THEN updatetime ELSE createtime END AS lasttime FROM dws_f_ent_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" ORDER BY source_type ASC,lasttime DESC LIMIT 1) UNION ALL
 	( SELECT contact_name, contact_tel, source_type, CASE WHEN updatetime IS NOT NULL THEN updatetime ELSE createtime END AS lasttime FROM dws_f_ent_contact WHERE name_id = '%s' and contact_name != "" and contact_tel != "" ORDER BY source_type ASC,lasttime DESC LIMIT 1) UNION ALL
 ( SELECT person AS contact_name, phone AS contact_tel, 0 AS source_type, lasttime FROM Jianyu_subjectdb.dwd_f_user_contact_record WHERE name_id = '%s' and person != "" and phone != "" ORDER BY lasttime DESC LIMIT 1)) a
 ( SELECT person AS contact_name, phone AS contact_tel, 0 AS source_type, lasttime FROM Jianyu_subjectdb.dwd_f_user_contact_record WHERE name_id = '%s' and person != "" and phone != "" ORDER BY lasttime DESC LIMIT 1)) a
 ORDER BY
 ORDER BY
 	a.source_type ASC,
 	a.source_type ASC,
 	a.lasttime DESC
 	a.lasttime DESC
 	LIMIT 1`, nameId, nameId, nameId))
 	LIMIT 1`, nameId, nameId, nameId))
-						if dataArr != nil {
-							data = (*dataArr)[0]
-						}
+					if dataArr != nil {
+						data = (*dataArr)[0]
 					}
 					}
-					/*connection := make(map[RemovalKey]map[string]interface{})
-					  nzjContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id ='%s' ORDER BY createtime DESC `, nameId))
-					  if nzjContact != nil && len(*nzjContact) > 0 {
-					  	for _, v := range *nzjContact {
-					  		v["lasttime"] = v["createtime"]
-					  		var key RemovalKey
-					  		key.person = common.InterfaceToStr(v["contact_name"])
-					  		key.phone = common.InterfaceToStr(v["contact_tel"])
-					  		v["source_type"] = 1
-					  		connection[key] = v
-					  	}
-					  }
-					  if equity > 3 {
-					  	//企业联系人
-					  	entContact := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM dws_f_ent_contact WHERE name_id ='%s'`, nameId))
-					  	if entContact != nil && len(*entContact) > 0 {
-					  		for _, v := range *entContact {
-					  			v["lasttime"] = v["createtime"]
-					  			if common.InterfaceToStr(v["createtime"]) < common.InterfaceToStr(v["updatetime"]) {
-					  				v["lasttime"] = v["updatetime"]
-					  			}
-					  			var key RemovalKey
-					  			key.person = common.InterfaceToStr(v["contact_name"])
-					  			key.phone = common.InterfaceToStr(v["contact_tel"])
-					  			connection[key] = v
-					  		}
-					  	}
-					  	for _, m := range connection {
-					  		data = append(data, m)
-					  	}
-					  	//私有联系人用户
-					  	userContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_user_contact_record WHERE name_id = '%s' `, nameId))
-					  	if userContact != nil && len(*userContact) > 0 {
-					  		for _, m := range *userContact {
-					  			m["source_type"] = 0
-					  			data = append(data, m)
-					  		}
-					  	}
-
-					  } else {
-					  	person.endName = codeContent
-					  	for _, m := range connection {
-					  		data = append(data, m)
-					  	}
-					  }
-					  // 自定义排序函数
-					  sort.Slice(data, func(i, j int) bool {
-					  	sourceTypeA := data[i]["source_type"].(string)
-					  	sourceTypeB := data[j]["source_type"].(string)
-					  	if sourceTypeA == sourceTypeB {
-					  		lastTimeA := data[i]["lasttime"].(int)
-					  		lastTimeB := data[j]["lasttime"].(int)
-					  		return lastTimeA > lastTimeB // 降序排序
-					  	}
-					  	return sourceTypeA < sourceTypeB // 升序排序
-					  })*/
-					person.data = data
-					lock.Lock()
-					contact[ks] = person
-					lock.Unlock()
-				}(nameMap, k)
-			}
-			wait.Wait()
-			detail["contact"] = contact
+				}
+				person.data = data
+				lock.Lock()
+				contact[ks] = person
+				lock.Unlock()
+			}(nameMap, k)
 		}
 		}
+		wait.Wait()
+		return contact
 	}
 	}
-	return detail
+	return nil
 }
 }
 
 
 func timeFmt(tm string) string {
 func timeFmt(tm string) string {
@@ -308,17 +355,30 @@ func getNzjList(infoMap map[string]interface{}) (count int64, list *[]map[string
 		return nzjEmptySearch(pageNum, pageSize)
 		return nzjEmptySearch(pageNum, pageSize)
 	}
 	}
 
 
+	categoryCodeArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT category_code FROM Jianyu_subjectdb.dwd_f_nzj_category_rule WHERE stage_info = '%s'`, common.InterfaceToStr(infoMap["keyWord"])))
+	if categoryCodeArr != nil && len(*categoryCodeArr) > 0 {
+		var codes []string
+		for _, code := range *categoryCodeArr {
+			codes = append(codes, fmt.Sprintf(`"%s"`, common.InterfaceToStr(code["category_code"])))
+		}
+		infoMap["keyCode"] = codes
+	}
 	musts := esQuery(infoMap)
 	musts := esQuery(infoMap)
+
 	if pageNum == 1 {
 	if pageNum == 1 {
-		count = elastic.Count(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}}`, strings.Join(musts, ",")))
+		count = elastic.Count(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}}}`, strings.Join(musts, ",")))
+		if count == 0 {
+			return count, nil
+		}
 		if count > common.Int64All(config.Sysconfig["nzjLimit"]) {
 		if count > common.Int64All(config.Sysconfig["nzjLimit"]) {
 			count = common.Int64All(config.Sysconfig["nzjLimit"])
 			count = common.Int64All(config.Sysconfig["nzjLimit"])
 		}
 		}
 	}
 	}
-	list = elastic.Get(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}},"_source":["projectname","area","area_city","lasttime","project_stage","ownerclass","proposed_id","category","project_stage"],"sort":[{"lasttime":{"order":"desc"}}],"from":%d,"size":%d`, strings.Join(musts, ","), (pageNum-1)*pageSize, pageSize))
+
+	list = elastic.Get(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}},"_source":["projectname","area","area_city","lasttime","project_stage","ownerclass","proposed_id","category","project_stage"],"sort":[{"lasttime":{"order":"desc"}}],"from":%d,"size":%d}`, strings.Join(musts, ","), (pageNum-1)*pageSize, pageSize))
 	if list != nil && len(*list) > 0 {
 	if list != nil && len(*list) > 0 {
 		for _, v := range *list {
 		for _, v := range *list {
-			v["lasttime"] = MillisecondsToStr(common.Int64All(v["lasttime"]))
+			//v["lasttime"] = MillisecondsToStr(common.Int64All(v["lasttime"]))
 			if v["area_city"] == nil || v["area_city"] == "" {
 			if v["area_city"] == nil || v["area_city"] == "" {
 				v["area_city"] = v["area"]
 				v["area_city"] = v["area"]
 			}
 			}
@@ -327,15 +387,19 @@ func getNzjList(infoMap map[string]interface{}) (count int64, list *[]map[string
 	return
 	return
 }
 }
 
 
-func MillisecondsToStr(ms int64) string {
-	seconds := ms / 1000
-	nanoseconds := (ms % 1000) * 1000000
-	return time.Unix(seconds, nanoseconds).Format("2006-01-02")
+func MillisecondsToStr(ms int64) int64 {
+	timestampStr := strconv.FormatInt(ms, 10)
+	if len(timestampStr) == 13 {
+		return ms / 1000
+	} else if len(timestampStr) == 10 {
+		return ms
+	}
+	return 0
 }
 }
 
 
 func esQuery(infoMap map[string]interface{}) []string {
 func esQuery(infoMap map[string]interface{}) []string {
 	var (
 	var (
-		terms []string
+		musts []string
 	)
 	)
 
 
 	if infoMap["area"] != nil && infoMap["area"] != "" {
 	if infoMap["area"] != nil && infoMap["area"] != "" {
@@ -344,7 +408,7 @@ func esQuery(infoMap map[string]interface{}) []string {
 		for _, v := range strings.Split(area, ",") {
 		for _, v := range strings.Split(area, ",") {
 			areas = append(areas, fmt.Sprintf(`"%s"`, v))
 			areas = append(areas, fmt.Sprintf(`"%s"`, v))
 		}
 		}
-		terms = append(terms, fmt.Sprintf(`{
+		musts = append(musts, fmt.Sprintf(`{
           "terms": {
           "terms": {
             "area": [%s]
             "area": [%s]
           }
           }
@@ -357,7 +421,7 @@ func esQuery(infoMap map[string]interface{}) []string {
 		for _, v := range strings.Split(category, ",") {
 		for _, v := range strings.Split(category, ",") {
 			categorys = append(categorys, fmt.Sprintf(`"%s"`, v))
 			categorys = append(categorys, fmt.Sprintf(`"%s"`, v))
 		}
 		}
-		terms = append(terms, fmt.Sprintf(`{
+		musts = append(musts, fmt.Sprintf(`{
           "terms": {
           "terms": {
             "category": [%s]
             "category": [%s]
           }
           }
@@ -369,7 +433,7 @@ func esQuery(infoMap map[string]interface{}) []string {
 		for _, v := range strings.Split(projectStage, ",") {
 		for _, v := range strings.Split(projectStage, ",") {
 			projectStages = append(projectStages, fmt.Sprintf(`"%s"`, v))
 			projectStages = append(projectStages, fmt.Sprintf(`"%s"`, v))
 		}
 		}
-		terms = append(terms, fmt.Sprintf(`{
+		musts = append(musts, fmt.Sprintf(`{
           "terms": {
           "terms": {
             "project_stage": [%s]
             "project_stage": [%s]
           }
           }
@@ -382,28 +446,37 @@ func esQuery(infoMap map[string]interface{}) []string {
 		for _, v := range strings.Split(ownerclass, ",") {
 		for _, v := range strings.Split(ownerclass, ",") {
 			ownerclasss = append(ownerclasss, fmt.Sprintf(`"%s"`, v))
 			ownerclasss = append(ownerclasss, fmt.Sprintf(`"%s"`, v))
 		}
 		}
-		terms = append(terms, fmt.Sprintf(`{
+		musts = append(musts, fmt.Sprintf(`{
           "terms": {
           "terms": {
             "ownerclass": [%s]
             "ownerclass": [%s]
           }
           }
         }`, strings.Join(ownerclasss, ",")))
         }`, strings.Join(ownerclasss, ",")))
 	}
 	}
-
+	var (
+		keyWordsMusts []string
+		wordsShould   []string
+	)
+	//查询关键词
 	if infoMap["keyWord"] != nil && infoMap["keyWord"] != "" {
 	if infoMap["keyWord"] != nil && infoMap["keyWord"] != "" {
 		keyWord := common.InterfaceToStr(infoMap["keyWord"])
 		keyWord := common.InterfaceToStr(infoMap["keyWord"])
-		keyWords := strings.Split(keyWord, " ")
-		var words []string
-		for _, vv := range keyWords {
-			words = append(words, vv)
+		for _, v := range strings.Split(keyWord, " ") {
+			keyWordsMusts = append(keyWordsMusts, fmt.Sprintf(`{"multi_match": {"query": "%s","type": "phrase","fields": ["projectname"]}}`, v))
 		}
 		}
-		terms = append(terms, fmt.Sprintf(`{
-          "multi_match": {
-            "query": "%s",
-            "fields": ["projectname"]
+		wordsShould = append(wordsShould, fmt.Sprintf(elastic.NgramMust, strings.Join(keyWordsMusts, ",")))
+	}
+	//查询关键词匹配到的code
+	if infoMap["keyCode"] != nil {
+		keyWord, _ := infoMap["keyCode"].([]string)
+		wordsShould = append(wordsShould, fmt.Sprintf(`{
+          "terms": {
+            "category_code": [%s]
           }
           }
-        },`, strings.Join(words, ",")))
+        }`, strings.Join(keyWord, ",")))
 	}
 	}
-	return terms
+	if len(keyWordsMusts) > 0 {
+		musts = append(musts, fmt.Sprintf(queryBoolShould, strings.Join(wordsShould, ",")))
+	}
+	return musts
 }
 }
 
 
 func nzjEmptySearch(pageNum, pageSize int) (int64, *[]map[string]interface{}) {
 func nzjEmptySearch(pageNum, pageSize int) (int64, *[]map[string]interface{}) {
@@ -419,7 +492,7 @@ func nzjEmptySearch(pageNum, pageSize int) (int64, *[]map[string]interface{}) {
 		dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT
 		dataArr := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT
     a.proposed_id,
     a.proposed_id,
 	a.projectname,
 	a.projectname,
-	DATE_FORMAT(a.lasttime, '%s') AS lasttime,
+	a.lasttime,
 	b.NAME AS project_stage,
 	b.NAME AS project_stage,
 	COALESCE(c.NAME, f.NAME) AS area_city,
 	COALESCE(c.NAME, f.NAME) AS area_city,
 	d.NAME AS category,
 	d.NAME AS category,
@@ -433,9 +506,20 @@ FROM
 	LEFT JOIN Jianyu_subjectdb.d_area_code f ON a.area_code = f.CODE
 	LEFT JOIN Jianyu_subjectdb.d_area_code f ON a.area_code = f.CODE
 	LEFT JOIN Jianyu_subjectdb.d_nzj_ownerclass_code e ON a.ownerclass_code = e.CODE
 	LEFT JOIN Jianyu_subjectdb.d_nzj_ownerclass_code e ON a.ownerclass_code = e.CODE
 	ORDER BY a.lasttime DESC
 	ORDER BY a.lasttime DESC
-	LIMIT %d`, "%Y-%m-%d", common.IntAll(config.Sysconfig["nzjLimit"])))
+	LIMIT %d`, common.IntAll(config.Sysconfig["nzjLimit"])))
 		if dataArr != nil && len(*dataArr) > 0 {
 		if dataArr != nil && len(*dataArr) > 0 {
 			count = int64(len(data))
 			count = int64(len(data))
+			for _, m := range *dataArr {
+				lasttime := common.InterfaceToStr(m["lasttime"])
+				if lasttime != "" { //日期转时间戳
+					layout := "2006-01-02 15:04:05" // 输入字符串的时间格式
+					t, err := time.Parse(layout, lasttime)
+					if err != nil {
+						continue
+					}
+					m["lasttime"] = t.UnixMilli()
+				}
+			}
 			redis.Put("newother", nzjRedisKey, *dataArr, 3600*24)
 			redis.Put("newother", nzjRedisKey, *dataArr, 3600*24)
 			ds = (*dataArr)[(pageNum-1)*pageSize : pageNum*pageSize]
 			ds = (*dataArr)[(pageNum-1)*pageSize : pageNum*pageSize]
 		}
 		}

+ 11 - 6
src/jfw/front/shorturl.go

@@ -135,13 +135,13 @@ func (s *Short) Article(stype, id string) error {
 		//	return s.Redirect("/notin/page")
 		//	return s.Redirect("/notin/page")
 		//}
 		//}
 	}
 	}
-	return s.LoginCommon(sess, stype, id, bm)
+	return s.LoginCommon(sess, stype, id, bm, false)
 }
 }
 
 
-func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bool) error {
+func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm, isHome bool) error {
 	log.Println(stype, "----stype:---", id)
 	log.Println(stype, "----stype:---", id)
 	//电脑端 剑鱼快照页面访问
 	//电脑端 剑鱼快照页面访问
-	if stype == "content" && !bm {
+	/*if stype == "content" && !bm {
 		//工作桌面内嵌 快照页
 		//工作桌面内嵌 快照页
 		//老地址(地址不包含aside)且非工作桌面地址
 		//老地址(地址不包含aside)且非工作桌面地址
 		if !strings.Contains(s.Request.URL.String(), "aside") && !strings.Contains(s.Request.URL.String(), "page_workDesktop") {
 		if !strings.Contains(s.Request.URL.String(), "aside") && !strings.Contains(s.Request.URL.String(), "page_workDesktop") {
@@ -156,8 +156,14 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
 			//urlStr := strings.ReplaceAll(s.Request.URL.String(), "nologin", "article")
 			//urlStr := strings.ReplaceAll(s.Request.URL.String(), "nologin", "article")
 			//return s.Redirect(strings.Replace(urlStr, replaceStr, paramSuffix, 1), 302)
 			//return s.Redirect(strings.Replace(urlStr, replaceStr, paramSuffix, 1), 302)
 		}
 		}
-	}
+	}*/
 	userId, _ := sess["userId"].(string)
 	userId, _ := sess["userId"].(string)
+	if stype == "content" && isHome && !bm { //pc端nologin 页面登录来 添加右侧导航信息
+		tg := &Tags{}
+		s.T["newBidInfoList"] = tg.GetNewBidInfo()
+		s.T["industryInfoList"] = tg.GetConsult()
+		s.T["hotLabelList"] = tg.GetHotLabel(30)
+	}
 	//getsession := s.Session().GetMultiple()
 	//getsession := s.Session().GetMultiple()
 	//先判断是否有session
 	//先判断是否有session
 	source := s.GetString("source")
 	source := s.GetString("source")
@@ -533,7 +539,6 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
 			}
 			}
 		}()
 		}()
 		catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", detailKey, stype, sid)
 		catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", detailKey, stype, sid)
-		log.Println(catchKey, "-缓存-", userId)
 		if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
 		if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
 			redisTimeOut := util.If((isVip && isOldVip) || isMember || isEntniche || newCanRead, detailRedisByPayTimeOut, detailRedisByFreeTimeOut).(int)
 			redisTimeOut := util.If((isVip && isOldVip) || isMember || isEntniche || newCanRead, detailRedisByPayTimeOut, detailRedisByFreeTimeOut).(int)
 			industry := s.GetString("industry")
 			industry := s.GetString("industry")
@@ -1217,7 +1222,7 @@ func (s *Short) NologinArticle(stype, id string) error {
 	}
 	}
 
 
 	if userId != "" { //已登录用户直接跳转至正常三级页
 	if userId != "" { //已登录用户直接跳转至正常三级页
-		return s.LoginCommon(sess, stype, id, mobileReg.MatchString(s.Header("User-Agent"))) //是否是移动端
+		return s.LoginCommon(sess, stype, id, mobileReg.MatchString(s.Header("User-Agent")), true) //是否是移动端
 	}
 	}
 	if detailNeedMosaic == nil {
 	if detailNeedMosaic == nil {
 		detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
 		detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})