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

Merge branch 'dev/v4.8.59_dx' of qmx/jy into feature/v4.8.59

duxin 1 рік тому
батько
коміт
ea850a13a5

+ 17 - 2
src/jfw/modules/bigmember/src/service/portrait/subvipPortraitAction.go

@@ -12,6 +12,7 @@ import (
 	"log"
 	"strings"
 	"time"
+	"unicode"
 
 	. "app.yhyue.com/moapp/jybase/api"
 	qutil "app.yhyue.com/moapp/jybase/common"
@@ -470,7 +471,6 @@ func (this *SubVipPortrait) BuyerPortrait() {
 		if buyerName == "" {
 			return nil, fmt.Errorf("参数异常")
 		}
-
 		cepm, power, err, isFree := entity.CreateSubVipPortraitManagerForOpen(userId, "buyerPortrait", buyerName, false, this.Session())
 		cepm.Session = this.Session()
 		if err != nil {
@@ -547,10 +547,25 @@ func getEntListMsg(ids []string) (dMap map[string]map[string]interface{}) {
 	return
 }
 
+func containsChineseByUnicode(s string) bool {
+	for _, r := range s {
+		if unicode.Is(unicode.Scripts["Han"], r) {
+			return true
+		}
+	}
+	return false
+}
+
 // getBuyerListMsg 获取采购单位基本信息
 func getBuyerListMsg(buyerNames []string) (dMap map[string]map[string]interface{}) {
 	dMap = make(map[string]map[string]interface{})
-	rData := elastic.Get("buyer", "buyer", fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"_id":"%s"}}]}},"size":1,"_source":["name"]}`, strings.Join(buyerNames, `","`)))
+	var buyerSql string
+	if len(buyerNames) > 0 && containsChineseByUnicode(buyerNames[0]) {
+		buyerSql = fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer_name":["%s"]}}]}},"size":%d,"_source":["buyer_name","name","city","province","buyerclass"]}`, strings.Join(buyerNames, `","`), len(buyerNames))
+	} else {
+		buyerSql = fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"_id":"%s"}}]}},"size":1,"_source":["name"]}`, strings.Join(buyerNames, `","`))
+	}
+	rData := elastic.Get("buyer", "buyer", buyerSql)
 	if rData == nil || len(*rData) == 0 {
 		return
 	}