Commit 78edeb9f authored by jianghaiming's avatar jianghaiming

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

parents c1c67ae6 e553537f
<?php
namespace App\Models\tmp\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
/**
* Class QyqTicketData
* 老商品数据,跑数据用
* @package App\Models\goods\mysql
*/
class QyqTicketData extends MysqlBase
{
const TABLE_NAME = 'qyq_ticketdata';
const CONFIG_INDEX = 'goods';
public static function getRecordList($where = [], $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::select($columns, $where);
}
}
\ No newline at end of file
......@@ -91,6 +91,7 @@ class GoodsToEsController extends Cli
"category_2_id" => $goodsSkuInfo["category_2_id"],
"category_1_name" => $nameList[0],
"category_2_name" => $nameList[1],
"life_account_id" => $goodsSkuInfo["life_account_id"],
"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"],
......
<?php
use Api\PhpUtils\Http\Request;
use App\Base\Cli;
use App\Exception\custom\InterfaceException;
use \App\Models\tmp\mysql\QyqTicketData;
/**
* 导入老商品数据
* php public/cli.php GoodsToInit run
* Class GoodsToInitController
*/
class GoodsToInitController extends Cli
{
public function runAction()
{
$total = $this->getDataCount();
$pageSize = 10;
$pageTotal = floor($total/$pageSize) + 1;
for ($i = 0; $i <= $pageTotal; $i++) {
echo $i."\n";
$list = $this->getDataList($i, $pageSize);
foreach ($list as $item) {
$lifeAccountId = $item["life_account_id"];
$merchantId = $this->getMerchantId($lifeAccountId);
if (empty($merchantId)) {
echo "生活号 ".$lifeAccountId." 没有对应的 merchant_id \n";
continue;
}
}
}
}
/**
* 总数
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
private function getDataCount()
{
return QyqTicketData::count([]);
}
/**
* 每页取指定条数数据处理
* @param $page
* @param $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
private function getDataList($page, $limit)
{
$from = $page * $limit;
$where["LIMIT"] = [$from, $limit];
return QyqTicketData::select("*", $where);
}
/**
* 脚本第一步,把所有的
*/
private function dealShopData()
{
}
/**
* 获取 merchant_id
* @param $lifeAccountId
* @return mixed|string
* @throws InterfaceException
*/
private function getMerchantId($lifeAccountId)
{
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) {
throw new InterfaceException(['cus' => 0]);
}
$lifeAccountRes = (new Request())->get($url, ["life_account_id" => $lifeAccountId]);
return empty($lifeAccountRes["response"]["result"]["merchant_id"]) ? "" : $lifeAccountRes["response"]["result"]["merchant_id"];
}
}
\ No newline at end of file
......@@ -150,6 +150,7 @@ class ElasticGoodService
$result["list"][$key]["online_status"] = $source["_source"]["online_status"];
$result["list"][$key]["shop_name"] = $source["_source"]["shop_name"];
$result["list"][$key]["shop_location"] = $source["_source"]["shop_location"];
$result["list"][$key]["life_account_id"] = $source["_source"]["life_account_id"];
$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"][1]) ? "" : round($source["sort"][1], 2) . "km";
......@@ -219,6 +220,7 @@ class ElasticGoodService
$longitude = empty($params["longitude"]) ? "" : $params["longitude"];
$searchContent = empty($params["search_content"]) ? "" : $params["search_content"];
$subjectName = empty($params["subject_name"]) ? "" : $params["subject_name"];
$lifeAccountId = empty($params["life_account_id"]) ? "" : $params["life_account_id"];
$data = [
"from" => ($from - 1) * $size,
......@@ -229,7 +231,7 @@ class ElasticGoodService
["term" => ["audit_status" => GoodsSku::STATUS_PASS]],
["term" => ["online_status" => GoodsSku::ONLINE_STATUS_ONLINE]],
];
if (!empty($searchContent)) {
if (!empty($searchContent) || (!empty($subjectName) && $subjectName != "本周上新")) {
$multiMatch = [["multi_match" => [
"query" => $searchContent.$subjectName,
"fields" => ["goods_name", "category_1_name", "category_2_name", "desc", "life_account_name", "shop_name"],
......@@ -240,6 +242,11 @@ class ElasticGoodService
$data["query"]["bool"]["must"] = $mustInit;
}
if (!empty($lifeAccountId)) {
$lifeAccountData = [["term" => ["life_account_id" => $lifeAccountId]]];
$data["query"]["bool"]["must"] = array_merge($data["query"]["bool"]["must"], $lifeAccountData);
}
if (!empty($latitude) && !empty($longitude)) {
$data["query"]["bool"]["filter"]["geo_distance"] = [
"distance" => "50km",
......
......@@ -935,7 +935,7 @@ class GoodsService
$lastId = $sku["goods_spu_id"];
}
} else {
$lastId = -1;
$lastId = "-1";
}
return ["status_list" => $statusList, "goods_list" => $data, "last_id" => $lastId];
......@@ -983,6 +983,7 @@ class GoodsService
"category_2_id" => $goodsSkuInfo["category_2_id"],
"category_1_name" => $nameList[0],
"category_2_name" => $nameList[1],
"life_account_id" => $goodsSkuInfo["life_account_id"],
"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"],
......@@ -1244,7 +1245,7 @@ class GoodsService
$objectId = $arr[1];
$url = Ksyun::getPicUrl("merchant-b", 'goods_temp', $bucket . '/' . $objectId, 200, 200, 'jpeg');
$data[$key] = $url;
$data[] = $url;
}
return $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