作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

个人中心接口

... ... @@ -238,6 +238,8 @@ class SignController extends RestBaseController
* @url /portal/Sign/weekSign
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @return param:各个参数
* @return record:周打卡记录
*/
public function weekSign(){
//用户信息
... ... @@ -281,4 +283,24 @@ class SignController extends RestBaseController
'record'=>$record
));
}
/**
* @title 周打卡提交
* @description 周打卡提交接口
* @author panhaowen
* @url /portal/Sign/weekSignPost
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @return param:各个参数
* @return record:周打卡记录
*/
public function weekSignPost(){
$param=$this->request->param();
$user=Db::name('user')->where('id',$this->getUserId())->find();
Db::name('user')->where('id',$this->getUserId())->update(['now_weight'=>$param['weight']]);
$paramService=new ParamService();
$param['status']=$paramService->week_status($param['weight'],$user['height']);
Db::name('user_week_sign')->insert(['user_id'=>$this->getUserId(),'create_time'=>time(),'weight'=>$param['weight'],'status'=>$param['status']]);
//返回
$this->success('周打卡提交成功');
}
}
... ...
... ... @@ -53,4 +53,18 @@ class ParamService
}
return $before_weight+($this->overplus($weight,$height)*$i);
}
public function week_status($weight=0,$height=0){
$bmi=$weight/pow(($height/100),2);
if($bmi<=18.5){
$status='1';
}elseif (18.5<$bmi&&$bmi<=23.9){
$status='2';
}elseif (24<$bmi&&$bmi<=27.9){
$status='3';
}elseif ($bmi>=28){
$status='4';
}
return $status;
}
}
... ...