diff --git a/app/Merchant/Controllers/Coupon/IndexController.php b/app/Merchant/Controllers/Coupon/IndexController.php index 38f15e5..a08e218 100644 --- a/app/Merchant/Controllers/Coupon/IndexController.php +++ b/app/Merchant/Controllers/Coupon/IndexController.php @@ -242,6 +242,9 @@ class IndexController extends Controller //导出数据 public function excel($request, $user) { + if (!$request->end) { + $request->end = now()->toDateTimeString(); + } set_time_limit(1200); ini_set('memory_limit', '1024M'); $filename = '卡券记录' . date('YmdHis') . '.csv'; @@ -278,7 +281,7 @@ class IndexController extends Controller ->when($request->end, function ($query) use ($request) { $query->where('created_at', '<', $request->end); }) - ->orderBy('created_at', 'desc') + ->latest() ->chunk(5000, function ($coupons) use ($handle) { foreach ($coupons as $index => $info) { fputcsv($handle, [