Commit 1136e25b authored by jianghaiming's avatar jianghaiming

Merge branch 'develop' of https://gitlab.yidian-inc.com/bp/goods into develop

parents 32a692bd 1a96c6df
......@@ -124,7 +124,6 @@ class ElasticGoodService
$sortList = [
["price_sort" => "asc", "total_amount_sold" => "desc"],
//todo 距离排序
["total_amount_sold" => "desc"],
["price_sort" => "asc"],
];
......@@ -163,6 +162,7 @@ class ElasticGoodService
],
"order" => "asc",
"unit" => "km",
"distance_type" => "plane",
];
}
......@@ -194,7 +194,7 @@ class ElasticGoodService
$result["list"][$key]["shop_location"] = $source["_source"]["shop_location"];
$result["list"][$key]["life_account_name"] = $source["_source"]["life_account_name"];
$result["list"][$key]["life_account_icon"] = $source["_source"]["life_account_icon"];
$result["list"][$key]["distance"] = empty($source["sort"][2]) ? "" : round($source["sort"][2], 2)."km";
$result["list"][$key]["distance"] = empty($source["sort"][2]) ? "" : round($source["sort"][2], 2) . "km";
}
}
......@@ -202,4 +202,23 @@ class ElasticGoodService
return $result ? $result : (object)$result;
}
/**
* id 在es数据里是否存在
* @param $skuId
* @return bool
*/
public static function isHaveById($skuId)
{
$data["query"]["bool"]["must"] = [
["term" => ["_id" => $skuId]],
];
$elasticClient = ElasticUtil::getInstance();
$res = $elasticClient->searchDoc(self::INDEX, $data);
if (!empty($res["hits"]["total"]["value"])) {
return $res["hits"]["total"]["value"] > 0;
}
return false;
}
}
\ No newline at end of file
......@@ -951,7 +951,13 @@ class GoodsService
"shop_location" => $subShop["latitude"].",".$subShop["longitude"],
],
];
$isHaveId = ElasticGoodService::isHaveById($goodsSkuId);
if ($isHaveId) {
ElasticGoodService::updateDoc($goodsSkuId, $data);
} else {
$data = $data["doc"];
ElasticGoodService::indexDoc($goodsSkuId, $data);
}
}
}
}
......
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