SchoolPhysicalExamination/application/NewReedaw/controller/app/Index.php

803 lines
41 KiB
PHP
Raw Normal View History

2025-10-11 18:11:41 +08:00
<?php
namespace app\NewReedaw\controller\app;
2025-11-21 19:13:01 +08:00
2025-10-11 18:11:41 +08:00
use think\Db;
2026-02-03 18:56:47 +08:00
// use think\Cache;
// use think\Log;
// use PHPMailer\PHPMailer\PHPMailer;
// use app\NewReedaw\controller\app\Role;
2026-03-06 18:02:49 +08:00
// use app\app\controller\Language;
use app\KitchenScale2\controller\app\Index as Cfindex;//厨房秤的config
2025-10-11 18:11:41 +08:00
class Index extends Base{
protected $index_db_name = [
'zhanghao'=>'app_account_number',
'juese'=>'app_user_data',
'body_data'=>'app_card_body_data',
2025-11-21 19:13:01 +08:00
'banben'=>'app_version_log',
'shangwuhezuo'=>'admin_business_cooperation',
'diqu'=>'admin_estimate',
'banner'=>'admin_notice_banner',
'skip'=>'app_card_skip_data',
'vitalcapacity'=>'app_card_vitalcapacity_data',
2026-03-06 18:02:49 +08:00
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
2025-11-21 19:13:01 +08:00
];
protected $request_result = [
'2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']],
'6'=>['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']],
'8'=>['one_val'=>['第一次','ml'],'two_val'=>['第二次','ml'],'three_val'=>['第三次','ml'],'average_val'=>['三次平均','ml'],'score'=>['最后成绩','分']]
];
protected $identity_list = ['P0'=>'陌生人','P1'=>'爸爸','P2'=>'妈妈','P3'=>'大宝','P4'=>'二宝','P5'=>'三宝','P6'=>'四宝','P7'=>'爷爷','P8'=>'奶奶'];
protected $grade_list = [
['id'=>'nothing','name'=>'无'],
['id'=>'grade_s_1','name'=>'小学一年级'],
['id'=>'grade_s_2','name'=>'小学二年级'],
['id'=>'grade_s_3','name'=>'小学三年级'],
['id'=>'grade_s_4','name'=>'小学四年级'],
['id'=>'grade_s_5','name'=>'小学五年级'],
['id'=>'grade_s_6','name'=>'小学六年级'],
['id'=>'grade_m_1','name'=>'初中一年级'],
['id'=>'grade_m_2','name'=>'初中二年级'],
['id'=>'grade_m_3','name'=>'初中三年级'],
['id'=>'grade_h_1','name'=>'高中一年级'],
['id'=>'grade_h_2','name'=>'高中二年级'],
['id'=>'grade_h_3','name'=>'高中三年级'],
['id'=>'grade_u_12','name'=>'大学一、二年级'],
['id'=>'grade_u_34','name'=>'大学三、四年级']
];
2025-10-11 18:11:41 +08:00
// 加 bcadd(,,20)
// 减 bcsub(,,20)
// 乘 bcmul(,,20)
// 除 bcdiv(,,20)
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
################################################################接口################################################################
################################################################接口################################################################
################################################################接口################################################################
2026-03-06 18:02:49 +08:00
// 检测版本及判断是否登录失效
public function login_invalid_version(){
$data = input('post.');
2026-03-11 18:45:25 +08:00
try {
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
$result = Db::table($this->index_db_name['banben'])->order('is_del,id desc')->find();
if($result){
$version = $result['version_num_original'];
$url = $result['download_url'];
}else{
$version = '';
$url = '';
}
if($data['token'] == ''){
return $this->msg(-2,'未登录',['version'=>$version,'url'=>$url,]);
// return $this->msg(-2,'未登录',['version'=>$version,'url'=>$url,'language'=>'zh-Hans','language_arr'=>$this->process_Language()]);
2026-03-06 18:02:49 +08:00
}
$user_token_state = $this->token_time_validate($data['token']);
2026-03-11 18:45:25 +08:00
2026-03-06 18:02:49 +08:00
if($user_token_state['state'] === false){
2026-03-11 18:45:25 +08:00
return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,]);
// return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]);
2026-03-06 18:02:49 +08:00
}else{
2026-03-11 18:45:25 +08:00
return $this->msg(['version'=>$version,'url'=>$url,]);
// return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]);
2026-03-06 18:02:49 +08:00
}
2026-03-11 18:45:25 +08:00
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "方法: " . __METHOD__ . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
2026-03-06 18:02:49 +08:00
}
2025-10-11 18:11:41 +08:00
// 配置信息
2026-02-03 18:56:47 +08:00
public function config(){
$data = input('post.');
2026-03-06 18:02:49 +08:00
// try {
2026-02-03 18:56:47 +08:00
if(!array_key_exists('token', $data)){
return $this->msg(10001,'token is miss');
}
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005,'token type error');
}
2025-10-11 18:11:41 +08:00
return $this->config_action($data);
2026-03-06 18:02:49 +08:00
// } catch (\Exception $e) {
// // 捕获异常
// $logContent["flie"] = $e->getFile();
// $logContent["line"] = $e->getLine();
// $logContent['all_content'] = "异常信息:\n";
// $logContent['all_content'] .= "函数: config" . "\n";
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
// $this->record_api_log($data, $logContent, null);
// return $this->msg(99999);
// }
2025-10-11 18:11:41 +08:00
}
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// 获取角色信息
public function get_user_list(){
$data = input('post.');
try {
if(!array_key_exists('token', $data)){
return $this->msg(10001,'token is miss');
2025-10-13 03:35:56 +08:00
}
2026-02-03 18:56:47 +08:00
if(!$this->verify_data_is_ok($data['token'],'str')){
return $this->msg(10005,'token type error');
2025-10-13 03:35:56 +08:00
}
2026-02-03 18:56:47 +08:00
return $this->get_user_list_action($data);
2025-10-13 03:35:56 +08:00
} catch (\Exception $e) {
// 捕获异常
$logContent["flie"] = $e->getFile();
$logContent["line"] = $e->getLine();
$logContent['all_content'] = "异常信息:\n";
2026-02-03 18:56:47 +08:00
$logContent['all_content'] .= "函数: get_user_list" . "\n";
2025-10-13 03:35:56 +08:00
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
$this->record_api_log($data, $logContent, null);
return $this->msg(99999);
}
}
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
2026-03-06 18:02:49 +08:00
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// // 数据对比(包含身体、跳绳、肺活量)
// public function all_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
2025-11-21 19:13:01 +08:00
// try {
// $data = input('post.');
2026-02-03 18:56:47 +08:00
// if(!array_key_exists('before_id', $data) || !array_key_exists('after_id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
2025-11-21 19:13:01 +08:00
// return $this->msg(10001);
// }
2026-02-03 18:56:47 +08:00
// if(!$this->verify_data_is_ok($data['before_id'],'intnum')){
// return $this->msg(10005);
// }
// if(!$this->verify_data_is_ok($data['after_id'],'intnum')){
// return $this->msg(10005);
// }
// if(!$this->verify_data_is_ok($data['type'],'intnum')){
// return $this->msg(10005);
2025-11-21 19:13:01 +08:00
// }
2026-02-03 18:56:47 +08:00
// unset($data['token']);
// if($data['type'] == '2'){
// return $this->get_body_data_contrast($data);
// }else if($data['type'] == '6'){
// return $this->get_skip_data_contrast($data);
// }else if($data['type'] == '8'){
// return $this->get_vitalcapacity_data_contrast($data);
2025-11-21 19:13:01 +08:00
// }
// } catch (\Exception $e) {
// // 捕获异常
// $logContent["flie"] = $e->getFile();
// $logContent["line"] = $e->getLine();
// $logContent['all_content'] = "异常信息:\n";
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
// $this->record_api_log($data, $logContent, null);
// return $this->msg(99999);
// }
2026-02-03 18:56:47 +08:00
2025-11-21 19:13:01 +08:00
// }
2026-02-03 18:56:47 +08:00
2025-10-11 18:11:41 +08:00
################################################################action################################################################
################################################################action################################################################
public function config_action($data){
$return_data = [
'literature'=>[
'index'=>[
'*数据参考:',
'《中华人民共和国卫生行业标准WS/T 423-2022》',
'《中华人民共和国卫生行业标准WS/T 612-2018》',
'《中华人民共和国卫生行业标准WS/T 586-2018》',
'《WHO 5~19岁身高/体重判定标准》',
],
'bmi_evaluation'=>[
'*数据参考:',
'《WHO 5~19岁身高/体重判定标准》'
],
'height_prediction'=>[
'*数据参考:',
'Khamis-Roche方法',
'北京积水潭医院儿科临床参考公式',
'《中国妇幼保健》等相关学术期刊文献',
],
'warning'=>[
'此测量数据仅供参考,不可替代医学专业测试!'
]
],
2026-03-06 18:02:49 +08:00
// 'king_kong_region'=>[
// ['title'=>'减值对比','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/contrast.png','jump'=>'/pageTwo/compk/contrast'],
// ['title'=>'中招估分','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/report.png','jump'=>'/pageTwo/score/report'],
// ['title'=>'遗传身高','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/inheritHeighet.png','jump'=>'/pageTwo/home/inheritHeighet'],
// ['title'=>'BMI测评','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/bmi.png','jump'=>'/pageTwo/home/bmi'],
// ],
2025-11-21 19:13:01 +08:00
'business_cooperation_url'=>[],
'area_list'=>[],
'identity_list'=>[],
'grade_list'=>[],
'banner'=>[],
2026-03-06 18:02:49 +08:00
'activity_level'=>[
['name'=>'久坐(很少或没有运动)','val'=>'1.2'],
['name'=>'轻度活动每周1-3天轻度运动','val'=>'1.375'],
['name'=>'中度活动每周3-5天中度运动','val'=>'1.55'],
['name'=>'高度活动每周6-7天高强度运动','val'=>'1.725'],
['name'=>'极高活动(体力劳动或每天高强度训练)','val'=>'1.9'],
],
'meal_list'=>[
['icon'=>'https://tc.pcxbc.com/kitchenscale_all/meal_1.png','name'=>'早餐','icon_bg'=>'https://tc.pcxbc.com/kitchenscale_all/meal_1_bg.jpg'],
['icon'=>'https://tc.pcxbc.com/kitchenscale_all/meal_2.png','name'=>'午餐','icon_bg'=>'https://tc.pcxbc.com/kitchenscale_all/meal_2_bg.jpg'],
['icon'=>'https://tc.pcxbc.com/kitchenscale_all/meal_3.png','name'=>'晚餐','icon_bg'=>'https://tc.pcxbc.com/kitchenscale_all/meal_3_bg.jpg'],
['icon'=>'https://tc.pcxbc.com/kitchenscale_all/meal_4.png','name'=>'加餐','icon_bg'=>'https://tc.pcxbc.com/kitchenscale_all/meal_4_bg.jpg'],
],
'default_count_foot'=>[
'date' => '',
'remaining_kcal' => 0,
'details' => [
'carbohydrate' => [
'name' => '碳水',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_carbohydrate.png',
'color' => '#ED7886',
'val' => 0,
'unit' => 'g',
'proportion' => '0.00',
'rank_list' => [
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank1.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank2.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank3.png', 'name' => '', 'pic_url' => '', 'weight' => '']
]
],
'protein' => [
'name' => '蛋白质',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_protein.png',
'color' => '#FFB169',
'val' => 0,
'unit' => 'g',
'proportion' => '0.00',
'rank_list' => [
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank1.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank2.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank3.png', 'name' => '', 'pic_url' => '', 'weight' => '']
]
],
'fat' => [
'name' => '脂肪',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_fat.png',
'color' => '#3CB383',
'val' => 0,
'unit' => 'g',
'proportion' => '0.00',
'rank_list' => [
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank1.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank2.png', 'name' => '', 'pic_url' => '', 'weight' => ''],
['icon' => 'https://tc.pcxbc.com/kitchenscale_all/rank3.png', 'name' => '', 'pic_url' => '', 'weight' => '']
]
]
],
'trace_elements_all_day' => [
['name' => 'VitaminA', 'name_ch' => '维生素A', 'unit' => 'μg RAE', 'value' => 0],
['name' => 'VitaminB1', 'name_ch' => '硫胺素', 'unit' => 'mg', 'value' => 0],
['name' => 'VitaminB2', 'name_ch' => '核黄素', 'unit' => 'mg', 'value' => 0],
['name' => 'VitaminB6', 'name_ch' => '维生素B6', 'unit' => 'mg', 'value' => 0],
['name' => 'VitaminB12', 'name_ch' => '维生素B12', 'unit' => 'μg', 'value' => 0],
['name' => 'VitaminD', 'name_ch' => '维生素D', 'unit' => 'μg', 'value' => 0],
['name' => 'VitaminK', 'name_ch' => '维生素K', 'unit' => 'μg', 'value' => 0],
['name' => 'Niacin', 'name_ch' => '烟酸', 'unit' => 'mg', 'value' => 0],
['name' => 'VitaminC', 'name_ch' => '维生素C', 'unit' => 'mg', 'value' => 0],
['name' => 'VitaminE', 'name_ch' => '维生素E', 'unit' => 'mg α-TE', 'value' => 0],
['name' => 'FolicAcid', 'name_ch' => '叶酸', 'unit' => 'μg', 'value' => 0],
['name' => 'Biotin', 'name_ch' => '生物素', 'unit' => 'μg', 'value' => 0],
['name' => 'PantothenicAcid', 'name_ch' => '泛酸', 'unit' => 'mg', 'value' => 0],
['name' => 'TotalCholine', 'name_ch' => '总胆碱', 'unit' => 'mg', 'value' => 0],
['name' => 'Ca', 'name_ch' => '钙', 'unit' => 'mg', 'value' => 0],
['name' => 'Phosphorus', 'name_ch' => '磷', 'unit' => 'mg', 'value' => 0],
['name' => 'Kalium', 'name_ch' => '钾', 'unit' => 'mg', 'value' => 0],
['name' => 'Mg', 'name_ch' => '镁', 'unit' => 'mg', 'value' => 0],
['name' => 'Na', 'name_ch' => '钠', 'unit' => 'mg', 'value' => 0],
['name' => 'Fe', 'name_ch' => '铁', 'unit' => 'mg', 'value' => 0],
['name' => 'Zn', 'name_ch' => '锌', 'unit' => 'mg', 'value' => 0],
['name' => 'Se', 'name_ch' => '硒', 'unit' => 'μg', 'value' => 0],
['name' => 'Cu', 'name_ch' => '铜', 'unit' => 'mg', 'value' => 0],
['name' => 'Mn', 'name_ch' => '锰', 'unit' => 'mg', 'value' => 0],
['name' => 'Iodine', 'name_ch' => '碘', 'unit' => 'μg', 'value' => 0]
],
'list' => [
[
'name' => '早餐',
'val' => 0,
'unit' => 'kcal',
'color' => '#0992B4',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/meal_1.png',
'icon_home' => '/static/1.png',
'bgimg_home' => '/static/2.png',
'kcal_proportion' => 0,
'nutrients_four' => [
['name' => '卡路里', 'unit' => 'kcal', 'color' => '', 'value' => 0, 'proportion' => 0],
['name' => '碳水化合物', 'unit' => 'g', 'color' => '#FFB169', 'value' => 0, 'proportion' => 0],
['name' => '蛋白质', 'unit' => 'g', 'color' => '#5180D8', 'value' => 0, 'proportion' => 0],
['name' => '脂肪', 'unit' => 'g', 'color' => '#ED7886', 'value' => 0, 'proportion' => 0]
],
'list' => []
],
[
'name' => '午餐',
'val' => 0,
'unit' => 'kcal',
'color' => '#4F9211',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/meal_2.png',
'icon_home' => '/static/3.png',
'bgimg_home' => '/static/4.png',
'kcal_proportion' => 0,
'nutrients_four' => [
['name' => '卡路里', 'unit' => 'kcal', 'color' => '', 'value' => 0, 'proportion' => 0],
['name' => '蛋白质', 'unit' => 'g', 'color' => '#5180D8', 'value' => 0, 'proportion' => 0],
['name' => '脂肪', 'unit' => 'g', 'color' => '#ED7886', 'value' => 0, 'proportion' => 0],
['name' => '碳水化合物', 'unit' => 'g', 'color' => '#FFB169', 'value' => 0, 'proportion' => 0]
],
'list' => []
],
[
'name' => '晚餐',
'val' => 0,
'unit' => 'kcal',
'color' => '#B354B0',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/meal_3.png',
'icon_home' => '/static/5.png',
'bgimg_home' => '/static/6.png',
'kcal_proportion' => 0,
'nutrients_four' => [
['name' => '卡路里', 'unit' => 'kcal', 'color' => '', 'value' => 0, 'proportion' => 0],
['name' => '蛋白质', 'unit' => 'g', 'color' => '#5180D8', 'value' => 0, 'proportion' => 0],
['name' => '脂肪', 'unit' => 'g', 'color' => '#ED7886', 'value' => 0, 'proportion' => 0],
['name' => '碳水化合物', 'unit' => 'g', 'color' => '#FFB169', 'value' => 0, 'proportion' => 0]
],
'list' => []
],
[
'name' => '加餐',
'val' => 0,
'unit' => 'kcal',
'color' => '#C08433',
'icon' => 'https://tc.pcxbc.com/kitchenscale_all/meal_4.png',
'icon_home' => '/static/7.png',
'bgimg_home' => '/static/8.png',
'kcal_proportion' => 0,
'nutrients_four' => [
['name' => '卡路里', 'unit' => 'kcal', 'color' => '', 'value' => 0, 'proportion' => 0],
['name' => '蛋白质', 'unit' => 'g', 'color' => '#5180D8', 'value' => 0, 'proportion' => 0],
['name' => '脂肪', 'unit' => 'g', 'color' => '#ED7886', 'value' => 0, 'proportion' => 0],
['name' => '碳水化合物', 'unit' => 'g', 'color' => '#FFB169', 'value' => 0, 'proportion' => 0]
],
'list' => []
]
],
'nutrients_four' => [
['name' => '卡路里', 'unit' => 'kcal', 'suggestion' => '0', 'today_intake' => 0, 'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_kcal.png', 'color' => '#5180D8', 'proportion' => '0.00', 'proportion_fp' => 0],
['name' => '碳水', 'unit' => 'g', 'suggestion' => '0', 'today_intake' => 0, 'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_carbohydrate.png', 'color' => '#ED7886', 'proportion' => '0.00', 'proportion_fp' => '0'],
['name' => '蛋白质', 'unit' => 'g', 'suggestion' => '0', 'today_intake' => 0, 'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_protein.png', 'color' => '#FFB169', 'proportion' => '0.00', 'proportion_fp' => '0'],
['name' => '脂肪', 'unit' => 'g', 'suggestion' => '0', 'today_intake' => 0, 'icon' => 'https://tc.pcxbc.com/kitchenscale_all/icon_fat.png', 'color' => '#3CB383', 'proportion' => '0.00', 'proportion_fp' => '0']
]
],
2025-10-11 18:11:41 +08:00
];
2026-03-06 18:02:49 +08:00
// $food_count = ;
// 处理厨房秤config
// $cf_index = new Cfindex;
// $cf_confog = $cf_index->get_default_config_action($data)->getData()['data'];
2025-11-21 19:13:01 +08:00
$return_data['business_cooperation_url'] = Db::table($this->index_db_name['shangwuhezuo'])->where(['is_del'=>0])->field('title,data_url as url')->select();
$address_data = Db::table($this->index_db_name['diqu'])->where(['type' => '2'])->cache(86400)->field('id,content,city,area')->find();
$return_data['area_list'] = json_decode($address_data['content'],true);
$return_data['identity_list'] = [];
foreach ($this->identity_list as $key => $value) {
array_push($return_data['identity_list'],['id'=>$key,'name'=>$value]);
}
$return_data['grade_list'] = $this->grade_list;
$return_data['banner'] = Db::table($this->index_db_name['banner'])->where(['scene_data' => '3','is_del'=>0])->cache(3600)->order('sort_num desc')->field('id,type,pic,jump_url,parameter_data,sort_num')->select();
for ($i=0; $i < count($return_data['banner']); $i++) {
if($return_data['banner'][$i]['type'] != 1){
$return_data['banner'][$i]['parameter_data'] = '';
}
unset($return_data['banner'][$i]['sort_num']);
unset($return_data['banner'][$i]['ROW_NUMBER']);
}
2026-03-06 18:02:49 +08:00
// 添加菜谱类型start
$cfc = Db::connect('cfc_db');
$cookbook_label = $cfc->table($this->index_db_name['cookbook_label'])->where(["is_del"=>0])->field('id,name')->select();
$return_data['cookbook_label'] = $cookbook_label;
// 添加菜谱类型end
// foreach ($cf_confog as $key => $value) {
// // dump($key);
// $return_data[$key] = $value;
// }
// $return_data['cfc'] = $cf_confog;
2025-10-11 18:11:41 +08:00
return $this->msg($return_data);
}
2026-02-03 18:56:47 +08:00
public function get_user_list_action($data){
$account_data = Db::table($this->index_db_name['zhanghao'])->where(['token' => $data['token'],'is_del' => 0])->cache(900)->field('token,id,default_user_id')->find();
if(!$account_data){
return $this->msg(10003);
2025-10-13 03:35:56 +08:00
}
2026-02-03 18:56:47 +08:00
$user_list = Db::table($this->index_db_name['juese'])->where(['aan_id' => $account_data['id'],'is_del' => 0])->cache(900)->field('id,nickname,birthday,gender,card_order,head_pic,grade,weight,height,identity_name,identity_id')->select();
$result_data = ['default_user_id'=>$account_data['default_user_id'],'user_list'=>$user_list];
return $this->msg($result_data);
2025-10-13 03:35:56 +08:00
}
2026-02-03 18:56:47 +08:00
2026-03-06 18:02:49 +08:00
2026-02-03 18:56:47 +08:00
// // 数据对比(身体)
// public function get_body_data_contrast($data){
// $data2 = [$data['before_id'],$data['after_id']];
// $data3 = implode(',',$data2);
// $calculate_arr = [];
// $result = Db::query("
// select
// acbd.id,
// acbd.height,
// acbd.weight,
// acbd.bmi,
// acbd.fat_r,
// acbd.fat_w,
// acbd.muscle,
// acbd.muscleval,
// acbd.water,
// acbd.proteinval,
// acbd.bone,
// acbd.protein,
// acbd.kcal,
// acbd.visceral,
// acbd.sfr,
// acbd.record_time,
// acbd.record_type,
// acbd.head_circumference,
// REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '-') AS b_time,
// aud.nickname,
// aud.gender,
// aud.birthday,
// aud.head_pic
// from ".$this->index_db_name['body_data']." as acbd
// left join ".$this->index_db_name['juese']." as aud on acbd.aud_id=aud.id
// where acbd.id in ($data3)
// and acbd.is_del = 0
// ");
2025-10-11 18:11:41 +08:00
2026-02-03 18:56:47 +08:00
// if(!$result || count($result)<2){
// return $this->msg(10004);
// }
// // 调整顺序
// foreach ($result as $key => $value) {
// if($value['id'] == $data2[0]){
// $calculate_arr['before'] = $value;
// }else{
// $calculate_arr['after'] = $value;
// }
// }
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// $return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time'];
// $return_data['headimg'] = $calculate_arr['before']['head_pic'];
// $return_data['name'] = $calculate_arr['before']['nickname'];
// $return_data['gender'] = $calculate_arr['before']['gender'];
// $return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
// $return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
// $return_data['list'] = [];
// // 处理如果没有阻抗的数据为0显示异常start;同步处理,如果两个对比数据,都没有阻抗数据,则只显示基础信息
// if($calculate_arr['before']['record_type'] != 'by_device_adc' && $calculate_arr['after']['record_type'] != 'by_device_adc'){
// foreach ($calculate_arr['before'] as $key => $value) {
// if(!in_array($key, ['height','weight','bmi','head_circumference'])){
// unset($calculate_arr['before'][$key]);
// unset($calculate_arr['after'][$key]);
// }
// }
// if($return_data['age']>=3){
// unset($calculate_arr['before']['head_circumference']);
// unset($calculate_arr['after']['head_circumference']);
// }else{
// $calculate_arr['before']['head_circumference'] = json_decode($calculate_arr['before']['head_circumference'],true);
// $calculate_arr['after']['head_circumference'] = json_decode($calculate_arr['after']['head_circumference'],true);
// foreach ($calculate_arr as $key => $value) {
// if(array_key_exists('value',$value['head_circumference'])){
// $calculate_arr[$key]['head'][0] = $value['head_circumference']['value'];
// }else{
// $calculate_arr[$key]['head'][0] = 0;
// }
// if(array_key_exists('level',$value['head_circumference'])){
// $calculate_arr[$key]['head'][1] = $value['head_circumference']['level'];
// }else{
// $calculate_arr[$key]['head'][1] = '异常';
// }
// if(array_key_exists('color',$value['head_circumference'])){
// $calculate_arr[$key]['head'][2] = $value['head_circumference']['color'];
// }else{
// $calculate_arr[$key]['head'][2] = '';
// }
// $calculate_arr[$key]['head'] = implode(',',$calculate_arr[$key]['head']);
// unset($calculate_arr['before']['head_circumference']);
// unset($calculate_arr['after']['head_circumference']);
// }
// }
// }else{
// foreach ($calculate_arr as $key => $value) {
// if($value['record_type'] != 'by_device_adc'){
// $calculate_arr[$key]['fat_r'] = "0,异常";
// $calculate_arr[$key]['fat_w'] = "0,异常";
// $calculate_arr[$key]['muscle'] = "0,异常";
// $calculate_arr[$key]['muscleval'] = "0,异常";
// $calculate_arr[$key]['water'] = "0,异常";
// $calculate_arr[$key]['proteinval'] = "0,异常";
// $calculate_arr[$key]['bone'] = "0,异常";
// $calculate_arr[$key]['protein'] = "0,异常";
// $calculate_arr[$key]['kcal'] = "0,异常";
// $calculate_arr[$key]['visceral'] = "0,异常";
// $calculate_arr[$key]['sfr'] = "0,异常";
// }
// }
// }
// // 处理如果没有阻抗的数据为0显示异常end同步处理如果两个对比数据都没有阻抗数据则只显示基础信息
// foreach ($calculate_arr['before'] as $key => $value) {
// if(in_array($key, ['height','weight','bmi','head','fat_r','fat_w','muscle','muscleval','water','proteinval','bone','protein','kcal','visceral','sfr'])){
// $before_arr = explode(',', $value);
// $after_arr = explode(',', $calculate_arr['after'][$key]);
// array_push($return_data['list'], [
// 'firstresult'=>[
// 'color'=>'',
// 'level'=>$before_arr[1],
// 'value'=>$before_arr[0],
// 'title'=>$this->request_result['2'][$key][0],
// 'unit'=>$this->request_result['2'][$key][1],
// 'name'=>$key,
// ],
// 'secondresult'=>[
// 'color'=>'',
// 'level'=>$after_arr[1],
// 'value'=>$after_arr[0],
// 'title'=>$this->request_result['2'][$key][0],
// 'unit'=>$this->request_result['2'][$key][1],
// 'name'=>$key,
// ],
// 'diffval'=>bcsub($after_arr[0],$before_arr[0],2),
// ]);
// }
// }
// // 添加头围数据如果需要的话end
// return $this->msg($return_data);
// }
// // 数据对比(跳绳)
// public function get_skip_data_contrast($data){
// $data2 = [$data['before_id'],$data['after_id']];
// $data3 = implode(',',$data2);
// $calculate_arr = [];
// $result = Db::query("
// select
// acsd.id,
// acsd.jump_num,
// acsd.jump_time,
// acsd.jump_kcal,
// acsd.record_time,
// REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
// aud.nickname,
// aud.gender,
// aud.birthday,
// aud.head_pic
// from ".$this->index_db_name['skip']." as acsd
// left join ".$this->index_db_name['juese']." as aud on acsd.aud_id=aud.id
// where acsd.id in ($data3)
// and acsd.is_del = 0
// ");
// if(!$result || count($result)<2){
// return $this->msg(10004);
// }
// // 调整顺序
// foreach ($result as $key => $value) {
// if($value['id'] == $data2[0]){
// $calculate_arr['before'] = $value;
// }else{
// $calculate_arr['after'] = $value;
// }
// }
// $return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
// $return_data['headimg'] = $calculate_arr['before']['head_pic'];
// $return_data['name'] = $calculate_arr['before']['nickname'];
// $return_data['gender'] = $calculate_arr['before']['gender'];
// $return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
// $return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
// $return_data['list'] = [];
// foreach ($calculate_arr['before'] as $key => $value) {
// if(in_array($key, ['jump_num','jump_time','jump_kcal'])){
// $before_arr = $value;
// $after_arr = $calculate_arr['after'][$key];
// $temporary_arr = [
// 'firstresult'=>[
// 'color'=>'',
// 'level'=>'',
// 'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($before_arr)):$before_arr,
// 'title'=>$this->request_result['6'][$key][0],
// 'unit'=>$this->request_result['6'][$key][1],
// 'name'=>$key,
// ],
// 'secondresult'=>[
// 'color'=>'',
// 'level'=>'',
// 'value'=>$key=='jump_time'?implode(':',$this->handle_hour_branch_second($after_arr)):$after_arr,
// 'title'=>$this->request_result['6'][$key][0],
// 'unit'=>$this->request_result['6'][$key][1],
// 'name'=>$key,
// ],
// 'diffval'=>bcsub($after_arr,$before_arr,2)
// ];
// if($key=='jump_time'){
// $temporary_arr['diffval'] = $temporary_arr['diffval'] >= 0?implode(':',$this->handle_hour_branch_second($temporary_arr['diffval'])):'-'.implode(':',$this->handle_hour_branch_second($temporary_arr['diffval']));
// }
// array_push($return_data['list'], $temporary_arr);
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// }
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// }
// return $this->msg($return_data);
// }
// // 数据对比(肺活)
// public function get_vitalcapacity_data_contrast($data){
// $data2 = [$data['before_id'],$data['after_id']];
// $data3 = implode(',',$data2);
// $calculate_arr = [];
// $result = Db::query("
// select
// acsd.id,
// acsd.one_val,
// acsd.two_val,
// acsd.three_val,
// acsd.average_val,
// acsd.score_val as score,
// acsd.record_time,
// REPLACE(CONVERT(varchar(10), acsd.record_time, 23), '-', '-') AS b_time,
// aud.nickname,
// aud.gender,
// aud.birthday,
// aud.head_pic
// from ".$this->index_db_name['vitalcapacity']." as acsd
// left join ".$this->index_db_name['juese']." as aud on acsd.aud_id=aud.id
// where acsd.id in ($data3)
// and acsd.is_del = 0
// ");
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// if(!$result || count($result)<2){
// return $this->msg(10004);
// }
// // 调整顺序
// foreach ($result as $key => $value) {
// if($value['id'] == $data2[0]){
// $calculate_arr['before'] = $value;
// }else{
// $calculate_arr['after'] = $value;
// }
// }
// $return_data['time'] = $calculate_arr['before']['b_time'].'-'.$calculate_arr['after']['b_time'];
// $return_data['headimg'] = $calculate_arr['before']['head_pic'];
// $return_data['name'] = $calculate_arr['before']['nickname'];
// $return_data['gender'] = $calculate_arr['before']['gender'];
// $return_data['age'] = $this->calculate_age($calculate_arr['before']['birthday']);
// $return_data['day'] = abs($this->daysSince($calculate_arr['before']['record_time'],$calculate_arr['after']['record_time']));
// $return_data['list'] = [];
// foreach ($calculate_arr['before'] as $key => $value) {
// if(in_array($key, ['one_val','two_val','three_val','average_val','score_val'])){
// $before_arr = $value;
// $after_arr = $calculate_arr['after'][$key];
// $temporary_arr = [
// 'firstresult'=>[
// 'color'=>'',
// 'level'=>'',
// 'value'=>$before_arr,
// 'title'=>$this->request_result['8'][$key][0],
// 'unit'=>$this->request_result['8'][$key][1],
// 'name'=>$key,
// ],
// 'secondresult'=>[
// 'color'=>'',
// 'level'=>'',
// 'value'=>$after_arr,
// 'title'=>$this->request_result['8'][$key][0],
// 'unit'=>$this->request_result['8'][$key][1],
// 'name'=>$key,
// ],
// 'diffval'=>bcsub($after_arr,$before_arr,2)
// ];
// array_push($return_data['list'], $temporary_arr);
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// }
2025-11-21 19:13:01 +08:00
2026-02-03 18:56:47 +08:00
// }
// return $this->msg($return_data);
// }
2025-11-21 19:13:01 +08:00
################################################################内部调用################################################################
################################################################内部调用################################################################
2026-03-06 18:02:49 +08:00
2025-11-21 19:13:01 +08:00
// 添加IP信息获取方法
protected function getIpInfo($ip) {
// 默认IP
$ip = $ip ?: request()->ip();
try {
$ip2region = new \Ip2Region();
$info = $ip2region->memorySearch($ip);
// 返回国家信息
return $info['region'] ?: '未知';
} catch (\Exception $e) {
return '未知';
}
}
public function pd_language($user_language,$isSupportedLanguage,$language){
if(!$user_language){
if($isSupportedLanguage){
$result = $language;
}else{
$result = 'zh-Hans'; // 默认语言为中文
}
}else{
$result = $user_language;
}
return $result;
}
// 处理返回的语言数组
protected function process_Language(){
$temporary_arr = [];
foreach ($this->language_country as $key => $value) {
array_push($temporary_arr,['key'=>$key,'value'=>$value]);
}
return $temporary_arr;
}
2025-10-11 18:11:41 +08:00
}