diff --git a/app/Merchant/Controllers/Unionpay/CouponController.php b/app/Merchant/Controllers/Unionpay/CouponController.php index 4d24007..3389e01 100644 --- a/app/Merchant/Controllers/Unionpay/CouponController.php +++ b/app/Merchant/Controllers/Unionpay/CouponController.php @@ -32,17 +32,17 @@ class CouponController extends Controller $action = $request->action ?? 'search'; $coupons = UnionpayCoupon::query() -// ->whereHas('outlet', function ($q) use ($shop_name, $user) { -// $q->where('parent_id', $user->id) -// ->when($shop_name, function ($q) use ($shop_name) { -// $q->whereHas('info', function ($q) use ($shop_name) { -// $q->where('nickname', 'like', "%{$shop_name}%"); -// }); -// }); -// }) + // ->whereHas('outlet', function ($q) use ($shop_name, $user) { + // $q->where('parent_id', $user->id) + // ->when($shop_name, function ($q) use ($shop_name) { + // $q->whereHas('info', function ($q) use ($shop_name) { + // $q->where('nickname', 'like', "%{$shop_name}%"); + // }); + // }); + // }) ->when($coupon_no, function ($q) use ($coupon_no) { - $q->where('coupon_no', $coupon_no); - }) + $q->where('coupon_no', $coupon_no); + }) ->when($shop_no, function ($q) use ($shop_no) { $q->where('shop_no', $shop_no); }) @@ -55,6 +55,7 @@ class CouponController extends Controller ->when(!$start && $end, function ($query) use ($end) { $query->where('created_at', '<', $end); }) + ->where('status', UnionpayCoupon::STATUS_INIT) ->latest() ->paginate(); @@ -89,17 +90,17 @@ class CouponController extends Controller $end = $request->end; UnionpayCoupon::query() -// ->whereHas('outlet', function ($q) use ($shop_name, $user) { -// $q->where('parent_id', $user->id) -// ->when($shop_name, function ($q) use ($shop_name) { -// $q->whereHas('info', function ($q) use ($shop_name) { -// $q->where('nickname', 'like', "%{$shop_name}%"); -// }); -// }); -// }) + // ->whereHas('outlet', function ($q) use ($shop_name, $user) { + // $q->where('parent_id', $user->id) + // ->when($shop_name, function ($q) use ($shop_name) { + // $q->whereHas('info', function ($q) use ($shop_name) { + // $q->where('nickname', 'like', "%{$shop_name}%"); + // }); + // }); + // }) ->when($coupon_no, function ($q) use ($coupon_no) { - $q->where('coupon_no', $coupon_no); - }) + $q->where('coupon_no', $coupon_no); + }) ->when($shop_no, function ($q) use ($shop_no) { $q->where('shop_no', $shop_no); }) @@ -112,6 +113,7 @@ class CouponController extends Controller ->when(!$start && $end, function ($query) use ($end) { $query->where('created_at', '<', $end); }) + ->where('status', UnionpayCoupon::STATUS_INIT) ->latest() ->chunk(5000, function ($coupons) use ($handle) { foreach ($coupons as $index => $coupon) {