测试0522
This commit is contained in:
parent
416a3f8d85
commit
fff1919ee7
|
|
@ -16,7 +16,7 @@ class Base extends Controller{
|
||||||
'10001'=>'关键参数缺失',
|
'10001'=>'关键参数缺失',
|
||||||
'10002'=>'操作失败',
|
'10002'=>'操作失败',
|
||||||
'10003'=>'信息核实错误',
|
'10003'=>'信息核实错误',
|
||||||
'10004'=>'未核实到数据',
|
'10004'=>'未找到有效数据',
|
||||||
'10005'=>'未核实到数据',
|
'10005'=>'未核实到数据',
|
||||||
'10006'=>'未核实到数据',
|
'10006'=>'未核实到数据',
|
||||||
'10007'=>'未核实到数据',
|
'10007'=>'未核实到数据',
|
||||||
|
|
@ -159,6 +159,33 @@ class Base extends Controller{
|
||||||
return $ageInMonthsPrecise;
|
return $ageInMonthsPrecise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 曲线页面-底部统计动作
|
||||||
|
|
||||||
|
public function base_target_initial_cumulative_weight($id,$weight = '',$target_weight,$initial_weight,$initial_date){
|
||||||
|
if($weight != ''){
|
||||||
|
$user_data = Db::table('app_user_data')->where(['id'=>$id])->field('target_weight,initial_weight,initial_date')->find();
|
||||||
|
}else{
|
||||||
|
$user_data = Db::table('app_user_data')->where(['id'=>$id])->field('target_weight,initial_weight,initial_date')->find();
|
||||||
|
}
|
||||||
|
if($user_data){
|
||||||
|
if($user_data['initial_date']){
|
||||||
|
$result_data['target_weight'] = $user_data['target_weight'];
|
||||||
|
$result_data['initial_weight'] = $user_data['initial_weight'];
|
||||||
|
$result_data['cumulative_weight'] = 0;
|
||||||
|
$result_data['cumulative_day'] = $this->daysSince($user_data['initial_date']).'天';
|
||||||
|
}else{
|
||||||
|
$result_data['target_weight'] = 0;
|
||||||
|
$result_data['initial_weight'] = 0;
|
||||||
|
$result_data['cumulative_weight'] = 0;
|
||||||
|
$result_data['cumulative_day'] = 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
dump($result_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function msg($data,$str=''){
|
public function msg($data,$str=''){
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,13 @@ use think\Controller;
|
||||||
|
|
||||||
class Calculatebody extends Controller{
|
class Calculatebody extends Controller{
|
||||||
|
|
||||||
|
// 默认阻抗值
|
||||||
|
protected $default_adc = 550;
|
||||||
|
|
||||||
function calculate_body_data_result($data = ['weight'=>52.5,'height'=>165,'age'=>30,'adc'=>550,'gender'=>1]){
|
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['gender'] = $data['gender'] == 0 ? 1 : $data['gender'];
|
||||||
|
|
||||||
|
$data['adc'] = $this->default_adc;
|
||||||
// 加 bcadd(,,20)
|
// 加 bcadd(,,20)
|
||||||
// 减 bcsub(,,20)
|
// 减 bcsub(,,20)
|
||||||
// 乘 bcmul(,,20)
|
// 乘 bcmul(,,20)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ class Card extends Base{
|
||||||
'color'=>'',
|
'color'=>'',
|
||||||
'list'=>[]
|
'list'=>[]
|
||||||
];
|
];
|
||||||
|
protected $card_body_curve_arr = ['weight','bmi','muscle','fat_r'];
|
||||||
|
protected $card_body_curve_arr2 = ['体重','BMI','肌肉率','脂肪率'];
|
||||||
|
protected $card_body_curve_arr3 = ['#fb7b92','#6bb0fe','#ff9f40','#3fcba7'];
|
||||||
|
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
################################################################接口################################################################
|
################################################################接口################################################################
|
||||||
|
|
@ -90,11 +93,11 @@ class Card extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 曲线页面-曲线接口
|
// 曲线页面-曲线接口
|
||||||
public function card_curve_chart($data = ['aud_id'=>'11','type'=>'weight','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-04-11 10:10:10','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
public function card_curve_chart($data = ['aud_id'=>'25','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-07-30 10:10:10','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
if(count(input()) > 0){
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('type', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data)){
|
if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data)){
|
||||||
return $this->msg(10001);
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
if($this->token_time_validate($data['token']) === false){
|
if($this->token_time_validate($data['token']) === false){
|
||||||
|
|
@ -104,14 +107,11 @@ class Card extends Base{
|
||||||
|
|
||||||
return $this->curve_chart_action($data);
|
return $this->curve_chart_action($data);
|
||||||
}
|
}
|
||||||
// 曲线页面-底部统计
|
|
||||||
public function card_curve_target(){
|
|
||||||
|
|
||||||
}
|
|
||||||
// 手动记录
|
// 手动记录
|
||||||
// $data = ['id'=>'2','time'=>'1991-04-20 10:10:10','height'=>'15.1','weight'=>'75.1']
|
// $data = ['id'=>'2','time'=>'1991-04-20 10:10:10','height'=>'15.1','weight'=>'75.1']
|
||||||
// public function card_manual_recording($data = ['acd_id'=>'2','aud_id'=>'11','time'=>'2024-04-11 10:10:10','data'=>['height'=>'175.1','weight'=>'77.1']]){
|
// public function card_manual_recording($data = ['acd_id'=>'2','aud_id'=>'11','time'=>'2024-04-11 10:10:10','data'=>['height'=>'175.1','weight'=>'77.1']]){
|
||||||
public function card_manual_recording($data = ['aud_id'=>'11','time'=>'2024-04-11 10:10:10','height'=>'165.3','weight'=>'66.1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
public function card_manual_recording($data = ['aud_id'=>'25','time'=>'2024-04-11 10:10:15','height'=>'165.3','weight'=>'66.1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
if(count(input()) > 0){
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ class Card extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取记录信息列表
|
// 获取记录信息列表
|
||||||
public function get_card_record_data($data = ['aud_id'=>'11','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-04-12 10:10:10','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
public function get_card_record_data($data = ['aud_id'=>'11','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-06-12 10:10:10','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
if(count(input()) > 0){
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
|
|
@ -183,256 +183,27 @@ class Card extends Base{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
################################################################身体数据卡片接口################################################################
|
################################################################业务接口################################################################
|
||||||
################################################################身体数据卡片接口################################################################
|
################################################################业务接口################################################################
|
||||||
|
|
||||||
public function curve_chart_action($data){
|
|
||||||
$user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('target_weight,initial_weight,initial_date')->find();
|
|
||||||
// dump($user_data);
|
|
||||||
if($user_data){
|
|
||||||
if($user_data['initial_date']){
|
|
||||||
$result_data['target_weight'] = $user_data['target_weight'].'kg';
|
|
||||||
$result_data['initial_weight'] = $user_data['initial_weight'].'kg';
|
|
||||||
$result_data['initial_date'] = $this->daysSince($user_data['initial_date']).'天';
|
|
||||||
}else{
|
|
||||||
$result_data['target_weight'] = '';
|
|
||||||
$result_data['initial_weight'] = '';
|
|
||||||
$result_data['initial_date'] = '';
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return $this->msg(10003);
|
|
||||||
}
|
|
||||||
dump($result_data);
|
|
||||||
$user_data_list = Db::query("select record_time,weight,bmi,muscleval,fat_w from app_card_body_data where aud_id='".$data['aud_id']."'and record_time between '".$data['s_time']."' and '".$data['e_time']."' order by record_time desc");
|
|
||||||
dump($user_data_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// weight height muscle fat
|
|
||||||
// 查询曲线数据
|
|
||||||
public function body_curve_data($data=['aud_id'=>'11','acd_id'=>'2','type'=>'weight','s_time'=>'2024-04-01 10:10:10','e_time'=>'2024-04-11 10:10:10']){
|
|
||||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('acd_id', $data) || !array_key_exists('type', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
|
||||||
return $this->msg(10001);
|
|
||||||
}
|
|
||||||
$user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('target_weight,initial_weight,initial_date')->find();
|
|
||||||
// dump($user_data);
|
|
||||||
if($user_data){
|
|
||||||
if($user_data['initial_date']){
|
|
||||||
$result_data['target_weight'] = $user_data['target_weight'].'kg';
|
|
||||||
$result_data['initial_weight'] = $user_data['initial_weight'].'kg';
|
|
||||||
$result_data['initial_date'] = $this->daysSince($user_data['initial_date']).'天';
|
|
||||||
}else{
|
|
||||||
$result_data['target_weight'] = '';
|
|
||||||
$result_data['initial_weight'] = '';
|
|
||||||
$result_data['initial_date'] = '';
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return $this->msg(10003);
|
|
||||||
}
|
|
||||||
$user_data_list = Db::query("select record_time,weight,bmi,muscleval,fat_w from app_card_body_data where aud_id='".$data['aud_id']."'and record_time between '".$data['s_time']."' and '".$data['e_time']."' order by record_time desc");
|
|
||||||
|
|
||||||
if(in_array($data['type'], ['weight','muscleval','fat_w','bmi'])){
|
|
||||||
$data_arr = [];
|
|
||||||
foreach ($user_data_list as $key => $value) {
|
|
||||||
$data_arr[] = [$value[$data['type']],$value['record_time']];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dump($result_data['target_weight']);
|
|
||||||
// dump($result_data['initial_weight']);
|
|
||||||
// die;
|
|
||||||
$cumulative_weight = $user_data['target_weight']-$user_data['initial_weight'];
|
|
||||||
|
|
||||||
if($cumulative_weight >= 0){
|
|
||||||
$result_data['cumulative_weight'] = [$cumulative_weight.'kg','累计减重'];
|
|
||||||
}else {
|
|
||||||
$result_data['cumulative_weight'] = [abs($cumulative_weight).'kg','累计增重'];
|
|
||||||
}
|
|
||||||
// if($user_data){
|
|
||||||
|
|
||||||
// }
|
|
||||||
$result_data['list'] = $data_arr;
|
|
||||||
return $this->msg([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取各类历史数据记录信息列表
|
|
||||||
public function get_all_record_data($data){
|
|
||||||
|
|
||||||
$result = Db::query("
|
|
||||||
select
|
|
||||||
id,
|
|
||||||
CONVERT(varchar(10), record_time, 120) AS r_t,
|
|
||||||
CONVERT(varchar(19), record_time, 120) AS record_time,
|
|
||||||
".$this->db_content[$data['acd_id']]."
|
|
||||||
from ".$this->db_name[$data['acd_id']]."
|
|
||||||
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");
|
|
||||||
// dump($result);
|
|
||||||
// die;
|
|
||||||
$return_result = [];
|
|
||||||
foreach ($result as $key => $value) {
|
|
||||||
$result[$key]['v1_name'] = '身高';
|
|
||||||
$result[$key]['v2_name'] = '体重';
|
|
||||||
$result[$key]['v3_name'] = 'BMI';
|
|
||||||
if(array_key_exists($value['r_t'], $return_result)){
|
|
||||||
array_push($return_result[$value['r_t']], ['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']);
|
|
||||||
}else{
|
|
||||||
$return_result[$value['r_t']] = [['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dump($result);
|
|
||||||
// dump($return_result);
|
|
||||||
// die;
|
|
||||||
return $this->msg(['original'=>$result,'optimization'=>$return_result]);
|
|
||||||
// return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 身体数据对比
|
|
||||||
public function body_data_contrast($data = ['acd_id'=>'2','data'=>[1,10]]){
|
|
||||||
$between_num = implode(',',$data['data']);
|
|
||||||
$calculate_arr = [];
|
|
||||||
$result = Db::query("
|
|
||||||
select
|
|
||||||
acbd.id,
|
|
||||||
acbd.height,
|
|
||||||
acbd.weight,
|
|
||||||
acbd.bmi,
|
|
||||||
acbd.fat_w,
|
|
||||||
acbd.record_time,
|
|
||||||
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '/') AS b_time,
|
|
||||||
aud.nickname,
|
|
||||||
aud.gender,
|
|
||||||
aud.birthday
|
|
||||||
from app_card_body_data as acbd
|
|
||||||
left join app_user_data as aud on acbd.aud_id=aud.id
|
|
||||||
where acbd.id in (".$between_num.")
|
|
||||||
");
|
|
||||||
if(!$result || count($result)<2){
|
|
||||||
return $this->msg(10003);
|
|
||||||
}
|
|
||||||
foreach ($data['data'] as $key => $value) {
|
|
||||||
foreach ($result as $k => $v) {
|
|
||||||
if($value == $v['id']){
|
|
||||||
array_push($calculate_arr, $v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$return_data['nickname'] = $calculate_arr[0]['nickname'];
|
|
||||||
if($calculate_arr[0]['gender']==1){
|
|
||||||
$return_data['gender'] = '男';
|
|
||||||
}else if ($calculate_arr[0]['gender']==2) {
|
|
||||||
$return_data['gender'] = '女';
|
|
||||||
}else{
|
|
||||||
$return_data['gender'] = '保密';
|
|
||||||
}
|
|
||||||
// bcsub(,,20)
|
|
||||||
$return_data['age'] = $this->calculate_age($calculate_arr[0]['birthday']);
|
|
||||||
$return_data['time'] = $this->daysSince($calculate_arr[0]['record_time'],$calculate_arr[1]['record_time']);
|
|
||||||
$return_data['weight_loss'] = bcsub($calculate_arr[1]['weight'],$calculate_arr[0]['weight'],1);
|
|
||||||
$return_data['reduce_fat'] = bcsub(explode(',',$calculate_arr[1]['fat_w'])[0],explode(',',$calculate_arr[0]['fat_w'])[0],2);
|
|
||||||
$return_data['between_time'] = $calculate_arr[0]['b_time'].'-'.$calculate_arr[1]['b_time'];
|
|
||||||
$return_data['execl_data']['height'] = ['身高',bcsub($calculate_arr[1]['height'],$calculate_arr[0]['height'],1),$calculate_arr[0]['height'],$calculate_arr[1]['height']];
|
|
||||||
$return_data['execl_data']['weight'] = ['体重',bcsub($calculate_arr[1]['weight'],$calculate_arr[0]['weight'],1),$calculate_arr[0]['weight'],$calculate_arr[1]['weight']];
|
|
||||||
$return_data['execl_data']['bmi'] = ['BMI',bcsub($calculate_arr[1]['bmi'],$calculate_arr[0]['bmi'],1),$calculate_arr[0]['bmi'],$calculate_arr[1]['bmi']];
|
|
||||||
// dump($return_data);
|
|
||||||
// die;
|
|
||||||
return $this->msg($return_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
################################################################身体数据卡片业务
|
|
||||||
// 用户身体数据卡片记录
|
|
||||||
public function set_user_body_data($data){
|
|
||||||
// if(!array_key_exists('time', $data) || !array_key_exists('height', $data) || !array_key_exists('weight', $data)){
|
|
||||||
// return $this->msg(10001,'数据格式错误');
|
|
||||||
// }
|
|
||||||
$data['type'] = 1;
|
|
||||||
$user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('birthday,gender')->find();
|
|
||||||
if(!$user_data){
|
|
||||||
return $this->msg(10003);
|
|
||||||
}
|
|
||||||
$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['adc'] = array_key_exists('impedance', $data)?$data['impedance']:550;
|
|
||||||
$calculate_body_formula = new Calculatebody();
|
|
||||||
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
|
||||||
$get_body_value['gender'] = $user_data['gender'];
|
|
||||||
$get_body_value['birthday'] = $user_data['birthday'];
|
|
||||||
$get_body_value = $this->hwb_standard($get_body_value);
|
|
||||||
// dump($get_body_value);
|
|
||||||
// // dump($get_body_value['脂肪率']);
|
|
||||||
// // dump(implode(',',$get_body_value['脂肪率']));
|
|
||||||
// die;
|
|
||||||
$set_user_data = Db::table('app_card_body_data')->insert([
|
|
||||||
'acd_id'=>$data['acd_id'],
|
|
||||||
'aud_id'=>$data['aud_id'],
|
|
||||||
'record_time'=>$data['time'],
|
|
||||||
'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['身高'],
|
|
||||||
'height_data'=>$get_body_value['身高2'],
|
|
||||||
'weight'=>$get_body_value['体重'],
|
|
||||||
'weight_data'=>$get_body_value['体重2'],
|
|
||||||
'bmi'=>$get_body_value['BMI'],
|
|
||||||
'bmi_data'=>$get_body_value['BMI2'],
|
|
||||||
'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['身体类型']
|
|
||||||
]);
|
|
||||||
if($set_user_data){
|
|
||||||
// 返回简要数据
|
|
||||||
if($data['type'] == 1){
|
|
||||||
return $this->msg(['acd_id'=>2,'height'=>$get_body_value['身高'].',CM','weight'=>$get_body_value['体重'].',公斤','bmi'=>$get_body_value['BMI']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
return $this->msg(10002);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
################################################card_data_detailed
|
||||||
// 用户身体数据卡片获取
|
// 用户身体数据卡片获取
|
||||||
public function get_user_body_data($data){
|
public function get_user_body_data($data){
|
||||||
$result = Db::table('app_card_body_data')
|
$result = Db::table('app_card_body_data')
|
||||||
->alias('acbd')
|
->alias('acbd')
|
||||||
->join('app_user_data aud','acbd.aud_id = aud.id','LEFT')
|
->join('app_user_data aud','acbd.aud_id = aud.id','LEFT')
|
||||||
->where(['acbd.aud_id'=>$data['aud_id']])
|
->where(['acbd.aud_id'=>$data['aud_id']])
|
||||||
->order('record_time desc')
|
->order('record_time desc')
|
||||||
->field('acbd.*,aud.birthday,aud.gender')
|
->field('acbd.*,aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date')
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
// dump($data);
|
|
||||||
// dump($result['age']);
|
|
||||||
// $result['age'] = 14;
|
|
||||||
// die;
|
|
||||||
if(!$result){
|
if(!$result){
|
||||||
return $this->msg(10003);
|
return $this->msg(10004);
|
||||||
}else{
|
}else{
|
||||||
|
// $curve_bottom = $this->card_curve_target_action($result);
|
||||||
$result_end = $this->processing_return_data_new($result);
|
$result_end = $this->processing_return_data_new($result);
|
||||||
// dump($result_end);
|
|
||||||
// die;
|
|
||||||
return $this->msg($result_end);
|
return $this->msg($result_end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回数据处理
|
// 返回数据处理
|
||||||
public function processing_return_data_new($data){
|
public function processing_return_data_new($data){
|
||||||
// dump($data);
|
// dump($data);
|
||||||
|
|
@ -514,6 +285,101 @@ class Card extends Base{
|
||||||
return $result_end_data;
|
return $result_end_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################card_curve_chart
|
||||||
|
|
||||||
|
// 曲线图动作函数
|
||||||
|
public function curve_chart_action($data){
|
||||||
|
$card_body_curve_arr = implode(',',$this->card_body_curve_arr);
|
||||||
|
$user_data_list = Db::query("
|
||||||
|
select
|
||||||
|
record_time,
|
||||||
|
$card_body_curve_arr
|
||||||
|
from app_card_body_data
|
||||||
|
where aud_id='".$data['aud_id']."'
|
||||||
|
and record_time between '".$data['s_time']."'
|
||||||
|
and '".$data['e_time']."'
|
||||||
|
order by record_time desc
|
||||||
|
");
|
||||||
|
$data_arr = [];
|
||||||
|
if(count($user_data_list)>0){
|
||||||
|
foreach ($this->card_body_curve_arr as $key => $value) {
|
||||||
|
$temporary_arr = [];
|
||||||
|
$temporary_arr['title'] = $this->card_body_curve_arr2[$key];
|
||||||
|
$temporary_arr['key'] = $value;
|
||||||
|
$temporary_arr['line']['categories'] = [];
|
||||||
|
$temporary_arr['line']['series'][0]['color'] = $this->card_body_curve_arr3[$key];
|
||||||
|
$temporary_arr['line']['series'][0]['data'] = [];
|
||||||
|
foreach ($user_data_list as $k => $v) {
|
||||||
|
array_push($temporary_arr['line']['categories'],$user_data_list[$k]['record_time']);
|
||||||
|
array_push($temporary_arr['line']['series'][0]['data'],$user_data_list[$k][$value]);
|
||||||
|
}
|
||||||
|
array_push($data_arr,$temporary_arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->msg($data_arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################card_manual_recording
|
||||||
|
// 用户身体数据卡片记录
|
||||||
|
public function set_user_body_data($data){
|
||||||
|
|
||||||
|
$data['type'] = 1;
|
||||||
|
$user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('birthday,gender')->find();
|
||||||
|
if(!$user_data){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
$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['adc'] = array_key_exists('impedance', $data)?$data['impedance']:550;
|
||||||
|
$calculate_body_formula = new Calculatebody();
|
||||||
|
$get_body_value = $calculate_body_formula->calculate_body_data_result($result_data);
|
||||||
|
$get_body_value['gender'] = $user_data['gender'];
|
||||||
|
$get_body_value['birthday'] = $user_data['birthday'];
|
||||||
|
$get_body_value = $this->hwb_standard($get_body_value);
|
||||||
|
// dump($get_body_value);
|
||||||
|
// dump($get_body_value['脂肪率']);
|
||||||
|
// dump(implode(',',$get_body_value['脂肪率']));
|
||||||
|
// die;
|
||||||
|
$set_user_data = Db::table('app_card_body_data')->insert([
|
||||||
|
'acd_id'=>$data['acd_id'],
|
||||||
|
'aud_id'=>$data['aud_id'],
|
||||||
|
'record_time'=>$data['time'],
|
||||||
|
'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['身高'],
|
||||||
|
'height_data'=>$get_body_value['身高2'],
|
||||||
|
'weight'=>$get_body_value['体重'],
|
||||||
|
'weight_data'=>$get_body_value['体重2'],
|
||||||
|
'bmi'=>$get_body_value['BMI'],
|
||||||
|
'bmi_data'=>$get_body_value['BMI2'],
|
||||||
|
'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['身体类型']
|
||||||
|
]);
|
||||||
|
if($set_user_data){
|
||||||
|
// 返回简要数据
|
||||||
|
if($data['type'] == 1){
|
||||||
|
return $this->msg(['acd_id'=>2,'height'=>$get_body_value['身高'].',CM','weight'=>$get_body_value['体重'].',公斤','bmi'=>$get_body_value['BMI']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return $this->msg(10002);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 添加身高体重bmi的标准
|
// 添加身高体重bmi的标准
|
||||||
public function hwb_standard($data){
|
public function hwb_standard($data){
|
||||||
|
|
@ -565,16 +431,25 @@ class Card extends Base{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// dump($linshi_data);
|
||||||
|
// die;
|
||||||
foreach ($linshi_data as $key => $value) {
|
foreach ($linshi_data as $key => $value) {
|
||||||
|
// dump($value);
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if($data[$key] > $v['min_val'] && $data[$key] < $v['max_val']){
|
if($data[$key] >= $v['min_val'] && $data[$key] < $v['max_val']){
|
||||||
|
// 如果落在区间内
|
||||||
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
|
$data[$key.'2'] = $data[$key].','.$v['text'].','.$v['color'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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{
|
}else{
|
||||||
$data['身高2'] = $data['身高'].',无,无';
|
$data['身高2'] = $data['身高'].',无,无';
|
||||||
$data['体重2'] = $data['身高'].',无,无';
|
$data['体重2'] = $data['身高'].',无,无';
|
||||||
|
|
@ -584,15 +459,100 @@ class Card extends Base{
|
||||||
return $data;
|
return $data;
|
||||||
// dump($data);
|
// dump($data);
|
||||||
}
|
}
|
||||||
|
################################################get_card_record_data
|
||||||
|
// 获取历史数据记录信息列表
|
||||||
|
public function get_all_record_data($data){
|
||||||
|
|
||||||
|
$result = Db::query("
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
CONVERT(varchar(10), record_time, 120) AS r_t,
|
||||||
|
CONVERT(varchar(19), record_time, 120) AS record_time,
|
||||||
|
".$this->db_content[$data['acd_id']]."
|
||||||
|
from ".$this->db_name[$data['acd_id']]."
|
||||||
|
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");
|
||||||
|
// dump($result);
|
||||||
|
// die;
|
||||||
|
$return_result = [];
|
||||||
|
foreach ($result as $key => $value) {
|
||||||
|
$result[$key]['v1_name'] = '身高';
|
||||||
|
$result[$key]['v2_name'] = '体重';
|
||||||
|
$result[$key]['v3_name'] = 'BMI';
|
||||||
|
if(array_key_exists($value['r_t'], $return_result)){
|
||||||
|
array_push($return_result[$value['r_t']], ['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']);
|
||||||
|
}else{
|
||||||
|
$return_result[$value['r_t']] = [['id'=>$value['id'],'v1'=>$value['v1'],'v2'=>$value['v2'],'v3'=>$value['v3'],'v1_name'=>'身高','v2_name'=>'体重','v3_name'=>'BMI']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->msg(['original'=>$result,'optimization'=>$return_result]);
|
||||||
|
// return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
################################################################其他接口################################################################
|
||||||
|
################################################################其他接口################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################跳绳数据卡片接口################################################################
|
|
||||||
################################################################跳绳数据卡片接口################################################################
|
// 身体数据对比
|
||||||
|
public function body_data_contrast($data = ['acd_id'=>'2','data'=>[1,10]]){
|
||||||
|
$between_num = implode(',',$data['data']);
|
||||||
|
$calculate_arr = [];
|
||||||
|
$result = Db::query("
|
||||||
|
select
|
||||||
|
acbd.id,
|
||||||
|
acbd.height,
|
||||||
|
acbd.weight,
|
||||||
|
acbd.bmi,
|
||||||
|
acbd.fat_w,
|
||||||
|
acbd.record_time,
|
||||||
|
REPLACE(CONVERT(varchar(10), acbd.record_time, 23), '-', '/') AS b_time,
|
||||||
|
aud.nickname,
|
||||||
|
aud.gender,
|
||||||
|
aud.birthday
|
||||||
|
from app_card_body_data as acbd
|
||||||
|
left join app_user_data as aud on acbd.aud_id=aud.id
|
||||||
|
where acbd.id in (".$between_num.")
|
||||||
|
");
|
||||||
|
if(!$result || count($result)<2){
|
||||||
|
return $this->msg(10003);
|
||||||
|
}
|
||||||
|
foreach ($data['data'] as $key => $value) {
|
||||||
|
foreach ($result as $k => $v) {
|
||||||
|
if($value == $v['id']){
|
||||||
|
array_push($calculate_arr, $v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_data['nickname'] = $calculate_arr[0]['nickname'];
|
||||||
################################################################other################################################################
|
if($calculate_arr[0]['gender']==1){
|
||||||
################################################################other################################################################
|
$return_data['gender'] = '男';
|
||||||
################################################################other################################################################
|
}else if ($calculate_arr[0]['gender']==2) {
|
||||||
|
$return_data['gender'] = '女';
|
||||||
|
}else{
|
||||||
|
$return_data['gender'] = '保密';
|
||||||
|
}
|
||||||
|
// bcsub(,,20)
|
||||||
|
$return_data['age'] = $this->calculate_age($calculate_arr[0]['birthday']);
|
||||||
|
$return_data['time'] = $this->daysSince($calculate_arr[0]['record_time'],$calculate_arr[1]['record_time']);
|
||||||
|
$return_data['weight_loss'] = bcsub($calculate_arr[1]['weight'],$calculate_arr[0]['weight'],1);
|
||||||
|
$return_data['reduce_fat'] = bcsub(explode(',',$calculate_arr[1]['fat_w'])[0],explode(',',$calculate_arr[0]['fat_w'])[0],2);
|
||||||
|
$return_data['between_time'] = $calculate_arr[0]['b_time'].'-'.$calculate_arr[1]['b_time'];
|
||||||
|
$return_data['execl_data']['height'] = ['身高',bcsub($calculate_arr[1]['height'],$calculate_arr[0]['height'],1),$calculate_arr[0]['height'],$calculate_arr[1]['height']];
|
||||||
|
$return_data['execl_data']['weight'] = ['体重',bcsub($calculate_arr[1]['weight'],$calculate_arr[0]['weight'],1),$calculate_arr[0]['weight'],$calculate_arr[1]['weight']];
|
||||||
|
$return_data['execl_data']['bmi'] = ['BMI',bcsub($calculate_arr[1]['bmi'],$calculate_arr[0]['bmi'],1),$calculate_arr[0]['bmi'],$calculate_arr[1]['bmi']];
|
||||||
|
// dump($return_data);
|
||||||
|
// die;
|
||||||
|
return $this->msg($return_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\app\controller;
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
use app\bj\controller\Common;
|
||||||
|
use think\Log;
|
||||||
|
use \think\Validate;
|
||||||
|
use app\app\controller\Calculatebody;
|
||||||
|
use app\app\controller\Skip;
|
||||||
|
|
||||||
|
class Cardparts extends Base{
|
||||||
|
|
||||||
|
protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6'];
|
||||||
|
protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data'];
|
||||||
|
|
||||||
|
|
||||||
|
// 计算部分内容的横线标准以及说明文字
|
||||||
|
public function hwb_standard($data){
|
||||||
|
|
||||||
|
// dump($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取指定用户详细信息
|
// 获取指定用户详细信息
|
||||||
public function get_user_data_information($data = ['aud_id'=>20,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
public function get_user_data_information($data = ['aud_id'=>25,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||||
if(count(input()) > 0){
|
if(count(input()) > 0){
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
|
|
@ -218,9 +218,54 @@ class Index extends Base{
|
||||||
$db_arr = [];
|
$db_arr = [];
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$db_arr[$value] = Db::table($this->db_name[$value])->where(['aud_id'=>$aud_id,'is_del'=>'0'])->order('id desc')->limit(1)->select();
|
$db_arr[$value] = Db::table($this->db_name[$value])->where(['aud_id'=>$aud_id,'is_del'=>'0'])->order('id desc')->limit(1)->select();
|
||||||
$db_arr[$value] = $db_arr[$value][0];
|
// dump($db_arr[$value]);
|
||||||
|
|
||||||
|
if(count($db_arr[$value]) > 0){
|
||||||
|
$db_arr[$value] = $db_arr[$value][0];
|
||||||
|
}else{
|
||||||
|
unset($db_arr[$value]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($db_arr) <= 0){
|
||||||
|
// 没有数据,传递一个空的卡片
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'id'=>'',
|
||||||
|
'acd_id'=>'2',
|
||||||
|
'record_time'=>'',
|
||||||
|
'card_name'=>'身体数据',
|
||||||
|
'inside_data'=>[
|
||||||
|
[
|
||||||
|
'key'=>'',
|
||||||
|
'name'=>'身高',
|
||||||
|
'value'=>'',
|
||||||
|
'unit'=>'cm',
|
||||||
|
'standard'=>'',
|
||||||
|
'color'=>'',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key'=>'',
|
||||||
|
'name'=>'体重',
|
||||||
|
'value'=>'',
|
||||||
|
'unit'=>'公斤',
|
||||||
|
'standard'=>'',
|
||||||
|
'color'=>'',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key'=>'',
|
||||||
|
'name'=>'BMI',
|
||||||
|
'value'=>'',
|
||||||
|
'unit'=>'',
|
||||||
|
'standard'=>'',
|
||||||
|
'color'=>'',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// dump($db_arr);
|
||||||
|
// die;
|
||||||
foreach ($db_arr as $key => $value) {
|
foreach ($db_arr as $key => $value) {
|
||||||
$temporary_arr = [];
|
$temporary_arr = [];
|
||||||
$temporary_arr['id'] = $value['id'];
|
$temporary_arr['id'] = $value['id'];
|
||||||
|
|
@ -245,7 +290,8 @@ class Index extends Base{
|
||||||
}
|
}
|
||||||
array_push($result,$temporary_arr);
|
array_push($result,$temporary_arr);
|
||||||
}
|
}
|
||||||
|
// dump($result);
|
||||||
|
// die;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ class Login extends Base{
|
||||||
$result = Db::table('app_account_number')->insertGetId($verify_result);
|
$result = Db::table('app_account_number')->insertGetId($verify_result);
|
||||||
if($result){
|
if($result){
|
||||||
cache($verify_result['token'], time());
|
cache($verify_result['token'], time());
|
||||||
return $this->msg(0,'success',['token'=>$verify_result['token'],'aan_id'=>$result]);
|
return $this->msg(['token'=>$verify_result['token'],'aan_id'=>$result]);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10003,'注册失败');
|
return $this->msg(10002);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 重置密码
|
// 重置密码
|
||||||
|
|
@ -45,11 +45,11 @@ class Login extends Base{
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['password'] != $data['c_password']){
|
if($data['password'] != $data['c_password']){
|
||||||
return $this->msg(10002,'两次密码不一致');
|
return $this->msg(10003,'两次密码不一致');
|
||||||
}
|
}
|
||||||
$code_result = $this->check_code($data['data'],$data['code']);
|
$code_result = $this->check_code($data['data'],$data['code']);
|
||||||
if($code_result !== true){
|
if($code_result !== true){
|
||||||
|
|
@ -57,18 +57,18 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
$t_y = $this->is_tel_email($data['data']);
|
$t_y = $this->is_tel_email($data['data']);
|
||||||
if($t_y === false){
|
if($t_y === false){
|
||||||
return $this->msg(10004,'账号格式错误');
|
return $this->msg(10003,'账号格式错误');
|
||||||
}
|
}
|
||||||
$find_data = Db::table('app_account_number')->where([$t_y=>$data['data']])->field('id,token')->find();
|
$find_data = Db::table('app_account_number')->where([$t_y=>$data['data']])->field('id,token')->find();
|
||||||
if(!$find_data){
|
if(!$find_data){
|
||||||
return $this->msg(10006,'未核实到账号信息');
|
return $this->msg(10003);
|
||||||
}
|
}
|
||||||
$result = Db::table('app_account_number')->where([$t_y=>$data['data']])->update(['password'=>$data['password']]);
|
$result = Db::table('app_account_number')->where([$t_y=>$data['data']])->update(['password'=>$data['password']]);
|
||||||
if($result){
|
if($result){
|
||||||
cache($find_data['token'], time());
|
cache($find_data['token'], time());
|
||||||
return $this->msg(0,'success',['token'=>$find_data['token'],'aan_id'=>$find_data['id']]);
|
return $this->msg(['token'=>$find_data['token'],'aan_id'=>$find_data['id']]);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10005,'注册失败');
|
return $this->msg(10002);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ class Login extends Base{
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
// 检测是否为手机
|
// 检测是否为手机
|
||||||
if (preg_match('/^\d{11}$/', $data['data'])) {
|
if (preg_match('/^\d{11}$/', $data['data'])) {
|
||||||
|
|
@ -103,24 +103,24 @@ class Login extends Base{
|
||||||
$result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find();
|
$result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find();
|
||||||
if($result){
|
if($result){
|
||||||
cache($result['token'], time());
|
cache($result['token'], time());
|
||||||
return $this->msg(0,'success',['token'=>$result['token'],'aan_id'=>$result['id']]);
|
return $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10002,'登录失败,无效账号');
|
return $this->msg(10003);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'登录失败,验证码错误或失效');
|
return $this->msg(10003,'登录失败,验证码错误或失效');
|
||||||
}
|
}
|
||||||
}else if($data['validate_type'] == 'password'){
|
}else if($data['validate_type'] == 'password'){
|
||||||
$verify_result['password'] = $data['validate_data'];
|
$verify_result['password'] = $data['validate_data'];
|
||||||
$result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find();
|
$result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find();
|
||||||
if($result){
|
if($result){
|
||||||
cache($result['token'], time());
|
cache($result['token'], time());
|
||||||
return $this->msg(0,'success',['token'=>$result['token'],'aan_id'=>$result['id']]);
|
return $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]);
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'登录失败,账号/密码错误');
|
return $this->msg(10003,'登录失败,账号/密码错误');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10002,'校验参数错误');
|
return $this->msg(10003,'校验参数错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +137,7 @@ class Login extends Base{
|
||||||
$data = input();
|
$data = input();
|
||||||
}
|
}
|
||||||
if(!array_key_exists('data', $data) || !array_key_exists('type', $data)){
|
if(!array_key_exists('data', $data) || !array_key_exists('type', $data)){
|
||||||
return $this->msg(10001,'数据&场景&通道必须');
|
return $this->msg(10001);
|
||||||
}
|
}
|
||||||
$num = $this->rand_int();
|
$num = $this->rand_int();
|
||||||
if (preg_match('/^\d{11}$/', $data['data'])) {
|
if (preg_match('/^\d{11}$/', $data['data'])) {
|
||||||
|
|
@ -150,10 +150,10 @@ class Login extends Base{
|
||||||
if(is_array($result) && $result['code'] == 0){
|
if(is_array($result) && $result['code'] == 0){
|
||||||
cache($data['data'], $num, $this->code_time);
|
cache($data['data'], $num, $this->code_time);
|
||||||
// dump($data['data']."_".$data['road']."_".$data['type']);
|
// dump($data['data']."_".$data['road']."_".$data['type']);
|
||||||
return $this->msg(0,'success',$num);
|
return $this->msg(['code'=>$num]);
|
||||||
// return true;
|
// return true;
|
||||||
}else{
|
}else{
|
||||||
return $this->msg(10001,'error');
|
return $this->msg(10002);
|
||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,10 +199,10 @@ class Login extends Base{
|
||||||
|
|
||||||
//发送
|
//发送
|
||||||
if (!$mail->Send()) {
|
if (!$mail->Send()) {
|
||||||
return $this->msg(10001,$mail->ErrorInfo);
|
return $this->msg(10003,$mail->ErrorInfo);
|
||||||
// return $mail->ErrorInfo;
|
// return $mail->ErrorInfo;
|
||||||
} else {
|
} else {
|
||||||
return $this->msg(0,'success');
|
return $this->msg([]);
|
||||||
// return 'success';
|
// return 'success';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ Route::any('/vitalcapacity_data_set', 'app/vitalcapacity/vitalcapacity_data_set'
|
||||||
Route::any('/generateRandomJumpData', 'app/skip/generateRandomJumpData');
|
Route::any('/generateRandomJumpData', 'app/skip/generateRandomJumpData');
|
||||||
Route::any('/setdb', 'app/skip/setdb');
|
Route::any('/setdb', 'app/skip/setdb');
|
||||||
Route::any('/readexcel', 'admin/execlaa/readexcel');
|
Route::any('/readexcel', 'admin/execlaa/readexcel');
|
||||||
Route::any('/demo_db', 'app/login/demo_db');
|
Route::any('/card_curve_target_action', 'app/card/card_curve_target_action');
|
||||||
|
|
||||||
|
|
||||||
// Route::any('/isNumericArray', 'app/base/isNumericArray');
|
// Route::any('/isNumericArray', 'app/base/isNumericArray');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue