This commit is contained in:
邓皓元 2019-05-10 17:28:22 +08:00
parent c5cf8dd814
commit 3a22a9dda3

View File

@ -124,16 +124,18 @@ trait OrderCardConcern
$relation->where('transaction_no', 'like', "%{$conditions['transaction_no']}%");
});
}
});
if (isset($conditions['card_status'])) {
switch ($conditions['card_status']) {
case 0:
$query->whereNull('service_start_at')->whereHas('card', function ($relation) {
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) {
$relation->whereNull('cancelled_at');
})->where('created_at', '<', Carbon::now()->subMonths(6));
break;
case 1:
$query->whereNull('service_start_at')->whereHas('card', function ($relation) {
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) {
$relation->whereNull('cancelled_at');
})->where('created_at', '>=', Carbon::now()->subMonths(6));
break;
@ -141,7 +143,7 @@ trait OrderCardConcern
case 2:
$havingRaw = sprintf("MAX(service_end_at) >= '%s'", date('Y-m-d H:i:s'));
$query->whereNotNull('service_start_at')
$this->model = $this->model->whereNotNull('service_start_at')
->groupBy('sim')->havingRaw($havingRaw)
->whereHas('card', function ($relation) {
$relation->whereNull('cancelled_at');
@ -151,7 +153,7 @@ trait OrderCardConcern
case 3:
$havingRaw = sprintf("MAX(service_end_at) < '%s'", date('Y-m-d H:i:s'));
$query->whereNotNull('service_start_at')
$this->model = $this->model->whereNotNull('service_start_at')
->groupBy('sim')->havingRaw($havingRaw)
->whereHas('card', function ($relation) {
$relation->whereNull('cancelled_at');
@ -159,7 +161,7 @@ trait OrderCardConcern
break;
case 4:
$query->whereHas('card', function ($relation) {
$this->model = $this->model->whereHas('card', function ($relation) {
$relation->whereNotNull('cancelled_at');
});
break;
@ -168,7 +170,7 @@ trait OrderCardConcern
# code...
break;
}
});
}
return $this;
}