From 33d6be13e122b3c7c2eeb3d5e001abfee025f4bc Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Tue, 18 Jun 2024 13:47:39 +0800 Subject: [PATCH] ys --- application/controllers/Api/Cage.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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']);