72 lines
2.3 KiB
PHP
Executable File
72 lines
2.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands\Lq;
|
|
|
|
use App\Model\Lq\JclqCompetition;
|
|
use App\Service\External\AlStatService;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class SyncCompetition extends Command
|
|
{
|
|
/**
|
|
* 这个就是命令名称
|
|
*/
|
|
protected $signature = 'lq:sync_competition';
|
|
|
|
/**
|
|
* 命令的说明描述
|
|
* @var string
|
|
*/
|
|
protected $description = '';
|
|
|
|
/**
|
|
* 创建命令的构造方法。
|
|
* @param string $words 传入的字符参数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* 命令的具体执行触发方法
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
Log::info('SyncCompetition 篮球赛事');
|
|
/** @var AlStatService $alStatService */
|
|
$alStatService = app(AlStatService::class);
|
|
$competitions = $alStatService->getLqCompetition();
|
|
if (!$competitions) {
|
|
return;
|
|
}
|
|
|
|
foreach ($competitions as $item) {
|
|
|
|
$competition = JclqCompetition::where('competition_id', $item['id'])->first();
|
|
if (!$competition) {
|
|
$competition = new JclqCompetition();
|
|
}
|
|
$competition->competition_id = $item['id'];
|
|
$competition->name = strval(Arr::get($item, 'name'));
|
|
$competition->name_full = strval(Arr::get($item, 'nameFull'));
|
|
$competition->name_en = strval(Arr::get($item, 'nameEn'));
|
|
$competition->name_en_full = strval(Arr::get($item, 'nameEnFull'));
|
|
$competition->competition_type = strval(Arr::get($item, 'competitionType'));
|
|
$competition->team_type = strval(Arr::get($item, 'teamType'));
|
|
$competition->gender = strval(Arr::get($item, 'gender'));
|
|
$competition->curr_season_id = intval( Arr::get($item, 'currSeasonId'));
|
|
$competition->curr_season = strval(Arr::get($item, 'currSeason'));
|
|
$competition->area_id = intval(Arr::get($item, 'areaId'));
|
|
$competition->quarter_num = intval(Arr::get($item, 'quarterNum'));
|
|
$competition->quarter_time = strval(Arr::get($item, 'quarterTime'));
|
|
$competition->colour = strval(Arr::get($item, 'colour'));
|
|
$competition->save();
|
|
}
|
|
}
|
|
}
|