39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Real\Commands\Sync;
|
|
|
|
use Carbon\Carbon;
|
|
use App\Models\Card;
|
|
use MongoDB\BSON\UTCDateTime;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ActivateSync extends Command
|
|
{
|
|
protected $name = 'sync:activate';
|
|
|
|
protected $description = '同步RD激活数据';
|
|
|
|
public function handle()
|
|
{
|
|
$datetime = $this->getDateTime();
|
|
$starttime = new UTCDateTime($datetime->copy()->startOfDay()->startOfMonth()->timestamp * 1000);
|
|
$endtime = new UTCDateTime($datetime->copy()->endOfDay()->endOfMonth()->timestamp * 1000);
|
|
|
|
$res = DB::connection('mongo')->table('tblCard')->select(['cNo', 'saDate'])
|
|
->where('pNo', 'No00000000768')
|
|
->where('isDel', '<>', 1)
|
|
->whereBetween('saDate', [$starttime, $endtime])->get();
|
|
|
|
$list = $res->map(function ($item) {
|
|
return [
|
|
'sim' => $item['cNo'],
|
|
'activate_at' => $item['saDate']->toDateTime()->format('Y-m-d H:i:s'),
|
|
];
|
|
})->toArray();
|
|
|
|
foreach (array_chunk($list, 10000) as $data) {
|
|
Card::updateBatch($data, 'sim');
|
|
}
|
|
}
|
|
}
|