From 4e9e6376365b91e6d9813261795d6b710644f2b3 Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Wed, 2 Sep 2020 13:52:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=A0=E9=81=93=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Merchant/Controllers/Coupon/IndexController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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, [