|
...
|
...
|
@@ -162,7 +162,7 @@ class RecommendedSuppliers extends Command |
|
|
|
$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'])){
|
|
|
|
if(isset($res['code']) && $res['code'] == 200){
|
|
|
|
//保存多条数据
|
|
|
|
$saveData = [
|
|
|
|
'project_id'=>$project_id,
|
|
...
|
...
|
@@ -171,14 +171,11 @@ class RecommendedSuppliers extends Command |
|
|
|
];
|
|
|
|
$purchaserModel = new Purchaser();
|
|
|
|
$purchaserModel->add($saveData);
|
|
|
|
if(!empty($res['data'])){
|
|
|
|
$this->savePurchaserInfo($project_id,$keyword,$res['data']);
|
|
|
|
}else{
|
|
|
|
if(!isset($res['code']) || $res['code'] != 200){
|
|
|
|
echo '请求错误,跳过当前项目。避免进入死循环'.PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$title = $this->getKeywords($project_id);
|
|
|
|
$this->savePurchaser($project_id,$title);
|
|
|
|
}else{
|
|
|
|
echo '未正常返回数据,跳过项目'.PHP_EOL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
...
|
...
|
@@ -193,11 +190,11 @@ class RecommendedSuppliers extends Command |
|
|
|
public function getKeywords($project_id){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keyword_array = $this->getPurchaserList($project_id);
|
|
|
|
$info = $keywordModel->read(['title'=>['not in',$keyword_array]],'title');
|
|
|
|
if($info === false){
|
|
|
|
$title = $keywordModel->where('title', 'not in', $keyword_array)->orderRaw('RAND()')->limit(1)->value('title'); // 只返回 title 字段
|
|
|
|
if(empty($title)){
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return $info['title'] ?? '';
|
|
|
|
return $title;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|