58 lines
1.3 KiB
PHP
Executable File
58 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands\Lq;
|
|
|
|
use App\Model\Lq\JclqCompany;
|
|
use App\Service\External\AlStatService;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class SyncLqCompany extends Command
|
|
{
|
|
/**
|
|
* 这个就是命令名称
|
|
*/
|
|
protected $signature = 'lq:sync_lq_company';
|
|
|
|
/**
|
|
* 命令的说明描述
|
|
* @var string
|
|
*/
|
|
protected $description = '';
|
|
|
|
/**
|
|
* 创建命令的构造方法。
|
|
* @param string $words 传入的字符参数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* 命令的具体执行触发方法
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
/** @var AlStatService $alStatService */
|
|
$alStatService = app(AlStatService::class);
|
|
$companies = $alStatService->getLqCompany();
|
|
if (!$companies) {
|
|
return;
|
|
}
|
|
|
|
foreach ($companies as $item) {
|
|
$company = JclqCompany::where('company_id', $item['id'])->first();
|
|
if (!$company) {
|
|
$company = new JclqCompany();
|
|
}
|
|
$company->company_id = $item['id'];
|
|
$company->name = strval(Arr::get($item, 'name'));
|
|
$company->country = strval(Arr::get($item, 'country'));
|
|
$company->save();
|
|
}
|
|
}
|
|
}
|