Kaynağa Gözat

fix:采购单位支持id查询

wangkaiyue 2 yıl önce
ebeveyn
işleme
717b57cd46

+ 28 - 24
src/jfw/front/classificationTag.go

@@ -1,28 +1,28 @@
 package front
 
 import (
-    qu "app.yhyue.com/moapp/jybase/common"
-    "app.yhyue.com/moapp/jybase/encrypt"
-    elastic "app.yhyue.com/moapp/jybase/es"
-    "app.yhyue.com/moapp/jybase/redis"
-    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
-    "app.yhyue.com/moapp/jypkg/public"
-    "encoding/json"
-    "fmt"
-    "jy/src/jfw/config"
-    "jy/src/jfw/jyutil"
-    "jy/src/jfw/paging"
-    "log"
-    "math"
-    "math/rand"
-    "strconv"
-    "sync"
-    "time"
+	qu "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
+	"app.yhyue.com/moapp/jypkg/public"
+	"encoding/json"
+	"fmt"
+	"jy/src/jfw/config"
+	"jy/src/jfw/jyutil"
+	"jy/src/jfw/paging"
+	"log"
+	"math"
+	"math/rand"
+	"strconv"
+	"sync"
+	"time"
 
-    "net/http"
+	"net/http"
 
-    "app.yhyue.com/moapp/jybase/date"
-    "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 )
 
 type KeyType struct {
@@ -290,10 +290,14 @@ func HotBuyerList(entIsNew bool) []*BuyerList {
 		var buyerList []*BuyerList
 		for _, b := range *data {
 			name := qu.ObjToString(b["name"])
-			buyerList = append(buyerList, &BuyerList{
-				Name: name,
-				Url:  qu.If(entIsNew, fmt.Sprintf("/entpc/unit_portrayal/%s", name), fmt.Sprintf("/swordfish/page_big_pc/unit_portrayal/%s", name)).(string),
-			})
+			buyerId := qu.ObjToString(b["id"])
+			if name != "" && buyerId != "" {
+				idEncode := encrypt.EncodeArticleId2ByCheck(buyerId)
+				buyerList = append(buyerList, &BuyerList{
+					Name: name,
+					Url:  qu.If(entIsNew, fmt.Sprintf("/entpc/unit_portrayal_id/%s", idEncode), fmt.Sprintf("/swordfish/page_big_pc/unit_portrayal_id/%s", idEncode)).(string),
+				})
+			}
 		}
 		return buyerList
 	}

+ 16 - 1
src/jfw/modules/bigmember/src/service/portrait/subvipPortraitAction.go

@@ -448,9 +448,15 @@ func (this *SubVipPortrait) BuyerPortrait() {
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	rData, errMsg := func() (interface{}, error) {
 		buyerName := this.GetString("buyer")
+		//id转中文
+		if len(buyerName) > 0 && len([]rune(buyerName)) == len(buyerName) {
+			//获取中文名字
+			buyerName = getBuyerNameById(util.DecodeId(buyerName))
+		}
 		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 {
@@ -507,7 +513,7 @@ func getEntListMsg(ids []string) (dMap map[string]map[string]interface{}) {
 // 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":[{"terms":{"buyer_name":["%s"]}}]}},"size":%d,"_source":["buyer_name","city","province","buyerclass"]}`, strings.Join(buyerNames, `","`), len(buyerNames)))
+	rData := elastic.Get("buyer", "buyer", fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"_id":"%s"}}]}},"size":1,"_source":["name"]}`, strings.Join(buyerNames, `","`)))
 	if rData == nil || len(*rData) == 0 {
 		return
 	}
@@ -529,3 +535,12 @@ func getBuyerListMsg(buyerNames []string) (dMap map[string]map[string]interface{
 	}
 	return
 }
+
+func getBuyerNameById(buyerId string) (buyerName string) {
+	r := elastic.Get("buyer", "buyer", fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"_id":["%s"]}}]}},"size":1,"_source":["name"]}`, buyerId))
+	if r == nil || len(*r) == 0 {
+		return
+	}
+	buyerName, _ = (*r)[0]["name"].(string)
+	return
+}