Commit 4f331a22 by mushishixian

锁定结果排序

parent 057d86dd
Showing with 41 additions and 34 deletions
......@@ -15,7 +15,7 @@ urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map2
attr_index = goods_map
[database]
user_name = root
......
......@@ -5,6 +5,7 @@ import (
"github.com/tidwall/gjson"
"search_server/pkg/config"
"search_server/protopb/bom"
"strings"
)
func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) {
......@@ -19,41 +20,47 @@ func GetGoodsInfo(goodsIdsStr string) (goodsList []*bom.GoodsModel, err error) {
}
//先判断返回的data是不是字典,不是字典代表可能是返回字符串了
if gjson.Get(resp.String(), "data").IsObject() {
for _, data := range gjson.Get(resp.String(), "data").Map() {
//还要去判断是否是bool
if data.IsObject() {
var goods bom.GoodsModel
goods.GoodsName = data.Get("goods_name").String()
goods.GoodsId = data.Get("goods_id").String()
goods.BrandId = data.Get("goods_id").Int()
goods.Pdf = data.Get("pdf").String()
goods.Stock = data.Get("stock").Int()
goods.Mpq = data.Get("mpq").Int()
goods.Moq = data.Get("moq").Int()
goods.SupplierName = data.Get("supplier_name").String()
goods.BrandName = data.Get("brand_name").String()
goods.HkDeliveryType = data.Get("hk_delivery_time").String()
goods.CnDeliveryTime = data.Get("cn_delivery_time").String()
goods.IsBuy = data.Get("is_buy").Int()
goods.Mpl = data.Get("mpl").Int()
goods.Encap = data.Get("encap").String()
goods.SupplierId = data.Get("supplier_id").Int()
goods.Status = data.Get("status").Int()
goods.GoodsType = data.Get("goods_type").Int()
goods.AcType = data.Get("ac_type").Int()
var ladderPrice []*bom.LADDER_PRICE
for _, price := range data.Get("ladder_price").Array() {
var ladder bom.LADDER_PRICE
ladder = bom.LADDER_PRICE{
Purchases: price.Get("purchases").Int(),
PriceUs: float32(price.Get("price_us").Float()),
PriceCn: float32(price.Get("price_cn").Float()),
PriceAc: float32(price.Get("price_ac").Float()),
//排序操作
goodsIdList := strings.Split(goodsIdsStr, ",")
for _, goodsId := range goodsIdList {
for _, data := range gjson.Get(resp.String(), "data").Map() {
if goodsId == data.Get("goods_id").String() {
//还要去判断是否是bool
if data.IsObject() {
var goods bom.GoodsModel
goods.GoodsName = data.Get("goods_name").String()
goods.GoodsId = data.Get("goods_id").String()
goods.BrandId = data.Get("goods_id").Int()
goods.Pdf = data.Get("pdf").String()
goods.Stock = data.Get("stock").Int()
goods.Mpq = data.Get("mpq").Int()
goods.Moq = data.Get("moq").Int()
goods.SupplierName = data.Get("supplier_name").String()
goods.BrandName = data.Get("brand_name").String()
goods.HkDeliveryType = data.Get("hk_delivery_time").String()
goods.CnDeliveryTime = data.Get("cn_delivery_time").String()
goods.IsBuy = data.Get("is_buy").Int()
goods.Mpl = data.Get("mpl").Int()
goods.Encap = data.Get("encap").String()
goods.SupplierId = data.Get("supplier_id").Int()
goods.Status = data.Get("status").Int()
goods.GoodsType = data.Get("goods_type").Int()
goods.AcType = data.Get("ac_type").Int()
var ladderPrice []*bom.LADDER_PRICE
for _, price := range data.Get("ladder_price").Array() {
var ladder bom.LADDER_PRICE
ladder = bom.LADDER_PRICE{
Purchases: price.Get("purchases").Int(),
PriceUs: float32(price.Get("price_us").Float()),
PriceCn: float32(price.Get("price_cn").Float()),
PriceAc: float32(price.Get("price_ac").Float()),
}
ladderPrice = append(ladderPrice, &ladder)
}
goods.LadderPrice = ladderPrice
goodsList = append(goodsList, &goods)
}
ladderPrice = append(ladderPrice, &ladder)
}
goods.LadderPrice = ladderPrice
goodsList = append(goodsList, &goods)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment