From 28c252d7091bce5ef4121b2e4681832ea4a9e097 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Wed, 19 Jun 2024 18:18:12 +0800 Subject: [PATCH] YS --- application/controllers/Api/Cage.php | 15 ++++++++++++++- application/models/Squirrel.php | 14 +++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index 1fa947f..4ad2548 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -136,10 +136,23 @@ class Api_CageController extends Ctrl_Api{ if(!$this->SquirrelModel->update($data)) Tool_Fnc::apiMsg('笼位未发生变化', '500'); Tool_Fnc::apiMsg('转移成功', '200'); } + public function cageMoreMoveAction(){ + $uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; + $id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID', '500'):implode(",",$this->POST['id']); + $cage = empty($this->POST['cage'])?Tool_Fnc::apiMsg('笼位ID', '500'):$this->POST['cage']; + $sql = "update {$this->SquirrelModel->table} set cage={$cage},type=1 where id in ({$id})"; + if(!$this->SquirrelModel->exec($sql)) Tool_Fnc::apiMsg('转移失败', '500'); + Tool_Fnc::apiMsg('转移成功', '200'); + } //获取转移笼位列表 public function cagemovellistAction(){ $uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; $id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID', '500'):$this->POST['id']; + $count = 1; + if(is_array($id)){ + $count = count($id); + $id = $id[0]; + } $order = empty($this->POST['order'])?'id':$this->POST['order']; $keyword = empty($this->POST['keyword'])?'':$this->POST['keyword']; $squirrel = $this->SquirrelModel->getOneInfo($id); @@ -152,7 +165,7 @@ class Api_CageController extends Ctrl_Api{ $data = $data->fList(); foreach($data as $key => $val){ $data[$key]['type_color'] = $data[$key]['type']==2?'#FF0000':''; - if($this->SquirrelModel->isFull($val['cage'],$uid)) { + if($this->SquirrelModel->isFull($val['cage'],$uid,($count-1))) { $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 and type=1"; diff --git a/application/models/Squirrel.php b/application/models/Squirrel.php index b19018b..de49fc0 100644 --- a/application/models/Squirrel.php +++ b/application/models/Squirrel.php @@ -52,7 +52,7 @@ class SquirrelModel extends Orm_Base{ return $data; } - public function isFull($cage,$uid){ + public function isFull($cage,$uid,$numbj=0){ $params['user_id'] = $uid; $CageSetModel = new CageSetModel(); $time = date('Y-m-d',time()); @@ -64,15 +64,19 @@ class SquirrelModel extends Orm_Base{ $big = $this->field('count(*) num')->where("cage={$cage} and is_delete=0 and is_kill=0 and nursing_time<'{$time}'")->fRow(); $data = true; if($small['num']>0&&$big['num']>0){ - if($cageSet['big_small_num']<=$big['num']) $data = false; + if($cageSet['big_small_num']<=$big['num'] || ($cageSet['big_small_num']-$big['num'])<$numbj) $data = false; } if($small['num']>0&&$big['num']==0){ - if($cageSet['small_num_max']<=$big['num']) $data = false; + if($cageSet['small_num_max']<=$big['num'] || ($cageSet['small_num_max']-$big['num'])<$numbj) $data = false; } if($small['num']==0&&$big['num']>0){ - if($cageSet['big_num_max']<=$big['num']) $data = false; + if($cageSet['big_num_max']<=$big['num'] || ($cageSet['big_num_max']-$big['num'])<$numbj ) $data = false; }else{ - $data = true; + if(($cageSet['big_num_max']-$big['num'])<$numbj){ + $data = false; + }else{ + $data = true; + } } return $data; }