Browse Source

fix:数据导出修改

duxin 2 năm trước cách đây
mục cha
commit
c188d005e8

+ 25 - 10
src/jfw/front/dataExport.go

@@ -229,7 +229,8 @@ func (d *DataExport) SieveData() {
 	}
 	}
 }
 }
 
 
-/**
+/*
+*
 
 
 根据 id+openid 取消订单
 根据 id+openid 取消订单
 */
 */
@@ -247,7 +248,8 @@ func (d *DataExport) CancelOrder() error {
 	return nil
 	return nil
 }
 }
 
 
-/**
+/*
+*
 根据 订单编号+userId 查询
 根据 订单编号+userId 查询
 */
 */
 func (d *DataExport) ToOrderDetail(orderCode string) error {
 func (d *DataExport) ToOrderDetail(orderCode string) error {
@@ -344,7 +346,7 @@ func (d *DataExport) ToOrderDetail(orderCode string) error {
 	return d.Render("/pc/orderDetail.html", &d.T)
 	return d.Render("/pc/orderDetail.html", &d.T)
 }
 }
 
 
-//------------------------------申请发票跳转页面-----------------------------
+// ------------------------------申请发票跳转页面-----------------------------
 func (d *DataExport) GetOrderCode(order_code string) error {
 func (d *DataExport) GetOrderCode(order_code string) error {
 	var status, order_status int64
 	var status, order_status int64
 	queryMap := map[string]interface{}{
 	queryMap := map[string]interface{}{
@@ -364,7 +366,7 @@ func (d *DataExport) GetOrderCode(order_code string) error {
 	return nil
 	return nil
 }
 }
 
 
-//---------------------------生成订单预览----------------------------------
+// ---------------------------生成订单预览----------------------------------
 func (d *DataExport) SuperSearchExport() error {
 func (d *DataExport) SuperSearchExport() error {
 	openid := util.ObjToString(d.GetSession("s_m_openid"))
 	openid := util.ObjToString(d.GetSession("s_m_openid"))
 	userId := util.ObjToString(d.GetSession("userId"))
 	userId := util.ObjToString(d.GetSession("userId"))
@@ -542,6 +544,18 @@ func (d *DataExport) PreviewData(source, _id string) error {
 	//格式化字段
 	//格式化字段
 	res_screen := dataexport.ScreenData(res, dataType, 20, kws)
 	res_screen := dataexport.ScreenData(res, dataType, 20, kws)
 	list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
 	list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
+	if len(kws) > 0 && kws[0].Keyword != "" {
+		var keys []string
+		//统计关键词
+		for _, vk := range kws {
+			keys = append(keys, strings.Replace(vk.Keyword, "+", "", -1))
+		}
+		//二次匹配
+		for _, vs := range *list {
+			vs["keyword"] = jy.GetMatchKey(strings.Join(keys, ","), scd.SelectType, vs)
+		}
+	}
+
 	d.T["data"] = subUrl(list, dataType)
 	d.T["data"] = subUrl(list, dataType)
 	d.T["dataType"] = dataType
 	d.T["dataType"] = dataType
 	d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
 	d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
@@ -549,7 +563,8 @@ func (d *DataExport) PreviewData(source, _id string) error {
 	return nil
 	return nil
 }
 }
 
 
-/**
+/*
+*
 设置ttf版本号
 设置ttf版本号
 */
 */
 func (d *DataExport) FontSet(version string) {
 func (d *DataExport) FontSet(version string) {
@@ -598,7 +613,7 @@ func subUrl(list *[]map[string]interface{}, dataType string) *[]map[string]inter
 	return &result
 	return &result
 }
 }
 
 
-//发送邮件
+// 发送邮件
 func (d *DataExport) SendMailVerify() {
 func (d *DataExport) SendMailVerify() {
 	email := d.GetString("email")
 	email := d.GetString("email")
 	if isEmail(email) {
 	if isEmail(email) {
@@ -670,7 +685,7 @@ func isPhone(value string) bool {
 	return phonePattern.MatchString(value)
 	return phonePattern.MatchString(value)
 }
 }
 
 
-//验证手机号
+// 验证手机号
 func (d *DataExport) CheckPhoneVerify() {
 func (d *DataExport) CheckPhoneVerify() {
 	phone := d.GetString("phone")
 	phone := d.GetString("phone")
 	verityResult := false
 	verityResult := false
@@ -682,7 +697,7 @@ func (d *DataExport) CheckPhoneVerify() {
 	d.ServeJson(&d.T)
 	d.ServeJson(&d.T)
 }
 }
 
 
-//验证邮箱
+// 验证邮箱
 func (d *DataExport) CheckMailVerify() {
 func (d *DataExport) CheckMailVerify() {
 	email := d.GetString("email")
 	email := d.GetString("email")
 	emailVerity := d.GetString("emailVerity")
 	emailVerity := d.GetString("emailVerity")
@@ -878,7 +893,7 @@ func (d *DataExport) ValuationList(order_code string) error {
 //	return nil
 //	return nil
 //}
 //}
 
 
-//剑鱼pc判断登录用户是否有我的企业、商机管理菜单
+// 剑鱼pc判断登录用户是否有我的企业、商机管理菜单
 func (this *DataExport) GetPcEntAuth() {
 func (this *DataExport) GetPcEntAuth() {
 	userId, _ := this.GetSession("userId").(string)
 	userId, _ := this.GetSession("userId").(string)
 	//userId := "1212"
 	//userId := "1212"
@@ -1136,7 +1151,7 @@ func (this *DataExport) GetPcEntAuth() {
 //	return count
 //	return count
 //}
 //}
 
 
-//获取当前登录用户的手机号
+// 获取当前登录用户的手机号
 func GetPhone(userId string) (string, string) {
 func GetPhone(userId string) (string, string) {
 	u, ok := mongodb.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
 	u, ok := mongodb.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
 	if ok && u != nil {
 	if ok && u != nil {

+ 22 - 16
src/jfw/modules/common/src/qfw/util/dataexport/dataexport.go

@@ -74,17 +74,17 @@ var topType = map[string]string{
 	"采购意向":   "采购意向",
 	"采购意向":   "采购意向",
 }
 }
 
 
-//包含正文或 附件 不包含标题
+// 包含正文或 附件 不包含标题
 func DetailFileORTitle(findfields string) bool {
 func DetailFileORTitle(findfields string) bool {
 	return (strings.Contains(findfields, "detail") || strings.Contains(findfields, "filetext")) && !strings.Contains(findfields, "title")
 	return (strings.Contains(findfields, "detail") || strings.Contains(findfields, "filetext")) && !strings.Contains(findfields, "title")
 }
 }
 
 
-//包含正文包含标题
+// 包含正文包含标题
 func DetailANDTitle(findfields string) bool {
 func DetailANDTitle(findfields string) bool {
 	return strings.Contains(findfields, "detail") && strings.Contains(findfields, "title")
 	return strings.Contains(findfields, "detail") && strings.Contains(findfields, "title")
 }
 }
 
 
-//获取数据导出查询语句
+// 获取数据导出查询语句
 func getDataExportSql(scd *SieveCondition) string {
 func getDataExportSql(scd *SieveCondition) string {
 	if len(scd.SelectIds) > 0 {
 	if len(scd.SelectIds) > 0 {
 		query := `{"query":{"bool":{"must":[%s]}}}`
 		query := `{"query":{"bool":{"must":[%s]}}}`
@@ -379,7 +379,7 @@ func getDataExportSql(scd *SieveCondition) string {
 	return qstr
 	return qstr
 }
 }
 
 
-//获取数据导出筛选条件
+// 获取数据导出筛选条件
 func GetSqlObjFromId(mongo mg.MongodbSim, _id string) *SieveCondition {
 func GetSqlObjFromId(mongo mg.MongodbSim, _id string) *SieveCondition {
 	var (
 	var (
 		query *map[string]interface{}
 		query *map[string]interface{}
@@ -414,7 +414,7 @@ func GetSqlObjFromId(mongo mg.MongodbSim, _id string) *SieveCondition {
 	}
 	}
 }
 }
 
 
-//数据导出-查询结果数量
+// 数据导出-查询结果数量
 func GetDataExportSearchCountByScdId(sim, bid mg.MongodbSim, biddingName, elasticAddress, id string) (count int) {
 func GetDataExportSearchCountByScdId(sim, bid mg.MongodbSim, biddingName, elasticAddress, id string) (count int) {
 	scd := GetSqlObjFromId(sim, id) //用户筛选条件
 	scd := GetSqlObjFromId(sim, id) //用户筛选条件
 	if scd.SelectIds != nil {
 	if scd.SelectIds != nil {
@@ -466,7 +466,7 @@ func GetDataExportSearchCountBySieveCondition(scd *SieveCondition, elasticAddres
 	return
 	return
 }
 }
 
 
-//合并map数据,去重
+// 合并map数据,去重
 func delRepeatMapArr(res *[]map[string]interface{}, res2 *[]map[string]interface{}) *[]map[string]interface{} {
 func delRepeatMapArr(res *[]map[string]interface{}, res2 *[]map[string]interface{}) *[]map[string]interface{} {
 	if res != nil {
 	if res != nil {
 		for _, v := range *res {
 		for _, v := range *res {
@@ -484,7 +484,7 @@ func delRepeatMapArr(res *[]map[string]interface{}, res2 *[]map[string]interface
 	return res
 	return res
 }
 }
 
 
-//查询条件是否为空
+// 查询条件是否为空
 func isNullSearch(scd *SieveCondition) (isNull bool) {
 func isNullSearch(scd *SieveCondition) (isNull bool) {
 	if scd.PublishTime == "" && len(scd.Area) == 0 && len(scd.Industry) == 0 && len(scd.Keyword) == 0 && len(scd.Buyer) == 0 && len(scd.Winner) == 0 && scd.MinPrice == "" && scd.MaxPrice == "" && scd.Subtype == "" && len(scd.City) == 0 {
 	if scd.PublishTime == "" && len(scd.Area) == 0 && len(scd.Industry) == 0 && len(scd.Keyword) == 0 && len(scd.Buyer) == 0 && len(scd.Winner) == 0 && scd.MinPrice == "" && scd.MaxPrice == "" && scd.Subtype == "" && len(scd.City) == 0 {
 		isNull = true
 		isNull = true
@@ -511,10 +511,10 @@ func GetDataExportIdArrByScdId(sim mg.MongodbSim, elasticAddress, id string, che
 	return GetDataExportIds(elasticAddress, scd, checkCount)
 	return GetDataExportIds(elasticAddress, scd, checkCount)
 }
 }
 
 
-//收藏导出
+// 收藏导出
 var contentfilterReg = regexp.MustCompile("<[^>]+>")
 var contentfilterReg = regexp.MustCompile("<[^>]+>")
 
 
-//GetDataExportSelectReallyCount 查询实际可调导出数量
+// GetDataExportSelectReallyCount 查询实际可调导出数量
 func GetDataExportSelectReallyCount(bid mg.MongodbSim, biddingName string, ids []string) int64 {
 func GetDataExportSelectReallyCount(bid mg.MongodbSim, biddingName string, ids []string) int64 {
 	sess := bid.GetMgoConn()
 	sess := bid.GetMgoConn()
 	defer bid.DestoryMongoConn(sess)
 	defer bid.DestoryMongoConn(sess)
@@ -560,7 +560,7 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
 		"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1,
 		"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1,
 	}
 	}
 	if dataType == "2" {
 	if dataType == "2" {
-		for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel"} {
+		for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime"} {
 			selectMap[key] = 1
 			selectMap[key] = 1
 		}
 		}
 	}
 	}
@@ -650,9 +650,9 @@ func GetDataExportIds(elasticAddress string, scd *SieveCondition, checkCount int
 	return idArr, nil
 	return idArr, nil
 }
 }
 
 
-//GetDataExportSearchResult 获取数据导出内容
-//entmg 高级字段包查询企业电话邮箱等字段
-//checkCount -1 预览500条
+// GetDataExportSearchResult 获取数据导出内容
+// entmg 高级字段包查询企业电话邮箱等字段
+// checkCount -1 预览500条
 func GetDataExportSearchResult(bid mg.MongodbSim, bidMgoDBName, elasticAddress string, scd *SieveCondition, dataType string, checkCount int) (*[]map[string]interface{}, error) {
 func GetDataExportSearchResult(bid mg.MongodbSim, bidMgoDBName, elasticAddress string, scd *SieveCondition, dataType string, checkCount int) (*[]map[string]interface{}, error) {
 	defer qutil.Catch()
 	defer qutil.Catch()
 	if scd == nil {
 	if scd == nil {
@@ -908,7 +908,7 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
 	return data
 	return data
 }
 }
 
 
-//保留到0.01分
+// 保留到0.01分
 func formatFloat(value float64) string {
 func formatFloat(value float64) string {
 	str := strings.TrimRight(fmt.Sprintf("%.7f", value*10000/100000000), "0")
 	str := strings.TrimRight(fmt.Sprintf("%.7f", value*10000/100000000), "0")
 	if str[len(str)-1:] == "." {
 	if str[len(str)-1:] == "." {
@@ -923,7 +923,7 @@ func doSearch(sql string, start, count int, dataType string) *[]map[string]inter
 		if dataType != "" {
 		if dataType != "" {
 			dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype"`
 			dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype"`
 			if dataType == "2" {
 			if dataType == "2" {
-				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel"`
+				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime"`
 			}
 			}
 			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
 			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
 		}
 		}
@@ -959,13 +959,19 @@ func getStringArrFromDbResult(c interface{}) (arr []string) {
 	return
 	return
 }
 }
 
 
-//获取结果,空字段最少的数据
+// 获取结果,空字段最少的数据
 func ScreenData(arr *[]map[string]interface{}, dataType string, resultNum int, kws []KeyWord) (res []map[string]interface{}) {
 func ScreenData(arr *[]map[string]interface{}, dataType string, resultNum int, kws []KeyWord) (res []map[string]interface{}) {
 	AllMap := map[int][]map[string]interface{}{}
 	AllMap := map[int][]map[string]interface{}{}
 
 
 	NoKwsMap := map[int][]map[string]interface{}{}
 	NoKwsMap := map[int][]map[string]interface{}{}
 	lastNum := resultNum
 	lastNum := resultNum
 	for _, v := range *arr {
 	for _, v := range *arr {
+		if qutil.Int64All(v["bidendtime"]) > 0 {
+			v["bidendtime"] = strings.Split(time.Unix(qutil.Int64All(v["bidendtime"]), 0).Format("2006-01-02 15:04:05"), " ")[0]
+		} else {
+			v["bidendtime"] = ""
+		}
+
 		emptyNum := countOfTheEmpty(v, dataType)
 		emptyNum := countOfTheEmpty(v, dataType)
 		if emptyNum == -1 {
 		if emptyNum == -1 {
 			continue
 			continue

+ 27 - 3
src/jfw/modules/common/src/qfw/util/dataexport/entdataexport.go

@@ -11,6 +11,7 @@ import (
 	"os"
 	"os"
 	"qfw/util"
 	"qfw/util"
 	"qfw/util/elastic"
 	"qfw/util/elastic"
+	"qfw/util/jy"
 	"qfw/util/mysql"
 	"qfw/util/mysql"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -21,7 +22,7 @@ import (
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson"
 )
 )
 
 
-//作者:一组开发
+// 作者:一组开发
 type Filters struct {
 type Filters struct {
 	FilterId string
 	FilterId string
 }
 }
@@ -38,7 +39,15 @@ func GetEntDataExportCount(sim, bid mg.MongodbSim, bidMgoDBName, elasticAddress,
 	log.Println("count", count)
 	log.Println("count", count)
 	dataType := "2"
 	dataType := "2"
 	//数据导出数据查询
 	//数据导出数据查询
-
+	scd := GetSqlObjFromId(sim, _id)
+	kws := scd.Keyword
+	var keys []string
+	if len(kws) > 0 && kws[0].Keyword != "" {
+		//统计关键词
+		for _, vk := range kws {
+			keys = append(keys, strings.Replace(vk.Keyword, "+", "", -1))
+		}
+	}
 	res, err := GetDataExportSearchResultByScdId(sim, bid, bidMgoDBName, elasticAddress, _id, dataType, count)
 	res, err := GetDataExportSearchResultByScdId(sim, bid, bidMgoDBName, elasticAddress, _id, dataType, count)
 	if err != nil {
 	if err != nil {
 		log.Println("企业数据导出错误 ", err)
 		log.Println("企业数据导出错误 ", err)
@@ -52,6 +61,15 @@ func GetEntDataExportCount(sim, bid mg.MongodbSim, bidMgoDBName, elasticAddress,
 		insertFlag = "true"
 		insertFlag = "true"
 	}
 	}
 	for _, v := range *res {
 	for _, v := range *res {
+		if len(keys) > 0 {
+			//二次匹配
+			v["keyword"] = jy.GetMatchKey(strings.Join(keys, ","), scd.SelectType, v)
+		}
+		if util.Int64All(v["bidendtime"]) > 0 {
+			v["bidendtime"] = strings.Split(time.Unix(util.Int64All(v["bidendtime"]), 0).Format("2006-01-02 15:04:05"), " ")[0]
+		} else {
+			v["bidendtime"] = ""
+		}
 		id := util.ObjToString(v["_id"])
 		id := util.ObjToString(v["_id"])
 		if m[id] {
 		if m[id] {
 			continue
 			continue
@@ -260,7 +278,7 @@ func Post(url string, form map[string]string) (data map[string]interface{}, err
 	return data, nil
 	return data, nil
 }
 }
 
 
-//生成xlsx
+// 生成xlsx
 func GetXlsx(mMap []map[string]interface{}, entId, entUserId int, filePath string) string {
 func GetXlsx(mMap []map[string]interface{}, entId, entUserId int, filePath string) string {
 	xf, err := xlsx.OpenFile("./web/staticres/fields.xlsx")
 	xf, err := xlsx.OpenFile("./web/staticres/fields.xlsx")
 	if err != nil {
 	if err != nil {
@@ -269,6 +287,7 @@ func GetXlsx(mMap []map[string]interface{}, entId, entUserId int, filePath strin
 	sh := xf.Sheets[1]
 	sh := xf.Sheets[1]
 	for _, v := range mMap {
 	for _, v := range mMap {
 		row := sh.AddRow()
 		row := sh.AddRow()
+		row.AddCell().SetValue(v["keyword"])
 		row.AddCell().SetValue(v["area"])
 		row.AddCell().SetValue(v["area"])
 		row.AddCell().SetValue(v["city"])
 		row.AddCell().SetValue(v["city"])
 		row.AddCell().SetValue(v["title"])
 		row.AddCell().SetValue(v["title"])
@@ -299,6 +318,11 @@ func GetXlsx(mMap []map[string]interface{}, entId, entUserId int, filePath strin
 		} else {
 		} else {
 			row.AddCell()
 			row.AddCell()
 		}
 		}
+		if v["bidendtime"] != nil {
+			row.AddCell().SetValue(v["bidendtime"])
+		} else {
+			row.AddCell()
+		}
 		row.AddCell().SetValue(v["buyer"])
 		row.AddCell().SetValue(v["buyer"])
 		row.AddCell().SetValue(v["buyerperson"])
 		row.AddCell().SetValue(v["buyerperson"])
 		row.AddCell().SetValue(v["buyertel"])
 		row.AddCell().SetValue(v["buyertel"])

+ 105 - 22
src/jfw/modules/common/src/qfw/util/jy/userPhoneUtil.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"fmt"
 	mg "mongodb"
 	mg "mongodb"
 	qutil "qfw/util"
 	qutil "qfw/util"
+	"strings"
 	"time"
 	"time"
 )
 )
 
 
@@ -24,7 +25,7 @@ func (this *PhoneUtil) Log(userId, operation, value string) {
 	})
 	})
 }
 }
 
 
-//获取微信关联字段
+// 获取微信关联字段
 func (this *PhoneUtil) getWxRelationMap(userId string) *map[string]interface{} {
 func (this *PhoneUtil) getWxRelationMap(userId string) *map[string]interface{} {
 	rData, _ := this.UserMgoDB.FindById("user", userId, `{"s_unionid":1,"s_name":1,"s_nickname":1,"s_headimageurl":1}`)
 	rData, _ := this.UserMgoDB.FindById("user", userId, `{"s_unionid":1,"s_name":1,"s_nickname":1,"s_headimageurl":1}`)
 	if rData == nil || len(*rData) == 0 {
 	if rData == nil || len(*rData) == 0 {
@@ -34,7 +35,7 @@ func (this *PhoneUtil) getWxRelationMap(userId string) *map[string]interface{} {
 	return rData
 	return rData
 }
 }
 
 
-//获取手机号
+// 获取手机号
 func (this *PhoneUtil) getUserPhone(userId string) (phone string) {
 func (this *PhoneUtil) getUserPhone(userId string) (phone string) {
 	rData, _ := this.UserMgoDB.FindById("user", userId, `{"s_phone":1}`)
 	rData, _ := this.UserMgoDB.FindById("user", userId, `{"s_phone":1}`)
 	if rData != nil && len(*rData) > 0 {
 	if rData != nil && len(*rData) > 0 {
@@ -43,7 +44,7 @@ func (this *PhoneUtil) getUserPhone(userId string) (phone string) {
 	return
 	return
 }
 }
 
 
-//绑定微信
+// 绑定微信
 func (this *PhoneUtil) bindWeixin(phoneUserId string, wxRelationMap *map[string]interface{}, opera string) error {
 func (this *PhoneUtil) bindWeixin(phoneUserId string, wxRelationMap *map[string]interface{}, opera string) error {
 	if !this.UserMgoDB.UpdateById("user", phoneUserId, map[string]interface{}{
 	if !this.UserMgoDB.UpdateById("user", phoneUserId, map[string]interface{}{
 		"$set": wxRelationMap,
 		"$set": wxRelationMap,
@@ -55,7 +56,7 @@ func (this *PhoneUtil) bindWeixin(phoneUserId string, wxRelationMap *map[string]
 	return nil
 	return nil
 }
 }
 
 
-//解绑微信
+// 解绑微信
 func (this *PhoneUtil) unBindWeixin(phoneUserId, opera string) error {
 func (this *PhoneUtil) unBindWeixin(phoneUserId, opera string) error {
 	//查询解绑微信unionid
 	//查询解绑微信unionid
 	logMap := this.getWxRelationMap(phoneUserId)
 	logMap := this.getWxRelationMap(phoneUserId)
@@ -73,7 +74,7 @@ func (this *PhoneUtil) unBindWeixin(phoneUserId, opera string) error {
 	return nil
 	return nil
 }
 }
 
 
-//绑定手机号
+// 绑定手机号
 func (this *PhoneUtil) bindPhone(weixinUserId, phone, opera string) error {
 func (this *PhoneUtil) bindPhone(weixinUserId, phone, opera string) error {
 	if !this.UserMgoDB.UpdateById("user", weixinUserId, map[string]interface{}{
 	if !this.UserMgoDB.UpdateById("user", weixinUserId, map[string]interface{}{
 		"$set": map[string]interface{}{
 		"$set": map[string]interface{}{
@@ -88,7 +89,7 @@ func (this *PhoneUtil) bindPhone(weixinUserId, phone, opera string) error {
 	return nil
 	return nil
 }
 }
 
 
-//解除手机号关联
+// 解除手机号关联
 func (this *PhoneUtil) unBindPhone(weixinUserId, opera string) error {
 func (this *PhoneUtil) unBindPhone(weixinUserId, opera string) error {
 	logPhone := this.getUserPhone(weixinUserId)
 	logPhone := this.getUserPhone(weixinUserId)
 	if !this.UserMgoDB.UpdateById("user", weixinUserId, map[string]interface{}{
 	if !this.UserMgoDB.UpdateById("user", weixinUserId, map[string]interface{}{
@@ -103,7 +104,7 @@ func (this *PhoneUtil) unBindPhone(weixinUserId, opera string) error {
 
 
 //=============================================
 //=============================================
 
 
-//建立双向关联关系
+// 建立双向关联关系
 func (this *PhoneUtil) buildRelation(wxUserId, phoneUserId, phone string, wxRelationMap *map[string]interface{}, opera string) error {
 func (this *PhoneUtil) buildRelation(wxUserId, phoneUserId, phone string, wxRelationMap *map[string]interface{}, opera string) error {
 	//建立双向关联关系
 	//建立双向关联关系
 	if wxRelationMap == nil {
 	if wxRelationMap == nil {
@@ -124,7 +125,7 @@ func (this *PhoneUtil) buildRelation(wxUserId, phoneUserId, phone string, wxRela
 	return nil
 	return nil
 }
 }
 
 
-//解除双向绑定
+// 解除双向绑定
 func (this *PhoneUtil) RelieveRelation(weixinId, phoneId, opera string) error {
 func (this *PhoneUtil) RelieveRelation(weixinId, phoneId, opera string) error {
 	if err := this.unBindPhone(weixinId, opera); err != nil {
 	if err := this.unBindPhone(weixinId, opera); err != nil {
 		return err
 		return err
@@ -135,7 +136,7 @@ func (this *PhoneUtil) RelieveRelation(weixinId, phoneId, opera string) error {
 	return nil
 	return nil
 }
 }
 
 
-//查询是否存在双向关联关系
+// 查询是否存在双向关联关系
 func (this *PhoneUtil) QueryRelation(phone string) (wId, pId string, err error) {
 func (this *PhoneUtil) QueryRelation(phone string) (wId, pId string, err error) {
 	relationUser, _ := this.UserMgoDB.Find("user", map[string]interface{}{
 	relationUser, _ := this.UserMgoDB.Find("user", map[string]interface{}{
 		"i_appid": 2,
 		"i_appid": 2,
@@ -170,9 +171,13 @@ func (this *PhoneUtil) QueryRelation(phone string) (wId, pId string, err error)
 /*
 /*
 微信账号绑定手机号判断是否存在
 微信账号绑定手机号判断是否存在
 param  unionId:当前微信的s_unionid
 param  unionId:当前微信的s_unionid
-		 phone:要绑定的手机号
+
+	phone:要绑定的手机号
+
 return exists:是否存在
 return exists:是否存在
-       relationPhoneId:需要建立关联关系的手机号用户id
+
+	relationPhoneId:需要建立关联关系的手机号用户id
+
 rule 1.不存在手机号,2.存在手机号用户,但此手机号未绑定微信 3.存在手机号用户,或绑定微信和当前账户绑定微信一致
 rule 1.不存在手机号,2.存在手机号用户,但此手机号未绑定微信 3.存在手机号用户,或绑定微信和当前账户绑定微信一致
 */
 */
 func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists bool, relationPhoneId string) {
 func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists bool, relationPhoneId string) {
@@ -204,9 +209,10 @@ func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists bool, re
 /*
 /*
 绑定手机号
 绑定手机号
 param wxUserId:绑定手机号的微信
 param wxUserId:绑定手机号的微信
-	  relationPhoneId:存在关联的手机号账户
-      phone:绑定的手机号
-      wxRelationMap:相关联的微信信息
+
+		  relationPhoneId:存在关联的手机号账户
+	      phone:绑定的手机号
+	      wxRelationMap:相关联的微信信息
 */
 */
 func (this *PhoneUtil) BindPhone(wxUserId, relationPhoneId, phone string, wxRelationMap *map[string]interface{}) error {
 func (this *PhoneUtil) BindPhone(wxUserId, relationPhoneId, phone string, wxRelationMap *map[string]interface{}) error {
 	if relationPhoneId == "" {
 	if relationPhoneId == "" {
@@ -221,9 +227,13 @@ func (this *PhoneUtil) BindPhone(wxUserId, relationPhoneId, phone string, wxRela
 /*
 /*
 更改手机号
 更改手机号
 param phone要更改的手机号
 param phone要更改的手机号
-    needMerge:当前账户是否需要合并
+
+	needMerge:当前账户是否需要合并
+
 return exists:是否存在
 return exists:是否存在
-        relationPhoneId:需要建立关联关系的手机号用户id
+
+	relationPhoneId:需要建立关联关系的手机号用户id
+
 rule:在合并状态的微信账户,可以更换存在但未绑定微信的手机号;其他情况只能更换新手机号
 rule:在合并状态的微信账户,可以更换存在但未绑定微信的手机号;其他情况只能更换新手机号
 */
 */
 func (this *PhoneUtil) ChangePhoneIsOccupy(phone string, isWxAndNeedMerge bool) (exists bool, relationPhoneId string) {
 func (this *PhoneUtil) ChangePhoneIsOccupy(phone string, isWxAndNeedMerge bool) (exists bool, relationPhoneId string) {
@@ -270,9 +280,13 @@ func (this *PhoneUtil) ChangePhoneIsOccupy(phone string, isWxAndNeedMerge bool)
 /*
 /*
 手机号账号绑定微信判断微信是否存在
 手机号账号绑定微信判断微信是否存在
 param   phone:当前手机号
 param   phone:当前手机号
-		unionId:要绑定的微信s_unionid
+
+	unionId:要绑定的微信s_unionid
+
 return exists:是否存在
 return exists:是否存在
-       relationWeixinId:需要建立关联关系的微信用户id
+
+	relationWeixinId:需要建立关联关系的微信用户id
+
 rule  存在对应的微信 1.未绑定手机号 2.绑定手机号为当前账户手机号
 rule  存在对应的微信 1.未绑定手机号 2.绑定手机号为当前账户手机号
 */
 */
 func (this *PhoneUtil) BindWeixinIsOccupy(phone, unionId string) (exists bool, relationWeixinId string) {
 func (this *PhoneUtil) BindWeixinIsOccupy(phone, unionId string) (exists bool, relationWeixinId string) {
@@ -304,9 +318,10 @@ func (this *PhoneUtil) BindWeixinIsOccupy(phone, unionId string) (exists bool, r
 /*
 /*
 手机号账号绑定微信
 手机号账号绑定微信
 param   phoneUserId:绑定微信的手机账户
 param   phoneUserId:绑定微信的手机账户
-        relationWeixinId:存在相关联的微信信息
-        phone:当前手机账号手机号
-		wxRelationMap:相关联的微信信息
+
+	        relationWeixinId:存在相关联的微信信息
+	        phone:当前手机账号手机号
+			wxRelationMap:相关联的微信信息
 */
 */
 func (this *PhoneUtil) BindWeixin(phoneUserId, relationWeixinId, phone string, wxRelationMap *map[string]interface{}, opear ...string) error {
 func (this *PhoneUtil) BindWeixin(phoneUserId, relationWeixinId, phone string, wxRelationMap *map[string]interface{}, opear ...string) error {
 	logFlag := "BindWeixin"
 	logFlag := "BindWeixin"
@@ -323,7 +338,8 @@ func (this *PhoneUtil) BindWeixin(phoneUserId, relationWeixinId, phone string, w
 /*
 /*
 手机号解绑微信
 手机号解绑微信
 param   phoneUserId:绑定微信的手机账户
 param   phoneUserId:绑定微信的手机账户
-        relationWeixinId:存在相关联的微信信息
+
+	relationWeixinId:存在相关联的微信信息
 */
 */
 func (this *PhoneUtil) UnBindWeixin(phoneUserId, relationWeixinId string, opear ...string) error {
 func (this *PhoneUtil) UnBindWeixin(phoneUserId, relationWeixinId string, opear ...string) error {
 	logFlag := "UnBindWeixin"
 	logFlag := "UnBindWeixin"
@@ -336,3 +352,70 @@ func (this *PhoneUtil) UnBindWeixin(phoneUserId, relationWeixinId string, opear
 		return this.RelieveRelation(relationWeixinId, phoneUserId, logFlag)
 		return this.RelieveRelation(relationWeixinId, phoneUserId, logFlag)
 	}
 	}
 }
 }
+
+// GetMatchKey key 关键词 逗号分隔 或的关系进行关联  types 匹配类型  data数据
+// title 标题,detail 正文,filetext 附件,purchasing 标的物,projectname.pname 项目命,mbuyer 采购单位,mwinner 中标单位,magency 代理机构
+func GetMatchKey(key, types string, data map[string]interface{}) string {
+	keyWord := []string{}
+	if strings.Contains(types, "title") {
+		title := qutil.ObjToString(data["title"])
+		keyWord = KeyWordToDatas(title, key, keyWord)
+	}
+	if strings.Contains(types, "detail") {
+		detail := qutil.ObjToString(data["detail"])
+		keyWord = KeyWordToDatas(detail, key, keyWord)
+	}
+	if strings.Contains(types, "purchasing") {
+		purchasing := qutil.ObjToString(data["purchasing"])
+		keyWord = KeyWordToDatas(purchasing, key, keyWord)
+	}
+	if strings.Contains(types, "filetext") {
+		filetext := qutil.ObjToString(data["filetext"])
+		keyWord = KeyWordToDatas(filetext, key, keyWord)
+	}
+	if strings.Contains(types, "projectname.pname") {
+		projectname := qutil.ObjToString(data["projectname"])
+		keyWord = KeyWordToDatas(projectname, key, keyWord)
+	}
+	if strings.Contains(types, "mbuyer") {
+		buyer := qutil.ObjToString(data["buyer"])
+		keyWord = KeyWordToDatas(buyer, key, keyWord)
+	}
+	if strings.Contains(types, "mwinner") {
+		winner := qutil.ObjToString(data["s_winner"])
+		keyWord = KeyWordToDatas(winner, key, keyWord)
+	}
+	if strings.Contains(types, "magency") {
+		winner := qutil.ObjToString(data["agency"])
+		keyWord = KeyWordToDatas(winner, key, keyWord)
+	}
+	keyMap := map[string]bool{}
+	keyArr := []string{}
+	for _, key := range keyWord {
+		keyMap[key] = true
+	}
+	for k, _ := range keyMap {
+		keyArr = append(keyArr, k)
+	}
+	return strings.Join(keyArr, ",")
+}
+
+func KeyWordToDatas(item, key string, keyWord []string) []string {
+	for _, mk := range strings.Split(key, ",") {
+		if strings.Contains(mk, "&&") {
+			arr := strings.Split(mk, "&&")
+			for _, s := range arr {
+				if s != "" {
+					if strings.Contains(strings.ToUpper(item), strings.ToUpper(s)) {
+						keyWord = append(keyWord, mk)
+					}
+				}
+			}
+		} else {
+			if strings.Contains(strings.ToUpper(item), strings.ToUpper(mk)) {
+				keyWord = append(keyWord, mk)
+			}
+		}
+	}
+	return keyWord
+}

BIN
src/web/staticres/fields.xlsx


+ 6 - 0
src/web/templates/pc/previewData.html

@@ -42,6 +42,7 @@
 				<table class="d_bz" cellspacing="0" cellpadding="0">
 				<table class="d_bz" cellspacing="0" cellpadding="0">
 					<tr>
 					<tr>
             <td>序号</td>
             <td>序号</td>
+            <td>匹配关键词</td>
           	<td>省份</td>
           	<td>省份</td>
 						<td>城市</td>
 						<td>城市</td>
 						<td>公告标题</td>
 						<td>公告标题</td>
@@ -61,6 +62,7 @@
 							document.write(index++)
 							document.write(index++)
 							</script>
 							</script>
 						</td>
 						</td>
+            <td>{{$v.keyword}}</td>
             <td>{{$v.area}}</td>
             <td>{{$v.area}}</td>
 						<td>{{$v.city}}</td>
 						<td>{{$v.city}}</td>
 						<td>{{$v.title}}</td>
 						<td>{{$v.title}}</td>
@@ -81,6 +83,7 @@
 				<table class="d_gj" cellspacing="0" cellpadding="0">
 				<table class="d_gj" cellspacing="0" cellpadding="0">
 				<tr>
 				<tr>
 					<td rowspan=2>序号</td>
 					<td rowspan=2>序号</td>
+          <td>匹配关键词</td>
           <td rowspan=2>省份</td>
           <td rowspan=2>省份</td>
 					<td rowspan=2>城市</td>
 					<td rowspan=2>城市</td>
 					<td rowspan=2>公告标题</td>
 					<td rowspan=2>公告标题</td>
@@ -95,6 +98,7 @@
           <td rowspan=2>预算金额<br>(万元)</td>
           <td rowspan=2>预算金额<br>(万元)</td>
           <td rowspan=2>中标金额<br>(万元)</td>
           <td rowspan=2>中标金额<br>(万元)</td>
           <td rowspan=2>开标日期</td>
           <td rowspan=2>开标日期</td>
+          <td rowspan=2>投标截止日期</td>
           <td colspan=3>采购单位信息</td>
           <td colspan=3>采购单位信息</td>
           <td rowspan=2>招标代理机构</td>
           <td rowspan=2>招标代理机构</td>
           <td colspan=3>中标单位信息(来源:招标公告网站)</td>
           <td colspan=3>中标单位信息(来源:招标公告网站)</td>
@@ -122,6 +126,7 @@
 					document.write(index++)
 					document.write(index++)
 					</script>
 					</script>
 					</td>
 					</td>
+          <td>{{$v.keyword}}</td>
           <td>{{$v.area}}</td>
           <td>{{$v.area}}</td>
 					<td>{{$v.city}}</td>
 					<td>{{$v.city}}</td>
 					<td>{{$v.title}}</td>
 					<td>{{$v.title}}</td>
@@ -136,6 +141,7 @@
           <td name="money">{{$v.budget}}</td>
           <td name="money">{{$v.budget}}</td>
           <td name="money">{{$v.bidamount}}</td>
           <td name="money">{{$v.bidamount}}</td>
           <td>{{$v.bidopentime}}</td>
           <td>{{$v.bidopentime}}</td>
+          <td>{{$v.bidendtime}}</td>
           <td>{{$v.buyer}}</td>
           <td>{{$v.buyer}}</td>
 				<td name="name">{{$v.buyerperson}}</td>
 				<td name="name">{{$v.buyerperson}}</td>
 				<td name="phone">{{$v.buyertel}}</td>
 				<td name="phone">{{$v.buyertel}}</td>