Commit 9663227e by mushishixian
parents 4ce1049d b937bb0f
......@@ -4,8 +4,6 @@ import (
"flag"
"os"
"search_server/boot"
"search_server/pkg/es"
"strings"
)
func main() {
......@@ -34,16 +32,16 @@ func main() {
//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 }`,
}
param := strings.Join(lines, "\n")+"\n"
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)
os.Exit(1)
}
......
......@@ -2,6 +2,7 @@ package model
//联营请求外链后格式化数据
type LyClearGoodsList struct {
GoodsId string `json:"goods_name"` //型号id
GoodsName string `json:"goods_name"` //型号名称
BrandName string `json:"brand_name"` //品牌名称
Desc string `json:"desc"` //描述
......@@ -10,6 +11,7 @@ type LyClearGoodsList struct {
Url string `json:"url"` //sku对应供应商的商品详情
GoodsImg string `json:"goods_img"` //sku图片
Cat string `json:"cat"` //分类
Encoded string `json:"encoded"` //内部编码
RestrictionMessage string `json:"RestrictionMessage"` //额外购买限制内容,如 ‘当前商品不在本地区销售’
Increment int64 `json:"increment"` //最小包装量、倍数 =Mpq
SinglePrice float64 `json:"single_price"` //最小单价
......
......@@ -21,9 +21,7 @@ type CommonLyService struct {
supplier_over_time map[string]int64
supplierId int64 //调用当前方法的供应商ID
supplierName string //调用当前方法的供应商名称
skuEsUpdataList []map[string]interface{} //组装批量更新es数据
spuId string //spuId
skuId string //skuId
skuEsUpdataList []string //组装批量更新es数据
}
//初始化类
......@@ -207,7 +205,57 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
/*
组装推送到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