Эх сурвалжийг харах

Merge branch 'master' into feature/v1.0.2

lianbingjie 1 жил өмнө
parent
commit
1b26be8c96

+ 81 - 46
common/src/qfw/util/dataexport/dataexport.go

@@ -117,6 +117,8 @@ func getDataExportSql(scd *SieveCondition) string {
 	query_bool_should_and := `{"bool":{"should":[%s],"minimum_should_match": 1 %s}}`
 	query_price := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
 	query_bool_must := `{"terms":{"%s":[%s]}}`
+	query_bool_should_wildcard := `{"bool":{"should":[%s]}}`
+	query_wildcard := `{"wildcard":{"%s":"*%s*"}}`
 	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
 	query_exists := `{"constant_score":{"filter":{"exists":{"field":"%s"}}}}`
 	query_bool_must_term := `{"bool": {"must": [{ "term": {"isValidFile": %t }}]}}`
@@ -225,13 +227,29 @@ func getDataExportSql(scd *SieveCondition) string {
 		musts = append(musts, fmt.Sprintf(query_bool_must, "s_subscopeclass", `"`+strings.Join(scd.Industry, `","`)+`"`))
 	}
 	if len(scd.Buyer) > 0 {
-		musts = append(musts, fmt.Sprintf(query_bool_must, "buyer", `"`+strings.Join(scd.Buyer, `","`)+`"`))
+		str := ""
+		for i, v := range scd.Buyer {
+			if i < len(scd.Buyer)-1 {
+				str += fmt.Sprintf(query_wildcard, "buyer", v) + ","
+			} else {
+				str += fmt.Sprintf(query_wildcard, "buyer", v)
+			}
+		}
+		musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
 	}
 	if len(scd.Buyerclass) > 0 {
 		musts = append(musts, fmt.Sprintf(query_bool_must, "buyerclass", `"`+strings.Join(scd.Buyerclass, `","`)+`"`))
 	}
 	if len(scd.Winner) > 0 {
-		musts = append(musts, fmt.Sprintf(query_bool_must, "s_winner", `"`+strings.Join(scd.Winner, `","`)+`"`))
+		str := ""
+		for i, v := range scd.Winner {
+			if i < len(scd.Winner)-1 {
+				str += fmt.Sprintf(query_wildcard, "s_winner", v) + ","
+			} else {
+				str += fmt.Sprintf(query_wildcard, "s_winner", v)
+			}
+		}
+		musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
 	}
 	_minPrice := ""
 	_maxPrice := ""
@@ -647,7 +665,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, "filetext": 1, "purchasing": 1,
 	//}
 	if dataType == "2" {
-		bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr"`
+		bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr","buyerclass","s_topscopeclass","entidlist"`
 		//for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext"} {
 		//	selectMap[key] = 1
 		//}
@@ -947,58 +965,75 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
 	if len(encry) > 0 {
 		isEncry = true
 	}
-	for _, v := range *data {
+	var entCacheMap = map[string]map[string]interface{}{}
+	for index := 0; index < len(*data); index++ {
+		v := (*data)[index]
 		//有中标企业 且 高级字段查询
 		if dataType == "2" {
 			//查询企业公示 法人 公司电话 公司邮箱地址
-			s_winner, ok := v["s_winner"].(string) //改为entidlistxx?
-			if ok && s_winner != "" {
-				if entData, ok := entmg.Find("winner_enterprise", map[string]interface{}{"company_name": s_winner}, nil, `{"company_name":1,"company_email":1,"legal_person":1,"company_phone":1}`, false, -1, -1); ok {
-					if entData != nil && *entData != nil && len(*entData) > 0 {
-						for _, ev := range *entData {
-							if v["s_winner"] == ev["company_name"] {
-								legal_person := ""
-								if ev["legal_person"] != nil {
-									legal_person = ev["legal_person"].(string)
-									if isEncry {
-										var xx = "*"
-										switch len([]rune(legal_person)) {
-										case 3:
-											xx = "**"
-										case 4:
-											xx = "***"
-										}
-										legal_person = string([]rune(legal_person)[:1]) + xx
-									}
+			entidlist, ok := v["entidlist"].([]interface{})
+			if ok && len(entidlist) > 0 {
+				var winnerMaps []map[string]interface{}
+				for _, entIdObj := range entidlist {
+					entId := qutil.ObjToString(entIdObj)
+					if entId == "" {
+						continue
+					}
+					if entCacheMap[entId] != nil {
+						winnerMaps = append(winnerMaps, entCacheMap[entId])
+					} else if entDetail := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"id":"%s"}}]}},"size":1,"_source":["company_name","company_email","company_phone","legal_person"]}`, entId)); entDetail != nil && len(*entDetail) > 0 {
+						thisEntMap := map[string]interface{}{}
+						legal_person := ""
+						if (*entDetail)[0]["legal_person"] != nil {
+							legal_person = (*entDetail)[0]["legal_person"].(string)
+							if isEncry {
+								var xx = "*"
+								switch len([]rune(legal_person)) {
+								case 3:
+									xx = "**"
+								case 4:
+									xx = "***"
 								}
-								company_phone := ""
-								if ev["company_phone"] != nil {
-									company_phone = ev["company_phone"].(string)
-									if isEncry {
-										if len([]rune(company_phone)) > 7 {
-											company_phone = company_phone[:7] + "****"
-										} else {
-											company_phone = "****"
-										}
-									}
+								legal_person = string([]rune(legal_person)[:1]) + xx
+							}
+						}
+						company_phone := ""
+						if (*entDetail)[0]["company_phone"] != nil {
+							company_phone = (*entDetail)[0]["company_phone"].(string)
+							if isEncry {
+								if len([]rune(company_phone)) > 7 {
+									company_phone = company_phone[:7] + "****"
+								} else {
+									company_phone = "****"
 								}
-								company_email := ""
-								if ev["company_email"] != nil && ev["company_email"] != "无" {
-									company_email = ev["company_email"].(string)
-									if isEncry {
-										if len(strings.Split(company_email, "@")) > 1 {
-											company_email = "******" + "@" + strings.Split(company_email, "@")[1]
-										}
-									}
+							}
+						}
+						company_email := ""
+						if (*entDetail)[0]["company_email"] != nil && (*entDetail)[0]["company_email"] != "无" {
+							company_email = (*entDetail)[0]["company_email"].(string)
+							if isEncry {
+								if len(strings.Split(company_email, "@")) > 1 {
+									company_email = "******" + "@" + strings.Split(company_email, "@")[1]
 								}
-								v["legal_person"] = legal_person
-								v["company_phone"] = company_phone
-								v["company_email"] = company_email
 							}
 						}
+						company_name := ""
+						if (*entDetail)[0]["company_name"] != nil {
+							company_name = (*entDetail)[0]["company_name"].(string)
+						}
+						thisEntMap["legal_person"] = legal_person
+						thisEntMap["company_phone"] = company_phone
+						thisEntMap["company_email"] = company_email
+						thisEntMap["company_name"] = company_name
+						entCacheMap[entId] = thisEntMap
+						winnerMaps = append(winnerMaps, thisEntMap)
 					}
 				}
+				if len(winnerMaps) > 0 {
+					v["winnerMaps"] = winnerMaps
+				}
 			}
+			delete(v, "entidlist")
 		}
 		//====================字段补漏=========================
 		if v["toptype"] == "结果" && dataType == "2" && !(v["agency"] != nil && v["budget"] != nil && v["buyerperson"] != nil && v["buyertel"] != nil) {
@@ -1052,7 +1087,7 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
 			date := v["bidendtime"]
 			v["bidendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
 		}
-		if v["_id"] != nil {
+		if v["_id"] != nil && !isEncry {
 			encodeId := CommonEncodeArticle("content", v["_id"].(string))
 			v["url"] = webdomain + "/article/content/" + encodeId + ".html"
 			v["url_jump"] = webdomain + "/front/reloadTo/article/content/" + encodeId + ".html"
@@ -1114,7 +1149,7 @@ func doSearch(sql string, start, count int, dataType string) *[]map[string]inter
 		if dataType != "" {
 			dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype","filetext","purchasing"`
 			if dataType == "2" {
-				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime","district","signendtime","buyeraddr"`
+				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime","district","signendtime","buyeraddr","buyerclass","s_topscopeclass","entidlist"`
 			}
 			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
 		}

+ 52 - 0
common/src/qfw/util/jy/channel.go

@@ -0,0 +1,52 @@
+package jy
+
+import (
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	"app.yhyue.com/moapp/jybase/mysql"
+	"net/http"
+	"time"
+)
+
+var (
+	ChannelCookieName = "channelCode"
+	ChannelTableName  = "thirdparty.user_source"
+)
+
+// SetCookieValue 更新cookie信息
+func SetCookieValue(rw http.ResponseWriter, name, val string, timeOut int) {
+	http.SetCookie(rw, func() *http.Cookie {
+		maxAge := timeOut //单位秒
+		expires := time.Now().Add(time.Duration(timeOut) * time.Second)
+		cookie := &http.Cookie{
+			Name:     name,
+			Value:    val,
+			Path:     "/",
+			HttpOnly: false,
+			MaxAge:   maxAge,
+			Expires:  expires,
+			Domain:   httpsession.Domain,
+		}
+		return cookie
+	}())
+}
+
+type UserSource struct {
+	UserId           string `json:"user_id"`            //用户id
+	PositionId       int64  `json:"position_id"`        //职位id
+	Phone            string `json:"phone"`              //手机号
+	State            int    `json:"state"`              //注册/登录标志 1:登录;2:注册
+	ChannelCode      string `json:"channel_code"`       //渠道代码
+	EncryptionUserId string `json:"encryption_user_id"` //用户加密id
+	CreateTime       string `json:"create_time"`        //创建时间
+	LoginWay         int    `json:"login_way"`          //登录方式;1:手机号密码登录;2:手机号验证码登录;3:微信登录;4:手机号一键登录
+	Platform         int    `json:"platform"`           //登录端;1:PC;2:WX;3:APP;4:H5
+	Ip               string `json:"ip"`                 //登录ip
+}
+
+// SaveUserSource 保存 user_source 表 > 剑鱼用户注册/登录
+func SaveUserSource(tidb *mysql.Mysql, tableName string, insertMap map[string]interface{}) bool {
+	if insertMap != nil && len(insertMap) > 0 {
+		return tidb.Insert(tableName, insertMap) > 0
+	}
+	return false
+}

+ 1 - 1
go.mod

@@ -16,7 +16,7 @@ require (
 	github.com/thinxer/go-word2vec v0.0.0-20150917053916-5c19ec7379ed
 	github.com/zeromicro/go-zero v1.5.3
 	go.mongodb.org/mongo-driver v1.11.6
-	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1
+	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a
 )
 
 require (

+ 2 - 1
middleground/publicservice.go

@@ -44,7 +44,7 @@ func (u *publicService) NewClient() zrpc.Client {
 	return client
 }
 
-//列表数据处理
+// 列表数据处理
 func (p *publicService) List(searchValue, dataType string, pageNum, pageSize int64) map[string]interface{} {
 	client := p.NewClient()
 	if client == nil {
@@ -101,5 +101,6 @@ func (p *publicService) Detail(id string) map[string]interface{} {
 	result["introduce"] = resp.Introduce
 	result["format"] = resp.Format
 	result["keyword"] = resp.Keyword
+	result["application"] = resp.FieldIllustrate.Application
 	return result
 }