|
@@ -135,7 +135,6 @@ class VideoTask extends Command |
|
@@ -135,7 +135,6 @@ class VideoTask extends Command |
|
135
|
],
|
135
|
],
|
|
136
|
'task_id' => $task_id,
|
136
|
'task_id' => $task_id,
|
|
137
|
'callback_url' => env('APP_URL') . '/api/video_task_callback',
|
137
|
'callback_url' => env('APP_URL') . '/api/video_task_callback',
|
|
138
|
-// 'callback_url' => url('a/getKeywordVideo?project_id='.$val->project_id.'&keyword_id='.$val->keyword_id.'&video='),
|
|
|
|
139
|
];
|
138
|
];
|
|
140
|
$result = Http::post('http://216.250.255.116:7866/create_task', $data);
|
139
|
$result = Http::post('http://216.250.255.116:7866/create_task', $data);
|
|
141
|
$val->task_id = $task_id;
|
140
|
$val->task_id = $task_id;
|
|
@@ -176,26 +175,9 @@ class VideoTask extends Command |
|
@@ -176,26 +175,9 @@ class VideoTask extends Command |
|
176
|
*/
|
175
|
*/
|
|
177
|
public function getKeywordImage($keyword_id,$project_id){
|
176
|
public function getKeywordImage($keyword_id,$project_id){
|
|
178
|
$keywordModel = new Keyword();
|
177
|
$keywordModel = new Keyword();
|
|
179
|
- $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
180
|
- $productModel = new Product();
|
|
|
|
181
|
- $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']);
|
|
|
|
182
|
- if(count($productList) < 5){
|
|
|
|
183
|
- $productList = $productModel->inRandomOrder()->take(100)->get()->toArray();
|
|
|
|
184
|
- //获取7个产品主图
|
|
|
|
185
|
- }
|
|
|
|
186
|
- $product_image = [];
|
|
|
|
187
|
- foreach ($productList as $v){
|
|
|
|
188
|
- $v = (array)$v;
|
|
|
|
189
|
- $image = [];
|
|
|
|
190
|
- if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
|
|
|
|
191
|
- $image['image'] = getImageUrl($v['thumb']['url']);
|
|
|
|
192
|
- $image['title'] = $v['title'];
|
|
|
|
193
|
- $product_image[] = $image;
|
|
|
|
194
|
- }
|
|
|
|
195
|
- if(count($product_image) > 6){
|
|
|
|
196
|
- break;
|
|
|
|
197
|
- }
|
|
|
|
198
|
- }
|
178
|
+ $thumb = $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
179
|
+ //TODO::所有产品
|
|
|
|
180
|
+ $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
|
|
199
|
$domainModel = new DomainInfo();
|
181
|
$domainModel = new DomainInfo();
|
|
200
|
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
|
182
|
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
|
|
201
|
if(!empty($domainInfo)){
|
183
|
if(!empty($domainInfo)){
|
|
@@ -206,8 +188,41 @@ class VideoTask extends Command |
|
@@ -206,8 +188,41 @@ class VideoTask extends Command |
|
206
|
'title'=>$keywordInfo['title'],
|
188
|
'title'=>$keywordInfo['title'],
|
|
207
|
'keyword_title'=>$keywordInfo['keyword_title'],
|
189
|
'keyword_title'=>$keywordInfo['keyword_title'],
|
|
208
|
'keyword_content'=>$keywordInfo['keyword_content'],
|
190
|
'keyword_content'=>$keywordInfo['keyword_content'],
|
|
209
|
- 'product_list'=>$product_image
|
191
|
+ 'product_list'=>$thumb ?? []
|
|
210
|
];
|
192
|
];
|
|
211
|
return $data;
|
193
|
return $data;
|
|
212
|
}
|
194
|
}
|
|
|
|
195
|
+
|
|
|
|
196
|
+ /**
|
|
|
|
197
|
+ * 关键词聚合页-推荐&热门产品
|
|
|
|
198
|
+ */
|
|
|
|
199
|
+ public function getRecommendAndHotProducts($project,$route): ?array
|
|
|
|
200
|
+ {
|
|
|
|
201
|
+ $productIds = [];
|
|
|
|
202
|
+ $productKeyword = Keyword::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
203
|
+ if (!empty($productKeyword)){
|
|
|
|
204
|
+ $productsQuery = Product::where("project_id", $project->id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
|
|
|
|
205
|
+ if (!empty($productsQuery)){
|
|
|
|
206
|
+ foreach ($productsQuery as $item){
|
|
|
|
207
|
+ $productIds[] = $item->id;
|
|
|
|
208
|
+ }
|
|
|
|
209
|
+ if (count($productIds)<7){
|
|
|
|
210
|
+ $randomData = Product::where("project_id", $project->id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();
|
|
|
|
211
|
+ $products = $productsQuery->merge($randomData);
|
|
|
|
212
|
+ }else{
|
|
|
|
213
|
+ $products = $productsQuery;
|
|
|
|
214
|
+ }
|
|
|
|
215
|
+ }else{
|
|
|
|
216
|
+ $products = Product::where("project_id", $project->id)->where("status",1)->inRandomOrder()->take(13)->get();
|
|
|
|
217
|
+ }
|
|
|
|
218
|
+ }
|
|
|
|
219
|
+ $data = [];
|
|
|
|
220
|
+ if (!empty($products)){
|
|
|
|
221
|
+ foreach ($products as $item){
|
|
|
|
222
|
+ $data[] = !empty($item->thumb) && $item->thumb != "[]"? getImageUrl(json_decode($item->thumb)->url) : "";
|
|
|
|
223
|
+ }
|
|
|
|
224
|
+ }
|
|
|
|
225
|
+ return $data;
|
|
|
|
226
|
+ }
|
|
|
|
227
|
+
|
|
213
|
} |
228
|
} |