作者 Your Name
... ... @@ -252,34 +252,14 @@ class VideoTask extends Command
$productIds[] = $item->id;
}
if (count($productIds)<7){
$product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0) {
$product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds)));
foreach ($product_id_key as $value_key){
$project_id_arr[] = $product_all_id[$value_key];
}
$randomData = Product::whereIn("id", $project_id_arr)->get();
$products = $productsQuery->merge($randomData);
}
$product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
$randomData = Product::whereIn("id", $product_all_id)->get();
$products = $productsQuery->merge($randomData);
}else{
$products = $productsQuery;
}
}else{
$product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
shuffle($product_all_id);
$number = 40;
$array_count = count($product_all_id);
if ($array_count > 0)
{
$project_id_arr = [];
$product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds)));
foreach ($product_id_key as $value_key){
$project_id_arr[] = $product_all_id[$value_key];
}
$products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get();
}
$products = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
}
$data = [];
if (!empty($products)){
... ...
... ... @@ -213,29 +213,6 @@ class ProductController extends BaseController
}
/**
* @remark :获取所有关键词
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getKeywordsList(){
$data = Common::get_user_cache('product_keyword',$this->user['project_id']);
if(empty($data)) {
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
}
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
... ...
... ... @@ -170,7 +170,7 @@ class ProjectLogic extends BaseLogic
//同步信息表
(new SyncService())->projectAcceptAddress($this->param['id']);
//双向绑定服务器
// $this->setServers($this->param['server_id'],$this->param['id']);
// $this->setServers($this->param['serve_id'],$this->param['id']);
}
return $this->success();
}
... ... @@ -210,8 +210,8 @@ class ProjectLogic extends BaseLogic
if(count($project_arr) >= $serversInfo['ip_total']){
$this->fail('请选择其他服务器,当前ip已满');
}
if(!in_array($project_id,$project_arr)){
array_push($project_id);
if(!in_array($project_id,$project_arr) || empty($project_arr)){
array_push($project_arr,$project_id);
$project_str = ','.implode(',',$project_arr).',';
$serversIpModel->edit(['project_arr'=>$project_str,'total'=>count($project_arr)],['id'=>$servers_id]);
$serversModel->where(['id'=>$info['servers_id']])->increment('being_number');
... ...
... ... @@ -326,13 +326,10 @@ class ProductLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function handleListCategory($category){
$str = '';
if(isset($category) && !empty($category)){
foreach ($category as $v){
$str .= $v.',';
}
return ','.implode(',',$category).',';
}
return !empty(trim($str,',')) ? ','.$str.',' : '';
return '';
}
... ...