yangsai@163.com 7 months ago
parent 8f14b881d7
commit 6be570d36d
  1. 4
      application/controllers/Api/Squirrel.php
  2. 9
      application/models/Squirrel.php

@ -117,7 +117,7 @@ class Api_SquirrelController extends Ctrl_Api{
$data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday']))); $data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday'])));
//查询笼位类型 //查询笼位类型
$cageinfo = $this->CageModel->field("type")->where("id={$data['cage']}")->fRow(); $cageinfo = $this->CageModel->field("type")->where("id={$data['cage']}")->fRow();
if($cageinfo==2){ if($cageinfo['type']==2){
if($data['sex']==1){ if($data['sex']==1){
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$data['cage']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500'); if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$data['cage']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500');
}if($data['sex']==2){ }if($data['sex']==2){
@ -183,7 +183,7 @@ class Api_SquirrelController extends Ctrl_Api{
$data['created'] = date('Y-m-d H:i:s',time()); $data['created'] = date('Y-m-d H:i:s',time());
$squirrelinfo = $this->Squirrelmodel->field("*")->where("id={$data['id']}")->fRow(); $squirrelinfo = $this->Squirrelmodel->field("*")->where("id={$data['id']}")->fRow();
$cageinfo = $this->CageModel->field("type")->where("id={$squirrelinfo['cage']}")->fRow(); $cageinfo = $this->CageModel->field("type")->where("id={$squirrelinfo['cage']}")->fRow();
if($cageinfo==2){ if($cageinfo['type']==2){
if($data['sex']==1){ if($data['sex']==1){
if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$data['cage']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500'); if((int)$this->Squirrelmodel->field("count(*) num")->where("sex=1 and cage={$data['cage']}")->fList()['num']==1) Tool_Fnc::apiMsg('该笼公鼠已上限', '500');
}if($data['sex']==2){ }if($data['sex']==2){

@ -79,9 +79,16 @@ class SquirrelModel extends Orm_Base{
} }
public function partent($cage){ public function partent($cage){
$time = date('Y-m-d',time()); $time = date('Y-m-d',time());
$exec=$this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}'"); $exec=$this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}'");
if(!empty($cage))$exec->where("cage={$cage}"); if(!empty($cage)){
$CageModel = new CageModel();
$cageinfo = $CageModel->field("type")->where("id={$cage}")->fRow();
if($cageinfo['type']==2) $exec->where("cage={$cage}");
}
$data = $exec->fList(); $data = $exec->fList();
$data[] = ['id'=>0,number=>"暂无",'sex'=>2];
$data[] = ['id'=>0,number=>"暂无",'sex'=>1];
return $data; return $data;
} }
public function getIcon($squirrel){ public function getIcon($squirrel){

Loading…
Cancel
Save