@ -269,9 +269,9 @@ class Api_SquirrelController extends Ctrl_Api{
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$data['count'] =empty($this->POST['count'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('填写幼崽数量', '500'):Tool_Fnc::safe_string($this->POST['count']);
$data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请选择生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']);
$data['father'] = empty($this->POST['father'])||!isset($this->POST['father'])?0 :Tool_Fnc::safe_string($this->POST['father']);
$data['mother'] = empty($this->POST['mother'])||!isset($this->POST['father'])?0 :Tool_Fnc::safe_string($this->POST['mother']);
$data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?Tool_Fnc::apiMsg('请填写品系', '500') :Tool_Fnc::safe_string($this->POST['strains']);
$data['father'] = empty($this->POST['father'])||!isset($this->POST['father'])?"" :Tool_Fnc::safe_string($this->POST['father']);
$data['mother'] = empty($this->POST['mother'])||!isset($this->POST['father'])?"" :Tool_Fnc::safe_string($this->POST['mother']);
$data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?"" :Tool_Fnc::safe_string($this->POST['strains']);
$data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?"":Tool_Fnc::safe_string($this->POST['gene']);
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']);
$data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']);
@ -295,9 +295,9 @@ class Api_SquirrelController extends Ctrl_Api{
$data['id'] = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($this->POST['id']);
$data['count'] =empty($this->POST['count'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('填写幼崽数量', '500'):Tool_Fnc::safe_string($this->POST['count']);
$data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请选择生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']);
$data['father'] = empty($this->POST['father'])||!isset($this->POST['father'])?0 :Tool_Fnc::safe_string($this->POST['father']);
$data['mother'] = empty($this->POST['mother'])||!isset($this->POST['father'])?0 :Tool_Fnc::safe_string($this->POST['mother']);
$data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?Tool_Fnc::apiMsg('请填写品系', '500') :Tool_Fnc::safe_string($this->POST['strains']);
$data['father'] = empty($this->POST['father'])||!isset($this->POST['father'])?'' :Tool_Fnc::safe_string($this->POST['father']);
$data['mother'] = empty($this->POST['mother'])||!isset($this->POST['father'])?'' :Tool_Fnc::safe_string($this->POST['mother']);
$data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?"" :Tool_Fnc::safe_string($this->POST['strains']);
$data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?"":Tool_Fnc::safe_string($this->POST['gene']);
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']);
$data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']);
@ -357,11 +357,53 @@ class Api_SquirrelController extends Ctrl_Api{
}
public function jianweiAction(){
$number = empty($this->POST['number'])?Tool_Fnc::apiMsg('请输入编号', '500'):$this->POST['number'];
$id = empty($this->POST['id'])?Tool_Fnc::apiMsg('缺少参数', '500'):$this->POST['id'];
$bianhao = explode('-',$number);
//获取号段编号
$start = (int) filter_var($bianhao[0], FILTER_SANITIZE_NUMBER_INT);
$end = (int) filter_var($bianhao[1], FILTER_SANITIZE_NUMBER_INT);
echo $start;
echo $end;die;
$qianzui = rtrim($bianhao[0],$start);
$a = 1;
//判断开始结束号段标志是否相同
if(strrpos($qianzui,rtrim($bianhao[1],$end))===false) Tool_Fnc::apiMsg('号段编号不同', '500');
//查询幼鼠信息
$NSdata = $this->NewSquirrelmodel->getOneInfo($id);
//判断编号数量和小鼠数量是否相同
if($NSdata['count']!=($end-$start)) Tool_Fnc::apiMsg('编号数量小于剪尾鼠', '500');
unset($NSdata['count']);
unset($NSdata['id']);
unset($NSdata['cage']);
$lastafter = $qianzui;
//整理新生小鼠信息
for ($i = $start;$i< =$end;$i++){
$after = substr($bianhao[0], 0 , strlen($bianhao[0])-strlen($i));
$NSdata['number'] = is_numeric(substr($lastafter, -1))?$after.$i:$lastafter.$i;
$NSdata['jianwei_time'] = date("Y-m-d",time());
$NSdata['cage'] = $NSdata['cage_id'];
$NSdata['type'] = 2;
$data[] = $NSdata;
//判断编号是否存在
if(!empty($this->Squirrelmodel->where("number = '{$NSdata['number']}'")->fRow())){
Tool_Fnc::apiMsg("已存在编号{$NSdata['number']}", '500');
}
$a++;
}
//开始事务
$this->Squirrelmodel->begin();
if(!$this->Squirrelmodel->inserts($data)) {
$this->Squirrelmodel->back();
Tool_Fnc::apiMsg('剪尾标记失败', '1');
}
$ndata['id'] = $id;
$ndata['is_fen'] = 1;
$ndata['fen_num'] = $end-$start;
if($a != ($end-$start) & & !$this->NewSquirrelmodel->update($ndata)) {
$this->Squirrelmodel->back();
Tool_Fnc::apiMsg('剪尾标记失败', '1');
}
//结束事务
$this->Squirrelmodel->commit();
Tool_Fnc::apiMsg('剪尾完成', '1');
}
}