From fbe38770cca1e6104dfbf2d54815f7815962c464 Mon Sep 17 00:00:00 2001 From: tsf <460834639@qq.com> Date: Wed, 5 Jun 2024 18:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=AC=AC=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/app/controller/Base.php | 12 +- application/app/controller/Index.php | 6 +- application/app/controller/Login.php | 178 ++-- application/app/controller/Myinformation.php | 154 ++++ application/app/controller/Sportstesting.php | 909 +++++++++++++++---- application/route.php | 21 +- public/tsf/head_pic.jpg | Bin 0 -> 1867 bytes 7 files changed, 975 insertions(+), 305 deletions(-) create mode 100644 application/app/controller/Myinformation.php create mode 100644 public/tsf/head_pic.jpg diff --git a/application/app/controller/Base.php b/application/app/controller/Base.php index e198413..4e2d876 100644 --- a/application/app/controller/Base.php +++ b/application/app/controller/Base.php @@ -17,12 +17,12 @@ class Base extends Controller{ '10002'=>'操作失败', '10003'=>'信息核实错误', '10004'=>'未找到有效数据', - '10005'=>'参数错误', - '10006'=>'未核实到数据', - '10007'=>'未核实到数据', - '10008'=>'未核实到数据', - '10009'=>'未核实到数据', - '10010'=>'未核实到数据', + '10005'=>'参数格式错误', + '10006'=>'参数不能为空', + '10007'=>'', + '10008'=>'', + '10009'=>'', + '10010'=>'', '20001'=>'登录失效', ]; diff --git a/application/app/controller/Index.php b/application/app/controller/Index.php index 6f453aa..ac4850f 100644 --- a/application/app/controller/Index.php +++ b/application/app/controller/Index.php @@ -453,7 +453,7 @@ class Index extends Base{ if($parameter_pd <= 0){ return '该账户不存在'; } - $result = Db::table('app_user_data')->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id']])->count(); + $result = Db::table('app_user_data')->where(['nickname'=>$parameter['nickname'],'aan_id'=>$parameter['aan_id'],'is_del'=>0])->count(); if($result>0){ return '该成员已存在'; } @@ -464,7 +464,7 @@ class Index extends Base{ // 设置验证 $rule = [ 'id' => 'require|number', - 'nickname' => 'require|chsAlpha', + 'nickname' => 'require|chsAlphaNum', 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', 'grade' => 'require', @@ -477,7 +477,7 @@ class Index extends Base{ 'grade.require' => '年级缺失', 'id.number' => '用户信息格式错误', - 'nickname.chsAlpha' => '昵称只能是只能是汉字、字母', + 'nickname.chsAlphaNum' => '昵称只能是只能是汉字、字母、数字', 'birthday.date' => '生日信息格式错误', 'gender.number' => '性别格式错误', 'gender.in' => '性别信息错误', diff --git a/application/app/controller/Login.php b/application/app/controller/Login.php index 07c8441..b89b895 100644 --- a/application/app/controller/Login.php +++ b/application/app/controller/Login.php @@ -11,6 +11,9 @@ use PHPMailer\PHPMailer\PHPMailer; class Login extends Base{ protected $code_time = 3600; + protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.jpg'; + + ################################################################接口################################################################ ################################################################接口################################################################ ################################################################接口################################################################ @@ -18,23 +21,43 @@ class Login extends Base{ // 注册 public function register_action($data = ['data'=>18530934717,'password'=>'ceshi','code'=>'746119']){ - // dump('123'); - // phpinfo(); - // die; if(count(input('post.')) > 0){ $data = input('post.'); } - $verify_result = $this->verify_parameters($data,'register'); - if(!is_array($verify_result)){ - return $this->msg(10001,$verify_result); + if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data)){ + return $this->msg(10001); } - // dump($verify_result); - // die; - // 记录 - $result = Db::table('app_account_number')->insertGetId($verify_result); + if(!$data['data'] || !$data['password'] || !$data['code']){ + return $this->msg(10006); + } + $set_data = []; + $montage_data = $this->is_tel_email($data['data']); + if($montage_data == false){ + return $this->msg(10005); + } + $inspect_repeat = Db::table('app_account_number')->where([$montage_data=>$data['data']])->count(); + if($inspect_repeat >= 0){ + return $this->msg(10002,'注册失败,账号已存在'); + } + $code_result = $this->check_code($data['data'],$data['code']); + if($code_result !== true){ + return $this->msg(10002,$code_result); + } + // 验证完之后 + if($montage_data == 'tel'){ + $set_data['tel'] = $data['data']; + }else{ + $set_data['email'] = $data['data']; + } + $set_data['password'] = $data['password']; + $set_data['head_pic'] = $this->default_head_pic; + $set_data['nickname'] = '用户'.$data['data']; + $set_data['create_time'] = date('Y-m-d H:i:s'); + $set_data['token'] = md5($data['data'].$this->create_random_string(12).time()); + $result = Db::table('app_account_number')->insertGetId($set_data); if($result){ - cache($verify_result['token'], time()); - return $this->msg(['token'=>$verify_result['token'],'aan_id'=>$result]); + cache($set_data['token'], time()); + return $this->msg(['token'=>$set_data['token'],'aan_id'=>$result]); }else{ return $this->msg(10002); } @@ -51,6 +74,9 @@ class Login extends Base{ if($data['password'] != $data['c_password']){ return $this->msg(10003,'两次密码不一致'); } + if($data['password'] == ''){ + return $this->msg(10003,'密码不能为空'); + } $code_result = $this->check_code($data['data'],$data['code']); if($code_result !== true){ return $this->msg(10003,$code_result); @@ -81,41 +107,52 @@ class Login extends Base{ return $this->msg(10001); } // 检测是否为手机 - if (preg_match('/^\d{11}$/', $data['data'])) { - $verify_result['tel'] = $data['data']; - $road = 'tel'; - }else{ - $verify_result['email'] = $data['data']; - $road = 'email'; + $montage_data = $this->is_tel_email($data['data']); + if($montage_data == false){ + return $this->msg(10005); } - // dump($verify_result); - // die; - // $find_token = Db::table('app_account_number')->where([$t_y=>$data['data']])->field('id,token')->find(); + $verify_result[$montage_data] = $data['data']; // 检测校验途径 if($data['validate_type'] == 'code'){ $code_name = $data['data']; - // dump(cache($code_name)); - // die; - // if(cache($code_name) == $data['validate_data']){ if($this->check_code($code_name,$data['validate_data']) === true){ $result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find(); if($result){ cache($result['token'], time()); return $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]); }else{ - return $this->msg(10003); + $set_data['password'] = ''; + $set_data[$montage_data] = $data['data']; + $set_data['head_pic'] = $this->default_head_pic; + $set_data['nickname'] = '用户'.$data['data']; + $set_data['create_time'] = date('Y-m-d H:i:s'); + $set_data['token'] = md5($data['data'].$this->create_random_string(12).time()); + $result = Db::table('app_account_number')->insertGetId($set_data); + if($result){ + cache($set_data['token'], time()); + return $this->msg(['token'=>$set_data['token'],'aan_id'=>$result]); + }else{ + return $this->msg(10002); + } } }else{ return $this->msg(10003,'登录失败,验证码错误或失效'); } }else if($data['validate_type'] == 'password'){ - $verify_result['password'] = $data['validate_data']; - $result = Db::table('app_account_number')->where($verify_result)->field('id,token')->find(); + // $verify_result['password'] = $data['validate_data']; + $result = Db::table('app_account_number')->where($verify_result)->field('id,token,password')->find(); if($result){ - cache($result['token'], time()); - return $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]); + if($result['password'] == ''){ + return $this->msg(10003,'该账户未设密码,请用验证码登录'); + } + if($data['validate_data'] != $result['password']){ + return $this->msg(10003,'账号密码错误'); + }else{ + cache($result['token'], time()); + return $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]); + } }else{ - return $this->msg(10003,'登录失败,账号/密码错误'); + return $this->msg(10003,'账号未注册,请先注册'); } }else{ return $this->msg(10003,'校验参数错误'); @@ -157,7 +194,7 @@ class Login extends Base{ if(!array_key_exists('data', $data) || !array_key_exists('type', $data)){ return $this->msg(10001); } - $num = $this->rand_int(); + $num = mt_rand(100000,999999); if (preg_match('/^\d{11}$/', $data['data'])) { $result = $this->send_tel_code($data['data'],$num); $road = 'tel'; @@ -266,6 +303,7 @@ class Login extends Base{ } public function check_code($data = 18530934717 , $code = 123456){ + // 默认验证码正确 return true; // dump($data); // dump(cache($data)); @@ -283,79 +321,6 @@ class Login extends Base{ ################################################################other################################################################ ################################################################other################################################################ - public function test(){ - dump($this->send_tel_code('18530934717',$this->rand_int())); - // dump(['code']); - - } - - public function rand_int(){ - return mt_rand(100000,999999); - } - - public function verify_parameters($data,$type){ - // 设置验证 - $rule = [ - 'data' => 'require', - 'password' => 'require', - 'code' => 'require|number', - ]; - $msg = [ - 'password.require' => '密码必须', - 'data.require' => '手机或邮箱必须', - 'code.number' => '验证码必须是数字', - 'code.number' => '验证码必须', - ]; - $validate = new Validate($rule,$msg); - $result = $validate->check($data); - if(!$result){ - return $validate->getError(); - } - // dump('3211'); - // 判断参数 - if(preg_match('/^\d{11}$/', $data['data'])){ - $parameter['tel'] = $data['data']; - $montage_data = 'tel'; - }else{ - $parameter['email'] = $data['data']; - $montage_data = 'email'; - } - $parameter['password'] = $data['password']; - - // dump($montage_data); - // dump( $parameter); - // 检验是否注册过 - // if($montage_data == 'tel'){ - // $inspect_repeat = Db::table('app_account_number')->where(['tel'=>$parameter['tel']])->count(); - // // $inspect_repeat = Db::query("select count(*) from app_account_number where tel='".$parameter['tel']."'and password='".$parameter['password']); - // }else{ - // $inspect_repeat = Db::table('app_account_number')->where(['email'=>$parameter['email']])->count(); - // } - $inspect_repeat = Db::table('app_account_number')->where([$montage_data=>$data['data']])->count(); - // dump( $inspect_repeat); - // die; - // dump($inspect_repeat); - // dump('3212'); - if($inspect_repeat>0){ - return '注册失败,账号已存在'; - } - - - if($type == 'register'){ - if(array_key_exists('code', $data)){ - $code_result = $this->check_code($parameter[$montage_data],$data['code']); - if($code_result !== true){ - return $code_result; - } - }else{ - return '验证码必须'; - } - $parameter['create_time'] = date('Y-m-d H:i:s'); - $parameter['token'] = md5($data['data'].$this->create_random_string(12).time()); - } - - return $parameter; - } public function create_random_string($length = 12) { @@ -368,9 +333,6 @@ class Login extends Base{ return $str; } - public function demo_db(){ - dump('开始测试'); - $this->ceshiyong(); - } + } \ No newline at end of file diff --git a/application/app/controller/Myinformation.php b/application/app/controller/Myinformation.php new file mode 100644 index 0000000..b792bff --- /dev/null +++ b/application/app/controller/Myinformation.php @@ -0,0 +1,154 @@ +'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']); + + return $this->get_my_account_msg_action($data); + } + // 修改昵称 + public function update_my_nickname($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','nickname'=>'']){ + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('nickname', $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']); + + return $this->update_my_nickname_action($data); + } + // 邮箱/手机绑定 + public function update_my_account_msg($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','data'=>'tsf3920322@126.com','code'=>'123456']){ + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('data', $data) || !array_key_exists('token', $data) || !array_key_exists('code', $data)){ + return $this->msg(10001); + } + if($this->token_time_validate($data['token']) === false){ + return $this->msg(20001); + } + // unset($data['token']); + + return $this->update_my_account_msg_action($data); + } + + // 修改密码 + public function update_my_password($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','password'=>'ceshi1','c_password'=>'ceshi1']){ + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('password', $data) || !array_key_exists('c_password', $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']); + return $this->update_my_password_action($data); + } + + ################################################################业务################################################################ + ################################################################get_my_account_msg + public function get_my_account_msg_action($data){ + $result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->find(); + if($result){ + return $this->msg([ + 'my_tel'=>$result['tel'], + 'my_email'=>$result['email'], + 'create_time'=>$result['tel'], + 'token'=>$result['token'], + 'nickname'=>$result['nickname'], + 'head_pic'=>$result['head_pic'], + 'last_update_time'=>$result['update_time'], + ]); + }else{ + return $this->msg(10002); + } + } + ################################################################update_my_nickname + public function update_my_nickname_action($data){ + $result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([ + 'nickname'=>$data['nickname'], + 'update_time'=>date('Y-m-d H:i:s') + ]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } + ################################################################update_my_account_msg + public function update_my_account_msg_action($data){ + $login_action = new Login(); + $validate_result = $login_action->check_code($data['data'],$data['code']); + if($validate_result !== true){ + return $this->msg(10001,$validate_result); + } + $montage_data = $this->is_tel_email($data['data']); + if($montage_data == false){ + return $this->msg(10005); + } + // dump($data); + // die; + $result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([ + $montage_data=>$data['data'], + 'update_time'=>date('Y-m-d H:i:s') + ]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } + ################################################################update_my_password + public function update_my_password_action($data){ + if($data['password'] != $data['c_password']){ + return $this->msg(10003,'两次密码不一致'); + } + if($data['password'] == ''){ + return $this->msg(10003,'密码不能为空'); + } + $result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([ + 'password'=>$data['password'], + 'update_time'=>date('Y-m-d H:i:s') + ]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } + + +} \ No newline at end of file diff --git a/application/app/controller/Sportstesting.php b/application/app/controller/Sportstesting.php index c3992ac..28caee1 100644 --- a/application/app/controller/Sportstesting.php +++ b/application/app/controller/Sportstesting.php @@ -13,6 +13,27 @@ use app\app\controller\Skip; class Sportstesting extends Base{ protected $color = ['#FF5656','#FF5656','#5AD06D','#6492F6','#3967D6']; + protected $page_num = 10; + + protected $city_data_rule_name = [ + 'xc'=>'现场', + 'xc_1'=>'第一类:素质项目Ⅰ(8分)', + 'xc_2'=>'第二类:素质项目Ⅱ(8分)', + 'xc_3'=>'第三类:运动能力Ⅰ(8分)', + 'xc_4'=>'第四类:运动能力Ⅱ(6分)', + 'gc'=>'过程', + 'gc_8_m'=>'8年级体质健康统测(10分)', + 'gc_8_r'=>'8年级体育与健康知识机考(10分)', + ]; + protected $city_data_rule_is_choice = ['xc_2','xc_3','xc_4']; + + protected $type_all = [ + '1'=>'整数填数字(例肺活量)', + '2'=>'小数(例50米跑)', + '3'=>'拖动区间(例坐位体前屈:-15至30之间,需要有小数1位)', + '4'=>'分钟秒钟(例1000米跑)', + ]; + protected $city_data_rule2 = [ '北京'=>[ 'xc'=>[ @@ -41,44 +62,153 @@ class Sportstesting extends Base{ 'unit'=>'分/秒', 'value'=>'00:00', 'proportion'=>'1', + 'type'=>'4', ], ], '2'=>[ - '800米'=>['list'=>['3:55'=>'8','4:01'=>'7.5','4:08'=>'7','4:16'=>'6.5','4:25'=>'6','4:35'=>'5.5','4:45'=>'5','4:49'=>'4.5','4:53'=>'4','4:57'=>'3.5','5:02'=>'3','5:07'=>'2.5','5:12'=>'2','5:19'=>'1.5','5:26'=>'1','5:35'=>'0.5','5:36'=>'0',],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1',] + '800米'=>[ + 'list'=>[ + '3:55'=>'8', + '4:01'=>'7.5', + '4:08'=>'7', + '4:16'=>'6.5', + '4:25'=>'6', + '4:35'=>'5.5', + '4:45'=>'5', + '4:49'=>'4.5', + '4:53'=>'4', + '4:57'=>'3.5', + '5:02'=>'3', + '5:07'=>'2.5', + '5:12'=>'2', + '5:19'=>'1.5', + '5:26'=>'1', + '5:35'=>'0.5', + '5:36'=>'0', + ], + 'unit'=>'分/秒', + 'value'=>'00:00', + 'proportion'=>'1', + 'type'=>'4', + ] ], ], 'xc_2'=>[ '1'=>[ - '引体向上'=>['list'=>['11'=>'8','10'=>'7.5','9'=>'7','8'=>'6.5','7'=>'6','6'=>'5.5','5'=>'5','4'=>'4.5','3'=>'4','2'=>'3.5','1'=>'3'],'unit'=>'次','value'=>'0','proportion'=>'1',], - '双杠臂屈伸'=>['list'=>['11'=>'8','10'=>'7.5','9'=>'7','8'=>'6.5','7'=>'6','6'=>'5.5','5'=>'5','4'=>'4.5','3'=>'4','2'=>'3.5','1'=>'3'],'unit'=>'次','value'=>'0','proportion'=>'1',], + '引体向上'=>[ + 'list'=>[ + '11'=>'8', + '10'=>'7.5', + '9'=>'7', + '8'=>'6.5', + '7'=>'6', + '6'=>'5.5', + '5'=>'5', + '4'=>'4.5', + '3'=>'4', + '2'=>'3.5', + '1'=>'3' + ], + 'unit'=>'次', + 'value'=>'0', + 'proportion'=>'1', + 'type'=>'1', + ], + '双杠臂屈伸'=>[ + 'list'=>[ + '11'=>'8', + '10'=>'7.5', + '9'=>'7', + '8'=>'6.5', + '7'=>'6', + '6'=>'5.5', + '5'=>'5', + '4'=>'4.5', + '3'=>'4', + '2'=>'3.5', + '1'=>'3' + ], + 'unit'=>'次', + 'value'=>'0', + 'proportion'=>'1', + 'type'=>'1', + ], ], '2'=>[ - '斜身引体'=>['list'=>['40'=>'8','36'=>'7.5','32'=>'7','28'=>'6.5','24'=>'6','20'=>'5.5','16'=>'5','12'=>'4.5','10'=>'4','9'=>'3.5','8'=>'3','7'=>'2.5','6'=>'2','5'=>'1.5','4'=>'1','3'=>'0.5','2'=>'0'],'unit'=>'次','value'=>'0','proportion'=>'1',], - '仰卧起坐'=>['list'=>['42'=>'8','40'=>'7.5','37'=>'7','34'=>'6.5','30'=>'6','26'=>'5.5','22'=>'5','21'=>'4.5','20'=>'4','19'=>'3.5','18'=>'3','17'=>'2.5','16'=>'2','15'=>'1.5','14'=>'1','13'=>'0.5','12'=>'0'],'unit'=>'次','value'=>'0','proportion'=>'1',], + '斜身引体'=>[ + 'list'=>[ + '40'=>'8', + '36'=>'7.5', + '32'=>'7', + '28'=>'6.5', + '24'=>'6', + '20'=>'5.5', + '16'=>'5', + '12'=>'4.5', + '10'=>'4', + '9'=>'3.5', + '8'=>'3', + '7'=>'2.5', + '6'=>'2', + '5'=>'1.5', + '4'=>'1', + '3'=>'0.5', + '2'=>'0' + ], + 'unit'=>'次', + 'value'=>'0', + 'proportion'=>'1', + 'type'=>'1', + ], + '仰卧起坐'=>[ + 'list'=>[ + '42'=>'8', + '40'=>'7.5', + '37'=>'7', + '34'=>'6.5', + '30'=>'6', + '26'=>'5.5', + '22'=>'5', + '21'=>'4.5', + '20'=>'4', + '19'=>'3.5', + '18'=>'3', + '17'=>'2.5', + '16'=>'2', + '15'=>'1.5', + '14'=>'1', + '13'=>'0.5', + '12'=>'0' + ], + 'unit'=>'次', + 'value'=>'0', + 'proportion'=>'1', + 'type'=>'1', + ], ], ], 'xc_3'=>[ '1'=>[ - '足球运球/射门'=>['list'=>['19.5'=>'8','20.0'=>'7.5','20.5'=>'7','21.0'=>'6.5','21.5'=>'6','22.0'=>'5.5','22.5'=>'5','23.0'=>'4.5','23.8'=>'4','24.6'=>'3.5','25.4'=>'3','26.2'=>'2.5','27.0'=>'2','27.8'=>'1.5','28.6'=>'1','29.4'=>'0.5','29.5'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1',], + '足球运球/射门'=>['list'=>['19.5'=>'8','20.0'=>'7.5','20.5'=>'7','21.0'=>'6.5','21.5'=>'6','22.0'=>'5.5','22.5'=>'5','23.0'=>'4.5','23.8'=>'4','24.6'=>'3.5','25.4'=>'3','26.2'=>'2.5','27.0'=>'2','27.8'=>'1.5','28.6'=>'1','29.4'=>'0.5','29.5'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1','type'=>'2',], ], '2'=>[ - '足球运球/射门'=>['list'=>['21.0'=>'8','21.5'=>'7.5','22.0'=>'7','22.5'=>'6.5','23.0'=>'6','23.5'=>'5.5','24.0'=>'5','24.5'=>'4.5','25.3'=>'4','26.1'=>'3.5','26.9'=>'3','27.7'=>'2.5','28.5'=>'2','29.3'=>'1.5','30.1'=>'1','30.9'=>'0.5','31.0'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1',], + '足球运球/射门'=>['list'=>['21.0'=>'8','21.5'=>'7.5','22.0'=>'7','22.5'=>'6.5','23.0'=>'6','23.5'=>'5.5','24.0'=>'5','24.5'=>'4.5','25.3'=>'4','26.1'=>'3.5','26.9'=>'3','27.7'=>'2.5','28.5'=>'2','29.3'=>'1.5','30.1'=>'1','30.9'=>'0.5','31.0'=>'0'],'unit'=>'秒','value'=>'00.0','proportion'=>'1','type'=>'2',], ], ], 'xc_4'=>[ '1'=>[ - '100米游泳'=>['list'=>['2:25'=>'6','2:35'=>'5.5','2:45'=>'5','2:55'=>'4.5','3:05'=>'4','3:15'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1',], + '100米游泳'=>['list'=>['2:25'=>'6','2:35'=>'5.5','2:45'=>'5','2:55'=>'4.5','3:05'=>'4','3:15'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1','type'=>'4',], ], '2'=>[ - '100米游泳'=>['list'=>['2:40'=>'6','2:48'=>'5.5','2:56'=>'5','3:04'=>'4.5','3:12'=>'4','3:20'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1',], + '100米游泳'=>['list'=>['2:40'=>'6','2:48'=>'5.5','2:56'=>'5','3:04'=>'4.5','3:12'=>'4','3:20'=>'3.5','3:30'=>'3','3:40'=>'2.5','3:50'=>'2','4:00'=>'1.5','4:10'=>'1','4:20'=>'0.5','4:21'=>'0'],'unit'=>'分/秒','value'=>'00:00','proportion'=>'1','type'=>'4',], ], ], ], 'gc'=>[ - 'gc_8'=>[ + 'gc_8_m'=>[ '1'=>[ - 'BMI'=>['list'=>['15.6'=>'80','22.5'=>'100','25.2'=>'80','100'=>'60'],'unit'=>'','value'=>'0','proportion'=>'0.15',], - '肺活量'=>['list'=>['3940'=>'100','3820'=>'95','3700'=>'90','3450'=>'85','3200'=>'80','3080'=>'78','2960'=>'76','2840'=>'74','2720'=>'72','2600'=>'70','2480'=>'68','2360'=>'66','2240'=>'64','2120'=>'62','2000'=>'60','1890'=>'50','1780'=>'40','1670'=>'30','1560'=>'20','1450'=>'10',],'unit'=>'ml','value'=>'0','proportion'=>'0.15',], + 'BMI'=>['list'=>['15.6'=>'80','22.5'=>'100','25.2'=>'80','100'=>'60'],'unit'=>'','value'=>'0','proportion'=>'0.15','type'=>'2',], + '肺活量'=>['list'=>['3940'=>'100','3820'=>'95','3700'=>'90','3450'=>'85','3200'=>'80','3080'=>'78','2960'=>'76','2840'=>'74','2720'=>'72','2600'=>'70','2480'=>'68','2360'=>'66','2240'=>'64','2120'=>'62','2000'=>'60','1890'=>'50','1780'=>'40','1670'=>'30','1560'=>'20','1450'=>'10',],'unit'=>'ml','value'=>'0','proportion'=>'0.15','type'=>'1',], '50米跑'=>[ 'list'=>[ '7.5'=>'100', @@ -103,8 +233,9 @@ class Sportstesting extends Base{ '10.9'=>'10', ], 'unit'=>'秒', - 'value'=>'0', + 'value'=>'00.0', 'proportion'=>'0.2', + 'type'=>'2', ], '坐位体前屈'=>[ 'list'=>[ @@ -130,8 +261,9 @@ class Sportstesting extends Base{ '-7.4'=>'10', ], 'unit'=>'cm', - 'value'=>'0', + 'value'=>'00.0', 'proportion'=>'0.1', + 'type'=>'3', ], '立定跳远'=>[ 'list'=>[ @@ -159,6 +291,7 @@ class Sportstesting extends Base{ 'unit'=>'cm', 'value'=>'0', 'proportion'=>'0.1', + 'type'=>'1', ], '引体向上'=>[ 'list'=>[ @@ -178,9 +311,10 @@ class Sportstesting extends Base{ '1'=>'20', '0'=>'10', ], - 'unit'=>'cm', + 'unit'=>'个', 'value'=>'0', 'proportion'=>'0.1', + 'type'=>'1', 'add_point'=>[ '10'=>'10', '9'=>'9', @@ -217,9 +351,10 @@ class Sportstesting extends Base{ '6:25'=>'20', '6:45'=>'10', ], - 'unit'=>'cm', + 'unit'=>'分/秒', 'value'=>'00:00', 'proportion'=>'0.2', + 'type'=>'4', 'add_point'=>[ '-35'=>'10', '-32'=>'9', @@ -243,8 +378,9 @@ class Sportstesting extends Base{ '100'=>'60' ], 'unit'=>'', - 'value'=>'0', + 'value'=>'00.0', 'proportion'=>'0.15', + 'type'=>'2', ], '肺活量'=>[ 'list'=>[ @@ -272,6 +408,7 @@ class Sportstesting extends Base{ 'unit'=>'ml', 'value'=>'0', 'proportion'=>'0.15', + 'type'=>'1', ], '50米跑'=>[ 'list'=>[ @@ -297,8 +434,9 @@ class Sportstesting extends Base{ '11.8'=>'10', ], 'unit'=>'秒', - 'value'=>'0', + 'value'=>'00.0', 'proportion'=>'0.2', + 'type'=>'2', ], '坐位体前屈'=>[ 'list'=>[ @@ -324,8 +462,9 @@ class Sportstesting extends Base{ '-1.1'=>'10', ], 'unit'=>'cm', - 'value'=>'0', + 'value'=>'00.0', 'proportion'=>'0.1', + 'type'=>'3', ], '立定跳远'=>[ 'list'=>[ @@ -353,6 +492,7 @@ class Sportstesting extends Base{ 'unit'=>'cm', 'value'=>'0', 'proportion'=>'0.1', + 'type'=>'1', ], '一分钟仰卧起坐'=>[ 'list'=>[ @@ -377,9 +517,10 @@ class Sportstesting extends Base{ '13'=>'20', '11'=>'10', ], - 'unit'=>'cm', + 'unit'=>'个', 'value'=>'0', 'proportion'=>'0.1', + 'type'=>'1', 'add_point'=>[ '13'=>'10', '12'=>'9', @@ -416,9 +557,10 @@ class Sportstesting extends Base{ '5:30'=>'20', '5:40'=>'10', ], - 'unit'=>'cm', + 'unit'=>'分/秒', 'value'=>'00:00', 'proportion'=>'0.2', + 'type'=>'4', 'add_point'=>[ '-50'=>'10', '-45'=>'9', @@ -433,6 +575,16 @@ class Sportstesting extends Base{ ] ], ], + ], + 'gc_8_r'=>[ + '1'=>[ + '机测'=>[ + 'list'=>[],'unit'=>'分','value'=>'0','proportion'=>'1','type'=>'1',], + ], + '2'=>[ + '机测'=>[ + 'list'=>[],'unit'=>'分','value'=>'0','proportion'=>'1','type'=>'1',], + ] ] ] ], @@ -446,7 +598,7 @@ class Sportstesting extends Base{ ################################################################接口################################################################ ################################################################接口################################################################ // 获取单个类型列表 - public function sportstesting_get_type_list($data = ['aud_id'=>'25','parameter_data'=>'北京-xc-2','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ + public function sportstesting_get_type_list($data = ['aud_id'=>'25','parameter_data'=>'北京','gender'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ if(count(input('post.')) > 0){ $data = input('post.'); } @@ -458,6 +610,7 @@ class Sportstesting extends Base{ return $this->msg(20001); } unset($data['token']); + // cache('sportstesting_get_type_list',json_encode($data)); return $this->sportstesting_get_type_list_action($data); } // 获取地区类型列表 @@ -473,9 +626,10 @@ class Sportstesting extends Base{ return $this->msg(20001); } unset($data['token']); + // cache('sportstesting_get_region_list',json_encode($data)); return $this->sportstesting_get_region_list_action($data); } - // 获取体测最后一次数据 + // 获取估分最后一次数据 public function sportstesting_get_last_data($data = ['aud_id'=>'25','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ if(count(input('post.')) > 0){ $data = input('post.'); @@ -487,6 +641,7 @@ class Sportstesting extends Base{ return $this->msg(20001); } unset($data['token']); + // cache('sportstesting_get_last_data',json_encode($data)); return $this->sportstesting_get_last_data_action($data); } @@ -501,56 +656,241 @@ class Sportstesting extends Base{ if($this->token_time_validate($data['token']) === false){ return $this->msg(20001); } + // cache('sportstesting_set_once_data',json_encode($data)); + // return $this->msg($data); unset($data['token']); return $this->sportstesting_set_once_data_action($data); } + // 获取估分历史列表 + public function sportstesting_get_all_list($data = ['aud_id'=>'25','page'=>'1','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data) || !array_key_exists('page', $data)){ + return $this->msg(10001); + } + // cache($data['token'], time()); + if($this->token_time_validate($data['token']) === false){ + return $this->msg(20001); + } + unset($data['token']); + // cache('sportstesting_get_all_list',json_encode($data)); + return $this->sportstesting_get_all_list_action($data); + } + // 获取估分历史详情 + public function sportstesting_get_one_details($data = ['id'=>'2','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); + } + // cache($data['token'], time()); + if($this->token_time_validate($data['token']) === false){ + return $this->msg(20001); + } + unset($data['token']); + // cache('sportstesting_get_one_details',json_encode($data)); + return $this->sportstesting_get_one_details_action($data); + } + ################################################################业务################################################################ ################################################sportstesting_get_type_list public function sportstesting_get_type_list_action($data){ - $parameter_data = explode('-',$data['parameter_data']); - if(count($parameter_data) < 3){ - return $this->msg(10005); - } - if(!array_key_exists($parameter_data[0], $this->city_data_rule2)){ - return $this->msg(10005); - } - if(!array_key_exists($parameter_data[1], $this->city_data_rule2[$parameter_data[0]])){ - return $this->msg(10005); - } - if(!array_key_exists($parameter_data[1].'_'.$parameter_data[2], $this->city_data_rule2[$parameter_data[0]][$parameter_data[1]])){ + // $parameter_data = explode('-',$data['parameter_data']); + // if(count($parameter_data) < 3){ + // return $this->msg(10005); + // } + if(!array_key_exists($data['parameter_data'], $this->city_data_rule2)){ return $this->msg(10005); } + // if(!array_key_exists($parameter_data[1], $this->city_data_rule2[$parameter_data[0]])){ + // return $this->msg(10005); + // } + // if(!array_key_exists($parameter_data[1].'_'.$parameter_data[2], $this->city_data_rule2[$parameter_data[0]][$parameter_data[1]])){ + // return $this->msg(10005); + // } $data['gender'] = $data['gender'] == 2?$data['gender']:1; $result['list'] = []; - foreach ($this->city_data_rule2[$parameter_data[0]][$parameter_data[1]][$parameter_data[1].'_'.$parameter_data[2]][$data['gender']] as $key => $value) { - // dump($key); - array_push($result['list'],['name'=>$key,'unit'=>$value['unit'],'value'=>'0']); + // city_data_rule_is_choice + foreach ($this->city_data_rule2[$data['parameter_data']] as $key => $value) { + foreach ($value as $k1 => $v1) { + if(in_array($k1,$this->city_data_rule_is_choice)){ + $temporary_arr_1 = ['key'=>$k1,'list'=>[]]; + foreach ($v1[$data['gender']] as $k2 => $v2) { + array_push($temporary_arr_1['list'],[ + 'name'=>$k2, + 'proportion'=>$v2['proportion'], + 'value'=>$v2['value'], + 'proportion_value'=>null, + 'unit'=>$v2['unit'], + 'type'=>$v2['type'], + ]); + } + array_push($result['list'],$temporary_arr_1); + } + } } + // foreach ($this->city_data_rule2[$parameter_data[0]][$parameter_data[1]][$parameter_data[1].'_'.$parameter_data[2]][$data['gender']] as $key => $value) { + // dump($key); + // dump($value); + // // $temporary_arr_1 = ['name'=>$key,'proportion'=>$value['proportion'],'value'=>$value['value'],'proportion_value'=>null,'unit'=>$value['unit']]; + // // array_push($result['list'],$temporary_arr_1); + // } + // die; + // dump($result); return $this->msg($result); } + ################################################sportstesting_get_region_list public function sportstesting_get_region_list_action($data){ if(!array_key_exists($data['parameter_data'], $this->city_data_rule2)){ return $this->msg(10005); } - $result = []; + $result['list'] = []; + $result['total_score'] = 0; foreach ($this->city_data_rule2[$data['parameter_data']] as $key => $value) { - // 现场/过程 - $result[$key] = []; + $temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]]; foreach ($value as $k1 => $v1) { - // 现场1234/过程1234 - // $result[$key][$k1] = []; - $result[$key][$k1]['list'] = []; - foreach ($v1[$data['gender']] as $k2 => $v2) { - // dump($k2); - array_push($result[$key][$k1]['list'],['name'=>$k2,'unit'=>$v2['unit'],'value'=>$v2['value']]); + $temporary_pd = in_array($k1,$this->city_data_rule_is_choice); + $temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k1],'key'=>$k1,'is_choice'=>$temporary_pd?1:0,'list'=>[]]; + if(!$temporary_pd){ + foreach ($v1[$data['gender']] as $k2 => $v2) { + + // dump($k2); + // dump($v2); + $temporary_arr_3 = ['name'=>$k2,'proportion'=>$v2['proportion'],'value'=>$v2['value'],'proportion_value'=>null,'unit'=>$v2['unit'],'type'=>$v2['type']]; + array_push($temporary_arr_2['list'],$temporary_arr_3); + } } + + array_push($temporary_arr_1['list'],$temporary_arr_2); } + array_push($result['list'],$temporary_arr_1); } - // dump($result); + // die; return $this->msg($result); } + + ################################################sportstesting_get_last_data + public function sportstesting_get_last_data_action($data){ + $user_data = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->order('id desc')->find(); + + if($user_data){ + $temporary_data = json_decode($user_data['content'],true); + // dump($temporary_data); + $result['list'] = []; + $result['total_score'] = $temporary_data['total_score']; + unset($temporary_data['total_score']); + foreach ($temporary_data as $key => $value) { + $temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]]; + foreach ($value as $k => $v) { + $temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k],'key'=>$k,'list'=>[]]; + foreach ($v as $k1 => $v1) { + array_push($temporary_arr_2['list'],$v1); + } + array_push($temporary_arr_1['list'],$temporary_arr_2); + } + array_push($result['list'],$temporary_arr_1); + } + return $this->msg($result); + }else{ + $user_data = Db::table('app_user_data')->where(['id'=>$data['aud_id']])->field('id,grade')->find(); + $result['list'] = [ + [ + 'name'=>'现场', + 'key'=>'xc', + 'list'=>[ + ['name'=>'第一类:素质项目Ⅰ(8分)','key'=>'xc_1','list'=>[ + $user_data==2?['name'=>'800米','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'1000米','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ],], + ['name'=>'第二类:素质项目Ⅱ(8分)','key'=>'xc_2','list'=>[],], + ['name'=>'第三类:运动能力Ⅰ(8分)','key'=>'xc_3','list'=>[],], + ['name'=>'第四类:运动能力Ⅱ(6分)','key'=>'xc_4','list'=>[],], + ], + ], + [ + 'name'=>'过程', + 'key'=>'gc', + 'list'=>[ + ['name'=>'8年级体质健康统测(10分)','key'=>'gc_8_m','list'=>[ + ['name'=>'BMI','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ['name'=>'肺活量','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ['name'=>'50米跑','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ['name'=>'坐位体前屈','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ['name'=>'立定跳远','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + $user_data==2?['name'=>'一分钟仰卧起坐','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'引体向上','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + $user_data==2?['name'=>'女生800米','proportion'=>'1','value'=>'0','proportion_value'=>'0']:['name'=>'男生1000米','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ],], + ['name'=>'8年级体育与健康知识机考(10分)','key'=>'gc_8_r','list'=>[ + ['name'=>'机考','proportion'=>'1','value'=>'0','proportion_value'=>'0'], + ],], + ], + ], + ]; + $result['total_score'] = 0; + return $this->msg($result); + } + } + ################################################sportstesting_get_all_list + public function sportstesting_get_all_list_action($data){ + $user_data_num = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->count(); + $user_data = Db::table('app_region_scores_data')->where(['aud_id'=>$data['aud_id']])->page($data['page'],$this->page_num)->order('id desc')->select(); + + if($user_data){ + $result = []; + $result['totalrows'] = $user_data_num; + $result['rows'] = []; + $result['pageno'] = $data['page']; + $result['pagesize'] = $this->page_num; + $result['totalpage'] = ceil($result['totalrows']/$this->page_num); + foreach ($user_data as $key => $value) { + array_push($result['rows'],[ + 'id'=>$value['id'], + 'create_time'=>$value['create_time'], + 'score'=>$value['score'], + ]); + } + return $this->msg($result); + }else{ + return $this->msg(10004); + } + } + ################################################sportstesting_get_one_details + public function sportstesting_get_one_details_action($data){ + $user_data = Db::table('app_region_scores_data')->where(['id'=>$data['id']])->find(); + if($user_data){ + $temporary_data = json_decode($user_data['content'],true); + $temporary_data['create_time'] = $user_data['create_time']; + $temporary_data['region'] = explode(',',$user_data['region'])[0]; + // $temporary_data[''] + // $result['list'] = []; + // $result['total_score'] = $temporary_data['total_score']; + // unset($temporary_data['total_score']); + // dump($temporary_data); + return $this->msg($temporary_data); + // foreach ($temporary_data['list'] as $key => $value) { + // // dump($this->city_data_rule_name[$key]); + // $temporary_arr_1 = ['name'=>$this->city_data_rule_name[$key],'key'=>$key,'list'=>[]]; + // // dump($temporary_arr_1); + // foreach ($value as $k => $v) { + // // dump($k); + // // dump($v); + // $temporary_arr_2 = ['name'=>$this->city_data_rule_name[$k],'key'=>$k,'list'=>[]]; + // foreach ($v as $k1 => $v1) { + // array_push($temporary_arr_2['list'],$v1); + // } + // array_push($temporary_arr_1['list'],$temporary_arr_2); + // } + // array_push($result['list'],$temporary_arr_1); + // } + // return $this->msg($result); + }else{ + return $this->msg(10004); + } + } + ################################################sportstesting_set_once_data public function sportstesting_set_once_data_action($data){ $region = explode(',',$data['parameter_data']); @@ -560,168 +900,336 @@ class Sportstesting extends Base{ if($region[0] == '北京市'){ $data_data = [ - 'xc'=>[ - 'xc_1'=>['name'=>'1000米','value'=>'4:40'], - 'xc_2'=>['name'=>'引体向上','value'=>'8'], - 'xc_3'=>['name'=>'足球运球/射门','value'=>'21.6'], - 'xc_4'=>['name'=>'100米游泳','value'=>'3:16'], + [ + "name"=>"现场", + "key"=>"xc", + "list"=>[ + [ + "name"=>"第一类:素质项目Ⅰ(8分)", + "key"=>"xc_1", + "is_choice"=>0, + "list"=>[ + [ + "name"=>"1000米", + "proportion"=>"1", + "value"=>"4:19", + "proportion_value"=>null, + "unit"=>"分/秒" + ] + ] + ], + [ + "name"=>"第二类:素质项目Ⅱ(8分)", + "key"=>"xc_2", + "is_choice"=>1, + "list"=>[ + [ + "name"=>"引体向上", + "proportion"=>"1", + "value"=>"5", + "proportion_value"=>null, + "unit"=>"个" + ] + ] + ], + [ + "name"=>"第三类:运动能力Ⅰ(8分)", + "key"=>"xc_3", + "is_choice"=>1, + "list"=>[ + [ + "name"=>"足球运球/射门", + "proportion"=>"1", + "value"=>"20.4", + "proportion_value"=>null, + "unit"=>"秒" + ] + ] + ], + [ + "name"=>"第四类:运动能力Ⅱ(6分)", + "key"=>"xc_4", + "is_choice"=>1, + "list"=>[ + [ + "name"=>"100米游泳", + "proportion"=>"1", + "value"=>"2:34", + "proportion_value"=>null, + "unit"=>"分/秒" + ] + ] + ] + ] ], - 'gc'=>[ - 'gc_8'=>[ - ['name'=>'BMI','value'=>'22.5'], - ['name'=>'肺活量','value'=>'3000'], - ['name'=>'50米跑','value'=>'8.2'], - ['name'=>'坐位体前屈','value'=>'10.4'], - ['name'=>'立定跳远','value'=>'200'], - ['name'=>'引体向上','value'=>'10'], - ['name'=>'男生1000米','value'=>'4:05'], + [ + "name"=>"过程", + "key"=>"gc", + "list"=>[ + [ + "name"=>"8年级体质健康统测(10分)", + "key"=>"gc_8_m", + "is_choice"=>0, + "list"=>[ + [ + "name"=>"BMI", + "proportion"=>"0.15", + "value"=>"17.5", + "proportion_value"=>null, + "unit"=>"" + ], + [ + "name"=>"肺活量", + "proportion"=>"0.15", + "value"=>"3450", + "proportion_value"=>null, + "unit"=>"ml" + ], + [ + "name"=>"50米跑", + "proportion"=>"0.2", + "value"=>"8.5", + "proportion_value"=>null, + "unit"=>"秒" + ], + [ + "name"=>"坐位体前屈", + "proportion"=>"0.1", + "value"=>"10.3", + "proportion_value"=>null, + "unit"=>"cm" + ], + [ + "name"=>"立定跳远", + "proportion"=>"0.1", + "value"=>"170", + "proportion_value"=>null, + "unit"=>"cm" + ], + [ + "name"=>"引体向上", + "proportion"=>"0.1", + "value"=>"12", + "proportion_value"=>null, + "unit"=>"个" + ], + [ + "name"=>"男生1000米", + "proportion"=>"0.2", + "value"=>"4:00", + "proportion_value"=>null, + "unit"=>"分/秒" + ] + ] + ], + [ + "name"=>"8年级体育与健康知识机考(10分)", + "key"=>"gc_8_r", + "is_choice"=>0, + "list"=>[ + [ + "name"=>"机测", + "proportion"=>"1", + "value"=>"5", + "proportion_value"=>null, + "unit"=>"分" + ] + ] + ] ] ] ]; - $data['result_data'] = $data_data; - foreach ($data['result_data']['xc'] as $k1 => $v1) { - $temporary_rule = $rule['xc'][$k1][$data['gender']][$v1['name']]; - $data['result_data']['xc'][$k1]['rule'] = $temporary_rule; - $result['xc'][$k1][0]['name'] = $v1['name']; - $result['xc'][$k1][0]['proportion'] = $temporary_rule['proportion']; - } - foreach ($data['result_data']['gc']['gc_8'] as $k1 => $v1) { - $temporary_rule = $rule['gc']['gc_8'][$data['gender']][$v1['name']]; - $data['result_data']['gc']['gc_8'][$k1]['rule'] = $temporary_rule; - $result['gc']['gc_8'][$k1]['name'] = $v1['name']; - } - - // dump($result); - // xc_1 - foreach ($data['result_data']['xc']['xc_1']['rule']['list'] as $key => $value) { - if($this->calculate_minutes_seconds($key,$data['result_data']['xc']['xc_1']['value'])[0]){ - $result['xc']['xc_1'][0]['value'] = $value; - $result['xc']['xc_1'][0]['proportion_value'] = $value; - break; - } - } - // dump($result); + // $data['result_data'] = '[{"name":"现场","key":"xc","list":[{"name":"第一类:素质项目Ⅰ(8分)","key":"xc_1","is_choice":0,"list":[{"name":"1000米","proportion":"1","value":"10:00","proportion_value":null,"unit":"分\/秒","type":"4"}]},{"name":"第二类:素质项目Ⅱ(8分)","key":"xc_2","is_choice":1,"list":[]},{"name":"第三类:运动能力Ⅰ(8分)","key":"xc_3","is_choice":1,"list":[]},{"name":"第四类:运动能力Ⅱ(6分)","key":"xc_4","is_choice":1,"list":[]}]},{"name":"过程","key":"gc","list":[{"name":"8年级体质健康统测(10分)","key":"gc_8_m","is_choice":0,"list":[{"name":"BMI","proportion":"0.15","value":"0","proportion_value":null,"unit":"","type":"4"},{"name":"肺活量","proportion":"0.15","value":"0","proportion_value":null,"unit":"ml","type":"4"},{"name":"50米跑","proportion":"0.2","value":"00.0","proportion_value":null,"unit":"秒","type":"4"},{"name":"坐位体前屈","proportion":"0.1","value":"-1","proportion_value":null,"unit":"cm","type":"4"},{"name":"立定跳远","proportion":"0.1","value":"0","proportion_value":null,"unit":"cm","type":"4"},{"name":"引体向上","proportion":"0.1","value":"0","proportion_value":null,"unit":"个","type":"4"},{"name":"男生1000米","proportion":"0.2","value":"00:00","proportion_value":null,"unit":"分\/秒","type":"4"}]},{"name":"8年级体育与健康知识机考(10分)","key":"gc_8_r","is_choice":0,"list":[{"name":"机测","proportion":"1","value":"10","proportion_value":null,"unit":"分","type":"4"}]}]}]'; + // dump($data['result_data']); + // dump(json_encode($data['result_data'])); // die; - // xc_2 - foreach ($data['result_data']['xc']['xc_2']['rule']['list'] as $key => $value) { - if(in_array($data['result_data']['xc']['xc_2']['name'],['引体向上','双杠臂屈伸','斜身引体','仰卧起坐'])){ - if($data['result_data']['xc']['xc_2']['value'] >= $key){ - $result['xc']['xc_2'][0]['value'] = $value; - $result['xc']['xc_2'][0]['proportion_value'] = $value; - break; - } - } - } - // xc_3 - foreach ($data['result_data']['xc']['xc_3']['rule']['list'] as $key => $value) { - if(in_array($data['result_data']['xc']['xc_3']['name'],['足球运球/射门'])){ - if($data['result_data']['xc']['xc_3']['value'] <= $key){ - $result['xc']['xc_3'][0]['value'] = $value; - $result['xc']['xc_3'][0]['proportion_value'] = $value; - break; - } - } - } - // xc_4 - foreach ($data['result_data']['xc']['xc_4']['rule']['list'] as $key => $value) { - if(in_array($data['result_data']['xc']['xc_4']['name'],['100米游泳'])){ - if($this->calculate_minutes_seconds($key,$data['result_data']['xc']['xc_4']['value'])[0]){ - $result['xc']['xc_4'][0]['value'] = $value; - $result['xc']['xc_4'][0]['proportion_value'] = $value; - break; - } - } - } + // return $this->msg(json_decode($data['result_data'],true)); + + // xc_1 + $data['result_data'] = json_decode($data['result_data'],true); + foreach ($data['result_data'] as $key => $value) { + // dump($key); + if($value['key'] == 'xc'){ + foreach ($value['list'] as $k1 => $v1) { + if(count($v1['list']) <= 0){ + break; + } + // dump($v1); + foreach ($v1['list'] as $k2 => $v2) { + // dump($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list']); + foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list'] as $r_k => $r_v) { + // dump($r_k); + // dump($r_k); + if($v2['value'] == '00:00' || $v2['value'] == '00.0' || $v2['value'] == '0'){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = '0'; + break; + } - // gc_8 - foreach ($data['result_data']['gc']['gc_8'] as $key => $value) { - $result['gc']['gc_8'][$key]['name'] = $value['name']; - $result['gc']['gc_8'][$key]['proportion'] = $value['rule']['proportion']; - foreach ($value['rule']['list'] as $k1 => $v1) { - if($value['name'] == 'BMI'){ - if($value['value'] <= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - break; - } - }else if($value['name'] == '肺活量'){ - if($value['value'] >= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - break; - } - }else if($value['name'] == '50米跑'){ - if($value['value'] <= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - break; - } - }else if($value['name'] == '坐位体前屈'){ - if($value['value'] >= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - break; - } - }else if($value['name'] == '立定跳远'){ - if($value['value'] >= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - break; - } - }else if($value['name'] == '引体向上'){ - if($value['value'] >= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - $add_point = $value['value'] - 14; - if(($add_point>=1) && ($add_point<=10)){ - $result['gc']['gc_8'][$key]['value'] = $add_point + $result['gc']['gc_8'][$key]['value']; - } - break; - } - }else if($value['name'] == '一分钟仰卧起坐'){ - if($value['value'] >= $k1){ - $result['gc']['gc_8'][$key]['value'] = $v1; - $add_point = $value['value'] - 51; - if(($add_point>=2) && ($add_point<=13)){ - foreach ($value['rule']['add_point'] as $kk1 => $vv1) { - if($add_point >= $kk1){ - $result['gc']['gc_8'][$key]['value'] = $vv1 + $result['gc']['gc_8'][$key]['value']; + // 设默认分值为0 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = '0'; + if($v1['key'] == 'xc_1'){ + if($this->calculate_minutes_seconds($r_k,$v2['value'])[0]){ + // dump($data['result_data'][$key]); + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v; break; } - } - }else{ - break; - } - - } - }else if($value['name'] == '男生1000米' || $value['name'] == '女生800米'){ - $temporary_js = $this->calculate_minutes_seconds($k1,$value['value']); - if($temporary_js[0]){ - $result['gc']['gc_8'][$key]['value'] = $v1; - if($result['gc']['gc_8'][$key]['value'] == 100 && $temporary_js[1] < -4){ - foreach ($value['rule']['add_point'] as $kk1 => $vv1) { - if($temporary_js[1] <= $kk1){ - $result['gc']['gc_8'][$key]['value'] = $vv1 + $result['gc']['gc_8'][$key]['value']; - break; + }else if($v1['key'] == 'xc_2'){ + if(in_array($v2['name'],['引体向上','双杠臂屈伸','斜身引体','仰卧起坐'])){ + if($v2['value'] >= $r_k){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v; + break; + } + } + }else if($v1['key'] == 'xc_3'){ + if(in_array($v2['name'],['足球运球/射门'])){ + if($v2['value'] <= $r_k){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v; + break; + } + } + }else if($v1['key'] == 'xc_4'){ + if(in_array($v2['name'],['100米游泳'])){ + if($this->calculate_minutes_seconds($r_k,$v2['value'])[0]){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['proportion_value'] = $r_v; + break; + } } } - }else{ - break; + } } } + }else{ + foreach ($value['list'] as $k1 => $v1) { + if($v1['key'] == 'gc_8_m'){ + foreach ($v1['list'] as $k2 => $v2) { + foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['list'] as $r_k => $r_v) { + if($v2['value'] == '00:00' || $v2['value'] == '00.0' || $v2['value'] == '0'){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = '0'; + break; + } + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = '0'; + // dump($r_k); + if($v2['name'] == 'BMI'){ + if($v2['value'] <= $r_k){ + // $result['gc']['gc_8'][$key]['value'] = $v1; + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + + break; + } + }else if($v2['name'] == '肺活量'){ + if($v2['value'] >= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + // $result['gc']['gc_8'][$key]['value'] = $v1; + break; + } + }else if($v2['name'] == '50米跑'){ + if($v2['value'] <= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + // $result['gc']['gc_8'][$key]['value'] = $v1; + break; + } + }else if($v2['name'] == '坐位体前屈'){ + if($v2['value'] >= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + // $result['gc']['gc_8'][$key]['value'] = $v1; + break; + } + }else if($v2['name'] == '立定跳远'){ + if($v2['value'] >= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + // $result['gc']['gc_8'][$key]['value'] = $v1; + break; + } + }else if($v2['name'] == '引体向上'){ + if($v2['value'] >= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + // $result['gc']['gc_8'][$key]['value'] = $v1; + $add_point = $v2['value'] - 14; + if(($add_point>=1) && ($add_point<=10)){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $add_point + $data['result_data'][$key]['list'][$k1]['list'][$k2]['value']; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $add_point + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score']; + } + break; + } + }else if($v2['name'] == '一分钟仰卧起坐'){ + if($v2['value'] >= $r_k){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + $add_point = $v2['value'] - 51; + if(($add_point>=2) && ($add_point<=13)){ + foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['add_point'] as $kk1 => $vv1) { + if($add_point >= $kk1){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['value']; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score']; + break; + } + } + }else{ + break; + } + } + }else if($v2['name'] == '男生1000米' || $v2['name'] == '女生800米'){ + $temporary_js = $this->calculate_minutes_seconds($r_k,$v2['value']); + if($temporary_js[0]){ + // $data['result_data'][$key]['list'][$k1]['list'][$k2]['value'] = $r_v; + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $r_v; + if($data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] >= 100 && $temporary_js[1] < -4){ + foreach ($rule[$value['key']][$v1['key']][$data['gender']][$v2['name']]['add_point'] as $kk1 => $vv1) { + if($temporary_js[1] <= $kk1){ + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score'] = $vv1 + $data['result_data'][$key]['list'][$k1]['list'][$k2]['score']; + break; + } + } + }else{ + break; + } + } + + } + } + } + }else{ + // dump($v1['name']); + // dump($v1['list'][0]); + if($v1['list'][0]['value'] >= '10'){ + $data['result_data'][$key]['list'][$k1]['list'][0]['proportion_value'] = '10'; + }else{ + $data['result_data'][$key]['list'][$k1]['list'][0]['proportion_value'] = $v1['list'][0]['value']; + } + + } + } } } - + // die; + + // 乘 bcmul(,,20) // 除 bcdiv(,,20) - foreach ($result['gc']['gc_8'] as $key => $value) { - $result['gc']['gc_8'][$key]['proportion_value'] = bcmul(bcdiv($result['gc']['gc_8'][$key]['value'],10,20),$result['gc']['gc_8'][$key]['proportion'],1); + // dump($data['result_data'][1]['list'][0]['list']); + foreach ($data['result_data'][1]['list'][0]['list'] as $key => $value) { + $data['result_data'][1]['list'][0]['list'][$key]['proportion_value'] = bcmul(bcdiv($data['result_data'][1]['list'][0]['list'][$key]['score'],10,20),$data['result_data'][1]['list'][0]['list'][$key]['proportion'],1); } $num = 0; - foreach ($result as $key => $value) { - foreach ($value as $k1 => $v1) { - foreach ($v1 as $k2 => $v2) { + $result['list'] = $data['result_data']; + foreach ($result['list'] as $key => $value) { + foreach ($value['list'] as $k1 => $v1) { + foreach ($v1['list'] as $k2 => $v2) { $num = bcadd($num,$v2['proportion_value'],1); } } } $result['total_score'] = $num; } + // die; + // return $this->msg($result); $user_card_list = Db::table('app_region_scores_data')->insert([ 'region'=>$data['parameter_data'], 'aud_id'=>$data['aud_id'], @@ -741,9 +1249,21 @@ class Sportstesting extends Base{ ################################################################其他################################################################ public function calculate_minutes_seconds($a,$b){ + // dump($a); + // dump($b); + + // if($b == '00:00'){ + + // } // 分解时间字符串 - list($minutesA, $secondsA) = explode(':', $a); - list($minutesB, $secondsB) = explode(':', $b); + $sjA = explode(':', $a); + $sjB = explode(':', $b); + $minutesA = $sjA[0]; + $secondsA = $sjA[1]; + $minutesB = $sjB[0]; + $secondsB = $sjB[1]; + // list($minutesA, $secondsA) = explode(':', $a); + // list($minutesB, $secondsB) = explode(':', $b); // 转换为秒 $totalSecondsA = intval($minutesA) * 60 + intval($secondsA); @@ -781,5 +1301,22 @@ class Sportstesting extends Base{ // 'update_time'=>date('Y-m-d H:i:s'), // ]); } + public function aaaaaaaaaaaaaaa(){ + // $this->set_rule_action(); + // die; + // return $this->msg($this->city_data_rule2); + // wuyong + // dump('111'); + $aa = cache('ceshiyong'); + dump($aa); + $bb = json_decode($aa,true); + dump($bb['result_data']); + $cc = json_decode($bb['result_data'],true); + + dump($cc); + // return $this->msg($bb['result_data']); + + + } } \ No newline at end of file diff --git a/application/route.php b/application/route.php index 82a0604..e570646 100644 --- a/application/route.php +++ b/application/route.php @@ -51,7 +51,7 @@ Route::any('/card_del_record_data', 'app/pagingcontrast/del_all_record_data'); // ################################登录接口################################ // 注册接口12 Route::any('/register_action', 'app/login/register_action'); -// 注册接口 +// 重置密码 Route::any('/reset_password', 'app/login/reset_password'); // 登录接口 Route::any('/login_action', 'app/login/login_action'); @@ -109,9 +109,26 @@ Route::any('/vitalcapacity_curve_chart', 'app/vitalcapacity/vitalcapacity_curve_ Route::any('/sportstesting_get_type_list', 'app/sportstesting/sportstesting_get_type_list'); // 获取类型列表 Route::any('/sportstesting_get_region_list', 'app/sportstesting/sportstesting_get_region_list'); +// 获取估分最后一次数据 +Route::any('/sportstesting_get_last_data', 'app/sportstesting/sportstesting_get_last_data'); +// 获取估分历史列表 +Route::any('/sportstesting_get_all_list', 'app/sportstesting/sportstesting_get_all_list'); +// 获取估分历史详情 +Route::any('/sportstesting_get_one_details', 'app/sportstesting/sportstesting_get_one_details'); // 计算并存储数据 Route::any('/sportstesting_set_once_data', 'app/sportstesting/sportstesting_set_once_data'); + +// ################################我的接口################################ + +// 获取账号信息 +Route::any('/get_my_account_msg', 'app/myinformation/get_my_account_msg'); +// 修改昵称 +Route::any('/update_my_nickname', 'app/myinformation/update_my_nickname'); +// 邮箱/手机绑定 +Route::any('/update_my_account_msg', 'app/myinformation/update_my_account_msg'); +// 修改密码 +Route::any('/update_my_password', 'app/myinformation/update_my_password'); // // 报告数据(上次数据) // Route::any('/vitalcapacity_data_report', 'app/sportstesting/vitalcapacity_data_report'); // // 曲线 @@ -136,7 +153,7 @@ Route::any('/sportstesting_set_once_data', 'app/sportstesting/sportstesting_set_ // Route::any('/vitalcapacity_standard_interval', 'app/vitalcapacity/vitalcapacity_standard_interval'); -// Route::any('/isNumericArray', 'app/base/isNumericArray'); +Route::any('/wuyong', 'app/sportstesting/aaaaaaaaaaaaaaa'); // 处理404错误 z Route::miss(function(){ diff --git a/public/tsf/head_pic.jpg b/public/tsf/head_pic.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d6ac6e2831a61aedd364a6c8dce6c1850a4557ee GIT binary patch literal 1867 zcmb7EXHZjF6u$2zA(6yjP(mmY2}QtAr6?M~f{vny6pcn96h#C?z=Ggll(m5r0YQRF zP?P|J1QBeMAO;n25y3TP6$PbZfkg~0*_Ytx?(DBUGw;ovd(Zcs?|k>XCl|~A1SllUJuQhi0(CT4xUA2vp(p25o(R)~(Po`{q7p6t`B(-&RP73+# z%|Da?FQAlWo@{A27N9x*J?G_%-ZJ(&kA#bp;|8VNi8vws0 zRWp2Tsh_Led;&4f08uZ%gesdmW_`B6h*BJW#om_deLcRq$D;Hj))}z`&C|~xFZLlk ze%af8dHeI*Nt2+bOpF6Ai4gloizwHV?1Ai3!`&Q(g^;}`-5_gDo<$NApQ$d&bWeL5 z>N1FC3TQ|*G!qg)f%zZX0$$$p;l)q_n7lk{ec3Lw0tuL?g$bR70gdgyqxmA2$c8Fn?Ca^0)6V$|CweP9Ui1gpwS2O)jad}vc{Y$6k=b|S z{dTJb{>apk=}@kyB9Tb-Q)yqH_-RXrZ*vpD^9F#95Narf(s>S+{ zcJ5$|xqS{X9a}CUdcUnHkqVY^Ob|1W$mo;w?;N<}(O8h>Ry==;w#4T$+pqG2aeiUJ z1{;=`Rw)vYgC_iWlQ0s)EVpU}_E+09n zW;@)!P2zM&bLc3ocz-JY7Y3)=CDN4^B*cAQ)hP!%QnVI5)mt0DT^AAN+GgZT(;s1M z#EPCg5L6a(dj`V8PiX9@q?=ApxbmN>7`848e+|x53Z@pq{a2%3_5_OnEJue~HaN%Vy8+qg6Q`>M*VWY}i2l`fmgm-H`wQ literal 0 HcmV?d00001