jingcai-php/app/Console/Commands/Zq/SyncZqPredict.php

68 lines
1.8 KiB
PHP
Executable File

<?php
namespace App\Console\Commands\Zq;
use App\Model\Zq\ZqCompany;
use App\Model\Zq\ZqPredict;
use App\Service\External\AlStatService;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
class SyncZqPredict extends Command
{
/**
* 这个就是命令名称
*/
protected $signature = 'zq:sync_zq_predict';
/**
* 命令的说明描述
* @var string
*/
protected $description = '';
/**
* 创建命令的构造方法。
* @param string $words 传入的字符参数
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* 命令的具体执行触发方法
* @return mixed
*/
public function handle()
{
$cdate = date('Ymd');
/** @var AlStatService $alStatService */
$alStatService = app(AlStatService::class);
$companies = $alStatService->getZqPredict($cdate);
if (!$companies) {
return;
}
foreach ($companies as $item) {
$matchId = Arr::get($item, 'matchId');
if (!$matchId) {
continue;
}
$predict = ZqPredict::where('match_id', $matchId)->where('cdate', $cdate)->first();
if (!$predict) {
$predict = new ZqPredict();
}
$predict->cdate = $cdate;
$predict->match_id = $matchId;
$predict->home_team_name = strval(Arr::get($item, 'homeTeamName'));
$predict->away_team_name = strval(Arr::get($item, 'awayTeamName'));
$predict->spf_pr = Arr::get($item, 'spfPR');
$predict->rq_pr = Arr::get($item, 'rqPR');
$predict->dx_pr = Arr::get($item, 'dxPR');
$predict->save();
}
}
}