SchoolPhysicalExamination/application/app/controller/Index.php

543 lines
23 KiB
PHP
Raw Normal View History

2024-03-06 16:58:11 +08:00
<?php
namespace app\app\controller;
use think\Controller;
use think\Db;
use app\bj\controller\Common;
use think\Log;
use \think\Validate;
2024-05-16 10:33:57 +08:00
class Index extends Base{
2024-03-06 16:58:11 +08:00
2024-05-16 10:33:57 +08:00
protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data'];
// protected $card_key = ['2'=>'body','6'=>'skip','8'=>'vitalcapacity'];
2024-05-25 18:39:08 +08:00
protected $default_card = ['2','6','8'];
2024-05-16 10:33:57 +08:00
protected $card_data = [
2024-05-25 18:39:08 +08:00
'2'=>['身体数据','body',['height'=>['身高','cm','-'],'weight'=>['体重','公斤','-'],'bmi'=>['BMI','无','-']]],
2024-06-07 16:49:19 +08:00
// '6'=>['跳绳数据','skip',['jump_time'=>['用时','无','--:--:--'],'jump_num'=>['本次次数','次','-'],'average_num'=>['平均成绩','个','-'],'jump_kcal'=>['卡路里','kcal','-']]],
'6'=>['跳绳数据','skip',['jump_time'=>['用时','无','--:--:--'],'jump_num'=>['本次次数','次','-'],'jump_kcal'=>['卡路里','kcal','-']]],
2024-05-25 18:39:08 +08:00
'8'=>['肺活量','vitalcapacity',['average'=>['本次数据','ml','-']]],
2024-05-16 10:33:57 +08:00
];
2024-05-21 18:43:56 +08:00
protected $data_name_unit = [
'height'=>['身高','cm','pc_heightstand2'],
'weight'=>['体重','公斤','pc_weightstand2'],
'bmi'=>['BMI','','pc_bmistand2'],
'average'=>['肺活量','ml','pc_vitalcapacity_standard']
];
protected $grade_list = [
['id'=>'nothing','name'=>'无'],
['id'=>'grade_s_1','name'=>'小学一年级'],
['id'=>'grade_s_2','name'=>'小学二年级'],
['id'=>'grade_s_3','name'=>'小学三年级'],
['id'=>'grade_s_4','name'=>'小学四年级'],
['id'=>'grade_s_5','name'=>'小学五年级'],
['id'=>'grade_s_6','name'=>'小学六年级'],
['id'=>'grade_m_1','name'=>'初中一年级'],
['id'=>'grade_m_2','name'=>'初中二年级'],
['id'=>'grade_m_3','name'=>'初中三年级'],
['id'=>'grade_h_1','name'=>'高中一年级'],
['id'=>'grade_h_2','name'=>'高中二年级'],
['id'=>'grade_h_3','name'=>'高中三年级'],
['id'=>'grade_u_12','name'=>'大学一、二年级'],
['id'=>'grade_u_34','name'=>'大学三、四年级']
];
2024-03-06 16:58:11 +08:00
################################################################个人资料卡################################################################
################################################################个人资料卡################################################################
################################################################个人资料卡################################################################
2024-06-07 17:34:13 +08:00
// 检测版本及判断是否登录失效
public function login_invalid_version($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
// phpinfo();
if(count(input('post.')) > 0){
$data = input('post.');
}
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
$result = Db::table('app_version_log')->order('id desc')->find();
if($result){
$version = $result['version_num_original'];
$url = $result['download_url'];
}else{
$version = '';
$url = '';
}
if($this->token_time_validate($data['token']) === false){
return $this->msg(20001,'未登录',['version'=>$version,'url'=>$url]);
}else{
return $this->msg(['version'=>$version,'url'=>$url]);
}
}
2024-05-16 10:33:57 +08:00
// 创建用户
2024-05-20 18:49:27 +08:00
public function create_user_data($data = ['aan_id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
2024-05-22 21:37:39 +08:00
if(count(input('post.')) > 0){
$data = input('post.');
2024-05-20 13:56:50 +08:00
}
2024-05-21 18:43:56 +08:00
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
2024-05-20 18:49:27 +08:00
if($this->token_time_validate($data['token']) === false){
2024-05-21 18:43:56 +08:00
return $this->msg(20001);
2024-05-20 18:49:27 +08:00
}
unset($data['token']);
2024-03-29 18:34:01 +08:00
$verify_result = $this->verify_parameters($data,'register');
2024-05-16 10:33:57 +08:00
if(!is_array($verify_result)){
2024-05-21 18:43:56 +08:00
return $this->msg(10001,$verify_result);
2024-03-15 18:15:17 +08:00
}
$result = Db::table('app_user_data')->insert($verify_result);
2024-03-06 16:58:11 +08:00
if($result){
2024-05-21 18:43:56 +08:00
return $this->msg([]);
2024-03-06 16:58:11 +08:00
}else{
2024-05-21 18:43:56 +08:00
return $this->msg(10002);
2024-03-06 16:58:11 +08:00
}
}
2024-05-28 18:43:48 +08:00
// 修改用户
public function update_user_data($data = ['id'=>66,'nickname'=>'王小二','birthday'=>'2019-01-01','gender'=>1,'grade'=>'二年级','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
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)){
return $this->msg(10001,$verify_result);
}
$id_val = $verify_result['id'];
unset($verify_result['id']);
$result = Db::table('app_user_data')->where(['id'=>$id_val])->update($verify_result);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
// 删除用户
public function del_user_data($data = ['id'=>'26','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
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('app_user_data')->where(['id'=>$data['id']])->update(['is_del'=>1]);
if($result){
return $this->msg([]);
}else{
return $this->msg(10002);
}
}
2024-03-15 18:15:17 +08:00
// 获取账号下用户列表
2024-03-06 16:58:11 +08:00
// $type 1获取列表2获取详细信息
2024-05-20 18:49:27 +08:00
public function get_user_card_list($data = ['aan_id'=>66,'type'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
2024-05-22 21:37:39 +08:00
if(count(input('post.')) > 0){
$data = input('post.');
2024-05-20 13:56:50 +08:00
}
2024-05-22 19:50:44 +08:00
if(!array_key_exists('token', $data) || !array_key_exists('aan_id', $data) || !array_key_exists('type', $data)){
2024-05-21 18:43:56 +08:00
return $this->msg(10001);
}
2024-05-20 18:49:27 +08:00
if($this->token_time_validate($data['token']) === false){
2024-05-21 18:43:56 +08:00
return $this->msg(20001);
2024-05-20 18:49:27 +08:00
}
unset($data['token']);
2024-05-28 18:43:48 +08:00
$result = Db::table('app_user_data')->where(['aan_id'=>$data['aan_id'],'is_del'=>0])->select();
2024-03-15 18:15:17 +08:00
// $result = Db::table('app_user_data')->where(['aan_id'=>$aan_id])->field('id,nickname')->select();
2024-05-20 13:56:50 +08:00
$temporary_data = [];
if($data['type'] == 1){
2024-03-06 16:58:11 +08:00
for ($i=0; $i < count($result); $i++) {
2024-05-20 13:56:50 +08:00
array_push($temporary_data,['id'=>$result[$i]['id'],'nickname'=>$result[$i]['nickname']]);
2024-03-06 16:58:11 +08:00
}
}else{
2024-06-07 16:49:19 +08:00
for ($i=0; $i < count($result); $i++) {
$result[$i]['age'] = $this->calculate_age($result[$i]['birthday']);
// array_push($temporary_data,['id'=>$result[$i]['id'],'nickname'=>$result[$i]['nickname'],'age'=>$this->calculate_age($result[$i]['birthday'])]);
}
2024-05-20 13:56:50 +08:00
$temporary_data = $result;
2024-03-06 16:58:11 +08:00
}
2024-05-21 18:43:56 +08:00
return $this->msg($temporary_data);
2024-03-06 16:58:11 +08:00
}
2024-03-15 18:15:17 +08:00
2024-05-16 10:33:57 +08:00
// 获取指定用户详细信息
2024-05-24 10:10:28 +08:00
public function get_user_data_information($data = ['aud_id'=>26,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
2024-05-22 21:37:39 +08:00
if(count(input('post.')) > 0){
$data = input('post.');
2024-05-20 13:56:50 +08:00
}
2024-05-23 18:49:55 +08:00
// dump(input('post.'));
// dump(input('get.'));
// // dump($data);
// die;
2024-05-22 19:50:44 +08:00
if(!array_key_exists('token', $data) || !array_key_exists('aud_id', $data)){
2024-05-21 18:43:56 +08:00
return $this->msg(10001);
}
2024-05-20 18:49:27 +08:00
if($this->token_time_validate($data['token']) === false){
2024-05-21 18:43:56 +08:00
return $this->msg(20001);
2024-05-20 18:49:27 +08:00
}
unset($data['token']);
2024-05-22 21:37:39 +08:00
$result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,aan_id,nickname,head_pic,birthday,gender,card_order,target_weight,initial_weight,initial_date')->find();
2024-05-21 18:43:56 +08:00
if(!$result){
return $this->msg(10003);
}
2024-05-16 10:33:57 +08:00
unset($result['ROW_NUMBER']);
2024-05-21 18:43:56 +08:00
$result['age'] = $this->calculate_age($result['birthday']);
2024-05-16 10:33:57 +08:00
if($result['card_order'] === ''){
$result['card_order'] = [];
$result['card_data_list'] = [];
2024-05-22 21:37:39 +08:00
$result['target_current'] = $this->base_target_initial_cumulative_weight([]);
2024-05-23 18:49:55 +08:00
2024-03-06 16:58:11 +08:00
}else{
2024-05-16 10:33:57 +08:00
$result['card_order'] = explode(',',$result['card_order']);
2024-05-22 21:37:39 +08:00
$calculation_results = $this->get_user_card_data_list($result,$result['id']);
2024-05-23 18:49:55 +08:00
// dump($calculation_results);
2024-05-24 10:10:28 +08:00
// die;
2024-05-22 21:37:39 +08:00
$result['card_data_list'] = $calculation_results[0];
$result['target_current'] = $calculation_results[1];
2024-03-06 16:58:11 +08:00
}
2024-05-22 19:50:44 +08:00
// base_target_initial_cumulative_weight
2024-05-23 18:49:55 +08:00
// dump($result);
// die;
2024-05-20 18:49:27 +08:00
$result['birthday'] = str_replace('-', '/', $result['birthday']);
foreach ($result['card_data_list'] as $key => $value) {
2024-05-24 10:10:28 +08:00
// dump($key);
if($key == 'record_time' && $value != ''){
// dump(111);
$result['card_data_list'][$key] = str_replace('-', '/', $result['card_data_list'][$key]);
}
2024-05-20 18:49:27 +08:00
}
2024-05-22 21:37:39 +08:00
unset($result['target_weight']);
unset($result['initial_weight']);
unset($result['initial_date']);
// dump($result);
// die;
2024-05-21 18:43:56 +08:00
return $this->msg($result);
2024-03-06 16:58:11 +08:00
}
2024-05-16 10:33:57 +08:00
// 获取所有卡片列表信息
2024-05-20 18:49:27 +08:00
public function get_card_all_list($data = ['aud_id'=>11,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
2024-05-22 21:37:39 +08:00
if(count(input('post.')) > 0){
$data = input('post.');
2024-05-20 13:56:50 +08:00
}
2024-05-21 18:43:56 +08:00
if(!array_key_exists('token', $data)){
return $this->msg(10001);
}
2024-05-20 18:49:27 +08:00
if($this->token_time_validate($data['token']) === false){
2024-05-21 18:43:56 +08:00
return $this->msg(20001);
2024-05-20 18:49:27 +08:00
}
unset($data['token']);
2024-05-20 13:56:50 +08:00
$user_card_list = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,card_order')->find();
2024-05-21 18:43:56 +08:00
if(!$user_card_list){
return $this->msg(10003);
}
2024-05-16 10:33:57 +08:00
unset($user_card_list['ROW_NUMBER']);
$user_card_list['card_order'] = explode(',',$user_card_list['card_order']);
$all_card_list = Db::table('app_card_data')->field('id,name')->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'])){
$result['user'][array_search($value['id'], $user_card_list['card_order'])] = ['id'=>$value['id'],'name'=>$value['name']];
}else{
array_push($result['all'],['id'=>$value['id'],'name'=>$value['name']]);
}
}
ksort($result['user']);
2024-05-21 18:43:56 +08:00
return $this->msg($result);
2024-05-16 10:33:57 +08:00
}
2024-03-15 18:15:17 +08:00
2024-05-16 10:33:57 +08:00
// 保存用户的卡片排序
2024-05-20 18:49:27 +08:00
public function save_user_card_order($data=['aud_id'=>11,'card_order'=>'2,8','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
2024-05-22 21:37:39 +08:00
if(count(input('post.')) > 0){
$data = input('post.');
2024-03-06 16:58:11 +08:00
}
2024-05-21 18:43:56 +08:00
if(!array_key_exists('aud_id', $data) || !array_key_exists('card_order', $data) || !array_key_exists('token', $data)){
return $this->msg(10001);
}
2024-05-20 18:49:27 +08:00
if($this->token_time_validate($data['token']) === false){
2024-05-21 18:43:56 +08:00
return $this->msg(20001);
2024-05-20 18:49:27 +08:00
}
unset($data['token']);
2024-05-20 13:56:50 +08:00
if(!$this->is_num_array(explode(',',$data['card_order']))){
2024-05-21 18:43:56 +08:00
return $this->msg(10001,'数据内参数格式或值错误');
2024-05-16 10:33:57 +08:00
}
2024-05-20 13:56:50 +08:00
$result = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->update(['card_order'=>$data['card_order']]);
2024-03-06 16:58:11 +08:00
if($result){
2024-05-21 18:43:56 +08:00
return $this->msg([]);
2024-03-06 16:58:11 +08:00
}else{
2024-05-21 18:43:56 +08:00
return $this->msg(10002);
2024-03-06 16:58:11 +08:00
}
2024-05-20 13:56:50 +08:00
2024-03-06 16:58:11 +08:00
}
2024-05-21 18:43:56 +08:00
2024-05-28 18:43:48 +08:00
// 获取年级key列表
2024-05-21 18:43:56 +08:00
public function get_grade_list(){
2024-05-22 21:37:39 +08:00
$data = input('post.');
2024-05-21 18:43:56 +08:00
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);
}
2024-05-16 10:33:57 +08:00
################################获取账号下信息操作################################
2024-05-21 18:43:56 +08:00
2024-05-16 10:33:57 +08:00
// 获取账号下首页卡片的基础数据
public function get_user_card_data_list($data,$aud_id){
2024-05-21 18:43:56 +08:00
2024-05-16 10:33:57 +08:00
$result = [];
2024-05-21 18:43:56 +08:00
$db_arr = [];
2024-05-22 21:37:39 +08:00
foreach ($data['card_order'] as $key => $value) {
2024-05-21 18:43:56 +08:00
$db_arr[$value] = Db::table($this->db_name[$value])->where(['aud_id'=>$aud_id,'is_del'=>'0'])->order('id desc')->limit(1)->select();
2024-05-22 18:36:27 +08:00
// dump($db_arr[$value]);
if(count($db_arr[$value]) > 0){
$db_arr[$value] = $db_arr[$value][0];
}else{
unset($db_arr[$value]);
}
2024-05-16 10:33:57 +08:00
}
2024-05-23 18:49:55 +08:00
2024-05-24 10:10:28 +08:00
// dump($db_arr);
2024-05-23 18:49:55 +08:00
// die;
2024-05-24 10:10:28 +08:00
// 添加目标体重于当前体重差数据
if(array_key_exists('2', $db_arr)){
$target_current = $this->base_target_initial_cumulative_weight([
'weight'=>$db_arr['2']['weight']>0?$db_arr['2']['weight']:0,
'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
]);
}else{
$target_current = $this->base_target_initial_cumulative_weight([
'weight'=>0,
'target_weight'=>$data['target_weight']>0?$data['target_weight']:0,
'initial_weight'=>$data['initial_weight']>0?$data['initial_weight']:0,
'initial_date'=>$data['initial_date']!=null?$data['initial_date']:0,
]);
}
2024-05-22 18:36:27 +08:00
if(count($db_arr) <= 0){
// 没有数据,传递一个空的卡片
2024-05-25 18:39:08 +08:00
foreach ($data['card_order'] as $key => $value) {
$temporary_arr = [];
$temporary_arr['id'] = '';
$temporary_arr['acd_id'] = $value;
$temporary_arr['record_time'] = '';
$temporary_arr['card_name'] = $this->card_data[$value][0];
$temporary_arr['card_key'] = $this->card_data[$value][1];
$temporary_arr['inside_data'] = [];
foreach ($this->card_data[$value][2] as $k => $v) {
2024-05-21 18:43:56 +08:00
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
2024-05-25 18:39:08 +08:00
'value'=>$v[2],
2024-05-21 18:43:56 +08:00
'unit'=>$v[1]!='无'?$v[1]:'',
2024-05-25 18:39:08 +08:00
'standard'=>'',
'color'=>''
2024-05-21 18:43:56 +08:00
]);
2024-05-16 10:33:57 +08:00
}
2024-05-25 18:39:08 +08:00
array_push($result,$temporary_arr);
}
}else{
// dump($db_arr);
// die;
foreach ($data['card_order'] as $key => $value) {
$temporary_arr = [];
$temporary_arr['acd_id'] = $value;
$temporary_arr['card_name'] = $this->card_data[$value][0];
$temporary_arr['card_key'] = $this->card_data[$value][1];
$temporary_arr['inside_data'] = [];
if(array_key_exists($value,$db_arr)){
$temporary_arr['id'] = $db_arr[$value]['id'];
$temporary_arr['record_time'] = $db_arr[$value]['record_time'];
foreach ($this->card_data[$value][2] as $k => $v) {
if($value == '2'){
$tem_arr_2 = explode(',', $db_arr[$value][$k]);
}else if($value == '6' && $k == 'jump_time'){
$time_conversion = $this->handle_hour_branch_second($db_arr[$value][$k]);
$tem_arr_2 = [$time_conversion['h'].':'.$time_conversion['m'].':'.$time_conversion['s'],'',''];
}else{
$tem_arr_2 = [$db_arr[$value][$k],'',''];
}
// dump($tem_arr_2);
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
'value'=>$tem_arr_2[0],
'unit'=>$v[1]!='无'?$v[1]:'',
'standard'=>$tem_arr_2[1]!='无'?$tem_arr_2[1]:'',
'color'=>$tem_arr_2[2]!='无'?$tem_arr_2[2]:''
]);
}
}else{
$temporary_arr['id'] = '';
$temporary_arr['record_time'] = '';
foreach ($this->card_data[$value][2] as $k => $v) {
array_push($temporary_arr['inside_data'],[
'key'=>$k,
'name'=>$v[0],
'value'=>$v[2],
'unit'=>$v[1]!='无'?$v[1]:'',
'standard'=>'',
'color'=>''
]);
}
}
array_push($result,$temporary_arr);
// $temporary_arr['acd_id'] = $value['acd_id'];
// $temporary_arr['record_time'] = $value['record_time'];
// $temporary_arr['card_name'] = $this->card_data[$value['acd_id']][0];
// $temporary_arr['card_key'] = $this->card_data[$value['acd_id']][1];
// $temporary_arr['inside_data'] = [];
// if(array_key_exists($value['acd_id'],$this->card_data)){
// foreach ($this->card_data[$value['acd_id']][2] as $k => $v) {
// $tem_arr_2 = explode(',', $db_arr[$key][$k."_data"]);
// array_push($temporary_arr['inside_data'],[
// 'key'=>$k,
// 'name'=>$v[0],
// 'value'=>$tem_arr_2[0],
// 'unit'=>$v[1]!='无'?$v[1]:'',
// 'standard'=>$tem_arr_2[1]!='无'?$tem_arr_2[1]:'',
// 'color'=>$tem_arr_2[2]!='无'?$tem_arr_2[2]:''
// ]);
// }
// }
// array_push($result,$temporary_arr);
2024-05-16 10:33:57 +08:00
}
}
2024-05-22 21:37:39 +08:00
return [$result,$target_current];
2024-05-21 18:43:56 +08:00
}
2024-03-06 16:58:11 +08:00
################################################################other################################################################
################################################################other################################################################
################################################################other################################################################
2024-05-16 10:33:57 +08:00
2024-03-06 16:58:11 +08:00
2024-03-15 18:15:17 +08:00
public function verify_parameters($data,$type){
// 设置验证
$rule = [
'aan_id' => 'require|number',
'nickname' => 'require|chsAlpha',
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
2024-03-29 18:34:01 +08:00
'grade' => 'require',
2024-06-07 16:49:19 +08:00
'height' => 'require|number',
'weight' => 'require|number',
2024-03-15 18:15:17 +08:00
];
$msg = [
'aan_id.require' => '账号信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
2024-03-29 18:34:01 +08:00
'grade.require' => '年级缺失',
2024-06-07 16:49:19 +08:00
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
2024-03-15 18:15:17 +08:00
'aan_id.number' => '账号信息格式错误',
'nickname.chsAlpha' => '昵称只能是只能是汉字、字母',
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
2024-06-07 16:49:19 +08:00
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
2024-03-15 18:15:17 +08:00
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['aan_id'] = $data['aan_id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
$parameter['gender'] = $data['gender'];
2024-03-29 18:34:01 +08:00
$parameter['grade'] = $data['grade'];
2024-05-25 18:39:08 +08:00
$parameter['card_order'] = '2,6,8';
2024-06-07 16:49:19 +08:00
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
2024-03-15 18:15:17 +08:00
$parameter['create_time'] = date('Y-m-d H:i:s');
$parameter['last_update_time'] = date('Y-m-d H:i:s');
2024-05-21 18:43:56 +08:00
$parameter_pd = Db::table('app_account_number')->where(['id'=>$parameter['aan_id']])->count();
if($parameter_pd <= 0){
return '该账户不存在';
}
2024-06-05 18:10:32 +08:00
$result = Db::table('app_user_data')->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count();
2024-05-20 13:56:50 +08:00
if($result>0){
return '该成员已存在';
}
2024-03-15 18:15:17 +08:00
return $parameter;
}
2024-05-28 18:43:48 +08:00
public function verify_parameters2($data,$type){
// 设置验证
$rule = [
'id' => 'require|number',
2024-06-05 18:10:32 +08:00
'nickname' => 'require|chsAlphaNum',
2024-05-28 18:43:48 +08:00
'birthday' => 'require|date',
'gender' => 'require|number|in:0,1,2',
'grade' => 'require',
2024-06-07 16:49:19 +08:00
'height' => 'require|number',
'weight' => 'require|number',
2024-05-28 18:43:48 +08:00
];
$msg = [
'id.require' => '用户信息缺失',
'nickname.require' => '昵称缺失',
'birthday.require' => '生日缺失',
'gender.require' => '性别缺失',
'grade.require' => '年级缺失',
2024-06-07 16:49:19 +08:00
'height.require' => '身高缺失',
'weight.require' => '体重缺失',
2024-05-28 18:43:48 +08:00
'id.number' => '用户信息格式错误',
2024-06-05 18:10:32 +08:00
'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母、数字',
2024-05-28 18:43:48 +08:00
'birthday.date' => '生日信息格式错误',
'gender.number' => '性别格式错误',
'gender.in' => '性别信息错误',
2024-06-07 16:49:19 +08:00
'height.number' => '身高必须为数字',
'weight.number' => '体重必须为数字',
2024-05-28 18:43:48 +08:00
];
$validate = new Validate($rule,$msg);
$result = $validate->check($data);
if(!$result){
return $validate->getError();
}
$parameter['id'] = $data['id'];
$parameter['nickname'] = $data['nickname'];
$parameter['birthday'] = $data['birthday'];
2024-06-07 16:49:19 +08:00
$parameter['height'] = $data['height'];
$parameter['weight'] = $data['weight'];
2024-05-28 18:43:48 +08:00
$parameter['gender'] = $data['gender'];
$parameter['grade'] = $data['grade'];
$parameter['last_update_time'] = date('Y-m-d H:i:s');
return $parameter;
}
2024-03-29 18:34:01 +08:00
2024-03-15 18:15:17 +08:00
2024-05-20 13:56:50 +08:00
2024-03-06 16:58:11 +08:00
}