Commit 1d702964 authored by luhongguang's avatar luhongguang

update:es 调整

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