예제 #1
0
 /**
  * 删除商品分类
  *
  */
 private function delGoodsClass()
 {
     /*权限检查*/
     $this->checkAdmin('goods_class_move');
     $class_id = intval($this->_input['id']);
     $select_value = intval($this->_input['select']);
     $productClassArray = $this->obj_goods_class->listClassDetail("");
     switch ($select_value) {
         case 1:
             // 删除当前分类包括当前分类的子分类和商品
             //查出所有子集分类
             $sub_class = $this->obj_goods_class->getArrayById($productClassArray, $result, $class_id);
             $sub_class[] = $class_id;
             $rs = $this->obj_goods_class->delGoodsClass($sub_class, "class_id");
             if ($rs) {
                 $rs = $this->obj_goods->delGoods($sub_class, "class_id");
                 if ($rs) {
                     $this->obj_goods_class->createGoodsClassArray();
                     /*日志保存*/
                     $log_array = array();
                     $log_array['log_info'] = $this->_lang['admin_goods_class_goods_del_ok'];
                     $this->obj_log->inLog($log_array);
                     $this->adminMessage($this->_lang['admin_goods_class_goods_del_ok'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
                 } else {
                     /*日志保存*/
                     $log_array = array();
                     $log_array['log_info'] = $this->_lang['admin_goods_class_goods_del_false'];
                     $this->obj_log->inLog($log_array);
                     $this->adminMessage($this->_lang['admin_goods_class_goods_del_false'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
                 }
             } else {
                 /*日志保存*/
                 $log_array = array();
                 $log_array['log_info'] = $this->_lang['admin_goods_class_goods_del_false'];
                 $this->obj_log->inLog($log_array);
                 $this->adminMessage($this->_lang['admin_goods_class_goods_del_false'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
             }
             break;
         case 2:
             //删除当前分类,移动子分类和商品
             $class_top_id = $this->_input['txt_class_top_id' . $class_id . "_2"];
             if ($class_top_id == 0) {
                 $this->adminMessage($this->_lang['admin_goods_class_list_select_error'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
             }
             $input_param['class_top_id'] = intval($class_top_id);
             $sub_one_class = $this->obj_goods_class->getArrayById($productClassArray, $result, $class_id);
             /* 检查修改的分类topid是否是当前分类的下级,如果是返回错误,不是的话,正常进行 */
             $sub_one_class[] = $class_id;
             if ($sub_one_class != null) {
                 if (in_array($class_top_id, $sub_one_class)) {
                     $this->adminMessage($this->_lang['admin_goods_class_list_del_error1'], $this->refer_url, 1, 3000);
                 }
             }
             /* 查出下一级分类 */
             $sub_one_class = array();
             $sub_one_class = $this->obj_goods_class->getOneArrayById($productClassArray, $result, $class_id);
             $sub_one_class_string = empty($sub_one_class) ? $class_id : @implode(",", $sub_one_class) . ',' . $class_id;
             /* 移动子类 */
             $update_class = $this->obj_goods_class->modifyMoreGoodsClass($input_param, array("more_id" => $sub_one_class_string));
             /* 移动当前类商品 */
             $update_goods = $this->obj_goods->modifyGoods($class_top_id, $class_id, "class_id", "class_id");
             /* 删除当前类 */
             $input['class_id'] = $class_id;
             $del_goods_class = $this->obj_goods_class->delGoodsClass($input, "class_id");
             if ($del_goods_class) {
                 $this->obj_goods_class->createGoodsClassArray();
                 $this->adminMessage($this->_lang['admin_goods_oper_succ'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
             }
             break;
         case 3:
             //删除当前分类和子分类,只移动商品
             $class_top_id = $this->_input['txt_class_top_id' . $class_id . "_2"];
             if ($class_top_id == 0) {
                 $this->adminMessage($this->_lang['admin_goods_class_list_select_error'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
             }
             //查出所有子集分类
             $sub_class = $this->obj_goods_class->getArrayById($productClassArray, $result, $class_id);
             $sub_class[] = $class_id;
             /* 检查修改的分类topid是否是当前分类的下级,如果是返回错误,不是的话,正常进行 */
             if ($sub_class != null) {
                 if (in_array($class_top_id, $sub_class)) {
                     $this->adminMessage($this->_lang['admin_goods_class_list_del_error'], $this->refer_url, 1, 3000);
                 }
             }
             $sub_class_string = @implode(",", $sub_class);
             $rs = $this->obj_goods_class->delGoodsClass($sub_class, "class_id");
             if ($rs) {
                 $input_param['class_id'] = $class_top_id;
                 $this->obj_goods->moveGoods($input_param, array("more_id" => $sub_class_string));
                 $this->obj_goods_class->createGoodsClassArray();
                 $this->adminMessage($this->_lang['admin_goods_oper_succ'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 1000);
             } else {
                 $this->adminMessage($this->_lang['admin_goods_oper_fill'], $this->_configinfo['websit']['site_url'] . "/admin/admin_goods_class.php?action=list", 1, 4000);
             }
             break;
     }
 }