690 lines
32 KiB
PHP
690 lines
32 KiB
PHP
|
<?php
|
|||
|
|
|||
|
|
|||
|
namespace app\admin\controller\cms;
|
|||
|
|
|||
|
use app\admin\model\MatchContestant;
|
|||
|
use app\admin\model\MatchRanking;
|
|||
|
use app\admin\model\MatchScreen;
|
|||
|
use app\admin\model\Players;
|
|||
|
use app\admin\model\User;
|
|||
|
use app\common\controller\Backend;
|
|||
|
use app\admin\service\LeagueService;
|
|||
|
use app\common\exception\UploadException;
|
|||
|
use app\common\library\Upload;
|
|||
|
use fast\Random;
|
|||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|||
|
use think\Cookie;
|
|||
|
use think\Session;
|
|||
|
use app\admin\controller\cms\Leaguexport;
|
|||
|
use app\admin\controller\cms\Leagueround;
|
|||
|
use app\admin\model\LeagueIntegral;
|
|||
|
|
|||
|
class League extends Backend
|
|||
|
{
|
|||
|
protected $noNeedLogin = ['*'];
|
|||
|
|
|||
|
public function _initialize()
|
|||
|
{
|
|||
|
parent::_initialize();
|
|||
|
$this->leagueService = new LeagueService();
|
|||
|
$this->leagueRound = new Leagueround();
|
|||
|
}
|
|||
|
|
|||
|
public function export()
|
|||
|
{
|
|||
|
$matchranking = new MatchRanking();
|
|||
|
$user = new User();
|
|||
|
$players = new Players();
|
|||
|
$this->exportmatch_id = $this->request->param("match_id");
|
|||
|
$this->exportcourse = $this->request->param("course"); // 赛程
|
|||
|
$this->exportround = $this->request->param("other_round");
|
|||
|
$this->exportsorting = $this->request->param("sorting");
|
|||
|
$this->birthday = $this->request->param("birthday");
|
|||
|
// if ($this->exportsorting == "false") {
|
|||
|
// $this->exportsorting = false;
|
|||
|
// }
|
|||
|
|
|||
|
if (empty($this->exportmatch_id)) {
|
|||
|
$this->error("赛事id不能为空!");
|
|||
|
} else if (empty($this->exportcourse)) {
|
|||
|
$this->error("赛程不可为空!");
|
|||
|
}
|
|||
|
|
|||
|
// $row = $this->rankingService->getRankingForCourse($this->exportmatch_id, $this->exportcourse, $this->exportsorting, "最佳成绩");
|
|||
|
if($this->exportcourse == 101 || $this->exportcourse == 102 ){
|
|||
|
$row = $this->leagueService->bestplayerqua($this->exportmatch_id, $this->exportcourse ,true);
|
|||
|
if($this->exportcourse == 101 && $this->exportround != 'best'){
|
|||
|
$row = $this->leagueService->getrank_course($this->exportmatch_id, $this->exportcourse,$this->exportround);
|
|||
|
// var_dump($row);exit;
|
|||
|
}
|
|||
|
// $round = $matchranking->where("match_id", "eq", $this->exportmatch_id)
|
|||
|
// ->where("course", "eq", $this->exportcourse)
|
|||
|
// ->max("other_round");
|
|||
|
// var_dump($this->exportround);exit;
|
|||
|
}
|
|||
|
if($this->exportcourse == 103){
|
|||
|
$Leaguexport = new Leaguexport();
|
|||
|
$row = $this->leagueRound->group_round2($this->exportmatch_id, $this->exportcourse,$this->exportround,true);
|
|||
|
// var_dump($row);exit;
|
|||
|
}
|
|||
|
if($this->exportcourse == 104){
|
|||
|
$Leaguexport = new Leaguexport();
|
|||
|
$row = $this->leagueRound->final_rank($this->exportmatch_id);
|
|||
|
}
|
|||
|
if($this->exportcourse == 'all'){
|
|||
|
$LeagueIntegral = new LeagueIntegral();
|
|||
|
$row = $LeagueIntegral->where('match_id',$this->exportmatch_id)->select();
|
|||
|
if(empty($row)) $this->error('请先生成积分');
|
|||
|
}
|
|||
|
$archives = new \app\admin\model\cms\Archives();
|
|||
|
$PDOStatement = $archives->find($this->exportmatch_id);
|
|||
|
if (empty($PDOStatement)) {
|
|||
|
$this->error('导出数据为空');
|
|||
|
}
|
|||
|
$cellTitles = [
|
|||
|
'player_id' => '编号',
|
|||
|
'player_name' => '姓名',
|
|||
|
'gender' => '性别',
|
|||
|
// 'position' => '号位',
|
|||
|
'name_short' => '所属队伍',
|
|||
|
'first_round_time1' => '第一圈',
|
|||
|
'first_round_time2' => '第二圈',
|
|||
|
'first_round_time3' => '第三圈',
|
|||
|
'second_round_time1' => '第一圈',
|
|||
|
'second_round_time2' => '第二圈',
|
|||
|
'second_round_time3' => '第三圈',
|
|||
|
'third_round_time1' => '第一圈',
|
|||
|
'third_round_time2' => '第二圈',
|
|||
|
'third_round_time3' => '第三圈',
|
|||
|
'fourth_round_time1' => '第一圈',
|
|||
|
'fourth_round_time2' => '第二圈',
|
|||
|
'fourth_round_time3' => '第三圈',
|
|||
|
'best_time1' => '第一圈',
|
|||
|
'best_time2' => '第二圈',
|
|||
|
'best_time3' => '第三圈',
|
|||
|
// 'fly_num' => '圈数',
|
|||
|
'times' => '平均用时',
|
|||
|
'num' => '排名',
|
|||
|
'channel' => '频道',
|
|||
|
'led_color' => 'LED颜色',
|
|||
|
'grouping' => '组别',
|
|||
|
'is_young' => '是否满足青少年组',
|
|||
|
|
|||
|
];
|
|||
|
if($this->exportcourse == 101 && $this->exportround != 'best'){
|
|||
|
$cellTitles = [
|
|||
|
'grouping' => '组别',
|
|||
|
'player_id' => '编号',
|
|||
|
'player_name' => '姓名',
|
|||
|
'gender' => '性别',
|
|||
|
'position' => '号位',
|
|||
|
'name_short' => '所属队伍',
|
|||
|
'first_round_time1' => '第一圈',
|
|||
|
'first_round_time2' => '第二圈',
|
|||
|
'first_round_time3' => '第三圈',
|
|||
|
'second_round_time1' => '第一圈',
|
|||
|
'second_round_time2' => '第二圈',
|
|||
|
'second_round_time3' => '第三圈',
|
|||
|
'third_round_time1' => '第一圈',
|
|||
|
'third_round_time2' => '第二圈',
|
|||
|
'third_round_time3' => '第三圈',
|
|||
|
'fourth_round_time1' => '第一圈',
|
|||
|
'fourth_round_time2' => '第二圈',
|
|||
|
'fourth_round_time3' => '第三圈',
|
|||
|
// 'best_time1' => '第一圈',
|
|||
|
// 'best_time2' => '第二圈',
|
|||
|
// 'best_time3' => '第三圈',
|
|||
|
// 'fly_num' => '圈数',
|
|||
|
// 'times' => '平均用时',
|
|||
|
// 'num' => '排名',
|
|||
|
'channel' => '频道',
|
|||
|
'led_color' => 'LED颜色',
|
|||
|
'is_young' => '是否满足青少年组',
|
|||
|
];
|
|||
|
}
|
|||
|
if($this->exportcourse == 102){
|
|||
|
$cellTitles = [
|
|||
|
'num' => '序号',
|
|||
|
'player_id' => '编号',
|
|||
|
'player_name' => '姓名',
|
|||
|
'first_round_time1' => '第一圈',
|
|||
|
'first_round_time2' => '第二圈',
|
|||
|
'first_round_time3' => '第三圈',
|
|||
|
'second_round_time1' => '第一圈',
|
|||
|
'second_round_time2' => '第二圈',
|
|||
|
'second_round_time3' => '第三圈',
|
|||
|
'fly_num' => '总圈数',
|
|||
|
'times' => '总时间',
|
|||
|
'grouping' => '组别',
|
|||
|
'channel' => '频道',
|
|||
|
'led_color' => 'LED颜色',
|
|||
|
];
|
|||
|
}
|
|||
|
if($this->exportcourse == 103 || $this->exportcourse == 104){
|
|||
|
$cellTitles = [
|
|||
|
'grouping' => '组别',
|
|||
|
'player_id' => '编号',
|
|||
|
'player_name' => '姓名',
|
|||
|
'gender' => '性别',
|
|||
|
'fly_num' => '总圈数',
|
|||
|
'times' => '总时间',
|
|||
|
'group_sort' => '小组排名',
|
|||
|
'channel' => '频道',
|
|||
|
'led_color' => 'LED颜色',
|
|||
|
'is_young' => '是否满足青少年组',
|
|||
|
];
|
|||
|
}
|
|||
|
if($this->exportcourse == 'all'){
|
|||
|
$cellTitles = [
|
|||
|
'num' => '排名',
|
|||
|
'player_id' => '编号',
|
|||
|
'player_name' => '姓名',
|
|||
|
'gender' => '性别',
|
|||
|
'name_short' => '所属队伍',
|
|||
|
'is_young' => '是否满足青少年组',
|
|||
|
];
|
|||
|
}
|
|||
|
// var_dump($cellTitles);exit;
|
|||
|
// if($round == 3){
|
|||
|
// $cellTitles['third_round_time1'] = '第一圈';
|
|||
|
// $cellTitles['third_round_time2'] = '第二圈';
|
|||
|
// $cellTitles['third_round_time3'] = '第三圈';
|
|||
|
// }
|
|||
|
|
|||
|
// if($round == 4){
|
|||
|
// $cellTitles['third_round_time1'] = '第一圈';
|
|||
|
// $cellTitles['third_round_time2'] = '第二圈';
|
|||
|
// $cellTitles['third_round_time3'] = '第三圈';
|
|||
|
// $cellTitles['fourth_round_time1'] = '第一圈';
|
|||
|
// $cellTitles['fourth_round_time2'] = '第二圈';
|
|||
|
// $cellTitles['fourth_round_time3'] = '第三圈';
|
|||
|
// }
|
|||
|
// $cellTitles['fly_num'] = '圈数';
|
|||
|
// $cellTitles['times'] = '时间';
|
|||
|
// $cellTitles['grouping'] = '组别';
|
|||
|
// $cellTitles['channel'] = '频道';
|
|||
|
// $cellTitles['led_color'] = 'LED颜色';
|
|||
|
// var_dump($cellTitles);exit;
|
|||
|
// var_dump($row);exit;
|
|||
|
// 数据总条数
|
|||
|
// var_dump($row);exit;
|
|||
|
$total = count($row);
|
|||
|
if ($total <= 0) {
|
|||
|
$this->error('导出数据为空');
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
switch ($this->exportcourse) {
|
|||
|
case 101:
|
|||
|
$PDOStatement->title = $PDOStatement->title."资格赛成绩";
|
|||
|
break;
|
|||
|
case 102:
|
|||
|
$PDOStatement->title = $PDOStatement->title."排位赛";
|
|||
|
break;
|
|||
|
case 103:
|
|||
|
$which_round = $this->win_or_lose_group($this->exportround);
|
|||
|
$PDOStatement->title = $PDOStatement->title."淘汰赛【第".$this->exportround.'轮'.$which_round['which_round'].'组】'.$which_round['status'].'-(成绩公布)';
|
|||
|
break;
|
|||
|
case 104:
|
|||
|
$PDOStatement->title = $PDOStatement->title."决赛成绩";
|
|||
|
break;
|
|||
|
case 'all':
|
|||
|
$PDOStatement->title = $PDOStatement->title."最终排名";
|
|||
|
break;
|
|||
|
default:
|
|||
|
if ($this->exportsorting == false) {
|
|||
|
$PDOStatement->title = $PDOStatement->title."【决赛】-未排序";
|
|||
|
} else {
|
|||
|
$PDOStatement->title = $PDOStatement->title."【决赛】-已排序";
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
//计算资格赛每组人数
|
|||
|
|
|||
|
$export = new \addons\shopro\library\Export();
|
|||
|
$params = [
|
|||
|
'file_name' => $PDOStatement->title,
|
|||
|
'cell_titles' => $cellTitles,
|
|||
|
'total' => $total,
|
|||
|
'is_sub_cell' => false,
|
|||
|
'group_people' =>4,
|
|||
|
];
|
|||
|
if( $this->exportcourse != 'all'){
|
|||
|
$group_people = $this->leagueService->group_people($this->exportmatch_id, $this->exportcourse);
|
|||
|
$params['group_people'] = $group_people;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission = 0;
|
|||
|
$config = $export->getConfig();
|
|||
|
if($this->exportcourse == 101 && $this->exportround == 'best'){
|
|||
|
$result = $export->exportRank_bestcourse($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
$datas = $this->leagueService->bestplayerqua($this->exportmatch_id, $this->exportcourse ,true);
|
|||
|
// var_dump($datas);exit;
|
|||
|
$user = new User();
|
|||
|
$players = new Players();
|
|||
|
// var_dump($datas);exit;
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
// var_dump($reward);exit;
|
|||
|
// var_dump(json_encode($reward['round1']['first_fly_time']));exit;
|
|||
|
// if(!array_key_exists($reward['round1']['first_fly_time'],$reward)) var_dump($reward['round1']);exit;
|
|||
|
$user_info = $user->where('member_number',$reward['info']['player_id'])->find();
|
|||
|
$player_info = $players->where('member_id',$user_info['id'])->find();
|
|||
|
$data = [
|
|||
|
'name_short' => $reward['info']['name_short'],
|
|||
|
'is_young' => $player_info['birthday'] >= $this->birthday ? '是' : '否',
|
|||
|
'gender' => $player_info['gender'],
|
|||
|
'num' => ++$nums,
|
|||
|
'player_id' => $reward['info']['player_id'] ? $reward['info']['player_id'] : 0,
|
|||
|
'player_name' => $reward['info']['player_name'],
|
|||
|
// 'fly_num' => $reward['fly_num'],
|
|||
|
'times' => $reward['avg'],
|
|||
|
'grouping' => $reward['info']['grouping'],
|
|||
|
'channel' => $reward['info']['channel'],
|
|||
|
'led_color' => $reward['info']['led_color'],
|
|||
|
'first_round_time1' => $reward['round1']['first_fly_time'] ? $reward['round1']['first_fly_time'] : '',
|
|||
|
'first_round_time2' => $reward['round1']['second_fly_time'] ? $reward['round1']['second_fly_time'] : '',
|
|||
|
'first_round_time3' => $reward['round1']['third_fly_time'] ? $reward['round1']['third_fly_time']:'',
|
|||
|
'second_round_time1' => $reward['round2']['first_fly_time'] ? $reward['round2']['first_fly_time'] : '',
|
|||
|
'second_round_time2' => $reward['round2']['second_fly_time']? $reward['round2']['second_fly_time'] : '',
|
|||
|
'second_round_time3' => $reward['round2']['third_fly_time']? $reward['round2']['third_fly_time']:'',
|
|||
|
'third_round_time1' => array_key_exists('round3',$reward) ? $reward['round3']['first_fly_time'] : '',
|
|||
|
'third_round_time2' => array_key_exists('round3',$reward) ? $reward['round3']['second_fly_time'] : '',
|
|||
|
'third_round_time3' => array_key_exists('round3',$reward) ? $reward['round3']['third_fly_time'] : '',
|
|||
|
'fourth_round_time1' => array_key_exists('round4',$reward) ? $reward['round4']['first_fly_time'] : '',
|
|||
|
'fourth_round_time2' => array_key_exists('round4',$reward) ? $reward['round4']['second_fly_time'] : '',
|
|||
|
'fourth_round_time3' => array_key_exists('round4',$reward) ? $reward['round4']['third_fly_time'] : '',
|
|||
|
'best_time1' => $this->getAllSeconds($reward['first']),
|
|||
|
'best_time2' => $this->getAllSeconds($reward['second']),
|
|||
|
'best_time3' => $this->getAllSeconds($reward['third']),
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if($this->exportcourse == 101 && $this->exportround != 'best'){
|
|||
|
$result = $export->exportRank_course($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
// var_dump(123);exit;
|
|||
|
// $datas = $this->leagueService->bestplayerqua($this->exportmatch_id, $this->exportcourse ,true);
|
|||
|
$datas = $this->leagueService->qqq($this->exportmatch_id, $this->exportcourse);
|
|||
|
$group_people = $this->leagueService->group_people($this->exportmatch_id, $this->exportcourse);
|
|||
|
// var_dump($group_people);exit;
|
|||
|
$user = new User();
|
|||
|
$players = new Players();
|
|||
|
// var_dump($datas);exit;
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;$j = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
// var_dump($reward);exit;
|
|||
|
if($j == $group_people) {$j = 0;}
|
|||
|
$user_info = $user->where('member_number',$reward['info']['player_id'])->find();
|
|||
|
$player_info = $players->where('member_id',$user_info['id'])->find();
|
|||
|
$data = [
|
|||
|
'position' => $j= $j + 1,
|
|||
|
'name_short' => $reward['info']['name_short'],
|
|||
|
'is_young' => $player_info['birthday'] >= $this->birthday ? '是' : '否',
|
|||
|
'gender' => $player_info['gender'],
|
|||
|
'player_id' => $reward['info']['player_id'] ? $reward['info']['player_id'] : 0,
|
|||
|
'player_name' => $reward['info']['player_name'],
|
|||
|
// 'fly_num' => $reward['fly_num'],
|
|||
|
// 'times' => $reward['avg'],
|
|||
|
'grouping' => $reward['info']['grouping'],
|
|||
|
'channel' => $reward['info']['channel'],
|
|||
|
'led_color' => $reward['info']['led_color'],
|
|||
|
'first_round_time1' => $reward['round1']['first_fly_time'] ? $reward['round1']['first_fly_time'] : '',
|
|||
|
'first_round_time2' => $reward['round1']['second_fly_time'] ? $reward['round1']['second_fly_time'] : '',
|
|||
|
'first_round_time3' => $reward['round1']['third_fly_time'] ? $reward['round1']['third_fly_time']:'',
|
|||
|
'second_round_time1' => $reward['round2']['first_fly_time']? $reward['round2']['first_fly_time'] : '',
|
|||
|
'second_round_time2' => $reward['round2']['second_fly_time']? $reward['round2']['second_fly_time'] : '',
|
|||
|
'second_round_time3' => $reward['round2']['third_fly_time']? $reward['round2']['third_fly_time']:'',
|
|||
|
'third_round_time1' => array_key_exists('round3',$reward) ? $reward['round3']['first_fly_time'] : '',
|
|||
|
'third_round_time2' => array_key_exists('round3',$reward) ? $reward['round3']['second_fly_time'] : '',
|
|||
|
'third_round_time3' => array_key_exists('round3',$reward) ? $reward['round3']['third_fly_time'] : '',
|
|||
|
'fourth_round_time1' => array_key_exists('round4',$reward) ? $reward['round4']['first_fly_time'] : '',
|
|||
|
'fourth_round_time2' => array_key_exists('round4',$reward) ? $reward['round4']['second_fly_time'] : '',
|
|||
|
'fourth_round_time3' => array_key_exists('round4',$reward) ? $reward['round4']['third_fly_time'] : '',
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if($this->exportcourse == 102){
|
|||
|
$result = $export->exportRank_sen($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
$datas = $this->leagueService->bestplayersen($this->exportmatch_id, $this->exportcourse ,true);
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
// var_dump(json_encode($reward['round1']['first_fly_time']));exit;
|
|||
|
// if(!array_key_exists($reward['round1']['first_fly_time'],$reward)) var_dump($reward['round1']);exit;
|
|||
|
$data = [
|
|||
|
'num' => ++$nums,
|
|||
|
'player_id' => $reward['info']['player_id'] ? $reward['info']['player_id'] : 0,
|
|||
|
'player_name' => $reward['info']['player_name'],
|
|||
|
'fly_num' => $reward['fly_num'],
|
|||
|
'times' => $reward['sum'],
|
|||
|
'grouping' => $reward['info']['grouping'],
|
|||
|
'channel' => $reward['info']['channel'],
|
|||
|
'led_color' => $reward['info']['led_color'],
|
|||
|
'first_round_time1' => $reward['round1']['first_fly_time'] ? $reward['round1']['first_fly_time'] : 0,
|
|||
|
'first_round_time2' => $reward['round1']['second_fly_time'] ? $reward['round1']['second_fly_time'] : 0,
|
|||
|
'first_round_time3' => $reward['round1']['third_fly_time'] ? $reward['round1']['third_fly_time']:0,
|
|||
|
'second_round_time1' => $reward['round2']['first_fly_time'],
|
|||
|
'second_round_time2' => $reward['round2']['second_fly_time'],
|
|||
|
'second_round_time3' => $reward['round2']['third_fly_time'],
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if($this->exportcourse == 103){
|
|||
|
|
|||
|
$result = $export->exportRank_tao($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
$Leaguexport = new Leaguexport();
|
|||
|
$Leagueround = new Leagueround();
|
|||
|
$user = new User();
|
|||
|
$players = new Players();
|
|||
|
if($this->exportround == 1){
|
|||
|
$datas = $Leagueround->group_round2($this->exportmatch_id, $this->exportcourse,$this->exportround,true);
|
|||
|
}elseif(in_array($this->exportround,array(2,3,5,6,8,9,11,12))){
|
|||
|
$datas = $Leagueround->group_round4($this->exportmatch_id, $this->exportcourse,$this->exportround,true);
|
|||
|
}elseif(in_array($this->exportround,array(4,7,10,13))){
|
|||
|
// var_dump(1234);exit;
|
|||
|
$datas = $Leagueround->group_round5($this->exportmatch_id, $this->exportcourse,$this->exportround,true);
|
|||
|
// var_dump($datas);exit;
|
|||
|
}
|
|||
|
|
|||
|
// var_dump($datas);exit;
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
$user_info = $user->where('member_number',$reward['player_id'])->find();
|
|||
|
$player_info = $players->where('member_id',$user_info['id'])->find();
|
|||
|
|
|||
|
$data = [
|
|||
|
'is_young' => $player_info['birthday'] >= $this->birthday ? '是' : '否',
|
|||
|
'gender' => $player_info['gender'],
|
|||
|
// 'num' => ++$nums,
|
|||
|
'player_id' => $reward['player_id'] ? $reward['player_id'] : 0,
|
|||
|
'player_name' => $reward['player_name'],
|
|||
|
'fly_num' => $reward['fly_num'],
|
|||
|
'times' => $reward['times'],
|
|||
|
'group_sort' => $reward['group_sort'],
|
|||
|
'grouping' => $reward['grouping'],
|
|||
|
'channel' => $reward['channel'],
|
|||
|
'led_color' => $reward['led_color'],
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if($this->exportcourse == 104){
|
|||
|
|
|||
|
$result = $export->exportRank_tao($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
$Leagueround = new Leagueround();
|
|||
|
$datas = $Leagueround->final_rank($this->exportmatch_id);
|
|||
|
// var_dump($datas);exit;
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
$data = [
|
|||
|
'num' => ++$nums,
|
|||
|
'player_id' => $reward['player_id'] ? $reward['player_id'] : 0,
|
|||
|
'player_name' => $reward['player_name'],
|
|||
|
'fly_num' => $reward['fly_num'],
|
|||
|
'times' => $reward['times'],
|
|||
|
'group_sort' => $reward['group_sort'],
|
|||
|
'grouping' => $reward['grouping'],
|
|||
|
'channel' => $reward['channel'],
|
|||
|
'led_color' => $reward['led_color'],
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if($this->exportcourse == 'all'){
|
|||
|
|
|||
|
$result = $export->export_finalRank($params, function ($pages) use (&$total_commission, $total) {
|
|||
|
$LeagueIntegral = new LeagueIntegral();
|
|||
|
$datas = $LeagueIntegral->where('match_id',$this->exportmatch_id)->select();
|
|||
|
if(empty($datas)) $this->error('请先生成积分');
|
|||
|
// $datas = $Leagueround->final_rank($this->exportmatch_id);
|
|||
|
// var_dump($datas);exit;
|
|||
|
$user = new User();
|
|||
|
$players = new Players();
|
|||
|
// var_dump($datas);exit;
|
|||
|
$newDatas = [];
|
|||
|
$nums = 0;
|
|||
|
foreach ($datas as &$reward) {
|
|||
|
// $user_info = $user->where('member_number',$reward['player_id'])->find();
|
|||
|
// $player_info = $players->where('member_id',$user_info['id'])->find();
|
|||
|
|
|||
|
// if(empty($player_info['gender'])){
|
|||
|
// var_dump($user_info);exit;
|
|||
|
// }
|
|||
|
$data = [
|
|||
|
'num' => ++$nums,
|
|||
|
'player_id' => $reward['player_id'] ? $reward['player_id'] : 0,
|
|||
|
'player_name' => $reward['player_name'],
|
|||
|
'gender' => $reward['gender'],
|
|||
|
'name_short' => $reward['name_short'],
|
|||
|
'is_young' => $reward['birthday'] >= $this->birthday ? '是' : '否',
|
|||
|
];
|
|||
|
|
|||
|
$newDatas[] = $data;
|
|||
|
}
|
|||
|
|
|||
|
$total_commission += array_sum(array_column($newDatas, 'commission'));
|
|||
|
|
|||
|
return $newDatas;
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
$this->success('导出成功' . (isset($result['file_path']) && $result['file_path'] ? ',请在服务器: “' . $result['file_path'] . '” 查看' : ''), null, $result);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public function win_or_lose_group($other_round){
|
|||
|
switch ($other_round) {
|
|||
|
case 1: $which_round['which_round'] = '1-16';$which_round['status'] = '胜者组';break;
|
|||
|
case 2: $which_round['which_round'] = '17-24';$which_round['status'] = '胜者组';break;
|
|||
|
case 3: $which_round['which_round'] = '25-32';$which_round['status'] = '败者组';break;
|
|||
|
case 4: $which_round['which_round'] = '33-40';$which_round['status'] = '败者组';break;
|
|||
|
case 5: $which_round['which_round'] = '41-44';$which_round['status'] = '败者组';break;
|
|||
|
case 6: $which_round['which_round'] = '45-48';$which_round['status'] = '胜者组';break;
|
|||
|
case 7: $which_round['which_round'] = '49-52';$which_round['status'] = '败者组';break;
|
|||
|
case 8: $which_round['which_round'] = '53-54';$which_round['status'] = '败者组';break;
|
|||
|
case 9: $which_round['which_round'] = '55-56';$which_round['status'] = '胜者组';break;
|
|||
|
case 10: $which_round['which_round'] = '57-58';$which_round['status'] = '败者组';break;
|
|||
|
case 11: $which_round['which_round'] = '59';$which_round['status'] = '败者组';break;
|
|||
|
case 12: $which_round['which_round'] = '60';$which_round['status'] = '胜者组';break;
|
|||
|
case 13: $which_round['which_round'] = '61';$which_round['status'] = '败者组';break;
|
|||
|
|
|||
|
}
|
|||
|
return $which_round;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public function getrank_course()
|
|||
|
{
|
|||
|
header('Access-Control-Allow-Origin:*');
|
|||
|
header('Access-Control-Allow-Methods:*');
|
|||
|
header('Access-Control-Allow-Headers:x-requested-with,content-type');
|
|||
|
$matchranking = new MatchRanking();
|
|||
|
$match_id = $this->request->param("match_id");
|
|||
|
$course = $this->request->param("course"); // 赛程
|
|||
|
// $where['sorting'] = $this->request->param("sorting", false);
|
|||
|
$other_round = $this->request->param("other_round", false); // 轮次
|
|||
|
$is_pic = $this->request->param("is_pic", 0); // 轮次
|
|||
|
|
|||
|
if (empty($match_id)) {
|
|||
|
$this->error("赛事id不能为空!");
|
|||
|
}
|
|||
|
$round = $matchranking->where("match_id", "eq", $match_id)
|
|||
|
->where("course", "eq", $course)
|
|||
|
->max("other_round");
|
|||
|
|
|||
|
if($other_round == 'bestsen'){
|
|||
|
$res_data = $this->leagueService->bestplayersen($match_id,$course);
|
|||
|
if (!empty($res_data)) {
|
|||
|
$res['code'] = 1;
|
|||
|
$res['data'] = $res_data;
|
|||
|
$res['round'] = $round;
|
|||
|
$res['msg'] = "获取成功";
|
|||
|
} else {
|
|||
|
$res['code'] = 0;
|
|||
|
$res['data'] = [];
|
|||
|
$res['round'] = '';
|
|||
|
$res['msg'] = "获取失败";
|
|||
|
}
|
|||
|
return json($res);
|
|||
|
}elseif($other_round == 'best'){
|
|||
|
// var_dump($other_round);exit;
|
|||
|
$res_data = $this->leagueService->bestplayerqua($match_id,$course);
|
|||
|
// var_dump($res_data);exit;
|
|||
|
if (!empty($res_data)) {
|
|||
|
$res['code'] = 1;
|
|||
|
$res['data'] = $res_data;
|
|||
|
$res['round'] = $round;
|
|||
|
$res['msg'] = "获取成功";
|
|||
|
} else {
|
|||
|
$res['code'] = 0;
|
|||
|
$res['data'] = [];
|
|||
|
$res['round'] = '';
|
|||
|
$res['msg'] = "获取失败";
|
|||
|
}
|
|||
|
// var_dump($res);exit;
|
|||
|
return json($res);
|
|||
|
}
|
|||
|
if($other_round == '总积分'){
|
|||
|
// $res_data = $this->leagueService->bestplayersen($match_id,$course);
|
|||
|
$res_data = $this->leagueService->get_final_integral($match_id,$course);
|
|||
|
if (!empty($res_data)) {
|
|||
|
$res['code'] = 1;
|
|||
|
$res['data'] = $res_data;
|
|||
|
$res['round'] = $round;
|
|||
|
$res['msg'] = "获取成功";
|
|||
|
} else {
|
|||
|
$res['code'] = 0;
|
|||
|
$res['data'] = [];
|
|||
|
$res['round'] = '';
|
|||
|
$res['msg'] = "获取失败";
|
|||
|
}
|
|||
|
return json($res);
|
|||
|
}
|
|||
|
// var_dump($is_pic);exit;
|
|||
|
$row = $this->leagueService->getrank_course($match_id,$course,$other_round,false,$is_pic);
|
|||
|
// $row = $this->rankingService->getRankingForCourse($param['match_id'], $param['course'], $param['sorting'], $param['other_round']);
|
|||
|
// $row = $matchranking->where($where)->select();
|
|||
|
$result = $matchranking->where('match_id',$match_id)->where('course',104)->where('other_round',1)->find();
|
|||
|
if(!empty($result)){
|
|||
|
if( $result['is_extra'] == 1) {
|
|||
|
$res['is_extra'] = 1;
|
|||
|
}else{
|
|||
|
$res['is_extra'] = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!empty($row)) {
|
|||
|
$res['code'] = 1;
|
|||
|
$res['data'] = $row;
|
|||
|
$res['round'] = $round;
|
|||
|
$res['msg'] = "获取成功";
|
|||
|
} else {
|
|||
|
$res['code'] = 0;
|
|||
|
$res['data'] = [];
|
|||
|
$res['round'] = $round;
|
|||
|
$res['msg'] = "获取失败1";
|
|||
|
}
|
|||
|
|
|||
|
return json($res);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public function setPlayerRanking()
|
|||
|
{
|
|||
|
$param['id'] = $this->request->param("id"); // id
|
|||
|
$param['player_id'] = $this->request->param("player_id", 0); // 飞手id
|
|||
|
$param['match_id'] = $this->request->param("match_id", 0); // 赛事id
|
|||
|
$param['course'] = $this->request->param("course", 32); // 赛程
|
|||
|
$param['group'] = $this->request->param("group"); // 分组
|
|||
|
$param['times'] = $this->request->param("times"); // 成绩
|
|||
|
$param['achievement'] = $this->request->param("achievement"); // 成绩
|
|||
|
$param['integral'] = $this->request->param("integral", 0); // 积分
|
|||
|
$param['fly_num'] = $this->request->param("fly_num"); // 飞行圈数
|
|||
|
$param['is_finals'] = $this->request->param("is_finals", 0); // 是否是决赛
|
|||
|
$param['finals_round'] = $this->request->param("finals_round"); // 决赛轮次
|
|||
|
$param['player_name'] = $this->request->param("player_name"); // 选手姓名
|
|||
|
$param['led_color'] = $this->request->param("led_color"); // 选手姓名
|
|||
|
$param['channel'] = $this->request->param("channel"); // 选手姓名
|
|||
|
$param['other_round'] = $this->request->param("other_round"); // 选手姓名
|
|||
|
$param['first_fly_time'] = $this->request->param("first_fly_time"); // 选手姓名
|
|||
|
$param['second_fly_time'] = $this->request->param("second_fly_time"); // 选手姓名
|
|||
|
$param['third_fly_time'] = $this->request->param("third_fly_time"); // 选手姓名
|
|||
|
|
|||
|
// $param = $this->request->param();
|
|||
|
// var_dump($param);exit;
|
|||
|
$res = $this->leagueService->setPlayerScore($param);
|
|||
|
|
|||
|
if (!empty($res)) {
|
|||
|
$result['code'] = 1;
|
|||
|
$result['data'] = [];
|
|||
|
$result['msg'] = "成功";
|
|||
|
} else {
|
|||
|
$result['code'] = 0;
|
|||
|
$result['data'] = [];
|
|||
|
$result['msg'] = "失败";
|
|||
|
}
|
|||
|
|
|||
|
return json($result);
|
|||
|
}
|
|||
|
|
|||
|
private function getAllSeconds($seconds){
|
|||
|
// var_dump($seconds);
|
|||
|
$lastTwoDigits = substr((string)$seconds, -3);
|
|||
|
$newStr = substr((string)$seconds, 0, -3);
|
|||
|
// var_dump(floor($newStr / 60));exit;
|
|||
|
$minutes = floor($newStr / 60);
|
|||
|
$remainingSeconds = $newStr % 60;
|
|||
|
$res = sprintf("%02d:%02d", $minutes, $remainingSeconds);
|
|||
|
// var_dump($res.'.'.$lastTwoDigits);exit;
|
|||
|
return $res.'.'.$lastTwoDigits;
|
|||
|
}
|
|||
|
}
|