@ -7,6 +7,7 @@
*/
*/
class Api_SquirrelController extends Ctrl_Api{
class Api_SquirrelController extends Ctrl_Api{
public $Squirrelmodel;
public $Squirrelmodel;
public $NewSquirrelmodel;
public $CageModel;
public $CageModel;
public $CageSetModel;
public $CageSetModel;
public $SquirrelSetModel;
public $SquirrelSetModel;
@ -14,6 +15,7 @@ class Api_SquirrelController extends Ctrl_Api{
public $ExcelSetModel;
public $ExcelSetModel;
public function init() {
public function init() {
$this->Squirrelmodel = new SquirrelModel();
$this->Squirrelmodel = new SquirrelModel();
$this->NewSquirrelmodel = new NewSquirrelModel();
$this->CageModel = new CageModel();
$this->CageModel = new CageModel();
$this->CageSetModel=new CageSetModel();
$this->CageSetModel=new CageSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
@ -192,5 +194,58 @@ class Api_SquirrelController extends Ctrl_Api{
public function getInfoAction(){
public function getInfoAction(){
$id = $this->POST['id'];
$id = $this->POST['id'];
}
}
/**
* 幼崽信息添加接口
* @param $sex 性别
* @param $birthday 生日
* @param $father 父亲id
* @param $mather 母亲id
* @param $strains_id 品系id
* @param $gene 基因id
* @param $hair_color 毛色
* @param $remark 备注
* @param $cage 笼位号
* @return
* {
* "errorcode": "200",
* "message": "添加成功",
* "data": {
* "sex": "用户名",性别
* "birthday": "1",生日
* "father": "1",母亲id
* "mather": "2",母亲id
* "strains_id": "1",品系id
* "gene": "1",基因id
* "hair_color": "1",毛色
* "remark": "备注",备注
* "cage": "1",笼位号id
* }
* }
*/
public function addNewSquirrelAction(){
//查询笼位号
$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['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):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']);
$data['created'] = date('Y-m-d H:i:s',time());
//获取当前用户仓鼠的配置
$params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params);
//根据生日获取各个提醒时间
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday'])));
$data['nursing_time'] = date("Y-m-d",strtotime("+{$squirrelSet['nursing_time']} day",strtotime($data['birthday'])));
$data['grow_time'] =$data['sex']==1? date("Y-m-d",strtotime("+{$squirrelSet['male_grow_time']} days",strtotime($data['birthday']))):date("Y-m-d",strtotime("+{$squirrelSet['female_grow_time']} days",strtotime($data['birthday'])));
$data['infertility_time'] = date("Y-m-d",strtotime("+{$squirrelSet['infertility_time']} month",strtotime($data['birthday'])));
$data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday'])));
$ret = $this->NewSquirrelmodel->insert($data);
if(!$ret) Tool_Fnc::apiMsg('添加失败', '500');
Tool_Fnc::apiMsg('添加成功', '200');
}
}
}