yangsai@163.com 5 months ago
parent 51ed65efb6
commit 28c252d709
  1. 15
      application/controllers/Api/Cage.php
  2. 14
      application/models/Squirrel.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";

@ -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;
}

Loading…
Cancel
Save