diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index 5d95b6f..ea3ccf5 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -149,15 +149,16 @@ class Api_CageController extends Ctrl_Api{ foreach($data as $key => $val){ $data[$key]['type_color'] = $data[$key]['type']==2?'#FF0000':''; if($this->SquirrelModel->isFull($val['cage'],$uid)) { + $data[$key]['squirrel'] = $this->SquirrelModel->query("select number from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and type=1 limit 0,6"); //查询公鼠 - $sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=1"; + $sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=1 and type=1"; $mannum = $this->Cagemodel->query($sql); if(!empty($mannum)){ $data[$key]['mannum'] = $mannum[0]['num']; // if(($val['type']==2 && $squirrel['sex']==1) || $squirrel['sex']==2) unset($data[$key]); } //查询母鼠 - $sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=2"; + $sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=2 and type=1"; $womannum = $this->Cagemodel->query($sql); if(!empty($womannum)){ $data[$key]['womannum'] = $womannum[0]['num']; @@ -165,16 +166,16 @@ class Api_CageController extends Ctrl_Api{ } if($val['type']==2){ if($squirrel['sex']==1){ - if((int)$this->SquirrelModel->field("count(*) num")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']}")->fList()['num']==1) unset($data[$key]); + if((int)$this->SquirrelModel->field("count(*) num")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fList()['num']==1) unset($data[$key]); }if($squirrel['sex']==2){ - if((int)$this->SquirrelModel->field("count(*) num")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']}")->fList()['num']==2) unset($data[$key]); + if((int)$this->SquirrelModel->field("count(*) num")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fList()['num']==2) unset($data[$key]); } }else{ //查询笼位是否有不同性别鼠 if($squirrel['sex']==1){ - if(!empty($this->SquirrelModel->field("*")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']}")->fRow())) unset($data[$key]); + if(!empty($this->SquirrelModel->field("*")->where("sex=2 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fRow())) unset($data[$key]); }if($squirrel['sex']==2){ - if(!empty($this->SquirrelModel->field("*")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']}")->fRow())) unset($data[$key]); + if(!empty($this->SquirrelModel->field("*")->where("sex=1 and cage={$val['id']} and id!={$squirrel['id']} and type=1")->fRow())) unset($data[$key]); } } }else{