yangsai@163.com 6 months ago
parent 82d90d40ae
commit da233c58a9
  1. 13
      application/controllers/Api/Squirrel.php
  2. 9
      application/models/NewSquirrel.php
  3. 3
      application/models/Squirrel.php

@ -405,5 +405,18 @@ class Api_SquirrelController extends Ctrl_Api{
$this->Squirrelmodel->commit();
Tool_Fnc::apiMsg('剪尾完成', '1');
}
public function setsexAction(){
$cage = empty($this->POST['cage'])?Tool_Fnc::apiMsg('笼位号丢失', '500'):$this->POST['cage'];
$sex = empty($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):$this->POST['sex'];
$unsex = $sex==1?2:1;
$squirrel = empty($this->POST['squirrel'])?Tool_Fnc::apiMsg('请选择幼崽', '500'):$this->POST['squirrel'];
$str = implode("','",$squirrel);
$sql = "update {$this->Squirrelmodel->table} set sex={$sex} where number in ('{$str}') and type=2 and cage={$cage}";
$unsql = "update {$this->Squirrelmodel->table} set sex={$unsex} where number not in ('{$str}') and type=2 and cage={$cage}";
if($this->Squirrelmodel->exec($sql)&&$this->Squirrelmodel->exec($unsql)){
Tool_Fnc::apiMsg('设置成功', '1');
}
Tool_Fnc::apiMsg('设置失败', '500');
}
}

@ -35,8 +35,8 @@ class NewSquirrelModel extends Orm_Base{
$CageModel = new CageModel();
$SquirrelModel = new SquirrelModel();
//获取幼崽信息
$data=$this->field('id,count,birthday,father,mother,strains,gene,remark,cage,is_fen')->where("id>0 {$params['where']}")->fList();
foreach($data as $key => &$val){
$data['wj']=$this->field('id,count,birthday,father,mother,strains,gene,remark,cage,is_fen')->where("id>0 {$params['where']}")->fList();
foreach($data['wj'] as $key => &$val){
if($val['is_fen']==1){
unset($data[$key]);
}else{
@ -44,12 +44,11 @@ class NewSquirrelModel extends Orm_Base{
$val['icon'] = Yaf_Registry::get("config")->web->url->img."/public/icon/small.png";
}
}
$jian = $SquirrelModel->field('id,number,birthday,father,mother,strains_id as strains,gene,remark,cage')->where("type=2 {$params['where']}")->fList();
foreach($jian as $key => &$va){
$data['j'] = $SquirrelModel->field('id,number,birthday,father,mother,strains_id as strains,gene,remark,cage')->where("type=2 {$params['where']}")->fList();
foreach($data['j'] as $key => &$va){
$va['cage'] = $CageModel->field('number')->where("id={$va['cage']}")->fRow()['number'];
$va['icon'] = Yaf_Registry::get("config")->web->url->img."/public/icon/small.png";
}
$data = array_merge($data,$jian);
return $data;
}
public function getOneInfo($squirrel){

@ -45,7 +45,8 @@ class SquirrelModel extends Orm_Base{
$val['icon'] = $this->getIcon($val['id'])['icon'];
}
//获取繁殖笼幼崽信息
$data['youzailishi'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params):[];
$data['youzailishi'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['wj']:[];
$data['youzailishijianwei'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['j']:[];
return $data;

Loading…
Cancel
Save