同步优化
This commit is contained in:
parent
0929d5a8d0
commit
f4ea4fd472
@ -52,6 +52,8 @@ class MongoSync extends Command
|
||||
|
||||
app(ConfigService::class)->set(self::CURSOR_KEY, intval($nextMicrotime));
|
||||
|
||||
MongoSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $utcDateTime);
|
||||
if ($total) {
|
||||
MongoSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $utcDateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,13 +93,7 @@ class MongoSyncJob implements ShouldQueue
|
||||
virtual_activated_at=COALESCE(cards.virtual_activated_at, excluded.activated_at),
|
||||
order_status=excluded.order_status';
|
||||
|
||||
try {
|
||||
$builder->connection->insert($sql, Arr::flatten($values, 1));
|
||||
} catch (\Exception $e) {
|
||||
$nextMicrotime = intval($res->first()->oRDate->toDateTime()->format('U.u') * 1000) - 1;
|
||||
app(ConfigService::class)->set(MongoSync::CURSOR_KEY, intval($nextMicrotime));
|
||||
}
|
||||
|
||||
$builder->connection->insert($sql, Arr::flatten($values, 1));
|
||||
|
||||
app(CardRepository::class)->forgetCached();
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ class CardSync extends Command
|
||||
|
||||
app(ConfigService::class)->set(self::CURSOR_KEY, $nextId);
|
||||
|
||||
CardSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $maxId);
|
||||
|
||||
if ($total) {
|
||||
CardSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $maxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace App\Domains\Virtual\Commands\Sync;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Card\Card;
|
||||
use App\Models\Virtual\Order;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use App\Domains\Virtual\Jobs\LogSyncJob;
|
||||
@ -60,6 +61,8 @@ class LogSync extends Command
|
||||
|
||||
app(ConfigService::class)->set(self::CURSOR_KEY, $nextId);
|
||||
|
||||
LogSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $maxId);
|
||||
if ($total) {
|
||||
LogSyncJob::onQueue('sync')->withChain($jobs->toArray())->dispatch(1, $this->limit, $maxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,12 +96,7 @@ class CardSyncJob implements ShouldQueue
|
||||
virtual_activated_at=excluded.virtual_activated_at,
|
||||
cancelled_at=excluded.cancelled_at';
|
||||
|
||||
try {
|
||||
$builder->connection->insert($sql, Arr::flatten($array, 1));
|
||||
} catch (\Exception $e) {
|
||||
$nextId = $res->first()->id - 1;
|
||||
app(ConfigService::class)->set(CardSync::CURSOR_KEY, $nextId);
|
||||
}
|
||||
$builder->connection->insert($sql, Arr::flatten($array, 1));
|
||||
|
||||
app(CardRepository::class)->forgetCached();
|
||||
}
|
||||
|
@ -150,8 +150,6 @@ class LogSyncJob implements ShouldQueue
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
$nextId = $res->first()->id - 1;
|
||||
app(ConfigService::class)->set(LogSync::CURSOR_KEY, $nextId);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user