Commit 1d702964 authored by luhongguang's avatar luhongguang

update:es 调整

parent f1ca2c0e
...@@ -62,7 +62,7 @@ class GoodsToEsController extends Cli ...@@ -62,7 +62,7 @@ class GoodsToEsController extends Cli
$goodsSkuInfo = $goodsSkuInfoList[0]; $goodsSkuInfo = $goodsSkuInfoList[0];
$nameList = Category::select("name", ["category_id" => [$goodsSkuInfo["category_1_id"], $goodsSkuInfo["category_2_id"]]]); $nameList = Category::select("name", ["category_id" => [$goodsSkuInfo["category_1_id"], $goodsSkuInfo["category_2_id"]]]);
//生活号信息 //生活号信息
$url = config('interface', 'goods.public.get_life_account_by_id'); $url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) { if (empty($url)) {
throw new InterfaceException(['cus' => 0]); throw new InterfaceException(['cus' => 0]);
} }
...@@ -72,30 +72,34 @@ class GoodsToEsController extends Cli ...@@ -72,30 +72,34 @@ class GoodsToEsController extends Cli
$latitude = empty($subShopList[0]["latitude"]) ? "" : $subShopList[0]["latitude"]; $latitude = empty($subShopList[0]["latitude"]) ? "" : $subShopList[0]["latitude"];
$longitude = empty($subShopList[0]["longitude"]) ? "" : $subShopList[0]["longitude"]; $longitude = empty($subShopList[0]["longitude"]) ? "" : $subShopList[0]["longitude"];
if (!empty($longitude) || !empty($latitude)) { if (!empty($longitude) && !empty($latitude) && !empty($subShopList)) {
$data = [ foreach ($subShopList as $subShop) {
"goods_sku_id" => $goodsSkuInfo["goods_sku_id"], $esId = $goodsSkuId."_".$subShop["sub_shop_id"];
"goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"], $data = [
"goods_name" => $goodsSkuInfo["goods_name"], "goods_sku_id" => $goodsSkuInfo["goods_sku_id"],
"inventory_rest" => $goodsSkuInfo["inventory_rest"], "goods_desc_pic_url" => $goodsSkuInfo["desc_pic_url"],
"total_amount_sold" => $goodsSkuInfo["total_amount_sold"], "goods_name" => $goodsSkuInfo["goods_name"],
"original_price" => $goodsSkuInfo["original_price"] / 100, "inventory_rest" => $goodsSkuInfo["inventory_rest"],
"price" => $goodsSkuInfo["price"] / 100, "total_amount_sold" => $goodsSkuInfo["total_amount_sold"],
"price_sort" => (int)$goodsSkuInfo["price"], "original_price" => $goodsSkuInfo["original_price"] / 100,
"audit_status" => $goodsSkuInfo["audit_status"], "price" => $goodsSkuInfo["price"] / 100,
"online_status" => $goodsSkuInfo["online_status"], "price_sort" => (int)$goodsSkuInfo["price"],
"desc" => $goodsSkuInfo["desc"], "audit_status" => $goodsSkuInfo["audit_status"],
"category_1_id" => $goodsSkuInfo["category_1_id"], "online_status" => $goodsSkuInfo["online_status"],
"category_2_id" => $goodsSkuInfo["category_2_id"], "desc" => $goodsSkuInfo["desc"],
"category_1_name" => $nameList[0], "category_1_id" => $goodsSkuInfo["category_1_id"],
"category_2_name" => $nameList[1], "category_2_id" => $goodsSkuInfo["category_2_id"],
"life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"], "category_1_name" => $nameList[0],
"life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"], "category_2_name" => $nameList[1],
"shop_name" => empty($subShopList[0]["shop_name"]) ? "" : $subShopList[0]["shop_name"], "life_account_name" => empty($lifeAccountRes["response"]["result"]["life_account_name"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_name"],
"shop_location" => $latitude.",".$longitude, "life_account_icon" => empty($lifeAccountRes["response"]["result"]["life_account_icon"]) ? "" : $lifeAccountRes["response"]["result"]["life_account_icon"],
"update_time" => strtotime($goodsSkuInfo["update_time"]), "shop_name" => $subShop["shop_name"],
]; "shop_location" => $latitude.",".$longitude,
return ElasticGoodService::indexDoc($goodsSkuId, $data); "update_time" => strtotime($goodsSkuInfo["update_time"]),
];
return ElasticGoodService::indexDoc($esId, $data);
}
} }
} }
} }
......
...@@ -212,7 +212,6 @@ class GoodsService ...@@ -212,7 +212,6 @@ class GoodsService
if (!empty($skuData["setmeal"])) { if (!empty($skuData["setmeal"])) {
$skuParams["setmeal"] = $skuData["setmeal"]; $skuParams["setmeal"] = $skuData["setmeal"];
} }
self::addGoodsInfoToEs($skuParams);
GoodsSku::save($skuParams); GoodsSku::save($skuParams);
return $skuId; return $skuId;
...@@ -338,7 +337,6 @@ class GoodsService ...@@ -338,7 +337,6 @@ class GoodsService
"rejected_reason" => $rejectedReason "rejected_reason" => $rejectedReason
], ["goods_sku_id" => $sku["goods_sku_id"]]); ], ["goods_sku_id" => $sku["goods_sku_id"]]);
//todo:: info to es
//商品操作记录 //商品操作记录
$res = self::getSnowIdgenId("goods"); $res = self::getSnowIdgenId("goods");
if (empty($res)) { if (empty($res)) {
...@@ -357,6 +355,8 @@ class GoodsService ...@@ -357,6 +355,8 @@ class GoodsService
"note" => $rejectedReason, "note" => $rejectedReason,
]; ];
GoodsOperationRecord::insertRecord($record); GoodsOperationRecord::insertRecord($record);
self::updateGoodsInfoToEs($goodsSkuId);
} }
} }
if (!GoodsSku::commit()) { if (!GoodsSku::commit()) {
...@@ -423,6 +423,8 @@ class GoodsService ...@@ -423,6 +423,8 @@ class GoodsService
if (GoodsSku::ONLINE_STATUS_ONLINE == $onlineStatus) { if (GoodsSku::ONLINE_STATUS_ONLINE == $onlineStatus) {
self::addGoodsSnapshot($sku); self::addGoodsSnapshot($sku);
} }
self::updateGoodsInfoToEs($goodsSkuId);
} }
} }
if (!GoodsSku::commit()) { if (!GoodsSku::commit()) {
...@@ -923,7 +925,7 @@ class GoodsService ...@@ -923,7 +925,7 @@ class GoodsService
$goodsSkuInfo = $goodsSkuInfoList[0]; $goodsSkuInfo = $goodsSkuInfoList[0];
$nameList = Category::select("name", ["category_id" => [$goodsSkuInfo["category_1_id"], $goodsSkuInfo["category_2_id"]]]); $nameList = Category::select("name", ["category_id" => [$goodsSkuInfo["category_1_id"], $goodsSkuInfo["category_2_id"]]]);
//生活号信息 //生活号信息
$url = config('interface', 'goods.public.get_life_account_by_id'); $url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) { if (empty($url)) {
throw new InterfaceException(['cus' => 0]); throw new InterfaceException(['cus' => 0]);
} }
...@@ -934,6 +936,7 @@ class GoodsService ...@@ -934,6 +936,7 @@ class GoodsService
if (!empty($subShopList)) { if (!empty($subShopList)) {
foreach ($subShopList as $subShop) { foreach ($subShopList as $subShop) {
if (!empty($subShop["latitude"]) && !empty($subShop["longitude"])) { if (!empty($subShop["latitude"]) && !empty($subShop["longitude"])) {
$esId = $goodsSkuInfo["goods_sku_id"]."_".$subShop["sub_shop_id"];
$data = [ $data = [
"doc" => [ "doc" => [
"goods_sku_id" => $goodsSkuInfo["goods_sku_id"], "goods_sku_id" => $goodsSkuInfo["goods_sku_id"],
...@@ -953,17 +956,17 @@ class GoodsService ...@@ -953,17 +956,17 @@ class GoodsService
"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_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" => $subShop["shop_name"],
"shop_location" => $subShop["latitude"].",".$subShop["longitude"], "shop_location" => $subShop["latitude"].",".$subShop["longitude"],
"update_time" => strtotime($goodsSkuInfo["update_time"]), "update_time" => strtotime($goodsSkuInfo["update_time"]),
], ],
]; ];
$isHaveId = ElasticGoodService::isHaveById($goodsSkuId); $isHaveId = ElasticGoodService::isHaveById($goodsSkuId);
if ($isHaveId) { if ($isHaveId) {
ElasticGoodService::updateDoc($goodsSkuId, $data); ElasticGoodService::updateDoc($esId, $data);
} else { } else {
$data = $data["doc"]; $data = $data["doc"];
ElasticGoodService::indexDoc($goodsSkuId, $data); ElasticGoodService::indexDoc($esId, $data);
} }
} }
} }
...@@ -980,7 +983,7 @@ class GoodsService ...@@ -980,7 +983,7 @@ class GoodsService
{ {
$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'); $url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) { if (empty($url)) {
throw new InterfaceException(['cus' => 0]); throw new InterfaceException(['cus' => 0]);
} }
......
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