作者 lyh

修改服務器配置

@@ -235,7 +235,7 @@ class VideoTask extends Command @@ -235,7 +235,7 @@ class VideoTask extends Command
235 } 235 }
236 } 236 }
237 //TODO::所有产品 237 //TODO::所有产品
238 - $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); 238 + $thumb = $this->getRecommendAndHotProducts($keyword_id,$project_id);
239 $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray(); 239 $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
240 $data = [ 240 $data = [
241 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'], 241 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'],
@@ -251,39 +251,38 @@ class VideoTask extends Command @@ -251,39 +251,38 @@ class VideoTask extends Command
251 /** 251 /**
252 * 关键词聚合页-推荐&热门产品 252 * 关键词聚合页-推荐&热门产品
253 */ 253 */
254 - public function getRecommendAndHotProducts($route,$project_id): ?array 254 + public function getRecommendAndHotProducts($keyword_id,$project_id): ?array
255 { 255 {
256 $productIds = []; 256 $productIds = [];
257 - $productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();  
258 - if (!empty($productKeyword)){  
259 - $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();  
260 - if (!empty($productsQuery)){  
261 - foreach ($productsQuery as $item){  
262 - $productIds[] = $item->id;  
263 - }  
264 - if (count($productIds)<7){  
265 - $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();  
266 - $number = 40;  
267 - $array_count = count($product_all_id);  
268 - if ($array_count > 0) {  
269 - $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));  
270 - $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();  
271 - $products = $productsQuery->merge($randomData);  
272 - }  
273 - }else{  
274 - $products = $productsQuery;  
275 - }  
276 - }else{  
277 - $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 257 + $productKeyword = Keyword::where("project_id",$project_id)->where("id",$keyword_id)->first();
  258 + $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
  259 + if (!empty($productsQuery)){
  260 + foreach ($productsQuery as $item){
  261 + $productIds[] = $item->id;
  262 + }
  263 + if (count($productIds)<7){
  264 + $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
278 $number = 40; 265 $number = 40;
279 $array_count = count($product_all_id); 266 $array_count = count($product_all_id);
280 - if ($array_count > 0)  
281 - {  
282 - $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));  
283 - $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 267 + if ($array_count > 0) {
  268 + $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));
  269 + $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
  270 + $products = $productsQuery->merge($randomData);
284 } 271 }
  272 + }else{
  273 + $products = $productsQuery;
  274 + }
  275 + }else{
  276 + $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  277 + $number = 40;
  278 + $array_count = count($product_all_id);
  279 + if ($array_count > 0)
  280 + {
  281 + $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
  282 + $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
285 } 283 }
286 } 284 }
  285 +
287 $data = []; 286 $data = [];
288 if (!empty($products)){ 287 if (!empty($products)){
289 foreach ($products as $item){ 288 foreach ($products as $item){
@@ -38,7 +38,7 @@ class ServersIpController extends BaseController @@ -38,7 +38,7 @@ class ServersIpController extends BaseController
38 $this->response('當前服務器不存在',Code::SERVER_ERROR); 38 $this->response('當前服務器不存在',Code::SERVER_ERROR);
39 } 39 }
40 $serversIpModel = new ServersIpModel(); 40 $serversIpModel = new ServersIpModel();
41 - $this->map['total'] = ['<',$info['ip_num']]; 41 + $this->map['total'] = ['<',$info['ip_total']];
42 $data = $serversIpModel->list($this->map); 42 $data = $serversIpModel->list($this->map);
43 $this->response('success',Code::SUCCESS,$data); 43 $this->response('success',Code::SUCCESS,$data);
44 } 44 }