260406
This commit is contained in:
parent
6ee76420eb
commit
cfef33b710
|
|
@ -10,6 +10,10 @@ class Appinterface extends Base{
|
||||||
|
|
||||||
protected $device_name_list = [
|
protected $device_name_list = [
|
||||||
'C03',
|
'C03',
|
||||||
|
'C06',
|
||||||
|
'C07',
|
||||||
|
'C09',
|
||||||
|
'C10',
|
||||||
];
|
];
|
||||||
|
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ class Savemsg extends Base{
|
||||||
|
|
||||||
// 设备名称列表
|
// 设备名称列表
|
||||||
protected $name_list = [
|
protected $name_list = [
|
||||||
['name'=>'PC-C02Pro']
|
['name'=>'PC-C02Pro'],
|
||||||
|
['name'=>'PC-C06Pro'],
|
||||||
|
['name'=>'PC-C07Pro'],
|
||||||
|
['name'=>'PC-C09Pro'],
|
||||||
|
['name'=>'PC-C10Pro'],
|
||||||
// [
|
// [
|
||||||
// 'name'=>'PC-C02Pro',
|
// 'name'=>'PC-C02Pro',
|
||||||
// ],
|
// ],
|
||||||
|
|
|
||||||
|
|
@ -285,8 +285,10 @@ class Base extends Controller{
|
||||||
if(!$grade){
|
if(!$grade){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if($grade['grade'] == 'nothing'){
|
// if($grade['grade'] == 'nothing'){
|
||||||
// 计算年龄判断是属于哪个年级
|
// // 计算年龄判断是属于哪个年级
|
||||||
|
|
||||||
|
// }
|
||||||
$user_age = $this->calculate_age($grade['birthday']);
|
$user_age = $this->calculate_age($grade['birthday']);
|
||||||
if($user_age <= 7){
|
if($user_age <= 7){
|
||||||
$grade['grade'] = 'grade_s_1';
|
$grade['grade'] = 'grade_s_1';
|
||||||
|
|
@ -317,7 +319,6 @@ class Base extends Controller{
|
||||||
}else if($user_age >= 21){
|
}else if($user_age >= 21){
|
||||||
$grade['grade'] = 'grade_u_34';
|
$grade['grade'] = 'grade_u_34';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$sql_min = "WITH RankedGrades AS (
|
$sql_min = "WITH RankedGrades AS (
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
|
@ -666,6 +667,9 @@ class Base extends Controller{
|
||||||
];
|
];
|
||||||
$weightConversion = [
|
$weightConversion = [
|
||||||
'kg' => 1,
|
'kg' => 1,
|
||||||
|
'公斤' => 1,
|
||||||
|
'g' => 0.001,
|
||||||
|
'克' => 0.001,
|
||||||
'斤' => 0.5, // 1斤 = 0.5kg
|
'斤' => 0.5, // 1斤 = 0.5kg
|
||||||
'st:lb' => function($value) {
|
'st:lb' => function($value) {
|
||||||
list($st, $lb) = explode(':', $value);
|
list($st, $lb) = explode(':', $value);
|
||||||
|
|
@ -707,7 +711,7 @@ class Base extends Controller{
|
||||||
|
|
||||||
|
|
||||||
// 处理 weight
|
// 处理 weight
|
||||||
if (preg_match('/([\d.:]+)(kg|斤|st:lb|lb)/', $weight, $matches)) {
|
if (preg_match('/([\d.:]+)(kg|公斤|g|克|斤|st:lb|lb)/', $weight, $matches)) {
|
||||||
$weightValue = $matches[1];
|
$weightValue = $matches[1];
|
||||||
$weightUnit = $matches[2];
|
$weightUnit = $matches[2];
|
||||||
if($weightUnit == 'st:lb'){
|
if($weightUnit == 'st:lb'){
|
||||||
|
|
@ -961,6 +965,8 @@ class Base extends Controller{
|
||||||
switch ($unit) {
|
switch ($unit) {
|
||||||
case 'g':
|
case 'g':
|
||||||
case '克':
|
case '克':
|
||||||
|
case 'ml':
|
||||||
|
case '毫升':
|
||||||
// 已经是克,直接返回
|
// 已经是克,直接返回
|
||||||
$result = $weight;
|
$result = $weight;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1000,34 +1006,119 @@ class Base extends Controller{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 以下是测试时使用
|
||||||
|
|
||||||
// public function ceshiyong($aa = 4,$gd = 0.2){
|
|
||||||
|
|
||||||
// phpinfo();
|
public function ceshiyong_page(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public function ceshiyong(){
|
||||||
|
|
||||||
|
// 老身体数据并入新身体数据
|
||||||
|
$test_data = Db::table('app_card_body_data')->where(['test_type'=>null,'aud_id'=>61])->page('1,100')->select();
|
||||||
|
// $test_data = Db::table('app_card_body_data')->where(['id'=>30883])->page('1,10')->select();
|
||||||
|
// $insert_search_log = Db::table('app_card_body_data_new')->where(['aud_id'=>61])->select();
|
||||||
|
// dump($test_data);
|
||||||
// die;
|
// die;
|
||||||
// $token = 'cd3f27cf4c4002170ea7bceeb723ac91';
|
$temporary_data = [];
|
||||||
|
|
||||||
// $data = Db::table('pc_bmistand2')->select();
|
$data = [];
|
||||||
// for ($i=0; $i < count($data); $i++) {
|
foreach ($test_data as $key => $value) {
|
||||||
// foreach ($data[$i] as $key => $value) {
|
$data = [];
|
||||||
// $data[$i][$key] = str_replace(' ', '',$data[$i][$key]);
|
$data = [
|
||||||
|
'bmi' => (float)$value['bmi_val'],
|
||||||
|
'bmilevel' => '',
|
||||||
|
'bm' => explode(',',$value['bone'])[0],
|
||||||
|
'rom' => explode(',',$value['muscle'])[0],
|
||||||
|
'vwc' => explode(',',$value['water'])[0],
|
||||||
|
'bfr' => explode(',',$value['fat_r'])[0],
|
||||||
|
'sfr' => explode(',',$value['sfr'])[0],
|
||||||
|
'pp' => explode(',',$value['protein'])[0],
|
||||||
|
'uvi' => explode(',',$value['visceral'])[0],
|
||||||
|
'bmr' => explode(',',$value['kcal'])[0],
|
||||||
|
'bodyage' => (float)$value['body_age'],
|
||||||
|
'weight' => (float)$value['weight_val'],
|
||||||
|
'height' => (float)$value['height_val'],
|
||||||
|
'age' => $value['age'],
|
||||||
|
'adc' => 550,
|
||||||
|
'sex' => 0,
|
||||||
|
'romval' => explode(',',$value['muscleval'])[0],
|
||||||
|
'ppval' => explode(',',$value['proteinval'])[0],
|
||||||
|
'bfrval' => explode(',',$value['fat_w'])[0],
|
||||||
|
'lbm' => 0,
|
||||||
|
'fatlevel' => 0,
|
||||||
|
'fatlevelname' => $value['body_level'],
|
||||||
|
'body' => $value['body_type'],
|
||||||
|
'cmi' => $value['score'],
|
||||||
|
'standardlist' => null
|
||||||
|
];
|
||||||
|
$temporary_data[] = [
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'create_time'=>$value['create_time'],
|
||||||
|
'acd_id'=>$value['acd_id'],
|
||||||
|
'aud_id'=>$value['aud_id'],
|
||||||
|
'record_time'=>$value['record_time'],
|
||||||
|
'age'=>$value['age'],
|
||||||
|
'is_del'=>$value['is_del'],
|
||||||
|
'record_type'=>$value['record_type'],
|
||||||
|
'height'=>(float)$value['height_val'],
|
||||||
|
'weight'=>(float)$value['weight_val'],
|
||||||
|
'bmi'=>(float)$value['bmi_val'],
|
||||||
|
'score'=>$value['score'],
|
||||||
|
'fat_r'=> explode(',',$value['fat_r'])[0],
|
||||||
|
'fat_w'=> explode(',',$value['fat_w'])[0],
|
||||||
|
'muscle'=> explode(',',$value['muscle'])[0],
|
||||||
|
'muscleval'=> explode(',',$value['muscleval'])[0],
|
||||||
|
'water'=>explode(',',$value['water'])[0],
|
||||||
|
'protein'=>explode(',',$value['protein'])[0],
|
||||||
|
'proteinval'=>explode(',',$value['proteinval'])[0],
|
||||||
|
'bone'=>explode(',',$value['bone'])[0],
|
||||||
|
'kcal'=>explode(',',$value['kcal'])[0],
|
||||||
|
'visceral'=>explode(',',$value['visceral'])[0],
|
||||||
|
'sfr'=>explode(',',$value['sfr'])[0],
|
||||||
|
'body_level'=>$value['body_level'],
|
||||||
|
'body_type'=>$value['body_type'],
|
||||||
|
'body_age'=>(float)$value['body_age'],
|
||||||
|
'heart_rate'=>$value['heart_rate'],
|
||||||
|
'head_circumference'=>$value['head_circumference'],
|
||||||
|
'8_electrode_data'=>null,
|
||||||
|
'4_electrode_data'=>json_encode($data),
|
||||||
|
'head_circumference_val'=>$value['head_circumference']?json_decode($value['head_circumference'],true)['value']:null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// }
|
foreach ($temporary_data as $key => $value) {
|
||||||
// Db::table('pc_bmistand2')->where(['id'=>$data[$i]['id']])->update([
|
|
||||||
// 'month'=>$data[$i]['month'],
|
$id = $value['id'];
|
||||||
// 'sex'=>$data[$i]['sex'],
|
$xh_data = $value;
|
||||||
// // 'f3sd'=>$data[$i]['f3sd'],
|
unset($xh_data['id']);
|
||||||
// // 'f2sd'=>$data[$i]['f2sd'],
|
// dump($xh_data);
|
||||||
// 'f1sd'=>$data[$i]['f1sd'],
|
// 启动事务
|
||||||
// 'median'=>$data[$i]['median'],
|
Db::startTrans();
|
||||||
// 'z1sd'=>$data[$i]['z1sd'],
|
try{
|
||||||
// 'z2sd'=>$data[$i]['z2sd'],
|
Db::table('app_card_body_data_new')->insert($xh_data);
|
||||||
// // 'z3sd'=>$data[$i]['z3sd'],
|
Db::table('app_card_body_data')->where(['id'=>$id])->update(['test_type'=>'1']);
|
||||||
// ]);
|
// 提交事务
|
||||||
// }
|
Db::commit();
|
||||||
|
dump('OK');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
dump($id);
|
||||||
|
// 记录异常信息
|
||||||
|
dump('事务回滚原因:' . $e->getMessage());
|
||||||
|
// dump('异常文件:' . $e->getFile());
|
||||||
|
// dump('异常行号:' . $e->getLine());
|
||||||
|
// dump('SQL错误代码:' . $e->getCode());
|
||||||
|
// dump('########################################################################################################');
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// dump($temporary_data);
|
||||||
// die;
|
// die;
|
||||||
// // $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
|
// $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -354,35 +354,6 @@ class Card extends Base{
|
||||||
return $this->msg(10005,'data type error');
|
return $this->msg(10005,'data type error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// $data = [
|
|
||||||
// 'aud_id' => '61',
|
|
||||||
// 'type' => 'skip',
|
|
||||||
// 'data' => [
|
|
||||||
// [
|
|
||||||
// 'name' => '日期',
|
|
||||||
// 'key_word' => 'r_time',
|
|
||||||
// 'type' => 'date',
|
|
||||||
// 'unit' => '',
|
|
||||||
// 'value' => '2026-03-18',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'name' => '时长',
|
|
||||||
// 'key_word' => 'time_m_s',
|
|
||||||
// 'type' => 'multiSelector',
|
|
||||||
// 'unit' => '',
|
|
||||||
// 'value' => '01:00',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'name' => '数量',
|
|
||||||
// 'key_word' => 'num',
|
|
||||||
// 'type' => 'number',
|
|
||||||
// 'unit' => '个',
|
|
||||||
// 'value' => '258',
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// 'token' => 'caadd1be045a65f30b92aa805f1de54a',
|
|
||||||
// 'aan_id' => '100',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
|
|
||||||
if($data['type'] == 'skip'){//跳绳
|
if($data['type'] == 'skip'){//跳绳
|
||||||
|
|
@ -1048,12 +1019,15 @@ class Card extends Base{
|
||||||
// 处理记录时间
|
// 处理记录时间
|
||||||
|
|
||||||
$user_msg = Db::name($this->card_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,grade,gender,birthday')->find();
|
$user_msg = Db::name($this->card_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,grade,gender,birthday')->find();
|
||||||
// die;
|
|
||||||
if($user_msg){
|
if($user_msg){
|
||||||
// 根据性别&年级&年龄查规则
|
// // 根据性别&年级&年龄查规则
|
||||||
if($user_msg['grade'] == 'nothing'){
|
// if($user_msg['grade'] == 'nothing' || $user_msg['grade'] == ''){
|
||||||
|
|
||||||
|
// }
|
||||||
// 计算年龄判断是属于哪个年级
|
// 计算年龄判断是属于哪个年级
|
||||||
$user_age = $this->calculate_age($user_msg['birthday']);
|
$user_age = $this->calculate_age($user_msg['birthday']);
|
||||||
|
// dump($user_age);
|
||||||
if($user_age <= 7){
|
if($user_age <= 7){
|
||||||
$user_msg['grade'] = 'grade_s_1';
|
$user_msg['grade'] = 'grade_s_1';
|
||||||
}else if($user_age == 8){
|
}else if($user_age == 8){
|
||||||
|
|
@ -1083,19 +1057,26 @@ class Card extends Base{
|
||||||
}else if($user_age >= 21){
|
}else if($user_age >= 21){
|
||||||
$user_msg['grade'] = 'grade_u_34';
|
$user_msg['grade'] = 'grade_u_34';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$sql_str = "sex = ".$user_msg['gender']." and ".$user_msg['grade']." <= ".$temporary_arr['average_val'];
|
$sql_str = "sex = ".$user_msg['gender']." and ".$user_msg['grade']." <= ".$temporary_arr['average_val'];
|
||||||
|
// dump($user_age);
|
||||||
|
// dump($user_msg);
|
||||||
|
|
||||||
$user_achievement = Db::name($this->card_db_name['vitalcapacity_biaozhun'])->where($sql_str)->order($user_msg['grade'] .' desc')->field('level,score,'.$user_msg['grade'])->limit(1)->cache(86400)->select();
|
$user_achievement = Db::name($this->card_db_name['vitalcapacity_biaozhun'])->where($sql_str)->order($user_msg['grade'] .' desc')->field('level,score,'.$user_msg['grade'])->limit(1)->cache(86400)->select();
|
||||||
|
|
||||||
if(count($user_achievement)<=0){
|
if(count($user_achievement)<=0){
|
||||||
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
|
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$temporary_arr['score'] = $user_achievement[0]['score'].','.$user_achievement[0]['level'].','.$this->vitalcapacity_color[$user_achievement[0]['level']];
|
$temporary_arr['score'] = $user_achievement[0]['score'].','.$user_achievement[0]['level'].','.$this->vitalcapacity_color[$user_achievement[0]['level']];
|
||||||
$temporary_arr['score_val'] = $user_achievement[0]['score'];
|
$temporary_arr['score_val'] = $user_achievement[0]['score'];
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10004,'未找到有效数据');
|
return $this->msg(10004,'未找到有效数据');
|
||||||
}
|
}
|
||||||
|
// dump($data);
|
||||||
$standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
$standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
||||||
|
|
||||||
|
|
||||||
$temporary_arr['standard_data'] = json_encode($standard_data);
|
$temporary_arr['standard_data'] = json_encode($standard_data);
|
||||||
$result = Db::table($this->card_db_name['vitalcapacity'])->insert($temporary_arr);
|
$result = Db::table($this->card_db_name['vitalcapacity'])->insert($temporary_arr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,14 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 隐私协议手机网页端
|
||||||
|
public function privacy_policy(){
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -452,12 +460,12 @@ class Index extends Base{
|
||||||
|
|
||||||
public function get_user_list_action($data){
|
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();
|
$account_data = Db::table($this->index_db_name['zhanghao'])->where(['token' => $data['token'],'is_del' => 0])->field('token,id,default_user_id')->find();
|
||||||
if(!$account_data){
|
if(!$account_data){
|
||||||
return $this->msg(10003);
|
return $this->msg(10003);
|
||||||
}
|
}
|
||||||
|
|
||||||
$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();
|
$user_list = Db::table($this->index_db_name['juese'])->where(['aan_id' => $account_data['id'],'is_del' => 0])->field('id,id as aud_id,activity_level,nickname,birthday,gender,card_order,head_pic,grade,weight,height,identity_name,identity_id')->select();
|
||||||
|
|
||||||
foreach ($user_list as $key => $value) {
|
foreach ($user_list as $key => $value) {
|
||||||
$user_list[$key]['age'] = $this->calculate_age($value['birthday']);
|
$user_list[$key]['age'] = $this->calculate_age($value['birthday']);
|
||||||
|
|
@ -762,39 +770,6 @@ class Index extends Base{
|
||||||
################################################################内部调用################################################################
|
################################################################内部调用################################################################
|
||||||
################################################################内部调用################################################################
|
################################################################内部调用################################################################
|
||||||
|
|
||||||
// 添加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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,9 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// 微信手机号快捷登录
|
// 微信手机号快捷登录
|
||||||
public function wechat_quick_login(){
|
public function wechat_quick_login(){
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
if(!array_key_exists('code', $data)){
|
if(!array_key_exists('code', $data)){
|
||||||
// return $this->msg(10001,'');
|
// return $this->msg(10001,'');
|
||||||
return $this->msg(10001,'code is miss');
|
return $this->msg(10001,'code is miss');
|
||||||
|
|
@ -157,14 +158,17 @@ class Login extends Base{
|
||||||
// 调用Wechat服务类处理微信登录逻辑
|
// 调用Wechat服务类处理微信登录逻辑
|
||||||
$wechatService = new Wechat();
|
$wechatService = new Wechat();
|
||||||
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
|
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
|
||||||
|
|
||||||
if($result['code'] == 0){
|
if($result['code'] == 0){
|
||||||
$user_data = Db::table($this->login_use_db_name['zhanghao'])->where(['tel'=>$result['data']['phoneNumber']])->fidle('token,id,is_del')->find();
|
$user_data = Db::table($this->login_use_db_name['zhanghao'])->where(['tel'=>$result['data']['phoneNumber']])->field('token,id,is_del')->find();
|
||||||
|
// dump($result);
|
||||||
|
// die;
|
||||||
if($user_data){
|
if($user_data){
|
||||||
if($user_data['is_del'] == 1){
|
if($user_data['is_del'] == 1){
|
||||||
return $this->msg(10002,'该账号已注销');
|
return $this->msg(10002,'该账号已注销');
|
||||||
}
|
}
|
||||||
Db::table($this->login_use_db_name['zhanghao'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
Db::table($this->login_use_db_name['zhanghao'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||||
$return_data = $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
|
return $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
|
||||||
}else{
|
}else{
|
||||||
$set_data['password'] = '';
|
$set_data['password'] = '';
|
||||||
$set_data['tel'] = $result['data']['phoneNumber'];
|
$set_data['tel'] = $result['data']['phoneNumber'];
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,26 @@ class Role extends Base{
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
try {
|
try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('activity_level', $data)){
|
return $this->msg(10001,'token is loss');
|
||||||
return $this->msg(10001);
|
}
|
||||||
|
if(!array_key_exists('nickname', $data)){
|
||||||
|
return $this->msg(10001,'昵称缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('birthday', $data)){
|
||||||
|
return $this->msg(10001,'生日缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('gender', $data)){
|
||||||
|
return $this->msg(10001,'性别缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('height', $data)){
|
||||||
|
return $this->msg(10001,'身高缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('weight', $data)){
|
||||||
|
return $this->msg(10001,'体重缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('activity_level', $data)){
|
||||||
|
return $this->msg(10001,'活动系数缺失');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
||||||
return $this->msg(10005,'activity_level type error');
|
return $this->msg(10005,'activity_level type error');
|
||||||
|
|
@ -239,6 +256,9 @@ class Role extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||||
return $this->msg(10005,'weight type error');
|
return $this->msg(10005,'weight type error');
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
||||||
|
return $this->msg(10005,'nickname type error');
|
||||||
|
}
|
||||||
return $this->add_member_action($data);
|
return $this->add_member_action($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
|
|
@ -260,8 +280,29 @@ class Role extends Base{
|
||||||
try {
|
try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
|
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('activity_level', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001,'token is loss');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('nickname', $data)){
|
||||||
|
return $this->msg(10001,'昵称缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('birthday', $data)){
|
||||||
|
return $this->msg(10001,'生日缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('gender', $data)){
|
||||||
|
return $this->msg(10001,'性别缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('height', $data)){
|
||||||
|
return $this->msg(10001,'身高缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('weight', $data)){
|
||||||
|
return $this->msg(10001,'体重缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('activity_level', $data)){
|
||||||
|
return $this->msg(10001,'活动系数缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('id', $data)){
|
||||||
|
return $this->msg(10001,'id is loss');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
||||||
return $this->msg(10005,'activity_level type error');
|
return $this->msg(10005,'activity_level type error');
|
||||||
|
|
@ -269,8 +310,8 @@ class Role extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type error');
|
return $this->msg(10005,'token type error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
return $this->msg(10005,'id type error');
|
return $this->msg(10005,'aud_id type error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
||||||
return $this->msg(10005,'birthday type error');
|
return $this->msg(10005,'birthday type error');
|
||||||
|
|
@ -284,6 +325,12 @@ class Role extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||||
return $this->msg(10005,'weight type error');
|
return $this->msg(10005,'weight type error');
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
||||||
|
return $this->msg(10005,'nickname type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||||
|
return $this->msg(10005,'id type error');
|
||||||
|
}
|
||||||
return $this->update_member_action($data);
|
return $this->update_member_action($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
|
|
@ -764,6 +811,7 @@ class Role extends Base{
|
||||||
if($user_account['set_kcal'] == '.00'){
|
if($user_account['set_kcal'] == '.00'){
|
||||||
$user_account['set_kcal'] = 0;
|
$user_account['set_kcal'] = 0;
|
||||||
}
|
}
|
||||||
|
$user_all_data['id'] = $user_account['aud_id'];
|
||||||
$user_all_data['aud_id'] = $user_account['aud_id'];
|
$user_all_data['aud_id'] = $user_account['aud_id'];
|
||||||
$user_all_data['nickname'] = $user_account['nickname'];
|
$user_all_data['nickname'] = $user_account['nickname'];
|
||||||
$user_all_data['gender'] = $user_account['gender'];
|
$user_all_data['gender'] = $user_account['gender'];
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,103 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="format-detection" content="telephone=no, email=no">
|
||||||
|
<meta name="full-screen" content="true">
|
||||||
|
<meta name="screen-orientation" content="portrait">
|
||||||
|
<meta name="x5-fullscreen" content="true">
|
||||||
|
<meta name="360-fullscreen" content="true">
|
||||||
|
<title>隐私协议</title>
|
||||||
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<style>
|
||||||
|
*{
|
||||||
|
padding: 0 0;
|
||||||
|
margin: 0 0;
|
||||||
|
}
|
||||||
|
.big_box{
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 10vw;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.title{
|
||||||
|
width: 100%;
|
||||||
|
height: 10vw;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 7vw;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 6vw;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.font_1{
|
||||||
|
font-size: 4.5vw;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.font_2{
|
||||||
|
font-size: 3.5vw;
|
||||||
|
margin: 3vw 0;
|
||||||
|
}
|
||||||
|
.fint_w{
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 5vw;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="box_k">
|
||||||
|
<div class="big_box">
|
||||||
|
<div class="title">Reedaw隐私协议</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="font_1">一、前言</div>
|
||||||
|
<div class="font_2">感谢您选择使用我们的Reedaw体重饮食可视化管理APP(以下简称“本应用”)。我们深知您的个人信息安全至关重要,在您使用本应用后我们郑重承诺,将严格遵守相关法律法规,采取合理有效的措施保护您的个人隐私。本隐私协议旨在明确我们在采集、使用、存储、共享及保护您的个人信息的责任、义务。请您在使用本应用前,仔细阅读并理解本协议内容,一旦您开始使用本应用,即视为您同意我们使用您的个人信息,接受本协议的全部条款。</div>
|
||||||
|
<div class="font_1">二、信息收集</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.必要信息:</span>为了提供基本服务,我们可能会采集您的基本信息,包括但不限于邮箱、姓名(可选择匿名使用)等。这些信息将用于验证您的身份、保障账号安全及提供个性化服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.健康数据:</span>在使用本应用进行身体数据健康评估时,我们会采集您的饮食、身高、体重等健康数据。这些数据将用于生成评估报告,并尽量提供相应的健康建议。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.设备信息:</span>为了优化服务体验,我们可能会采集您的设备型号、操作系统版本、IP地址等必要的技术信息。这些信息将帮助我们了解用户的使用环境,以便进行技术调试和服务改进。</div>
|
||||||
|
<div class="font_1">三、信息使用</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.服务提供:</span>我们将根据您提供的信息,为您提供饮食数据评估服务,并生成相应的评估报告。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.个性化推荐:</span>基于您的饮食数据和使用习惯,我们可能会向您推荐适合的饮食管理方案。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.数据分析:</span>我们会对收集到的数据进行匿名化处理,用于统计分析,以改进我们的产品和服务。这些统计数据将不包含任何可以识别您个人身份的信息。</div>
|
||||||
|
<div class="font_1">四、信息共享与披露</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.内部共享:</span>我们可能会将您的信息共享给公司内部负责处理您个人信息的部门或人员,以确保为您提供更好的服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.第三方合作:</span>在必要且合法的情况下,我们可能会与第三方服务提供商(如云服务提供商、数据分析公司等)共享您的个人信息,以便他们为我们提供技术支持或数据分析服务。我们将与这些第三方签订严格的保密协议,并要求他们遵守相关法律法规和本协议的规定。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.法律要求:</span>在法律法规要求或政府部门、司法机关要求的情况下,我们可能会依法披露您的个人信息。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">4.其他</span>4.其他对您的服务性应用。</div>
|
||||||
|
<div class="font_1">五、信息安全</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.技术保障:</span>我们将采取合理的技术手段和管理措施,确保您的个人信息在采集、存储、使用、共享等过程中的安全。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.数据加密:</span>对于敏感信息,我们将采用加密技术进行处理,防止数据在传输和存储过程中被非法访问或泄露。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.访问控制:</span>我们将对访问个人信息的员工进行严格的权限管理,确保只有授权人员才能访问相关信息。</div>
|
||||||
|
<div class="font_1">六、用户权利</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.知情权:</span>您有权了解我们采集、使用、共享及保护您个人信息的详细情况。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.选择权:</span>您有权选择是否向我们提供个人信息的具体内容,以及选择是否接受我们的个性化推荐服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.更正权:</span>如果您发现我们采集的个人信息有误,您有权要求我们及时更正。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">4.屏蔽权:</span>在符合法律法规要求的情况下,您有权要求我们屏蔽您的个人信息全部内容。</div>
|
||||||
|
<div class="font_1">七、协议变更</div>
|
||||||
|
<div class="font_2">我们有权根据法律法规的变化或业务发展的需要,对本隐私协议进行修订。修订后的协议将通过本应用内通知或其他适当方式告知您。请您定期查阅本隐私协议,以便及时了解我们的最新政策。</div>
|
||||||
|
<div class="font_1">八、争议解决</div>
|
||||||
|
<div class="font_2">如因本协议产生任何争议,双方应首先通过友好协商解决;协商不成的,任何一方均有权向本应用运营方所在地的法院提起诉讼。</div>
|
||||||
|
<div class="font_1">九、生效与终止</div>
|
||||||
|
<div class="font_2">本协议自您同意并接受之日起生效,并持续有效至您注销账号或本应用终止服务时止。</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
use think\Controller;
|
use think\Controller;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
|
@ -16,7 +16,10 @@ class Base extends Controller{
|
||||||
'3'=>'app_user_data',
|
'3'=>'app_user_data',
|
||||||
'4'=>'pc_vitalcapacity_standard',
|
'4'=>'pc_vitalcapacity_standard',
|
||||||
'5'=>'admin_estimate',
|
'5'=>'admin_estimate',
|
||||||
'6'=>'app_account_number'
|
'6'=>'app_account_number',
|
||||||
|
'search_history'=>'app_user_search_history',
|
||||||
|
'foodlist4'=>'app_z_national_standard_food_type_4',
|
||||||
|
'user'=>'app_user_data'
|
||||||
];
|
];
|
||||||
|
|
||||||
public $test_token = ['57bd45e3a963b372ea2d873e4bd8d1f8','e0966788d02cc93290d9d674921d9715'];
|
public $test_token = ['57bd45e3a963b372ea2d873e4bd8d1f8','e0966788d02cc93290d9d674921d9715'];
|
||||||
|
|
@ -80,15 +83,8 @@ class Base extends Controller{
|
||||||
return false;//跟数据库比对过,存在无效数值
|
return false;//跟数据库比对过,存在无效数值
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function validate_user_identity($data) {
|
|
||||||
$validate_user = Db::table($this->base_use_db_name['3'])->where(['id'=>$data])->count();
|
// 判断字符串是手机还是邮箱(有用)
|
||||||
if($validate_user<=0){
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 判断字符串是手机还是邮箱
|
|
||||||
public function is_tel_email($str) {
|
public function is_tel_email($str) {
|
||||||
// 手机号码的正则表达式(中国大陆格式)(下面正则实际判断的是是否为11位数字)
|
// 手机号码的正则表达式(中国大陆格式)(下面正则实际判断的是是否为11位数字)
|
||||||
$mobilePattern = '/^\d{11}$/';
|
$mobilePattern = '/^\d{11}$/';
|
||||||
|
|
@ -106,7 +102,7 @@ class Base extends Controller{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算年龄
|
// 计算年龄(有用)
|
||||||
public function calculate_age($data = '1991-04-20'){
|
public function calculate_age($data = '1991-04-20'){
|
||||||
$today = time(); // 获取当前时间的 Unix 时间戳
|
$today = time(); // 获取当前时间的 Unix 时间戳
|
||||||
$birthDate = strtotime($data); // 将出生日期字符串转换为 Unix 时间戳
|
$birthDate = strtotime($data); // 将出生日期字符串转换为 Unix 时间戳
|
||||||
|
|
@ -121,7 +117,7 @@ class Base extends Controller{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 秒转化格式,00:00:00
|
// 秒转化格式,00:00:00(有用)
|
||||||
public function handle_hour_branch_second($data = '2000'){
|
public function handle_hour_branch_second($data = '2000'){
|
||||||
$data = abs($data);
|
$data = abs($data);
|
||||||
$hours = intval($data / 3600);
|
$hours = intval($data / 3600);
|
||||||
|
|
@ -134,7 +130,7 @@ class Base extends Controller{
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断token是否过期
|
// 判断token是否过期(有用)
|
||||||
public function token_time_validate($token){
|
public function token_time_validate($token){
|
||||||
// 591b70e0d80b5fa6d77e6e1384453ab9
|
// 591b70e0d80b5fa6d77e6e1384453ab9
|
||||||
if(is_string($token)){
|
if(is_string($token)){
|
||||||
|
|
@ -189,7 +185,7 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算天数
|
// 计算天数(有用)
|
||||||
public function daysSince($pastDate,$now = false)
|
public function daysSince($pastDate,$now = false)
|
||||||
{
|
{
|
||||||
// 创建一个表示过去日期的 DateTime 对象
|
// 创建一个表示过去日期的 DateTime 对象
|
||||||
|
|
@ -206,7 +202,7 @@ class Base extends Controller{
|
||||||
return $interval->format('%a');
|
return $interval->format('%a');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算月龄
|
// 计算月龄(有用)
|
||||||
public function calculateAgeInMonthsWithPrecision($birthDateStr) {
|
public function calculateAgeInMonthsWithPrecision($birthDateStr) {
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
$now = new \DateTime();
|
$now = new \DateTime();
|
||||||
|
|
@ -224,28 +220,32 @@ class Base extends Controller{
|
||||||
$ageInMonthsPrecise = intval($ageInMonths + $partialMonth);
|
$ageInMonthsPrecise = intval($ageInMonths + $partialMonth);
|
||||||
return $ageInMonthsPrecise;
|
return $ageInMonthsPrecise;
|
||||||
}
|
}
|
||||||
// 曲线页面-底部统计动作
|
|
||||||
public function base_target_initial_cumulative_weight($data = []){
|
|
||||||
// 第一种:用户详情(所有数据都有)
|
// // 曲线页面-底部统计动作
|
||||||
// 第二种:手动记录(只有最新体重)
|
// public function base_target_initial_cumulative_weight($data = []){
|
||||||
// 第三种:修改原始体重(只有原始体重)
|
// // 第一种:用户详情(所有数据都有)
|
||||||
// $result_data['target_weight'] 目标体重
|
// // 第二种:手动记录(只有最新体重)
|
||||||
// $result_data['initial_weight'] 最初体重
|
// // 第三种:修改原始体重(只有原始体重)
|
||||||
// $result_data['weight'] 最近一次测量重量
|
// // $result_data['target_weight'] 目标体重
|
||||||
// $result_data['initial_date'] 初始体重日期
|
// // $result_data['initial_weight'] 最初体重
|
||||||
if(count($data) > 0){
|
// // $result_data['weight'] 最近一次测量重量
|
||||||
$result_data['target_weight'] = $data['target_weight'];
|
// // $result_data['initial_date'] 初始体重日期
|
||||||
$result_data['initial_weight'] = $data['initial_weight'];
|
// if(count($data) > 0){
|
||||||
$result_data['cumulative_weight'] = bcsub($data['weight'],$data['initial_weight'],2);
|
// $result_data['target_weight'] = $data['target_weight'];
|
||||||
$result_data['cumulative_day'] = $data['initial_date'] == 0?0:$this->daysSince($data['initial_date']);
|
// $result_data['initial_weight'] = $data['initial_weight'];
|
||||||
}else{
|
// $result_data['cumulative_weight'] = bcsub($data['weight'],$data['initial_weight'],2);
|
||||||
$result_data['target_weight'] = 0;
|
// $result_data['cumulative_day'] = $data['initial_date'] == 0?0:$this->daysSince($data['initial_date']);
|
||||||
$result_data['initial_weight'] = 0;
|
// }else{
|
||||||
$result_data['cumulative_weight'] = 0;
|
// $result_data['target_weight'] = 0;
|
||||||
$result_data['cumulative_day'] = 0;
|
// $result_data['initial_weight'] = 0;
|
||||||
}
|
// $result_data['cumulative_weight'] = 0;
|
||||||
return $result_data;
|
// $result_data['cumulative_day'] = 0;
|
||||||
}
|
// }
|
||||||
|
// return $result_data;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 判断一个参数是否为数字且大于等于0
|
// 判断一个参数是否为数字且大于等于0
|
||||||
public function isPositiveNumber($value) {
|
public function isPositiveNumber($value) {
|
||||||
|
|
@ -285,8 +285,10 @@ class Base extends Controller{
|
||||||
if(!$grade){
|
if(!$grade){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if($grade['grade'] == 'nothing'){
|
// if($grade['grade'] == 'nothing'){
|
||||||
// 计算年龄判断是属于哪个年级
|
// // 计算年龄判断是属于哪个年级
|
||||||
|
|
||||||
|
// }
|
||||||
$user_age = $this->calculate_age($grade['birthday']);
|
$user_age = $this->calculate_age($grade['birthday']);
|
||||||
if($user_age <= 7){
|
if($user_age <= 7){
|
||||||
$grade['grade'] = 'grade_s_1';
|
$grade['grade'] = 'grade_s_1';
|
||||||
|
|
@ -317,7 +319,6 @@ class Base extends Controller{
|
||||||
}else if($user_age >= 21){
|
}else if($user_age >= 21){
|
||||||
$grade['grade'] = 'grade_u_34';
|
$grade['grade'] = 'grade_u_34';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$sql_min = "WITH RankedGrades AS (
|
$sql_min = "WITH RankedGrades AS (
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
|
@ -593,11 +594,48 @@ class Base extends Controller{
|
||||||
case 'intnum':
|
case 'intnum':
|
||||||
// 整数验证 - 必须是整型或纯整数字符串
|
// 整数验证 - 必须是整型或纯整数字符串
|
||||||
// 使用 filter_var 同时验证整型和整数字符串
|
// 使用 filter_var 同时验证整型和整数字符串
|
||||||
return filter_var($data, FILTER_VALIDATE_INT) !== false;
|
// 必须是 >0 的整数或字符串整数
|
||||||
|
$filtered = filter_var($data, FILTER_VALIDATE_INT);
|
||||||
|
return $filtered !== false && $filtered > 0;
|
||||||
|
|
||||||
|
case 'intnum_0':
|
||||||
|
// 整数验证 - 必须是整型或纯整数字符串
|
||||||
|
// 使用 filter_var 同时验证整型和整数字符串
|
||||||
|
// 必须是 >0 的整数或字符串整数
|
||||||
|
$filtered = filter_var($data, FILTER_VALIDATE_INT);
|
||||||
|
return $filtered !== false;
|
||||||
|
|
||||||
|
case 'arr_intnum':
|
||||||
|
// 一维整数数组验证 - 必须是非空数组,且所有元素都是整数
|
||||||
|
// 1. 先检查是否是数组
|
||||||
|
if (!is_array($data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 检查数组是否为空
|
||||||
|
if (empty($data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 检查是否是一维数组
|
||||||
|
foreach ($data as $item) {
|
||||||
|
if (is_array($item)) {
|
||||||
|
return false; // 包含多维数组,不是一维数组
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 验证所有元素都是整数
|
||||||
|
foreach ($data as $item) {
|
||||||
|
$filtered = filter_var($item, FILTER_VALIDATE_INT);
|
||||||
|
if ($filtered === false) {
|
||||||
|
return false; // 不是整数
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
// 日期时间验证 - 保持原有逻辑不变
|
// 日期时间验证 - 保持原有逻辑不变
|
||||||
$formats = ['Y-m-d', 'Y-m-d H:i:s'];
|
$formats = ['Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i:s'];
|
||||||
foreach ($formats as $format) {
|
foreach ($formats as $format) {
|
||||||
$dateTime = \DateTime::createFromFormat($format, $data);
|
$dateTime = \DateTime::createFromFormat($format, $data);
|
||||||
if ($dateTime && $dateTime->format($format) === $data) {
|
if ($dateTime && $dateTime->format($format) === $data) {
|
||||||
|
|
@ -612,7 +650,7 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 处理身高体重的单位,转换它们为cm和kg。
|
// 处理身高体重的单位,转换它们为cm和kg。(有用)
|
||||||
public function convertHeightAndWeight($height, $weight) {
|
public function convertHeightAndWeight($height, $weight) {
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
// 减 bcsub(,,20)
|
// 减 bcsub(,,20)
|
||||||
|
|
@ -629,6 +667,9 @@ class Base extends Controller{
|
||||||
];
|
];
|
||||||
$weightConversion = [
|
$weightConversion = [
|
||||||
'kg' => 1,
|
'kg' => 1,
|
||||||
|
'公斤' => 1,
|
||||||
|
'g' => 0.001,
|
||||||
|
'克' => 0.001,
|
||||||
'斤' => 0.5, // 1斤 = 0.5kg
|
'斤' => 0.5, // 1斤 = 0.5kg
|
||||||
'st:lb' => function($value) {
|
'st:lb' => function($value) {
|
||||||
list($st, $lb) = explode(':', $value);
|
list($st, $lb) = explode(':', $value);
|
||||||
|
|
@ -670,7 +711,7 @@ class Base extends Controller{
|
||||||
|
|
||||||
|
|
||||||
// 处理 weight
|
// 处理 weight
|
||||||
if (preg_match('/([\d.:]+)(kg|斤|st:lb|lb)/', $weight, $matches)) {
|
if (preg_match('/([\d.:]+)(kg|公斤|g|克|斤|st:lb|lb)/', $weight, $matches)) {
|
||||||
$weightValue = $matches[1];
|
$weightValue = $matches[1];
|
||||||
$weightUnit = $matches[2];
|
$weightUnit = $matches[2];
|
||||||
if($weightUnit == 'st:lb'){
|
if($weightUnit == 'st:lb'){
|
||||||
|
|
@ -707,34 +748,375 @@ class Base extends Controller{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################以下是厨房秤的内容##########################################################
|
||||||
|
##########################################################以下是厨房秤的内容##########################################################
|
||||||
|
##########################################################以下是厨房秤的内容##########################################################
|
||||||
|
|
||||||
|
// 计算常规卡路里
|
||||||
|
public function count_user_nutrition_all($data){
|
||||||
|
// 计算基础代谢率(BMR)
|
||||||
|
if($data['gender'] == 1){
|
||||||
|
// 男性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) + 5
|
||||||
|
$bmr = bcmul(10,$data['weight'],20);
|
||||||
|
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||||
|
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||||
|
$bmr = bcadd($bmr,5,2);
|
||||||
|
}else if($data['gender'] == 2){
|
||||||
|
// 女性:BMR = 10 × 体重(kg) + 6.25 × 身高(cm) - 5 × 年龄(岁) - 161
|
||||||
|
$bmr = bcmul(10,$data['weight'],20);
|
||||||
|
$bmr = bcadd($bmr,bcmul(6.25,$data['height'],20),20);
|
||||||
|
$bmr = bcsub($bmr,bcmul(5,$data['age_num'],20),20);
|
||||||
|
$bmr = bcsub($bmr,161,2);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10003,'性别未知');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每日总能量消耗(TDEE)
|
||||||
|
// 久坐(很少或没有运动):BMR × 1.2
|
||||||
|
// 轻度活动(每周1-3天轻度运动):BMR × 1.375
|
||||||
|
// 中度活动(每周3-5天中度运动):BMR × 1.55
|
||||||
|
// 高度活动(每周6-7天高强度运动):BMR × 1.725
|
||||||
|
// 极高活动(体力劳动或每天高强度训练):BMR × 1.9
|
||||||
|
if(array_key_exists('activity_level',$data)){
|
||||||
|
if($data['activity_level'] != null){
|
||||||
|
$tdee = bcmul($bmr,$data['activity_level'],2);
|
||||||
|
}else{
|
||||||
|
$tdee = bcmul($bmr,1.55,2);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$tdee = bcmul($bmr,1.55,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 碳水化合物:通常占总热量的45-65%
|
||||||
|
// 蛋白质:通常占总热量的10-35%
|
||||||
|
// 脂肪:通常占总热量的20-35%
|
||||||
|
// 孩子&成年人:碳水化合物50%,蛋白质20%,脂肪30%。
|
||||||
|
// 老人:碳水化合物50%,蛋白质25%,脂肪25%。
|
||||||
|
// 建议每日摄入量计算:
|
||||||
|
// 1.碳水化合物(克): (TDEE × 碳水化合物比例) / 4
|
||||||
|
// 2.蛋白质(克):(TDEE × 蛋白质比例) / 4
|
||||||
|
// 3.脂肪(克): (TDEE × 脂肪比例) / 9
|
||||||
|
|
||||||
public function ceshiyong($aa = 4,$gd = 0.2){
|
$carbohydrate_p = 0.5;
|
||||||
|
$carbohydrate = bcdiv(bcmul($tdee,0.5,20),4,2);
|
||||||
|
if($data['age_num'] < 65){
|
||||||
|
$protein_p = 0.2;
|
||||||
|
$fat_p = 0.3;
|
||||||
|
$protein = bcdiv(bcmul($tdee,0.2,20),4,2);
|
||||||
|
$fat = bcdiv(bcmul($tdee,0.3,20),9,2);
|
||||||
|
}else{
|
||||||
|
$protein_p = 0.25;
|
||||||
|
$fat_p = 0.25;
|
||||||
|
$protein = bcdiv(bcmul($tdee,0.25,20),4,2);
|
||||||
|
$fat =bcdiv(bcmul($tdee,0.25,20),9,2);
|
||||||
|
}
|
||||||
|
return ['kcal'=>$tdee,'carbohydrate'=>$carbohydrate,'protein'=>$protein,'fat'=>$fat,'bmr'=>$bmr,'carbohydrate_p'=>$carbohydrate_p,'protein_p'=>$protein_p,'fat_p'=>$fat_p];
|
||||||
|
}
|
||||||
|
|
||||||
phpinfo();
|
// 计算营养物质
|
||||||
die;
|
public function calculate_nutrients($data){
|
||||||
$token = 'cd3f27cf4c4002170ea7bceeb723ac91';
|
// dump($data);
|
||||||
|
$food_id_arr = [];
|
||||||
$data = Db::table('pc_bmistand2')->select();
|
|
||||||
for ($i=0; $i < count($data); $i++) {
|
for ($i=0; $i < count($data); $i++) {
|
||||||
foreach ($data[$i] as $key => $value) {
|
$food_id_arr[] = $data[$i]['food_id'];
|
||||||
$data[$i][$key] = str_replace(' ', '',$data[$i][$key]);
|
}
|
||||||
|
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
|
||||||
|
// dump($data);
|
||||||
|
// dump(implode(",",$food_id_arr));
|
||||||
|
$nutrients_list = $cfc->table($this->base_use_db_name['foodlist4'])
|
||||||
|
->where("father_id in (".implode(",",$food_id_arr).")")
|
||||||
|
// ->field()
|
||||||
|
->select();
|
||||||
|
|
||||||
|
$nutrients_arr = ['VitaminA','VitaminB1','VitaminB2','VitaminB6','VitaminB12','VitaminD','VitaminK','Niacin','VitaminC','VitaminE','FolicAcid','Biotin','PantothenicAcid','TotalCholine','Ca','Phosphorus','Kalium','Mg','Na','Fe','Zn','Se','Cu','Mn','Iodine'];
|
||||||
|
// dump($nutrients_list);
|
||||||
|
// die;
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
for ($i=0; $i < count($data); $i++) {
|
||||||
|
$zong_all = bcadd($data[$i]['protein_val'],bcadd($data[$i]['fat_val'],$data[$i]['carbohydrate_val'],20),20);
|
||||||
|
$data[$i]['nutrients_four'][] = [
|
||||||
|
'name' => '卡路里',
|
||||||
|
'unit' => 'kcal',
|
||||||
|
'color' => '',
|
||||||
|
'value' => $data[$i]['kcal_val'],
|
||||||
|
'proportion' => 0,
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_four'][] = [
|
||||||
|
'name' => '蛋白质',
|
||||||
|
'unit' => 'g',
|
||||||
|
'color' => '#5180D8',
|
||||||
|
'value' => $data[$i]['protein_val'],
|
||||||
|
'proportion' => $zong_all == 0?0:bcmul(bcdiv($data[$i]['protein_val'],$zong_all,2),100,0),
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_four'][] = [
|
||||||
|
'name' => '脂肪',
|
||||||
|
'unit' => 'g',
|
||||||
|
'color' => '#ED7886',
|
||||||
|
'value' => $data[$i]['fat_val'],
|
||||||
|
'proportion' => $zong_all == 0?0:bcmul(bcdiv($data[$i]['fat_val'],$zong_all,2),100,0),
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_four'][] = [
|
||||||
|
'name' => '碳水化合物',
|
||||||
|
'unit' => 'g',
|
||||||
|
'color' => '#FFB169',
|
||||||
|
'value' => $data[$i]['carbohydrate_val'],
|
||||||
|
'proportion' => $zong_all == 0?0:bcmul(bcdiv($data[$i]['carbohydrate_val'],$zong_all,2),100,0),
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_list'][] = [
|
||||||
|
'name' => 'Calorie',
|
||||||
|
'name_ch' => '卡路里',
|
||||||
|
'unit' => 'kcal',
|
||||||
|
'value' => $data[$i]['kcal_val'],
|
||||||
|
'type' => 1,
|
||||||
|
'type_name' => '能量及宏量营养素',
|
||||||
|
'color' => '#C4FFE0',
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_list'][] = [
|
||||||
|
'name' => 'Protein',
|
||||||
|
'name_ch' => '蛋白质',
|
||||||
|
'unit' => 'g',
|
||||||
|
'value' => $data[$i]['protein_val'],
|
||||||
|
'type' => 1,
|
||||||
|
'type_name' => '能量及宏量营养素',
|
||||||
|
'color' => '#C4FFE0',
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_list'][] = [
|
||||||
|
'name' => 'Fat',
|
||||||
|
'name_ch' => '脂肪',
|
||||||
|
'unit' => 'g',
|
||||||
|
'value' => $data[$i]['fat_val'],
|
||||||
|
'type' => 1,
|
||||||
|
'type_name' => '能量及宏量营养素',
|
||||||
|
'color' => '#C4FFE0',
|
||||||
|
];
|
||||||
|
$data[$i]['nutrients_list'][] = [
|
||||||
|
'name' => 'Carbohydrate',
|
||||||
|
'name_ch' => '碳水化合物',
|
||||||
|
'unit' => 'g',
|
||||||
|
'value' => $data[$i]['carbohydrate_val'],
|
||||||
|
'type' => 1,
|
||||||
|
'type_name' => '能量及宏量营养素',
|
||||||
|
'color' => '#C4FFE0',
|
||||||
|
];
|
||||||
|
foreach ($nutrients_list as $key => $value) {
|
||||||
|
if($value['father_id'] == $data[$i]['food_id']){
|
||||||
|
if(in_array($value['name'],$nutrients_arr)){
|
||||||
|
$data[$i]['nutrients_list'][] = [
|
||||||
|
'name' => $value['name'],
|
||||||
|
'name_ch' => $value['name_ch'],
|
||||||
|
'unit' => $value['unit'],
|
||||||
|
'value' => bcmul($value['value'],bcdiv($data[$i]['weight'],100,20),2),
|
||||||
|
'type' => $value['type'],
|
||||||
|
'type_name' => $value['type'] == 1?'能量及宏量营养素':($value['type'] == 2?'维生素':($value['type'] == 3?'矿物质':'')),
|
||||||
|
'color' => $value['type'] == 1?'#C4FFE0':($value['type'] == 2?'#FFEFB7':($value['type'] == 3?'#7DA8E0':'')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Db::table('pc_bmistand2')->where(['id'=>$data[$i]['id']])->update([
|
}
|
||||||
'month'=>$data[$i]['month'],
|
}
|
||||||
'sex'=>$data[$i]['sex'],
|
return $data;
|
||||||
// 'f3sd'=>$data[$i]['f3sd'],
|
}
|
||||||
// 'f2sd'=>$data[$i]['f2sd'],
|
|
||||||
'f1sd'=>$data[$i]['f1sd'],
|
|
||||||
'median'=>$data[$i]['median'],
|
public function add_search_history_action($data){
|
||||||
'z1sd'=>$data[$i]['z1sd'],
|
// 添加一条搜索记录start
|
||||||
'z2sd'=>$data[$i]['z2sd'],
|
// $data['id']是账号id
|
||||||
// 'z3sd'=>$data[$i]['z3sd'],
|
// $cfc = Db::connect('cfc_db');
|
||||||
|
$insert_search_log = Db::table($this->base_use_db_name['search_history'])->where(['user_id'=>$data['id'],'keyword'=>$data['search_data'],'type'=>$data['type']])->field('id,search_count')->find();
|
||||||
|
if($insert_search_log){
|
||||||
|
Db::table($this->base_use_db_name['search_history'])->where(['id'=>$insert_search_log['id']])->update([
|
||||||
|
'search_count'=>$insert_search_log['search_count']+1,
|
||||||
|
'last_searched_at'=>date('Y-m-d H:i:s'),
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
Db::table($this->base_use_db_name['search_history'])->insert([
|
||||||
|
'user_id'=>$data['id'],
|
||||||
|
'keyword'=>$data['search_data'],
|
||||||
|
'type'=>$data['type'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
die;
|
// 添加一条搜索记录end
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将重量转换为克(g)
|
||||||
|
* @param string $weight 重量值
|
||||||
|
* @param string $unit 单位 (g, oz, lb, lb:oz)
|
||||||
|
* @return float 转换后的克重
|
||||||
|
*/
|
||||||
|
public function convertWeightToGrams($weight = 100, $unit = 'oz') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 定义精确的转换常量
|
||||||
|
$G_PER_OZ = '28.349523125';
|
||||||
|
$G_PER_LB = '453.59237';
|
||||||
|
|
||||||
|
$unit = strtolower($unit);
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
|
switch ($unit) {
|
||||||
|
case 'g':
|
||||||
|
case '克':
|
||||||
|
case 'ml':
|
||||||
|
case '毫升':
|
||||||
|
// 已经是克,直接返回
|
||||||
|
$result = $weight;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'oz':
|
||||||
|
case '盎司':
|
||||||
|
// 盎司转克
|
||||||
|
$result = bcmul($weight,$G_PER_OZ,2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'lb':
|
||||||
|
case '磅':
|
||||||
|
// 磅转克
|
||||||
|
$result = bcmul($weight,$G_PER_LB,2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'lb:oz':
|
||||||
|
case '磅:盎司':
|
||||||
|
// 磅:盎司复合单位处理
|
||||||
|
if (strpos($weight, ':') !== false) {
|
||||||
|
$temporary_data = explode(':', $weight);
|
||||||
|
$result = bcadd(bcmul($temporary_data[0],$G_PER_LB,20),bcmul($temporary_data[1],$G_PER_OZ,20),20);
|
||||||
|
} else {
|
||||||
|
// 如果格式不正确,可以抛出异常或返回0
|
||||||
|
$result = '0';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$result = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保留两位小数并返回(目前不做截取,全额返回)
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 以下是测试时使用
|
||||||
|
|
||||||
|
|
||||||
|
public function ceshiyong_page(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public function ceshiyong(){
|
||||||
|
|
||||||
|
// 老身体数据并入新身体数据
|
||||||
|
$test_data = Db::table('app_card_body_data')->where(['test_type'=>null,'aud_id'=>61])->page('1,100')->select();
|
||||||
|
// $test_data = Db::table('app_card_body_data')->where(['id'=>30883])->page('1,10')->select();
|
||||||
|
// $insert_search_log = Db::table('app_card_body_data_new')->where(['aud_id'=>61])->select();
|
||||||
|
// dump($test_data);
|
||||||
|
// die;
|
||||||
|
$temporary_data = [];
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
foreach ($test_data as $key => $value) {
|
||||||
|
$data = [];
|
||||||
|
$data = [
|
||||||
|
'bmi' => (float)$value['bmi_val'],
|
||||||
|
'bmilevel' => '',
|
||||||
|
'bm' => explode(',',$value['bone'])[0],
|
||||||
|
'rom' => explode(',',$value['muscle'])[0],
|
||||||
|
'vwc' => explode(',',$value['water'])[0],
|
||||||
|
'bfr' => explode(',',$value['fat_r'])[0],
|
||||||
|
'sfr' => explode(',',$value['sfr'])[0],
|
||||||
|
'pp' => explode(',',$value['protein'])[0],
|
||||||
|
'uvi' => explode(',',$value['visceral'])[0],
|
||||||
|
'bmr' => explode(',',$value['kcal'])[0],
|
||||||
|
'bodyage' => (float)$value['body_age'],
|
||||||
|
'weight' => (float)$value['weight_val'],
|
||||||
|
'height' => (float)$value['height_val'],
|
||||||
|
'age' => $value['age'],
|
||||||
|
'adc' => 550,
|
||||||
|
'sex' => 0,
|
||||||
|
'romval' => explode(',',$value['muscleval'])[0],
|
||||||
|
'ppval' => explode(',',$value['proteinval'])[0],
|
||||||
|
'bfrval' => explode(',',$value['fat_w'])[0],
|
||||||
|
'lbm' => 0,
|
||||||
|
'fatlevel' => 0,
|
||||||
|
'fatlevelname' => $value['body_level'],
|
||||||
|
'body' => $value['body_type'],
|
||||||
|
'cmi' => $value['score'],
|
||||||
|
'standardlist' => null
|
||||||
|
];
|
||||||
|
$temporary_data[] = [
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'create_time'=>$value['create_time'],
|
||||||
|
'acd_id'=>$value['acd_id'],
|
||||||
|
'aud_id'=>$value['aud_id'],
|
||||||
|
'record_time'=>$value['record_time'],
|
||||||
|
'age'=>$value['age'],
|
||||||
|
'is_del'=>$value['is_del'],
|
||||||
|
'record_type'=>$value['record_type'],
|
||||||
|
'height'=>(float)$value['height_val'],
|
||||||
|
'weight'=>(float)$value['weight_val'],
|
||||||
|
'bmi'=>(float)$value['bmi_val'],
|
||||||
|
'score'=>$value['score'],
|
||||||
|
'fat_r'=> explode(',',$value['fat_r'])[0],
|
||||||
|
'fat_w'=> explode(',',$value['fat_w'])[0],
|
||||||
|
'muscle'=> explode(',',$value['muscle'])[0],
|
||||||
|
'muscleval'=> explode(',',$value['muscleval'])[0],
|
||||||
|
'water'=>explode(',',$value['water'])[0],
|
||||||
|
'protein'=>explode(',',$value['protein'])[0],
|
||||||
|
'proteinval'=>explode(',',$value['proteinval'])[0],
|
||||||
|
'bone'=>explode(',',$value['bone'])[0],
|
||||||
|
'kcal'=>explode(',',$value['kcal'])[0],
|
||||||
|
'visceral'=>explode(',',$value['visceral'])[0],
|
||||||
|
'sfr'=>explode(',',$value['sfr'])[0],
|
||||||
|
'body_level'=>$value['body_level'],
|
||||||
|
'body_type'=>$value['body_type'],
|
||||||
|
'body_age'=>(float)$value['body_age'],
|
||||||
|
'heart_rate'=>$value['heart_rate'],
|
||||||
|
'head_circumference'=>$value['head_circumference'],
|
||||||
|
'8_electrode_data'=>null,
|
||||||
|
'4_electrode_data'=>json_encode($data),
|
||||||
|
'head_circumference_val'=>$value['head_circumference']?json_decode($value['head_circumference'],true)['value']:null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($temporary_data as $key => $value) {
|
||||||
|
|
||||||
|
$id = $value['id'];
|
||||||
|
$xh_data = $value;
|
||||||
|
unset($xh_data['id']);
|
||||||
|
// dump($xh_data);
|
||||||
|
// 启动事务
|
||||||
|
Db::startTrans();
|
||||||
|
try{
|
||||||
|
Db::table('app_card_body_data_new')->insert($xh_data);
|
||||||
|
Db::table('app_card_body_data')->where(['id'=>$id])->update(['test_type'=>'1']);
|
||||||
|
// 提交事务
|
||||||
|
Db::commit();
|
||||||
|
dump('OK');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
dump($id);
|
||||||
|
// 记录异常信息
|
||||||
|
dump('事务回滚原因:' . $e->getMessage());
|
||||||
|
// dump('异常文件:' . $e->getFile());
|
||||||
|
// dump('异常行号:' . $e->getLine());
|
||||||
|
// dump('SQL错误代码:' . $e->getCode());
|
||||||
|
// dump('########################################################################################################');
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// dump($temporary_data);
|
||||||
|
// die;
|
||||||
// $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
|
// $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
use think\Controller;
|
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Cache;
|
use app\NewReedaw2\controller\app\Cardparts;
|
||||||
use think\Log;
|
use app\NewReedaw2\controller\app\Calculatebody;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
|
||||||
use app\NewReedaw\controller\app\Cardparts;
|
|
||||||
|
|
||||||
class Body extends Base{
|
class Body extends Base{
|
||||||
|
|
||||||
|
|
@ -30,6 +27,7 @@ class Body extends Base{
|
||||||
'list'=>[]
|
'list'=>[]
|
||||||
];
|
];
|
||||||
protected $age_limit = 16;
|
protected $age_limit = 16;
|
||||||
|
protected $pagesize = 15;
|
||||||
protected $unit_name = ['score'=>'身体得分','height'=>'身高','weight'=>'体重','bmi'=>'BMI','fat_r'=>'脂肪率','fat_w'=>'脂肪量','muscle'=>'肌肉率','muscleval'=>'肌肉量','water'=>'水分','bone'=>'骨重','protein'=>'蛋白率','proteinval'=>'蛋白量','kcal'=>'基础代谢','visceral'=>'内脏指数','sfr'=>'皮下脂肪','body_level'=>'肥胖等级','body_type'=>'身体类型'];
|
protected $unit_name = ['score'=>'身体得分','height'=>'身高','weight'=>'体重','bmi'=>'BMI','fat_r'=>'脂肪率','fat_w'=>'脂肪量','muscle'=>'肌肉率','muscleval'=>'肌肉量','water'=>'水分','bone'=>'骨重','protein'=>'蛋白率','proteinval'=>'蛋白量','kcal'=>'基础代谢','visceral'=>'内脏指数','sfr'=>'皮下脂肪','body_level'=>'肥胖等级','body_type'=>'身体类型'];
|
||||||
protected $unit_symbol = ['score'=>'分','height'=>'CM','weight'=>'公斤','bmi'=>'','fat_r'=>'%','fat_w'=>'kg','muscle'=>'%','muscleval'=>'kg','water'=>'kg','bone'=>'kg','protein'=>'%','proteinval'=>'kg','kcal'=>'kcal','visceral'=>'','sfr'=>'%',];
|
protected $unit_symbol = ['score'=>'分','height'=>'CM','weight'=>'公斤','bmi'=>'','fat_r'=>'%','fat_w'=>'kg','muscle'=>'%','muscleval'=>'kg','water'=>'kg','bone'=>'kg','protein'=>'%','proteinval'=>'kg','kcal'=>'kcal','visceral'=>'','sfr'=>'%',];
|
||||||
protected $standard_color = [
|
protected $standard_color = [
|
||||||
|
|
@ -85,7 +83,7 @@ class Body extends Base{
|
||||||
public function body_report(){
|
public function body_report(){
|
||||||
// phpinfo();
|
// phpinfo();
|
||||||
// die;
|
// die;
|
||||||
// try {
|
try {
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
|
|
@ -97,20 +95,243 @@ class Body extends Base{
|
||||||
return $this->msg(10005,'aud_id type error');
|
return $this->msg(10005,'aud_id type error');
|
||||||
}
|
}
|
||||||
return $this->body_report_action_detailed($data);
|
return $this->body_report_action_detailed($data);
|
||||||
// } catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// // 捕获异常
|
// 捕获异常
|
||||||
// $logContent["flie"] = $e->getFile();
|
$logContent["flie"] = $e->getFile();
|
||||||
// $logContent["line"] = $e->getLine();
|
$logContent["line"] = $e->getLine();
|
||||||
// $logContent['all_content'] = "异常信息:\n";
|
$logContent['all_content'] = "异常信息:\n";
|
||||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||||
// $this->record_api_log($data, $logContent, null);
|
$this->record_api_log($data, $logContent, null);
|
||||||
// return $this->msg(99999);
|
return $this->msg(99999);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// 手动记录
|
||||||
|
public function manual_record(){
|
||||||
|
try {
|
||||||
|
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('time', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||||
|
return $this->msg(10005,'time type error');
|
||||||
|
}
|
||||||
|
$temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']);
|
||||||
|
if($temporary_data['height_in_cm'] == false){
|
||||||
|
return $this->msg(10005,'身高单位错误');
|
||||||
|
}
|
||||||
|
if($temporary_data['weight_in_kg'] == false){
|
||||||
|
return $this->msg(10005,'体重单位错误');
|
||||||
|
}
|
||||||
|
$data['height'] = $temporary_data['height_in_cm'];
|
||||||
|
$data['weight'] = $temporary_data['weight_in_kg'];
|
||||||
|
if(strlen($data['time']) <= 12){
|
||||||
|
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||||
|
$data['time'] = $this->addCurrentTimeToDateString($data['time']);
|
||||||
|
}
|
||||||
|
// $data['acd_id'] = '2';
|
||||||
|
return $this->set_user_body_data($data,'by_hand_means');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 设备记录
|
||||||
|
public function device_record(){
|
||||||
|
try {
|
||||||
|
// 你的业务逻辑
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('adc', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['adc'],'num')){
|
||||||
|
return $this->msg(10005,'adc type error');
|
||||||
|
}
|
||||||
|
$temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']);
|
||||||
|
if($temporary_data['height_in_cm'] == false){
|
||||||
|
return $this->msg(10005,'身高单位错误');
|
||||||
|
}
|
||||||
|
if($temporary_data['weight_in_kg'] == false){
|
||||||
|
return $this->msg(10005,'体重单位错误');
|
||||||
|
}
|
||||||
|
// 检测设备传过来的info信息
|
||||||
|
if(array_key_exists('info', $data)){
|
||||||
|
if (!is_array($data['info'])) {
|
||||||
|
return $this->msg(10005,'info参数格式错误');
|
||||||
|
}else{
|
||||||
|
$info_data_arr =['bodyage','fat_r','muscle','kcal','visceral','sfr','water','bone','fatlevlval','protein','bmi'];
|
||||||
|
foreach ($data['info'] as $key => $value) {
|
||||||
|
if (!in_array($key, $info_data_arr)) {
|
||||||
|
return $this->msg(10005,'info参数格式错误-2');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['height'] = $temporary_data['height_in_cm'];
|
||||||
|
$data['weight'] = $temporary_data['weight_in_kg'];
|
||||||
|
$data['time'] = date('Y-m-d H:i:s');
|
||||||
|
return $this->set_user_body_data($data,'by_device');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 获取历史列表(分页)
|
||||||
|
public function record_list_page(){
|
||||||
|
try {
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('page', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005,'token type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
||||||
|
return $this->msg(10005,'page type error');
|
||||||
|
}
|
||||||
|
return $this->record_list_page_or_group_action($data,'page');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 获取历史列表(分组)
|
||||||
|
public function record_list_group(){
|
||||||
|
try {
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005,'token type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['s_time'],'datetime')){
|
||||||
|
return $this->msg(10005,'page type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||||
|
return $this->msg(10005,'page type error');
|
||||||
|
}
|
||||||
|
return $this->record_list_page_or_group_action($data,'group');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 历史记录(详细)
|
||||||
|
public function detailed_record(){
|
||||||
|
try {
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005,'token type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||||
|
return $this->msg(10005,'id type error');
|
||||||
|
}
|
||||||
|
return $this->get_all_detaile_data_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 删除历史数据
|
||||||
|
public function del_record(){
|
||||||
|
try {
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
$user_data = Db::table($this->body_db_name['body_data'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||||
|
if($user_data){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
|
|
@ -223,8 +444,10 @@ class Body extends Base{
|
||||||
}
|
}
|
||||||
// 暂时存储头围数据
|
// 暂时存储头围数据
|
||||||
$head_circumference = $body_last_data[0]['head_circumference']?json_decode($body_last_data[0]['head_circumference'],true):false;
|
$head_circumference = $body_last_data[0]['head_circumference']?json_decode($body_last_data[0]['head_circumference'],true):false;
|
||||||
|
|
||||||
unset($body_last_data[0]['head_circumference']);
|
unset($body_last_data[0]['head_circumference']);
|
||||||
// 处理返回数据
|
// 处理返回数据
|
||||||
|
|
||||||
$result_end = $this->processing_return_data_new($body_last_data[0]);
|
$result_end = $this->processing_return_data_new($body_last_data[0]);
|
||||||
|
|
||||||
$cardparts = new Cardparts;
|
$cardparts = new Cardparts;
|
||||||
|
|
@ -233,7 +456,9 @@ class Body extends Base{
|
||||||
|
|
||||||
$result_end['score'] = $result_end['score'];
|
$result_end['score'] = $result_end['score'];
|
||||||
$result_end['body_type'] = $result_end['body_type'];
|
$result_end['body_type'] = $result_end['body_type'];
|
||||||
|
|
||||||
$result_end = $cardparts->conversion_interval($result_end);
|
$result_end = $cardparts->conversion_interval($result_end);
|
||||||
|
// return $this->msg($result_end);
|
||||||
$result_end['cplist'] = $this->grow_up_recommendation([
|
$result_end['cplist'] = $this->grow_up_recommendation([
|
||||||
'birthday'=>$body_last_data[0]['birthday'],
|
'birthday'=>$body_last_data[0]['birthday'],
|
||||||
'body'=>[
|
'body'=>[
|
||||||
|
|
@ -242,6 +467,7 @@ class Body extends Base{
|
||||||
'bmi'=>$body_last_data[0]['bmi']
|
'bmi'=>$body_last_data[0]['bmi']
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
// return $this->msg($result_end);
|
||||||
|
|
||||||
// // 加入曲线板块底部的减肥计划数据start
|
// // 加入曲线板块底部的减肥计划数据start
|
||||||
// $result_end['target_current'] = $this->base_target_initial_cumulative_weight([
|
// $result_end['target_current'] = $this->base_target_initial_cumulative_weight([
|
||||||
|
|
@ -307,6 +533,9 @@ class Body extends Base{
|
||||||
// 这段业务处理可以删除,是做的临时的,假的start
|
// 这段业务处理可以删除,是做的临时的,假的start
|
||||||
|
|
||||||
$biaozhun_val = $this->body_temporary_use($body_last_data[0]['birthday'],$body_last_data[0]['gender']);
|
$biaozhun_val = $this->body_temporary_use($body_last_data[0]['birthday'],$body_last_data[0]['gender']);
|
||||||
|
//
|
||||||
|
// dump($biaozhun_val);
|
||||||
|
// die;
|
||||||
// dump($biaozhun_val);
|
// dump($biaozhun_val);
|
||||||
// $biaozhun_val_weight = 50;
|
// $biaozhun_val_weight = 50;
|
||||||
// $biaozhun_val_height = 170;
|
// $biaozhun_val_height = 170;
|
||||||
|
|
@ -344,7 +573,318 @@ class Body extends Base{
|
||||||
// dump($result_end);
|
// dump($result_end);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// 用户身体数据卡片记录
|
||||||
|
public function set_user_body_data($data,$type){
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
|
||||||
|
// 判断头围数据是否存在是否合理
|
||||||
|
if(array_key_exists('head_data', $data)){
|
||||||
|
if(!$this->verify_data_is_ok($data['head_data'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$data['head_circumference'] = $data['head_data'];
|
||||||
|
}else{
|
||||||
|
$data['head_circumference'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户信息
|
||||||
|
$user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->field('birthday,gender,target_weight,initial_weight,initial_date')->find();
|
||||||
|
|
||||||
|
if(!$user_data){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
// 如果最初体重设置为null
|
||||||
|
if($user_data['initial_date'] == null){
|
||||||
|
Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
|
||||||
|
$target_current = $this->base_target_initial_cumulative_weight([
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'target_weight'=>$user_data['target_weight'],
|
||||||
|
'initial_weight'=>$data['weight'],
|
||||||
|
'initial_date'=>$data['time'],
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$target_current = $this->base_target_initial_cumulative_weight([
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'target_weight'=>$user_data['target_weight'],
|
||||||
|
'initial_weight'=>$user_data['initial_weight'],
|
||||||
|
'initial_date'=>$user_data['initial_date'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// 设置身高、体重、年龄、性别、阶段称谓、头围、生日、阻抗
|
||||||
|
$result_data['height'] = $data['height'];
|
||||||
|
$result_data['weight'] = $data['weight'];
|
||||||
|
$result_data['age'] = $this->calculate_age($user_data['birthday']);
|
||||||
|
$result_data['gender'] = $user_data['gender'];
|
||||||
|
$result_data['head_circumference'] = $data['head_circumference'];
|
||||||
|
$result_data['birthday'] = $user_data['birthday'];
|
||||||
|
if(array_key_exists('adc', $data)){
|
||||||
|
if($data['adc'] > 0){
|
||||||
|
$result_data['adc'] = $data['adc'];
|
||||||
|
$type = "by_device_adc";
|
||||||
|
}else{
|
||||||
|
$result_data['adc'] = 550;
|
||||||
|
$type = "by_device";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$calculate_body_formula = new Calculatebody();
|
||||||
|
|
||||||
|
// 计算身体数据
|
||||||
|
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
||||||
|
|
||||||
|
if($get_body_value === false){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果年纪小于三岁,处理头围数据star
|
||||||
|
$standardlist = [];
|
||||||
|
if($result_data['age'] < 3){
|
||||||
|
if(array_key_exists('standardlist',$get_body_value)){
|
||||||
|
$standardlist = $get_body_value['standardlist'];
|
||||||
|
foreach ($standardlist as $key => $value) {
|
||||||
|
if($value['name'] == 'head' && count($value['list'] ) > 0){
|
||||||
|
$standardlist = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$standardlist['list2'] = [];
|
||||||
|
foreach ($standardlist['list'] as $key => $value) {
|
||||||
|
array_push($standardlist['list2'],[
|
||||||
|
'min_val'=>$value['minvalue'],
|
||||||
|
'max_val'=>$value['maxvalue'],
|
||||||
|
'text'=>$value['text'],
|
||||||
|
'color'=>$value['color']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
unset($standardlist['list']);
|
||||||
|
unset($get_body_value['standardlist']);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(array_key_exists('standardlist',$get_body_value)){
|
||||||
|
unset($get_body_value['standardlist']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果年纪小于三岁,处理头围数据end
|
||||||
|
$get_body_value['gender'] = $user_data['gender'];
|
||||||
|
$get_body_value['birthday'] = $user_data['birthday'];
|
||||||
|
// 添加身高、体重、bmi、头围(如果有)的标尺标准
|
||||||
|
$get_body_value = $this->hwb_standard($get_body_value);
|
||||||
|
|
||||||
|
|
||||||
|
$enumeration_data = [
|
||||||
|
'fat_r'=>'脂肪率',
|
||||||
|
'muscle'=>'肌肉率',
|
||||||
|
'kcal'=>'基础代谢',
|
||||||
|
'visceral'=>'内脏指数',
|
||||||
|
'sfr'=>'皮下脂肪',
|
||||||
|
'water'=>'水分',
|
||||||
|
'bone'=>'骨重',
|
||||||
|
'protein'=>'蛋白率',
|
||||||
|
'bodyage'=>'身体年龄'
|
||||||
|
];
|
||||||
|
|
||||||
|
// return $this->msg($get_body_value);
|
||||||
|
// 根据秤传过来的数据,去处理要存的结果
|
||||||
|
if(array_key_exists('info', $data)){
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($data['info'] as $key => $value) {
|
||||||
|
if($key == 'bmi'){
|
||||||
|
if($value > 0){
|
||||||
|
$get_body_value['BMI'] = $value;
|
||||||
|
$get_body_value['BMI2'] = explode(',',$get_body_value['BMI2']);
|
||||||
|
$get_body_value['BMI2'][0] = $value;
|
||||||
|
$get_body_value['BMI2'] = implode(',',$get_body_value['BMI2']);
|
||||||
|
}
|
||||||
|
}else if($key == 'bodyage'){
|
||||||
|
$get_body_value[$enumeration_data[$key]] = $value;
|
||||||
|
}else if($key == 'fatlevlval'){
|
||||||
|
continue;
|
||||||
|
}else{
|
||||||
|
if($value > 0){
|
||||||
|
$get_body_value[$enumeration_data[$key]][0] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$set_data = [
|
||||||
|
'acd_id'=>2,
|
||||||
|
'aud_id'=>$data['aud_id'],
|
||||||
|
'record_time'=>array_key_exists('time', $data)?$data['time']:date('Y-m-d H:i:s'),
|
||||||
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'age'=>$get_body_value['age'],
|
||||||
|
'height'=>$get_body_value['身高2'],
|
||||||
|
'height_val'=>$get_body_value['身高'],
|
||||||
|
'weight'=>$get_body_value['体重2'],
|
||||||
|
'weight_val'=>$get_body_value['体重'],
|
||||||
|
'bmi'=>$get_body_value['BMI2'],
|
||||||
|
'bmi_val'=>$get_body_value['BMI'],
|
||||||
|
'score'=>$get_body_value['身体得分'],
|
||||||
|
'fat_r'=> implode(',',$get_body_value['脂肪率']),
|
||||||
|
'fat_w'=>implode(',',$get_body_value['脂肪量']),
|
||||||
|
'muscle'=>implode(',',$get_body_value['肌肉率']),
|
||||||
|
'muscleval'=>implode(',',$get_body_value['肌肉量']),
|
||||||
|
'water'=>implode(',',$get_body_value['水分']),
|
||||||
|
'proteinval'=>implode(',',$get_body_value['蛋白量']),
|
||||||
|
'bone'=>implode(',',$get_body_value['骨重']),
|
||||||
|
'protein'=>implode(',',$get_body_value['蛋白率']),
|
||||||
|
'kcal'=>implode(',',$get_body_value['基础代谢']),
|
||||||
|
'visceral'=>implode(',',$get_body_value['内脏指数']),
|
||||||
|
'sfr'=>implode(',',$get_body_value['皮下脂肪']),
|
||||||
|
'body_level'=>$get_body_value['肥胖等级'],
|
||||||
|
'body_type'=>$get_body_value['身体类型'],
|
||||||
|
'body_age'=>$get_body_value['身体年龄'],
|
||||||
|
'record_type' => $type,
|
||||||
|
'head_circumference' => $result_data['age'] < 3?json_encode($standardlist):"",
|
||||||
|
];
|
||||||
|
if(strlen($set_data['record_time']) <= 12){
|
||||||
|
// 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式
|
||||||
|
$set_data['record_time'] = $this->addCurrentTimeToDateString($set_data['record_time']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启动事务
|
||||||
|
Db::startTrans();
|
||||||
|
try{
|
||||||
|
$set_user_data = Db::table($this->body_db_name['body_data'])->insert($set_data);
|
||||||
|
$update_arr = [
|
||||||
|
'height'=>$get_body_value['身高'],
|
||||||
|
'weight'=>$get_body_value['体重']
|
||||||
|
];
|
||||||
|
if($data['head_circumference']>0){
|
||||||
|
$update_arr['head_data'] = $data['head_circumference'];
|
||||||
|
}
|
||||||
|
$update_user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update($update_arr);
|
||||||
|
// 提交事务
|
||||||
|
Db::commit();
|
||||||
|
return $this->msg([
|
||||||
|
'acd_id'=>2,
|
||||||
|
'height'=>$get_body_value['身高'].',CM',
|
||||||
|
'weight'=>$get_body_value['体重'].',公斤',
|
||||||
|
'bmi'=>$get_body_value['BMI'],
|
||||||
|
'target_current'=>$target_current,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function record_list_page_or_group_action($data,$type){
|
||||||
|
$return_result = [];
|
||||||
|
|
||||||
|
if($type == 'group'){
|
||||||
|
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||||
|
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||||
|
$result = Db::query("
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||||
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||||
|
height_val as v1,
|
||||||
|
weight_val as v2,
|
||||||
|
bmi_val as v3
|
||||||
|
from ".$this->body_db_name['body_data']."
|
||||||
|
where aud_id='".$data['aud_id']."'
|
||||||
|
and record_time between '".$data['s_time']."' and '".$data['e_time']."'
|
||||||
|
and is_del = 0
|
||||||
|
order by record_time desc");
|
||||||
|
foreach ($result as $key => $value) {
|
||||||
|
array_push($return_result, [
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'v1'=>floatval(sprintf("%.2f", $value['v1'])),
|
||||||
|
'v2'=>floatval(sprintf("%.2f", $value['v2'])),
|
||||||
|
'v3'=>floatval(sprintf("%.2f", $value['v3'])),
|
||||||
|
'v1_name'=>'身高',
|
||||||
|
'v2_name'=>'体重',
|
||||||
|
'v3_name'=>'BMI',
|
||||||
|
// 'r_t'=>str_replace('-', '/', $value['r_t'])
|
||||||
|
'r_t'=>$value['r_t']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$result = Db::table($this->body_db_name['body_data'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->field("id,record_time,REPLACE(record_time, '-', '-') AS b_time,height_val,weight_val,bmi_val")->order('record_time desc')->page($data['page'],$this->pagesize)->select();
|
||||||
|
$return_result['totalrows'] = Db::table($this->body_db_name['body_data'])->where(['aud_id'=>$data['aud_id']])->count();
|
||||||
|
$return_result['rows'] = [];
|
||||||
|
$return_result['pageno'] = $data['page'];
|
||||||
|
$return_result['pagesize'] = $this->pagesize;
|
||||||
|
$return_result['totalpage'] = ceil($return_result['totalrows']/$this->pagesize);
|
||||||
|
foreach ($result as $key => $value) {
|
||||||
|
array_push($return_result['rows'],[
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'v1'=>floatval(sprintf("%.2f", $value['height_val'])),
|
||||||
|
'v2'=>floatval(sprintf("%.2f", $value['weight_val'])),
|
||||||
|
'v3'=>floatval(sprintf("%.2f", $value['bmi_val'])),
|
||||||
|
'v1_name'=>'身高',
|
||||||
|
'v2_name'=>'体重',
|
||||||
|
'v3_name'=>'BMI',
|
||||||
|
'record_time'=>$value['b_time'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->msg($return_result);
|
||||||
|
}
|
||||||
|
// 获取详细历史数据信息
|
||||||
|
public function get_all_detaile_data_action($data){
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 设置排除在外的数据类型start
|
||||||
|
$exclude_data_arr = ['height','weight','age','bmi'];
|
||||||
|
// 设置排除在外的数据类型end
|
||||||
|
$result = Db::table($this->body_db_name['body_data'])->where(['id'=>$data['id']])->find();
|
||||||
|
$for_data_arr = ['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'=>['体型','']];
|
||||||
|
if($result){
|
||||||
|
$result_data = [];
|
||||||
|
foreach ($for_data_arr as $key => $value) {
|
||||||
|
$temporary_arr['key_name'] = $key;
|
||||||
|
$temporary_arr['name'] = $value[0];
|
||||||
|
// 身体数据处理,如果没有阻抗,则只显示四项$exclude_data_arr
|
||||||
|
if($result['record_type'] != 'by_device_adc'){
|
||||||
|
if(!in_array($key, $exclude_data_arr)){
|
||||||
|
continue;
|
||||||
|
}else{
|
||||||
|
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if($key == 'un_fat_w_weight'){
|
||||||
|
$temporary_arr['value'] = bcsub(explode(',',$result['weight'])[0],explode(',',$result['fat_w'])[0],2);
|
||||||
|
}else{
|
||||||
|
if(array_key_exists($key,$result)){
|
||||||
|
$temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$temporary_arr['unit'] = $value[1];
|
||||||
|
array_push($result_data,$temporary_arr);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// 添加头围详细start
|
||||||
|
if($result['head_circumference'] != null){
|
||||||
|
array_unshift($result_data,[
|
||||||
|
'key_name'=>'head_circumference',
|
||||||
|
'name'=>'头围',
|
||||||
|
'value'=>json_decode($result['head_circumference'],true)['value'] == 0?"0":json_decode($result['head_circumference'],true)['value'],
|
||||||
|
'unit'=>'cm',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// 添加头围详细end
|
||||||
|
return $this->msg($result_data);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10004);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
################################################################内部调用################################################################
|
||||||
public function processing_return_data_new($data){
|
public function processing_return_data_new($data){
|
||||||
$result_end_data = [];
|
$result_end_data = [];
|
||||||
$month_num = $this->calculateAgeInMonthsWithPrecision($data['birthday']);
|
$month_num = $this->calculateAgeInMonthsWithPrecision($data['birthday']);
|
||||||
|
|
@ -655,9 +1195,86 @@ class Body extends Base{
|
||||||
}
|
}
|
||||||
return $return_data;
|
return $return_data;
|
||||||
}
|
}
|
||||||
// public function body_report_action_detailed($data){
|
|
||||||
|
|
||||||
// }
|
// 添加身高体重bmi的标准
|
||||||
|
public function hwb_standard($data){
|
||||||
|
$linshi_data = [];
|
||||||
|
$month_num = $this->calculateAgeInMonthsWithPrecision($data['birthday']);
|
||||||
|
$gender_val = $data['gender'];
|
||||||
|
if($data['age'] < $this->age_limit){
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
if($key =='身高'){
|
||||||
|
$linshi_data['身高'] = $this->bhw_list['height'];
|
||||||
|
$bhw_date = Db::table($this->body_db_name['heigh'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||||
|
|
||||||
|
if($bhw_date){
|
||||||
|
$linshi_data['身高'][0]['max_val'] = $bhw_date[0]['f2sd'];
|
||||||
|
$linshi_data['身高'][1]['min_val'] = $bhw_date[0]['f2sd'];
|
||||||
|
$linshi_data['身高'][1]['max_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['身高'][2]['min_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['身高'][2]['max_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['身高'][3]['min_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['身高'][3]['max_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
$linshi_data['身高'][4]['min_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
$linshi_data['身高'][4]['max_val'] = $bhw_date[0]['z3sd'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if($key =='体重'){
|
||||||
|
$linshi_data['体重'] = $this->bhw_list['weight'];
|
||||||
|
$bhw_date = Db::table($this->body_db_name['weigh'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||||
|
if($bhw_date){
|
||||||
|
$linshi_data['体重'][0]['max_val'] = $bhw_date[0]['f2sd'];
|
||||||
|
$linshi_data['体重'][1]['min_val'] = $bhw_date[0]['f2sd'];
|
||||||
|
$linshi_data['体重'][1]['max_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['体重'][2]['min_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['体重'][2]['max_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['体重'][3]['min_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['体重'][3]['max_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
$linshi_data['体重'][4]['min_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
$linshi_data['体重'][4]['max_val'] = $bhw_date[0]['z3sd'];
|
||||||
|
}
|
||||||
|
}else if($key =='BMI'){
|
||||||
|
$linshi_data['BMI'] = $this->bhw_list['bmi'];
|
||||||
|
$bhw_date = Db::table($this->body_db_name['bmi'])->where("Month <= $month_num and Sex = '$gender_val'")->order('Month desc')->limit(1)->select();
|
||||||
|
if($bhw_date){
|
||||||
|
$linshi_data['BMI'][0]['max_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['BMI'][1]['min_val'] = $bhw_date[0]['f1sd'];
|
||||||
|
$linshi_data['BMI'][1]['max_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['BMI'][2]['min_val'] = $bhw_date[0]['z1sd'];
|
||||||
|
$linshi_data['BMI'][2]['max_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
$linshi_data['BMI'][3]['min_val'] = $bhw_date[0]['z2sd'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($linshi_data as $key => $value) {
|
||||||
|
foreach ($value as $k => $v) {
|
||||||
|
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
|
||||||
|
// 如果落在区间内
|
||||||
|
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果$key.'2'没有被设置
|
||||||
|
if(!array_key_exists($key.'2', $data)){
|
||||||
|
if($data[$key] < $value[0]['min_val']){
|
||||||
|
// 如果小于最小值
|
||||||
|
$data[$key.'2'] = $data[$key].','.$value[0]['text'].','.$value[0]['color'];
|
||||||
|
}else if($data[$key] >= $value[count($value)-1]['max_val']){
|
||||||
|
// 如果大于最大值
|
||||||
|
$data[$key.'2'] = $data[$key].','.$value[count($value)-1]['text'].','.$value[count($value)-1]['color'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// die;
|
||||||
|
}else{
|
||||||
|
$data['身高2'] = $data['身高'].',无,无';
|
||||||
|
$data['体重2'] = $data['体重'].',无,无';
|
||||||
|
$data['BMI2'] = $data['BMI'].',无,无';
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class Business extends Base{
|
||||||
|
|
||||||
|
public function business_cooperation(){
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function business_cooperation_action(){
|
||||||
|
$data = input();
|
||||||
|
$result = Db::table('admin_business_cooperation_log')->insert([
|
||||||
|
'name'=>$data['name'],
|
||||||
|
'tel'=>$data['phone'],
|
||||||
|
'company'=>$data['company'],
|
||||||
|
'intention_data'=>implode(',',$data['selectedValues']),
|
||||||
|
'notes_data'=>$data['remark'],
|
||||||
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
|
]);
|
||||||
|
if($result){
|
||||||
|
$this->send_email_api_error(["19759414@qq.com"],['title'=>'商户合作','from_user_name'=>'reedaw商务','content'=>'有一封商户合作']);
|
||||||
|
// $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'商户合作','from_user_name'=>'reedaw商务','content'=>'有一封商户合作']);
|
||||||
|
|
||||||
|
return json(['code'=>0,'msg'=>'提交成功']);
|
||||||
|
}else{
|
||||||
|
return json(['code'=>10001,'msg'=>'网络错误']);
|
||||||
|
// return json(['code'=>10001,'msg'=>'网络错误,请直接联系商务合作电话/微信:13590959084']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,638 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Calculatebody extends Base{
|
||||||
|
|
||||||
|
// 默认阻抗值
|
||||||
|
protected $default_adc = 550;
|
||||||
|
// 体重 = weight weight
|
||||||
|
// 身高 = height height
|
||||||
|
// BMI = bmi bmi
|
||||||
|
// age = age age
|
||||||
|
// 身体得分 = cmi cmi
|
||||||
|
// 脂肪量 = fat_w bfrval
|
||||||
|
// 脂肪率 = fat_r bfr
|
||||||
|
// 肌肉量 = muscleval romval
|
||||||
|
// 肌肉率 = muscle rom
|
||||||
|
// 水分 = water vwc
|
||||||
|
// 蛋白量 = proteinval ppval
|
||||||
|
// 蛋白率 = protein pp
|
||||||
|
// 骨重 = bone bm
|
||||||
|
// 基础代谢 = kcal bmr
|
||||||
|
// 内脏指数 = visceral uvi
|
||||||
|
// 皮下脂肪 = sfr sfr
|
||||||
|
// 肥胖等级 = standard_level fatlevel (fatlevelName)
|
||||||
|
// 身体年龄 = bodyage bodyage
|
||||||
|
// 去脂体重 = lbm lbm
|
||||||
|
// 身体类型 = body body
|
||||||
|
|
||||||
|
public function calculate_body_data_result($data = ['weight'=>52.5,'height'=>165,'age'=>30,'gender'=>1]){
|
||||||
|
$data['gender'] = $data['gender'] == 0 ? 1 : $data['gender'];
|
||||||
|
|
||||||
|
$data['adc'] = array_key_exists('adc', $data)?$data['adc']:$this->default_adc;
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
|
||||||
|
// 青测自己写的计算start
|
||||||
|
// $result = $this->calculate_body_data($data['height'],$data['weight'],$data['age'],$data['gender'],$data['adc']);
|
||||||
|
// // $result['fat_w'] = $result['fat_r'] / 100 * $data['weight'];
|
||||||
|
// $result['fat_w'] = bcmul(bcdiv($result['fat_r'],'100',20),$data['weight'],2);
|
||||||
|
// // $result['proteinval'] = $result['protein'] / 100 * $data['weight'];
|
||||||
|
// $result['proteinval'] = bcmul(bcdiv($result['protein'],'100',20),$data['weight'],2);
|
||||||
|
// //肌肉量=体重-脂肪量-骨量
|
||||||
|
// // $result['muscleval'] = $result['weight'] - $result['fat_w'] - $result['bone'];
|
||||||
|
// $result['muscleval'] = bcsub(bcsub($result['weight'],$result['fat_w'],20),$result['bone'],2);
|
||||||
|
// // $result['muscle'] = $result['muscleval'] / $data['weight'] * 100.0;
|
||||||
|
// $result['muscle'] = bcmul(bcdiv($result['muscleval'],$data['weight'],20),'100.0',2);
|
||||||
|
// // 水份=肌肉量-蛋白量
|
||||||
|
// // $result['water'] = $result['muscleval'] - $result['proteinval'];
|
||||||
|
// $result['water'] = bcsub($result['muscleval'],$result['proteinval'],2);
|
||||||
|
// // $result['lbm'] = (1 - $result['fat_r'] / 100) * $data['weight'];
|
||||||
|
// $result['lbm'] = bcmul(bcsub('1',bcdiv($result['fat_r'],'100',20),20),$data['weight'],2);
|
||||||
|
// 青测自己写的计算end
|
||||||
|
|
||||||
|
// 使用接口调用之前的进行计算start
|
||||||
|
$url = 'https://klcz.pcxbc.com/open-api/calc/healthcalc/bodyfat3';
|
||||||
|
if($data['age'] < '3'){
|
||||||
|
$temporary_parameter = [
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'height'=>$data['height'],
|
||||||
|
'age'=>round($data['age']),//四舍五入取整
|
||||||
|
'adc'=>round($data['adc']),//四舍五入取整
|
||||||
|
'gender'=>$data['gender'],
|
||||||
|
'head'=>$data['head_circumference'],
|
||||||
|
'hasStandardList'=>true,
|
||||||
|
'birthDay'=>$data['birthday'],
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$temporary_parameter = [
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'height'=>$data['height'],
|
||||||
|
'age'=>round($data['age']),//四舍五入取整
|
||||||
|
'adc'=>round($data['adc']),//四舍五入取整
|
||||||
|
'gender'=>$data['gender'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$request_result = $this->postRequest($url,$temporary_parameter);
|
||||||
|
if($request_result['code'] != 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['weight'] = $request_result['data']['weight'];
|
||||||
|
$result['height'] = $request_result['data']['height'];
|
||||||
|
$result['bmi'] = $request_result['data']['bmi'];
|
||||||
|
$result['age'] = $request_result['data']['age'];
|
||||||
|
$result['cmi'] = $request_result['data']['cmi'];
|
||||||
|
$result['fat_w'] = $request_result['data']['bfrval'];
|
||||||
|
$result['fat_r'] = $request_result['data']['bfr'];
|
||||||
|
$result['muscleval'] = $request_result['data']['romval'];
|
||||||
|
$result['muscle'] = $request_result['data']['rom'];
|
||||||
|
$result['water'] = $request_result['data']['vwc'];
|
||||||
|
$result['proteinval'] = $request_result['data']['ppval'];
|
||||||
|
$result['protein'] = $request_result['data']['pp'];
|
||||||
|
$result['bone'] = $request_result['data']['bm'];
|
||||||
|
$result['kcal'] = $request_result['data']['bmr'];
|
||||||
|
$result['visceral'] = $request_result['data']['uvi'];
|
||||||
|
$result['sfr'] = $request_result['data']['sfr'];
|
||||||
|
$result['standard_level'] = $request_result['data']['fatlevelname'];
|
||||||
|
$result['bodyage'] = $request_result['data']['bodyage'];
|
||||||
|
$result['lbm'] = $request_result['data']['lbm'];
|
||||||
|
$result['body'] = $request_result['data']['body'];
|
||||||
|
// 使用接口调用之前的进行计算end
|
||||||
|
|
||||||
|
$return_data['standardlist'] = $request_result['data']['standardlist'];
|
||||||
|
$return_data['体重'] = $data['weight'];
|
||||||
|
$return_data['身高'] = $data['height'];
|
||||||
|
$return_data['BMI'] = $result['bmi'];
|
||||||
|
$return_data['age'] = $result['age'];
|
||||||
|
|
||||||
|
// 身体得分修改start
|
||||||
|
// if($result['bmi']<21.6){
|
||||||
|
// $return_data['身体得分'] = bcmul(bcdiv($result['bmi'],'21.6',20),'100',0);
|
||||||
|
// }else{
|
||||||
|
// $return_data['身体得分'] = bcmul(bcdiv('21.6',$result['bmi'],20),'100',0);
|
||||||
|
// }
|
||||||
|
$return_data['身体得分'] = $result['cmi'];
|
||||||
|
// 身体得分修改end
|
||||||
|
|
||||||
|
$return_data['脂肪量'][0] = $result['fat_w'];
|
||||||
|
$return_data['脂肪率'][0] = $result['fat_r'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $data['age']<30 && $result['fat_r']<10) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && $result['fat_r']<11) ||
|
||||||
|
($data['gender']==2 && $data['age']<30 && $result['fat_r']<20) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && $result['fat_r']<21)){
|
||||||
|
$return_data['脂肪率'][1] = '偏低';
|
||||||
|
$return_data['脂肪量'][1] = '偏低';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=10 && $result['fat_r']<21) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=11 && $result['fat_r']<22) ||
|
||||||
|
($data['gender']==2 && $data['age']<30 && $result['fat_r']>=20 && $result['fat_r']<31) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && $result['fat_r']>=21 && $result['fat_r']<32)){
|
||||||
|
$return_data['脂肪率'][1] = '标准';
|
||||||
|
$return_data['脂肪量'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=21 && $result['fat_r']<26) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=22 && $result['fat_r']<27) ||
|
||||||
|
($data['gender']==2 && $data['age']<30 && $result['fat_r']>=31 && $result['fat_r']<38) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && $result['fat_r']>=32 && $result['fat_r']<39)){
|
||||||
|
$return_data['脂肪率'][1] = '偏高';
|
||||||
|
$return_data['脂肪量'][1] = '偏高';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['age']<30 && $result['fat_r']>=26) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && $result['fat_r']>=27) ||
|
||||||
|
($data['gender']==2 && $data['age']<30 && $result['fat_r']<38) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && $result['fat_r']<39)){
|
||||||
|
$return_data['脂肪率'][1] = '高';
|
||||||
|
$return_data['脂肪量'][1] = '高';
|
||||||
|
}else{
|
||||||
|
$return_data['脂肪率'][1] = '异常';
|
||||||
|
$return_data['脂肪量'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['肌肉量'][0] = $result['muscleval'];
|
||||||
|
$return_data['肌肉率'][0] = $result['muscle'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $result['muscle']<40) ||
|
||||||
|
($data['gender']==2 && $result['muscle']<30)){
|
||||||
|
$return_data['肌肉量'][1] = '不足';
|
||||||
|
$return_data['肌肉率'][1] = '不足';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['muscle']>=40 && $result['muscle']<60) ||
|
||||||
|
($data['gender']==2 && $result['muscle']>=30 && $result['muscle']<50)){
|
||||||
|
$return_data['肌肉量'][1] = '标准';
|
||||||
|
$return_data['肌肉率'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['muscle']>=60) ||
|
||||||
|
($data['gender']==2 && $result['muscle']>=50)){
|
||||||
|
$return_data['肌肉量'][1] = '优';
|
||||||
|
$return_data['肌肉率'][1] = '优';
|
||||||
|
}else{
|
||||||
|
$return_data['肌肉量'][1] = '异常';
|
||||||
|
$return_data['肌肉率'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['水分'][0] = $result['water'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $result['water']<55) ||
|
||||||
|
($data['gender']==2 && $result['water']<45)){
|
||||||
|
$return_data['水分'][1] = '不足';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['water']>=55 && $result['water']<65) ||
|
||||||
|
($data['gender']==2 && $result['water']>=45 && $result['water']<60)){
|
||||||
|
$return_data['水分'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['water']>65) ||
|
||||||
|
($data['gender']==2 && $result['water']>60)){
|
||||||
|
$return_data['水分'][1] = '优';
|
||||||
|
}else{
|
||||||
|
$return_data['水分'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['蛋白量'][0] = $result['proteinval'];
|
||||||
|
$return_data['蛋白率'][0] = $result['protein'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $result['protein']<16) ||
|
||||||
|
($data['gender']==2 && $result['protein']<14)){
|
||||||
|
$return_data['蛋白量'][1] = '不足';
|
||||||
|
$return_data['蛋白率'][1] = '不足';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['protein']>=16 && $result['protein']<18) ||
|
||||||
|
($data['gender']==2 && $result['protein']>=14 && $result['protein']<16)){
|
||||||
|
$return_data['蛋白量'][1] = '标准';
|
||||||
|
$return_data['蛋白率'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['protein']>18) ||
|
||||||
|
($data['gender']==2 && $result['protein']>16)){
|
||||||
|
$return_data['蛋白量'][1] = '优';
|
||||||
|
$return_data['蛋白率'][1] = '优';
|
||||||
|
}else{
|
||||||
|
$return_data['蛋白量'][1] = '异常';
|
||||||
|
$return_data['蛋白率'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['骨重'][0] = $result['bone'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $data['weight']<60 && $result['bone']<2.4) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']<2.8) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=75 && $result['bone']<3.1) ||
|
||||||
|
($data['gender']==2 && $data['weight']<45 && $result['bone']<1.7) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']<2.1) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=60 && $result['bone']<2.4)){
|
||||||
|
$return_data['骨重'][1] = '不足';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['weight']<60 && $result['bone']>=2.4 && $result['bone']<=2.6) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']>=2.8 && $result['bone']<=3) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=75 && $result['bone']>=3.1 && $result['bone']<=3.3) ||
|
||||||
|
($data['gender']==2 && $data['weight']<45 && $result['bone']>=1.7 && $result['bone']<=1.9) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']>=2.1 && $result['bone']<=2.3) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=60 && $result['bone']>=2.4 && $result['bone']<=2.6)){
|
||||||
|
$return_data['骨重'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['weight']<60 && $result['bone']>2.6) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=60 && $data['weight']<75 && $result['bone']>3) ||
|
||||||
|
($data['gender']==1 && $data['weight']>=75 && $result['bone']<3.3) ||
|
||||||
|
($data['gender']==2 && $data['weight']<45 && $result['bone']>1.9) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=45 && $data['weight']<60 && $result['bone']>2.3) ||
|
||||||
|
($data['gender']==2 && $data['weight']>=60 && $result['bone']>2.6)){
|
||||||
|
$return_data['骨重'][1] = '优';
|
||||||
|
}else{
|
||||||
|
$return_data['骨重'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['基础代谢'][0] = $result['kcal'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $data['age']>0 && $data['age']<3 && (60.9*$data['weight']-54)>$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=3 && $data['age']<10 && (22.7*$data['weight']+495)>$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=10 && $data['age']<18 && (17.5*$data['weight']+651)>$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=18 && $data['age']<30 && (15.3*$data['weight']+679)>$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && (11.6*$data['weight']+879)>$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>0 && $data['age']<3 && (61*$data['weight']-51)>$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=3 && $data['age']<10 && (22.5*$data['weight']+499)>$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=10 && $data['age']<18 && (12.2*$data['weight']+746)>$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=18 && $data['age']<30 && (14.7*$data['weight']+496)>$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && (8.7*$data['weight']+820)>$result['kcal'])){
|
||||||
|
$return_data['基础代谢'][1] = '偏低';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $data['age']>0 && $data['age']<3 && (60.9*$data['weight']-54)<=$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=3 && $data['age']<10 && (22.7*$data['weight']+495)<=$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=10 && $data['age']<18 && (17.5*$data['weight']+651)<=$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=18 && $data['age']<30 && (15.3*$data['weight']+679)<=$result['kcal']) ||
|
||||||
|
($data['gender']==1 && $data['age']>=30 && (11.6*$data['weight']+879)<=$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>0 && $data['age']<3 && (61*$data['weight']-51)<=$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=3 && $data['age']<10 && (22.5*$data['weight']+499)<=$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=10 && $data['age']<18 && (12.2*$data['weight']+746)<=$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=18 && $data['age']<30 && (14.7*$data['weight']+496)<=$result['kcal']) ||
|
||||||
|
($data['gender']==2 && $data['age']>=30 && (8.7*$data['weight']+820)<=$result['kcal'])){
|
||||||
|
$return_data['基础代谢'][1] = '优';
|
||||||
|
}else{
|
||||||
|
$return_data['基础代谢'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['内脏指数'][0] = $result['visceral'];
|
||||||
|
if($result['visceral']<9){
|
||||||
|
$return_data['内脏指数'][1] = '标准';
|
||||||
|
}else if($result['visceral']>=9 && $result['visceral']<14){
|
||||||
|
$return_data['内脏指数'][1] = '警惕';
|
||||||
|
}else if($result['visceral']>=14){
|
||||||
|
$return_data['内脏指数'][1] = '危险';
|
||||||
|
}else{
|
||||||
|
$return_data['内脏指数'][1] = '异常';
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['皮下脂肪'][0] = $result['sfr'];
|
||||||
|
if(
|
||||||
|
($data['gender']==1 && $result['sfr']<7) ||
|
||||||
|
($data['gender']==2 && $result['sfr']<11)){
|
||||||
|
$return_data['皮下脂肪'][1] = '不足';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['sfr']>=7 && $result['sfr']<15) ||
|
||||||
|
($data['gender']==2 && $result['sfr']>=11 && $result['sfr']<17)){
|
||||||
|
$return_data['皮下脂肪'][1] = '标准';
|
||||||
|
}else if(
|
||||||
|
($data['gender']==1 && $result['sfr']>=15) ||
|
||||||
|
($data['gender']==2 && $result['sfr']>=17)){
|
||||||
|
$return_data['皮下脂肪'][1] = '偏高';
|
||||||
|
}else{
|
||||||
|
$return_data['皮下脂肪'][1] = '异常';
|
||||||
|
}
|
||||||
|
// 脂肪率:偏低 标准 偏高 高
|
||||||
|
// 肌肉率:不足 标准 优
|
||||||
|
|
||||||
|
// 肥胖等级修改start
|
||||||
|
// // if($data['age']>=16){
|
||||||
|
// if($result['standard_level']<-0.2){
|
||||||
|
// $return_data['肥胖等级'] = '体重不足';
|
||||||
|
// }else if($result['standard_level']>=-0.2 && $result['standard_level']<-0.1){
|
||||||
|
// $return_data['肥胖等级'] = '偏瘦';
|
||||||
|
// }else if($result['standard_level']>=-0.1 && $result['standard_level']<=0.1){
|
||||||
|
// $return_data['肥胖等级'] = '标准';
|
||||||
|
// }else if($result['standard_level']>0.1 && $result['standard_level']<=0.2){
|
||||||
|
// $return_data['肥胖等级'] = '偏重';
|
||||||
|
// }else if($result['standard_level']>0.2){
|
||||||
|
// $return_data['肥胖等级'] = '超重';
|
||||||
|
// }else{
|
||||||
|
// $return_data['肥胖等级'] = '暂无数据';
|
||||||
|
// }
|
||||||
|
// // }else{
|
||||||
|
// // $return_data['肥胖等级'] = '儿童';
|
||||||
|
// // }
|
||||||
|
$return_data['肥胖等级'] = $result['standard_level'];
|
||||||
|
// 肥胖等级修改end
|
||||||
|
|
||||||
|
|
||||||
|
// 身体类型修改start
|
||||||
|
// // if($data['age']>=16){
|
||||||
|
// if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '不足'){
|
||||||
|
// $return_data['身体类型'] = '隐形肥胖';
|
||||||
|
// }else if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '标准'){
|
||||||
|
// $return_data['身体类型'] = '偏胖';
|
||||||
|
// }else if(($return_data['脂肪率'][1] == '高' || $return_data['脂肪率'][1] == '偏高') && $return_data['肌肉率'][1] == '优'){
|
||||||
|
// $return_data['身体类型'] = '结实型偏胖';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '不足'){
|
||||||
|
// $return_data['身体类型'] = '缺乏肌肉型';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '标准'){
|
||||||
|
// $return_data['身体类型'] = '标准型';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '标准' && $return_data['肌肉率'][1] == '优'){
|
||||||
|
// $return_data['身体类型'] = '标准肌肉型';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '不足'){
|
||||||
|
// $return_data['身体类型'] = '偏瘦';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '标准'){
|
||||||
|
// $return_data['身体类型'] = '偏瘦肌肉型';
|
||||||
|
// }else if($return_data['脂肪率'][1] == '偏低' && $return_data['肌肉率'][1] == '优'){
|
||||||
|
// $return_data['身体类型'] = '健美肌肉型';
|
||||||
|
// }else{
|
||||||
|
// $return_data['身体类型'] = '暂无数据';
|
||||||
|
// }
|
||||||
|
// // }else{
|
||||||
|
// // $return_data['身体类型'] = '儿童';
|
||||||
|
// // }
|
||||||
|
$return_data['身体类型'] = $result['body'];
|
||||||
|
// 身体类型修改end
|
||||||
|
|
||||||
|
$return_data['身体年龄'] = $result['bodyage'];
|
||||||
|
|
||||||
|
// $result_end['fat_r'] = $result['fat_r'];
|
||||||
|
// $result_end['muscle'] = $result['muscle'];
|
||||||
|
// $result_end['water'] = $result['water'];
|
||||||
|
// $result_end['bone'] = $result['bone'];
|
||||||
|
// $result_end['kcal'] = $result['kcal'];
|
||||||
|
// $result_end['fat_w'] = $result['fat_w'];
|
||||||
|
// $result_end['visceral'] = $result['visceral'];
|
||||||
|
// $result_end['protein'] = $result['protein'];
|
||||||
|
// $result_end['bodyage'] = $result['bodyage'];
|
||||||
|
// $result_end['bmi'] = $result['bmi'];
|
||||||
|
// // $result_end['cmi'] = $result['cmi'];
|
||||||
|
// $result_end['sfr'] = $result['sfr'];
|
||||||
|
// // $result_end['sfrval'] = $result['sfrval'];
|
||||||
|
// $result_end['skeletalmuscle'] = $result['skeletalmuscle'];
|
||||||
|
// $result_end['muscleval'] = $result['muscleval'];
|
||||||
|
// $result_end['proteinval'] = $result['proteinval'];
|
||||||
|
// $result_end['lbm'] = $result['lbm'];
|
||||||
|
// $result_end['weight'] = $result['weight'];
|
||||||
|
// $result_end['height'] = $result['height'];
|
||||||
|
return $return_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
|
||||||
|
// 计算身体数据,BMI、脂肪率、脂肪量、肌肉率、肌肉量....
|
||||||
|
public function calculate_body_data($height,$weight,$age,$gender,$impedance){
|
||||||
|
|
||||||
|
$result_data = [];
|
||||||
|
$mheight = bcdiv($height, '100', 20); // 假设我们保留20位小数
|
||||||
|
$gender = $gender == 0 ? 1 : $gender;
|
||||||
|
|
||||||
|
if (($weight <= 0) || ($weight > 220) || ($height <= 0) || ($height > 270) || ($age <= 0) || ($age > 120) || ($impedance <= 0) || ($impedance > 1000) || !in_array($gender, [1, 2])) {
|
||||||
|
if ($weight != 0 && $height != 0) {
|
||||||
|
// 计算BMI
|
||||||
|
$bmi = bcdiv($weight, bcmul($mheight, $mheight,20), 2);
|
||||||
|
$result_data['bmi'] = $bmi;
|
||||||
|
$result_data['bone'] = 0;
|
||||||
|
$result_data['muscle'] = 0;
|
||||||
|
$result_data['water'] = 0;
|
||||||
|
$result_data['fat_r'] = 0;
|
||||||
|
$result_data['sfr'] = 0;
|
||||||
|
$result_data['skeletalmuscle'] = 0;
|
||||||
|
$result_data['protein'] = 0;
|
||||||
|
$result_data['visceral'] = 0;
|
||||||
|
$result_data['kcal'] = 0;
|
||||||
|
$result_data['bodyage'] = 0;
|
||||||
|
$result_data['weight'] = $weight;
|
||||||
|
$result_data['height'] = $height;
|
||||||
|
$result_data['age'] = $age;
|
||||||
|
$result_data['adc'] = $impedance;
|
||||||
|
$result_data['gender'] = $gender;
|
||||||
|
$result_data['standard_level'] = 0.0;
|
||||||
|
return $result_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$num = intval(bcmul(bcdiv($weight,bcmul($mheight,$mheight,20),20),'10',20))/10;
|
||||||
|
$num2 = 0.0;
|
||||||
|
$num3 = 0.0;
|
||||||
|
$num4 = 0.0;
|
||||||
|
$num5 = 0.0;
|
||||||
|
$num6 = 0.0;
|
||||||
|
$num7 = 0.0;
|
||||||
|
$num8 = 0.0;
|
||||||
|
$num9 = 0.0;
|
||||||
|
$num10 = 0.0;
|
||||||
|
$num11 = 0.0;
|
||||||
|
// 根据男女计算脂肪率、脂肪量、肌肉率、肌肉量等等....
|
||||||
|
$standard_weight = 0.0;
|
||||||
|
$standard_level = 0.0;
|
||||||
|
if ($gender == 1){
|
||||||
|
// $num2 = 0.015 * $weight + (2.0 - 0.00055 * $impedance) * $height / 100 - 1.15;
|
||||||
|
$num2 = bcsub(bcadd(bcmul('0.015',$weight,20),bcdiv(bcmul(bcsub('2.0',bcmul('0.00055',$impedance,20),20),$height,20),'100.0',20),20),'1.15',2);
|
||||||
|
// $num3 = (0.0 - (0.00115 * $impedance + 0.01)) * $weight + (49.64 - 0.031 * $impedance) * $height / 100.0 + $impedance * 0.08 + $age * 0.04 + 15.4;
|
||||||
|
$num3 = bcsub(bcsub(bcsub(bcsub(bcmul(bcsub('0.0',bcadd(bcmul('0.00115',$impedance,20),'0.01',20),20),$weight,20),bcdiv(bcmul(bcsub('49.64',bcmul('0.031',$impedance,20)),$height,20),'100.0',20),20),bcmul($impedance,'0.08'),20),bcmul($age,'0.04'),20),'15.4',2);
|
||||||
|
// $num4 = 1000000.0/($num*(2.688*$impedance-78.28))-(10058/$impedance)-0.22*$age+52.6;
|
||||||
|
$num4 = bcadd(bcsub(bcsub(bcdiv('1000000.0',bcmul($num,bcsub(bcmul('2.688',$impedance,20),'78.28',20),20),20),bcdiv('10058',$impedance,20),20),bcmul('0.22',$age,20),20),'52.6',20);
|
||||||
|
// $num5 = -930000.0 / $num / (1.966 * $impedance - 58.46) + (13176 / $impedance) - 0.06 * $age + 40.0;
|
||||||
|
$num5 = bcadd(bcsub(bcadd(bcdiv(bcdiv('-930000.0',$num,20),bcsub(bcmul('1.966',$impedance,20),'58.46',20),20),bcdiv('13176',$impedance,0),20),bcmul('0.06',$age,20),20),'40.0',20);
|
||||||
|
// $num6 = 0.898 * $num5;
|
||||||
|
$num6 = bcmul('0.898',$num5,1);
|
||||||
|
// $num7 = 0.895 * $num4;
|
||||||
|
$num7 = bcmul('0.895',$num4,20);
|
||||||
|
// $num8 = 0.8 * (100.0 - $num5 - $num4 - $num2 / $weight);
|
||||||
|
$num8 = bcmul('0.8',bcsub(bcsub(bcsub('100.0',$num5,20),$num4,20),bcdiv($num2,$weight,20),20),2);
|
||||||
|
// $num9 = 0.304 * $weight - 25.58 * $height / 100.0 + 0.131 * $age + 0.005 * $impedance + 22.0;
|
||||||
|
$num9 = bcadd(bcadd(bcadd(bcsub(bcmul('0.304',$weight,20),bcdiv(bcmul('25.58',$height,20),'100.0',20),20),bcmul('0.131',$age,20),20),bcmul('0.005',$impedance,20),20),'22.0',0);
|
||||||
|
// $num10 = (9.0 + 0.0015 * $impedance) * $weight + (1350.0 - 0.88 * $impedance) * $height / 100.0 + (188 / $age) + 0.748 * $impedance - 1053.0;
|
||||||
|
$num10 = bcsub(bcadd(bcadd(bcadd(bcmul(bcadd('9.0',bcmul('0.0015',$impedance,20),20),$weight,20),bcdiv(bcmul(bcsub('1350.0',bcmul('0.88',$impedance,20),20),$height,20),'100.0',20),20),bcdiv('188',$age,20),20),bcmul('0.748',$impedance,20),20),'1053.0',0);
|
||||||
|
// $num11 = $age * (1.0 + 0.012 * ($num - 1.0)) - 21.0 + (30 - $age) * 0.35 + ($impedance - 450) * 0.02 + 11.0;
|
||||||
|
$num11 = bcadd(bcadd(bcadd(bcsub(bcmul($age,bcadd('1.0',bcmul('0.012',bcsub($num,'1.0',20),20),20),20),'21.0',20),bcmul(bcsub('30',$age,20),'0.35',20),20),bcmul(bcsub($impedance,'450',20),'0.02',20),20),'11.0',0);
|
||||||
|
|
||||||
|
// $standard_weight = ($height-80)*0.7;
|
||||||
|
$standard_weight = bcmul(bcsub($height,'80',20),'0.7',20);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// $num2 = 2.2E-05 * $impedance * $weight + (4.99 - 0.00284 * $impedance) * $height / 100.0 + 0.0012 * $impedance - 4.45;
|
||||||
|
$num2 = bcsub(bcadd(bcadd(bcmul(bcmul('0.000022',$impedance,20),$weight,20),bcdiv(bcmul(bcsub('4.99',bcmul('0.00284',$impedance,20),20),$height,20),'100.0',20),20),bcmul('0.0012',$impedance,20),20),'4.45',2);
|
||||||
|
// $num3 = (0.0 - (0.00115 * $impedance + 0.01)) * $weight + (49.64 - 0.031 * $impedance) * $height / 100.0 + $impedance * 0.08 + $age * 0.04 + 6.0;
|
||||||
|
$num3 = bcadd(bcadd(bcadd(bcadd(bcmul(bcsub('0.0',bcadd(bcmul('0.00115',$impedance,20),'0.01',20),20),$weight,20),bcdiv(bcmul(bcsub('49.64',bcmul('0.031',$impedance,20),20),$height,20),'100.0',20),20),bcmul($impedance,'0.08',20),20),bcmul($age,'0.04',20),20),'6.0',2);
|
||||||
|
// $num4 = 1000000.0 / ($num * (2.467 * $impedance - 75.37)) - (14215 / $impedance) - 0.034 * $age + 43.2;
|
||||||
|
$num4 = bcadd(bcsub(bcsub(bcdiv('1000000.0',bcmul($num,bcsub(bcmul('2.467',$impedance,20),'75.37',20),20),20),bcdiv('14215',$impedance,20),20),bcmul('0.034',$age,20),20),'43.2',20);
|
||||||
|
// $num5 = -3030000.0 / ($num + 20.0) / (1.966 * $impedance - 58.46) + (28176 / $impedance) - 0.06 * $age + 51.0;
|
||||||
|
$num5 = bcadd(bcsub(bcadd(bcdiv(bcdiv('-3030000.0',bcadd($num,'20.0',20),20),bcsub(bcmul('1.966',$impedance,20),'58.46',20),20),bcdiv('28176',$impedance,20),20),bcmul('0.06',$age,20),20),'51.0',20);
|
||||||
|
// $num6 = 0.876 * $num5 + 1.66;
|
||||||
|
$num6 = bcadd(bcmul('0.876',$num5,20),'1.66',1);
|
||||||
|
// $num7 = 0.857 * $num4 - 0.36;
|
||||||
|
$num7 = bcsub(bcmul('0.857',$num4,20),'0.36',20);
|
||||||
|
// $num8 = 0.75 * (100.0 - $num5 - $num4 - $num2 / $weight);
|
||||||
|
$num8 = bcmul('0.75',bcsub('100.0',bcsub($num5,bcsub($num4,bcdiv($num2,$weight,20),20),20),20),2);
|
||||||
|
// $num9 = 0.304 * $weight - 25.58 * $height / 100.0 + 0.131 * $age + 0.005 * $impedance + 22.0;
|
||||||
|
$num9 = bcadd(bcadd(bcadd(bcsub(bcmul(0.304,$weight,20),bcdiv(bcmul(25.58,$height,20),'100.0',20),20),bcmul('0.131',$age,20),20),bcmul('0.005',$impedance,20),20),'22.0',0);
|
||||||
|
// $num10 = (0.00307 * $impedance + 1.5) * $weight + (1459.0 - 0.989 * $impedance) * $height / 100.0 + $age * 0.9 + 0.923 * $impedance - 950.0;
|
||||||
|
$num10 = bcsub(bcadd(bcadd(bcadd(bcmul(bcadd(bcmul('0.00307',$impedance,20),'1.5',20),$weight,20),bcdiv(bcmul(bcsub('1459.0',bcmul('0.989',$impedance,20),20),$height,20),'100.0',20),20),bcmul($age,'0.9',20),20),bcmul('0.923',$impedance,20),20),'950.0',0);
|
||||||
|
// $num11 = $age * (0.95 + 0.02 * ($num - 21.2)) + ($impedance - 500) * 0.02;
|
||||||
|
$num11 = bcadd(bcmul($age,bcadd(0.95,bcmul('0.02',bcsub($num,'21.2',20),20),20),20),bcmul(bcsub($impedance,'500',20),'0.02',20),0);
|
||||||
|
|
||||||
|
// $standard_weight = ($height-80)*0.7;
|
||||||
|
$standard_weight = bcmul(bcsub($height,'80',20),'0.6',20);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result_data['bmi'] = $num;
|
||||||
|
// $num2 = (($num2 > $weight * 0.15) ? ($weight * 0.15) : $num2);
|
||||||
|
if(bccomp($num2, bcmul($weight,'0.15',20), 20) === 1){
|
||||||
|
$num2 = bcmul($weight,'0.15',2);
|
||||||
|
}
|
||||||
|
// $result_data['bone'] = ($num2 < $weight * 0.02) ? ($weight * 0.02) : $num2;
|
||||||
|
if(bccomp($num2, bcmul($weight,'0.02',20), 20) === -1){
|
||||||
|
$result_data['bone'] = bcmul($weight,'0.02',2);
|
||||||
|
}else{
|
||||||
|
$result_data['bone'] = $num2;
|
||||||
|
}
|
||||||
|
// $num3 = (($num3 > 75.0) ? 75.0 : $num3);
|
||||||
|
if(bccomp($num3, '75.0', 20) === 1){
|
||||||
|
$num3 = '75.0';
|
||||||
|
}
|
||||||
|
// $result_data['muscle'] = ($num3 < 15.0) ? 15.0 : $num3;
|
||||||
|
if(bccomp($num3, '15.0', 20) === -1){
|
||||||
|
$result_data['muscle'] = '15.00';
|
||||||
|
}else{
|
||||||
|
$result_data['muscle'] = $num3;
|
||||||
|
}
|
||||||
|
// $num4 = (($num4 > 70.0) ? 70.0 : $num4);
|
||||||
|
if(bccomp($num4, '70.0', 20) === 1){
|
||||||
|
$num4 = '70.0';
|
||||||
|
}
|
||||||
|
// $result_data['water'] = ($num4 < 20.0) ? 20.0 : $num4;
|
||||||
|
if(bccomp($num4, '20.0', 20) === -1){
|
||||||
|
$result_data['water'] = '20.00';
|
||||||
|
}else{
|
||||||
|
$result_data['water'] = $num4;
|
||||||
|
}
|
||||||
|
// $num5 = (($num5 > 50.0) ? 50.0 : $num5);
|
||||||
|
if(bccomp($num5, '50.0', 20) === 1){
|
||||||
|
$num5 = '50.0';
|
||||||
|
}
|
||||||
|
// $result_data['fat_r'] = ($num5 < 5.0) ? 5.0 : $num5;
|
||||||
|
|
||||||
|
if(bccomp($num5, '5.0', 20) === -1){
|
||||||
|
$result_data['fat_r'] = '5.00';
|
||||||
|
}else{
|
||||||
|
// $result_data['fat_r'] = $num5;
|
||||||
|
$result_data['fat_r'] = substr($num5, 0, strpos($num5, ".") + 3);
|
||||||
|
}
|
||||||
|
// $result_data['sfr'] = $num6 <= 0 ? "0" : $num6;
|
||||||
|
if(bccomp($num6, '0.0', 20) === -1){
|
||||||
|
$result_data['sfr'] = '0.00';
|
||||||
|
}else{
|
||||||
|
$result_data['sfr'] = $num6;
|
||||||
|
}
|
||||||
|
// $result_data['skeletalmuscle'] = $num7;
|
||||||
|
$result_data['skeletalmuscle'] = substr($num7, 0, strpos($num7, ".") + 3);
|
||||||
|
// $num8 = (($num8 > 50.0) ? 50.0 : $num8);
|
||||||
|
if(bccomp($num8, '50.0', 20) === 1){
|
||||||
|
$num8 = '50.00';
|
||||||
|
}
|
||||||
|
// $result_data['protein'] = ($num8 < 10.0) ? 10.0 : $num8;
|
||||||
|
if(bccomp($num8, '10.0', 20) === -1){
|
||||||
|
$result_data['protein'] = '10.00';
|
||||||
|
}else{
|
||||||
|
$result_data['protein'] = $num8;
|
||||||
|
}
|
||||||
|
// $num9 = (($num9 > 20.0) ? 20.0 : $num9);
|
||||||
|
if(bccomp($num9, '20.0', 20) === 1){
|
||||||
|
$num9 = '20.0';
|
||||||
|
}
|
||||||
|
// $result_data['visceral'] = ($num9 < 1.0) ? 1.0 : $num9;
|
||||||
|
if(bccomp($num9, '1.0', 20) === -1){
|
||||||
|
$result_data['visceral'] = '1.0';
|
||||||
|
}else{
|
||||||
|
$result_data['visceral'] = $num9;
|
||||||
|
}
|
||||||
|
// $result_data['kcal'] = $num10 <= 0 ? "0" : $num10;
|
||||||
|
if(bccomp($num10, '0', 20) !== 1){
|
||||||
|
$result_data['kcal'] = '0';
|
||||||
|
}else{
|
||||||
|
$result_data['kcal'] = $num10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $standard_level = ($weight-$standard_weight)/$standard_weight;
|
||||||
|
$standard_level = bcdiv(bcsub($weight,$standard_weight,20),$standard_weight,2);
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
if ($age < 18){
|
||||||
|
$num11 = $age;
|
||||||
|
}else{
|
||||||
|
// $num11 = (($num11 > ($age + 10)) ? (($age + 10)) : $num11);
|
||||||
|
if(bccomp($num11, $age + 10, 20) === 1){
|
||||||
|
$num11 = $age + 10;
|
||||||
|
}
|
||||||
|
// $num11 = (($num11 < ($age - 10)) ? (($age - 10)) : $num11);
|
||||||
|
if(bccomp($num11, $age - 10, 20) === -1){
|
||||||
|
$num11 = $age - 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result_data['bodyage'] = $num11;
|
||||||
|
$result_data['weight'] = $weight;
|
||||||
|
$result_data['height'] = $height;
|
||||||
|
$result_data['age'] = $age;
|
||||||
|
$result_data['adc'] = $impedance;
|
||||||
|
$result_data['gender'] = $gender;
|
||||||
|
$result_data['standard_level'] = $standard_level;
|
||||||
|
return $result_data;
|
||||||
|
}
|
||||||
|
// 计算脂肪率
|
||||||
|
function calculate_fat_r(){
|
||||||
|
}
|
||||||
|
// 计算脂肪量
|
||||||
|
function calculate_zhifangliang(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算肌肉率
|
||||||
|
function calculate_jiroulv(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算肌肉量
|
||||||
|
function calculate_jirouliang(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算水分
|
||||||
|
function calculate_shuifen(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算蛋白量
|
||||||
|
function calculate_danbailiang(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算骨重
|
||||||
|
function calculate_guzhong(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算蛋白率
|
||||||
|
function calculate_danbailv(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算基础代谢
|
||||||
|
function calculate_jichudaixie(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算内脏指数
|
||||||
|
function calculate_neizangzhishu(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算皮下脂肪
|
||||||
|
function calculate_pixiazhifang(){
|
||||||
|
|
||||||
|
}
|
||||||
|
// 计算肥胖等级
|
||||||
|
function calculate_feipangdengji(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
|
||||||
class Cardparts extends Base{
|
class Cardparts extends Base{
|
||||||
|
|
@ -213,9 +213,11 @@ class Cardparts extends Base{
|
||||||
}
|
}
|
||||||
// 处理顶部list
|
// 处理顶部list
|
||||||
foreach ($temporary_arr['top_list'] as $key => $value) {
|
foreach ($temporary_arr['top_list'] as $key => $value) {
|
||||||
|
// dump($value['list']);
|
||||||
|
// dump($value['value']);
|
||||||
|
// dump($value['standard']);
|
||||||
if(count($value['list']) > 0){
|
if(count($value['list']) > 0){
|
||||||
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard'])[0];
|
$temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果是没有阻抗的测试,那么就不要底部的其他数据了
|
// 如果是没有阻抗的测试,那么就不要底部的其他数据了
|
||||||
|
|
@ -223,9 +225,10 @@ class Cardparts extends Base{
|
||||||
$temporary_arr['bottom_list'] = [];
|
$temporary_arr['bottom_list'] = [];
|
||||||
return $temporary_arr;
|
return $temporary_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理底部list
|
// 处理底部list
|
||||||
|
|
||||||
|
|
||||||
foreach ($temporary_arr['bottom_list'] as $key => $value) {
|
foreach ($temporary_arr['bottom_list'] as $key => $value) {
|
||||||
// dump($value);
|
// dump($value);
|
||||||
// 脂肪率&
|
// 脂肪率&
|
||||||
|
|
@ -360,7 +363,41 @@ class Cardparts extends Base{
|
||||||
|
|
||||||
|
|
||||||
// 计算落点百分比(区间字典,值,值描述)
|
// 计算落点百分比(区间字典,值,值描述)
|
||||||
public function calculate_landing_point($data,$val,$t_val){
|
public function calculate_landing_point($data = [],$val = '0',$t_val = ''){
|
||||||
|
// $data = [
|
||||||
|
// [
|
||||||
|
// 'min_val' => '0',
|
||||||
|
// 'max_val' => '32.5',
|
||||||
|
// 'text' => '低',
|
||||||
|
// 'color' => '#F8595D'
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'min_val' => '32.5',
|
||||||
|
// 'max_val' => '36.2',
|
||||||
|
// 'text' => '偏低',
|
||||||
|
// 'color' => '#FFAF04'
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'min_val' => '36.2',
|
||||||
|
// 'max_val' => '48.7',
|
||||||
|
// 'text' => '标准',
|
||||||
|
// 'color' => '#59D168'
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'min_val' => '48.7',
|
||||||
|
// 'max_val' => '57.7',
|
||||||
|
// 'text' => '偏高',
|
||||||
|
// 'color' => '#FFAF04'
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'min_val' => '57.7',
|
||||||
|
// 'max_val' => '69.7',
|
||||||
|
// 'text' => '高',
|
||||||
|
// 'color' => '#F8595D'
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// $val = "41.80";
|
||||||
|
// dump($data);
|
||||||
// 根据字典确认有几个区间
|
// 根据字典确认有几个区间
|
||||||
$num = count($data);
|
$num = count($data);
|
||||||
if($num <= 0){
|
if($num <= 0){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Cache;
|
||||||
|
|
||||||
|
class Countfood extends Base{
|
||||||
|
|
||||||
|
protected $card_db_name = [
|
||||||
|
'zhanghao'=>'app_account_number',
|
||||||
|
];
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||||
|
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
// 卡片列表信息
|
||||||
|
public function card_list_msg(){
|
||||||
|
try {
|
||||||
|
// 你的业务逻辑
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005,'token type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
return $this->card_list_msg_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################action################################################################
|
||||||
|
################################################################action################################################################
|
||||||
|
public function card_list_msg_action($data){
|
||||||
|
// 检查角色
|
||||||
|
$user_data = Db::table($this->card_db_name['juese'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,card_order')->find();
|
||||||
|
if(!$user_data){
|
||||||
|
return $this->msg(10003,'未核实到角色信息');
|
||||||
|
}
|
||||||
|
// 获取卡片信息
|
||||||
|
$card_data = Db::table($this->card_db_name['card'])->where(['is_del'=>0])->field('id,name,content,page_url_report,is_sub_item,background_color,background_pic,key_word')->cache(86400)->select();
|
||||||
|
// 根据用户处理卡片信息
|
||||||
|
$return_data = [
|
||||||
|
'chosen_yes'=>[],
|
||||||
|
'chosen_no'=>[],
|
||||||
|
];
|
||||||
|
if($user_data['card_order'] != ''){
|
||||||
|
$user_data['card_order'] = explode(',',$user_data['card_order']);
|
||||||
|
}else{
|
||||||
|
$user_data['card_order'] = [];
|
||||||
|
}
|
||||||
|
for ($i=0; $i < count($card_data); $i++) {
|
||||||
|
if(!in_array($card_data[$i]['id'],$user_data['card_order'])){
|
||||||
|
$return_data['chosen_no'][] = $card_data[$i];
|
||||||
|
}else{
|
||||||
|
$key = array_search($card_data[$i]['id'], $user_data['card_order']);
|
||||||
|
$return_data['chosen_yes'][$key] = $card_data[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ksort($return_data['chosen_yes']);
|
||||||
|
return $this->msg($return_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,436 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Controller;
|
||||||
|
|
||||||
|
class Guessyoulike extends Controller {
|
||||||
|
|
||||||
|
protected $kitchenscale_db_msg = [
|
||||||
|
'cookbook' => 'app_user_cookbook', //食谱表
|
||||||
|
'cookbook_label' => 'app_user_cookbook_label', //食谱标签表
|
||||||
|
'cookbook_food_relation' => 'app_user_cookbook_food_relation', //食谱跟食材关系表
|
||||||
|
'foodlist2' => 'app_z_national_standard_food_type_2', //食材标签表2
|
||||||
|
'foodlist3' => 'app_z_national_standard_food_type_3', //食材表
|
||||||
|
'kcal_log' => 'app_user_kcal_log', //用户饮食记录表记录用户吃了什么食材
|
||||||
|
'search_history' => 'app_user_search_history', //用户搜索记录表,记录用户搜索过什么内容
|
||||||
|
'tag_preference' => 'app_user_tag_preference', //用户标签偏好表
|
||||||
|
'recommend_cache' => 'app_recommend_cache' //智能推荐缓存表
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $config = [
|
||||||
|
'tag_limit' => 2,
|
||||||
|
'item_limit' => 12,
|
||||||
|
'cache_time' => 3600
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 猜你喜欢主接口
|
||||||
|
*/
|
||||||
|
public function getGuessYouLike($user_id = 1, $type = 'food', $limit = null) {
|
||||||
|
try {
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
// dump(1);
|
||||||
|
// 设置限制数量
|
||||||
|
$tag_limit = $limit ? intval($limit) : $this->config['tag_limit'];
|
||||||
|
$item_limit = $this->config['item_limit'];
|
||||||
|
|
||||||
|
// 检查缓存
|
||||||
|
// $cache_key = $user_id . ':' . $type;
|
||||||
|
// $cache_result = $this->getCache($cfc, $cache_key);
|
||||||
|
// // die;
|
||||||
|
// if ($cache_result !== null) {
|
||||||
|
// return $cache_result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 判断用户是否有历史数据
|
||||||
|
$has_history = $this->checkUserHistory($cfc, $user_id);
|
||||||
|
|
||||||
|
if (!$has_history) {
|
||||||
|
// 新用户,返回最火信息(仅一个标签)
|
||||||
|
$result = $this->getPopularRecommendations($cfc, $type, 1, $item_limit);
|
||||||
|
} else {
|
||||||
|
// 老用户,根据类型返回个性化推荐
|
||||||
|
|
||||||
|
if ($type === 'cookbook') {
|
||||||
|
$result = $this->getCookbookRecommendations($cfc, $user_id, $tag_limit, $item_limit);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$result = $this->getFoodRecommendations($cfc, $user_id, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保返回格式正确
|
||||||
|
if (!is_array($result)) {
|
||||||
|
$result = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新缓存
|
||||||
|
// $this->updateCache($cfc, $cache_key, $user_id, $type, $result);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 记录错误日志
|
||||||
|
\think\Log::error('猜你喜欢功能错误: ' . $e->getMessage());
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否有历史数据
|
||||||
|
*/
|
||||||
|
private function checkUserHistory($db, $user_id) {
|
||||||
|
try {
|
||||||
|
// 检查饮食记录
|
||||||
|
// $kcal_result = $db->query("
|
||||||
|
$kcal_result = Db::query("
|
||||||
|
SELECT COUNT(*) as count
|
||||||
|
FROM {$this->kitchenscale_db_msg['kcal_log']}
|
||||||
|
WHERE aud_id = ? AND is_del = 0
|
||||||
|
", [$user_id]);
|
||||||
|
$kcal_count = $kcal_result[0]['count'] ?? 0;
|
||||||
|
|
||||||
|
// 检查搜索记录
|
||||||
|
// $search_result = $db->query("
|
||||||
|
$search_result = Db::query("
|
||||||
|
SELECT COUNT(*) as count
|
||||||
|
FROM {$this->kitchenscale_db_msg['search_history']}
|
||||||
|
WHERE user_id = ? AND is_del = 0
|
||||||
|
", [$user_id]);
|
||||||
|
$search_count = $search_result[0]['count'] ?? 0;
|
||||||
|
|
||||||
|
return ($kcal_count > 0 || $search_count > 0);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存数据
|
||||||
|
*/
|
||||||
|
private function getCache($db, $cache_key) {
|
||||||
|
try {
|
||||||
|
// $cache_result = $db->query("
|
||||||
|
$cache_result = Db::query("
|
||||||
|
SELECT id, cache_key, user_id, keyword, recommend_data, hit_count, last_hit, is_del, create_time
|
||||||
|
FROM {$this->kitchenscale_db_msg['recommend_cache']}
|
||||||
|
WHERE cache_key = ? AND is_del = 0
|
||||||
|
", [$cache_key]);
|
||||||
|
|
||||||
|
if (!empty($cache_result)) {
|
||||||
|
$cache = $cache_result[0];
|
||||||
|
$last_hit_timestamp = strtotime($cache['last_hit']);
|
||||||
|
|
||||||
|
if (time() - $last_hit_timestamp < $this->config['cache_time']) {
|
||||||
|
// 更新命中次数和时间
|
||||||
|
// $db->execute("
|
||||||
|
Db::execute("
|
||||||
|
UPDATE {$this->kitchenscale_db_msg['recommend_cache']}
|
||||||
|
SET hit_count = hit_count + 1, last_hit = GETDATE()
|
||||||
|
WHERE id = ?
|
||||||
|
", [$cache['id']]);
|
||||||
|
|
||||||
|
$data = json_decode($cache['recommend_data'], true);
|
||||||
|
return is_array($data) ? $data : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 忽略缓存错误,继续执行
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新缓存
|
||||||
|
*/
|
||||||
|
private function updateCache($db, $cache_key, $user_id, $keyword, $data) {
|
||||||
|
try {
|
||||||
|
$current_time = date('Y-m-d H:i:s');
|
||||||
|
$recommend_data = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
// 检查是否存在缓存
|
||||||
|
// $existing_result = $db->query("
|
||||||
|
$existing_result = Db::query("
|
||||||
|
SELECT id FROM {$this->kitchenscale_db_msg['recommend_cache']}
|
||||||
|
WHERE cache_key = ? AND is_del = 0
|
||||||
|
", [$cache_key]);
|
||||||
|
|
||||||
|
if (!empty($existing_result)) {
|
||||||
|
// 更新现有缓存
|
||||||
|
// $db->execute("
|
||||||
|
Db::execute("
|
||||||
|
UPDATE {$this->kitchenscale_db_msg['recommend_cache']}
|
||||||
|
SET user_id = ?, keyword = ?, recommend_data = ?, hit_count = 1,
|
||||||
|
last_hit = ?, create_time = ?
|
||||||
|
WHERE cache_key = ? AND is_del = 0
|
||||||
|
", [$user_id, $keyword, $recommend_data, $current_time, $current_time, $cache_key]);
|
||||||
|
} else {
|
||||||
|
// 插入新缓存
|
||||||
|
// $db->execute("
|
||||||
|
Db::execute("
|
||||||
|
INSERT INTO {$this->kitchenscale_db_msg['recommend_cache']}
|
||||||
|
(cache_key, user_id, keyword, recommend_data, hit_count, last_hit, create_time, is_del)
|
||||||
|
VALUES (?, ?, ?, ?, 1, ?, ?, 0)
|
||||||
|
", [$cache_key, $user_id, $keyword, $recommend_data, $current_time, $current_time]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 忽略缓存更新错误
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取热门推荐(新用户)
|
||||||
|
*/
|
||||||
|
private function getPopularRecommendations($db, $type, $tag_limit, $item_limit) {
|
||||||
|
// dump($type);
|
||||||
|
if ($type === 'cookbook') {
|
||||||
|
return $this->getPopularCookbooks($db, $tag_limit, $item_limit);
|
||||||
|
} else {
|
||||||
|
// dump(111);
|
||||||
|
return $this->getPopularFoods($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取热门食谱(新用户)
|
||||||
|
*/
|
||||||
|
private function getPopularCookbooks($db, $tag_limit, $item_limit) {
|
||||||
|
try {
|
||||||
|
// 简化查询,避免复杂关联导致的错误
|
||||||
|
$popular_cookbooks = $db->query("
|
||||||
|
SELECT TOP {$item_limit}
|
||||||
|
id,
|
||||||
|
title as name
|
||||||
|
FROM {$this->kitchenscale_db_msg['cookbook']}
|
||||||
|
WHERE is_del = 0
|
||||||
|
ORDER BY likes_num DESC, read_it DESC, create_time DESC
|
||||||
|
");
|
||||||
|
// dump('sp');
|
||||||
|
// dump($popular_cookbooks);
|
||||||
|
$result = [];
|
||||||
|
$label_data = [];
|
||||||
|
|
||||||
|
foreach ($popular_cookbooks as $cookbook) {
|
||||||
|
$label_data[] = [
|
||||||
|
'name' => $cookbook['name'] ?? '未知食谱',
|
||||||
|
'id' => $cookbook['id'] ?? 0,
|
||||||
|
'type' => 'cookbook'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($label_data)) {
|
||||||
|
$result['最火食谱搜索'] = $label_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取热门食材(新用户)
|
||||||
|
*/
|
||||||
|
private function getPopularFoods($db, $tag_limit, $item_limit) {
|
||||||
|
try {
|
||||||
|
// dump(2222);
|
||||||
|
// // 简化查询,避免复杂关联导致的错误
|
||||||
|
// $popular_foods = $db->query("
|
||||||
|
$popular_foods = Db::query("
|
||||||
|
SELECT TOP {$item_limit}
|
||||||
|
id,
|
||||||
|
keyword as name,
|
||||||
|
COUNT(*) as num
|
||||||
|
FROM {$this->kitchenscale_db_msg['search_history']}
|
||||||
|
WHERE is_del = 0 AND type = 'food'
|
||||||
|
GROUP BY id, keyword
|
||||||
|
ORDER BY num DESC
|
||||||
|
");
|
||||||
|
// dump('sc');
|
||||||
|
// dump($popular_foods);
|
||||||
|
|
||||||
|
$popular_foods_2 = [];
|
||||||
|
if(count($popular_foods) < $item_limit){
|
||||||
|
$num = $item_limit - count($popular_foods);
|
||||||
|
$popular_foods_2 = $db->query("
|
||||||
|
SELECT TOP {$num}
|
||||||
|
id,
|
||||||
|
food_name as name
|
||||||
|
FROM {$this->kitchenscale_db_msg['foodlist3']}
|
||||||
|
WHERE is_del = 0
|
||||||
|
ORDER BY is_popular DESC, food_name ASC
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($popular_foods_2 as $key => $value) {
|
||||||
|
$popular_foods[] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
$label_data = [];
|
||||||
|
|
||||||
|
foreach ($popular_foods as $food) {
|
||||||
|
$label_data[] = [
|
||||||
|
'name' => $food['name'] ?? '未知食材',
|
||||||
|
'id' => $food['id'] ?? 0,
|
||||||
|
'type' => 'food'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($label_data)) {
|
||||||
|
$result['最火食材搜索'] = $label_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取个性化食谱推荐(老用户)
|
||||||
|
*/
|
||||||
|
private function getCookbookRecommendations($db, $user_id, $tag_limit, $item_limit) {
|
||||||
|
// dump($user_id);
|
||||||
|
try {
|
||||||
|
// 获取用户最常吃的食材
|
||||||
|
// $user_top_foods = $db->query("
|
||||||
|
$user_top_foods = Db::query("
|
||||||
|
SELECT TOP 10 food_id, COUNT(*) as eat_count
|
||||||
|
FROM {$this->kitchenscale_db_msg['kcal_log']}
|
||||||
|
WHERE aud_id = ? AND is_del = 0
|
||||||
|
GROUP BY food_id
|
||||||
|
ORDER BY eat_count DESC
|
||||||
|
", [$user_id]);
|
||||||
|
|
||||||
|
// dump($user_top_foods);
|
||||||
|
|
||||||
|
if (empty($user_top_foods)) {
|
||||||
|
return $this->getPopularCookbooks($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$food_ids = array_column($user_top_foods, 'food_id');
|
||||||
|
if (empty($food_ids)) {
|
||||||
|
return $this->getPopularCookbooks($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
$food_ids_str = implode(',', $food_ids);
|
||||||
|
// dump($food_ids_str);
|
||||||
|
// 获取包含这些食材的食谱标签
|
||||||
|
$preferred_labels = $db->query("
|
||||||
|
SELECT TOP {$tag_limit} lbl.id, lbl.name, COUNT(DISTINCT cb.id) as match_count
|
||||||
|
FROM {$this->kitchenscale_db_msg['cookbook_label']} lbl
|
||||||
|
INNER JOIN {$this->kitchenscale_db_msg['cookbook']} cb ON lbl.id = cb.cook_label AND cb.is_del = 0
|
||||||
|
INNER JOIN {$this->kitchenscale_db_msg['cookbook_food_relation']} cfr ON cb.id = cfr.cookbook_id
|
||||||
|
WHERE lbl.is_del = 0 AND cfr.food_id IN ({$food_ids_str})
|
||||||
|
GROUP BY lbl.id, lbl.name
|
||||||
|
ORDER BY match_count DESC
|
||||||
|
");
|
||||||
|
// dump($preferred_labels);
|
||||||
|
$result = [];
|
||||||
|
foreach ($preferred_labels as $label) {
|
||||||
|
// 使用子查询避免GROUP BY复杂性问题
|
||||||
|
$cookbooks = $db->query("
|
||||||
|
SELECT TOP {$item_limit} cb.id, cb.title as name
|
||||||
|
FROM {$this->kitchenscale_db_msg['cookbook']} cb
|
||||||
|
WHERE cb.id IN (
|
||||||
|
SELECT DISTINCT cfr.cookbook_id
|
||||||
|
FROM {$this->kitchenscale_db_msg['cookbook_food_relation']} cfr
|
||||||
|
WHERE cfr.food_id IN ({$food_ids_str})
|
||||||
|
)
|
||||||
|
AND cb.cook_label = ?
|
||||||
|
AND cb.is_del = 0
|
||||||
|
ORDER BY cb.likes_num DESC, cb.read_it DESC
|
||||||
|
", [$label['id']]);
|
||||||
|
|
||||||
|
$label_data = [];
|
||||||
|
foreach ($cookbooks as $cookbook) {
|
||||||
|
$label_data[] = [
|
||||||
|
'name' => $cookbook['name'] ?? '未知食谱',
|
||||||
|
'id' => $cookbook['id'] ?? 0,
|
||||||
|
'type' => 'cookbook'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($label_data)) {
|
||||||
|
$result[$label['name'] ?? '未知标签'] = $label_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dump($result);
|
||||||
|
if(count($result)<=0){
|
||||||
|
return $this->getPopularCookbooks($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->getPopularCookbooks($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取个性化食材推荐(老用户)
|
||||||
|
*/
|
||||||
|
private function getFoodRecommendations($db, $user_id, $tag_limit, $item_limit) {
|
||||||
|
try {
|
||||||
|
// 获取用户最常吃的食材
|
||||||
|
// $user_top_foods = $db->query("
|
||||||
|
$user_top_foods = Db::query("
|
||||||
|
SELECT TOP 10 food_id, COUNT(*) as eat_count
|
||||||
|
FROM {$this->kitchenscale_db_msg['kcal_log']}
|
||||||
|
WHERE aud_id = ? AND is_del = 0
|
||||||
|
GROUP BY food_id
|
||||||
|
ORDER BY eat_count DESC
|
||||||
|
", [$user_id]);
|
||||||
|
|
||||||
|
if (empty($user_top_foods)) {
|
||||||
|
return $this->getPopularFoods($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$food_ids = array_column($user_top_foods, 'food_id');
|
||||||
|
if (empty($food_ids)) {
|
||||||
|
return $this->getPopularFoods($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
$food_ids_str = implode(',', $food_ids);
|
||||||
|
|
||||||
|
// 获取用户偏好食材的分类
|
||||||
|
$preferred_categories = $db->query("
|
||||||
|
SELECT TOP {$tag_limit} f2.id, f2.name, COUNT(DISTINCT f3.id) as food_count
|
||||||
|
FROM {$this->kitchenscale_db_msg['foodlist2']} f2
|
||||||
|
INNER JOIN {$this->kitchenscale_db_msg['foodlist3']} f3 ON f2.id = f3.two_id
|
||||||
|
WHERE f3.id IN ({$food_ids_str}) AND f2.is_del = 0 AND f3.is_del = 0
|
||||||
|
GROUP BY f2.id, f2.name
|
||||||
|
ORDER BY food_count DESC
|
||||||
|
");
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($preferred_categories as $category) {
|
||||||
|
// 获取该分类下的其他食材
|
||||||
|
$foods = $db->query("
|
||||||
|
SELECT TOP {$item_limit} id, food_name as name
|
||||||
|
FROM {$this->kitchenscale_db_msg['foodlist3']}
|
||||||
|
WHERE two_id = ? AND is_del = 0 AND id NOT IN ({$food_ids_str})
|
||||||
|
ORDER BY is_popular DESC, food_name ASC
|
||||||
|
", [$category['id']]);
|
||||||
|
|
||||||
|
$category_data = [];
|
||||||
|
foreach ($foods as $food) {
|
||||||
|
$category_data[] = [
|
||||||
|
'name' => $food['name'] ?? '未知食材',
|
||||||
|
'id' => $food['id'] ?? 0,
|
||||||
|
'type' => 'food'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($category_data)) {
|
||||||
|
$result[$category['name'] ?? '未知分类'] = $category_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->getPopularFoods($db, $tag_limit, $item_limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Cache;
|
||||||
|
|
||||||
|
class Gufen extends Base{
|
||||||
|
|
||||||
|
protected $card_db_name = [
|
||||||
|
'zhanghao'=>'app_account_number',
|
||||||
|
'guize'=>'admin_estimate',
|
||||||
|
|
||||||
|
];
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||||
|
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
// 获取单个类型列表
|
||||||
|
public function get_single_data($data = ['address'=>'上海','gender'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||||
|
try {
|
||||||
|
// 你的业务逻辑
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('address', $data) || !array_key_exists('gender', $data) || !array_key_exists('token', $data)){
|
||||||
|
$return_data = $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['address'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
$return_data = $this->sportstesting_get_type_list_action($data);
|
||||||
|
|
||||||
|
// 成功
|
||||||
|
$this->record_api_log($data, null, $return_data);
|
||||||
|
return $return_data;
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################action################################################################
|
||||||
|
################################################################action################################################################
|
||||||
|
public function sportstesting_get_type_list_action($data){
|
||||||
|
|
||||||
|
$parameter_data = explode(',',$data['address']);
|
||||||
|
$gender = $data['gender'];
|
||||||
|
// 精准查询地市规则start
|
||||||
|
// if(count($parameter_data) == 1){
|
||||||
|
// $db_condition = "province = '".$parameter_data[0]."'";
|
||||||
|
// }else if(count($parameter_data) == 2){
|
||||||
|
// $db_condition = "province = '".$parameter_data[0]."' and city = '".$parameter_data[1]."'";
|
||||||
|
// }else if(count($parameter_data) == 3){
|
||||||
|
// $db_condition = "province = ".$parameter_data[0]."' and city = '".$parameter_data[1]."' and area = '".$parameter_data[2]."'";
|
||||||
|
// }else{
|
||||||
|
// return $this->msg(10005);
|
||||||
|
// }
|
||||||
|
// 精准查询地市规则end
|
||||||
|
// 全省地市一个规则start
|
||||||
|
$db_condition = "province = '".$parameter_data[0]."'";
|
||||||
|
// 全省地市一个规则end
|
||||||
|
$data = Db::table($this->card_db_name['guize'])->where($db_condition)->find();
|
||||||
|
$data = json_decode($data['content'],true);
|
||||||
|
$result = $this->handle_default_rule_list_content($data,$gender);
|
||||||
|
return $this->msg($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
|
||||||
use think\Controller;
|
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Cache;
|
// use think\Cache;
|
||||||
use think\Log;
|
// use think\Log;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
// use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use app\NewReedaw\controller\app\Role;
|
// use app\NewReedaw\controller\app\Role;
|
||||||
|
// use app\app\controller\Language;
|
||||||
|
use app\KitchenScale2\controller\app\Index as Cfindex;//厨房秤的config
|
||||||
|
|
||||||
class Index extends Base{
|
class Index extends Base{
|
||||||
|
|
||||||
|
|
@ -15,7 +17,36 @@ class Index extends Base{
|
||||||
'zhanghao'=>'app_account_number',
|
'zhanghao'=>'app_account_number',
|
||||||
'juese'=>'app_user_data',
|
'juese'=>'app_user_data',
|
||||||
'body_data'=>'app_card_body_data',
|
'body_data'=>'app_card_body_data',
|
||||||
|
'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',
|
||||||
|
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
|
||||||
|
];
|
||||||
|
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'=>'大学三、四年级']
|
||||||
];
|
];
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
// 减 bcsub(,,20)
|
// 减 bcsub(,,20)
|
||||||
|
|
@ -27,20 +58,36 @@ class Index extends Base{
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
||||||
// 配置信息
|
// 检测版本及判断是否登录失效
|
||||||
public function config($data = ['token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
public function login_invalid_version(){
|
||||||
try {
|
|
||||||
// 你的业务逻辑
|
|
||||||
if(count(input('post.')) > 0){
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
}
|
try {
|
||||||
if(!array_key_exists('token', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
||||||
return $this->msg(10005);
|
$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()]);
|
||||||
|
}
|
||||||
|
$user_token_state = $this->token_time_validate($data['token']);
|
||||||
|
|
||||||
|
if($user_token_state['state'] === false){
|
||||||
|
return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,]);
|
||||||
|
// return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(['version'=>$version,'url'=>$url,]);
|
||||||
|
// return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]);
|
||||||
}
|
}
|
||||||
return $this->config_action($data);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
$logContent["flie"] = $e->getFile();
|
$logContent["flie"] = $e->getFile();
|
||||||
|
|
@ -49,126 +96,58 @@ class Index extends Base{
|
||||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
|
$logContent['all_content'] .= "方法: " . __METHOD__ . "\n";
|
||||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||||
$this->record_api_log($data, $logContent, null);
|
$this->record_api_log($data, $logContent, null);
|
||||||
return $this->msg(99999);
|
return $this->msg(99999);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// 遗传身高
|
|
||||||
public function genetic_height(){
|
|
||||||
try {
|
|
||||||
$data = input('post.');
|
|
||||||
if(!array_key_exists('dadHeight', $data) || !array_key_exists('momHeight', $data) || !array_key_exists('birthday', $data) || !array_key_exists('sex', $data)){
|
|
||||||
return $this->msg(10001);
|
|
||||||
}
|
|
||||||
unset($data['token']);
|
|
||||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['dadHeight'],'num')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['momHeight'],'num')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['sex'],'intnum')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 直接开始业务,请求外部接口start
|
|
||||||
$url = 'https://ybapi.pcxbc.com/api/child/predictheight';
|
|
||||||
$temporary_parameter = [
|
|
||||||
'dadHeight'=>$data['dadHeight'],
|
|
||||||
'momHeight'=>$data['momHeight'],
|
|
||||||
'birthday'=>$data['birthday'],
|
|
||||||
'sex'=>$data['sex'],
|
|
||||||
];
|
|
||||||
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
|
|
||||||
// 直接开始业务,请求外部接口end
|
|
||||||
return json($request_result);
|
|
||||||
} 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);
|
|
||||||
}
|
}
|
||||||
}
|
// 配置信息
|
||||||
// BMI测评
|
public function config(){
|
||||||
public function bmi_evaluation(){
|
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
if(!array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('birthday', $data) || !array_key_exists('sex', $data)){
|
// try {
|
||||||
return $this->msg(10001);
|
if(!array_key_exists('token', $data)){
|
||||||
}
|
return $this->msg(10001,'token is miss');
|
||||||
unset($data['token']);
|
|
||||||
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['height'],'num')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
if(!$this->verify_data_is_ok($data['sex'],'intnum')){
|
|
||||||
return $this->msg(10005);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 直接开始业务,请求外部接口start
|
|
||||||
$url = 'http://ybdevice.pcxbc.com/api/result/calcbmi';
|
|
||||||
$temporary_parameter = [
|
|
||||||
'height'=>$data['height'],
|
|
||||||
'weight'=>$data['weight'],
|
|
||||||
'birthday'=>$data['birthday'],
|
|
||||||
'sex'=>$data['sex'],
|
|
||||||
];
|
|
||||||
$request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com'));
|
|
||||||
// 直接开始业务,请求外部接口end
|
|
||||||
|
|
||||||
// 处理进度点
|
|
||||||
$return_result =$this->bmi_evaluation_action($request_result);
|
|
||||||
return $return_result;
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 获取首页角色信息
|
|
||||||
public function get_user_data_information(){
|
|
||||||
try {
|
|
||||||
$data = input('post.');
|
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
|
|
||||||
return $this->msg(10001);
|
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type error');
|
return $this->msg(10005,'token type error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
return $this->config_action($data);
|
||||||
return $this->msg(10005,'aud_id type error');
|
// } 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);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return $this->get_user_data_information_action($data);
|
|
||||||
|
// 获取角色信息
|
||||||
|
public function get_user_list(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
return $this->get_user_list_action($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
$logContent["flie"] = $e->getFile();
|
$logContent["flie"] = $e->getFile();
|
||||||
$logContent["line"] = $e->getLine();
|
$logContent["line"] = $e->getLine();
|
||||||
$logContent['all_content'] = "异常信息:\n";
|
$logContent['all_content'] = "异常信息:\n";
|
||||||
|
$logContent['all_content'] .= "函数: get_user_list" . "\n";
|
||||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||||
|
|
@ -179,6 +158,64 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 隐私协议手机网页端
|
||||||
|
public function privacy_policy(){
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // 数据对比(包含身体、跳绳、肺活量)
|
||||||
|
// public function all_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||||
|
// try {
|
||||||
|
// $data = input('post.');
|
||||||
|
// if(!array_key_exists('before_id', $data) || !array_key_exists('after_id', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||||
|
// return $this->msg(10001);
|
||||||
|
// }
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// } 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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
|
|
||||||
|
|
@ -193,6 +230,7 @@ class Index extends Base{
|
||||||
'《WHO 5~19岁身高/体重判定标准》',
|
'《WHO 5~19岁身高/体重判定标准》',
|
||||||
],
|
],
|
||||||
'bmi_evaluation'=>[
|
'bmi_evaluation'=>[
|
||||||
|
"BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。",
|
||||||
'*数据参考:',
|
'*数据参考:',
|
||||||
'《WHO 5~19岁身高/体重判定标准》'
|
'《WHO 5~19岁身高/体重判定标准》'
|
||||||
],
|
],
|
||||||
|
|
@ -206,93 +244,534 @@ class Index extends Base{
|
||||||
'此测量数据仅供参考,不可替代医学专业测试!'
|
'此测量数据仅供参考,不可替代医学专业测试!'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'king_kong_region'=>[
|
// 'king_kong_region'=>[
|
||||||
['title'=>'增量对比','icon'=>'','jump'=>''],
|
// ['title'=>'减值对比','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/contrast.png','jump'=>'/pageTwo/compk/contrast'],
|
||||||
['title'=>'中招估分','icon'=>'','jump'=>''],
|
// ['title'=>'中招估分','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/report.png','jump'=>'/pageTwo/score/report'],
|
||||||
['title'=>'遗传身高','icon'=>'','jump'=>''],
|
// ['title'=>'遗传身高','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/inheritHeighet.png','jump'=>'/pageTwo/home/inheritHeighet'],
|
||||||
['title'=>'BMI测评','icon'=>'','jump'=>''],
|
// ['title'=>'BMI测评','icon'=>'https://tc.pcxbc.com/new_reedaw/icon/bmi.png','jump'=>'/pageTwo/home/bmi'],
|
||||||
|
// ],
|
||||||
|
'business_cooperation_url'=>[],
|
||||||
|
'area_list'=>[],
|
||||||
|
'identity_list'=>[],
|
||||||
|
'grade_list'=>[],
|
||||||
|
'banner'=>[],
|
||||||
|
'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'],
|
||||||
],
|
],
|
||||||
'role_list'=>[
|
'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']
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
$role = new Role;
|
// $food_count = ;
|
||||||
$return_data['role_list'] = $role->role_list_action(['token'=>$data['token'],'type'=>2])->getData()['data'];
|
|
||||||
|
// 处理厨房秤config
|
||||||
|
// $cf_index = new Cfindex;
|
||||||
|
// $cf_confog = $cf_index->get_default_config_action($data)->getData()['data'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 添加菜谱类型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
|
||||||
|
|
||||||
|
// $return_data['cfc'] = $cf_confog;
|
||||||
return $this->msg($return_data);
|
return $this->msg($return_data);
|
||||||
}
|
}
|
||||||
public function bmi_evaluation_action($data){
|
|
||||||
// 加 bcadd(,,20)
|
public function get_user_list_action($data){
|
||||||
// 减 bcsub(,,20)
|
|
||||||
// 乘 bcmul(,,20)
|
$account_data = Db::table($this->index_db_name['zhanghao'])->where(['token' => $data['token'],'is_del' => 0])->field('token,id,default_user_id')->find();
|
||||||
// 除 bcdiv(,,20)
|
if(!$account_data){
|
||||||
if(!array_key_exists('code',$data) || !array_key_exists('data',$data)){
|
return $this->msg(10003);
|
||||||
return $this->msg(99999,'网络异常,请稍后重试1');
|
|
||||||
}
|
|
||||||
if($data['code'] != 0){
|
|
||||||
return $this->msg(99999,'网络异常,请稍后重试2');
|
|
||||||
}
|
|
||||||
if(!is_array($data['data'])){
|
|
||||||
return $this->msg(99999,'网络异常,请稍后重试3');
|
|
||||||
}
|
|
||||||
if(!array_key_exists('bmi',$data['data']) || !array_key_exists('bmilevel',$data['data']) || !array_key_exists('bmilevelcolor',$data['data']) || !array_key_exists('bmilevellist',$data['data'])){
|
|
||||||
return $this->msg(99999,'网络异常,请稍后重试4');
|
|
||||||
}
|
|
||||||
if(!is_array($data['data']['bmilevellist'])){
|
|
||||||
return $this->msg(99999,'网络异常,请稍后重试5');
|
|
||||||
}
|
|
||||||
$num = 0;
|
|
||||||
$subsection_val = 0;
|
|
||||||
$temporary_subsection_val = null;
|
|
||||||
foreach ($data['data']['bmilevellist'] as $key => $value) {
|
|
||||||
if(!array_key_exists('maxvalue',$value) || !array_key_exists('minvalue',$value)){
|
|
||||||
return $this->msg(99999,'网络异常,请稍后重试6');
|
|
||||||
}
|
|
||||||
// 判断是否可以进行比较,规则是否正确
|
|
||||||
if(is_numeric($value['maxvalue']) && is_numeric($value['minvalue'])){
|
|
||||||
if($data['data']['bmi'] >= $value['minvalue'] && $data['data']['bmi'] < $value['maxvalue']){
|
|
||||||
// 在落点内
|
|
||||||
$subsection_val = bcsub($value['maxvalue'],$value['minvalue'],1);//获取最大最小值差
|
|
||||||
$temporary_subsection_val = bcsub($data['data']['bmi'],$value['minvalue'],1);//获取当前值与最小值差
|
|
||||||
$temporary_subsection_val = bcdiv($temporary_subsection_val,$subsection_val,1);//获取当前值与最小值差与最大最小值差之比
|
|
||||||
$subsection_val = bcdiv(100,count($data['data']['bmilevellist']),1);//每段应该的百分比
|
|
||||||
$temporary_subsection_val = bcmul($subsection_val,$temporary_subsection_val,1);//获取当前值与最小值差与最大最小值差之比与总段数之比
|
|
||||||
$temporary_subsection_val = bcadd($temporary_subsection_val,bcmul($subsection_val,$num,1),1);
|
|
||||||
}else{
|
|
||||||
$num = $num + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($temporary_subsection_val === null){
|
$user_list = Db::table($this->index_db_name['juese'])->where(['aan_id' => $account_data['id'],'is_del' => 0])->field('id,id as aud_id,activity_level,nickname,birthday,gender,card_order,head_pic,grade,weight,height,identity_name,identity_id')->select();
|
||||||
if($data['data']['bmi'] >= $data['data']['bmilevellist'][count($data['data']['bmilevellist'])-1]['maxvalue']){
|
|
||||||
$temporary_subsection_val = 100;
|
foreach ($user_list as $key => $value) {
|
||||||
}else{
|
$user_list[$key]['age'] = $this->calculate_age($value['birthday']);
|
||||||
return $this->msg(99999,'网络异常,请稍后重试7');
|
}
|
||||||
}
|
$result_data = ['default_user_id'=>$account_data['default_user_id'],'user_list'=>$user_list];
|
||||||
}
|
return $this->msg($result_data);
|
||||||
$data['data']['offset'] = $temporary_subsection_val;
|
}
|
||||||
$data = $data['data'];
|
|
||||||
// 处理key名称一致start
|
|
||||||
foreach ($data['bmilevellist'] as $key => $value) {
|
|
||||||
$data['bmilevellist'][$key]['max_val'] = $value['maxvalue'];
|
|
||||||
$data['bmilevellist'][$key]['min_val'] = $value['minvalue'];
|
|
||||||
unset($data['bmilevellist'][$key]['minvalue']);
|
|
||||||
unset($data['bmilevellist'][$key]['maxvalue']);
|
|
||||||
}
|
// // 数据对比(身体)
|
||||||
// 处理key名称一致end
|
// public function get_body_data_contrast($data){
|
||||||
return $this->msg($data);
|
// $data2 = [$data['before_id'],$data['after_id']];
|
||||||
}
|
// $data3 = implode(',',$data2);
|
||||||
public function get_user_data_information_action($data){
|
// $calculate_arr = [];
|
||||||
$return_result = [
|
// $result = Db::query("
|
||||||
'body_data'=>[],
|
// select
|
||||||
'kcal_data'=>[],
|
// acbd.id,
|
||||||
'card_data'=>[]
|
// acbd.height,
|
||||||
];
|
// acbd.weight,
|
||||||
$aud_data = Db::table($this->index_db_name['juese'])->where(['id'=>$data['aud_id']])->find();
|
// 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
|
||||||
|
// ");
|
||||||
|
|
||||||
|
// 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'] = [];
|
||||||
|
// // 处理如果没有阻抗的数据为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);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// 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
|
||||||
|
// ");
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// return $this->msg($return_data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
|
||||||
$body_data = Db::table($this->index_db_name['body_data'])->where(['id'=>$data['aud_id']])->find();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,211 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\app\controller;
|
||||||
|
|
||||||
|
class Language extends Base
|
||||||
|
{
|
||||||
|
// 支持的语言列表
|
||||||
|
protected $supportedLanguages = [
|
||||||
|
'en' => 'English',
|
||||||
|
'zh-Hans' => 'Chinese',
|
||||||
|
'es' => 'Spanish',
|
||||||
|
'fr' => 'French',
|
||||||
|
'pt' => 'Portuguese',
|
||||||
|
'ar' => 'Arabic',
|
||||||
|
'ru' => 'Russian',
|
||||||
|
'de' => 'German'
|
||||||
|
];
|
||||||
|
|
||||||
|
// 语言映射表
|
||||||
|
protected $languageMap = [
|
||||||
|
'en' => [
|
||||||
|
'操作成功' => 'Success',
|
||||||
|
'体重' => 'Weight',
|
||||||
|
'身高' => 'Height',
|
||||||
|
'消瘦' => 'Slim',
|
||||||
|
'正常' => 'Normal',
|
||||||
|
'偏重' => 'Overweight',
|
||||||
|
'肥胖' => 'Obesity',
|
||||||
|
'反映和衡量一个人健康状况的重要标志之一' => "One of the important indicators reflecting and measuring a person's health status",
|
||||||
|
'人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大' => "The length of the longitudinal part of the human body is derived from its longitudinal growth and is greatly influenced by genetic factors",
|
||||||
|
'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.",
|
||||||
|
'公斤' => "kg",
|
||||||
|
'CM' => "cm",
|
||||||
|
'年' => "-",
|
||||||
|
'月' => "-",
|
||||||
|
'日' => "",
|
||||||
|
'身体得分' => "Physical score",
|
||||||
|
'分' => "score",
|
||||||
|
'身体类型' => "body type",
|
||||||
|
'健美肌肉型' => "Bodybuilding muscle type",
|
||||||
|
'低' => "Low",
|
||||||
|
'偏低' => "Slightly low",
|
||||||
|
'标准' => "Standard",
|
||||||
|
'偏高' => "Slightly high",
|
||||||
|
'高' => "High",
|
||||||
|
'矮' => "Short",
|
||||||
|
'偏矮' => "Slightly short",
|
||||||
|
'脂肪率' => "Body Fat Percentage",
|
||||||
|
'体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.",
|
||||||
|
'脂肪量' => "Fat Mass",
|
||||||
|
'人体脂肪的重量' => "Body Fat Weight",
|
||||||
|
'肌肉率' => "Muscle Percentage",
|
||||||
|
'优' => "Excellent",
|
||||||
|
'根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.",
|
||||||
|
'肌肉量' => "Muscle Mass",
|
||||||
|
'不足' => "Insufficient",
|
||||||
|
'肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage",
|
||||||
|
'水分' => "Body Water",
|
||||||
|
'指人体内水分比例。' => "Refers to the proportion of water in the human body.",
|
||||||
|
'蛋白量' => "Protein Mass",
|
||||||
|
'蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage",
|
||||||
|
'骨重' => "Bone Mass",
|
||||||
|
'单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.",
|
||||||
|
'蛋白率' => "Protein Percentage",
|
||||||
|
'人体内蛋白率含量。' => "The proportion of protein in the human body.",
|
||||||
|
'基础代谢' => "Basal Metabolic Rate (BMR)",
|
||||||
|
'指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.",
|
||||||
|
'内脏指数' => "Visceral Fat Index",
|
||||||
|
'警惕' => "Caution",
|
||||||
|
'危险' => "Danger",
|
||||||
|
'内脏脂肪指数' => "Visceral Fat Level",
|
||||||
|
'皮下脂肪' => "Subcutaneous Fat",
|
||||||
|
'皮下脂脂肪就是贮存于皮下的脂肪组织,人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.",
|
||||||
|
'肥胖等级' => "Obesity Level",
|
||||||
|
'体重不足' => "Underweight",
|
||||||
|
'肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.",
|
||||||
|
'孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.",
|
||||||
|
'孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => "The child may be malnourished: For children in their growth and development stage, the most beneficial nutrients for height growth are proteins, carbohydrates, vitamins, and minerals. It is recommended to ensure adequate intake of nutrients such as protein, zinc, iron, calcium, vitamin D, and lysine.",
|
||||||
|
'坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.",
|
||||||
|
'3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.",
|
||||||
|
'该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.",
|
||||||
|
'孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').",
|
||||||
|
'《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》",
|
||||||
|
'《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》",
|
||||||
|
'《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》",
|
||||||
|
'《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》",
|
||||||
|
'头围' => "Head Circumference",
|
||||||
|
'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.",
|
||||||
|
|
||||||
|
],
|
||||||
|
// 可以添加更多语言映射
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理多国语言翻译
|
||||||
|
*
|
||||||
|
* @param string $language 目标语言代码
|
||||||
|
* @param mixed $data 要翻译的数据(字符串或数组)
|
||||||
|
* @return mixed 翻译后的数据
|
||||||
|
*/
|
||||||
|
public function handling_languages_from_multiple_countries($language, $data)
|
||||||
|
{
|
||||||
|
|
||||||
|
// dump($data);
|
||||||
|
// 验证语言是否支持
|
||||||
|
if (!$this->isLanguageSupported($language)) {
|
||||||
|
return $this->msg($data['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是数组,递归处理每个元素
|
||||||
|
if (is_array($data)) {
|
||||||
|
// dump(2);
|
||||||
|
$data = $this->translateArray($language, $data);
|
||||||
|
return $this->msg($data['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是字符串,直接翻译
|
||||||
|
if (is_string($data)) {
|
||||||
|
// dump(3);
|
||||||
|
return $this->translateString($language, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dump($data);
|
||||||
|
// 其他类型直接返回
|
||||||
|
return $this->msg($data['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查语言是否支持
|
||||||
|
*
|
||||||
|
* @param string $language 语言代码
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isLanguageSupported($language)
|
||||||
|
{
|
||||||
|
return isset($this->supportedLanguages[$language]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译数组
|
||||||
|
*
|
||||||
|
* @param string $language 目标语言
|
||||||
|
* @param array $array 要翻译的数组
|
||||||
|
* @return array 翻译后的数组
|
||||||
|
*/
|
||||||
|
protected function translateArray($language, array $array)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($array as $key => $value) {
|
||||||
|
// 保持键不变,只翻译值
|
||||||
|
$result[$key] = is_array($value)
|
||||||
|
? $this->translateArray($language, $value)
|
||||||
|
: $this->translateString($language, $value);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译字符串
|
||||||
|
*
|
||||||
|
* @param string $language 目标语言
|
||||||
|
* @param string $string 要翻译的字符串
|
||||||
|
* @return string 翻译后的字符串
|
||||||
|
*/
|
||||||
|
protected function translateString($language, $string)
|
||||||
|
{
|
||||||
|
// dump($string);
|
||||||
|
// 检查是否有该语言的映射表
|
||||||
|
if (!isset($this->languageMap[$language])) {
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有对应的翻译
|
||||||
|
return $this->languageMap[$language][$string] ?? $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取支持的语言列表
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSupportedLanguages()
|
||||||
|
{
|
||||||
|
return $this->supportedLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加新的语言翻译
|
||||||
|
*
|
||||||
|
* @param string $language 语言代码
|
||||||
|
* @param array $translations 翻译映射数组
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function addTranslations($language, array $translations)
|
||||||
|
{
|
||||||
|
if (!$this->isLanguageSupported($language)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->languageMap[$language])) {
|
||||||
|
$this->languageMap[$language] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->languageMap[$language] = array_merge(
|
||||||
|
$this->languageMap[$language],
|
||||||
|
$translations
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use app\NewReedaw\controller\app\Wechat;// 引入Wechat服务类
|
use app\NewReedaw2\controller\app\Wechat;// 引入Wechat服务类
|
||||||
use app\NewReedaw\controller\app\Smsaliyun;// 引入Wechat服务类
|
use app\NewReedaw2\controller\app\Smsaliyun;// 引入Wechat服务类
|
||||||
|
|
||||||
class Login extends Base{
|
class Login extends Base{
|
||||||
protected $code_time = 55;
|
protected $code_time = 55;
|
||||||
|
|
@ -22,8 +22,9 @@ class Login extends Base{
|
||||||
|
|
||||||
// 注册
|
// 注册
|
||||||
public function register(){
|
public function register(){
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
// 验证数据项是否完整
|
// 验证数据项是否完整
|
||||||
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data)){
|
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
|
|
@ -57,8 +58,9 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// 登录
|
// 登录
|
||||||
public function login(){
|
public function login(){
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('validate_type', $data)){
|
if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('validate_type', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
|
|
@ -90,8 +92,9 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// 重置密码
|
// 重置密码
|
||||||
public function reset_password(){
|
public function reset_password(){
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
// 验证数据项是否完整
|
// 验证数据项是否完整
|
||||||
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('c_password', $data) || !array_key_exists('code', $data)){
|
if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('c_password', $data) || !array_key_exists('code', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
|
|
@ -128,8 +131,9 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
// 微信手机号快捷登录
|
// 微信手机号快捷登录
|
||||||
public function wechat_quick_login(){
|
public function wechat_quick_login(){
|
||||||
try {
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
if(!array_key_exists('code', $data)){
|
if(!array_key_exists('code', $data)){
|
||||||
// return $this->msg(10001,'');
|
// return $this->msg(10001,'');
|
||||||
return $this->msg(10001,'code is miss');
|
return $this->msg(10001,'code is miss');
|
||||||
|
|
@ -154,14 +158,17 @@ class Login extends Base{
|
||||||
// 调用Wechat服务类处理微信登录逻辑
|
// 调用Wechat服务类处理微信登录逻辑
|
||||||
$wechatService = new Wechat();
|
$wechatService = new Wechat();
|
||||||
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
|
$result = $wechatService->handleWechatLogin($data['code'], $data['encryptedData'], $data['iv']);
|
||||||
|
|
||||||
if($result['code'] == 0){
|
if($result['code'] == 0){
|
||||||
$user_data = Db::table($this->login_use_db_name['zhanghao'])->where(['tel'=>$result['data']['phoneNumber']])->fidle('token,id,is_del')->find();
|
$user_data = Db::table($this->login_use_db_name['zhanghao'])->where(['tel'=>$result['data']['phoneNumber']])->field('token,id,is_del')->find();
|
||||||
|
// dump($result);
|
||||||
|
// die;
|
||||||
if($user_data){
|
if($user_data){
|
||||||
if($user_data['is_del'] == 1){
|
if($user_data['is_del'] == 1){
|
||||||
return $this->msg(10002,'该账号已注销');
|
return $this->msg(10002,'该账号已注销');
|
||||||
}
|
}
|
||||||
Db::table($this->login_use_db_name['zhanghao'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
Db::table($this->login_use_db_name['zhanghao'])->where(['token'=>$user_data['token']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||||
$return_data = $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
|
return $this->msg(['token'=>$user_data['token'],'aan_id'=>$user_data['id']]);
|
||||||
}else{
|
}else{
|
||||||
$set_data['password'] = '';
|
$set_data['password'] = '';
|
||||||
$set_data['tel'] = $result['data']['phoneNumber'];
|
$set_data['tel'] = $result['data']['phoneNumber'];
|
||||||
|
|
@ -356,6 +363,7 @@ class Login extends Base{
|
||||||
return $this->msg(10005);
|
return $this->msg(10005);
|
||||||
}
|
}
|
||||||
$verify_result[$montage_data] = $data['data'];
|
$verify_result[$montage_data] = $data['data'];
|
||||||
|
$verify_result['is_del'] = 0;
|
||||||
// $verify_result['is_del'] = 0;
|
// $verify_result['is_del'] = 0;
|
||||||
// 检测校验途径
|
// 检测校验途径
|
||||||
if($data['validate_type'] == 'code'){
|
if($data['validate_type'] == 'code'){
|
||||||
|
|
@ -363,10 +371,10 @@ class Login extends Base{
|
||||||
if($this->check_code($code_name,$data['validate_data']) === true){
|
if($this->check_code($code_name,$data['validate_data']) === true){
|
||||||
$result = Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->field('id,token,is_del')->find();
|
$result = Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->field('id,token,is_del')->find();
|
||||||
if($result){
|
if($result){
|
||||||
if($result['is_del'] == 1){
|
// if($result['is_del'] == 1){
|
||||||
return $this->msg(10002,'该账号已注销');
|
// return $this->msg(10002,'该账号已注销');
|
||||||
}
|
// }
|
||||||
Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s')]);
|
Db::table($this->login_use_db_name['zhanghao'])->where(['id'=>$result['id']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||||
$return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]);
|
$return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]);
|
||||||
}else{
|
}else{
|
||||||
$set_data['password'] = '';
|
$set_data['password'] = '';
|
||||||
|
|
@ -390,16 +398,16 @@ class Login extends Base{
|
||||||
// $verify_result['password'] = $data['validate_data'];
|
// $verify_result['password'] = $data['validate_data'];
|
||||||
$result = Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->field('id,token,password,is_del')->find();
|
$result = Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->field('id,token,password,is_del')->find();
|
||||||
if($result){
|
if($result){
|
||||||
if($result['is_del'] == 1){
|
// if($result['is_del'] == 1){
|
||||||
return $this->msg(10002,'该账号已注销');
|
// return $this->msg(10002,'该账号已注销');
|
||||||
}
|
// }
|
||||||
if($result['password'] == ''){
|
if($result['password'] == ''){
|
||||||
$return_data = $this->msg(10002,'该账户未设密码,请用验证码登录');
|
$return_data = $this->msg(10002,'该账户未设密码,请用验证码登录');
|
||||||
}
|
}
|
||||||
if($data['validate_data'] != $result['password']){
|
if($data['validate_data'] != $result['password']){
|
||||||
$return_data = $this->msg(10002,'账号或密码错误');
|
$return_data = $this->msg(10002,'账号或密码错误');
|
||||||
}else{
|
}else{
|
||||||
Db::table($this->login_use_db_name['zhanghao'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s')]);
|
Db::table($this->login_use_db_name['zhanghao'])->where(['id'=>$result['id']])->update(['login_time'=>date('Y-m-d H:i:s')]);
|
||||||
$return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']],'登录成功');
|
$return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']],'登录成功');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
use think\Controller;
|
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\Cache;
|
use app\NewReedaw2\controller\app\Login;
|
||||||
use think\Log;
|
use app\NewReedaw2\controller\app\Kitchenscale;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
|
||||||
|
|
||||||
class Role extends Base{
|
class Role extends Base{
|
||||||
|
|
||||||
protected $role_db_name = [
|
protected $role_db_name = [
|
||||||
'zhanghao'=>'app_account_number',
|
'zhanghao'=>'app_account_number',
|
||||||
'juese'=>'app_user_data',
|
'juese'=>'app_user_data',
|
||||||
'quyu_card'=>'admin_estimate'
|
'quyu_card'=>'admin_estimate',
|
||||||
|
'cfc_user'=>'app_user_data'
|
||||||
];
|
];
|
||||||
protected $identity_list = ['P0'=>'陌生人','P1'=>'爸爸','P2'=>'妈妈','P3'=>'大宝','P4'=>'二宝','P5'=>'三宝','P6'=>'四宝','P7'=>'爷爷','P8'=>'奶奶'];
|
protected $identity_list = ['P0'=>'陌生人','P1'=>'爸爸','P2'=>'妈妈','P3'=>'大宝','P4'=>'二宝','P5'=>'三宝','P6'=>'四宝','P7'=>'爷爷','P8'=>'奶奶'];
|
||||||
protected $grade_list = [
|
protected $grade_list = [
|
||||||
|
|
@ -52,9 +52,9 @@ class Role extends Base{
|
||||||
];
|
];
|
||||||
// 阶段性称谓
|
// 阶段性称谓
|
||||||
protected $stage_appellation = [
|
protected $stage_appellation = [
|
||||||
['min'=>'0','max'=>'3','value'=>'婴儿'],
|
['min'=>'0','max'=>'3','value'=>'婴儿','identification'=>3],
|
||||||
['min'=>'3','max'=>'16','value'=>'儿童'],
|
['min'=>'3','max'=>'16','value'=>'儿童','identification'=>2],
|
||||||
['min'=>'16','max'=>'500','value'=>'成人']
|
['min'=>'16','max'=>'500','value'=>'成人','identification'=>1]
|
||||||
];
|
];
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
// 减 bcsub(,,20)
|
// 减 bcsub(,,20)
|
||||||
|
|
@ -66,17 +66,181 @@ class Role extends Base{
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
||||||
// 添加角色
|
// 获取账号下信息
|
||||||
public function add_member(){
|
public function get_my_account_msg(){
|
||||||
try {
|
|
||||||
// 你的业务逻辑
|
|
||||||
$data = input('post.');
|
$data = input('post.');
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('measure_model', $data)){
|
try {
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
|
if($data['token'] == ''){
|
||||||
|
return $this->msg(-2,'请先登录',[]);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$return_data = $this->get_my_account_msg_action($data);
|
||||||
|
// 成功
|
||||||
|
$this->record_api_log($data, null, $return_data);
|
||||||
|
return $return_data;
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 邮箱/手机绑定
|
||||||
|
public function update_my_account_msg(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('data', $data) || !array_key_exists('token', $data) || !array_key_exists('code', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['code'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->update_my_account_msg_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 修改密码
|
||||||
|
public function update_my_password(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('password', $data) || !array_key_exists('c_password', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['password'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['c_password'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$return_data = $this->update_my_password_action($data);
|
||||||
|
// 成功
|
||||||
|
$this->record_api_log($data, null, $return_data);
|
||||||
|
return $return_data;
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 修改账号信息
|
||||||
|
public function set_my_account_msg(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('weight', $data) || !array_key_exists('height', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('activity_level', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['height'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['gender'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$return_data = $this->set_my_account_msg_action($data);
|
||||||
|
// 成功
|
||||||
|
$this->record_api_log($data, null, $return_data);
|
||||||
|
return $return_data;
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 添加角色
|
||||||
|
public function add_member(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
// 你的业务逻辑
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001,'token is loss');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('nickname', $data)){
|
||||||
|
return $this->msg(10001,'昵称缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('birthday', $data)){
|
||||||
|
return $this->msg(10001,'生日缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('gender', $data)){
|
||||||
|
return $this->msg(10001,'性别缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('height', $data)){
|
||||||
|
return $this->msg(10001,'身高缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('weight', $data)){
|
||||||
|
return $this->msg(10001,'体重缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('activity_level', $data)){
|
||||||
|
return $this->msg(10001,'活动系数缺失');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
||||||
|
return $this->msg(10005,'activity_level type error');
|
||||||
|
}
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type error');
|
return $this->msg(10005,'token type error');
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +256,9 @@ class Role extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||||
return $this->msg(10005,'weight type error');
|
return $this->msg(10005,'weight type error');
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
||||||
|
return $this->msg(10005,'nickname type error');
|
||||||
|
}
|
||||||
return $this->add_member_action($data);
|
return $this->add_member_action($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
|
|
@ -109,14 +276,36 @@ class Role extends Base{
|
||||||
}
|
}
|
||||||
// 更新角色
|
// 更新角色
|
||||||
public function update_member(){
|
public function update_member(){
|
||||||
|
$data = input('post.');
|
||||||
try {
|
try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
$data = input('post.');
|
|
||||||
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data) || !array_key_exists('nickname', $data) || !array_key_exists('birthday', $data) || !array_key_exists('gender', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data) || !array_key_exists('measure_model', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001,'token is loss');
|
||||||
}
|
}
|
||||||
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
|
if(!array_key_exists('nickname', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001,'昵称缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('birthday', $data)){
|
||||||
|
return $this->msg(10001,'生日缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('gender', $data)){
|
||||||
|
return $this->msg(10001,'性别缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('height', $data)){
|
||||||
|
return $this->msg(10001,'身高缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('weight', $data)){
|
||||||
|
return $this->msg(10001,'体重缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('activity_level', $data)){
|
||||||
|
return $this->msg(10001,'活动系数缺失');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('id', $data)){
|
||||||
|
return $this->msg(10001,'id is loss');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
||||||
|
return $this->msg(10005,'activity_level type error');
|
||||||
}
|
}
|
||||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
return $this->msg(10005,'token type error');
|
return $this->msg(10005,'token type error');
|
||||||
|
|
@ -136,6 +325,12 @@ class Role extends Base{
|
||||||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||||
return $this->msg(10005,'weight type error');
|
return $this->msg(10005,'weight type error');
|
||||||
}
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
||||||
|
return $this->msg(10005,'nickname type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['id'],'intnum')){
|
||||||
|
return $this->msg(10005,'id type error');
|
||||||
|
}
|
||||||
return $this->update_member_action($data);
|
return $this->update_member_action($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 捕获异常
|
// 捕获异常
|
||||||
|
|
@ -153,9 +348,10 @@ class Role extends Base{
|
||||||
}
|
}
|
||||||
// 获取角色列表
|
// 获取角色列表
|
||||||
public function role_list(){
|
public function role_list(){
|
||||||
|
$data = input('post.');
|
||||||
try {
|
try {
|
||||||
// 你的业务逻辑
|
// 你的业务逻辑
|
||||||
$data = input('post.');
|
|
||||||
if(!array_key_exists('token', $data)){
|
if(!array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
|
|
@ -177,9 +373,240 @@ class Role extends Base{
|
||||||
return $this->msg(99999);
|
return $this->msg(99999);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 修改昵称
|
||||||
|
public function update_my_nickname(){
|
||||||
|
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
if(!array_key_exists('nickname', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$return_data = $this->update_my_nickname_action($data);
|
||||||
|
// 成功
|
||||||
|
$this->record_api_log($data, null, $return_data);
|
||||||
|
return $return_data;
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 获取指定用户详细信息
|
||||||
|
public function get_user_data_information(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!array_key_exists('aud_id', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
return $this->get_user_data_information_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 删除角色
|
||||||
|
public function del_member(){
|
||||||
|
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
return $this->del_member_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
################################################################action################################################################
|
################################################################action################################################################
|
||||||
|
|
||||||
|
|
||||||
|
public function get_my_account_msg_action($data){
|
||||||
|
$result = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->find();
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
$cfc_user = $cfc->table($this->role_db_name['cfc_user'])
|
||||||
|
->where(['token'=>$data['token']])
|
||||||
|
->find(); // 然后获取结果
|
||||||
|
|
||||||
|
//
|
||||||
|
if($result){
|
||||||
|
$return_data = [
|
||||||
|
'my_tel'=>$result['tel'],
|
||||||
|
'my_email'=>$result['email'],
|
||||||
|
'create_time'=>$result['create_time'],
|
||||||
|
'token'=>$result['token'],
|
||||||
|
'nickname'=>$result['nickname'],
|
||||||
|
'head_pic'=>$result['head_pic'],
|
||||||
|
];
|
||||||
|
if($cfc_user){
|
||||||
|
// dump($result);
|
||||||
|
|
||||||
|
$return_data['weight'] = $cfc_user['weight'];
|
||||||
|
$return_data['height'] = $cfc_user['height'];
|
||||||
|
$return_data['birthday'] = $cfc_user['birthday'];
|
||||||
|
$return_data['gender'] = $cfc_user['gender'];
|
||||||
|
$return_data['activity_level'] = $cfc_user['activity_level'];
|
||||||
|
}else{
|
||||||
|
$return_data['weight'] = 0;
|
||||||
|
$return_data['height'] = 0;
|
||||||
|
$return_data['birthday'] = '';
|
||||||
|
$return_data['gender'] = '';
|
||||||
|
$return_data['activity_level'] = '';
|
||||||
|
}
|
||||||
|
return $this->msg($return_data);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function update_my_account_msg_action($data){
|
||||||
|
$login_action = new Login();
|
||||||
|
$validate_result = $login_action->check_code($data['data'],$data['code']);
|
||||||
|
if($validate_result !== true){
|
||||||
|
return $this->msg(10001,$validate_result);
|
||||||
|
}
|
||||||
|
$montage_data = $this->is_tel_email($data['data']);
|
||||||
|
if($montage_data == false){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
$result = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||||||
|
$montage_data=>$data['data'],
|
||||||
|
'update_time'=>date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
if($result){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function update_my_password_action($data){
|
||||||
|
if($data['password'] != $data['c_password']){
|
||||||
|
return $this->msg(10003,'两次密码不一致');
|
||||||
|
}
|
||||||
|
if($data['password'] == ''){
|
||||||
|
return $this->msg(10003,'密码不能为空');
|
||||||
|
}
|
||||||
|
$result = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||||||
|
'password'=>$data['password'],
|
||||||
|
'update_time'=>date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
if($result){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function set_my_account_msg_action($data){
|
||||||
|
$cfc = Db::connect('cfc_db');
|
||||||
|
$user = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->find();
|
||||||
|
if($user){
|
||||||
|
$cfc_user = $cfc->table($this->role_db_name['cfc_user'])
|
||||||
|
->where(['token'=>$data['token']])
|
||||||
|
->find(); // 然后获取结果
|
||||||
|
if($cfc_user){
|
||||||
|
$cfc_user = $cfc->table($this->role_db_name['cfc_user'])
|
||||||
|
->where(['token'=>$data['token']])
|
||||||
|
->update([
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'height'=>$data['height'],
|
||||||
|
'birthday'=>$data['birthday'],
|
||||||
|
'gender'=>$data['gender'],
|
||||||
|
'activity_level'=>$data['activity_level'],
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$add_data = [
|
||||||
|
'token'=>$data['token'],
|
||||||
|
'nickname'=>$user['nickname'],
|
||||||
|
'gender'=>$data['gender'],
|
||||||
|
'height'=>$data['height'],
|
||||||
|
'weight'=>$data['weight'],
|
||||||
|
'birthday'=>$data['birthday'],
|
||||||
|
'activity_level'=>$data['activity_level'],
|
||||||
|
];
|
||||||
|
$user_age = $this->calculate_age($data['birthday']);
|
||||||
|
if($data['gender'] == 2){
|
||||||
|
if($user_age <= 18){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman1.png";
|
||||||
|
}else if($user_age <= 39 && $user_age > 18){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman2.png";
|
||||||
|
}else if($user_age <= 59 && $user_age > 39){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman3.png";
|
||||||
|
}else if($user_age >= 60){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman4.png";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if($user_age <= 18){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
||||||
|
}else if($user_age <= 39 && $user_age > 18){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man2.png";
|
||||||
|
}else if($user_age <= 59 && $user_age > 39){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man3.png";
|
||||||
|
}else if($user_age >= 60){
|
||||||
|
$data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man4.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cfc_user = $cfc->table($this->role_db_name['cfc_user'])->insert($add_data);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function add_member_action($data){
|
public function add_member_action($data){
|
||||||
$aan_id = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token']])->field('id,token')->find();
|
$aan_id = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token']])->field('id,token')->find();
|
||||||
if(!$aan_id){
|
if(!$aan_id){
|
||||||
|
|
@ -195,42 +622,42 @@ class Role extends Base{
|
||||||
$parameter['card_order'] = '';
|
$parameter['card_order'] = '';
|
||||||
$parameter['create_time'] = date('Y-m-d H:i:s');
|
$parameter['create_time'] = date('Y-m-d H:i:s');
|
||||||
$parameter['last_update_time'] = $parameter['create_time'];
|
$parameter['last_update_time'] = $parameter['create_time'];
|
||||||
$parameter['measure_model'] = $data['measure_model'];
|
$parameter['activity_level'] = $data['activity_level'];
|
||||||
$is_nickname_ok = Db::table($this->role_db_name['juese'])->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
|
$is_nickname_ok = Db::table($this->role_db_name['juese'])->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
|
||||||
if($is_nickname_ok>0){
|
if($is_nickname_ok>0){
|
||||||
return $this->msg(10002,'该角色已存在');
|
return $this->msg(10002,'该角色已存在');
|
||||||
}
|
}
|
||||||
if($parameter['measure_model'] == 1){
|
// if($parameter['measure_model'] == 1){
|
||||||
if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
// if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||||
return $this->msg(10001);
|
// return $this->msg(10001);
|
||||||
}
|
// }
|
||||||
if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
// if(!array_key_exists($data['identity_id'],$this->identity_lis3t)){
|
||||||
return $this->msg(10005,'身份信息错误');
|
// return $this->msg(10005,'身份信息错误');
|
||||||
}
|
// }
|
||||||
if(!array_key_exists($data['grade'],$this->grade_list2)){
|
// if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||||
return $this->msg(10005,'年级信息错误');
|
// return $this->msg(10005,'年级信息错误');
|
||||||
}
|
// }
|
||||||
$parameter['grade'] = $data['grade'];
|
// $parameter['grade'] = $data['grade'];
|
||||||
$parameter['identity_id'] = $data['identity_id'];
|
// $parameter['identity_id'] = $data['identity_id'];
|
||||||
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
// $parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||||
$parameter['address'] = $data['address'];
|
// $parameter['address'] = $data['address'];
|
||||||
$address_data = Db::table($this->role_db_name['quyu_card'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
|
// $address_data = Db::table($this->role_db_name['quyu_card'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
|
||||||
$parameter['card_order'] = $address_data['recommend_cards'];
|
// $parameter['card_order'] = $address_data['recommend_cards'];
|
||||||
}else{
|
// }else{
|
||||||
$parameter['grade'] = 'nothing';
|
// $parameter['grade'] = 'nothing';
|
||||||
$parameter['identity_id'] = 'P0';
|
// $parameter['identity_id'] = 'P0';
|
||||||
$parameter['identity_name'] = '陌生人';
|
// $parameter['identity_name'] = '陌生人';
|
||||||
$parameter['address'] = '';
|
// $parameter['address'] = '';
|
||||||
}
|
// }
|
||||||
if($parameter['identity_id'] != 'P0'){
|
// if($parameter['identity_id'] != 'P0'){
|
||||||
$result = Db::table($this->role_db_name['juese'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
|
// $result = Db::table($this->role_db_name['juese'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
|
||||||
if($result>0){
|
// if($result>0){
|
||||||
return $this->msg(10005,'该身份已存在');
|
// return $this->msg(10005,'该身份已存在');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
$return_result = Db::table($this->role_db_name['juese'])->insert($parameter);
|
$return_result = Db::table($this->role_db_name['juese'])->insertGetId($parameter);
|
||||||
if($return_result){
|
if($return_result){
|
||||||
return $this->msg([]);
|
return $this->msg(['aud_id'=>$return_result]);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10002);
|
return $this->msg(10002);
|
||||||
}
|
}
|
||||||
|
|
@ -248,32 +675,32 @@ class Role extends Base{
|
||||||
$parameter['weight'] = $data['weight'];
|
$parameter['weight'] = $data['weight'];
|
||||||
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
|
$parameter['head_pic'] = $data['gender'] == 2?'http://tc.pcxbc.com/tsf/2.png':'http://tc.pcxbc.com/tsf/1.png';
|
||||||
$parameter['last_update_time'] = date('Y-m-d H:i:s');
|
$parameter['last_update_time'] = date('Y-m-d H:i:s');
|
||||||
$parameter['measure_model'] = $data['measure_model'];
|
$parameter['activity_level'] = $data['activity_level'];
|
||||||
if($parameter['measure_model'] == 1){
|
// if($parameter['measure_model'] == 1){
|
||||||
if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
// if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||||
return $this->msg(10001);
|
// return $this->msg(10001);
|
||||||
}
|
// }
|
||||||
if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
// if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
||||||
return $this->msg(10005,'身份信息错误');
|
// return $this->msg(10005,'身份信息错误');
|
||||||
}
|
// }
|
||||||
if(!array_key_exists($data['grade'],$this->grade_list2)){
|
// if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||||
return $this->msg(10005,'年级信息错误');
|
// return $this->msg(10005,'年级信息错误');
|
||||||
}
|
// }
|
||||||
$parameter['grade'] = $data['grade'];
|
// $parameter['grade'] = $data['grade'];
|
||||||
$parameter['identity_id'] = $data['identity_id'];
|
// $parameter['identity_id'] = $data['identity_id'];
|
||||||
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
// $parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||||
$parameter['address'] = $data['address'];
|
// $parameter['address'] = $data['address'];
|
||||||
if($parameter['identity_id'] != 'P0'){
|
// if($parameter['identity_id'] != 'P0'){
|
||||||
$result = Db::table($this->role_db_name['juese'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$aan_id['id'],'is_del'=>0])->count();
|
// $result = Db::table($this->role_db_name['juese'])->where(['identity_id'=>$parameter['identity_id'],'aan_id'=>$aan_id['id'],'is_del'=>0])->count();
|
||||||
if($result>0){
|
// if($result>0){
|
||||||
return $this->msg(10005,'该身份已存在');
|
// return $this->msg(10005,'该身份已存在');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
$address_data = Db::table($this->role_db_name['quyu_card'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
|
// $address_data = Db::table($this->role_db_name['quyu_card'])->where(['province'=>explode(',',$parameter['address'])[0],'is_del'=>0])->field('id,recommend_cards')->find();
|
||||||
$parameter['card_order'] = $address_data['recommend_cards'];
|
// $parameter['card_order'] = $address_data['recommend_cards'];
|
||||||
}
|
// }
|
||||||
|
|
||||||
$return_result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['aud_id']])->update($parameter);
|
$return_result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['id']])->update($parameter);
|
||||||
if($return_result){
|
if($return_result){
|
||||||
return $this->msg([]);
|
return $this->msg([]);
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -312,7 +739,9 @@ class Role extends Base{
|
||||||
// 添加阶段称谓、婴儿、儿童、成人
|
// 添加阶段称谓、婴儿、儿童、成人
|
||||||
foreach ($this->stage_appellation as $key => $value) {
|
foreach ($this->stage_appellation as $key => $value) {
|
||||||
if($result[$i]['age'] >= $value['min'] && $result[$i]['age'] < $value['max']){
|
if($result[$i]['age'] >= $value['min'] && $result[$i]['age'] < $value['max']){
|
||||||
$result[$i]['stage'] = $value['value'];
|
// $result[$i]['stage'] = $value['value'];
|
||||||
|
$result[$i]['stage'] = $value['identification'];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -320,6 +749,154 @@ class Role extends Base{
|
||||||
}
|
}
|
||||||
return $this->msg($temporary_data);
|
return $this->msg($temporary_data);
|
||||||
}
|
}
|
||||||
|
public function update_my_nickname_action($data){
|
||||||
|
$result = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||||||
|
'nickname'=>$data['nickname'],
|
||||||
|
'update_time'=>date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
if($result){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_user_data_information_action($data){
|
||||||
|
|
||||||
|
// 获取账号下信息以及用户信息
|
||||||
|
$zhanghao_data = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!$zhanghao_data){
|
||||||
|
return $this->msg(10004);
|
||||||
|
}
|
||||||
|
// 获取账号下信息以及用户信息start
|
||||||
|
$user_all_data['aud_id'] = '';
|
||||||
|
$user_all_data['token'] = $zhanghao_data['token'];
|
||||||
|
$user_all_data['nickname'] = '';
|
||||||
|
$user_all_data['head_pic'] = $zhanghao_data['head_pic'];
|
||||||
|
$user_all_data['gender'] = '';
|
||||||
|
$user_all_data['age'] = '';
|
||||||
|
$user_all_data['height'] = '';
|
||||||
|
$user_all_data['weight'] = '';
|
||||||
|
$user_all_data['set_kcal'] = '';
|
||||||
|
$user_all_data['is_use_set_kcal'] = '';
|
||||||
|
$user_all_data['tel'] = $zhanghao_data['tel'];
|
||||||
|
$user_all_data['email'] = $zhanghao_data['email'];
|
||||||
|
|
||||||
|
$user_all_data['aan_id'] = $zhanghao_data['id'];
|
||||||
|
$user_all_data['card_order'] = [];
|
||||||
|
$user_all_data['target_weight'] = 0;
|
||||||
|
$user_all_data['initial_weight'] = 0;
|
||||||
|
$user_all_data['initial_date'] = 0;
|
||||||
|
$user_all_data['address'] = '';
|
||||||
|
$user_all_data['identity_id'] = 'P0';
|
||||||
|
$user_all_data['measure_model'] = 1;
|
||||||
|
$user_all_data['head_data'] = 0;
|
||||||
|
$user_all_data['stage'] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$user_account = Db::table($this->role_db_name['juese'])
|
||||||
|
->where(["id"=>$data['aud_id']])
|
||||||
|
// ->field('id as aud_id,nickname,head_pic,gender,height,weight,birthday,set_kcal,is_use_set_kcal,activity_level')
|
||||||
|
->field('id as aud_id,nickname,head_pic,gender,height,weight,birthday,card_order,target_weight,initial_weight,initial_date,address,identity_id,measure_model,head_data,set_kcal,is_use_set_kcal,activity_level')
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if($user_account){
|
||||||
|
if($user_account['set_kcal'] == '.00'){
|
||||||
|
$user_account['set_kcal'] = 0;
|
||||||
|
}
|
||||||
|
$user_all_data['id'] = $user_account['aud_id'];
|
||||||
|
$user_all_data['aud_id'] = $user_account['aud_id'];
|
||||||
|
$user_all_data['nickname'] = $user_account['nickname'];
|
||||||
|
$user_all_data['gender'] = $user_account['gender'];
|
||||||
|
$user_all_data['age'] = $this->calculate_age($user_account['birthday']);
|
||||||
|
$user_all_data['height'] = $user_account['height'];
|
||||||
|
$user_all_data['weight'] = $user_account['weight'];
|
||||||
|
$user_all_data['set_kcal'] = $user_account['set_kcal'];
|
||||||
|
$user_all_data['is_use_set_kcal'] = $user_account['is_use_set_kcal'];
|
||||||
|
$user_all_data['birthday'] = $user_account['birthday'];
|
||||||
|
$user_all_data['activity_level'] = $user_account['activity_level'];
|
||||||
|
|
||||||
|
$user_all_data['card_order'] = explode(',',$user_account['card_order']);
|
||||||
|
$user_all_data['target_weight'] = $user_account['target_weight'];
|
||||||
|
$user_all_data['initial_weight'] = $user_account['initial_weight'];
|
||||||
|
$user_all_data['initial_date'] = $user_account['initial_date'];
|
||||||
|
$user_all_data['address'] = $user_account['address'];
|
||||||
|
$user_all_data['identity_id'] = $user_account['identity_id'];
|
||||||
|
$user_all_data['measure_model'] = $user_account['measure_model'];
|
||||||
|
$user_all_data['head_data'] = $user_account['head_data'];
|
||||||
|
|
||||||
|
foreach ($this->stage_appellation as $key => $value) {
|
||||||
|
if($user_all_data['age'] >= $value['min'] && $user_all_data['age'] < $value['max']){
|
||||||
|
// $user_all_data['stage'] = $value['value'];
|
||||||
|
$user_all_data['stage'] = $value['identification'];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if($user_all_data['gender'] == 2){
|
||||||
|
// if($user_all_data['age'] <= 18){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman1.png";
|
||||||
|
// }else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman2.png";
|
||||||
|
// }else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman3.png";
|
||||||
|
// }else if($user_all_data['age'] >= 60){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman4.png";
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// if($user_all_data['age'] <= 18){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
||||||
|
// }else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man2.png";
|
||||||
|
// }else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man3.png";
|
||||||
|
// }else if($user_all_data['age'] >= 60){
|
||||||
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man4.png";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
$kitchenscale = NEW Kitchenscale;
|
||||||
|
$user_all_data['food_count'] = $kitchenscale->get_countfoot_content_action(['token'=>$data['token'],'aud_id'=>$user_all_data['aud_id'],'time'=>date('Y-m-d')]);
|
||||||
|
$user_all_data['food_count'] = ($user_all_data['food_count']->getData())['data'];
|
||||||
|
// dump($user_all_data['food_count']);
|
||||||
|
}else{
|
||||||
|
$user_account['set_kcal'] = 0;
|
||||||
|
$user_all_data['aud_id'] = null;
|
||||||
|
$user_all_data['gender'] = 0;
|
||||||
|
$user_all_data['age'] = false;
|
||||||
|
$user_all_data['height'] = null;
|
||||||
|
$user_all_data['weight'] = null;
|
||||||
|
$user_all_data['set_kcal'] = 0;
|
||||||
|
$user_all_data['is_use_set_kcal'] = 0;
|
||||||
|
$user_all_data['birthday'] = null;
|
||||||
|
$user_all_data['activity_level'] = null;
|
||||||
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
||||||
|
|
||||||
|
$user_all_data['food_count'] = [];
|
||||||
|
// $user_all_data['food_count'] = ($user_all_data['food_count']->getData())['data'];
|
||||||
|
}
|
||||||
|
return $this->msg($user_all_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function del_member_action($data){
|
||||||
|
// $zh_data = Db::table($this->role_db_name['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->field('id,token')->find();
|
||||||
|
|
||||||
|
$result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['aud_id']])->update([
|
||||||
|
'is_del'=>1
|
||||||
|
]);
|
||||||
|
if($result){
|
||||||
|
return $this->msg([]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,267 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Cache;
|
||||||
|
|
||||||
|
class Skip extends Base{
|
||||||
|
|
||||||
|
protected $skip_db_name = [
|
||||||
|
'zhanghao'=>'app_account_number',
|
||||||
|
'juese'=>'app_user_data',
|
||||||
|
'body'=>'app_card_body_data',
|
||||||
|
'body_new'=>'app_card_body_data_new',
|
||||||
|
'skip'=>'app_card_skip_data',
|
||||||
|
|
||||||
|
];
|
||||||
|
protected $curve_data_format = ['jump_num'=>['跳绳个数','个','#009DFF'],'jump_time'=>['跳绳时长','分钟','#009DFF'],'jump_kcal'=>['消耗卡路里','kcal','#009DFF']];
|
||||||
|
// protected $skip_use_db_name = [
|
||||||
|
// '1'=>'app_card_skip_data',
|
||||||
|
// '2'=>'app_user_data',
|
||||||
|
// '3'=>'app_card_body_data',
|
||||||
|
// ];
|
||||||
|
protected $pagesize = 15;
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||||
|
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
|
||||||
|
// 设备记录
|
||||||
|
public function device_record(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
// 你的业务逻辑
|
||||||
|
if(count(input('post.')) > 0){
|
||||||
|
$data = input('post.');
|
||||||
|
}
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('kcal', $data) || !array_key_exists('num', $data) || !array_key_exists('time_m', $data) || !array_key_exists('time_s', $data) || !array_key_exists('type', $data) || !array_key_exists('token', $data)){
|
||||||
|
$return_data = $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['kcal'],'num')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['type'],'str')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
if(!$this->isValidInteger($data['num']+0) || !$this->isValidInteger($data['time_m']+0) || !$this->isValidInteger($data['time_s']+0)){
|
||||||
|
$return_data = $this->msg(10005,'跳绳数量或者分钟、秒钟值必须为整数');
|
||||||
|
}
|
||||||
|
if($data['num'] <= 0){
|
||||||
|
$return_data = $this->msg(10005,'跳绳数不能小于等于0');
|
||||||
|
}
|
||||||
|
if(abs($data['time_s']) >= 60){
|
||||||
|
$return_data = $this->msg(10005,'秒钟值不能大于60');
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
|
||||||
|
return $this->device_record_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 数据报告
|
||||||
|
public function data_report(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
return $this->data_report_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################action################################################################
|
||||||
|
################################################################action################################################################
|
||||||
|
public function device_record_action($data){
|
||||||
|
|
||||||
|
// 分秒转换为秒
|
||||||
|
$data['time'] = abs($data['time_m'])*60+abs($data['time_s']);
|
||||||
|
$user_msg_content = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->count();
|
||||||
|
if($user_msg_content<=0){
|
||||||
|
return $this->msg(10004);
|
||||||
|
}
|
||||||
|
if(!array_key_exists('kcal', $data)){
|
||||||
|
$last_data_body = Db::table($this->skip_db_name['body_new'])->where(['aud_id'=>$data['aud_id'],'is_del'=>0])->order('record_time desc,id desc')->field('id,weight_val,record_time')->find();
|
||||||
|
if(!$last_data_body){
|
||||||
|
$last_data_body = Db::table($this->skip_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,weight as weight_val')->find();
|
||||||
|
if(!$last_data_body){
|
||||||
|
return $this->msg(10004);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$kcal_data = $this->skip_kcal_calculate($data['num'],$data['time'],$last_data_body['weight_val']);
|
||||||
|
}else{
|
||||||
|
// 将时间从秒转换为分钟
|
||||||
|
$minutes = bcdiv($data['time'],60,20);
|
||||||
|
// 计算每分钟的跳绳次数
|
||||||
|
$jumpsPerMinute = bcdiv($data['num'],$minutes,2);
|
||||||
|
$kcal_data['totalCalories'] = $data['kcal'];
|
||||||
|
$kcal_data['averageAchievement'] = $jumpsPerMinute;
|
||||||
|
$kcal_data['caloriesPerMinute'] = bcdiv($kcal_data['totalCalories'],$minutes,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$data_set = [
|
||||||
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'last_update_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'jump_num'=>$data['num'],
|
||||||
|
|
||||||
|
'jump_time'=>$data['time'],
|
||||||
|
'jump_kcal'=>$kcal_data['totalCalories'],
|
||||||
|
'average_num'=>$kcal_data['averageAchievement'],
|
||||||
|
'average_kcal'=>$kcal_data['caloriesPerMinute'],
|
||||||
|
'aud_id'=>$data['aud_id'],
|
||||||
|
'record_time'=>array_key_exists('r_time', $data)?$data['r_time']:date('Y-m-d H:i:s'),
|
||||||
|
'jump_type'=>$data['type']
|
||||||
|
];
|
||||||
|
if(strlen($data_set['record_time']) <= 12){
|
||||||
|
$data_set['record_time'] = $this->addCurrentTimeToDateString($data_set['record_time']);
|
||||||
|
}
|
||||||
|
$last_data_body = Db::table($this->skip_db_name['skip'])->insert($data_set);
|
||||||
|
$result = [
|
||||||
|
'today_jump_num'=>0,
|
||||||
|
'today_jump_time'=>0,
|
||||||
|
'today_jump_kcal'=>0,
|
||||||
|
];
|
||||||
|
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||||
|
foreach ($all_data as $key => $value) {
|
||||||
|
$result['today_jump_num'] = $result['today_jump_num']+$value['jump_num'];
|
||||||
|
$result['today_jump_time'] = $result['today_jump_time']+$value['jump_time'];
|
||||||
|
$result['today_jump_kcal'] = bcadd($result['today_jump_kcal'],$value['jump_kcal'],2);
|
||||||
|
}
|
||||||
|
$result['last_jump_num'] = $data['num'];
|
||||||
|
$result['last_jump_time'] = $data['time'];
|
||||||
|
$result['last_jump_kcal'] = $data_set['jump_kcal'];
|
||||||
|
// $result['last_record_time'] = str_replace('-', '/', $data_set['record_time']);
|
||||||
|
$result['last_record_time'] = $data_set['record_time'];
|
||||||
|
$time_conversion = $this->handle_hour_branch_second($result['today_jump_time']);
|
||||||
|
$result['today_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||||
|
$time_conversion = $this->handle_hour_branch_second($result['last_jump_time']);
|
||||||
|
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||||
|
return $this->msg($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function data_report_action($data){
|
||||||
|
$all_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->whereTime('record_time','today')->field('jump_num,jump_time,jump_kcal')->select();
|
||||||
|
$last_data = Db::table($this->skip_db_name['skip'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc,id desc')->field('id,jump_num,jump_time,jump_kcal,record_time')->find();
|
||||||
|
$result = [
|
||||||
|
'today_jump_num'=>0,
|
||||||
|
'today_jump_time'=>0,
|
||||||
|
'today_jump_kcal'=>0,
|
||||||
|
];
|
||||||
|
foreach ($all_data as $key => $value) {
|
||||||
|
$result['today_jump_num'] = $result['today_jump_num']+$value['jump_num'];
|
||||||
|
$result['today_jump_time'] = $result['today_jump_time']+$value['jump_time'];
|
||||||
|
$result['today_jump_kcal'] = bcadd($result['today_jump_kcal'],$value['jump_kcal'],2);
|
||||||
|
}
|
||||||
|
if($last_data){
|
||||||
|
$result['last_jump_num'] = $last_data['jump_num'];
|
||||||
|
$result['last_jump_time'] = $last_data['jump_time'];
|
||||||
|
$result['last_jump_kcal'] = $last_data['jump_kcal'];
|
||||||
|
$result['last_record_time'] = $last_data['record_time'];
|
||||||
|
}else{
|
||||||
|
$result['last_jump_num'] = 0;
|
||||||
|
$result['last_jump_time'] = 0;
|
||||||
|
$result['last_jump_kcal'] = 0;
|
||||||
|
$result['last_record_time'] = '';
|
||||||
|
}
|
||||||
|
$time_conversion = $this->handle_hour_branch_second($result['today_jump_time']);
|
||||||
|
$result['today_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||||
|
$time_conversion = $this->handle_hour_branch_second($result['last_jump_time']);
|
||||||
|
$result['last_jump_time'] = $time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'];
|
||||||
|
return $this->msg($result);
|
||||||
|
}
|
||||||
|
// public function get_all_detaile_data_action($data){
|
||||||
|
|
||||||
|
// $result = $result = Db::table($this->skip_db_name['skip'])->where(['id'=>$data['id'],'is_del'=>0])->find();
|
||||||
|
// $for_data_arr = ['jump_num'=>['个数',''],'jump_time'=>['时长',''],'jump_kcal'=>['卡路里','kcal']];
|
||||||
|
// if($result){
|
||||||
|
// $result_data = [];
|
||||||
|
// foreach ($for_data_arr as $key => $value) {
|
||||||
|
// $temporary_arr['key_name'] = $key;
|
||||||
|
// $temporary_arr['name'] = $value[0];
|
||||||
|
// $temporary_arr['value'] = explode(',',$result[$key])[0];
|
||||||
|
// $temporary_arr['unit'] = $value[1];
|
||||||
|
// array_push($result_data,$temporary_arr);
|
||||||
|
// }
|
||||||
|
// return $this->msg($result_data);
|
||||||
|
// }else{
|
||||||
|
// return $this->msg(10002);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
// 跳绳卡路里计算
|
||||||
|
public function skip_kcal_calculate($num=143, $time=222, $weight=70) {
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 将时间从秒转换为分钟
|
||||||
|
$minutes = bcdiv($time,60,20);
|
||||||
|
// 计算每分钟的跳绳次数
|
||||||
|
$jumpsPerMinute = bcdiv($num,$minutes,2);
|
||||||
|
// 根据跳绳次数确定MET值
|
||||||
|
// $met = 11.8;
|
||||||
|
if ($jumpsPerMinute < 100) {
|
||||||
|
$met = 8.8;
|
||||||
|
} else if ($jumpsPerMinute >= 100 && $jumpsPerMinute < 120) {
|
||||||
|
$met = 11.8;
|
||||||
|
} else {
|
||||||
|
$met = 12.3;
|
||||||
|
}
|
||||||
|
// 计算每分钟燃烧的卡路里
|
||||||
|
$caloriesPerMinute = bcdiv(bcmul(bcmul($met,$weight,20),3.5,20),200,2);
|
||||||
|
// 计算总卡路里消耗
|
||||||
|
$totalCalories = bcmul($caloriesPerMinute,$minutes,2);
|
||||||
|
// 返回结果
|
||||||
|
return [
|
||||||
|
'averageAchievement' => $jumpsPerMinute,
|
||||||
|
'caloriesPerMinute' => $caloriesPerMinute,
|
||||||
|
'totalCalories' => $totalCalories
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
use AlibabaCloud\Client\AlibabaCloud;
|
use AlibabaCloud\Client\AlibabaCloud;
|
||||||
use AlibabaCloud\Client\Exception\ClientException;
|
use AlibabaCloud\Client\Exception\ClientException;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,286 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Cache;
|
||||||
|
|
||||||
|
class Vitalcapacity extends Base{
|
||||||
|
|
||||||
|
protected $vitalcapacity_db_name = [
|
||||||
|
'zhanghao'=>'app_account_number',
|
||||||
|
'juese'=>'app_user_data',
|
||||||
|
'vitalcapacity'=>'app_card_vitalcapacity_data',
|
||||||
|
'biaozhun'=>'pc_vitalcapacity_standard',
|
||||||
|
|
||||||
|
];
|
||||||
|
protected $color = ['无效'=>'#FF5656','不及格'=>'#FF5656','及格'=>'#FFAB00','良好'=>'#5AD06D','优秀'=>'#6492F6','牛逼'=>'#3967D6'];
|
||||||
|
protected $curve_data_format = ['one_val'=>['第一次','容积/ml','#009DFF'],'two_val'=>['第二次','容积/ml','#009DFF'],'three_val'=>['第三次','容积/ml','#009DFF'],'average_val'=>['平均','容积/ml','#009DFF']];
|
||||||
|
protected $pagesize = 15;
|
||||||
|
// 加 bcadd(,,20)
|
||||||
|
// 减 bcsub(,,20)
|
||||||
|
// 乘 bcmul(,,20)
|
||||||
|
// 除 bcdiv(,,20)
|
||||||
|
// 测试token=>'caadd1be045a65f30b92aa805f1de54a'
|
||||||
|
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
################################################################接口################################################################
|
||||||
|
|
||||||
|
// 设备记录
|
||||||
|
public function device_record(){
|
||||||
|
try {
|
||||||
|
$data = input('post.');
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('one', $data) || !array_key_exists('two', $data) || !array_key_exists('three', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['one'],'intnum')){
|
||||||
|
return $this->msg(10005,'one type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['two'],'intnum')){
|
||||||
|
return $this->msg(10005,'two type error');
|
||||||
|
}
|
||||||
|
if(!$this->verify_data_is_ok($data['three'],'intnum')){
|
||||||
|
return $this->msg(10005,'three type error');
|
||||||
|
}
|
||||||
|
$data['time'] = date('Y-m-d H:i:s');
|
||||||
|
return $this->manual_record_action($data,'by_device');
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 数据报告
|
||||||
|
public function data_report(){
|
||||||
|
$data = input('post.');
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||||
|
return $this->msg(10001);
|
||||||
|
}
|
||||||
|
unset($data['token']);
|
||||||
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||||
|
return $this->msg(10005,'aud_id type error');
|
||||||
|
}
|
||||||
|
return $this->data_report_action($data);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################action################################################################
|
||||||
|
################################################################action################################################################
|
||||||
|
public function manual_record_action($data,$type){
|
||||||
|
$temporary_arr['aud_id'] = $data['aud_id'];
|
||||||
|
$temporary_arr['record_time'] = $data['time'];
|
||||||
|
$temporary_arr['one'] = $data['one'];
|
||||||
|
$temporary_arr['two'] = $data['two'];
|
||||||
|
$temporary_arr['three'] = $data['three'];
|
||||||
|
$temporary_arr['average'] = bcdiv(bcadd(bcadd($data['one'],$data['two'],2),$data['three'],2),3,2);
|
||||||
|
$temporary_arr['create_time'] = date('Y-m-d H:i:s');
|
||||||
|
$temporary_arr['one_val'] = $data['one'];
|
||||||
|
$temporary_arr['two_val'] = $data['two'];
|
||||||
|
$temporary_arr['three_val'] = $data['three'];
|
||||||
|
$temporary_arr['average_val'] = $temporary_arr['average'];
|
||||||
|
$temporary_arr['flow_val'] = array_key_exists('flow', $data)?$data['flow']:'0.00';//流速
|
||||||
|
$temporary_arr['record_type'] = $type;
|
||||||
|
// die;
|
||||||
|
// 处理记录时间
|
||||||
|
|
||||||
|
$user_msg = Db::name($this->vitalcapacity_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,grade,gender,birthday')->find();
|
||||||
|
// die;
|
||||||
|
if($user_msg){
|
||||||
|
// 根据性别&年级&年龄查规则
|
||||||
|
if($user_msg['grade'] == 'nothing'){
|
||||||
|
// 计算年龄判断是属于哪个年级
|
||||||
|
$user_age = $this->calculate_age($user_msg['birthday']);
|
||||||
|
if($user_age <= 7){
|
||||||
|
$user_msg['grade'] = 'grade_s_1';
|
||||||
|
}else if($user_age == 8){
|
||||||
|
$user_msg['grade'] = 'grade_s_2';
|
||||||
|
}else if($user_age == 9){
|
||||||
|
$user_msg['grade'] = 'grade_s_3';
|
||||||
|
}else if($user_age == 10){
|
||||||
|
$user_msg['grade'] = 'grade_s_4';
|
||||||
|
}else if($user_age == 11){
|
||||||
|
$user_msg['grade'] = 'grade_s_5';
|
||||||
|
}else if($user_age == 12){
|
||||||
|
$user_msg['grade'] = 'grade_s_6';
|
||||||
|
}else if($user_age == 13){
|
||||||
|
$user_msg['grade'] = 'grade_m_1';
|
||||||
|
}else if($user_age == 14){
|
||||||
|
$user_msg['grade'] = 'grade_m_2';
|
||||||
|
}else if($user_age == 15){
|
||||||
|
$user_msg['grade'] = 'grade_m_3';
|
||||||
|
}else if($user_age == 16){
|
||||||
|
$user_msg['grade'] = 'grade_h_1';
|
||||||
|
}else if($user_age == 17){
|
||||||
|
$user_msg['grade'] = 'grade_h_2';
|
||||||
|
}else if($user_age == 18){
|
||||||
|
$user_msg['grade'] = 'grade_h_3';
|
||||||
|
}else if($user_age == 19 || $user_age == 20){
|
||||||
|
$user_msg['grade'] = 'grade_u_12';
|
||||||
|
}else if($user_age >= 21){
|
||||||
|
$user_msg['grade'] = 'grade_u_34';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql_str = "sex = ".$user_msg['gender']." and ".$user_msg['grade']." <= ".$temporary_arr['average_val'];
|
||||||
|
$user_achievement = Db::name($this->vitalcapacity_db_name['biaozhun'])->where($sql_str)->order($user_msg['grade'] .' desc')->field('level,score,'.$user_msg['grade'])->limit(1)->cache(86400)->select();
|
||||||
|
if(count($user_achievement)<=0){
|
||||||
|
$user_achievement[0] = ['level'=>'无效','score'=>'0'];
|
||||||
|
}
|
||||||
|
$temporary_arr['score'] = $user_achievement[0]['score'].','.$user_achievement[0]['level'].','.$this->color[$user_achievement[0]['level']];
|
||||||
|
$temporary_arr['score_val'] = $user_achievement[0]['score'];
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return $this->msg(10004,'未找到有效数据');
|
||||||
|
}
|
||||||
|
$standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
||||||
|
$temporary_arr['standard_data'] = json_encode($standard_data);
|
||||||
|
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->insert($temporary_arr);
|
||||||
|
|
||||||
|
if($result){
|
||||||
|
$time = $result[0]['record_time'];
|
||||||
|
$time = strtotime($time);
|
||||||
|
$time = date('Y年m月d日 H:i:s', $time);
|
||||||
|
return $this->msg([
|
||||||
|
'average'=>$temporary_arr['average'].'ml',
|
||||||
|
'level'=>$user_achievement[0]['level'],
|
||||||
|
'time'=>$time,
|
||||||
|
'flow_val'=>$temporary_arr['flow_val'],
|
||||||
|
'list'=>$standard_data,
|
||||||
|
'offset'=>$this->vitalcapacity_standard_interval($temporary_arr['average'],$standard_data)
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function data_report_action($data){
|
||||||
|
$result = Db::table($this->vitalcapacity_db_name['vitalcapacity'])->where(['aud_id'=>$data['aud_id']])->order('record_time desc')->field('record_time,score,average,flow_val,standard_data')->limit(1)->select();
|
||||||
|
|
||||||
|
if(count($result) <= 0){
|
||||||
|
// return $this->msg(10004);
|
||||||
|
return $this->msg([
|
||||||
|
'average'=>'',
|
||||||
|
'level'=>'',
|
||||||
|
'time'=>'',
|
||||||
|
'flow_val'=>'',
|
||||||
|
'list'=>'',
|
||||||
|
'offset'=>''
|
||||||
|
]);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$time = $result[0]['record_time'];
|
||||||
|
$time = strtotime($time);
|
||||||
|
$time = date('Y年m月d日 H:i:s', $time);
|
||||||
|
$o_l = explode(',',$result[0]['score']);
|
||||||
|
// $standard_data = $this->get_vitalcapacity_data($data['aud_id']);
|
||||||
|
$standard_data = json_decode($result[0]['standard_data'],true);
|
||||||
|
|
||||||
|
return $this->msg([
|
||||||
|
'average'=>$result[0]['average'].'ml',
|
||||||
|
'level'=>$o_l[1],
|
||||||
|
'time'=>$time,
|
||||||
|
'flow_val'=>$result[0]['flow_val'] == '.00'?'0.00':$result[0]['flow_val'],
|
||||||
|
'list'=>$standard_data,
|
||||||
|
'offset'=>$this->vitalcapacity_standard_interval($result[0]['average'],$standard_data)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
################################################################内部调用################################################################
|
||||||
|
// 肺活量判断区间
|
||||||
|
public function vitalcapacity_standard_interval($val,$data){
|
||||||
|
// 缓存一周
|
||||||
|
$result = '';
|
||||||
|
if(!$data || count($data) <= 0){
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
$temporary_qj = $data;
|
||||||
|
$max = 0;
|
||||||
|
$min = 0;
|
||||||
|
$num = 0;
|
||||||
|
foreach ($temporary_qj as $key => $value) {
|
||||||
|
if($val >= $value['min_val'] && $val <= $value['max_val']){
|
||||||
|
$max = $value['max_val'];
|
||||||
|
$min = $value['min_val'];
|
||||||
|
$num = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$num = count($temporary_qj)-1-$num;
|
||||||
|
|
||||||
|
if($max == 0){
|
||||||
|
if($val >= $temporary_qj[0]['max_val']){
|
||||||
|
$result = 100;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
|
||||||
|
$result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
// 肺活量判断区间(根据得分)
|
||||||
|
public function vitalcapacity_standard_interval2($val,$data){
|
||||||
|
// 缓存一周
|
||||||
|
$result = '';
|
||||||
|
if(count($data) <= 0){
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
$temporary_qj = $data;
|
||||||
|
$max = 0;
|
||||||
|
$min = 0;
|
||||||
|
$num = 0;
|
||||||
|
foreach ($temporary_qj as $key => $value) {
|
||||||
|
if($val >= $value['min_val'] && $val <= $value['max_val']){
|
||||||
|
$max = $value['max_val'];
|
||||||
|
$min = $value['min_val'];
|
||||||
|
$num = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 计算每份占比
|
||||||
|
$share_value = bcdiv($temporary_qj[0]['max_val'],count($temporary_qj),1);
|
||||||
|
// 计算在这一段中占多少
|
||||||
|
$result = bcsub($val,$min,1);
|
||||||
|
$result = bcdiv($result,bcsub($max,$min,1),1);
|
||||||
|
$num = count($temporary_qj)-1-$num;
|
||||||
|
$num = bcmul($num,$share_value,1);
|
||||||
|
$result = bcadd($num,$result,1);
|
||||||
|
// $num = count($temporary_qj)-1-$num;
|
||||||
|
// $temporary_num = bcmul(bcdiv(bcsub($val,$min,20),bcsub($max,$min,20),2),bcdiv(100,count($temporary_qj),2),2);
|
||||||
|
// $result = bcadd(bcmul(bcdiv(100,count($temporary_qj),2),$num,2),$temporary_num,2);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\NewReedaw\controller\app;
|
namespace app\NewReedaw2\controller\app;
|
||||||
|
|
||||||
class Wechat extends Base{
|
class Wechat extends Base{
|
||||||
// reedaw的小程序信息
|
// reedaw的小程序信息
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,398 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="format-detection" content="telephone=no, email=no">
|
||||||
|
<meta name="full-screen" content="true">
|
||||||
|
<meta name="screen-orientation" content="portrait">
|
||||||
|
<meta name="x5-fullscreen" content="true">
|
||||||
|
<meta name="360-fullscreen" content="true">
|
||||||
|
<title>商务合作</title>
|
||||||
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||||
|
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||||
|
<style>
|
||||||
|
*{
|
||||||
|
padding: 0 0;
|
||||||
|
margin: 0 0;
|
||||||
|
}
|
||||||
|
.big_box{
|
||||||
|
width: 100vw;
|
||||||
|
min-height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: url(/tsf/business_bg.jpg) no-repeat;
|
||||||
|
background-size: 100% 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
width: 85vw;
|
||||||
|
max-width: 880px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
border-radius: 1vw;
|
||||||
|
background-color: white;
|
||||||
|
margin: 24px 0;
|
||||||
|
overflow: hidden;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.content img{
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.content_c{
|
||||||
|
width: 100%;
|
||||||
|
padding: 2% 12%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.title_t{
|
||||||
|
border: none;
|
||||||
|
text-align: center;
|
||||||
|
color: rgba(8, 14, 23, 0.9);
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 28px;
|
||||||
|
line-height: 40px;
|
||||||
|
word-break: break-all;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow: visible;
|
||||||
|
margin: 4% 0;
|
||||||
|
}
|
||||||
|
.title_c2{
|
||||||
|
font-size: 12px;
|
||||||
|
margin-bottom: 10%;
|
||||||
|
}
|
||||||
|
.title_c2 span{
|
||||||
|
color: rgb(17, 106, 240);
|
||||||
|
}
|
||||||
|
.write_box{
|
||||||
|
width: 100%;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 10% 0;
|
||||||
|
}
|
||||||
|
.write_box_t{
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.write_box_r{
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
.write_k{
|
||||||
|
padding: 8px 12px;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid rgba(8, 14, 23, 0.24);
|
||||||
|
display: flex;
|
||||||
|
outline: 0 !important;
|
||||||
|
word-break: break-all;
|
||||||
|
margin: 2% 0;
|
||||||
|
}
|
||||||
|
.write_k textarea{
|
||||||
|
width: 100%;
|
||||||
|
resize: none;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
line-height: 22px;
|
||||||
|
border: none !important;
|
||||||
|
border-radius: 0;
|
||||||
|
background: transparent !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
outline: 0 !important;
|
||||||
|
cursor: auto;
|
||||||
|
padding: 0;
|
||||||
|
min-height: 22px;
|
||||||
|
margin: 0 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-select-write {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-select-write-tip {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #8E9095;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-select-write-tile {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-checkboxgroup {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-col {
|
||||||
|
flex: 1 1 48%; /* 两列布局 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ksapc-checkbox input {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
.ksapc-checkbox span{
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#onload{
|
||||||
|
width: 20vw;
|
||||||
|
height: 5vw;
|
||||||
|
min-width: 200px;
|
||||||
|
min-height: 45px;
|
||||||
|
background-color: #0A6CFF;
|
||||||
|
color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
line-height: 5vw;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 35px;
|
||||||
|
cursor: pointer; /* 添加小手图标 */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="box_k">
|
||||||
|
<div class="big_box">
|
||||||
|
<div class="content">
|
||||||
|
<img src="/tsf/business_title.jpg" alt="">
|
||||||
|
<div class="content_c">
|
||||||
|
<div class="title_t">商务合作意向登记表</div>
|
||||||
|
<div class="title_c2">
|
||||||
|
智能设备产品包<span>含身高测量仪、体重体脂秤、宠物秤, 母婴秤,厨房秤,商业秤,身高体重/体脂秤,八电极体脂秤,运动训练设备</span>等;软件包含就智能健康管理系统,智能硬件管理系统等,支持智能设备选购/定制、健康系统对接/定制,行业解决方案等,期待与您合作!
|
||||||
|
</div>
|
||||||
|
<div class="write_box">
|
||||||
|
<div class="write_box_t">
|
||||||
|
<span class="write_box_r">*</span> 1.客户姓名
|
||||||
|
</div>
|
||||||
|
<div class="write_k">
|
||||||
|
<textarea placeholder="请输入" rows="1" oninput="autoResize(this)" class="name-input"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="write_box">
|
||||||
|
<div class="write_box_t">
|
||||||
|
<span class="write_box_r">*</span> 2.联系电话
|
||||||
|
</div>
|
||||||
|
<div class="write_k">
|
||||||
|
<textarea placeholder="请输入手机号" rows="1" oninput="autoResize(this)" class="phone-input"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="write_box">
|
||||||
|
<div class="write_box_t">
|
||||||
|
<span class="write_box_r">*</span> 3.公司名称
|
||||||
|
</div>
|
||||||
|
<div class="write_k">
|
||||||
|
<textarea placeholder="请输入" rows="1" oninput="autoResize(this)" class="company-input"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="write_box">
|
||||||
|
<div class="write_box_t">
|
||||||
|
<span class="write_box_r">*</span> 4.合作意向
|
||||||
|
</div>
|
||||||
|
<div class="write_k" style="border: none;">
|
||||||
|
<div class="ksapc-select-write">
|
||||||
|
<div class="ksapc-select-write-tip" id="selectedCount">此题已选择 0/6 项</div>
|
||||||
|
<div class="ksapc-select-write-tile">
|
||||||
|
<div class="ksapc-checkboxgroup">
|
||||||
|
<div class="ksapc-row">
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="智能设备">
|
||||||
|
<span>智能设备</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="健康软件">
|
||||||
|
<span>健康软件</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="解决方案">
|
||||||
|
<span>解决方案</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="系统定制">
|
||||||
|
<span>系统定制</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="设备定制">
|
||||||
|
<span>设备定制</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="ksapc-col">
|
||||||
|
<label class="ksapc-checkbox">
|
||||||
|
<input type="checkbox" class="option-checkbox" value="其它">
|
||||||
|
<span>其它</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="write_box">
|
||||||
|
<div class="write_box_t">
|
||||||
|
<span class="write_box_r">*</span> 5.备注
|
||||||
|
</div>
|
||||||
|
<div class="write_k">
|
||||||
|
<textarea placeholder="请输入" rows="1" oninput="autoResize(this)" class="remark-input"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="write_box" style="color: #8E9095;">
|
||||||
|
商务合作电话/微信:13590959084
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="onload">提交</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var selectedValues = [];
|
||||||
|
function autoResize(textarea) {
|
||||||
|
textarea.style.height = 'auto'; // 重置高度
|
||||||
|
textarea.style.height = textarea.scrollHeight + 'px'; // 设置为内容高度
|
||||||
|
}
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// 获取 #onload 元素
|
||||||
|
const onloadElement = document.getElementById('onload');
|
||||||
|
|
||||||
|
// 计算 #onload 元素的高度
|
||||||
|
const height = onloadElement.offsetHeight;
|
||||||
|
|
||||||
|
// 设置 #onload 元素的行高与高度一致
|
||||||
|
onloadElement.style.lineHeight = height + 'px';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const checkboxes = document.querySelectorAll('.option-checkbox');
|
||||||
|
const selectedCountElement = document.getElementById('selectedCount');
|
||||||
|
let selectedCount = 0;
|
||||||
|
|
||||||
|
function updateSelectedCount() {
|
||||||
|
selectedCount = 0;
|
||||||
|
selectedValues = [];
|
||||||
|
checkboxes.forEach(checkbox => {
|
||||||
|
if (checkbox.checked) {
|
||||||
|
selectedCount++;
|
||||||
|
selectedValues.push(checkbox.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
selectedCountElement.textContent = `此题已选择 ${selectedCount}/6 项`;
|
||||||
|
console.log('Selected Values:', selectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkboxes.forEach(checkbox => {
|
||||||
|
checkbox.addEventListener('change', updateSelectedCount);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#onload').on('click', function() {
|
||||||
|
|
||||||
|
// 获取所有需要检查的输入字段
|
||||||
|
const nameInput = document.querySelector('.name-input');
|
||||||
|
const phoneInput = document.querySelector('.phone-input');
|
||||||
|
const companyInput = document.querySelector('.company-input');
|
||||||
|
const remarkInput = document.querySelector('.remark-input');
|
||||||
|
|
||||||
|
// 检查每个字段是否为空
|
||||||
|
let hasError = false;
|
||||||
|
let errorMessage = '';
|
||||||
|
|
||||||
|
if (!nameInput || nameInput.value.trim() === '') {
|
||||||
|
hasError = true;
|
||||||
|
errorMessage += '1. 客户姓名\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!phoneInput || phoneInput.value.trim() === '') {
|
||||||
|
hasError = true;
|
||||||
|
errorMessage += '2. 联系电话\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!companyInput || companyInput.value.trim() === '') {
|
||||||
|
hasError = true;
|
||||||
|
errorMessage += '3. 公司名称\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedCount === 0) {
|
||||||
|
hasError = true;
|
||||||
|
errorMessage += '4. 合作意向\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!remarkInput || remarkInput.value.trim() === '') {
|
||||||
|
hasError = true;
|
||||||
|
errorMessage += '5. 备注\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
|
||||||
|
layer.msg('以下项目未填写或未选择:\n' + errorMessage, {icon: 2});
|
||||||
|
// alert('以下项目未填写或未选择:\n' + errorMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var index = layer.load(1, {
|
||||||
|
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||||
|
});
|
||||||
|
|
||||||
|
// 如果所有字段都填写了,执行提交操作
|
||||||
|
$.ajax({
|
||||||
|
url: "business_cooperation_action", // 请求的url地址
|
||||||
|
dataType: "json", // 返回格式为json
|
||||||
|
async: true, // 请求是否异步,默认为异步,这也是ajax重要特性
|
||||||
|
data: {
|
||||||
|
"name": nameInput.value,
|
||||||
|
"phone": phoneInput.value,
|
||||||
|
"company": companyInput.value,
|
||||||
|
"selectedValues": selectedValues,
|
||||||
|
"remark": remarkInput.value
|
||||||
|
},
|
||||||
|
type: "POST", // 请求方式
|
||||||
|
success: function(req) {
|
||||||
|
layer.close(layer.index)
|
||||||
|
// 请求成功时处理
|
||||||
|
if(req.code == 0){
|
||||||
|
layer.msg(req.msg, {icon: 1});
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 2000);
|
||||||
|
}else{
|
||||||
|
layer.msg(req.msg, {icon: 2});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.close(layer.index)
|
||||||
|
// 请求出错处理
|
||||||
|
layer.msg('网络错误了,请直接联系商务合作电话/微信:13590959084', {icon: 2});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="format-detection" content="telephone=no, email=no">
|
||||||
|
<meta name="full-screen" content="true">
|
||||||
|
<meta name="screen-orientation" content="portrait">
|
||||||
|
<meta name="x5-fullscreen" content="true">
|
||||||
|
<meta name="360-fullscreen" content="true">
|
||||||
|
<title>隐私协议</title>
|
||||||
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<style>
|
||||||
|
*{
|
||||||
|
padding: 0 0;
|
||||||
|
margin: 0 0;
|
||||||
|
}
|
||||||
|
.big_box{
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 10vw;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.title{
|
||||||
|
width: 100%;
|
||||||
|
height: 10vw;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 7vw;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 6vw;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.font_1{
|
||||||
|
font-size: 4.5vw;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.font_2{
|
||||||
|
font-size: 3.5vw;
|
||||||
|
margin: 3vw 0;
|
||||||
|
}
|
||||||
|
.fint_w{
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 5vw;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="box_k">
|
||||||
|
<div class="big_box">
|
||||||
|
<div class="title">Reedaw隐私协议</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="font_1">一、前言</div>
|
||||||
|
<div class="font_2">感谢您选择使用我们的Reedaw体重饮食可视化管理APP(以下简称“本应用”)。我们深知您的个人信息安全至关重要,在您使用本应用后我们郑重承诺,将严格遵守相关法律法规,采取合理有效的措施保护您的个人隐私。本隐私协议旨在明确我们在采集、使用、存储、共享及保护您的个人信息的责任、义务。请您在使用本应用前,仔细阅读并理解本协议内容,一旦您开始使用本应用,即视为您同意我们使用您的个人信息,接受本协议的全部条款。</div>
|
||||||
|
<div class="font_1">二、信息收集</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.必要信息:</span>为了提供基本服务,我们可能会采集您的基本信息,包括但不限于邮箱、姓名(可选择匿名使用)等。这些信息将用于验证您的身份、保障账号安全及提供个性化服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.健康数据:</span>在使用本应用进行身体数据健康评估时,我们会采集您的饮食、身高、体重等健康数据。这些数据将用于生成评估报告,并尽量提供相应的健康建议。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.设备信息:</span>为了优化服务体验,我们可能会采集您的设备型号、操作系统版本、IP地址等必要的技术信息。这些信息将帮助我们了解用户的使用环境,以便进行技术调试和服务改进。</div>
|
||||||
|
<div class="font_1">三、信息使用</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.服务提供:</span>我们将根据您提供的信息,为您提供饮食数据评估服务,并生成相应的评估报告。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.个性化推荐:</span>基于您的饮食数据和使用习惯,我们可能会向您推荐适合的饮食管理方案。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.数据分析:</span>我们会对收集到的数据进行匿名化处理,用于统计分析,以改进我们的产品和服务。这些统计数据将不包含任何可以识别您个人身份的信息。</div>
|
||||||
|
<div class="font_1">四、信息共享与披露</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.内部共享:</span>我们可能会将您的信息共享给公司内部负责处理您个人信息的部门或人员,以确保为您提供更好的服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.第三方合作:</span>在必要且合法的情况下,我们可能会与第三方服务提供商(如云服务提供商、数据分析公司等)共享您的个人信息,以便他们为我们提供技术支持或数据分析服务。我们将与这些第三方签订严格的保密协议,并要求他们遵守相关法律法规和本协议的规定。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.法律要求:</span>在法律法规要求或政府部门、司法机关要求的情况下,我们可能会依法披露您的个人信息。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">4.其他</span>4.其他对您的服务性应用。</div>
|
||||||
|
<div class="font_1">五、信息安全</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.技术保障:</span>我们将采取合理的技术手段和管理措施,确保您的个人信息在采集、存储、使用、共享等过程中的安全。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.数据加密:</span>对于敏感信息,我们将采用加密技术进行处理,防止数据在传输和存储过程中被非法访问或泄露。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.访问控制:</span>我们将对访问个人信息的员工进行严格的权限管理,确保只有授权人员才能访问相关信息。</div>
|
||||||
|
<div class="font_1">六、用户权利</div>
|
||||||
|
<div class="font_2"><span class="fint_w">1.知情权:</span>您有权了解我们采集、使用、共享及保护您个人信息的详细情况。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">2.选择权:</span>您有权选择是否向我们提供个人信息的具体内容,以及选择是否接受我们的个性化推荐服务。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">3.更正权:</span>如果您发现我们采集的个人信息有误,您有权要求我们及时更正。</div>
|
||||||
|
<div class="font_2"><span class="fint_w">4.屏蔽权:</span>在符合法律法规要求的情况下,您有权要求我们屏蔽您的个人信息全部内容。</div>
|
||||||
|
<div class="font_1">七、协议变更</div>
|
||||||
|
<div class="font_2">我们有权根据法律法规的变化或业务发展的需要,对本隐私协议进行修订。修订后的协议将通过本应用内通知或其他适当方式告知您。请您定期查阅本隐私协议,以便及时了解我们的最新政策。</div>
|
||||||
|
<div class="font_1">八、争议解决</div>
|
||||||
|
<div class="font_2">如因本协议产生任何争议,双方应首先通过友好协商解决;协商不成的,任何一方均有权向本应用运营方所在地的法院提起诉讼。</div>
|
||||||
|
<div class="font_1">九、生效与终止</div>
|
||||||
|
<div class="font_2">本协议自您同意并接受之日起生效,并持续有效至您注销账号或本应用终止服务时止。</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
<meta name="360-fullscreen" content="true">
|
<meta name="360-fullscreen" content="true">
|
||||||
<title>下载页面</title>
|
<title>下载页面</title>
|
||||||
<script src="/x_admin/js/jq.js"></script>
|
<script src="/x_admin/js/jq.js"></script>
|
||||||
|
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||||
<style>
|
<style>
|
||||||
*{
|
*{
|
||||||
padding: 0 0;
|
padding: 0 0;
|
||||||
|
|
@ -171,7 +172,7 @@
|
||||||
|
|
||||||
function jump(){
|
function jump(){
|
||||||
// window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
|
// window.location.href = 'weixin://dl/business/?appid=wx3e50e84030fe0d1e&path=pages/index/index';
|
||||||
window.location.href = 'weixin://dl/business/?appid=wx9c0b7a436ada6d1e&path=pages/home/home';
|
window.location.href = 'weixin://dl/business/?appid=wx9c0b7a436ada6d1e&path=pages/index/index';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ class Qrcode extends Base{
|
||||||
|
|
||||||
// 小贴士视频上传管理页面
|
// 小贴士视频上传管理页面
|
||||||
public function little_tips_project_set_page(){
|
public function little_tips_project_set_page(){
|
||||||
|
// phpinfo();
|
||||||
|
// die;
|
||||||
$qrcode_db = Db::connect('qrcode_db');
|
$qrcode_db = Db::connect('qrcode_db');
|
||||||
$temporary_data = $qrcode_db->table('little_tips_data')
|
$temporary_data = $qrcode_db->table('little_tips_data')
|
||||||
->alias('a')
|
->alias('a')
|
||||||
|
|
@ -135,7 +137,7 @@ class Qrcode extends Base{
|
||||||
$pathinfo_video = pathinfo($name_video);
|
$pathinfo_video = pathinfo($name_video);
|
||||||
$extension_video = strtolower($pathinfo_video['extension']); // 转换为小写以进行不区分大小写的比较
|
$extension_video = strtolower($pathinfo_video['extension']); // 转换为小写以进行不区分大小写的比较
|
||||||
$new_filename_video = 'pic_'.time().$this->generateRandomString(). '.' . $extension_video;
|
$new_filename_video = 'pic_'.time().$this->generateRandomString(). '.' . $extension_video;
|
||||||
$info_video = $video->validate(['size'=>1024*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
|
$info_video = $video->validate(['size'=>500*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
|
||||||
if(!$info_video){
|
if(!$info_video){
|
||||||
// 上传失败获取错误信息
|
// 上传失败获取错误信息
|
||||||
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $new_filename_pic);
|
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $new_filename_pic);
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@
|
||||||
|
|
||||||
<div><span>设备图片:</span><button onclick="change_action_pic()">选择图片</button><span style="font-size: 12px;color: red;">请不要上传超过10M的图片</span></div></br>
|
<div><span>设备图片:</span><button onclick="change_action_pic()">选择图片</button><span style="font-size: 12px;color: red;">请不要上传超过10M的图片</span></div></br>
|
||||||
<div><span>图片预览:</span><img id="show_pic" src="" alt=""></div></br>
|
<div><span>图片预览:</span><img id="show_pic" src="" alt=""></div></br>
|
||||||
<div><span>设备视频:</span><button onclick="change_action_video()">选择视频</button><span style="font-size: 12px;color: red;">请不要上传超过1G的视频,大于1G的视频概率会导致提交失败</span></div></br>
|
<div><span>设备视频:</span><button onclick="change_action_video()">选择视频</button><span style="font-size: 12px;color: red;">请不要上传超过500M的视频,大于500M的视频概率会导致提交失败</span></div></br>
|
||||||
<div><span>视频名称:</span><span id="show_video"></span></div></br>
|
<div><span>视频名称:</span><span id="show_video"></span></div></br>
|
||||||
<div>
|
<div>
|
||||||
<span>设备分类:</span>
|
<span>设备分类:</span>
|
||||||
|
|
@ -433,6 +433,9 @@
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
async: true, // 请求是否异步,默认为异步
|
async: true, // 请求是否异步,默认为异步
|
||||||
|
// ==========修改开始:添加timeout=0防止大文件上传超时==========
|
||||||
|
timeout: 0, // 设置为0表示永不超时,解决大文件上传超时问题
|
||||||
|
// ==========修改结束==========
|
||||||
data: formdata, // 表单数据
|
data: formdata, // 表单数据
|
||||||
type: "POST", // 请求方式
|
type: "POST", // 请求方式
|
||||||
xhr: function () {
|
xhr: function () {
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ Route::any('/kitchenscale2/food_count_kcal', 'app/kitchenscale2/app.cookbook/foo
|
||||||
// 获取当前食材重量卡路里
|
// 获取当前食材重量卡路里
|
||||||
Route::any('/kitchenscale/find_food', 'app/kitchenscale/app.cookbook/find_food');
|
Route::any('/kitchenscale/find_food', 'app/kitchenscale/app.cookbook/find_food');
|
||||||
Route::any('/kitchenscale2/find_food', 'app/kitchenscale2/app.cookbook/find_food');
|
Route::any('/kitchenscale2/find_food', 'app/kitchenscale2/app.cookbook/find_food');
|
||||||
// 获取当前食材重量卡路里
|
// 查询食材信息
|
||||||
Route::any('/kitchenscale/get_food_list', 'app/kitchenscale/app.cookbook/get_food_list');
|
Route::any('/kitchenscale/get_food_list', 'app/kitchenscale/app.cookbook/get_food_list');
|
||||||
Route::any('/kitchenscale2/get_food_list', 'app/kitchenscale2/app.cookbook/get_food_list');
|
Route::any('/kitchenscale2/get_food_list', 'app/kitchenscale2/app.cookbook/get_food_list');
|
||||||
// 获取所有食谱label
|
// 获取所有食谱label
|
||||||
|
|
@ -849,6 +849,12 @@ Route::any('/de/check_device_msg', 'app/DeviceEnter/Appinterface/check_device_ms
|
||||||
#############################################################################################################################################################
|
#############################################################################################################################################################
|
||||||
|
|
||||||
################################################################接口(API)################################################################
|
################################################################接口(API)################################################################
|
||||||
|
|
||||||
|
|
||||||
|
// 检测版本及判断是否登录失效
|
||||||
|
Route::any('/reedaw/ceshiyong', 'app/NewReedaw/app.base/ceshiyong');
|
||||||
|
|
||||||
|
|
||||||
################################################################登录注册部分(OK)
|
################################################################登录注册部分(OK)
|
||||||
// 检测版本及判断是否登录失效
|
// 检测版本及判断是否登录失效
|
||||||
Route::any('/reedaw/login_invalid_version', 'app/NewReedaw/app.index/login_invalid_version');
|
Route::any('/reedaw/login_invalid_version', 'app/NewReedaw/app.index/login_invalid_version');
|
||||||
|
|
@ -936,6 +942,9 @@ Route::any('/reedaw/set_up_content', 'app/NewReedaw/app.Kitchenscale/set_up_cont
|
||||||
// 本次添加食材的营养统计
|
// 本次添加食材的营养统计
|
||||||
Route::any('/reedaw/current_food_statistics', 'app/NewReedaw/app.Kitchenscale/current_food_statistics');
|
Route::any('/reedaw/current_food_statistics', 'app/NewReedaw/app.Kitchenscale/current_food_statistics');
|
||||||
|
|
||||||
|
// 查询条形码数据信息
|
||||||
|
Route::any('/reedaw/search_food_barcode', 'app/kitchenscale2/app.barcode/search_food_barcode');
|
||||||
|
|
||||||
################################################################首页(健康工具)
|
################################################################首页(健康工具)
|
||||||
// 卡片列表
|
// 卡片列表
|
||||||
Route::any('/reedaw/card_list_all', 'app/NewReedaw/app.Card/card_list_all');
|
Route::any('/reedaw/card_list_all', 'app/NewReedaw/app.Card/card_list_all');
|
||||||
|
|
@ -1008,89 +1017,190 @@ Route::any('/reedaw/set_my_account_msg', 'app/NewReedaw/app.role/set_my_account_
|
||||||
Route::any('/reedaw/business_cooperation', 'app/NewReedaw/app.business/business_cooperation');
|
Route::any('/reedaw/business_cooperation', 'app/NewReedaw/app.business/business_cooperation');
|
||||||
// 商务合作提交
|
// 商务合作提交
|
||||||
Route::any('/reedaw/business_cooperation_action', 'app/NewReedaw/app.business/business_cooperation_action');
|
Route::any('/reedaw/business_cooperation_action', 'app/NewReedaw/app.business/business_cooperation_action');
|
||||||
|
// 隐私协议
|
||||||
|
Route::any('/reedaw/privacy_policy', 'app/NewReedaw/app.index/privacy_policy');
|
||||||
|
|
||||||
// https://tc.pcxbc.comreedaw/pdate_my_nickname
|
// https://tc.pcxbc.comreedaw/pdate_my_nickname
|
||||||
|
|
||||||
|
################################################################下面是新版reedaw(体侧+厨房秤)(多语言版本)################################################################
|
||||||
|
########################################################################################################################################################################
|
||||||
|
|
||||||
|
################################################################接口(API)################################################################
|
||||||
|
|
||||||
|
|
||||||
|
// 检测版本及判断是否登录失效
|
||||||
|
Route::any('/reedaw2/ceshiyong', 'app/NewReedaw/app.base/ceshiyong');
|
||||||
|
|
||||||
|
|
||||||
|
################################################################登录注册部分(OK)
|
||||||
|
// 检测版本及判断是否登录失效
|
||||||
|
Route::any('/reedaw2/login_invalid_version', 'app/NewReedaw/app.index/login_invalid_version');
|
||||||
|
|
||||||
|
// 注册账号
|
||||||
|
Route::any('/reedaw2/register', 'app/NewReedaw/app.login/register');
|
||||||
|
// 登录账号
|
||||||
|
Route::any('/reedaw2/login', 'app/NewReedaw/app.login/login');
|
||||||
|
// 重置密码
|
||||||
|
Route::any('/reedaw2/reset_password', 'app/NewReedaw/app.login/reset_password');
|
||||||
|
// 微信快捷登录
|
||||||
|
Route::any('/reedaw2/wechat_quick_login', 'app/NewReedaw/app.login/wechat_quick_login');
|
||||||
|
// 退出登录
|
||||||
|
Route::any('/reedaw2/quit_account', 'app/NewReedaw/app.login/quit_account');
|
||||||
|
// 账号注销
|
||||||
|
Route::any('/reedaw2/delete_account', 'app/NewReedaw/app.login/delete_account');
|
||||||
|
// 发送验证码
|
||||||
|
Route::any('/reedaw2/send_phone_email_code', 'app/NewReedaw/app.login/send_phone_email_code');
|
||||||
|
|
||||||
|
################################################################首页(其他)
|
||||||
|
// 默认配置
|
||||||
|
Route::any('/reedaw2/config', 'app/NewReedaw/app.index/config');
|
||||||
|
// 获取角色列表
|
||||||
|
Route::any('/reedaw2/get_user_list', 'app/NewReedaw/app.index/get_user_list');
|
||||||
|
|
||||||
|
################################################################首页(身体数据)
|
||||||
|
// 角色报告(简要)
|
||||||
|
Route::any('/reedaw2/body_report_brief', 'app/NewReedaw/app.Userbody/body_report_brief');
|
||||||
|
// 角色报告(详细)
|
||||||
|
Route::any('/reedaw2/body_report_detailed', 'app/NewReedaw/app.Userbody/body_report_detailed');
|
||||||
|
// 角色报告(深度)
|
||||||
|
Route::any('/reedaw2/body_report_depth', 'app/NewReedaw/app.Userbody/body_report_depth');
|
||||||
|
// 手动记录
|
||||||
|
Route::any('/reedaw2/manual_record', 'app/NewReedaw/app.Userbody/manual_record');
|
||||||
|
// 设备记录
|
||||||
|
Route::any('/reedaw2/device_record', 'app/NewReedaw/app.Userbody/device_record');
|
||||||
|
// 修改目标体重
|
||||||
|
Route::any('/reedaw2/set_target_weight', 'app/NewReedaw/app.Userbody/set_target_weight');
|
||||||
|
// 修改初始体重
|
||||||
|
Route::any('/reedaw2/set_initial_weight', 'app/NewReedaw/app.Userbody/set_initial_weight');
|
||||||
|
// 历史数据(分页)
|
||||||
|
Route::any('/reedaw2/history_list_page', 'app/NewReedaw/app.Userbody/history_list_page');
|
||||||
|
// 历史详情
|
||||||
|
Route::any('/reedaw2/history_detailed', 'app/NewReedaw/app.Userbody/history_detailed');
|
||||||
|
// 删除历史数据
|
||||||
|
Route::any('/reedaw2/history_del', 'app/NewReedaw/app.Userbody/history_del');
|
||||||
|
// 曲线详情
|
||||||
|
Route::any('/reedaw2/curve_detailed', 'app/NewReedaw/app.Userbody/curve_detailed');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################首页(饮食数据)
|
||||||
|
// 根据用户获取他的饮食信息
|
||||||
|
// Route::any('/reedaw2/user_diet_content', 'app/NewReedaw/app.Kitchenscale/user_diet_content');
|
||||||
|
// 获取记食器板块内容
|
||||||
|
Route::any('/reedaw2/get_countfoot_content', 'app/NewReedaw/app.Kitchenscale/get_countfoot_content');
|
||||||
|
// 修改角色信息
|
||||||
|
Route::any('/reedaw2/update_user_msg', 'app/NewReedaw/app.Kitchenscale/update_user_msg');
|
||||||
|
// 搜索页面的默认信息数据
|
||||||
|
Route::any('/reedaw2/search_default_msg', 'app/NewReedaw/app.Kitchenscale/search_default_msg');
|
||||||
|
// 搜索食材列表
|
||||||
|
Route::any('/reedaw2/get_food_list', 'app/NewReedaw/app.Kitchenscale/get_food_list');
|
||||||
|
// 搜索食材列表
|
||||||
|
Route::any('/reedaw2/search_column', 'app/NewReedaw/app.Kitchenscale/search_column');
|
||||||
|
// 查询食谱的详情
|
||||||
|
Route::any('/reedaw2/cookbook_details', 'app/NewReedaw/app.Kitchenscale/cookbook_details');
|
||||||
|
// 点赞收藏菜谱
|
||||||
|
Route::any('/reedaw2/cookbook_like', 'app/NewReedaw/app.Kitchenscale/cookbook_like');
|
||||||
|
// 点赞收藏菜谱
|
||||||
|
Route::any('/reedaw2/add_intake_food', 'app/NewReedaw/app.Kitchenscale/add_intake_food');
|
||||||
|
// 获取记食器饮食记录
|
||||||
|
Route::any('/reedaw2/get_log_list', 'app/NewReedaw/app.Kitchenscale/get_log_list');
|
||||||
|
// 设置角色营养比例
|
||||||
|
Route::any('/reedaw2/set_user_kcal', 'app/NewReedaw/app.Kitchenscale/set_nutrition_proportion');
|
||||||
|
// 删除一条指定的饮食记录
|
||||||
|
Route::any('/reedaw2/del_user_eat_log', 'app/NewReedaw/app.Kitchenscale/del_user_eat_log');
|
||||||
|
// 搜索历史删除
|
||||||
|
Route::any('/reedaw2/del_search_history', 'app/NewReedaw/app.Kitchenscale/del_search_history');
|
||||||
|
// 设置角色营养比例
|
||||||
|
Route::any('/reedaw2/del_user_eat_list_log', 'app/NewReedaw/app.Kitchenscale/del_user_eat_list_log');
|
||||||
|
// 我的收藏
|
||||||
|
Route::any('/reedaw2/get_user_collect_list', 'app/NewReedaw/app.Kitchenscale/get_user_collect_list');
|
||||||
|
// 设置营养占比页面数据
|
||||||
|
Route::any('/reedaw2/set_up_content', 'app/NewReedaw/app.Kitchenscale/set_up_content');
|
||||||
|
// 本次添加食材的营养统计
|
||||||
|
Route::any('/reedaw2/current_food_statistics', 'app/NewReedaw/app.Kitchenscale/current_food_statistics');
|
||||||
|
|
||||||
|
// 查询条形码数据信息
|
||||||
|
Route::any('/reedaw2/search_food_barcode', 'app/kitchenscale2/app.barcode/search_food_barcode');
|
||||||
|
|
||||||
|
################################################################首页(健康工具)
|
||||||
|
// 卡片列表
|
||||||
|
Route::any('/reedaw2/card_list_all', 'app/NewReedaw/app.Card/card_list_all');
|
||||||
|
// 保存用户所选的卡片列表
|
||||||
|
Route::any('/reedaw2/save_card_list', 'app/NewReedaw/app.Card/save_card_list');
|
||||||
|
// // BMI评测
|
||||||
|
Route::any('/reedaw2/bmi_evaluation', 'app/NewReedaw/app.Card/bmi_evaluation');
|
||||||
// ################################################################接口(管理后台)
|
|
||||||
|
|
||||||
// // // 默认配置
|
|
||||||
// // Route::any('/reedaw/config', 'app/NewReedaw/app.index/config');
|
|
||||||
// // 通用数据对比
|
|
||||||
// Route::any('/reedaw/all_data_contrast', 'app/NewReedaw/app.index/all_data_contrast');
|
|
||||||
|
|
||||||
// ################################################################金刚区部分
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ################################################################首页金刚区部分
|
|
||||||
// // 遗传身高
|
// // 遗传身高
|
||||||
// Route::any('/reedaw/genetic_height', 'app/NewReedaw/app.index/genetic_height');
|
Route::any('/reedaw2/genetic_height', 'app/NewReedaw/app.Card/genetic_height');
|
||||||
// // BMI测评
|
// 获取手动记录内容
|
||||||
// Route::any('/reedaw/bmi_evaluation', 'app/NewReedaw/app.index/bmi_evaluation');
|
Route::any('/reedaw2/obtain_manual_record_content', 'app/NewReedaw/app.Card/obtain_manual_record_content');
|
||||||
|
|
||||||
|
|
||||||
|
// ###############################跳绳&肺活通用部分
|
||||||
|
// 手动记录
|
||||||
|
Route::any('/reedaw2/card/manual_record', 'app/NewReedaw/app.card/manual_record');
|
||||||
|
// 曲线
|
||||||
|
Route::any('/reedaw2/card/curve_chart', 'app/NewReedaw/app.card/curve_chart');
|
||||||
|
// 数据对比列表(分组)
|
||||||
|
Route::any('/reedaw2/card/record_list_group', 'app/NewReedaw/app.card/record_list_group');
|
||||||
|
// 数据对比详情
|
||||||
|
Route::any('/reedaw2/card/data_compare', 'app/NewReedaw/app.card/data_compare');
|
||||||
|
// 历史记录(分页)
|
||||||
|
Route::any('/reedaw2/card/record_list_page', 'app/NewReedaw/app.card/record_list_page');
|
||||||
|
// 删除历史记录
|
||||||
|
Route::any('/reedaw2/card/del_record', 'app/NewReedaw/app.card/del_record');
|
||||||
|
// 历史记录(详细)
|
||||||
|
Route::any('/reedaw2/card/detailed_record', 'app/NewReedaw/app.card/detailed_record');
|
||||||
|
|
||||||
|
// ###############################跳绳部分
|
||||||
|
// 设备记录
|
||||||
|
Route::any('/reedaw2/skip/device_record', 'app/NewReedaw/app.skip/device_record');
|
||||||
|
// 上一次数据
|
||||||
|
Route::any('/reedaw2/skip/data_report', 'app/NewReedaw/app.skip/data_report');
|
||||||
|
// ###############################肺活部分
|
||||||
|
// 设备记录
|
||||||
|
Route::any('/reedaw2/vitalcapacity/device_record', 'app/NewReedaw/app.vitalcapacity/device_record');
|
||||||
|
// 上一次数据
|
||||||
|
Route::any('/reedaw2/vitalcapacity/data_report', 'app/NewReedaw/app.vitalcapacity/data_report');
|
||||||
|
// ###############################体侧部分
|
||||||
|
// 获取地区标准
|
||||||
|
Route::any('/reedaw2/sportstesting/sportstesting_get_region_list', 'app/NewReedaw/app.sportstesting/sportstesting_get_region_list');
|
||||||
|
// 计算获取结果
|
||||||
|
Route::any('/reedaw2/sportstesting/sportstesting_set_once_data', 'app/NewReedaw/app.sportstesting/sportstesting_set_once_data');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################################我的
|
||||||
|
// 创建角色
|
||||||
|
Route::any('/reedaw2/add_member', 'app/NewReedaw/app.role/add_member');
|
||||||
|
// 更新角色
|
||||||
|
Route::any('/reedaw2/update_member', 'app/NewReedaw/app.role/update_member');
|
||||||
|
// 删除角色
|
||||||
|
Route::any('/reedaw2/del_member', 'app/NewReedaw/app.role/del_member');
|
||||||
|
// 获取指定角色详细信息(含厨房秤的当日信息)
|
||||||
|
Route::any('/reedaw2/get_user_data_information', 'app/NewReedaw/app.role/get_user_data_information');
|
||||||
|
// 修改账号昵称
|
||||||
|
Route::any('/reedaw2/update_my_nickname', 'app/NewReedaw/app.role/update_my_nickname');
|
||||||
|
// 获取账号信息
|
||||||
|
Route::any('/reedaw2/get_my_account_msg', 'app/NewReedaw/app.role/get_my_account_msg');
|
||||||
|
// 邮箱/手机绑定
|
||||||
|
Route::any('/reedaw2/update_my_account_msg', 'app/NewReedaw/app.role/update_my_account_msg');
|
||||||
|
// 修改密码
|
||||||
|
Route::any('/reedaw2/update_my_password', 'app/NewReedaw/app.role/update_my_password');
|
||||||
|
// 修改账号信息
|
||||||
|
Route::any('/reedaw2/set_my_account_msg', 'app/NewReedaw/app.role/set_my_account_msg');
|
||||||
|
// 商务合作页面
|
||||||
|
Route::any('/reedaw2/business_cooperation', 'app/NewReedaw/app.business/business_cooperation');
|
||||||
|
// 商务合作提交
|
||||||
|
Route::any('/reedaw2/business_cooperation_action', 'app/NewReedaw/app.business/business_cooperation_action');
|
||||||
|
// 隐私协议
|
||||||
|
Route::any('/reedaw2/privacy_policy', 'app/NewReedaw/app.index/privacy_policy');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ################################################################角色部分
|
|
||||||
|
|
||||||
|
|
||||||
// // 获取角色列表
|
|
||||||
// Route::any('/reedaw/role_list', 'app/NewReedaw/app.role/role_list');
|
|
||||||
// ################################################################卡片部分
|
|
||||||
// // 卡片列表
|
|
||||||
// Route::any('/reedaw/card/card_list_msg', 'app/NewReedaw/app.card/card_list_msg');
|
|
||||||
// // 用户卡片排序
|
|
||||||
// Route::any('/reedaw/card/card_user_order', 'app/NewReedaw/app.card/card_user_order');
|
|
||||||
// ################################################################身体报告部分
|
|
||||||
// // 获取角色报告
|
|
||||||
// Route::any('/reedaw/body/body_report', 'app/NewReedaw/app.body/body_report');
|
|
||||||
// // 手动记录
|
|
||||||
// Route::any('/reedaw/body/manual_record', 'app/NewReedaw/app.body/manual_record');
|
|
||||||
// // 设备记录
|
|
||||||
// Route::any('/reedaw/body/device_record', 'app/NewReedaw/app.body/device_record');
|
|
||||||
// // 历史记录(分页)
|
|
||||||
// Route::any('/reedaw/body/record_list_page', 'app/NewReedaw/app.body/record_list_page');
|
|
||||||
// // 历史记录(分组)
|
|
||||||
// Route::any('/reedaw/body/record_list_group', 'app/NewReedaw/app.body/record_list_group');
|
|
||||||
// // 历史记录(详细)
|
|
||||||
// Route::any('/reedaw/body/detailed_record', 'app/NewReedaw/app.body/detailed_record');
|
|
||||||
// // 历史记录(详细)
|
|
||||||
// Route::any('/reedaw/body/del_record', 'app/NewReedaw/app.body/del_record');
|
|
||||||
// ################################################################肺活部分
|
|
||||||
// // 手动记录
|
|
||||||
// Route::any('/reedaw/vitalcapacity/manual_record', 'app/NewReedaw/app.vitalcapacity/manual_record');
|
|
||||||
// // 设备记录
|
|
||||||
// Route::any('/reedaw/vitalcapacity/device_record', 'app/NewReedaw/app.vitalcapacity/device_record');
|
|
||||||
// // 上一次数据
|
|
||||||
// Route::any('/reedaw/vitalcapacity/data_report', 'app/NewReedaw/app.vitalcapacity/data_report');
|
|
||||||
// // 曲线
|
|
||||||
// Route::any('/reedaw/vitalcapacity/curve_chart', 'app/NewReedaw/app.vitalcapacity/curve_chart');
|
|
||||||
// // 历史记录(分页)
|
|
||||||
// Route::any('/reedaw/vitalcapacity/record_list_page', 'app/NewReedaw/app.vitalcapacity/record_list_page');
|
|
||||||
// // 历史记录(分组)
|
|
||||||
// Route::any('/reedaw/vitalcapacity/record_list_group', 'app/NewReedaw/app.vitalcapacity/record_list_group');
|
|
||||||
// // 历史记录(详细)
|
|
||||||
// Route::any('/reedaw/vitalcapacity/detailed_record', 'app/NewReedaw/app.vitalcapacity/detailed_record');
|
|
||||||
// // 历史记录(详细)
|
|
||||||
// Route::any('/reedaw/vitalcapacity/del_record', 'app/NewReedaw/app.vitalcapacity/del_record');
|
|
||||||
|
|
||||||
// ################################################################跳绳部分
|
|
||||||
// // 获取单个地区数据
|
|
||||||
// Route::any('/reedaw/gf/get_single_data', 'app/NewReedaw/app.gufen/get_single_data');
|
|
||||||
|
|
||||||
|
|
||||||
#######################################################################下面是外部接口#######################################################################
|
#######################################################################下面是外部接口#######################################################################
|
||||||
|
|
@ -1184,6 +1294,7 @@ Route::any('/xishuju1/new_step1_action', 'test/xishuju1/new_step1_action');
|
||||||
Route::any('/xishuju1/new_step2_action', 'test/xishuju1/new_step2_action');
|
Route::any('/xishuju1/new_step2_action', 'test/xishuju1/new_step2_action');
|
||||||
Route::any('/xishuju1/new_step3_action', 'test/xishuju1/new_step3_action');
|
Route::any('/xishuju1/new_step3_action', 'test/xishuju1/new_step3_action');
|
||||||
Route::any('/xishuju1/new_step4_action', 'test/xishuju1/new_step4_action');
|
Route::any('/xishuju1/new_step4_action', 'test/xishuju1/new_step4_action');
|
||||||
|
Route::any('/xishuju1/tc_xishuju', 'test/xishuju1/tc_xishuju');
|
||||||
|
|
||||||
|
|
||||||
Route::any('/xishuju1/ceshiyong', 'test/xishuju1/ceshiyong');
|
Route::any('/xishuju1/ceshiyong', 'test/xishuju1/ceshiyong');
|
||||||
|
|
|
||||||
|
|
@ -1514,6 +1514,7 @@ class Xishuju1 extends Controller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function new_step4_action(){
|
public function new_step4_action(){
|
||||||
|
|
||||||
$nutrients = [
|
$nutrients = [
|
||||||
"10-Formyl folic acid (10HCOFA)" => "حمض الفوليك 10-فورميل",
|
"10-Formyl folic acid (10HCOFA)" => "حمض الفوليك 10-فورميل",
|
||||||
"25-hydroxycholecalciferol" => "25-هيدروكسي كوليكالسيفيرول",
|
"25-hydroxycholecalciferol" => "25-هيدروكسي كوليكالسيفيرول",
|
||||||
|
|
@ -1569,7 +1570,7 @@ class Xishuju1 extends Controller{
|
||||||
"Vitamin K (Menaquinone-4)" => "فيتامين ك (ميناكينون-4)",
|
"Vitamin K (Menaquinone-4)" => "فيتامين ك (ميناكينون-4)",
|
||||||
"Vitamin K (phylloquinone)" => "فيتامين ك (فيلوكينون)",
|
"Vitamin K (phylloquinone)" => "فيتامين ك (فيلوكينون)",
|
||||||
"Zinc, Zn" => "الزنك"
|
"Zinc, Zn" => "الزنك"
|
||||||
];
|
];
|
||||||
$cfc = Db::connect('cfc_db');
|
$cfc = Db::connect('cfc_db');
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($nutrients as $key => $value) {
|
foreach ($nutrients as $key => $value) {
|
||||||
|
|
@ -1581,22 +1582,6 @@ class Xishuju1 extends Controller{
|
||||||
$num = $num+1;
|
$num = $num+1;
|
||||||
dump($num);
|
dump($num);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(!$congfu_num){
|
|
||||||
// return $this->msg(11006,'没了');
|
|
||||||
// }
|
|
||||||
// // 加 bcadd(,,20)
|
|
||||||
// // 减 bcsub(,,20)
|
|
||||||
// // 乘 bcmul(,,20)
|
|
||||||
// // 除 bcdiv(,,20)
|
|
||||||
// $kcal_val = bcdiv($congfu_num['Calorie_val'],4.184,2);
|
|
||||||
// $result = $cfc->table('app_z_national_standard_food_type_3_multilingual_copy1')->where(['id'=>$congfu_num['id']])->update(['Calorie_unit'=>'KCAL','Calorie_val'=>$kcal_val]);
|
|
||||||
|
|
||||||
// if($result){
|
|
||||||
// return $this->msg([]);
|
|
||||||
// }else{
|
|
||||||
// return $this->msg(10002);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1646,6 +1631,135 @@ class Xishuju1 extends Controller{
|
||||||
return $response ? json_decode($response, true) : false;
|
return $response ? json_decode($response, true) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###########################################################################洗体侧的数据###########################################################################
|
||||||
|
###########################################################################洗体侧的数据###########################################################################
|
||||||
|
###########################################################################洗体侧的数据###########################################################################
|
||||||
|
|
||||||
|
public function tc_xishuju(){
|
||||||
|
|
||||||
|
// $page = input()['page'];
|
||||||
|
|
||||||
|
// dump($page);
|
||||||
|
// die;
|
||||||
|
// 老身体数据并入新身体数据
|
||||||
|
$test_data = Db::table('app_card_body_data')->where(['test_type'=>null])->page("1,100")->select();
|
||||||
|
$temporary_data = [];
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
foreach ($test_data as $key => $value) {
|
||||||
|
$data = [];
|
||||||
|
$data = [
|
||||||
|
'bmi' => (float)$value['bmi_val'],
|
||||||
|
'bmilevel' => '',
|
||||||
|
'bm' => explode(',',$value['bone'])[0],
|
||||||
|
'rom' => explode(',',$value['muscle'])[0],
|
||||||
|
'vwc' => explode(',',$value['water'])[0],
|
||||||
|
'bfr' => explode(',',$value['fat_r'])[0],
|
||||||
|
'sfr' => explode(',',$value['sfr'])[0],
|
||||||
|
'pp' => explode(',',$value['protein'])[0],
|
||||||
|
'uvi' => explode(',',$value['visceral'])[0],
|
||||||
|
'bmr' => explode(',',$value['kcal'])[0],
|
||||||
|
'bodyage' => (float)$value['body_age'],
|
||||||
|
'weight' => (float)$value['weight_val'],
|
||||||
|
'height' => (float)$value['height_val'],
|
||||||
|
'age' => $value['age'],
|
||||||
|
'adc' => 550,
|
||||||
|
'sex' => 0,
|
||||||
|
'romval' => explode(',',$value['muscleval'])[0],
|
||||||
|
'ppval' => explode(',',$value['proteinval'])[0],
|
||||||
|
'bfrval' => explode(',',$value['fat_w'])[0],
|
||||||
|
'lbm' => 0,
|
||||||
|
'fatlevel' => 0,
|
||||||
|
'fatlevelname' => $value['body_level'],
|
||||||
|
'body' => $value['body_type'],
|
||||||
|
'cmi' => $value['score'],
|
||||||
|
'standardlist' => null
|
||||||
|
];
|
||||||
|
$temporary_data[] = [
|
||||||
|
'id'=>$value['id'],
|
||||||
|
'create_time'=>$value['create_time'],
|
||||||
|
'acd_id'=>$value['acd_id'],
|
||||||
|
'aud_id'=>$value['aud_id'],
|
||||||
|
'record_time'=>$value['record_time'],
|
||||||
|
'age'=>$value['age'],
|
||||||
|
'is_del'=>$value['is_del'],
|
||||||
|
'record_type'=>$value['record_type'],
|
||||||
|
'height'=>(float)$value['height_val'],
|
||||||
|
'weight'=>(float)$value['weight_val'],
|
||||||
|
'bmi'=>(float)$value['bmi_val'],
|
||||||
|
'score'=>$value['score'],
|
||||||
|
'fat_r'=> explode(',',$value['fat_r'])[0],
|
||||||
|
'fat_w'=> explode(',',$value['fat_w'])[0],
|
||||||
|
'muscle'=> explode(',',$value['muscle'])[0],
|
||||||
|
'muscleval'=> explode(',',$value['muscleval'])[0],
|
||||||
|
'water'=>explode(',',$value['water'])[0],
|
||||||
|
'protein'=>explode(',',$value['protein'])[0],
|
||||||
|
'proteinval'=>explode(',',$value['proteinval'])[0],
|
||||||
|
'bone'=>explode(',',$value['bone'])[0],
|
||||||
|
'kcal'=>explode(',',$value['kcal'])[0],
|
||||||
|
'visceral'=>explode(',',$value['visceral'])[0],
|
||||||
|
'sfr'=>explode(',',$value['sfr'])[0],
|
||||||
|
'body_level'=>$value['body_level'],
|
||||||
|
'body_type'=>$value['body_type'],
|
||||||
|
'body_age'=>(float)$value['body_age'],
|
||||||
|
// 'heart_rate'=>$value['heart_rate'],
|
||||||
|
'head_circumference'=>$value['head_circumference'],
|
||||||
|
'8_electrode_data'=>null,
|
||||||
|
'4_electrode_data'=>json_encode($data),
|
||||||
|
'head_circumference_val'=>$value['head_circumference']?json_decode($value['head_circumference'],true)['value']:null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$success_num = 0;
|
||||||
|
$total_num = 100;
|
||||||
|
$fail_num = 0;
|
||||||
|
|
||||||
|
foreach ($temporary_data as $key => $value) {
|
||||||
|
|
||||||
|
$id = $value['id'];
|
||||||
|
$xh_data = $value;
|
||||||
|
unset($xh_data['id']);
|
||||||
|
// dump($xh_data);
|
||||||
|
// 启动事务
|
||||||
|
Db::startTrans();
|
||||||
|
try{
|
||||||
|
Db::table('app_card_body_data_new')->insert($xh_data);
|
||||||
|
Db::table('app_card_body_data')->where(['id'=>$id])->update(['test_type'=>'1']);
|
||||||
|
// 提交事务
|
||||||
|
Db::commit();
|
||||||
|
$success_num = $success_num+1;
|
||||||
|
// dump('OK');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
$fail_num = $fail_num+1;
|
||||||
|
// dump($id);
|
||||||
|
// 记录异常信息
|
||||||
|
// dump('事务回滚原因:' . $e->getMessage());
|
||||||
|
// dump('异常文件:' . $e->getFile());
|
||||||
|
// dump('异常行号:' . $e->getLine());
|
||||||
|
// dump('SQL错误代码:' . $e->getCode());
|
||||||
|
// dump('########################################################################################################');
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($test_data) < 100){
|
||||||
|
return $this->msg(11006);
|
||||||
|
}else if($fail_num >= 100){
|
||||||
|
return $this->msg(99999);
|
||||||
|
}else{
|
||||||
|
return $this->msg(0,'success',[
|
||||||
|
'success_num'=>$success_num,
|
||||||
|
'total_num'=>$total_num,
|
||||||
|
'fail_num'=>$fail_num,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
|
|
@ -1653,19 +1767,8 @@ class Xishuju1 extends Controller{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function msg($data,$str='',$result = []){
|
public function msg($code,$str='',$result = []){
|
||||||
if(is_array($data)){
|
return json(['code'=>$code,'msg'=>$str,'data'=>$result]);
|
||||||
if($str != ''){
|
|
||||||
return json(['code'=>0,'msg'=>$str,'data'=>$data]);
|
|
||||||
}else{
|
|
||||||
return json(['code'=>0,'msg'=>'操作成功','data'=>$data]);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if($str != ''){
|
|
||||||
return json(['code'=>$data,'msg'=>$str,'data'=>$result]);
|
|
||||||
}
|
|
||||||
return json(['code'=>$data,'msg'=>$this->return_data_all[$data],'data'=>$result]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 使用纯BC函数的版本(最精确)
|
// 使用纯BC函数的版本(最精确)
|
||||||
public function processPrecisionNumberBC($numberStr) {
|
public function processPrecisionNumberBC($numberStr) {
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="start_action" onclick="start_action()">开始</div>
|
<div class="start_action" onclick="start_action2()">开始</div>
|
||||||
<div class="title">描述:</div>
|
<div class="title">描述:</div>
|
||||||
<div class="centent"></div><br/><br/>
|
<div class="centent"></div><br/><br/>
|
||||||
<div>~~~~~~~~~~~~~~~~~~~~~~分割线~~~~~~~~~~~~~~~~~~~~</div>
|
<div>~~~~~~~~~~~~~~~~~~~~~~分割线~~~~~~~~~~~~~~~~~~~~</div>
|
||||||
|
|
@ -166,7 +166,8 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// url:"new_step1_action", //请求的url地址
|
// url:"new_step1_action", //请求的url地址
|
||||||
// url:"new_step2_action", //请求的url地址
|
// url:"new_step2_action", //请求的url地址
|
||||||
url:"new_step3_action", //请求的url地址
|
// url:"new_step3_action", //请求的url地址
|
||||||
|
url:"tc_xishuju", //请求的url地址
|
||||||
dataType:"json", //返回格式为json
|
dataType:"json", //返回格式为json
|
||||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||||
data:{"page":page}, //参数值
|
data:{"page":page}, //参数值
|
||||||
|
|
@ -194,9 +195,33 @@
|
||||||
// start_action2()
|
// start_action2()
|
||||||
// }, 100);
|
// }, 100);
|
||||||
// }
|
// }
|
||||||
|
// if(req.code == 0){
|
||||||
|
// success_num = success_num+1
|
||||||
|
// total_num = total_num+1
|
||||||
|
// str = "<p>处理成功:"+(success_num)+"项</p>"
|
||||||
|
// + "<p>处理失败:"+(fail_num)+"项</p>"
|
||||||
|
// + "<p>总计处理:"+(total_num)+"项</p>"
|
||||||
|
// $('.centent').html(str)
|
||||||
|
// setTimeout(() => {
|
||||||
|
// start_action2()
|
||||||
|
// }, 100);
|
||||||
|
// }else if(req.code == 11006){
|
||||||
|
// $('.centent').append('<p>处理完成!</p>');
|
||||||
|
// }else{
|
||||||
|
// total_num = total_num+1
|
||||||
|
// fail_num = fail_num+1
|
||||||
|
// str = "<p>处理成功:"+(success_num)+"项</p>"
|
||||||
|
// + "<p>处理失败:"+(fail_num)+"项</p>"
|
||||||
|
// + "<p>总计处理:"+(total_num)+"项</p>"
|
||||||
|
// $('.centent').html(str)
|
||||||
|
// setTimeout(() => {
|
||||||
|
// start_action2()
|
||||||
|
// }, 100);
|
||||||
|
// }
|
||||||
if(req.code == 0){
|
if(req.code == 0){
|
||||||
success_num = success_num+1
|
success_num = success_num+req.data.success_num
|
||||||
total_num = total_num+1
|
total_num = total_num+req.data.total_num
|
||||||
|
fail_num = fail_num+req.data.fail_num
|
||||||
str = "<p>处理成功:"+(success_num)+"项</p>"
|
str = "<p>处理成功:"+(success_num)+"项</p>"
|
||||||
+ "<p>处理失败:"+(fail_num)+"项</p>"
|
+ "<p>处理失败:"+(fail_num)+"项</p>"
|
||||||
+ "<p>总计处理:"+(total_num)+"项</p>"
|
+ "<p>总计处理:"+(total_num)+"项</p>"
|
||||||
|
|
@ -207,15 +232,7 @@
|
||||||
}else if(req.code == 11006){
|
}else if(req.code == 11006){
|
||||||
$('.centent').append('<p>处理完成!</p>');
|
$('.centent').append('<p>处理完成!</p>');
|
||||||
}else{
|
}else{
|
||||||
total_num = total_num+1
|
$('.centent').append('<p>处理异常</p>');
|
||||||
fail_num = fail_num+1
|
|
||||||
str = "<p>处理成功:"+(success_num)+"项</p>"
|
|
||||||
+ "<p>处理失败:"+(fail_num)+"项</p>"
|
|
||||||
+ "<p>总计处理:"+(total_num)+"项</p>"
|
|
||||||
$('.centent').html(str)
|
|
||||||
setTimeout(() => {
|
|
||||||
start_action2()
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error:function(){
|
error:function(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue