132 lines
2.1 KiB
PHP
132 lines
2.1 KiB
PHP
public function __construct()
|
|
{
|
|
$this->matchModel = new Archives();
|
|
$this->matchContestantModel = new MatchContestant();
|
|
$this->addonproductModel = db("cms_addonproduct");
|
|
}
|
|
|
|
function errors(string $message)
|
|
{
|
|
$res['code'] = 102;
|
|
$res['data'] = [];
|
|
$res['message'] = $message;
|
|
|
|
return json($res);
|
|
}
|
|
|
|
function succeed(array $data) {
|
|
$res['code'] = 100;
|
|
$res['data'] = $data;
|
|
$res['message'] = '获取成功';
|
|
|
|
return json($res);
|
|
}
|
|
|
|
/**
|
|
* 获取赛事信息开启缓存
|
|
* @Author:Soar
|
|
* @Time:2023/10/8 15:33
|
|
* @return \think\response\Json
|
|
*/
|
|
public function get_match()
|
|
{
|
|
$match = $this->matchModel::get($this->match_id, [], true);
|
|
$addon = $this->addonproductModel->where('id', $this->match_id)->find();
|
|
if ($addon) {
|
|
$match->setData($addon);
|
|
}
|
|
|
|
try {
|
|
$match = $match->toArray();
|
|
} catch (\Exception $exception) {
|
|
$message = $exception->getMessage();
|
|
|
|
return $this->errors($message);
|
|
|
|
}
|
|
|
|
return $this->succeed($match);
|
|
}
|
|
|
|
/**
|
|
* 获取赛事信息禁用缓存
|
|
* @Author:Soar
|
|
* @Time:2023/10/8 15:33
|
|
* @return \think\response\Json
|
|
*/
|
|
public function get_line_match()
|
|
{
|
|
$match = $this->matchModel::get($this->match_id, [], false);
|
|
$addon = $this->addonproductModel->where('id', $this->match_id)->find();
|
|
if ($addon) {
|
|
$match->setData($addon);
|
|
}
|
|
|
|
try {
|
|
$match = $match->toArray();
|
|
} catch (\Exception $exception) {
|
|
$message = $exception->getMessage();
|
|
|
|
return $this->errors($message);
|
|
|
|
}
|
|
|
|
return $this->succeed($match);
|
|
}
|
|
|
|
public function get_match_players(int $players_id = null, array $where = [])
|
|
{
|
|
$collection = $this->matchContestantModel->all($where, [], true);
|
|
|
|
return $collection;
|
|
}
|
|
|
|
/**
|
|
* 飞手报名参赛
|
|
* @Author:Soar
|
|
* @Time:2023/10/8 16:48
|
|
* @param int $players_id
|
|
* @param int $match_id
|
|
*/
|
|
public function add_players_to_match(int $players_id = null, int $match_id = null)
|
|
{
|
|
$players_ids = 358;
|
|
$match_ids = 181;
|
|
|
|
$match_info_players = $this->matchContestantModel->where('player_id', $players_ids)
|
|
->where('match_id', $match_ids)
|
|
->where('status', 'in', [1,2])
|
|
->select();
|
|
|
|
if (!empty($match_info_players)) {
|
|
return $this->errors("报名信息已存在!请勿重复报名!");
|
|
}
|
|
|
|
print_r($match_info_players);exit;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|