作者 赵彬吉

update

@@ -116,6 +116,6 @@ class CategoryLogic extends BaseLogic @@ -116,6 +116,6 @@ class CategoryLogic extends BaseLogic
116 */ 116 */
117 public function getProductNum($cate_id){ 117 public function getProductNum($cate_id){
118 $cate_ids = $this->model->getChildIdsArr($cate_id); 118 $cate_ids = $this->model->getChildIdsArr($cate_id);
119 - return CategoryRelated::whereIn('cate_id', $cate_ids)->count(); 119 + return CategoryRelated::whereIn('cate_id', $cate_ids)->distinct()->count('product_id');
120 } 120 }
121 } 121 }
@@ -92,6 +92,6 @@ class KeywordLogic extends BaseLogic @@ -92,6 +92,6 @@ class KeywordLogic extends BaseLogic
92 } 92 }
93 93
94 public function getProductNum($keyword_id){ 94 public function getProductNum($keyword_id){
95 - return KeywordRelated::where('keyword_id', $keyword_id)->count(); 95 + return KeywordRelated::where('keyword_id', $keyword_id)->distinct()->count('product_id');
96 } 96 }
97 } 97 }
@@ -86,7 +86,15 @@ class ProductLogic extends BaseLogic @@ -86,7 +86,15 @@ class ProductLogic extends BaseLogic
86 86
87 DB::beginTransaction(); 87 DB::beginTransaction();
88 try { 88 try {
89 - foreach ($ids as $id){ 89 + foreach ($ids as $k => $id) {
  90 +
  91 + $info = $this->getCacheInfo($id);
  92 + if(!$info){
  93 + unset($ids[$k]);
  94 + continue;
  95 + }
  96 +
  97 + if($info->status == Product::STATUS_RECYCLE){
90 //删除路由映射 98 //删除路由映射
91 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 99 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
92 100
@@ -95,6 +103,12 @@ class ProductLogic extends BaseLogic @@ -95,6 +103,12 @@ class ProductLogic extends BaseLogic
95 103
96 //删除关键词关联 104 //删除关键词关联
97 KeywordRelated::where('product_id', $id)->delete(); 105 KeywordRelated::where('product_id', $id)->delete();
  106 + }else{
  107 + //回收站
  108 + $info->status = Product::STATUS_RECYCLE;
  109 + $info->save();
  110 + unset($ids[$k]);
  111 + }
98 } 112 }
99 parent::delete($ids); 113 parent::delete($ids);
100 114