作者 赵彬吉

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,15 +86,29 @@ class ProductLogic extends BaseLogic
DB::beginTransaction();
try {
foreach ($ids as $id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
foreach ($ids as $k => $id) {
//删除分类关联
CategoryRelated::where('product_id', $id)->delete();
$info = $this->getCacheInfo($id);
if(!$info){
unset($ids[$k]);
continue;
}
//删除关键词关联
KeywordRelated::where('product_id', $id)->delete();
if($info->status == Product::STATUS_RECYCLE){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//删除分类关联
CategoryRelated::where('product_id', $id)->delete();
//删除关键词关联
KeywordRelated::where('product_id', $id)->delete();
}else{
//回收站
$info->status = Product::STATUS_RECYCLE;
$info->save();
unset($ids[$k]);
}
}
parent::delete($ids);
... ...