use
This commit is contained in:
parent
970ff52bc6
commit
21be6e8530
@ -171,42 +171,44 @@ trait OrderCardConcern
|
||||
|
||||
if (isset($conditions['card_status'])) {
|
||||
$conditions['card_status'] = intval($conditions['card_status']);
|
||||
$date = isset($conditions['month']) ? Carbon::parse($conditions['month'])->copy()->startOfMonth() : date('Y-m-d H:i:s');
|
||||
|
||||
switch ($conditions['card_status']) {
|
||||
case 0:
|
||||
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", date('Y-m-d H:i:s'));
|
||||
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) use ($date) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", $date);
|
||||
})->where('created_at', '<', Carbon::now()->subMonths(6));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", date('Y-m-d H:i:s'));
|
||||
$this->model = $this->model->whereNull('service_start_at')->whereHas('card', function ($relation) use ($date) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", $date);
|
||||
})->where('created_at', '>=', Carbon::now()->subMonths(6));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MAX(service_end_at) >= '%s')", date('Y-m-d H:i:s'));
|
||||
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MAX(service_end_at) >= '%s')", $date);
|
||||
|
||||
$this->model = $this->model->whereNotNull('service_start_at')
|
||||
->whereRaw($havingRaw)
|
||||
->whereHas('card', function ($relation) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", date('Y-m-d H:i:s'));
|
||||
->whereHas('card', function ($relation) use ($date) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", $date);
|
||||
});
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MAX(service_end_at) < '%s')", date('Y-m-d H:i:s'));
|
||||
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MAX(service_end_at) < '%s')", $date);
|
||||
|
||||
$this->model = $this->model->whereNotNull('service_start_at')
|
||||
->whereRaw($havingRaw)
|
||||
->whereHas('card', function ($relation) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", date('Y-m-d H:i:s'));
|
||||
->whereHas('card', function ($relation) use ($date) {
|
||||
$relation->whereNull('cancelled_at')->orWhere('cancelled_at', "<", $date);
|
||||
});
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$this->model = $this->model->whereHas('card', function ($relation) {
|
||||
$relation->where('cancelled_at', ">=", date('Y-m-d H:i:s'));
|
||||
$relation->where('cancelled_at', ">=", $date);
|
||||
});
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user