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

个人中心接口

... ... @@ -303,4 +303,27 @@ class SignController extends RestBaseController
//返回
$this->success('周打卡提交成功');
}
/**
* @title 我的体重数据
* @description 我的体重数据接口
* @author panhaowen
* @url /portal/Sign/myWeight
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @return param:各个参数
* @return record:周打卡记录
*/
public function myWeight(){
$user=Db::name('user')->where('id',$this->getUserId())->find();
$paramService=new ParamService();
$nengliang=$paramService->nengliang($user['before_weight'],$user['height'],$user['weight_level'],$user['pregnant_week'],$user['register_time']);
$param['day_energy']=$nengliang*0.2/4;
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('周打卡提交成功');
}
}
... ...
... ... @@ -54,6 +54,7 @@ class UserController extends RestBaseController
public function registerPost(){
$param=$this->request->param();
$param['status']=1;
$param['register_time']=time();
Db::name('user')->where('id',$this->getUserId())->update($param);
$this->success('提交成功');
}
... ...
... ... @@ -67,4 +67,35 @@ class ParamService
}
return $status;
}
public function nengliang($weight=0,$height=0,$weight_level="",$pregnant_week="",$register_time=""){
$bmi=$this->BMI($weight,$height);
if($bmi<=18.5){
$type1=0;
}elseif (18.5<$bmi&&$bmi<=23.9){
$type1=1;
}elseif (24<$bmi&&$bmi<=27.9){
$type1=2;
}elseif ($bmi>=28){
$type1=3;
}
if ($weight_level=="休息状态"){
$type2=[30,25,20,20];
}elseif ($weight_level=="轻体力"){
$type2=[35,30,25,25];
}
elseif ($weight_level=="中体力"){
$type2=[40,35,30,30];
}
elseif ($weight_level=="重体力"){
$type2=[45,40,35,35];
}
if ($pregnant_week<=12){
$x=0;
}else{
$x=200;
}
$result=($height-105)*$type2[$type1]+$x;
return $result;
}
}
... ...
... ... @@ -10,7 +10,7 @@
// [ 入口文件 ]
// 调试模式开关
define("APP_DEBUG", false);
define("APP_DEBUG", true);
// 定义CMF根目录,可更改此目录
define('CMF_ROOT', __DIR__ . '/../');
... ...