作者 赵彬吉

update

... ... @@ -116,6 +116,6 @@ class CategoryLogic extends BaseLogic
*/
public function getProductNum($cate_id){
$cate_ids = $this->model->getChildIdsArr($cate_id);
return CategoryRelated::whereIn('cate_id', $cate_ids)->count();
return CategoryRelated::whereIn('cate_id', $cate_ids)->distinct()->count('product_id');
}
}
... ...
... ... @@ -92,6 +92,6 @@ class KeywordLogic extends BaseLogic
}
public function getProductNum($keyword_id){
return KeywordRelated::where('keyword_id', $keyword_id)->count();
return KeywordRelated::where('keyword_id', $keyword_id)->distinct()->count('product_id');
}
}
... ...
... ... @@ -86,7 +86,15 @@ class ProductLogic extends BaseLogic
DB::beginTransaction();
try {
foreach ($ids as $id){
foreach ($ids as $k => $id) {
$info = $this->getCacheInfo($id);
if(!$info){
unset($ids[$k]);
continue;
}
if($info->status == Product::STATUS_RECYCLE){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
... ... @@ -95,6 +103,12 @@ class ProductLogic extends BaseLogic
//删除关键词关联
KeywordRelated::where('product_id', $id)->delete();
}else{
//回收站
$info->status = Product::STATUS_RECYCLE;
$info->save();
unset($ids[$k]);
}
}
parent::delete($ids);
... ...