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

个人中心接口

@@ -238,6 +238,8 @@ class SignController extends RestBaseController @@ -238,6 +238,8 @@ class SignController extends RestBaseController
238 * @url /portal/Sign/weekSign 238 * @url /portal/Sign/weekSign
239 * @method POST 239 * @method POST
240 * @header name:XX-Token require:1 default: desc:token 240 * @header name:XX-Token require:1 default: desc:token
  241 + * @return param:各个参数
  242 + * @return record:周打卡记录
241 */ 243 */
242 public function weekSign(){ 244 public function weekSign(){
243 //用户信息 245 //用户信息
@@ -281,4 +283,24 @@ class SignController extends RestBaseController @@ -281,4 +283,24 @@ class SignController extends RestBaseController
281 'record'=>$record 283 'record'=>$record
282 )); 284 ));
283 } 285 }
  286 + /**
  287 + * @title 周打卡提交
  288 + * @description 周打卡提交接口
  289 + * @author panhaowen
  290 + * @url /portal/Sign/weekSignPost
  291 + * @method POST
  292 + * @header name:XX-Token require:1 default: desc:token
  293 + * @return param:各个参数
  294 + * @return record:周打卡记录
  295 + */
  296 + public function weekSignPost(){
  297 + $param=$this->request->param();
  298 + $user=Db::name('user')->where('id',$this->getUserId())->find();
  299 + Db::name('user')->where('id',$this->getUserId())->update(['now_weight'=>$param['weight']]);
  300 + $paramService=new ParamService();
  301 + $param['status']=$paramService->week_status($param['weight'],$user['height']);
  302 + Db::name('user_week_sign')->insert(['user_id'=>$this->getUserId(),'create_time'=>time(),'weight'=>$param['weight'],'status'=>$param['status']]);
  303 + //返回
  304 + $this->success('周打卡提交成功');
  305 + }
284 } 306 }
@@ -53,4 +53,18 @@ class ParamService @@ -53,4 +53,18 @@ class ParamService
53 } 53 }
54 return $before_weight+($this->overplus($weight,$height)*$i); 54 return $before_weight+($this->overplus($weight,$height)*$i);
55 } 55 }
  56 +
  57 + public function week_status($weight=0,$height=0){
  58 + $bmi=$weight/pow(($height/100),2);
  59 + if($bmi<=18.5){
  60 + $status='1';
  61 + }elseif (18.5<$bmi&&$bmi<=23.9){
  62 + $status='2';
  63 + }elseif (24<$bmi&&$bmi<=27.9){
  64 + $status='3';
  65 + }elseif ($bmi>=28){
  66 + $status='4';
  67 + }
  68 + return $status;
  69 + }
56 } 70 }