ParamService.php 2.0 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
namespace api\portal\service;
use Think\Db;

class ParamService
{
   public function BMI($weight=0,$height=0){
       $bmi=$weight/pow(($height/100),2);
       return $bmi;
   }

    public function status($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;
    }

    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 bashBoard($before_weight=0,$weight=0,$height=0){
        $bmi=$weight/pow(($height/100),2);
        if($bmi<=18.5){
            $i=0.2;
        }elseif (18.5<$bmi&&$bmi<=23.9){
            $i=0.4;
        }elseif (24<$bmi&&$bmi<=27.9){
            $i=0.6;
        }elseif ($bmi>=28){
            $i=0.8;
        }
        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;
    }
}