Compare commits

...

2 Commits

Author SHA1 Message Date
yangsai@163.com 2db25c42e6 YS 6 months ago
yangsai@163.com 76f9b51193 YS 6 months ago
  1. 13
      application/controllers/Api/Cage.php
  2. 6
      application/models/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{

@ -37,19 +37,19 @@ class CageModel extends Orm_Base{
//查询鼠编号
$val['squirrel'] = $this->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={$val['id']} and is_kill=0 and is_delete=0 and sex=1";
$sql = "select count(*) num from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and sex=1 and type=1";
$mannum = $this->query($sql);
if(!empty($mannum)){
$val['mannum'] = $mannum[0]['num'];
}
//查询母鼠
$sql = "select count(*) num from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and sex=2";
$sql = "select count(*) num from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and sex=2 and type=1";
$womannum = $this->query($sql);
if(!empty($womannum)){
$val['womannum'] = $womannum[0]['num'];
}
//查询其他
$sql = "select count(*) num from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and sex=0";
$sql = "select count(*) num from squirrel where cage={$val['id']} and is_kill=0 and is_delete=0 and sex=0 and type=1";
$othernum = $this->query($sql);
if(!empty($othernum)){
$val['othernum'] = $othernum[0]['num'];

Loading…
Cancel
Save