|
...
|
...
|
@@ -62,7 +62,11 @@ class RecommendedSuppliers extends Command |
|
|
|
if($result !== false){
|
|
|
|
ProjectServer::useProject($v['project_id']);
|
|
|
|
$title = $this->getKeywords($v['project_id']);
|
|
|
|
if(!empty($title)){
|
|
|
|
$this->savePurchaser($v['project_id'],$title);
|
|
|
|
}else{
|
|
|
|
echo '关键词已取完'.PHP_EOL;
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -84,7 +88,9 @@ class RecommendedSuppliers extends Command |
|
|
|
$count = $purchaserInfoModel->counts(['project_id'=>$v['project_id']]);
|
|
|
|
//获取项目版本
|
|
|
|
$plan = ['专业版'=>300, '标准版'=>500, '商务版'=>800, '旗舰版'=>1200];
|
|
|
|
$total_number = $plan[Project::planMap()[$v['plan']]] ?? 300;
|
|
|
|
$typePlan = Project::planMap();
|
|
|
|
$version = $typePlan[$v['plan']] ?? '专业版';
|
|
|
|
$total_number = $plan[$version] ?? 300;
|
|
|
|
if($count > $total_number){
|
|
|
|
echo date('Y-m-d H:i:s') . '达到数量上线关闭的项目:'.$v['project_id'] . PHP_EOL;
|
|
|
|
//更新数量上限字段,并关闭推荐供应商
|
|
...
|
...
|
@@ -95,12 +101,31 @@ class RecommendedSuppliers extends Command |
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取关键词数据
|
|
|
|
* @name :getPurchaser
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/15 17:55
|
|
|
|
*/
|
|
|
|
public function getPurchaser($keyword,$project_id){
|
|
|
|
$purchaserModel = new Purchaser();
|
|
|
|
return $purchaserModel->read(['keyword'=>$keyword,'project_id'=>$project_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取已经处理过的关键词
|
|
|
|
* @name :getPurchaserList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/15 17:55
|
|
|
|
*/
|
|
|
|
public function getPurchaserList($project_id){
|
|
|
|
$purchaserModel = new Purchaser();
|
|
|
|
return $purchaserModel->selectField(['project_id'=>$project_id],'keyword');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存供应商
|
|
|
|
* @name :getPurchaser
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -110,6 +135,7 @@ class RecommendedSuppliers extends Command |
|
|
|
public function savePurchaser($project_id,$keyword,$row = 10){
|
|
|
|
//项目还没有关键词
|
|
|
|
if(!$keyword){
|
|
|
|
echo '项目还没有关键词'.PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$url = 'https://fob.ai.cc/api/company_list';
|
|
...
|
...
|
@@ -126,6 +152,7 @@ class RecommendedSuppliers extends Command |
|
|
|
'total'=>$this->param['row'] ?? 10,
|
|
|
|
];
|
|
|
|
$res = http_post($url,json_encode($param));
|
|
|
|
echo '请求返回状态'. $res['code']?? ''.PHP_EOL;
|
|
|
|
// echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
|
|
|
|
if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
|
|
|
|
//保存多条数据
|
|
...
|
...
|
@@ -152,15 +179,13 @@ class RecommendedSuppliers extends Command |
|
|
|
* @time :2024/7/1 18:07
|
|
|
|
*/
|
|
|
|
public function getKeywords($project_id){
|
|
|
|
$info = Keyword::inRandomOrder()->first();
|
|
|
|
if(!$info){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keyword_array = $this->getPurchaserList($project_id);
|
|
|
|
$info = $keywordModel->read(['title'=>['not in',$keyword_array]],'title');
|
|
|
|
if($info === false){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
$keywordInfo = $this->getPurchaser($info->title,$project_id);
|
|
|
|
if($keywordInfo !== false){
|
|
|
|
$this->getKeywords($project_id);
|
|
|
|
}
|
|
|
|
return $info->title;
|
|
|
|
return $info['title'] ?? '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|