正在显示
4 个修改的文件
包含
56 行增加
和
1 行删除
@@ -303,4 +303,27 @@ class SignController extends RestBaseController | @@ -303,4 +303,27 @@ class SignController extends RestBaseController | ||
303 | //返回 | 303 | //返回 |
304 | $this->success('周打卡提交成功'); | 304 | $this->success('周打卡提交成功'); |
305 | } | 305 | } |
306 | + | ||
307 | + /** | ||
308 | + * @title 我的体重数据 | ||
309 | + * @description 我的体重数据接口 | ||
310 | + * @author panhaowen | ||
311 | + * @url /portal/Sign/myWeight | ||
312 | + * @method POST | ||
313 | + * @header name:XX-Token require:1 default: desc:token | ||
314 | + * @return param:各个参数 | ||
315 | + * @return record:周打卡记录 | ||
316 | + */ | ||
317 | + public function myWeight(){ | ||
318 | + $user=Db::name('user')->where('id',$this->getUserId())->find(); | ||
319 | + $paramService=new ParamService(); | ||
320 | + $nengliang=$paramService->nengliang($user['before_weight'],$user['height'],$user['weight_level'],$user['pregnant_week'],$user['register_time']); | ||
321 | + $param['day_energy']=$nengliang*0.2/4; | ||
322 | + Db::name('user')->where('id',$this->getUserId())->update(['now_weight'=>$param['weight']]); | ||
323 | + $paramService=new ParamService(); | ||
324 | + $param['status']=$paramService->week_status($param['weight'],$user['height']); | ||
325 | + Db::name('user_week_sign')->insert(['user_id'=>$this->getUserId(),'create_time'=>time(),'weight'=>$param['weight'],'status'=>$param['status']]); | ||
326 | + //返回 | ||
327 | + $this->success('周打卡提交成功'); | ||
328 | + } | ||
306 | } | 329 | } |
@@ -54,6 +54,7 @@ class UserController extends RestBaseController | @@ -54,6 +54,7 @@ class UserController extends RestBaseController | ||
54 | public function registerPost(){ | 54 | public function registerPost(){ |
55 | $param=$this->request->param(); | 55 | $param=$this->request->param(); |
56 | $param['status']=1; | 56 | $param['status']=1; |
57 | + $param['register_time']=time(); | ||
57 | Db::name('user')->where('id',$this->getUserId())->update($param); | 58 | Db::name('user')->where('id',$this->getUserId())->update($param); |
58 | $this->success('提交成功'); | 59 | $this->success('提交成功'); |
59 | } | 60 | } |
@@ -67,4 +67,35 @@ class ParamService | @@ -67,4 +67,35 @@ class ParamService | ||
67 | } | 67 | } |
68 | return $status; | 68 | return $status; |
69 | } | 69 | } |
70 | + | ||
71 | + public function nengliang($weight=0,$height=0,$weight_level="",$pregnant_week="",$register_time=""){ | ||
72 | + $bmi=$this->BMI($weight,$height); | ||
73 | + if($bmi<=18.5){ | ||
74 | + $type1=0; | ||
75 | + }elseif (18.5<$bmi&&$bmi<=23.9){ | ||
76 | + $type1=1; | ||
77 | + }elseif (24<$bmi&&$bmi<=27.9){ | ||
78 | + $type1=2; | ||
79 | + }elseif ($bmi>=28){ | ||
80 | + $type1=3; | ||
81 | + } | ||
82 | + if ($weight_level=="休息状态"){ | ||
83 | + $type2=[30,25,20,20]; | ||
84 | + }elseif ($weight_level=="轻体力"){ | ||
85 | + $type2=[35,30,25,25]; | ||
86 | + } | ||
87 | + elseif ($weight_level=="中体力"){ | ||
88 | + $type2=[40,35,30,30]; | ||
89 | + } | ||
90 | + elseif ($weight_level=="重体力"){ | ||
91 | + $type2=[45,40,35,35]; | ||
92 | + } | ||
93 | + if ($pregnant_week<=12){ | ||
94 | + $x=0; | ||
95 | + }else{ | ||
96 | + $x=200; | ||
97 | + } | ||
98 | + $result=($height-105)*$type2[$type1]+$x; | ||
99 | + return $result; | ||
100 | + } | ||
70 | } | 101 | } |
-
请 注册 或 登录 后发表评论