wangchuanjin 2 жил өмнө
parent
commit
7d4ea602f4

+ 3 - 2
src/jfw/front/dataExport.go

@@ -13,11 +13,12 @@ import (
 	"sync"
 	"time"
 
+	newjy "jy/src/jfw/jy"
+
 	. "app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-
 	"app.yhyue.com/moapp/jypkg/public"
 
 	util "app.yhyue.com/moapp/jybase/common"
@@ -421,7 +422,7 @@ func (d *DataExport) SuperSearchExport() error {
 		AdditionalWords: d.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 
 	}
-	selectType := strings.Join(jy.GetVipState(d.Session(), *config.Middleground, userId).GetQueryItems(d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
+	selectType := strings.Join(newjy.GetQueryItems(jy.GetVipState(d.Session(), *config.Middleground, userId), d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	//数据回显
 	d.SetSession("Echo_timeslot", d.GetString("timeslot"))
 	d.SetSession("Echo_keywords", reqData.Keywords)

+ 89 - 4
src/jfw/front/pcIndex.go

@@ -28,6 +28,10 @@ import (
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 )
 
+const (
+	tagQuery = `{"query":{"bool":{"must":[%s]}},"_source":["_id","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname"],"sort":[{"dataweight":"desc","publishtime":"desc"}],"from":%d,"size":%d}`
+)
+
 type PcIndex struct {
 	*xweb.Action
 	newSordfish  xweb.Mapper `xweb:"/(old|)"`                  //剑鱼标讯pc首页
@@ -387,7 +391,6 @@ func (f *PcIndex) SearchResult(at, name string) error {
 			// stype = "招标预告,招标公告,招标结果,招标信用信息"
 			stype = "招标,询价,竞谈,变更,单一,竞价,邀标,成交,中标,废标,流标,结果变更,合同,验收,违规,预告,需求公示,预审,论证意见,预审结果"
 		}
-		query := getLastNewsQuery(area, "", stype, industry, city)
 
 		var datas *[]map[string]interface{}
 		if list == nil || len(list.([]interface{})) == 0 {
@@ -400,8 +403,9 @@ func (f *PcIndex) SearchResult(at, name string) error {
 				if count1 < startPage || startPage < 0 {
 					startPage = 0
 				}
-				datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, `"_id","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname"`, startPage, limitcount)
-				log.Println(len(*datas), "=====", limitcount)
+				query := fmt.Sprintf(tagQuery, getLastNewsQueryTemp(area, "", stype, industry, city), startPage, limitcount)
+				datas = elastic.Get(INDEX, TYPE, query)
+				log.Println(len(*datas), "=====", limitcount, "=====", query)
 
 			} else {
 				//关键词  如果规定时间内未取到数据 则按照老规则取数据   //规则开发一半被砍 暂时注释
@@ -442,7 +446,88 @@ func (f *PcIndex) SearchResult(at, name string) error {
 	}
 	return f.Render("/pc/classifylist.html", &f.T)
 }
-
+func getLastNewsQueryTemp(area, publishtime, subtype, industry, city string) string {
+	query := ``
+	if area != "" {
+		query += `{"terms":{"area":[`
+		for k, v := range strings.Split(area, ",") {
+			if k > 0 {
+				query += `,`
+			}
+			query += `"` + v + `"`
+		}
+		query += `]}}`
+	}
+	if publishtime != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		starttime, endtime := "", ""
+		now := time.Now()
+		if publishtime == "lately-7" { //最近7天
+			starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
+		} else if publishtime == "lately-30" { //最近30天
+			starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
+		} else if publishtime == "thisyear" { //去年
+			starttime = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Unix())
+			endtime = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Unix())
+		} else {
+			starttime = strings.Split(publishtime, "_")[0]
+			endtime = strings.Split(publishtime, "_")[1]
+			et, _ := strconv.ParseInt(endtime, 0, 64)
+			etTime := time.Unix(et, 0)
+			endtime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
+		}
+		if starttime != "" && endtime != "" {
+			query += `{"range":{"publishtime":{"$gte":` + starttime + `,"$lt":` + endtime + `}}}`
+		} else if starttime != "" && endtime == "" {
+			query += `{"range":{"publishtime":{"$gte":` + starttime + `}}}`
+		} else if starttime == "" && endtime != "" {
+			query += `{"range":{"publishtime":{"$lt":` + endtime + `}}}`
+		}
+	}
+	if subtype != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		query += `{"terms":{"subtype":[`
+		for k, v := range strings.Split(subtype, ",") {
+			if k > 0 {
+				query += `,`
+			}
+			query += `"` + v + `"`
+		}
+		query += `]}}`
+	}
+	//
+	if industry != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		query += `{"terms":{"s_subscopeclass":[`
+		for k, v := range strings.Split(industry, ",") {
+			if k > 0 {
+				query += `,`
+			}
+			query += `"` + v + `"`
+		}
+		query += `]}}`
+	}
+	if city != "" {
+		if len(query) > 0 {
+			query += ","
+		}
+		query += `{"terms":{"city":[`
+		for k, v := range strings.Split(city, ",") {
+			if k > 0 {
+				query += `,`
+			}
+			query += `"` + v + `"`
+		}
+		query += `]}}`
+	}
+	return query
+}
 func getCityMap() map[string]interface{} {
 	m := map[string]interface{}{}
 	citymp, _ := config.Seoconfig["city"].(map[string]interface{})

+ 3 - 2
src/jfw/front/supsearch.go

@@ -3,6 +3,7 @@ package front
 import (
 	"fmt"
 	"jy/src/jfw/config"
+	newjy "jy/src/jfw/jy"
 	"jy/src/jfw/jyutil"
 	"log"
 	"math/rand"
@@ -374,7 +375,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		selectType = "title,content"
 	}
 	userInfo := jy.GetVipState(p.Session(), *config.Middleground, userId)
-	queryItems := userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
+	queryItems := newjy.GetQueryItems(userInfo, selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 	isPayedUser := userInfo.IsPayedUser()
 	if isPayedUser {
 		buyerclass = p.GetString("buyerclass")
@@ -405,7 +406,7 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 		searchMode = util.IntAll(p.GetSession("Echo_searchMode"))                //搜索模式;默认0:精准模式(不进行系统分词);1:模糊模式(进行系统分词)。
 		wordsMode = util.IntAll(p.GetSession("Echo_wordsMode"))                  //搜索关键词模式;默认0:包含所有关键词;1:包含任意关键词。
 		additionalWords = util.ObjToString(p.GetSession("Echo_additionalWords")) //关键词:附加关键词(副:五组,每组最多15个字符 每组,号隔开)
-		queryItems = userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
+		queryItems = newjy.GetQueryItems(userInfo, selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 	}
 	keywordsLimit := util.IntAllDef(config.Sysconfig["keywordsLimit"], 35)
 	searchLimit := public.IsSearchLimit(queryItems)

+ 3 - 2
src/jfw/front/swordfish.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"jy/src/jfw/config"
+	newjy "jy/src/jfw/jy"
 	"jy/src/jfw/jyutil"
 	"jy/src/jfw/wx"
 	"log"
@@ -134,7 +135,7 @@ func (m *Front) PcAjaxReq() {
 		list                      []*map[string]interface{}
 		heightKeys                string //需要高亮的关键词
 	)
-	queryItems = userInfo.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
+	queryItems = newjy.GetQueryItems(userInfo, selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 	isPayedUser = userInfo.IsPayedUser()
 	if isPayedUser {
 		buyerclass = m.GetString("buyerclass")
@@ -530,7 +531,7 @@ func (m *Front) WxsearchlistPaging() {
 			var city string = ""                          //城市
 			vipStatus := jy.GetVipState(m.Session(), *config.Middleground, userId)
 			isPayedUser = vipStatus.IsPayedUser()
-			queryItems := vipStatus.GetQueryItems(selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
+			queryItems := newjy.GetQueryItems(vipStatus, selectType, util.Int64All(config.Sysconfig["bidSearchOldUserLimit"]))
 			if isPayedUser {
 				if publishtime == "" {
 					publishtime = "fiveyear"

+ 4 - 5
src/jfw/front/ws_dataExport.go

@@ -5,9 +5,9 @@ import (
 	"errors"
 	"fmt"
 	"jy/src/jfw/config"
-	"strconv"
-
+	newjy "jy/src/jfw/jy"
 	"jy/src/jfw/jyutil"
+	"strconv"
 
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
@@ -307,7 +307,7 @@ func (w *WsDataExport) SubmitOrder() error {
 	if resEmail == "" || resPhone == "" {
 		lastEmail, lastPhone := "", ""
 		if lastPhone, lastEmail = dataexport.GetLastExportPhoneAndMail(public.Mysql, userId, util.ObjToString(w.GetSession("entUserId"))); lastPhone == "" || lastEmail == "" {
-			userData :=jyutil.Compatible.Select( userId, `{"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
+			userData := jyutil.Compatible.Select(userId, `{"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
 			if userData != nil && len(*userData) > 0 {
 				if lastEmail == "" {
 					lastEmail, _ = (*userData)["s_myemail"].(string)
@@ -382,8 +382,7 @@ func (wd *WsDataExport) SearchExport() error {
 		AdditionalWords: wd.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 	}
 	saveData := reqData.PassBidSearchExport(config.Sysconfig)
-	saveData["selectType"] = strings.Join(jy.GetVipState(wd.Session(), *config.Middleground, userId).
-		GetQueryItems(wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
+	saveData["selectType"] = strings.Join(newjy.GetQueryItems(jy.GetVipState(wd.Session(), *config.Middleground, userId), wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	saveData["s_openid"] = openid
 	saveData["s_userid"] = userId
 	saveData["comeinfrom"] = "supersearchPage"

+ 48 - 0
src/jfw/jy/payUser.go

@@ -0,0 +1,48 @@
+package jy
+
+import (
+	"strings"
+
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+)
+
+//免费 标题(title)  正文(content) 老用户【中标企业(winner)】
+//付费用户 全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
+//项目名称projectname和标的物purchasing(ppa)
+func GetQueryItems(vs *jy.VipState, selectType string, limitOldTime int64) (items []string) {
+	if vs.IsPayedUser() {
+		for _, t := range strings.Split(selectType, ",") {
+			if t == "content" {
+				items = append(items, "detail")
+			} else if t == "buyer" {
+				items = append(items, "buyer.mbuyer")
+			} else if t == "winner" {
+				items = append(items, "s_winner.mwinner")
+			} else if t == "agency" {
+				items = append(items, "agency.magency")
+			} else if t == "title" {
+				items = append(items, "title")
+			} else if t == "ppa" {
+				items = append(items, []string{"purchasing", "projectname.pname"}...)
+			} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+				items = append(items, "filetext")
+			}
+		}
+		return
+	}
+	isOldUser := vs.RegisterData != 0 && vs.RegisterData < limitOldTime
+	for _, t := range strings.Split(selectType, ",") {
+		if t == "winner" {
+			if isOldUser {
+				items = append(items, "s_winner.mwinner")
+			}
+		} else if t == "title" {
+			items = append(items, "title")
+		} else if t == "content" {
+			items = append(items, "detail")
+		} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+			items = append(items, "filetext")
+		}
+	}
+	return
+}

+ 2 - 2
src/jfw/modules/app/src/app/front/ws_dataExport.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	newjy "jy/src/jfw/modules/app/src/app/jy"
 	utils "jy/src/jfw/modules/app/src/app/jyutil"
 	"jy/src/jfw/modules/app/src/jfw/config"
 	"log"
@@ -360,8 +361,7 @@ func (wd *WsDataExport) SearchExport() error {
 		AdditionalWords: wd.GetString("additionalWords"),              //关键词:附加关键词(副:五组,每组最多15个字符)
 	}
 	saveData := reqData.PassBidSearchExport(config.Sysconfig)
-	saveData["selectType"] = strings.Join(jy.GetVipState(wd.Session(), *config.Middleground, userId).
-		GetQueryItems(wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
+	saveData["selectType"] = strings.Join(newjy.GetQueryItems(jy.GetVipState(wd.Session(), *config.Middleground, userId), wd.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
 	saveData["s_openid"] = openid
 	saveData["s_userid"] = userId
 	saveData["comeinfrom"] = "supersearchPage"

+ 48 - 0
src/jfw/modules/app/src/app/jy/payUser.go

@@ -0,0 +1,48 @@
+package jy
+
+import (
+	"strings"
+
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+)
+
+//免费 标题(title)  正文(content) 老用户【中标企业(winner)】
+//付费用户 全部(all)、标题(title)  正文(content)  会员: 采购单位(buyer) 中标企业(winner) 招标代理机构(agency) 附件(file)
+//项目名称projectname和标的物purchasing(ppa)
+func GetQueryItems(vs *jy.VipState, selectType string, limitOldTime int64) (items []string) {
+	if vs.IsPayedUser() {
+		for _, t := range strings.Split(selectType, ",") {
+			if t == "content" {
+				items = append(items, "detail")
+			} else if t == "buyer" {
+				items = append(items, "buyer.mbuyer")
+			} else if t == "winner" {
+				items = append(items, "s_winner.mwinner")
+			} else if t == "agency" {
+				items = append(items, "agency.magency")
+			} else if t == "title" {
+				items = append(items, "title")
+			} else if t == "ppa" {
+				items = append(items, []string{"purchasing", "projectname.pname"}...)
+			} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+				items = append(items, "filetext")
+			}
+		}
+		return
+	}
+	isOldUser := vs.RegisterData != 0 && vs.RegisterData < limitOldTime
+	for _, t := range strings.Split(selectType, ",") {
+		if t == "winner" {
+			if isOldUser {
+				items = append(items, "s_winner.mwinner")
+			}
+		} else if t == "title" {
+			items = append(items, "title")
+		} else if t == "content" {
+			items = append(items, "detail")
+		} else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
+			items = append(items, "filetext")
+		}
+	}
+	return
+}