作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>917]);
$list = $projectModel->list(['id'=>206]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -152,6 +152,8 @@ class ProjectController extends BaseController
$query = $this->searchUpgrade($query);
//搜索战队
$query = $this->searchChannel($query);
//其他搜索
$query = $this->searchTechMid($query);
return $query;
}
... ... @@ -252,6 +254,20 @@ class ProjectController extends BaseController
}
/**
* @remark :搜索售后技术
* @name :searchTechMid
* @author :lyh
* @method :post
* @time :2024/3/4 14:58
*/
public function searchTechMid(&$query){
if(isset($this->map['tech_mid'])){
$query = $query->where('gl_project_deploy_optimize.tech_mid',$this->map['tech_mid']);
}
return $query;
}
/**
* @remark :访问权限
* @name :getManagerRole
* @author :lyh
... ...
... ... @@ -7,6 +7,8 @@ use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\UserLogic;
use App\Jobs\PurchaserJob;
use App\Models\Com\Purchaser;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
... ... @@ -15,6 +17,7 @@ use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
/***
* 当前为公共类
... ... @@ -333,22 +336,14 @@ class ComController extends BaseController
* @time :2024/3/4 10:10
*/
public function recommendedPurchaser(){
$this->param['keyword'] = 'led';
$url = 'https://admin.hagro.cn/api/company_list';
$data = [
'prod_desc'=>$this->param['keyword'],
'total'=>$this->param['now'] ?? 10,
];
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(http_build_query($data), true) . PHP_EOL, FILE_APPEND);
$token = 'company_list'.date('Y-m-d').http_build_query(arsort($data));
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($token, true) . PHP_EOL, FILE_APPEND);
$param = [
'prod_desc'=>$this->param['keyword'],
'token'=>$token,
'total'=>$this->param['now'] ?? 10,
];
$lists = http_post($url,$param);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($token, true) . PHP_EOL, FILE_APPEND);
$this->response('success',Code::SUCCESS,$lists);
$data = [];
$purchaserModel = new Purchaser();
$info = $purchaserModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
PurchaserJob::dispatch(['keyword'=>$this->param['keyword'] ?? 'led','row'=>$this->param['row'] ?? 10,'project_id'=>$this->user['project_id']]);
}else{
$data = json_decode($info['data']);
}
$this->response('数据生成中',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -472,23 +472,26 @@ class RankDataLogic extends BaseLogic
}
//关键词达标天数
if($model->updated_date != date('Y-m-d') || empty($model->is_compliance)){
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
if($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num){
Log::channel('rank_data')->info('项目'.$project_id.':关键词达标-'.$first_page_num);
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
//项目表更新
if(!$lang){
$compliance_day = Project::where(['id' => $project_id])->value('finish_remain_day') ?: 0;
Project::where('id', $project_id)->update(['is_remain_today' => 1, 'finish_remain_day' => $compliance_day+1]);
}
}else{
Log::channel('rank_data')->info('项目'.$project_id.':关键词未达标-'.$first_page_num);
}
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
$type = Project::where('id', $project_id)->value('type');
$model->is_compliance = 0;
if ($keyword_num && $type == Project::TYPE_TWO && $first_page_num >= $keyword_num) {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词达标'. $keyword_num .' - ' . $first_page_num);
//项目表更新
if (($model->updated_date != date('Y-m-d') || empty($model->is_compliance)) && !$lang) {
$compliance_day = Project::where(['id' => $project_id])->value('finish_remain_day') ?: 0;
Project::where('id', $project_id)->update(['is_remain_today' => 1, 'finish_remain_day' => $compliance_day + 1]);
Log::channel('rank_data')->info('项目' . $project_id . '达标天数+1:'. ($compliance_day + 1));
}
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
} else {
Log::channel('rank_data')->info('项目' . $project_id . ':关键词未达标'. $keyword_num .' - ' . $first_page_num);
}
$model->project_id = $project_id;
$model->first_num = $first_num;
$model->first_page_num = $first_page_num;
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Jobs;
use App\Models\Com\Purchaser;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
... ... @@ -41,6 +42,29 @@ class PurchaserJob implements ShouldQueue
*/
public function handle()
{
$this->param['keyword'] = 'led';
$url = 'https://admin.hagro.cn/api/company_list';
$data = [
'prod_desc'=>$this->param['keyword'],
'total'=>$this->param['row'] ?? 10,
];
arsort($data);
$token = 'company_list+'.date('Y-m-d').'+'.http_build_query($data);
$param = [
'prod_desc'=>$this->param['keyword'],
'token'=>md5($token),
'total'=>$this->param['row'] ?? 10,
];
$res = http_post($url,json_encode($param));
if(!empty($res) && $res['code'] == 200){
$saveData = [
'project_id'=>$this->param['project_id'],
'keyword'=>$this->param['keyword'],
'data'=>json_encode($res['data'])
];
$purchaserModel = new Purchaser();
$purchaserModel->add($saveData);
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :Purchaser.php
* @author :lyh
* @method :post
* @time :2024/3/4 14:39
*/
namespace App\Models\Com;
use App\Models\Base;
class Purchaser extends Base
{
protected $table = 'gl_purchaser';
}
... ...