ParamService.php
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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;
}
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+ceil((time()-$register_time)/(24*60*60*7)))<=12){
$x=0;
}else{
$x=200;
}
$result=($height-105)*$type2[$type1]+$x;
return $result;
}
}