260316部分测试
|
|
@ -242,7 +242,7 @@ class Card extends Base{
|
|||
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();
|
||||
$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(10)->select();
|
||||
// 根据用户处理卡片信息
|
||||
$return_data = [
|
||||
'chosen_yes'=>[],
|
||||
|
|
|
|||
|
|
@ -463,6 +463,9 @@ class Index extends Base{
|
|||
|
||||
$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();
|
||||
|
||||
foreach ($user_list as $key => $value) {
|
||||
$user_list[$key]['age'] = $this->calculate_age($value['birthday']);
|
||||
}
|
||||
$result_data = ['default_user_id'=>$account_data['default_user_id'],'user_list'=>$user_list];
|
||||
return $this->msg($result_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,11 +218,11 @@ class Role extends Base{
|
|||
try {
|
||||
// 你的业务逻辑
|
||||
|
||||
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)){
|
||||
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);
|
||||
}
|
||||
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
|
||||
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')){
|
||||
return $this->msg(10005,'token type error');
|
||||
|
|
@ -260,11 +260,11 @@ class Role extends Base{
|
|||
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('measure_model', $data)){
|
||||
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)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if($data['measure_model'] != '1' && $data['measure_model'] != '2'){
|
||||
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')){
|
||||
return $this->msg(10005,'token type error');
|
||||
|
|
@ -575,42 +575,42 @@ class Role extends Base{
|
|||
$parameter['card_order'] = '';
|
||||
$parameter['create_time'] = date('Y-m-d H:i:s');
|
||||
$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();
|
||||
if($is_nickname_ok>0){
|
||||
return $this->msg(10002,'该角色已存在');
|
||||
}
|
||||
if($parameter['measure_model'] == 1){
|
||||
if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
||||
return $this->msg(10005,'身份信息错误');
|
||||
}
|
||||
if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||
return $this->msg(10005,'年级信息错误');
|
||||
}
|
||||
$parameter['grade'] = $data['grade'];
|
||||
$parameter['identity_id'] = $data['identity_id'];
|
||||
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||
$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();
|
||||
$parameter['card_order'] = $address_data['recommend_cards'];
|
||||
}else{
|
||||
$parameter['grade'] = 'nothing';
|
||||
$parameter['identity_id'] = 'P0';
|
||||
$parameter['identity_name'] = '陌生人';
|
||||
$parameter['address'] = '';
|
||||
}
|
||||
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();
|
||||
if($result>0){
|
||||
return $this->msg(10005,'该身份已存在');
|
||||
}
|
||||
}
|
||||
$return_result = Db::table($this->role_db_name['juese'])->insert($parameter);
|
||||
// if($parameter['measure_model'] == 1){
|
||||
// if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||
// return $this->msg(10001);
|
||||
// }
|
||||
// if(!array_key_exists($data['identity_id'],$this->identity_lis3t)){
|
||||
// return $this->msg(10005,'身份信息错误');
|
||||
// }
|
||||
// if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||
// return $this->msg(10005,'年级信息错误');
|
||||
// }
|
||||
// $parameter['grade'] = $data['grade'];
|
||||
// $parameter['identity_id'] = $data['identity_id'];
|
||||
// $parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||
// $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();
|
||||
// $parameter['card_order'] = $address_data['recommend_cards'];
|
||||
// }else{
|
||||
// $parameter['grade'] = 'nothing';
|
||||
// $parameter['identity_id'] = 'P0';
|
||||
// $parameter['identity_name'] = '陌生人';
|
||||
// $parameter['address'] = '';
|
||||
// }
|
||||
// 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();
|
||||
// if($result>0){
|
||||
// return $this->msg(10005,'该身份已存在');
|
||||
// }
|
||||
// }
|
||||
$return_result = Db::table($this->role_db_name['juese'])->insertGetId($parameter);
|
||||
if($return_result){
|
||||
return $this->msg([]);
|
||||
return $this->msg(['aud_id'=>$return_result]);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
}
|
||||
|
|
@ -628,30 +628,30 @@ class Role extends Base{
|
|||
$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['last_update_time'] = date('Y-m-d H:i:s');
|
||||
$parameter['measure_model'] = $data['measure_model'];
|
||||
if($parameter['measure_model'] == 1){
|
||||
if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
||||
return $this->msg(10005,'身份信息错误');
|
||||
}
|
||||
if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||
return $this->msg(10005,'年级信息错误');
|
||||
}
|
||||
$parameter['grade'] = $data['grade'];
|
||||
$parameter['identity_id'] = $data['identity_id'];
|
||||
$parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||
$parameter['address'] = $data['address'];
|
||||
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();
|
||||
if($result>0){
|
||||
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();
|
||||
$parameter['card_order'] = $address_data['recommend_cards'];
|
||||
}
|
||||
$parameter['activity_level'] = $data['activity_level'];
|
||||
// if($parameter['measure_model'] == 1){
|
||||
// if(!array_key_exists('grade',$data) || !array_key_exists('identity_id',$data) || !array_key_exists('address',$data)){
|
||||
// return $this->msg(10001);
|
||||
// }
|
||||
// if(!array_key_exists($data['identity_id'],$this->identity_list)){
|
||||
// return $this->msg(10005,'身份信息错误');
|
||||
// }
|
||||
// if(!array_key_exists($data['grade'],$this->grade_list2)){
|
||||
// return $this->msg(10005,'年级信息错误');
|
||||
// }
|
||||
// $parameter['grade'] = $data['grade'];
|
||||
// $parameter['identity_id'] = $data['identity_id'];
|
||||
// $parameter['identity_name'] = $this->identity_list[$data['identity_id']];
|
||||
// $parameter['address'] = $data['address'];
|
||||
// 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();
|
||||
// if($result>0){
|
||||
// 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();
|
||||
// $parameter['card_order'] = $address_data['recommend_cards'];
|
||||
// }
|
||||
|
||||
$return_result = Db::table($this->role_db_name['juese'])->where(['id'=>$data['id']])->update($parameter);
|
||||
if($return_result){
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class Userbody extends Base{
|
|||
'unit' => 'cm',
|
||||
"description"=>"人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大",
|
||||
"smart_tip_description"=>"",
|
||||
"icon"=>"https://tc.pcxbc.com/new_reedaw/icon/height.png",
|
||||
'standard_list' => [
|
||||
['min_val'=>'0','max_val'=>'','text'=>'矮','color'=>'#FD5759'],
|
||||
['min_val'=>'','max_val'=>'','text'=>'偏矮','color'=>'#FAAD01'],
|
||||
|
|
@ -67,6 +68,7 @@ class Userbody extends Base{
|
|||
'unit' => 'kg',
|
||||
"description"=>"体重指人体的重量,通常用斤、公斤或磅作为单位来衡量。体重是人体健康的重要指标,但需要结合身高、体型和体脂率等因素来综合评估。",
|
||||
"smart_tip_description"=>"保持均衡营养的饮食,摄入足够的碳水化合物、蛋白质、脂肪等。适度进行运动,保持良好的生活习惯。",
|
||||
"icon"=>"https://tc.pcxbc.com/new_reedaw/icon/weight.png",
|
||||
'standard_list' => [
|
||||
['min_val'=>'0','max_val'=>'','text'=>'低','color'=>'#F8595D'],
|
||||
['min_val'=>'','max_val'=>'','text'=>'偏低','color'=>'#FFAF04'],
|
||||
|
|
@ -81,6 +83,7 @@ class Userbody extends Base{
|
|||
'unit' => '',
|
||||
"description"=>"BMI是身体质量指数(BodyMasslndex)的缩写,是一种常用的衡量人体肥胖程度的指标",
|
||||
"smart_tip_description"=>"",
|
||||
"icon"=>"https://tc.pcxbc.com/new_reedaw/icon/bmi10.png",
|
||||
'standard_list' => [
|
||||
['min_val'=>'0','max_val'=>'','text'=>'消瘦','color'=>'#FDDA6B'],
|
||||
['min_val'=>'','max_val'=>'','text'=>'正常','color'=>'#5BD068'],
|
||||
|
|
@ -436,6 +439,7 @@ class Userbody extends Base{
|
|||
'unit' => 'cm',
|
||||
"description"=>"",
|
||||
"smart_tip_description"=>"",
|
||||
"icon"=>"https://tc.pcxbc.com/new_reedaw/icon/head_circumference.png",
|
||||
'standard_list' => [],
|
||||
'key_name'=>'head_circumference',
|
||||
],
|
||||
|
|
@ -444,6 +448,7 @@ class Userbody extends Base{
|
|||
'unit' => '跳/分钟',
|
||||
"description"=>"心率指正常人安静状态下每分钟心跳的次数,可因年龄、性别或其他生理因素产生个体差异。",
|
||||
"smart_tip_description"=>"注意减少压力和焦虑,适度锻炼,保持良好的睡眠质量,避免过度用力或剧烈运动。",
|
||||
"icon"=>"https://tc.pcxbc.com/new_reedaw/icon/heart_rate10.png",
|
||||
'standard_list' => [
|
||||
['min_val'=>'0','max_val'=>'','text'=>'偏低','color'=>'#FCDB67'],
|
||||
['min_val'=>'','max_val'=>'','text'=>'标准','color'=>'#58D268'],
|
||||
|
|
@ -772,7 +777,7 @@ class Userbody extends Base{
|
|||
public function set_initial_weight(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('weight', $data) || !array_key_exists('token', $data)){
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('weight', $data) || !array_key_exists('time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
||||
|
|
@ -781,11 +786,12 @@ class Userbody extends Base{
|
|||
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
||||
return $this->msg(10005,'weight type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['time'],'datetime')){
|
||||
return $this->msg(10005,'time type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005,'token type error');
|
||||
}
|
||||
|
||||
$data['time'] = date('Y-m-d H:i:s');
|
||||
return $this->set_initial_weight_action($data);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
|
|
@ -804,8 +810,9 @@ class Userbody extends Base{
|
|||
}
|
||||
// 获取历史列表(分页)
|
||||
public function history_list_page(){
|
||||
$data = input('post.');
|
||||
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);
|
||||
}
|
||||
|
|
@ -835,8 +842,9 @@ class Userbody extends Base{
|
|||
}
|
||||
// 历史记录(详细)
|
||||
public function history_detailed(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
$data = input('post.');
|
||||
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
|
|
@ -863,8 +871,9 @@ class Userbody extends Base{
|
|||
}
|
||||
// 历史记录删除
|
||||
public function history_del(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
$data = input('post.');
|
||||
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
|
|
@ -889,6 +898,42 @@ class Userbody extends Base{
|
|||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
// 曲线详情
|
||||
public function curve_detailed(){
|
||||
$data = input('post.');
|
||||
try {
|
||||
|
||||
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,'s_time type error');
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['e_time'],'datetime')){
|
||||
return $this->msg(10005,'e_time type error');
|
||||
}
|
||||
return $this->curve_detailed_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################################################################
|
||||
|
|
@ -987,6 +1032,7 @@ class Userbody extends Base{
|
|||
}
|
||||
unset($standardlist['list']);
|
||||
unset($get_body_value['standardlist']);
|
||||
$db_data['head_circumference_val'] = $db_data['head_circumference'];
|
||||
$db_data['head_circumference'] = json_encode($standardlist);
|
||||
}
|
||||
}else{
|
||||
|
|
@ -1428,23 +1474,6 @@ class Userbody extends Base{
|
|||
}
|
||||
}
|
||||
|
||||
// // 分割数据
|
||||
// $temporary_data_1 = explode(',',$body_last_data[0][$value]);
|
||||
// // 设置默认标准颜色
|
||||
// $standard_color = '#121212';
|
||||
// // 处理标准颜色
|
||||
// if(array_key_exists($temporary_data_1[1],$this->merged_data[$value]['list'])){
|
||||
// $standard_color = $this->merged_data[$value]['list'][$temporary_data_1[1]];
|
||||
// }
|
||||
// $result_return['card_list'][] = [
|
||||
// 'name'=>$this->merged_data[$value]['name'],
|
||||
// 'icon'=>'',
|
||||
// 'value'=>$temporary_data_1[0],
|
||||
// 'unit'=>$this->merged_data[$value]['unit'],
|
||||
// 'standard'=>$temporary_data_1[1],
|
||||
// 'standard_color'=>$standard_color,
|
||||
// 'key_name'=>$value,
|
||||
// ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1514,7 +1543,43 @@ class Userbody extends Base{
|
|||
$result_return[] = $temporary_data_list;
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
// $temporary_data_list = $this->merged_data[$value];
|
||||
// $temporary_data_list['list'] = [];
|
||||
// $temporary_data_list['standard_list'] = [];
|
||||
// $temporary_data_list['value'] = '--';
|
||||
// $result_return[] = $temporary_data_list;
|
||||
// continue;
|
||||
if($value == 'ideal_weight' || $value == 'ideal_height' || $value == 'ideal_bmi'){
|
||||
$temporary_data_list = $this->judgment_standard_color_detailed(null,$value,$user_data);
|
||||
if($temporary_data_list){
|
||||
$temporary_data_list['value'] = '--';
|
||||
if(array_key_exists('offset',$temporary_data_list) && $temporary_data_list['offset']){
|
||||
$temporary_data_list['offset'] = 0;
|
||||
}
|
||||
$result_return[] = $temporary_data_list;
|
||||
}
|
||||
}else if($value == 'body_type'){
|
||||
$temporary_data_list = $this->judgment_standard_color_detailed($body_last_data[$value],$value,$user_data);
|
||||
if($temporary_data_list){
|
||||
$temporary_data_list['l_line_color'] = ['name'=>'体脂率','standard_list'=>[['name'=>'偏低','color'=>'#EAAE29'],['name'=>'标准、偏高','color'=>'#0AD2B0'],['name'=>'过高、超高','color'=>'#F83F29']]];
|
||||
$temporary_data_list['r_line_color'] = ['name'=>'肌肉量','standard_list'=>[['name'=>'偏低','color'=>'#4db4ec'],['name'=>'标准','color'=>'#8bcc4c'],['name'=>'优秀','color'=>'#159383']]];
|
||||
$temporary_data_list['box_list'] = ['浮肿肥胖型','偏胖肌肉型','肌肉型偏胖','缺乏运动型','标准型','标准肌肉型','偏瘦型','偏瘦肌肉型','肌肉发达型'];
|
||||
$temporary_data_list['value'] = '--';
|
||||
if(array_key_exists('offset',$temporary_data_list) && $temporary_data_list['offset']){
|
||||
$temporary_data_list['offset'] = 0;
|
||||
}
|
||||
$result_return[] = $temporary_data_list;
|
||||
}
|
||||
}else{
|
||||
$temporary_data_list = $this->judgment_standard_color_detailed($body_last_data[$value],$value,$user_data);
|
||||
if($temporary_data_list){
|
||||
$temporary_data_list['value'] = '--';
|
||||
if(array_key_exists('offset',$temporary_data_list) && $temporary_data_list['offset']){
|
||||
$temporary_data_list['offset'] = 0;
|
||||
}
|
||||
$result_return[] = $temporary_data_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($value == 'ideal_weight' || $value == 'ideal_height' || $value == 'ideal_bmi'){
|
||||
|
|
@ -1969,7 +2034,8 @@ class Userbody extends Base{
|
|||
}
|
||||
}
|
||||
public function set_initial_weight_action($data){
|
||||
$user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight']]);
|
||||
$data['time'] = $data['time'].' '.date('H:i:s');
|
||||
$user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->update(['initial_weight'=>$data['weight'],'initial_date'=>$data['time']]);
|
||||
if($user_data){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
|
|
@ -2076,6 +2142,107 @@ class Userbody extends Base{
|
|||
return $this->msg(10002);
|
||||
}
|
||||
|
||||
}
|
||||
public function curve_detailed_action($data){
|
||||
|
||||
$user_data = Db::table($this->body_db_name['juese'])->where(['id'=>$data['aud_id']])->field('id,target_weight,initial_weight,initial_date')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10003);
|
||||
}
|
||||
|
||||
|
||||
$weight_result = null;
|
||||
if($user_data['target_weight'] == null || $user_data['initial_weight'] == null){
|
||||
$user_data['target_weight'] = $user_data['target_weight'] == null?0:$user_data['target_weight'];
|
||||
$user_data['initial_weight'] = $user_data['initial_weight'] == null?0:$user_data['initial_weight'];
|
||||
}else{
|
||||
$weight_result = Db::table($this->body_db_name['body_data_new'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,weight,record_time')->find();
|
||||
}
|
||||
|
||||
$return_data['target_weight'] = $user_data['target_weight'];
|
||||
$return_data['initial_weight'] = $user_data['initial_weight'];
|
||||
if($weight_result){
|
||||
$return_data['calculate_time'] = $this->daysSince($user_data['initial_date']);
|
||||
$return_data['calculate_val'] = bcsub($weight_result['weight'],$data['initial_weight'],2);
|
||||
}else{
|
||||
$return_data['calculate_time'] = 0;
|
||||
$return_data['calculate_val'] = 0;
|
||||
}
|
||||
|
||||
$db_type = [['weight','体重'],['height','身高'],['bmi','BMI'],['heart_rate','心率'],['head_circumference_val','头围']];
|
||||
|
||||
// foreach ($variable as $key => $value) {
|
||||
// # code...
|
||||
// }
|
||||
|
||||
$data['s_time'] = $data['s_time'].' 00:00:00';
|
||||
$data['e_time'] = $data['e_time'].' 23:59:59';
|
||||
|
||||
$cha_data = Db::table($this->body_db_name['body_data_new'])
|
||||
->where("aud_id = ".$data['aud_id']." AND is_del = 0 AND record_time >= '".$data['s_time']."' AND record_time <= '".$data['e_time']."'")
|
||||
->order('record_time desc')
|
||||
->field('id,weight,height,bmi,heart_rate,head_circumference_val,LEFT(record_time,10) as record_time')
|
||||
->select();
|
||||
|
||||
$temporary_arr = [];
|
||||
$return_data['curve_list'] = [];
|
||||
foreach ($db_type as $key => $value) {
|
||||
$temporary_arr = [];
|
||||
// $temporary_arr['key'] = $value[0];
|
||||
$temporary_arr['title'] = $value[1];
|
||||
$temporary_arr['line'] = [
|
||||
'categories' => [],
|
||||
'series' => [
|
||||
['color' => "#000000",'data' => []]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($cha_data as $k => $v) {
|
||||
if($v[$value[0]]){
|
||||
$temporary_arr['line']['categories'][] = $v['record_time'];
|
||||
$temporary_arr['line']['series'][0]['data'][] = floatval($v[$value[0]]);
|
||||
}
|
||||
|
||||
}
|
||||
$return_data['curve_list'][] = $temporary_arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if($data['type'] == 'heart_rate'){
|
||||
// $where_str = "aud_id = ".$data['aud_id']." AND heart_rate is not null AND is_del = 0";
|
||||
// $field_str = "id,record_time,heart_rate as val_data";
|
||||
// }else if($data['type'] == 'head_circumference'){
|
||||
// $where_str = "aud_id = ".$data['aud_id']." AND head_circumference_val is not null AND is_del = 0";
|
||||
// $field_str = "id,record_time,head_circumference_val as val_data";
|
||||
// }else{
|
||||
// $where_str = "aud_id = ".$data['aud_id']." AND is_del = 0";
|
||||
// $field_str = "id,record_time,".$data['type']." as val_data";
|
||||
// }
|
||||
|
||||
|
||||
// $return_data['curve_list'] = [
|
||||
// 'key' => $data['type'],
|
||||
// 'line' => [
|
||||
// 'categories' => [],
|
||||
// 'series' => [
|
||||
// 'color' => "#000000",
|
||||
// 'data' => [],
|
||||
// ],
|
||||
// ],
|
||||
// ];
|
||||
|
||||
// foreach ($cha_data as $key => $value) {
|
||||
// $return_data['curve_list']['line']['categories'][] = $value['record_time'];
|
||||
// $return_data['curve_list']['line']['series']['data'][] = $value['val_data'];
|
||||
// }
|
||||
|
||||
|
||||
return $this->msg($return_data);
|
||||
|
||||
}
|
||||
|
||||
################################################################工具################################################################
|
||||
|
|
|
|||
|
|
@ -895,6 +895,9 @@ Route::any('/reedaw/history_list_page', 'app/NewReedaw/app.Userbody/history_list
|
|||
Route::any('/reedaw/history_detailed', 'app/NewReedaw/app.Userbody/history_detailed');
|
||||
// 删除历史数据
|
||||
Route::any('/reedaw/history_del', 'app/NewReedaw/app.Userbody/history_del');
|
||||
// 曲线详情
|
||||
Route::any('/reedaw/curve_detailed', 'app/NewReedaw/app.Userbody/curve_detailed');
|
||||
|
||||
|
||||
|
||||
################################################################首页(饮食数据)
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.1 KiB |