增加类型筛选

This commit is contained in:
2022-01-24 17:00:46 +08:00
parent 1f6079ed12
commit fce06208b9
2 changed files with 17 additions and 6 deletions

View File

@@ -35,6 +35,8 @@ class IndexController extends Controller
$end = $request->end;
$thirdPartyGoodsId = $request->thirdPartyGoodsId;
$pa_order_id = $request->pa_order_id;
$type = $request->type;
$this->query = Coupon::where('user_id', $user->id)
->when($outlet, function ($q) use ($outlet) {
@@ -47,6 +49,9 @@ class IndexController extends Controller
->when($redemptionCode, function ($q) use ($redemptionCode) {
$q->where('redemptionCode', $redemptionCode);
})
->when($type == 'pingan', function ($q) {
$q->where('type', 1);
})
->when($thirdPartyGoodsId, function ($q) use ($thirdPartyGoodsId) {
$q->where('thirdPartyGoodsId', $thirdPartyGoodsId);
})
@@ -54,12 +59,7 @@ class IndexController extends Controller
$q->where('pa_order_id', $pa_order_id);
})
->when(is_numeric($status), function ($query) use ($status) {
if ($status == 4) {
$query->where('is_profit', 1);
} else {
$query->where('status', $status);
}
$query->where('status', $status);
}, function ($query) {
$query->whereIn('status', [2, 3]);
})