Commit dc1123d3 authored by luhongguang's avatar luhongguang

update:线上环境做商品限制准备

parent 12c653d5
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Services\goods; namespace App\Services\goods;
use Api\PhpUtils\Common\BaseConvert; use Api\PhpUtils\Common\BaseConvert;
use Api\PhpUtils\Common\IP;
use Api\PhpUtils\Elastic\ElasticUtil; use Api\PhpUtils\Elastic\ElasticUtil;
use App\Models\goods\mysql\GoodsSku; use App\Models\goods\mysql\GoodsSku;
...@@ -15,6 +16,11 @@ class ElasticGoodService ...@@ -15,6 +16,11 @@ class ElasticGoodService
const SORT_TYPE_SALES = 2; const SORT_TYPE_SALES = 2;
const SORT_TYPE_PRICE = 3; const SORT_TYPE_PRICE = 3;
//添加生活号id,这里的生活号id发的商品,es查不出来
const TEST_LIFE_ACCOUNT_ID = [];
//公司内网wifi ip
const WIFI_IPS = ['123.103.40.112','123.103.40.113','123.103.40.114','123.103.40.115','123.103.40.116','123.103.40.117'];
public static function createIndex() public static function createIndex()
{ {
$elasticClient = ElasticUtil::getInstance(); $elasticClient = ElasticUtil::getInstance();
...@@ -221,6 +227,7 @@ class ElasticGoodService ...@@ -221,6 +227,7 @@ class ElasticGoodService
$searchContent = empty($params["search_content"]) ? "" : $params["search_content"]; $searchContent = empty($params["search_content"]) ? "" : $params["search_content"];
$subjectName = empty($params["subject_name"]) ? "" : $params["subject_name"]; $subjectName = empty($params["subject_name"]) ? "" : $params["subject_name"];
$lifeAccountId = empty($params["life_account_id"]) ? "" : $params["life_account_id"]; $lifeAccountId = empty($params["life_account_id"]) ? "" : $params["life_account_id"];
$ip = empty($params["ip"]) ? "" : $params["ip"];
$data = [ $data = [
"from" => ($from - 1) * $size, "from" => ($from - 1) * $size,
...@@ -231,6 +238,13 @@ class ElasticGoodService ...@@ -231,6 +238,13 @@ class ElasticGoodService
["term" => ["audit_status" => GoodsSku::STATUS_PASS]], ["term" => ["audit_status" => GoodsSku::STATUS_PASS]],
["term" => ["online_status" => GoodsSku::ONLINE_STATUS_ONLINE]], ["term" => ["online_status" => GoodsSku::ONLINE_STATUS_ONLINE]],
]; ];
//线上环境,配置不允许发现的生活号发布的商品
$env = \Yaf\Application::app()->environ();
if (in_array($env, ['dev'])) {
if (!empty(self::TEST_LIFE_ACCOUNT_ID) && !in_array($ip, self::WIFI_IPS)) {
$data["query"]["bool"]["must_not"] = ["terms" => ["life_account_id" => self::TEST_LIFE_ACCOUNT_ID]];
}
}
//gte 是大于等于; gt是大于; lte是小于等于; lt是小于 //gte 是大于等于; gt是大于; lte是小于等于; lt是小于
$data["query"]["bool"]["filter"][]["range"] = ["inventory_rest" => [["gt" => 0]]]; $data["query"]["bool"]["filter"][]["range"] = ["inventory_rest" => [["gt" => 0]]];
//$data["query"]["bool"]["filter"][]["range"] = ["price" => [["gt" => 0]]]; //$data["query"]["bool"]["filter"][]["range"] = ["price" => [["gt" => 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