Example #1
0
 /**
  * 把商品从一个分类转移到另外一个分类
  * @param $f3
  */
 public function TransferGoods($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_goods_category_edit');
     // 参数验证
     $validator = new Validator($f3->get('POST'));
     $meta_id = $validator->required()->digits()->min(1)->validate('meta_id');
     $target_meta_id = $validator->required('必须选择一个目标分类')->digits()->min(1)->validate('target_meta_id');
     if (!$this->validate($validator)) {
         goto out;
     }
     if ($meta_id == $target_meta_id) {
         $this->addFlashMessage('目标分类不能是自己');
         goto out;
     }
     $goodsCategoryService = new GoodsCategoryService();
     $goodsCategoryService->transferGoodsToNewCategory($meta_id, $target_meta_id);
     $this->addFlashMessage('商品转移成功');
     $this->addFlashMessage('注意:商品转移只是当前分类商品,不包括子分类的商品');
     out:
     RouteHelper::reRoute($this, RouteHelper::getRefer(), false);
 }