Commit 76f0856b by huangchengyi

1.0

parent a362780b
......@@ -2,10 +2,10 @@ package main
import (
"flag"
"fmt"
"os"
"search_server/boot"
"search_server/pkg/es"
"strings"
"search_server/service"
)
func main() {
......@@ -32,18 +32,27 @@ func main() {
//fmt.Println(err)
//fmt.Println(attrName)
//os.Exit(1)
//dd := service.OutLink("LM358","-1")
lines := []string{
`{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`,
`{"name":"john doe","age":25 }`,
`{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`,
`{"name":"mary smith","age":32 }`,
ss := "LM358"
mouserRes := service.OutLink(&ss,"-1")
for k, mouseItem := range mouserRes {
fmt.Println(k)
fmt.Println(mouseItem.PriceTemp)
os.Exit(1)
}
param := strings.Join(lines, "\n")+"\n"
//fmt.Errorf()
result,err := es.BulkES(param)
println(result,err)
//lines := []string{
// `{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`,
// `{"name":"john doe","age":25 }`,
// `{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`,
// `{"name":"mary smith","age":32 }`,
//}
//param := strings.Join(lines, "\n")+"\n"
//
//result,err := es.BulkES(param)
//println(result,err)
//var skuEsUpdataList []string
//
......
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
url = amqp:;guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST=bom_sku_list
;联营数据推送入队列-》go后台任务消费(斌哥脚本)
search_sku_list=search_sku_list
SEARCH_SKU_UPDATE_LIST=search_sku_update_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST=ziying_bom_items_list
; bom更新数据队列
ZIYING_MQ_BOM_SKU_LIST=ziying_bom_sku_list
\ No newline at end of file
......@@ -13,6 +13,7 @@ import (
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
"search_server/pkg/mq"
"search_server/pkg/mysql"
"strconv"
"strings"
......@@ -287,8 +288,14 @@ func (t * CommonLyService) updateSkuDB(skuInfo *model.LyClearGoodsList) {
"goods_name":skuInfo.GoodsName,
"goods_sn":skuInfo.GoodsSn,
}
paramjson,_ := json.Marshal(param)
if t.flag == "101" {
t.flagStr = "<br/><br/>";
t.flagStr = "推送到go更新db:";
t.flagStr = string(paramjson);
t.flagStr = "<br/><br/>";
}
mq.PushMsg(config.Get("rabmq_all.SEARCH_SKU_UPDATE_LIST").String(),string(paramjson))
}
/*
......
......@@ -4,6 +4,8 @@ import (
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/model"
"strconv"
"strings"
"time"
)
//mouser外链网址
......@@ -25,8 +27,7 @@ func OutLink(goodsName *string,flag string) map[string]*model.LyClearGoodsList {
result = resp.String(); //请求外链拿到结果
}
var productList map[string]*model.LyClearGoodsList //格式化数据后返回的所有数据
productList = make(map[string]*model.LyClearGoodsList,0)
productList := make(map[string]*model.LyClearGoodsList,0)
apiGoodsList := gjson.Get(result, "SearchResults.Parts").Array()
for _, goods := range apiGoodsList {
......@@ -40,22 +41,30 @@ func OutLink(goodsName *string,flag string) map[string]*model.LyClearGoodsList {
var apiLowerPrice float64 = 0; //计算最低价格
for _,priceItem := range apiPriceTi{
priceItemStr := priceItem.String();
onePrice := gjson.Get(priceItemStr, "Price").Float()
//价格转换
onePrice := gjson.Get(priceItemStr, "Price").String()
onePrice = strings.ReplaceAll(strings.Trim(onePrice,"$"),",","")
skuPrice,_ := strconv.ParseFloat(onePrice,64) //转成float64
//数量转换
quantity := gjson.Get(priceItemStr, "Quantity").Uint()
if apiLowerPrice == 0 {
apiLowerPrice = onePrice
}else if apiLowerPrice > onePrice {
apiLowerPrice = onePrice
apiLowerPrice = skuPrice
}else if apiLowerPrice > skuPrice {
apiLowerPrice = skuPrice
}
ladder := model.TierItem{
Purchases: gjson.Get(priceItemStr, "Quantity").Uint(),
PriceUs: onePrice,
Purchases: quantity,
PriceUs: skuPrice,
PriceCn: 0,
}
ladderPrice = append(ladderPrice, &ladder)
//梯度缓存数据
priceTemp = append(priceTemp,gjson.Get(priceItemStr, "Quantity").Uint())
priceTemp = append(priceTemp,gjson.Get(priceItemStr, "Price").Float())
priceTemp = append(priceTemp,[]interface{}{
quantity,
skuPrice,
})
}
//拼接联营数据
......
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