优化同步机制
This commit is contained in:
parent
97ccf8696c
commit
ba1745124a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use App\Jobs\QueuedCommand;
|
use App\Jobs\QueuedCommand;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
@ -28,6 +29,10 @@ class Kernel extends ConsoleKernel
|
|||||||
{
|
{
|
||||||
$logPath = storage_path('logs/artisan.log');
|
$logPath = storage_path('logs/artisan.log');
|
||||||
$schedule->command('real:sync-activated')->cron('* */4 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
$schedule->command('real:sync-activated')->cron('* */4 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
|
$schedule->command(sprintf('real:sync-activated %s', Carbon::now()->subDays(2)->format('Y-m-d')))->cron('0 3 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
|
$schedule->command(sprintf('real:sync-activated %s', Carbon::now()->subDays(3)->format('Y-m-d')))->cron('0 3 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
|
$schedule->command(sprintf('real:sync-activated %s', Carbon::now()->subDays(4)->format('Y-m-d')))->cron('0 3 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
|
$schedule->command(sprintf('real:sync-activated %s', Carbon::now()->subDays(5)->format('Y-m-d')))->cron('0 3 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
$schedule->command('virtual:schedule-auto-activate')->cron('* * * 1 *')->withoutOverlapping()->appendOutputTo($logPath);
|
$schedule->command('virtual:schedule-auto-activate')->cron('* * * 1 *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
// $schedule->command('virtual:schedule-vd-activate')->cron('0 2 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
// $schedule->command('virtual:schedule-vd-activate')->cron('0 2 * * *')->withoutOverlapping()->appendOutputTo($logPath);
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ class ActivatedSync extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$day = $this->getDay();
|
$day = $this->getDay();
|
||||||
|
$this->line('开始' . $this->description . '#:' . $day);
|
||||||
|
|
||||||
$startMicrotime = new UTCDateTime($day->copy()->startOfDay());
|
$startMicrotime = new UTCDateTime($day->copy()->startOfDay());
|
||||||
$endMicrotime = new UTCDateTime($day->copy()->endOfDay());
|
$endMicrotime = new UTCDateTime($day->copy()->endOfDay());
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ class ActivatedSync extends Command
|
|||||||
|
|
||||||
$total = $query->count();
|
$total = $query->count();
|
||||||
|
|
||||||
$this->line('待同步条数:'.$total);
|
$this->line('待同步条数:' . $total);
|
||||||
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ class ActivatedSync extends Command
|
|||||||
$array = $res->map(function ($item) {
|
$array = $res->map(function ($item) {
|
||||||
return [
|
return [
|
||||||
'sim' => $item['cNo'],
|
'sim' => $item['cNo'],
|
||||||
'activated_at' => $item['saDate'] ? (string)Carbon::createFromTimestampMs(strval($item['saDate'])) : null,
|
'activated_at' => $item['saDate'] ? (string) Carbon::createFromTimestampMs(strval($item['saDate'])) : null,
|
||||||
];
|
];
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ class ActivatedSync extends Command
|
|||||||
->whereNotNull('virtual_activated_at')->get()->pluck('sim')->toArray();
|
->whereNotNull('virtual_activated_at')->get()->pluck('sim')->toArray();
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if(in_array($value['sim'], $exists)){
|
if (in_array($value['sim'], $exists)) {
|
||||||
unset($array);
|
unset($array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1018,9 +1018,12 @@ class OrderService extends Service
|
|||||||
->whereIn('sim', array_pluck($value, 'sim'))->update(['virtual_order_id' => $node['id']]);
|
->whereIn('sim', array_pluck($value, 'sim'))->update(['virtual_order_id' => $node['id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 只要销售订单同步卡信息即可
|
||||||
|
if ($node['type'] === 0) {
|
||||||
$simArray = array_pluck($data, 'sim');
|
$simArray = array_pluck($data, 'sim');
|
||||||
MongoCardJob::dispatch($simArray)->onQueue('sync');
|
MongoCardJob::dispatch($simArray)->onQueue('sync');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function refundedList(array $conditions = [])
|
public function refundedList(array $conditions = [])
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ use App\Domains\Stats\Exports\CompanyReportExport;
|
|||||||
require_once realpath(dirname(__FILE__) . '/TestCase.php');
|
require_once realpath(dirname(__FILE__) . '/TestCase.php');
|
||||||
|
|
||||||
$conditions = [
|
$conditions = [
|
||||||
'type' => [0, 1],
|
'type' => [2, 3],
|
||||||
'company_name' => '福建车媒通网络科技有限公司',
|
'company_name' => '福建车媒通网络科技有限公司',
|
||||||
'month' => '2016-01'
|
'month' => '2016-01'
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user