diff --git a/app/Domains/Real/Commands/Sync/RefundSync.php b/app/Domains/Real/Commands/Sync/RefundSync.php index e1be6cab..72fc28c5 100644 --- a/app/Domains/Real/Commands/Sync/RefundSync.php +++ b/app/Domains/Real/Commands/Sync/RefundSync.php @@ -21,10 +21,12 @@ class RefundSync extends Command $starttime = $datetime->copy()->startOfMonth()->startOfDay(); $endtime = $datetime->copy()->endOfMonth()->endOfDay(); + $lasttime = $starttime->copy()->subMonth()->startOfMonth(); + $refunds = DB::connection('real')->table('jxc_back_card') ->select(['sim', 'create_time']) ->where('status', 2) - ->where('create_time', '>=', $starttime) + ->where('create_time', '>=', $lasttime) ->where('create_time', '<=', $endtime) ->get(); @@ -36,12 +38,12 @@ class RefundSync extends Command }); // 最早退货的时间 - DB::transaction(function () use ($refunds, $starttime) { + DB::transaction(function () use ($refunds, $lasttime) { foreach ($refunds as $item) { DB::table('real_order_cards') ->whereIn('sim', $item->sim) ->where('created_at', '<=', $item->create_time) - ->where('created_at', '>=', $starttime) + ->where('created_at', '>=', $lasttime) ->update(['refunded_at' => $item->create_time]); $simArrayText = implode(',', $item->sim); @@ -56,7 +58,7 @@ class RefundSync extends Command AND v.created_at >= '%s' "; - DB::update(sprintf($sql, $item->create_time, $simArrayText, $item->create_time, $starttime)); + DB::update(sprintf($sql, $item->create_time, $simArrayText, $item->create_time, $lasttime)); } });