|
@@ -62,7 +62,11 @@ class RecommendedSuppliers extends Command |
|
@@ -62,7 +62,11 @@ class RecommendedSuppliers extends Command |
|
62
|
if($result !== false){
|
62
|
if($result !== false){
|
|
63
|
ProjectServer::useProject($v['project_id']);
|
63
|
ProjectServer::useProject($v['project_id']);
|
|
64
|
$title = $this->getKeywords($v['project_id']);
|
64
|
$title = $this->getKeywords($v['project_id']);
|
|
65
|
- $this->savePurchaser($v['project_id'],$title);
|
65
|
+ if(!empty($title)){
|
|
|
|
66
|
+ $this->savePurchaser($v['project_id'],$title);
|
|
|
|
67
|
+ }else{
|
|
|
|
68
|
+ echo '关键词已取完'.PHP_EOL;
|
|
|
|
69
|
+ }
|
|
66
|
DB::disconnect('custom_mysql');
|
70
|
DB::disconnect('custom_mysql');
|
|
67
|
}
|
71
|
}
|
|
68
|
}
|
72
|
}
|
|
@@ -95,12 +99,31 @@ class RecommendedSuppliers extends Command |
|
@@ -95,12 +99,31 @@ class RecommendedSuppliers extends Command |
|
95
|
return true;
|
99
|
return true;
|
|
96
|
}
|
100
|
}
|
|
97
|
|
101
|
|
|
|
|
102
|
+ /**
|
|
|
|
103
|
+ * @remark :获取关键词数据
|
|
|
|
104
|
+ * @name :getPurchaser
|
|
|
|
105
|
+ * @author :lyh
|
|
|
|
106
|
+ * @method :post
|
|
|
|
107
|
+ * @time :2025/4/15 17:55
|
|
|
|
108
|
+ */
|
|
98
|
public function getPurchaser($keyword,$project_id){
|
109
|
public function getPurchaser($keyword,$project_id){
|
|
99
|
$purchaserModel = new Purchaser();
|
110
|
$purchaserModel = new Purchaser();
|
|
100
|
return $purchaserModel->read(['keyword'=>$keyword,'project_id'=>$project_id]);
|
111
|
return $purchaserModel->read(['keyword'=>$keyword,'project_id'=>$project_id]);
|
|
101
|
}
|
112
|
}
|
|
102
|
|
113
|
|
|
103
|
/**
|
114
|
/**
|
|
|
|
115
|
+ * @remark :获取已经处理过的关键词
|
|
|
|
116
|
+ * @name :getPurchaserList
|
|
|
|
117
|
+ * @author :lyh
|
|
|
|
118
|
+ * @method :post
|
|
|
|
119
|
+ * @time :2025/4/15 17:55
|
|
|
|
120
|
+ */
|
|
|
|
121
|
+ public function getPurchaserList($project_id){
|
|
|
|
122
|
+ $purchaserModel = new Purchaser();
|
|
|
|
123
|
+ return $purchaserModel->selectField(['project_id'=>$project_id],'keyword');
|
|
|
|
124
|
+ }
|
|
|
|
125
|
+
|
|
|
|
126
|
+ /**
|
|
104
|
* @remark :保存供应商
|
127
|
* @remark :保存供应商
|
|
105
|
* @name :getPurchaser
|
128
|
* @name :getPurchaser
|
|
106
|
* @author :lyh
|
129
|
* @author :lyh
|
|
@@ -110,6 +133,7 @@ class RecommendedSuppliers extends Command |
|
@@ -110,6 +133,7 @@ class RecommendedSuppliers extends Command |
|
110
|
public function savePurchaser($project_id,$keyword,$row = 10){
|
133
|
public function savePurchaser($project_id,$keyword,$row = 10){
|
|
111
|
//项目还没有关键词
|
134
|
//项目还没有关键词
|
|
112
|
if(!$keyword){
|
135
|
if(!$keyword){
|
|
|
|
136
|
+ echo '项目还没有关键词';
|
|
113
|
return true;
|
137
|
return true;
|
|
114
|
}
|
138
|
}
|
|
115
|
$url = 'https://fob.ai.cc/api/company_list';
|
139
|
$url = 'https://fob.ai.cc/api/company_list';
|
|
@@ -126,8 +150,10 @@ class RecommendedSuppliers extends Command |
|
@@ -126,8 +150,10 @@ class RecommendedSuppliers extends Command |
|
126
|
'total'=>$this->param['row'] ?? 10,
|
150
|
'total'=>$this->param['row'] ?? 10,
|
|
127
|
];
|
151
|
];
|
|
128
|
$res = http_post($url,json_encode($param));
|
152
|
$res = http_post($url,json_encode($param));
|
|
|
|
153
|
+ echo '请求返回状态'.$res['code']?? ''.PHP_EOL;
|
|
129
|
// echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
|
154
|
// echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
|
|
130
|
if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
|
155
|
if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
|
|
|
|
156
|
+
|
|
131
|
//保存多条数据
|
157
|
//保存多条数据
|
|
132
|
$saveData = [
|
158
|
$saveData = [
|
|
133
|
'project_id'=>$project_id,
|
159
|
'project_id'=>$project_id,
|
|
@@ -152,15 +178,13 @@ class RecommendedSuppliers extends Command |
|
@@ -152,15 +178,13 @@ class RecommendedSuppliers extends Command |
|
152
|
* @time :2024/7/1 18:07
|
178
|
* @time :2024/7/1 18:07
|
|
153
|
*/
|
179
|
*/
|
|
154
|
public function getKeywords($project_id){
|
180
|
public function getKeywords($project_id){
|
|
155
|
- $info = Keyword::inRandomOrder()->first();
|
|
|
|
156
|
- if(!$info){
|
181
|
+ $keywordModel = new Keyword();
|
|
|
|
182
|
+ $keyword_array = $this->getPurchaserList($project_id);
|
|
|
|
183
|
+ $info = $keywordModel->read(['title'=>'not in',$keyword_array],'title');
|
|
|
|
184
|
+ if($info === false){
|
|
157
|
return '';
|
185
|
return '';
|
|
158
|
}
|
186
|
}
|
|
159
|
- $keywordInfo = $this->getPurchaser($info->title,$project_id);
|
|
|
|
160
|
- if($keywordInfo !== false){
|
|
|
|
161
|
- $this->getKeywords($project_id);
|
|
|
|
162
|
- }
|
|
|
|
163
|
- return $info->title;
|
187
|
+ return $info['title'] ?? '';
|
|
164
|
}
|
188
|
}
|
|
165
|
|
189
|
|
|
166
|
/**
|
190
|
/**
|