From aaa969a2837f8e8a7fe7d4d6f2917322142794f9 Mon Sep 17 00:00:00 2001 From: denghy Date: Mon, 13 May 2019 10:16:26 +0800 Subject: [PATCH] virtual_activated_at --- app/Domains/Real/Commands/Sync/RefundSync.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Domains/Real/Commands/Sync/RefundSync.php b/app/Domains/Real/Commands/Sync/RefundSync.php index c8f45192..b8862dcc 100644 --- a/app/Domains/Real/Commands/Sync/RefundSync.php +++ b/app/Domains/Real/Commands/Sync/RefundSync.php @@ -43,10 +43,13 @@ class RefundSync extends Command ->update(['refunded_at' => $item->create_time]); DB::table('virtual_order_cards_partition') - ->whereIn('sim', $item->sim) - ->where('created_at', '<=', $item->create_time) - // ->whereNull('service_start_at') - ->update(['refunded_at' => $item->create_time]); + ->leftJoin('cards', 'cards.sim', '=', 'virtual_order_cards_partition.sim') + ->whereIn('virtual_order_cards_partition.sim', $item->sim) + ->where('virtual_order_cards_partition.created_at', '<=', $item->create_time) + ->where(function ($query) use ($item) { + $query->whereNull('cards.virtual_activated_at')->orWhere('cards.virtual_activated_at', '>=', $item->create_time); + }) + ->update(['virtual_order_cards_partition.refunded_at' => $item->create_time]); } });