|
...
|
...
|
@@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup; |
|
|
|
use App\Models\Manage\Dept;
|
|
|
|
use App\Models\Manage\EntryPosition;
|
|
|
|
use App\Models\Manage\ManageHr;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\WebSetting\WebSettingService;
|
|
|
|
use App\Services\ProjectServer;
|
|
...
|
...
|
@@ -260,17 +262,73 @@ class Demo extends Command |
|
|
|
// }
|
|
|
|
|
|
|
|
public function handle(){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$list = $projectModel->list(['delete_status'=>0]);
|
|
|
|
foreach ($list as $v){
|
|
|
|
ProjectServer::useProject($v['id']);
|
|
|
|
$webSettingServiceModel = new WebSettingService();
|
|
|
|
$info = $webSettingServiceModel->read(['values'=>['like','%+86%']]);
|
|
|
|
if($info !== false){
|
|
|
|
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
|
|
|
|
}
|
|
|
|
// $projectModel = new Project();
|
|
|
|
// $list = $projectModel->list(['delete_status'=>0]);
|
|
|
|
// foreach ($list as $v){
|
|
|
|
ProjectServer::useProject(1);
|
|
|
|
$this->getKeywordImage();
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据关键字获取产品主图
|
|
|
|
* @name :getKeywordList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/2/23 16:28
|
|
|
|
*/
|
|
|
|
public function getKeywordImage($keyword_id = 14,$project_id = 1){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$thumb = $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
//TODO::所有产品
|
|
|
|
$this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
|
|
|
|
$domainModel = new DomainInfo();
|
|
|
|
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
|
|
|
|
if(!empty($domainInfo)){
|
|
|
|
$keywordInfo['route'] = $domainInfo['domain'].'/'.$keywordInfo['route'];
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'url'=>$keywordInfo['route'],
|
|
|
|
'title'=>$keywordInfo['title'],
|
|
|
|
'keyword_title'=>$keywordInfo['keyword_title'],
|
|
|
|
'keyword_content'=>$keywordInfo['keyword_content'],
|
|
|
|
'product_list'=>$thumb ?? []
|
|
|
|
];
|
|
|
|
echo '返回数据'.json_encode($data);
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关键词聚合页-推荐&热门产品
|
|
|
|
*/
|
|
|
|
public function getRecommendAndHotProducts($project_id,$route): ?array
|
|
|
|
{
|
|
|
|
$productIds = [];
|
|
|
|
$productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();
|
|
|
|
if (!empty($productKeyword)){
|
|
|
|
$productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
|
|
|
|
if (!empty($productsQuery)){
|
|
|
|
foreach ($productsQuery as $item){
|
|
|
|
$productIds[] = $item->id;
|
|
|
|
}
|
|
|
|
if (count($productIds)<7){
|
|
|
|
$randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
}else{
|
|
|
|
$products = $productsQuery;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
if (!empty($products)){
|
|
|
|
foreach ($products as $item){
|
|
|
|
$data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
public function printMessage()
|
|
|
|
{
|
...
|
...
|
|