作者 赵彬吉
... ... @@ -77,7 +77,7 @@ class AyrReleaseController extends BaseController
//统一生成发布
foreach ($this->param['platforms'] as $value){
if($value == 'youtube'){
$param['youTubeOptions'] = json_encode(['title'=>$this->param['title']]);
$param['youTubeOptions'] = ['title'=>$this->param['title']];
}
}
... ...
... ... @@ -40,7 +40,7 @@ class CategoryController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = $category->getProductNum($v['id']);
$v['product_num'] = $category->getProductNum($list,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
... ...
... ... @@ -115,9 +115,12 @@ class ProductController extends BaseController
$query = $query->where('project_id',$this->user['project_id']);
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
$str[] = $this->map['category_id'];
$str = $this->getAllSub($this->map['category_id'],$str);
$productArr = CategoryRelated::whereIn('cate_id',$str)->pluck('product_id')->toArray();
$query->whereIn('id',$productArr);
$this->getAllSub($this->map['category_id'],$str);
$query->where(function ($subQuery) use ($str) {
foreach ($str as $v) {
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
}
});
}
if(isset($this->map['title']) && !empty($this->map['title'])){
$query = $query->where('title','like','%'.$this->map['title'].'%');
... ...
... ... @@ -215,7 +215,7 @@ class ProductLogic extends BaseLogic
try {
if(isset($this->param['route']) && !empty($this->param['route'])){
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
$this->editProductRoute($this->param['id'],$this->param['route']);
// $this->editProductRoute($this->param['id'],$this->param['route']);
}
$this->model->edit($this->param,['id'=>$this->param['id']]);
//产品分类关联
... ...
... ... @@ -48,12 +48,11 @@ class Category extends Base
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->list(['pid'=>$id,'status'=>1],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
public function getAllSub($list,$id,&$str = []){
foreach ($list as $k =>$v){
if($v['pid'] == $id){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
$this->getAllSub($list,$v['id'],$str);
}
}
return $str;
... ... @@ -66,9 +65,9 @@ class Category extends Base
* @author zbj
* @date 2023/4/28
*/
public function getProductNum($cate_id){
public function getProductNum($list,$cate_id){
$str[] = $cate_id;
$cate_ids = $this->getAllSub($cate_id,$str);
$cate_ids = $this->getAllSub($list,$cate_id,$str);
$productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->unique()->toArray();
$count = count($productArr);
return $count;
... ...