更新 体质指数(BMI)

main
鹿和sa0ChunLuyu 1 year ago
parent 673f55aee4
commit 460a2139ae

@ -88,6 +88,7 @@ class QuestionnaireController extends Controller
} }
} }
$v = str_replace('${体重}', '', $v); $v = str_replace('${体重}', '', $v);
$v = str_replace('${身高}', '', $v);
$item_data['value'] = $v; $item_data['value'] = $v;
$list[] = $item_data; $list[] = $item_data;
} }

@ -89,6 +89,7 @@ class QuestionnairesLogsController extends Controller
$person_info = json_decode($log_info->person_info, true); $person_info = json_decode($log_info->person_info, true);
$age = !!$person_info['birthday'] ? date('Y') - date('Y', strtotime($person_info['birthday'])) : 0; $age = !!$person_info['birthday'] ? date('Y') - date('Y', strtotime($person_info['birthday'])) : 0;
$weight = !!$log_info->weight ? $log_info->weight : 0; $weight = !!$log_info->weight ? $log_info->weight : 0;
$height = !!$log_info->height ? $log_info->height : 0;
$items_ids = json_decode($log_info->check_items, true); $items_ids = json_decode($log_info->check_items, true);
$check_items = []; $check_items = [];
if (!!count($items_ids)) { if (!!count($items_ids)) {
@ -102,10 +103,14 @@ class QuestionnairesLogsController extends Controller
} }
$items = json_decode($log_info->items, true); $items = json_decode($log_info->items, true);
$check_items_array = json_decode($log_info->check_items_array, true); $check_items_array = json_decode($log_info->check_items_array, true);
$wh = '-';
if (!!$weight && $height) {
$wh = round($weight / pow($height / 100, 2), 2);
}
return \Yz::Return(true, '操作完成', [ return \Yz::Return(true, '操作完成', [
'date' => date('Y-m-d', strtotime($log_info->created_at)), 'date' => date('Y-m-d', strtotime($log_info->created_at)),
'age' => $age, 'age' => $age,
'weight' => $weight == '0' ? '-' : $weight, 'weight' => $wh,
'items' => $items, 'items' => $items,
'check_items' => $check_items, 'check_items' => $check_items,
'check_items_array' => $check_items_array, 'check_items_array' => $check_items_array,
@ -217,6 +222,7 @@ class QuestionnairesLogsController extends Controller
$question_questions = []; $question_questions = [];
} }
$weight = 0; $weight = 0;
$height = 0;
$score = 0; $score = 0;
foreach ($question_questions as $value) { foreach ($question_questions as $value) {
$id = $value->id; $id = $value->id;
@ -227,6 +233,12 @@ class QuestionnairesLogsController extends Controller
$weight = $question_map["q{$id}"]['value']; $weight = $question_map["q{$id}"]['value'];
} }
} }
if ($option['input']['value'] === '${身高}') {
if (isset($question_map["q{$id}"])) {
$height = $question_map["q{$id}"]['value'];
}
}
} else { } else {
if (isset($question_map["q{$id}"])) { if (isset($question_map["q{$id}"])) {
$v = $question_map["q{$id}"]['active']; $v = $question_map["q{$id}"]['active'];
@ -339,6 +351,9 @@ class QuestionnairesLogsController extends Controller
preg_match_all('/\d+/', $weight, $matches); preg_match_all('/\d+/', $weight, $matches);
$weight = $matches[0][0]; $weight = $matches[0][0];
$weight = $weight ? $weight : 0; $weight = $weight ? $weight : 0;
preg_match_all('/\d+/', $height, $matches);
$height = $matches[0][0];
$height = $height ? $height : 0;
$ip = self::getTrustedProxiesIp(); $ip = self::getTrustedProxiesIp();
$ip2region = new \Ip2Region(); $ip2region = new \Ip2Region();
$record = $ip2region->simple($ip); $record = $ip2region->simple($ip);
@ -350,6 +365,7 @@ class QuestionnairesLogsController extends Controller
'question_id' => $question_id, 'question_id' => $question_id,
'type' => $type, 'type' => $type,
'weight' => $weight, 'weight' => $weight,
'height' => $height,
'use_time' => $use_time, 'use_time' => $use_time,
'ip' => $ip, 'ip' => $ip,
'ip_info' => $ip_info, 'ip_info' => $ip_info,

Loading…
Cancel
Save