Commit e5591958 authored by luhongguang's avatar luhongguang

update:es数据结构修改

parent 9750a7c5
...@@ -70,6 +70,9 @@ class GoodsToEsController extends Cli ...@@ -70,6 +70,9 @@ class GoodsToEsController extends Cli
//门店信息 //门店信息
$subShopList = ShopService::getRelationShop($goodsSkuId); $subShopList = ShopService::getRelationShop($goodsSkuId);
$latitude = empty($subShopList[0]["latitude"]) ? "" : $subShopList[0]["latitude"];
$longitude = empty($subShopList[0]["longitude"]) ? "" : $subShopList[0]["longitude"];
if (!empty($longitude) || !empty($latitude)) {
$data = [ $data = [
"goods_sku_id" => $goodsSkuInfo["goods_sku_id"], "goods_sku_id" => $goodsSkuInfo["goods_sku_id"],
"goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"], "goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"],
...@@ -87,11 +90,11 @@ class GoodsToEsController extends Cli ...@@ -87,11 +90,11 @@ class GoodsToEsController extends Cli
"life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"], "life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"],
"life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"], "life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"],
"shop_name" => empty($subShopList[0]["shop_name"]) ? "" : $subShopList[0]["shop_name"], "shop_name" => empty($subShopList[0]["shop_name"]) ? "" : $subShopList[0]["shop_name"],
"shop_longitude" => empty($subShopList[0]["longitude"]) ? "" : $subShopList[0]["longitude"], "shop_location" => $latitude.",".$longitude,
"shop_latitude" => empty($subShopList[0]["latitude"]) ? "" : $subShopList[0]["latitude"],
]; ];
return ElasticGoodService::indexDoc($goodsSkuId, $data); return ElasticGoodService::indexDoc($goodsSkuId, $data);
} }
} }
}
} }
\ No newline at end of file
...@@ -49,6 +49,9 @@ class ElasticGoodService ...@@ -49,6 +49,9 @@ class ElasticGoodService
'type' => 'text', 'type' => 'text',
'analyzer' => 'ik_max_word', 'analyzer' => 'ik_max_word',
], ],
'shop_location' => [
'type' => 'geo_point',
],
] ]
] ]
]; ];
......
...@@ -914,9 +914,12 @@ class GoodsService ...@@ -914,9 +914,12 @@ class GoodsService
//门店信息 //门店信息
$subShopList = ShopService::getRelationShop($goodsSkuId); $subShopList = ShopService::getRelationShop($goodsSkuId);
if (!empty($subShopList)) {
foreach ($subShopList as $subShop) {
if (!empty($subShop["latitude"]) && !empty($subShop["longitude"])) {
$data = [ $data = [
"doc" => [ "doc" => [
"id" => $goodsSkuInfo["goods_sku_id"], "goods_sku_id" => $goodsSkuInfo["goods_sku_id"],
"goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"], "goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"],
"goods_name" => $goodsSkuInfo["goods_name"], "goods_name" => $goodsSkuInfo["goods_name"],
"inventory_rest" => $goodsSkuInfo["inventory_rest"], "inventory_rest" => $goodsSkuInfo["inventory_rest"],
...@@ -932,11 +935,13 @@ class GoodsService ...@@ -932,11 +935,13 @@ class GoodsService
"life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"], "life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"],
"life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"], "life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"],
"shop_name" => empty($subShopList[0]["shop_name"]) ? "" : $subShopList[0]["shop_name"], "shop_name" => empty($subShopList[0]["shop_name"]) ? "" : $subShopList[0]["shop_name"],
"shop_longitude" => empty($subShopList[0]["longitude"]) ? "" : $subShopList[0]["longitude"], "shop_location" => $subShop["latitude"].",".$subShop["longitude"],
"shop_latitude" => empty($subShopList[0]["latitude"]) ? "" : $subShopList[0]["latitude"],
], ],
]; ];
return ElasticGoodService::updateDoc($goodsSkuId, $data); ElasticGoodService::updateDoc($goodsSkuId, $data);
}
}
}
} }
} }
...@@ -948,8 +953,15 @@ class GoodsService ...@@ -948,8 +953,15 @@ class GoodsService
private static function addGoodsInfoToEs($skuParams) private static function addGoodsInfoToEs($skuParams)
{ {
$nameList = Category::select("name", ["category_id" => [$skuParams["category_1_id"], $skuParams["category_2_id"]]]); $nameList = Category::select("name", ["category_id" => [$skuParams["category_1_id"], $skuParams["category_2_id"]]]);
//生活号信息
$url = config('interface', 'goods.public.get_life_account_by_id');
if (empty($url)) {
throw new InterfaceException(['cus' => 0]);
}
$lifeAccountRes = (new Request())->get($url, ["life_account_id" => $skuParams["life_account_id"]]);
$data = [ $data = [
"id" => $skuParams["goods_sku_id"], "goods_sku_id" => $skuParams["goods_sku_id"],
"goods_desc_pic_url" => $skuParams["desc_pic_url"], "goods_desc_pic_url" => $skuParams["desc_pic_url"],
"goods_name" => $skuParams["goods_name"], "goods_name" => $skuParams["goods_name"],
"inventory_rest" => $skuParams["inventory_rest"], "inventory_rest" => $skuParams["inventory_rest"],
...@@ -962,6 +974,8 @@ class GoodsService ...@@ -962,6 +974,8 @@ class GoodsService
"desc" => $skuParams["desc"], "desc" => $skuParams["desc"],
"category_1_name" => $nameList[0], "category_1_name" => $nameList[0],
"category_2_name" => $nameList[1], "category_2_name" => $nameList[1],
"life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"],
"life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"],
]; ];
$esRes = ElasticGoodService::indexDoc($skuParams["goods_sku_id"], $data); $esRes = ElasticGoodService::indexDoc($skuParams["goods_sku_id"], $data);
if ($esRes["result"] == "created" && $esRes["_shards"]["successful"] == 1) { if ($esRes["result"] == "created" && $esRes["_shards"]["successful"] == 1) {
......
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 to comment