www_fpvone_cn/application/api/controller/Players.php

193 lines
8.2 KiB
PHP

<?php
/**
* @Created by PhpStorm.
* @Author:Soar
* @Time:2023/10/8 15:47
*/
namespace app\api\controller;
use app\admin\model\PlayerCheck;
use app\common\controller\Api;
use think\Request;
use app\admin\model\ClubInvate;
use app\admin\model\User;
use app\admin\model\LeagueIntegral;
use app\admin\model\Club as ClubModel;
use app\admin\model\cms\Archives;
use app\index\controller\League;
use app\admin\model\Players as PlayersModel;
class Players extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function add_players(Request $request)
{
print_r($request);exit;
$add_data['real_name'] = $request->post("real_name");
$add_data['gender'] = $request->post("gender");
$add_data['birthday'] = $request->post("birthday");
$add_data['age'] = $request->post("age");
$add_data['country'] = $request->post("country");
$add_data['province'] = $request->post("province");
$add_data['city'] = $request->post("city");
$add_data['district'] = $request->post("district");
$add_data['address'] = $request->post("address");
$add_data['player_pic'] = $request->post("player_pic");
$add_data['experience'] = $request->post("experience");
$add_data['guarder_name'] = $request->post("guarder_name");
$add_data['guarder_phone'] = $request->post("guarder_phone");
$add_data['guarder_card_number'] = $request->post("guarder_card_number");
$add_data['guarder_card_type'] = $request->post("guarder_card_type");
$add_data['guarder_card_front_view'] = $request->post("guarder_card_front_view");
$add_data['guarder_card_back_view'] = $request->post("guarder_card_back_view");
$add_data['card_type'] = $request->post("card_type");
$add_data['card_number'] = $request->post("card_number");
$add_data['card_front_view'] = $request->post("card_front_view");
$add_data['card_back_view'] = $request->post("card_back_view");
$add_data['card_view_same'] = $request->post("card_view_same");
$add_data['guarder_card_view_same'] = $request->post("guarder_card_view_same");
$add_data['asfc_user'] = $request->post("asfc_user");
$add_data['membership_id'] = $request->post("membership_id");
$add_data['flight_number'] = $request->post("flight_number");
$add_data['club_members'] = $request->post("club_members");
$add_data['club_name'] = $request->post("club_name");
$add_data['duties'] = $request->post("duties");
}
public function getplayer()
{
$token = $this->auth->getToken();
$token_info = \app\common\library\Token::get($token);
$expiretime = date("Y-m-d H:i:s", $token_info['expiretime']);
$where['member_id'] = $token_info['user_id'];
$plyaerinfo = \app\common\model\Players::get($where);
if (empty($plyaerinfo)) {
$result['data'] = [];
$result['message'] = "请先申请认证飞手!";
$result['code'] = 500;
return json($result);
}
$plyaer['real_name'] = $plyaerinfo->real_name;
$plyaer['phone'] = $plyaerinfo->phone;
$plyaer['age'] = $plyaerinfo->age;
$plyaer['gender'] = $plyaerinfo->gender;
$plyaer['birthday'] = $plyaerinfo->birthday;
$plyaer['country'] = $plyaerinfo->country;
$plyaer['player_status'] = $plyaerinfo->player_status;
$plyaer['player_pic'] = $plyaerinfo->player_pic;
$plyaer['card_number'] = $plyaerinfo->card_number;
$plyaer['check_mark'] = "";
if ($plyaerinfo->player_status == \app\common\model\Players::PLAYERS_MODIFY
|| $plyaerinfo->player_status == \app\common\model\Players::PLAYERS_NO_PASS
) {
$playerCheck = new PlayerCheck();
$check_info = $playerCheck->where("member_id", $token_info['user_id'])
->order("id", "DESC")
->find();
$plyaer['check_mark'] = $check_info->mark;
}
$result['data'] = $plyaer;
$result['message'] = "获取成功";
$result['code'] = 200;
return json($result);
}
public function get_player_detail()
{
$token = $this->auth->getToken();
$token_info = \app\common\library\Token::get($token);
$expiretime = date("Y-m-d H:i:s", $token_info['expiretime']);
$where['member_id'] = $token_info['user_id'];
$plyaerinfo = \app\common\model\Players::get($where);
return $plyaerinfo;
}
public function playerInfo(Request $request){
$player_id = $request->param('player_id');
$member_number = $request->param('member_number');
if(!empty($player_id)){
$player_res = model('players')->getPlayerId($player_id);
}elseif(!empty($member_number)){
$user_info = $user->where('member_number',$member_number)->find();
$player_res = $PlayersModel->field('id,real_name,age,province,player_pic,member_id')->where('member_id',$user_info['id'])->find();
}
$data['player'] = $player_res;
$msg = ['code'=>200,'data'=>$data];
return json($msg);
}
public function getDraPlayer(ClubModel $clubModel,User $user,Request $request,ClubInvate $clubInvate,LeagueIntegral $leagueIntegral){
$Archives = new Archives();
$League = new League();
$PlayersModel = new PlayersModel();
$player_id = $request->param('player_id');
$member_number = $request->param('member_number');
if(!empty($player_id)){
$club_res = $clubInvate->where('player_id',$player_id)->where('status',6)->where('deletetime',null)->find();
$club_info = $clubModel->field('name,name_short,logo')->where('id',$club_res['club_id'])->find();
$player_res = model('players')->getPlayerId($player_id);
$user_info = $user->where('id',$player_res['member_id'])->find();
$player_res['member_number'] = $user_info['member_number'];
}elseif(!empty($member_number)){
$user_info = $user->where('member_number',$member_number)->find();
$player_res = $PlayersModel->field('id,real_name,age,province,player_pic,member_id')->where('member_id',$user_info['id'])->find();
$player_res['member_number'] = $member_number;
$club_res = $clubInvate->where('player_id',$player_res['id'])->where('status',6)->where('deletetime',null)->find();
$club_info = $clubModel->field('name,name_short,logo')->where('id',$club_res['club_id'])->find();
}
$Archives_res = $Archives->where('channel_id',73)->select();
unset($Archives_res[1]);//国家集训队
unset($Archives_res[4]);//测试站
$station_integral = [];$i = 0;
$lastElement = end($Archives_res);
foreach ($Archives_res as $value){
$club_integral_res = $leagueIntegral->where('player_id',$user_info['member_number'])->where('match_id',$value['id'])->find();
if(!empty($club_integral_res)){
//复用分站积分排名
// $res = $League->player_integral($value['id'],$user_info['member_number']);
// var_dump($res);exit;
$station_integral[] = array('match_id'=>$value['id'],'name'=> $value['title'],'sum_grade'=>$club_integral_res['grade'],'number'=>$club_integral_res['number'],'nostart'=>0);
}else{
$station_integral[] = array('match_id'=>$value['id'],'name'=> $value['title'],'sum_grade'=>0,'number'=>0,'nostart'=>0);
}
//判断最后一场比赛是否未开始
if($value['id'] == $lastElement['id']){
$res = db("cms_addonproducts")->where('id',$value['id'])->find();
if(strtotime($res['stime']) > time()){
$station_integral[$i]['nostart'] = 1;
}
// var_dump($res['stime']);exit;
}
// var_dump($club_integral_res);exit;
$i++;
}
$data['player'] = $player_res;
$data['club'] = $club_info;
$data['integral'] = $station_integral;
$msg = ['code'=>200,'data'=>$data];
return json($msg);
// var_dump($integral_res);exit;
}
}