Commit 7a36aafb by huangchengyi

1.0

parent 3e7012c7
......@@ -3,7 +3,9 @@ package main
import (
"flag"
"os"
"fmt"
"search_server/boot"
"search_server/pkg/gredis"
"search_server/service"
)
......@@ -24,6 +26,13 @@ func main() {
//fmt.Println(flag)
//os.Exit(1)
redisConn := gredis.Conn("search_r")
defer redisConn.Close()
attrName, err := gredis.String(redisConn.Do("GET", "hcy1"))
fmt.Println(err)
fmt.Println(attrName)
//os.Exit(1)
dd := service.OutLink("LM358","-1")
print("niin")
print(dd)
......
......@@ -32,6 +32,10 @@ func Setup() (err error) {
return nil
}
func String( a interface{},err error) (string,error) {
return redis.String(a,err)
}
func getConn(writeHost, password string) (pool *redis.Pool, err error) {
maxIdle, _ := config.Get("redis.max_idle").Int()
maxActive, _ := config.Get("redis.max_active").Int()
......
......@@ -40,7 +40,7 @@ var brand_name_all string = config.Get("redis_all.BRAND_NAME_ALL").String() /
func getSkuByGoodsSn(goods_list map[string]*model.LyClearGoodsList,supplier_info *model.SUPPLIER_REDIS_INFO_) map[string]interface{}{
originGoods := make(map[string]interface{},0)
searredis := gredis.Conn("search_read")
searredis := gredis.Conn("search_r")
defer searredis.Close()
for goods_sn, info := range goods_list {
......@@ -49,7 +49,7 @@ func getSkuByGoodsSn(goods_list map[string]*model.LyClearGoodsList,supplier_info
searredis.Do("set","hcttest","dddd")
sku_id,_ := gredis.get(sku_uique_judge,sn_sku) //查询唯一值,反查sku_id
sku_id,_ := redis.String(redisConn.Do("GET", "hcy1"))(sku_uique_judge,sn_sku) //查询唯一值,反查sku_id
var sku_flag bool = false; //是否新增或者更新db+redis,true则新增
if sku_id == "" { //为空,先创建sku
......
......@@ -38,12 +38,11 @@ func OutLink(goodsName string,flag string) map[string]*model.LyClearGoodsList {
apiGoodsList := gjson.Get(result, "SearchResults.Parts").Array()
for _, goods := range apiGoodsList {
goodsStr := goods.String()
goodsSn := gjson.Get(goodsStr, "MouserPartNumber").String() //供应商唯一编码
goodsSn := goods.Get("MouserPartNumber").String()
ladderPrice := make([]*model.TierItem, 0)
//拼接价格梯度
apiPriceTi := gjson.Get(goodsStr, "PriceBreaks").Array()
apiPriceTi := goods.Get("PriceBreaks").Array()
var apiLowerPrice float64 = 0; //计算最低价格
for _,priceItem := range apiPriceTi{
priceItemStr := priceItem.String();
......@@ -63,16 +62,16 @@ func OutLink(goodsName string,flag string) map[string]*model.LyClearGoodsList {
//拼接联营数据
LyClearGoodsList := model.LyClearGoodsList{
GoodsName: gjson.Get(goodsStr, "ManufacturerPartNumber").String(),
BrandName: gjson.Get(goodsStr, "Manufacturer").String(),
Desc: gjson.Get(goodsStr, "Description").String(),
GoodsName: goods.Get("ManufacturerPartNumber").String(),
BrandName: goods.Get("Manufacturer").String(),
Desc: goods.Get("Description").String(),
GoodsSn: goodsSn,
Docurl: gjson.Get(goodsStr, "DataSheetUrl").String(),
Url: gjson.Get(goodsStr, "ProductDetailUrl").String(),
GoodsImg: gjson.Get(goodsStr, "ImagePath").String(),
Cat: gjson.Get(goodsStr, "Category").String(),
Increment: gjson.Get(goodsStr, "Mult").Uint(),
RestrictionMessage: gjson.Get(goodsStr, "RestrictionMessage").String(),
Docurl: goods.Get("DataSheetUrl").String(),
Url: goods.Get("ProductDetailUrl").String(),
GoodsImg: goods.Get("ImagePath").String(),
Cat: goods.Get("Category").String(),
Increment: goods.Get("Mult").Uint(),
RestrictionMessage: goods.Get("RestrictionMessage").String(),
SinglePrice: apiLowerPrice,
Tiered:ladderPrice,
}
......
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