Commit 9663227e by mushishixian
parents 4ce1049d b937bb0f
...@@ -4,8 +4,6 @@ import ( ...@@ -4,8 +4,6 @@ import (
"flag" "flag"
"os" "os"
"search_server/boot" "search_server/boot"
"search_server/pkg/es"
"strings"
) )
func main() { func main() {
...@@ -34,16 +32,16 @@ func main() { ...@@ -34,16 +32,16 @@ func main() {
//os.Exit(1) //os.Exit(1)
//dd := service.OutLink("LM358","-1") //dd := service.OutLink("LM358","-1")
lines := []string{ //lines := []string{
`{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`, // `{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`,
`{"name":"john doe","age":25 }`, // `{"name":"john doe","age":25 }`,
`{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`, // `{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`,
`{"name":"mary smith","age":32 }`, // `{"name":"mary smith","age":32 }`,
} //}
param := strings.Join(lines, "\n")+"\n" //param := strings.Join(lines, "\n")+"\n"
//
result,err := es.BulkES(param) //result,err := es.BulkES(param)
println(result,err) //println(result,err)
os.Exit(1) os.Exit(1)
} }
......
...@@ -2,6 +2,7 @@ package model ...@@ -2,6 +2,7 @@ package model
//联营请求外链后格式化数据 //联营请求外链后格式化数据
type LyClearGoodsList struct { type LyClearGoodsList struct {
GoodsId string `json:"goods_name"` //型号id
GoodsName string `json:"goods_name"` //型号名称 GoodsName string `json:"goods_name"` //型号名称
BrandName string `json:"brand_name"` //品牌名称 BrandName string `json:"brand_name"` //品牌名称
Desc string `json:"desc"` //描述 Desc string `json:"desc"` //描述
...@@ -10,8 +11,9 @@ type LyClearGoodsList struct { ...@@ -10,8 +11,9 @@ type LyClearGoodsList struct {
Url string `json:"url"` //sku对应供应商的商品详情 Url string `json:"url"` //sku对应供应商的商品详情
GoodsImg string `json:"goods_img"` //sku图片 GoodsImg string `json:"goods_img"` //sku图片
Cat string `json:"cat"` //分类 Cat string `json:"cat"` //分类
Encoded string `json:"encoded"` //内部编码
RestrictionMessage string `json:"RestrictionMessage"` //额外购买限制内容,如 ‘当前商品不在本地区销售’ RestrictionMessage string `json:"RestrictionMessage"` //额外购买限制内容,如 ‘当前商品不在本地区销售’
Increment int64 `json:"increment"` //最小包装量、倍数 =Mpq Increment int64 `json:"increment"` //最小包装量、倍数 =Mpq
SinglePrice float64 `json:"single_price"` //最小单价 SinglePrice float64 `json:"single_price"` //最小单价
Stock int64 `json:"increment"` //库存 Stock int64 `json:"increment"` //库存
Moq int64 `json:"moq"` //最小起订量、起订量 Moq int64 `json:"moq"` //最小起订量、起订量
...@@ -51,7 +53,7 @@ Array ...@@ -51,7 +53,7 @@ Array
) )
*/ */
type SUPPLIER_REDIS_INFO_ struct { type SUPPLIER_REDIS_INFO_ struct {
SupplierId int64 `json:"supplier_id"` //供应商id SupplierId int64 `json:"supplier_id"` //供应商id
SupplierNickname string `json:"supplier_nickname"` //供应商名称 SupplierNickname string `json:"supplier_nickname"` //供应商名称
AdText string `json:"ad_text"` //供应商描述 AdText string `json:"ad_text"` //供应商描述
CnDelivery string `json:"cn_delivery"` //国内交货时间 CnDelivery string `json:"cn_delivery"` //国内交货时间
...@@ -117,22 +119,22 @@ Array ...@@ -117,22 +119,22 @@ Array
) )
*/ */
type LySkuInfo struct { type LySkuInfo struct {
SpuId string `json:"spu_id"` //spu_id SpuId string `json:"spu_id"` //spu_id
Encoded string `json:"encoded"` Encoded string `json:"encoded"`
Moq int64 `json:"moq"` Moq int64 `json:"moq"`
Mpq int64 `json:"mpq"` Mpq int64 `json:"mpq"`
OldGoodsId int64 `json:"old_goods_id"` OldGoodsId int64 `json:"old_goods_id"`
GoodsType int `json:"goods_type"` GoodsType int `json:"goods_type"`
GoodsStatus int `json:"goods_status"` GoodsStatus int `json:"goods_status"`
BatchSn string `json:"batch_sn"` BatchSn string `json:"batch_sn"`
Stock int64 `json:"stock"` Stock int64 `json:"stock"`
UpdateTime int64 `json:"update_time"` UpdateTime int64 `json:"update_time"`
GoodsImages string `json:"goods_images"` GoodsImages string `json:"goods_images"`
Canal string `json:"canal"` Canal string `json:"canal"`
SupplierId int64 `json:"supplier_id"` SupplierId int64 `json:"supplier_id"`
IsExpire string `json:"is_expire"` IsExpire string `json:"is_expire"`
HkDeliveryTime string `json:"hk_delivery_time"` HkDeliveryTime string `json:"hk_delivery_time"`
CnDeliveryTime string `json:"cn_delivery_time"` CnDeliveryTime string `json:"cn_delivery_time"`
LadderPrice []*TierItem `json:"ladder_price"` LadderPrice []*TierItem `json:"ladder_price"`
} }
......
...@@ -21,9 +21,7 @@ type CommonLyService struct { ...@@ -21,9 +21,7 @@ type CommonLyService struct {
supplier_over_time map[string]int64 supplier_over_time map[string]int64
supplierId int64 //调用当前方法的供应商ID supplierId int64 //调用当前方法的供应商ID
supplierName string //调用当前方法的供应商名称 supplierName string //调用当前方法的供应商名称
skuEsUpdataList []map[string]interface{} //组装批量更新es数据 skuEsUpdataList []string //组装批量更新es数据
spuId string //spuId
skuId string //skuId
} }
//初始化类 //初始化类
...@@ -207,7 +205,57 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64 ...@@ -207,7 +205,57 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
/* /*
组装推送到es数据 组装推送到es数据
*/ */
func esSkuInfo(skuInfo *model.LyClearGoodsList,brandId *string) { func (t * CommonLyService) EsSkuInfo(skuInfo *model.LyClearGoodsList,spuId * string,brandId *string) {
sort := 1; //排序
if skuInfo.SinglePrice >0 && skuInfo.Stock >0 && skuInfo.Stock >= skuInfo.Increment && skuInfo.Stock >= skuInfo.Moq {
sort = 31;
}else if skuInfo.SinglePrice >0 && skuInfo.Stock >0 {
sort = 30;
}else if skuInfo.SinglePrice > 0 {
sort = 28;
}else if skuInfo.Stock >0 {
sort = 29;
}
stock_sort := 1;
if skuInfo.Stock > 0 {
stock_sort = 3;
}
single_price_sort := 1;
if skuInfo.SinglePrice > 0 {
single_price_sort = 3;
}
nowTime := php2go.Time()
param := map[string]interface{}{
"goods_id":skuInfo.GoodsId,
"goods_name":skuInfo.GoodsName,
"auto_goods_name":php2go.Strtoupper(skuInfo.GoodsName),
"brand_id":*brandId,
"brand_name":skuInfo.BrandName,
"supplier_name":t.supplierName,
"class_id1":0,
"class_id2":0,
"class_id3":0,
"spu_id":*spuId,
"sale_time":nowTime,
"create_time":nowTime,
"update_time":nowTime,
"single_price":skuInfo.SinglePrice,
"stock":skuInfo.Stock,
"goods_status":1,
"status":1,
"sort":sort,
"encoded": "",
"encap":"",
"canal_new":"",
"stock_sort":stock_sort, //主要为库存为0的往后排服务
"single_price_sort":single_price_sort, //主要为单价为0的往后排服务
}
paramjson,_ := json.Marshal(param)
_ = append(t.skuEsUpdataList,`{"index":{"_index":"`+t.supplierName+`","_type":"goods","_id":"`+skuInfo.GoodsId+`"}}`)
_ = append(t.skuEsUpdataList,string(paramjson))
} }
......
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