111 lines
3.4 KiB
PHP
Executable File
111 lines
3.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands\Zq;
|
|
|
|
use App\Jobs\RefreshOrderGuanYaResult;
|
|
use App\Model\Zq\JczqGuanYa;
|
|
use App\Model\Zq\JczqGuanYaOdds;
|
|
use App\Service\External\AlStatService;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class SyncGuanYa extends Command
|
|
{
|
|
/**
|
|
* 这个就是命令名称
|
|
*/
|
|
protected $signature = 'zq:sync_guan_ya';
|
|
|
|
/**
|
|
* 命令的说明描述
|
|
* @var string
|
|
*/
|
|
protected $description = '竞彩足球冠亚军数据';
|
|
|
|
/**
|
|
* 创建命令的构造方法。
|
|
* @param string $words 传入的字符参数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* 命令的具体执行触发方法
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->syncOdds();
|
|
|
|
|
|
}
|
|
|
|
public function syncOdds()
|
|
{
|
|
/** @var AlStatService $alStatService */
|
|
$alStatService = app(AlStatService::class);
|
|
$odds = $alStatService->getZqGuanYa();
|
|
if (!$odds) {
|
|
return;
|
|
}
|
|
|
|
foreach ($odds as $item) {
|
|
$id = $item['id'];
|
|
$odd = JczqGuanYa::where('guan_ya_id', $id)->first();
|
|
if (!$odd) {
|
|
$odd = new JczqGuanYa();
|
|
}
|
|
$options = Arr::get($item, 'options');
|
|
$odd->guan_ya_id = $id;
|
|
$odd->competition = intval(Arr::get($item, 'competition'));
|
|
$odd->competition_name = strval(Arr::get($item, 'competitionName'));
|
|
$odd->season = strval(Arr::get($item, 'season'));
|
|
$odd->type = strval(Arr::get($item, 'type'));
|
|
$odd->sales_state = strval(Arr::get($item, 'salesState'));
|
|
$odd->lott_state = strval(Arr::get($item, 'lottState'));
|
|
$odd->close_time = strval(Arr::get($item, 'closeTime'));
|
|
$odd->options = $options;
|
|
$odd->save();
|
|
$this->saveGuanOdds($odd->id, $options);
|
|
}
|
|
}
|
|
|
|
protected function saveGuanOdds($jczqGuanYaId, $options)
|
|
{
|
|
if (!is_array($options)) {
|
|
return;
|
|
}
|
|
|
|
foreach ($options as $item) {
|
|
$id = $item['id'];
|
|
$odd = JczqGuanYaOdds::where('odds_id', $id)->where('jczq_guan_ya_id', $jczqGuanYaId)->first();
|
|
if (!$odd) {
|
|
$odd = new JczqGuanYaOdds();
|
|
}
|
|
$odd->jczq_guan_ya_id = $jczqGuanYaId;
|
|
$odd->odds_id = $id;
|
|
$odd->team_a_id = intval(Arr::get($item, 'teamAId'));
|
|
$odd->team_a_name = strval(Arr::get($item, 'teamAName'));
|
|
$odd->team_b_id = intval(Arr::get($item, 'teamBId'));
|
|
$odd->team_b_name = strval(Arr::get($item, 'teamBName'));
|
|
$odd->option_num = intval(Arr::get($item, 'optionNum'));
|
|
$odd->odds = Arr::get($item, 'odds');
|
|
$odd->season = strval(Arr::get($item, 'season'));
|
|
$odd->sales_state = strval(Arr::get($item, 'salesState'));
|
|
$odd->show_state = strval(Arr::get($item, 'showState'));
|
|
$odd->order_state = strval(Arr::get($item, 'orderState'));
|
|
$odd->save();
|
|
|
|
if ($odd->show_state == 'win' || $odd->show_state == 'out') {
|
|
Log::info('guanyakaijiang will dispath RefreshOrderGuanYaResult, guanOddsId:' .$odd->id);
|
|
RefreshOrderGuanYaResult::dispatch($odd->id);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|