测试版9月27修改(公共接口的删除数据问题,数据记录都得是最后一次成绩问题,添加卡片内时间问题等)
This commit is contained in:
parent
e1d0159046
commit
0b736cc355
|
|
@ -306,6 +306,7 @@ Route::any('/use_test', 'admin/base/use_test');
|
|||
|
||||
|
||||
Route::any('/ceshiyong', 'app/base/ceshiyong');
|
||||
Route::any('/testedition/ceshiyong', 'testapp/base/ceshiyong');
|
||||
|
||||
|
||||
// Route::any('/app_update_file/*', 'app/sportstesting/aaaaaaaaaaaaaaa');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use think\Controller;
|
|||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Base extends Controller{
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ class Base extends Controller{
|
|||
'10009'=>'',
|
||||
'10010'=>'自定义信息',
|
||||
'20001'=>'登录失效',
|
||||
'99999'=>'接口错误',
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
|
|
@ -39,7 +41,26 @@ class Base extends Controller{
|
|||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
|
||||
// 操作记录留存
|
||||
// 接口记录
|
||||
public function record_api_log($params, $error = null, $response = null){
|
||||
$logContent = "接口请求参数:" . json_encode($params, JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
||||
if ($error) {
|
||||
$logContent .= "错误信息:" . $error['all_content'] . PHP_EOL;
|
||||
if(!cache($error['flie']."_".$error['line'])){
|
||||
cache($error['flie']."_".$error['line'],"API错误",3600);
|
||||
$this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>$logContent]);
|
||||
}
|
||||
}
|
||||
if ($response) {
|
||||
$logContent .= "返回信息:" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
||||
}
|
||||
// 使用ThinkPHP的日志记录方法
|
||||
Log::record($logContent, 'api_log');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $data = ['aud_id'=>'xxxxxxxxxxxxxxx','order_list'=>[1,2,3,4,5]]
|
||||
public function abnormal_data_log_action($dacall_methoda = 0,$content='未记录的内容',$use_database_name='未记录的数据库名'){
|
||||
$result = Db::table($this->base_use_db_name['1'])->insert([
|
||||
|
|
@ -126,22 +147,6 @@ class Base extends Controller{
|
|||
|
||||
// 判断token是否过期
|
||||
public function token_time_validate($token){
|
||||
// if(in_array($token,$this->ceshiyong_token)){
|
||||
// return true;
|
||||
// }
|
||||
// $time = cache($token);
|
||||
// if($time === false){
|
||||
// Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token', 'log');
|
||||
// return false;
|
||||
// }
|
||||
// $diff_time = bcsub(time(),$time,0);
|
||||
// if($diff_time > $this->token_time){
|
||||
// Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因当前时间戳减去记录时间戳后为'.$diff_time.'秒,大于规定秒数'.$this->token_time, 'log');
|
||||
// return false;
|
||||
// }
|
||||
// cache($token, time());
|
||||
// Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的秒数为'.time(), 'log');
|
||||
// return true;
|
||||
if(is_string($token)){
|
||||
$length = strlen($token);
|
||||
if ($length < 10 ) {
|
||||
|
|
@ -151,12 +156,12 @@ class Base extends Controller{
|
|||
return false;
|
||||
}
|
||||
if(cache($token) === false){
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token,或该token已经超过30天', 'log');
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',但是更新token失败,原因没有找到该token,或该token已经超过30天', 'token_log');
|
||||
return false;
|
||||
}
|
||||
$time_now = date('Y-m-d H:i:s');
|
||||
cache($token,$time_now,$this->token_time);
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.$time_now, 'log');
|
||||
Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.$time_now, 'token_log');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -426,44 +431,66 @@ class Base extends Controller{
|
|||
}
|
||||
|
||||
|
||||
/* 接口说明(发邮件)
|
||||
* $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......]
|
||||
* $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123']
|
||||
* $annex(附件路径信息) 字符串
|
||||
*/
|
||||
public function send_email_api_error($address,$content,$annex=''){
|
||||
// $ad = '460834639@qq.com';
|
||||
$ad1 = '295155911@qq.com';
|
||||
$mail = new PHPMailer(); //实例化
|
||||
$mail->IsSMTP(); // 启用SMTP
|
||||
$mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子
|
||||
$mail->Port = 465; //邮件发送端口
|
||||
$mail->SMTPAuth = true; //启用SMTP认证
|
||||
$mail->SMTPSecure = 'ssl';
|
||||
$mail->CharSet = "UTF-8"; //字符集
|
||||
$mail->Encoding = "base64"; //编码方式
|
||||
$mail->Username = "tsf3920322@126.com"; //你的邮箱
|
||||
$mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码)
|
||||
$mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱)
|
||||
|
||||
// $mail->Subject = "微盟测试邮件"; //邮件标题
|
||||
$mail->Subject = $content['title']; //邮件标题
|
||||
|
||||
// $mail->FromName = "微盟体测中心"; //发件人姓名
|
||||
$mail->FromName = $content['from_user_name']; //发件人姓名
|
||||
|
||||
|
||||
for ($i=0; $i < count($address); $i++) {
|
||||
$mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称)
|
||||
}
|
||||
|
||||
if($annex != ''){
|
||||
// $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg';
|
||||
$mail->AddAttachment($annex,''); // 添加附件,并指定名称
|
||||
}
|
||||
|
||||
$mail->IsHTML(true); //支持html格式内容
|
||||
|
||||
$neirong = $content['content'];
|
||||
|
||||
$mail->Body = $neirong; //邮件主体内容
|
||||
// dump($address);
|
||||
// die;
|
||||
//发送
|
||||
if (!$mail->Send()) {
|
||||
|
||||
return ['code' => 10003,'msg'=>$mail->ErrorInfo];
|
||||
// return $mail->ErrorInfo;
|
||||
} else {
|
||||
return ['code' => 0];
|
||||
// return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function ceshiyong($aa = 4,$gd = 0.2){
|
||||
$token = 'caadd1be045a65f30b92aa805f1de54a';
|
||||
$jieguo = $this->token_time_validate($token);
|
||||
// // // Log::record('用户尝试更新token时间,token:' . $token, 'log');
|
||||
// // // phpinfo();
|
||||
// // dump($jieguo);
|
||||
// // // return $jieguo;
|
||||
// // die;
|
||||
// // cache($token, time());
|
||||
$time = cache($token);
|
||||
dump($jieguo);
|
||||
dump($time);
|
||||
// // die;
|
||||
|
||||
|
||||
|
||||
|
||||
// $aa = 3;
|
||||
// dump($aa/20);
|
||||
$a = $aa;
|
||||
for ($i=0; $i < 100; $i++) {
|
||||
dump($a.'======='.$a/$aa*100);
|
||||
$a = $a - $gd;
|
||||
if($a < 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// $aa = 15;
|
||||
// $a = 1;
|
||||
// for ($i=0; $i < 100; $i++) {
|
||||
// dump($aa.'======='.$aa/17.5*100);
|
||||
// $aa = $aa - $a;
|
||||
// if($aa < 1){
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
dump('ok');
|
||||
$this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'青测API','content'=>'123']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,117 +22,268 @@ class Cardpublic extends Base{
|
|||
['min_val'=>'90','max_val'=>'150','text'=>'优秀','color'=>'#6691EF'],
|
||||
];
|
||||
|
||||
// // 示意接口
|
||||
// public function card_curve_chart($data = ['aud_id'=>'83','s_time'=>'2024-04-01','e_time'=>'2024-07-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
// if(count(input('post.')) > 0){
|
||||
// $data = input('post.');
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
// // if($this->token_time_validate($data['token']) === false){
|
||||
// // return $this->msg(20001);
|
||||
// // }
|
||||
// unset($data['token']);
|
||||
// }
|
||||
|
||||
// 获取卡片数据
|
||||
public function get_card_content($data = ['aud_id'=>'83','acd_id'=>'10','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
// try {
|
||||
// // 你的业务逻辑
|
||||
// // 成功
|
||||
// $this->record_api_log($data, null, $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,'接口错误');
|
||||
// }
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('acd_id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
// dump(111);
|
||||
// die;
|
||||
return $this->get_card_content_action($data);
|
||||
$return_data = $this->get_card_content_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,'接口错误');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// {"acd_id":"11","name":"200米","record_time":"2024-09-27","data":"02:00","aud_id":"1","token":"57bd45e3a963b372ea2d873e4bd8d1f8","aan_id":"1"}
|
||||
// 存储信息
|
||||
public function data_save($data = ['aud_id'=>'83','acd_id'=>'10','name'=>'50米','data'=>'10.3','record_time'=>'2024-09-06','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
public function data_save($data = ['aud_id'=>'1','acd_id'=>'11','name'=>'200米','data'=>'02:00','record_time'=>'2024-09-27','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('acd_id', $data) || !array_key_exists('name', $data) || !array_key_exists('data', $data) || !array_key_exists('record_time', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
$return_data = $this->data_save_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,'接口错误');
|
||||
}
|
||||
|
||||
return $this->data_save_action($data);
|
||||
}
|
||||
|
||||
// 获取标签项目信息
|
||||
public function get_label_list($data = ['aud_id'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
return $this->get_label_list_action($data);
|
||||
$return_data = $this->get_label_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,'接口错误');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 卡片运动曲线
|
||||
public function card_motion_curve($data = ['aud_id'=>'1','acd_id'=>'10','s_time'=>'2024-04-01','e_time'=>'2024-07-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
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);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
return $this->card_motion_curve_action($data);
|
||||
$return_data = $this->card_motion_curve_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 data_contrast_obtain_data($data = ['aud_id'=>'1','acd_id'=>'10','name'=>'1000米','s_time'=>'2024-04-01','e_time'=>'2024-10-03']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('acd_id', $data) || !array_key_exists('name', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
return $this->data_contrast_obtain_data_action($data);
|
||||
$return_data = $this->data_contrast_obtain_data_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 data_contrast_contrast_data($data = ['before_id'=>'1','after_id'=>'3']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('before_id', $data) || !array_key_exists('after_id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
return $this->data_contrast_contrast_data_action($data);
|
||||
$return_data = $this->data_contrast_contrast_data_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 obtain_history_record($data = ['aud_id'=>'1','acd_id'=>'10','name'=>'1000米','page'=>'1']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('acd_id', $data) || !array_key_exists('name', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
return $this->obtain_history_record_action($data);
|
||||
$return_data = $this->obtain_history_record_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 history_record_del($data = ['id'=>'10']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('id', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
return $this->history_record_del_action($data);
|
||||
$return_data = $this->history_record_del_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 obtain_manual_record_content($data = ['aud_id'=>1]){
|
||||
|
|
@ -162,6 +313,8 @@ class Cardpublic extends Base{
|
|||
'number'=>false,
|
||||
'type'=>4,
|
||||
'time'=>true,
|
||||
'describe'=>'时长',
|
||||
'unit'=>'',
|
||||
],
|
||||
[
|
||||
'id'=>'2',
|
||||
|
|
@ -169,6 +322,8 @@ class Cardpublic extends Base{
|
|||
'number'=>false,
|
||||
'type'=>4,
|
||||
'time'=>true,
|
||||
'describe'=>'时长',
|
||||
'unit'=>'',
|
||||
],
|
||||
[
|
||||
'id'=>'3',
|
||||
|
|
@ -176,14 +331,81 @@ class Cardpublic extends Base{
|
|||
'number'=>true,
|
||||
'type'=>2,
|
||||
'time'=>false,
|
||||
'describe'=>'时长',
|
||||
'unit'=>'秒',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'id'=>'12',
|
||||
'height'=>false,
|
||||
'weight'=>false,
|
||||
'number'=>false,
|
||||
'time'=>false,
|
||||
'list'=>[
|
||||
[
|
||||
'id'=>'7',
|
||||
'name'=>'立定跳远',
|
||||
'number'=>true,
|
||||
'type'=>1,
|
||||
'time'=>false,
|
||||
'describe'=>'距离',
|
||||
'unit'=>'CM',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'id'=>'13',
|
||||
'height'=>false,
|
||||
'weight'=>false,
|
||||
'number'=>false,
|
||||
'time'=>false,
|
||||
'list'=>[
|
||||
[
|
||||
'id'=>'8',
|
||||
'name'=>'引体向上',
|
||||
'number'=>true,
|
||||
'type'=>1,
|
||||
'time'=>false,
|
||||
'describe'=>'个数',
|
||||
'unit'=>'个',
|
||||
],
|
||||
[
|
||||
'id'=>'9',
|
||||
'name'=>'仰卧起坐',
|
||||
'number'=>true,
|
||||
'type'=>1,
|
||||
'time'=>false,
|
||||
'describe'=>'个数',
|
||||
'unit'=>'个',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'id'=>'14',
|
||||
'height'=>false,
|
||||
'weight'=>false,
|
||||
'number'=>false,
|
||||
'time'=>false,
|
||||
'list'=>[
|
||||
[
|
||||
'id'=>'10',
|
||||
'name'=>'坐位体前屈',
|
||||
'number'=>true,
|
||||
'type'=>1,
|
||||
'time'=>false,
|
||||
'describe'=>'距离',
|
||||
'unit'=>'CM',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
if($user_data['gender'] == 1){
|
||||
unset($card_data[2]['list'][1]);//800米
|
||||
unset($card_data[4]['list'][1]);//仰卧起坐
|
||||
}else if($user_data['gender'] == 2){
|
||||
unset($card_data[2]['list'][0]);//1000米
|
||||
unset($card_data[4]['list'][0]);//引体向上
|
||||
}
|
||||
foreach ($card_data as $key => $value) {
|
||||
$card_data[$key]['list'] = array_values($card_data[$key]['list']);
|
||||
|
|
@ -201,12 +423,12 @@ class Cardpublic extends Base{
|
|||
##################################################get_card_content##################################################
|
||||
public function get_card_content_action($data){
|
||||
// 查找用户是存在
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,gender')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
// 卡片是否存在,以及是否含有子项
|
||||
$card_data_sub_item = Db::table($this->cardpublic_use_db_name['2'])->where("acd_id = ".$data['acd_id']." and suit_gender LIKE '%".$user_data['gender']."%'")->field('id,type,name,unit')->select();
|
||||
$card_data_sub_item = Db::table($this->cardpublic_use_db_name['2'])->where("acd_id = ".$data['acd_id']." and is_del = 0 and suit_gender LIKE '%".$user_data['gender']."%'")->field('id,type,name,unit')->select();
|
||||
if(!$card_data_sub_item){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
|
|
@ -238,13 +460,14 @@ class Cardpublic extends Base{
|
|||
'color' => '',
|
||||
'offset' => '',
|
||||
'unit_data' => '',
|
||||
'record_time' => '',
|
||||
];
|
||||
// 添加标签
|
||||
array_push($return_data['label_list'],$value['name']);
|
||||
// 添加线性轴描述
|
||||
$return_data['line_list'] = $this->level_data;
|
||||
// 查询最后一次成绩
|
||||
$data_this_time = Db::table($this->cardpublic_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$value['id']])->order('id desc')->field('id,detailed_msg,achievement')->find();
|
||||
$data_this_time = Db::table($this->cardpublic_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$value['id'],'is_del'=>0])->order('record_time desc')->field('id,detailed_msg,achievement,record_time')->find();
|
||||
// dump($data_this_time);
|
||||
if($data_this_time){
|
||||
$data_this_time['detailed_msg'] = json_decode($data_this_time['detailed_msg'],true);
|
||||
|
|
@ -256,8 +479,9 @@ class Cardpublic extends Base{
|
|||
$temporary_arr_c['color'] = $data_this_time['detailed_msg']['color'];
|
||||
$temporary_arr_c['offset'] = $data_this_time['detailed_msg']['offset'];
|
||||
$temporary_arr_c['unit_data'] = $data_this_time['detailed_msg']['unit_data'];
|
||||
$temporary_arr_c['record_time'] = $data_this_time['record_time'];
|
||||
// 获取到该项所有数据
|
||||
$all_time_title = Db::table($this->cardpublic_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$value['id']])->order('id desc')->field('id,achievement,LEFT(record_time,10) AS r_t')->select();
|
||||
$all_time_title = Db::table($this->cardpublic_use_db_name['3'])->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$value['id'],'is_del'=>0])->order('id desc')->field('id,achievement,LEFT(record_time,10) AS r_t')->select();
|
||||
// 处理今日,以及总计数据
|
||||
if($data_this_time['detailed_msg']['unit_data'] == '分/秒'){
|
||||
// 如果是分秒形式的数据
|
||||
|
|
@ -267,7 +491,6 @@ class Cardpublic extends Base{
|
|||
// 处理本次数据最终格式
|
||||
list($minutes, $seconds) = explode(':', $data_this_time['achievement']);
|
||||
$temporary_arr_c['this_time_value'] = $minutes . '分' . sprintf('%02d', $seconds) . '秒';
|
||||
|
||||
// 计算今日总计&所有平均
|
||||
$temporary_arr_c['all_times'] = count($all_time_title);
|
||||
foreach ($all_time_title as $k1 => $v1) {
|
||||
|
|
@ -367,11 +590,11 @@ class Cardpublic extends Base{
|
|||
##################################################get_label_list##################################################
|
||||
public function get_label_list_action($data){
|
||||
// 查找用户是存在
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,gender')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
$label_data = Db::table($this->cardpublic_use_db_name['2'])->where("suit_gender LIKE '%".$user_data['gender']."%'")->field('id,acd_id,name,unit,type')->select();
|
||||
$label_data = Db::table($this->cardpublic_use_db_name['2'])->where("is_del = 0 and suit_gender LIKE '%".$user_data['gender']."%'")->field('id,acd_id,name,unit,type')->select();
|
||||
if(count($label_data)<=0){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
|
|
@ -396,12 +619,12 @@ class Cardpublic extends Base{
|
|||
|
||||
##################################################card_motion_curve##################################################
|
||||
public function card_motion_curve_action($data){
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
|
||||
$user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,gender')->find();
|
||||
if(!$user_data){
|
||||
return $this->msg(10004);
|
||||
}
|
||||
$card_sub_item_data = Db::table($this->cardpublic_use_db_name['3'])->where(['acd_id'=>$data['acd_id'],'aud_id'=>$data['aud_id']])->order('record_time desc')->field('id,acdsi_id,score,LEFT(record_time,10) as record_time')->select();
|
||||
$card_sub_item_type = Db::table($this->cardpublic_use_db_name['2'])->where("acd_id = ".$data['acd_id']." and suit_gender LIKE '%".$user_data['gender']."%'")->field('id,name,unit')->select();
|
||||
$card_sub_item_data = Db::table($this->cardpublic_use_db_name['3'])->where(['acd_id'=>$data['acd_id'],'aud_id'=>$data['aud_id'],'is_del'=>0])->order('record_time desc')->field('id,acdsi_id,score,LEFT(record_time,10) as record_time')->select();
|
||||
$card_sub_item_type = Db::table($this->cardpublic_use_db_name['2'])->where("acd_id = ".$data['acd_id']." and is_del = 0 and suit_gender LIKE '%".$user_data['gender']."%'")->field('id,name,unit')->select();
|
||||
$temporary_arr = [];
|
||||
$return_data = [];
|
||||
// 处理一个临时数据
|
||||
|
|
@ -441,10 +664,10 @@ class Cardpublic extends Base{
|
|||
public function data_contrast_obtain_data_action($data){
|
||||
// dump($data);
|
||||
// $user_data = Db::table($this->cardpublic_use_db_name['1'])->where(['id'=>$data['aud_id']])->field('id,gender')->find();
|
||||
$card_data = Db::table($this->cardpublic_use_db_name['2'])->where(['acd_id'=>$data['acd_id'],'name'=>$data['name']])->find();
|
||||
$card_data = Db::table($this->cardpublic_use_db_name['2'])->where(['acd_id'=>$data['acd_id'],'name'=>$data['name'],'is_del'=>0])->find();
|
||||
|
||||
$result_data = Db::table($this->cardpublic_use_db_name['3'])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id']])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id'],'is_del'=>0])
|
||||
->whereTime('record_time', 'between', [$data['s_time'], $data['e_time']])
|
||||
->field('id,achievement,score,unit,record_time')
|
||||
->order('record_time desc')
|
||||
|
|
@ -491,12 +714,12 @@ class Cardpublic extends Base{
|
|||
}
|
||||
##################################################obtain_history_record##################################################
|
||||
public function obtain_history_record_action($data){
|
||||
$card_data = Db::table($this->cardpublic_use_db_name['2'])->where(['acd_id'=>$data['acd_id'],'name'=>$data['name']])->find();
|
||||
$card_data = Db::table($this->cardpublic_use_db_name['2'])->where(['acd_id'=>$data['acd_id'],'name'=>$data['name'],'is_del'=>0])->find();
|
||||
$result_count = Db::table($this->cardpublic_use_db_name['3'])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id']])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id'],'is_del'=>0])
|
||||
->count();
|
||||
$result_data = Db::table($this->cardpublic_use_db_name['3'])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id']])
|
||||
->where(['aud_id'=>$data['aud_id'],'acdsi_id'=>$card_data['id'],'is_del'=>0])
|
||||
->field('id,achievement,score,unit,record_time')
|
||||
->order('record_time desc')
|
||||
->page($data['page'].",10")
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class Index extends Base{
|
|||
'6'=>'test_app_card_data',
|
||||
'7'=>'test_app_account_number',
|
||||
'8'=>'test_app_card_data_sub_item',
|
||||
'9'=>'test_app_card_data_sub_item_data',
|
||||
];
|
||||
// protected $card_key = ['2'=>'body','6'=>'skip','8'=>'vitalcapacity'];
|
||||
protected $default_card = ['2','6','8'];
|
||||
|
|
@ -58,7 +59,27 @@ class Index extends Base{
|
|||
|
||||
// 检测版本及判断是否登录失效
|
||||
public function login_invalid_version($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
// phpinfo();
|
||||
// try {
|
||||
// // 你的业务逻辑
|
||||
// // 失败
|
||||
// $this->record_api_log($data, null, ['code'=>-1,'msg'=>'',[]]);
|
||||
// // 成功
|
||||
// $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[]]);
|
||||
// } 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,'接口错误');
|
||||
// }
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
|
|
@ -74,24 +95,43 @@ class Index extends Base{
|
|||
$url = '';
|
||||
}
|
||||
if($this->token_time_validate($data['token']) === false){
|
||||
|
||||
$this->record_api_log($data, null, ['code'=>-1,'msg'=>'未登录',['version'=>$version,'url'=>$url]]);
|
||||
return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url]);
|
||||
}else{
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',['version'=>$version,'url'=>$url]]);
|
||||
return $this->msg(['version'=>$version,'url'=>$url]);
|
||||
}
|
||||
|
||||
} 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 create_user_data($data = ['aan_id'=>1,'height'=>'152.3','weight'=>'35.4','nickname'=>'钮祜禄测试1','birthday'=>'2019-04-20','gender'=>1,'grade'=>'grade_s_3','token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){
|
||||
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
unset($data['token']);
|
||||
$verify_result = $this->verify_parameters($data,'register');
|
||||
if(!is_array($verify_result)){
|
||||
|
|
@ -99,22 +139,40 @@ class Index extends Base{
|
|||
}
|
||||
$result = Db::table($this->index_use_db_name['2'])->insertGetId($verify_result);
|
||||
if($result){
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',['aud_id'=>$result]]);
|
||||
return $this->msg(['aud_id'=>$result]);
|
||||
}else{
|
||||
$this->record_api_log($data, null, ['code'=>10002,'msg'=>'',[]]);
|
||||
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,'接口错误');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
// 修改用户
|
||||
public function update_user_data($data = ['id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
unset($data['token']);
|
||||
$verify_result = $this->verify_parameters2($data,'update');
|
||||
if(!is_array($verify_result)){
|
||||
|
|
@ -124,46 +182,83 @@ class Index extends Base{
|
|||
unset($verify_result['id']);
|
||||
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$id_val])->update($verify_result);
|
||||
if($result){
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[]]);
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10002,'msg'=>'',[]]);
|
||||
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,'接口错误');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
public function del_user_data($data = ['id'=>'26','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('id', $data) || !array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
unset($data['token']);
|
||||
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['id']])->update(['is_del'=>1]);
|
||||
if($result){
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[]]);
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10002,'msg'=>'',[]]);
|
||||
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,'接口错误');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 获取账号下用户列表
|
||||
// $type 1获取列表,2获取详细信息
|
||||
public function get_user_card_list($data = ['aan_id'=>1,'type'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('token', $data) || !array_key_exists('aan_id', $data) || !array_key_exists('type', $data)){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
|
||||
return $this->msg(10001);
|
||||
}
|
||||
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
unset($data['token']);
|
||||
$result = Db::table($this->index_use_db_name['2'])->where(['aan_id'=>$data['aan_id'],'is_del'=>0])->select();
|
||||
$temporary_data = [];
|
||||
|
|
@ -177,22 +272,41 @@ class Index extends Base{
|
|||
}
|
||||
$temporary_data = $result;
|
||||
}
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',$temporary_data]);
|
||||
return $this->msg($temporary_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 = ['aud_id'=>3]){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
|
||||
if(!array_key_exists('aud_id', $data)){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
// unset($data['token']);
|
||||
|
||||
// 获取用户信息
|
||||
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id']])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date,weight')->find();
|
||||
// 获取用户身体卡片信息
|
||||
|
|
@ -201,6 +315,8 @@ class Index extends Base{
|
|||
// dump($card_pic_color);
|
||||
// die;
|
||||
if(!$result){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10003,'msg'=>'',[]]);
|
||||
return $this->msg(10003);
|
||||
}
|
||||
unset($result['ROW_NUMBER']);
|
||||
|
|
@ -262,32 +378,52 @@ class Index extends Base{
|
|||
// 插入肺活量的卡片标准
|
||||
$result['address'] = $this->moren_gufen_diqu;
|
||||
$result['vitalcapacity_data'] = $this->get_vitalcapacity_data($result['id']);
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',$result]);
|
||||
return $this->msg($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_card_all_list($data = ['aud_id'=>1,'token'=>'57bd45e3a963b372ea2d873e4bd8d1f8']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
|
||||
unset($data['token']);
|
||||
$user_card_list = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id'],'is_del'=>0])->field('id,card_order')->find();
|
||||
// dump($user_card_list);
|
||||
// die;
|
||||
|
||||
if(!$user_card_list){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10003,'msg'=>'',[]]);
|
||||
return $this->msg(10003);
|
||||
}
|
||||
unset($user_card_list['ROW_NUMBER']);
|
||||
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
|
||||
$all_card_list = Db::table($this->index_use_db_name['6'])->where(['is_del'=>0])->field('id,name,pic')->select();
|
||||
// dump($user_card_list);
|
||||
// dump($all_card_list);
|
||||
|
||||
$result = ['user'=>[],'all'=>[]];
|
||||
foreach ($all_card_list as $key => $value) {
|
||||
if(in_array($value['id'],$user_card_list['card_order'])){
|
||||
|
|
@ -297,31 +433,73 @@ class Index extends Base{
|
|||
}
|
||||
}
|
||||
ksort($result['user']);
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',$result]);
|
||||
return $this->msg($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 save_user_card_order($data=['aud_id'=>11,'card_order'=>'2,8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('aud_id', $data) || !array_key_exists('card_order', $data) || !array_key_exists('token', $data)){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
|
||||
unset($data['token']);
|
||||
if(!$this->is_num_array(explode(',',$data['card_order']))){
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]);
|
||||
return $this->msg(10001,'数据内参数格式或值错误');
|
||||
}
|
||||
$result = Db::table($this->index_use_db_name['2'])->where(['id'=>$data['aud_id']])->update(['card_order'=>$data['card_order']]);
|
||||
if($result){
|
||||
// 成功
|
||||
$this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[]]);
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
// 失败
|
||||
$this->record_api_log($data, null, ['code'=>10002,'msg'=>'',[]]);
|
||||
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,'接口错误');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 获取年级key列表
|
||||
|
|
@ -330,9 +508,7 @@ class Index extends Base{
|
|||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
// if($this->token_time_validate($data['token']) === false){
|
||||
// return $this->msg(20001);
|
||||
// }
|
||||
|
||||
|
||||
return $this->msg($this->grade_list);
|
||||
|
||||
|
|
@ -341,38 +517,34 @@ class Index extends Base{
|
|||
|
||||
// 获取账号下首页卡片的基础数据
|
||||
public function get_user_card_data_list($data,$aud_id){
|
||||
|
||||
// try {
|
||||
// 你的业务逻辑
|
||||
$result = [];
|
||||
$db_arr = [];
|
||||
foreach ($data['card_order'] as $key => $value) {
|
||||
if($value<10){
|
||||
$db_arr[$value] = Db::table($this->db_name[$value])->where(['aud_id'=>$aud_id,'is_del'=>'0'])->order('record_time desc')->limit(1)->select();
|
||||
|
||||
if($value >= 10 && count($db_arr[$value]) > 0){
|
||||
// dump($value);
|
||||
// dump($db_arr[$value]);
|
||||
// dump($db_arr);
|
||||
}else{
|
||||
// 公共卡牌
|
||||
$db_arr[$value] = Db::table($this->index_use_db_name['9'])->where(['aud_id'=>$aud_id,'acd_id'=>$value,'is_del'=>'0'])->order('record_time desc')->limit(1)->select();
|
||||
if(count($db_arr[$value]) > 0){
|
||||
$temporary_data = Db::table($this->index_use_db_name['8'])->where(['id'=>$db_arr[$value][0]['acdsi_id']])->field('id,name')->find();
|
||||
$db_arr[$value][0]['acdsi_name'] = $temporary_data['name'];
|
||||
}
|
||||
}
|
||||
if(count($db_arr[$value]) > 0){
|
||||
$db_arr[$value] = $db_arr[$value][0];
|
||||
}else{
|
||||
unset($db_arr[$value]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取卡片背景图,及背景色信息及其他信息
|
||||
$card_all_data = Db::table($this->index_use_db_name['6'])->field('id,name,page_url_record,page_url_report,page_url_bluetooth,key_word,background_color,background_pic')->select();
|
||||
// $card_data
|
||||
$card_all_data_result = [];
|
||||
foreach ($card_all_data as $key => $value) {
|
||||
$card_all_data_result[$value['id']] = $value;
|
||||
}
|
||||
// 获取卡片路径及卡片数组处理end
|
||||
|
||||
// dump($this->card_data);
|
||||
// dump($card_all_data_result);
|
||||
// die;
|
||||
// 添加目标体重于当前体重差数据
|
||||
if(array_key_exists('2', $db_arr)){
|
||||
$target_current = $this->base_target_initial_cumulative_weight([
|
||||
|
|
@ -428,8 +600,6 @@ class Index extends Base{
|
|||
array_push($result,$temporary_arr);
|
||||
}
|
||||
}else{
|
||||
// dump($db_arr);
|
||||
// die;
|
||||
foreach ($data['card_order'] as $key => $value) {
|
||||
$temporary_arr = [];
|
||||
$temporary_arr['acd_id'] = $value;
|
||||
|
|
@ -487,10 +657,28 @@ class Index extends Base{
|
|||
array_push($temporary_arr['inside_data'],[
|
||||
'key'=>'last_time',
|
||||
// 'name'=>'最近一次',
|
||||
'name'=>$db_arr[$value]['acdsi_name'],
|
||||
'name'=>"项目名称",
|
||||
'value'=>$db_arr[$value]['acdsi_name'],
|
||||
'unit'=>'',
|
||||
'standard'=>'',
|
||||
'color'=>''
|
||||
]);
|
||||
array_push($temporary_arr['inside_data'],[
|
||||
'key'=>'last_time',
|
||||
// 'name'=>'最近一次',
|
||||
'name'=>"成绩",
|
||||
'value'=>$db_arr[$value]['achievement'],
|
||||
'unit'=>$db_arr[$value]['unit'],
|
||||
'standard'=>$db_arr[$value]['score'].'分',
|
||||
'standard'=>'',
|
||||
'color'=>''
|
||||
]);
|
||||
array_push($temporary_arr['inside_data'],[
|
||||
'key'=>'last_time',
|
||||
// 'name'=>'最近一次',
|
||||
'name'=>'得分',
|
||||
'value'=>$db_arr[$value]['score'],
|
||||
'unit'=>'分',
|
||||
'standard'=>"",
|
||||
'color'=>''
|
||||
]);
|
||||
}else{
|
||||
|
|
@ -507,12 +695,17 @@ class Index extends Base{
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
array_push($result,$temporary_arr);
|
||||
|
||||
}
|
||||
}
|
||||
// 成功
|
||||
// $this->record_api_log($data, null, ['code'=>0,'msg'=>'success',[$result,$target_current]]);
|
||||
return [$result,$target_current];
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $this->record_api_log($data, $e->getMessage(), null);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ namespace app\testapp\controller;
|
|||
|
||||
|
||||
use think\Db;
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
|
||||
class Login extends Base{
|
||||
protected $code_time = 50;
|
||||
// protected $token_time = 2592000;//30天的秒数
|
||||
|
|
|
|||
Loading…
Reference in New Issue