|
|
|
@ -84,11 +84,13 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
|
*/ |
|
|
|
|
public function addAction(){ |
|
|
|
|
//查询笼位号 |
|
|
|
|
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow(); |
|
|
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; |
|
|
|
|
// $CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow(); |
|
|
|
|
// $CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; |
|
|
|
|
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
|
$data['type'] = $this->POST['type']; |
|
|
|
|
|
|
|
|
|
$data['number'] =empty($this->POST['number'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请输入编号', '500'):Tool_Fnc::safe_string($this->POST['number']); |
|
|
|
|
$number = $this->Squirrelmodel->field("type")->where("number='{$data['number']}'")->fRow(); |
|
|
|
|
if(!empty($number)) Tool_Fnc::apiMsg('该编号已存在', '500'); |
|
|
|
|
$data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']); |
|
|
|
|
$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']); |
|
|
|
@ -99,11 +101,11 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
|
$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']); |
|
|
|
|
$data['created'] = date('Y-m-d H:i:s',time()); |
|
|
|
|
$data['number'] = $data['strains_id']."00000".$CageNum; |
|
|
|
|
if($CageNum>9) $data['number'] = $data['strains_id']."0000".$CageNum; |
|
|
|
|
if($CageNum>99) $data['number'] = $data['strains_id']."000".$CageNum; |
|
|
|
|
if($CageNum>999) $data['number'] = $data['strains_id']."00".$CageNum; |
|
|
|
|
if($CageNum>9999) $data['number'] = $data['strains_id']."0".$CageNum; |
|
|
|
|
// $data['number'] = $data['strains_id']."00000".$CageNum; |
|
|
|
|
// if($CageNum>9) $data['number'] = $data['strains_id']."0000".$CageNum; |
|
|
|
|
// if($CageNum>99) $data['number'] = $data['strains_id']."000".$CageNum; |
|
|
|
|
// if($CageNum>999) $data['number'] = $data['strains_id']."00".$CageNum; |
|
|
|
|
// if($CageNum>9999) $data['number'] = $data['strains_id']."0".$CageNum; |
|
|
|
|
//判断鼠笼鼠的数量是否可以容纳 |
|
|
|
|
if(!$this->Squirrelmodel->isFull($data['cage'],$this->POST['uid'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500'); |
|
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
|