diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index ea3ccf5..1fa947f 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -68,8 +68,12 @@ class Api_CageController extends Ctrl_Api{ public function addAction(){ //查询笼位号 $data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; - $CageNum = $this->Cagemodel->field('count(*) as num')->where("c_user_id={$data['c_user_id']}")->fRow(); - $CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; + $CageNum = $this->Cagemodel->field('count(*) as num')->where("c_user_id={$data['c_user_id']} and is_delete=0")->fRow(); + if(!empty($this->POST['number'])){ + $uni = $this->Cagemodel->field('*')->where("c_user_id={$data['c_user_id']} and is_delete=0 and number='{$this->POST['number']}'")->fRow(); + if($uni) Tool_Fnc::apiMsg('笼位号已存在', '500'); + } + $CageNum = empty($this->POST['number'])?(int) $CageNum['num']+1:$this->POST['number']; $data['type'] = $this->POST['type']; $data['number'] = $CageNum; $data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?Tool_Fnc::apiMsg('请选择笼位品系', '500'):Tool_Fnc::safe_string($this->POST['strains']);