作者 赵彬吉
<?php
/**
* @remark :
* @name :AfterCount.php
* @name :AfterDayCount.php
* @author :lyh
* @method :post
* @time :2025/3/26 15:28
... ... @@ -16,7 +16,7 @@ use Carbon\Carbon;
use App\Models\HomeCount\AfterCount as AfterCountModel;
use Illuminate\Console\Command;
class AfterCount extends Command
class AfterDayCount extends Command
{
/**
* The name and signature of the console command.
... ... @@ -44,6 +44,7 @@ class AfterCount extends Command
echo date('Y-m-d H:i:s').'统计start->'.PHP_EOL;
$saveData = $this->_action();
$afterModel = new AfterCountModel();
//保存数据
$afterModel->insertAll($saveData);
echo date('Y-m-d H:i:s').'->统计end'.PHP_EOL;
return true;
... ... @@ -62,7 +63,7 @@ class AfterCount extends Command
$rankDataLogModel = new RankDataLog();
$todayMidnight = date('Y-m-d 00:00:00', strtotime('today'));
$saveData = [];
$projectIdArr = $rankDataLogModel->selectField(['is_compliance'=>1,'lang'=>null,'date'=>date('Y-m-d', strtotime('-3 months'))],'project_id');//3个月前达标的项目id
$projectIdArr = $rankDataLogModel->selectField(['is_compliance'=>1,'lang'=>'','date'=>date('Y-m-d', strtotime('-3 months'))],'project_id');//3个月前达标的项目id
foreach ($this->after_manager as $key => $valM){
$idArr = $this->managerHrModel->selectField(['name'=>['in',$valM]],'id');
$project_count = $projectModel->where('gl_project.extend_type',0)
... ... @@ -108,9 +109,9 @@ class AfterCount extends Command
'project_count'=>$project_count,
'qualified_count'=>$qualified_count,
'rate'=>$rate,
'three_project_count'=>$project_count - $three_project_count,
'three_qualified_count'=>$qualified_count - $three_qualified_count,
'three_rate'=>$rate - $three_rate,
'three_project_count'=>$three_project_count,
'three_qualified_count'=>$three_qualified_count,
'three_rate'=>$three_rate,
'data' => json_encode($data,true)
];
}
... ...
... ... @@ -66,7 +66,27 @@ class UpdateRoute extends Command
*/
public function handle()
{
$this->insertData();
return $this->_action();
}
/**
* @remark :清洗数据
* @name :_action
* @author :lyh
* @method :post
* @time :2025/4/10 17:08
*/
public function _action(){
$projectModel = new Project();
$lists = $projectModel->list(['delete_status'=>0,'extend_type'=>0,'type'=>['!=',0]],'id',['id']);
$keywordModel = new Keyword();
foreach ($lists as $v){
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s').' 执行的项目id:'.$v['id'].PHP_EOL;
$keywordModel->edit(['type'=>1],['id'=>['!=',0]]);
DB::disconnect('custom_mysql');
}
return true;
}
/**
* @remark :
... ...
... ... @@ -73,11 +73,10 @@ class OptimizeSetKeywordSync extends Command
{
$keywords = explode("\n", $keywords);
$keywords = array_unique(array_filter($keywords));
ProjectServer::useProject($project_id);
$keywordModel = new Keyword();
$keywordModel->saveBKeyword($project_id,$keywords);
$keywordModel->saveBKeyword($project_id,$keywords,Keyword::TYPE_ORDER_KEYWORD);
DB::disconnect('custom_mysql');
return true;
}
}
\ No newline at end of file
}
... ...
... ... @@ -576,6 +576,7 @@ class ProjectLogic extends BaseLogic
'main_keyword'=>$project_keyword['main_keyword'] ?? '',
'customer_keywords'=>$project_keyword['customer_keywords'] ?? '',
'search_keywords'=>$project_keyword['search_keywords'] ?? '',
'seo_keywords'=>$project_keyword['seo_keywords'] ?? '',
];
if(isset($project_keyword['operator_log']) && !empty($project_keyword['operator_log'])){
$data['operator_log'] = json_encode($project_keyword['operator_log'] ?? []);
... ...
<?php
/**
* @remark :
* @name :AfterCount.php
* @name :AfterDayCount.php
* @author :lyh
* @method :post
* @time :2025/3/26 15:31
... ...
... ... @@ -21,6 +21,8 @@ class Keyword extends Base
//连接数据库
protected $connection = 'custom_mysql';
const TYPE_ORDER_KEYWORD = 1;//关键词标识,预约关键词标识
const STATUS_ACTIVE = 1;
//获取字母对应数字
public $firstNumWord = [
... ... @@ -110,7 +112,7 @@ class Keyword extends Base
public static function extendKeyword($project_id)
{
$result = [];
$keywords = self::where(['project_id' => $project_id])->pluck('seo_title', 'title')->toArray();
$keywords = self::where(['project_id' => $project_id])->where('type',self::TYPE_ORDER_KEYWORD)->pluck('seo_title', 'title')->toArray();
if (empty($keywords))
return $result;
// $item:前缀 + 关键词 + 后缀
... ... @@ -149,7 +151,7 @@ class Keyword extends Base
* @method :post
* @time :2025/3/25 16:28
*/
public function saveBKeyword($project_id,$keywords){
public function saveBKeyword($project_id,$keywords,$type = 0){
foreach ($keywords as $v){
if(empty($v)){
continue;
... ... @@ -159,6 +161,7 @@ class Keyword extends Base
$param['project_id'] = $project_id;
$param['title'] = $v;
$param['first_word'] = $this->first_word($param['title']);
$param['type'] = $type;
$this->addReturnId($param);
}
}
... ...