archivesModel = new Archives(); $this->archivesModel = new Leaguearchives(); $this->addonproductModel = db("cms_addonproduct"); } public function getAllMatch($param) { // $data = array('url'=>'dra.sdoijhflk','full'=>'sdfsd'); // return ($data); // var_dump($this->MATCH_MODEL);exit; if (!empty($param['date'])) { $year = $param['date']."-01-01"; $lastYear = ($param['date']+1)."-01-01"; $match_list = $this->archivesModel ->alias("archives") ->join("cms_addonproduct" . ' addon', 'addon.id=archives.id', 'LEFT') ->where("model_id", "eq", $this->MATCH_MODEL) ->where("channel_id", "eq", 36) ->where("status", "eq", "normal") ->where("createtime", ">", strtotime($year)) ->where("createtime", "<", strtotime($lastYear)) ->whereNull("deletetime") ->order("archives.id", "DESC") ->paginate($param['limit']); $years = $this->archivesModel->query("SELECT DATE_FORMAT(addon.starttime, '%Y') as date_key FROM `peewee_cms_archives` `archives` LEFT JOIN `peewee_cms_addonproduct` `addon` ON `addon`.`id`=`archives`.`id` WHERE ( `model_id` = 2 AND `channel_id` = 36 AND `deletetime` IS NULL ) AND `archives`.`deletetime` IS NULL GROUP BY `date_key`"); $result = array("total" => $match_list->total(), "rows" => $match_list->items(), "years" => $years); } else { $match_list = $this->archivesModel ->alias("archives") ->join("cms_addonproduct" . ' addon', 'addon.id=archives.id', 'LEFT') ->where("model_id", "eq", $this->MATCH_MODEL) ->where("channel_id", "eq", 36) ->whereNull("deletetime") ->where("status", "eq", "normal") // ->fetchSql(true) ->order("archives.id", "DESC") // ->select(); ->paginate( $param['limit']); foreach ($match_list->items() as $value){ $value['url'] = 'https://www.fpvone.cn/wurenjijingsusaicheng/'.$value['id'].'.html'; $value['fullurl'] = 'https://www.fpvone.cn/wurenjijingsusaicheng/'.$value['id'].'.html'; $value['status_text'] = 'Status Normal'; } $match_lists = $this->archivesModel ->alias("archives") ->join("cms_addonproducts" . ' addons', 'addons.id=archives.id', 'LEFT') ->where("model_id in (6)",) ->where("channel_id in (73)") ->whereNull("deletetime") ->where("status", "eq", "normal") // ->fetchSql(true) ->order("archives.id", "DESC") // ->select(); ->paginate( $param['limit']); // var_dump(str_replace("www", "dra", $match_lists->items()[0]['url']));exit; // $match_list->union($match_lists, true); // $change = $match_lists->items()[0]->toArray(); // $change['url'] = ''; $match_lists->items()[0]['url'] = 'https://dra.fpvone.cn/matchs/804.html'; $match_lists->items()[0]['fullurl'] = 'https://dra.fpvone.cn/matchs/804.html'; $match_lists->items()[0]['status_text'] = 'Status Normal'; // $match_lists->items()[0]['admin_id'] = 666; // var_dump($change[0]->toArray()['url']);exit; // foreach ($match_lists->items()[0] as &$val){ // $val['url'] = str_replace("www", "dra", $val['url']); // } // var_dump($match_lists);exit; $mergedArray = array_merge($match_lists->items(),$match_list->items()); // var_dump($mergedArray);exit; array_multisort(array_column($mergedArray,'stime'), SORT_DESC,$mergedArray); $years = $this->archivesModel->query("SELECT DATE_FORMAT(addon.starttime, '%Y') as date_key FROM `peewee_cms_archives` `archives` LEFT JOIN `peewee_cms_addonproduct` `addon` ON `addon`.`id`=`archives`.`id` WHERE ( `model_id` = 2 AND `channel_id` = 36 AND `deletetime` IS NULL ) AND `archives`.`deletetime` IS NULL GROUP BY `date_key`"); $result = array("total" => $match_lists->total(), "rows" => $mergedArray, "years" => $years); } if (!empty($result['rows'])) { foreach ($result['rows'] as $key => $val) { $matchContestant = new MatchContestant(); //宁波站 if($val->id == 1007){ $val->entry_player = $matchContestant->where("match_id", $val->id) ->whereIn("status", [1, 2]) ->count("*"); }else{ $val->entry_player = '统计中'; } } } return $result; } /** * 根据身份证查询选手是否参加赛事 * @Author:Soar * @Time:2023/12/6 14:21 * @param $match_id * @param $user_id * @return void */ public function getMatchUserInfo($match_id, $user_id) { $players = new Players(); $matchContestant = new MatchContestant(); $player_info = $players->where("card_number", "eq", $user_id)->select(); if (empty($player_info)) { return; } foreach ($player_info as $value) { $match_info = $matchContestant->where("player_id", "eq", $value->id) ->where("match_id", "eq", $match_id) ->order("id", "DESC") ->find(); if (!empty($match_info)) { $player_info = $value; break; } } if (empty($match_info)) { return; } $archives_info = $this->archivesModel ->where("id", "eq", $match_id) ->find(); if (empty($archives_info)) { return; } $res['title'] = $archives_info->title; $res['status'] = $match_info->status; $res['name'] = $player_info->real_name; return $res; } }