作者 潘浩文

个人中心接口

... ... @@ -243,23 +243,25 @@ class SignController extends RestBaseController
//用户信息
$user=Db::name('user')->where('id',$this->getUserId())->find();
//判断是否是第一次周打卡
$re=Db::name('user_week_sign')->where('user_id',$user['id'])->find();
$re=Db::name('user_week_sign')->where('user_id',$user['id'])->order('create_time','desc')->find();
if (!$re){
$param['pregnant_week']=$user['pregnant_week'];
$param['day']=ceil((time()-$user['register_time'])/(60*60*21));
$param['weight']=$user['before_weight'];
$paramService=new ParamService();
$param['status']=$paramService->status($user['before_weight'],$user['height']);
$param['increase']=0;
$param['overplus']=$paramService->overplus($user['before_weight'],$user['height']);
}else{
$param['weight']=$re['weight'];
$param['increase']=$re['weight']-$user['before_weight'];
$paramService=new ParamService();
$param['overplus']=$paramService->overplus($user['before_weight'],$user['height'])-($re['weight']-$user['before_weight']);
$record=Db::name('user_week_sign')->where('user_id',$user['id'])->select();
}
$param['day']=ceil((time()-$user['register_time'])/(60*60*21));
$param['pregnant_week']=$user['pregnant_week'];
//返回
$this->success('日打卡信息',array(
'all'=>$user['all_sign_day'],
'last'=>$user['stay_sign_day'],
'longest'=>$user['longest_sign_day'],
'morning'=>$daySign['morning'],
'noon'=>$daySign['noon'],
'night'=>$daySign['night'],
'sleep'=>$daySign['sleep'],
$param,$record
));
}
}
... ...
... ... @@ -27,4 +27,30 @@ class ParamService
}
return $status;
}
public function overplus($weight=0,$height=0){
$bmi=$weight/pow(($height/100),2);
if($bmi<18.5){
$overplus=18;
}elseif (18.5<=$bmi&&$bmi<=24.9){
$overplus=16;
}elseif (25<$bmi){
$overplus=11.5;
}
return $overplus;
}
public function allIncrease($weight=0,$height=0){
$bmi=$weight/pow(($height/100),2);
if($bmi<=18.5){
$status='消瘦';
}elseif (18.5<$bmi&&$bmi<=23.9){
$status='正常';
}elseif (24<$bmi&&$bmi<=27.9){
$status='超重';
}elseif ($bmi>=28){
$status='肥胖';
}
return $status;
}
}
... ...