syncOdds(); } public function syncOdds() { /** @var AlStatService $alStatService */ $alStatService = app(AlStatService::class); $odds = $alStatService->getZqGuan(); if (!$odds) { return; } foreach ($odds as $item) { $id = $item['id']; $odd = JczqGuan::where('guan_id', $id)->first(); if (!$odd) { $odd = new JczqGuan(); } $options = Arr::get($item, 'options'); $odd->guan_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($jczqGuanId, $options) { if (!is_array($options)) { return; } foreach ($options as $item) { $id = $item['id']; $odd = JczqGuanOdds::where('odds_id', $id)->where('jczq_guan_id', $jczqGuanId)->first(); if (!$odd) { $odd = new JczqGuanOdds(); } $odd->jczq_guan_id = $jczqGuanId; $odd->odds_id = $id; $odd->team_id = intval(Arr::get($item, 'teamId')); $odd->team_name = strval(Arr::get($item, 'teamName')); $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('guankaijiang will dispath RefreshOrderGuanResult, guanOddsId:' .$odd->id); RefreshOrderGuanResult::dispatch($odd->id); } } } }