yangsai@163.com 8 months ago
parent 8b1730725e
commit 8b0a49cdf3
  1. 8
      application/controllers/Api/Squirrel.php

@ -185,16 +185,16 @@ class Api_SquirrelController extends Ctrl_Api{
$cageinfo = $this->CageModel->field("id,type")->where("id={$squirrelinfo['cage']}")->fRow();
if($cageinfo['type']==2){
if($data['sex']==1){
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$cageinfo['id']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500');
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$cageinfo['id']} and id!={$data['id']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500');
}if($data['sex']==2){
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=2 and cage={$cageinfo['id']}")->fList()['num']==2) Tool_Fnc::apiMsg('该笼母鼠已上限', '500');
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=2 and cage={$cageinfo['id']} and id!={$data['id']}")->fList()['num']==2) Tool_Fnc::apiMsg('该笼母鼠已上限', '500');
}
}else{
//查询笼位是否有不同性别鼠
if($data['sex']==1){
if(!empty($this->Squirrelmodel->field("*")->where("sex=2 and cage={$cageinfo['id']}")->fRow())) Tool_Fnc::apiMsg('该笼只能添加母鼠', '500');
if(!empty($this->Squirrelmodel->field("*")->where("sex=2 and cage={$cageinfo['id']} and id!={$data['id']}")->fRow())) Tool_Fnc::apiMsg('该笼只能添加母鼠', '500');
}if($data['sex']==2){
if(!empty($this->Squirrelmodel->field("*")->where("sex=1 and cage={$cageinfo['id']}")->fRow())) Tool_Fnc::apiMsg('该笼只能添加公鼠', '500');
if(!empty($this->Squirrelmodel->field("*")->where("sex=1 and cage={$cageinfo['id']} and id!={$data['id']}")->fRow())) Tool_Fnc::apiMsg('该笼只能添加公鼠', '500');
}
}
//获取当前用户仓鼠的配置

Loading…
Cancel
Save