作者 Your Name
@@ -252,34 +252,14 @@ class VideoTask extends Command @@ -252,34 +252,14 @@ class VideoTask extends Command
252 $productIds[] = $item->id; 252 $productIds[] = $item->id;
253 } 253 }
254 if (count($productIds)<7){ 254 if (count($productIds)<7){
255 - $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();  
256 - $number = 40;  
257 - $array_count = count($product_all_id);  
258 - if ($array_count > 0) {  
259 - $product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds)));  
260 - foreach ($product_id_key as $value_key){  
261 - $project_id_arr[] = $product_all_id[$value_key];  
262 - }  
263 - $randomData = Product::whereIn("id", $project_id_arr)->get();  
264 - $products = $productsQuery->merge($randomData);  
265 - } 255 + $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
  256 + $randomData = Product::whereIn("id", $product_all_id)->get();
  257 + $products = $productsQuery->merge($randomData);
266 }else{ 258 }else{
267 $products = $productsQuery; 259 $products = $productsQuery;
268 } 260 }
269 }else{ 261 }else{
270 - $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();  
271 - shuffle($product_all_id);  
272 - $number = 40;  
273 - $array_count = count($product_all_id);  
274 - if ($array_count > 0)  
275 - {  
276 - $project_id_arr = [];  
277 - $product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds)));  
278 - foreach ($product_id_key as $value_key){  
279 - $project_id_arr[] = $product_all_id[$value_key];  
280 - }  
281 - $products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get();  
282 - } 262 + $products = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
283 } 263 }
284 $data = []; 264 $data = [];
285 if (!empty($products)){ 265 if (!empty($products)){
@@ -213,29 +213,6 @@ class ProductController extends BaseController @@ -213,29 +213,6 @@ class ProductController extends BaseController
213 } 213 }
214 214
215 /** 215 /**
216 - * @remark :获取所有关键词  
217 - * @name :getCategoryList  
218 - * @author :lyh  
219 - * @method :post  
220 - * @time :2023/9/14 13:56  
221 - */  
222 - public function getKeywordsList(){  
223 - $data = Common::get_user_cache('product_keyword',$this->user['project_id']);  
224 - if(empty($data)) {  
225 - $keywordModel = new Keyword();  
226 - $data = [];  
227 - $cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);  
228 - if (!empty($cateList)) {  
229 - foreach ($cateList as $value) {  
230 - $data[$value['id']] = $value['title'];  
231 - }  
232 - }  
233 - Common::set_user_cache($data,'product_keyword',$this->user['project_id']);  
234 - }  
235 - return $data;  
236 - }  
237 -  
238 - /**  
239 * @remark :获取分类名称 216 * @remark :获取分类名称
240 * @name :categoryName 217 * @name :categoryName
241 * @author :lyh 218 * @author :lyh
@@ -170,7 +170,7 @@ class ProjectLogic extends BaseLogic @@ -170,7 +170,7 @@ class ProjectLogic extends BaseLogic
170 //同步信息表 170 //同步信息表
171 (new SyncService())->projectAcceptAddress($this->param['id']); 171 (new SyncService())->projectAcceptAddress($this->param['id']);
172 //双向绑定服务器 172 //双向绑定服务器
173 -// $this->setServers($this->param['server_id'],$this->param['id']); 173 +// $this->setServers($this->param['serve_id'],$this->param['id']);
174 } 174 }
175 return $this->success(); 175 return $this->success();
176 } 176 }
@@ -210,8 +210,8 @@ class ProjectLogic extends BaseLogic @@ -210,8 +210,8 @@ class ProjectLogic extends BaseLogic
210 if(count($project_arr) >= $serversInfo['ip_total']){ 210 if(count($project_arr) >= $serversInfo['ip_total']){
211 $this->fail('请选择其他服务器,当前ip已满'); 211 $this->fail('请选择其他服务器,当前ip已满');
212 } 212 }
213 - if(!in_array($project_id,$project_arr)){  
214 - array_push($project_id); 213 + if(!in_array($project_id,$project_arr) || empty($project_arr)){
  214 + array_push($project_arr,$project_id);
215 $project_str = ','.implode(',',$project_arr).','; 215 $project_str = ','.implode(',',$project_arr).',';
216 $serversIpModel->edit(['project_arr'=>$project_str,'total'=>count($project_arr)],['id'=>$servers_id]); 216 $serversIpModel->edit(['project_arr'=>$project_str,'total'=>count($project_arr)],['id'=>$servers_id]);
217 $serversModel->where(['id'=>$info['servers_id']])->increment('being_number'); 217 $serversModel->where(['id'=>$info['servers_id']])->increment('being_number');
@@ -326,13 +326,10 @@ class ProductLogic extends BaseLogic @@ -326,13 +326,10 @@ class ProductLogic extends BaseLogic
326 * @time :2023/10/20 9:02 326 * @time :2023/10/20 9:02
327 */ 327 */
328 public function handleListCategory($category){ 328 public function handleListCategory($category){
329 - $str = '';  
330 if(isset($category) && !empty($category)){ 329 if(isset($category) && !empty($category)){
331 - foreach ($category as $v){  
332 - $str .= $v.',';  
333 - } 330 + return ','.implode(',',$category).',';
334 } 331 }
335 - return !empty(trim($str,',')) ? ','.$str.',' : ''; 332 + return '';
336 } 333 }
337 334
338 335