38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Real\Commands\Sync;
|
|
|
|
use Carbon\Carbon;
|
|
use App\Models\Real\Bloc;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Domains\Real\Repositories\BlocRepository;
|
|
|
|
class BlocSync extends Command
|
|
{
|
|
protected $name = 'sync:bloc';
|
|
|
|
protected $description = '同步RD集团数据';
|
|
|
|
protected $carrier_operator = ['lt' => 0, 'yd' => 1, 'dx' => 2, 'qw' => 3];
|
|
|
|
public function handle()
|
|
{
|
|
$datetime = $this->getDateTime();
|
|
|
|
$select = ['bloc_code as id', "bloc_name as name", 'carrieroperator as carrier_operator', 'create_time as created_at'];
|
|
|
|
$data = DB::connection('real')->table('jxc_bloc_manage')->select($select)->where('del', 0)->get()->toArray();
|
|
|
|
foreach ($data as &$item) {
|
|
$item = (array)$item;
|
|
$item['carrier_operator'] = $this->carrier_operator[$item['carrier_operator']];
|
|
$item['created_at'] = Carbon::createFromTimestamp($item['created_at']);
|
|
$item['updated_at'] = date('Y-m-d H:i:s');
|
|
}
|
|
|
|
Bloc::replace($data);
|
|
|
|
app(BlocRepository::class)->forgetCached();
|
|
}
|
|
}
|