查询优化
This commit is contained in:
parent
65f0282a36
commit
c40138c19a
@ -62,19 +62,19 @@ class CardService extends Service
|
|||||||
{
|
{
|
||||||
switch ($card_status) {
|
switch ($card_status) {
|
||||||
case 0:
|
case 0:
|
||||||
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereIn('type', [0, 1, 2])->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
||||||
$relation->whereNull('cancelled_at');
|
$relation->whereNull('cancelled_at');
|
||||||
})->where('created_at', '<', Carbon::now()->subMonths(6))->orderBy('created_at', 'desc')->paginate($limit);
|
})->where('created_at', '<', Carbon::now()->subMonths(6))->orderBy('created_at', 'desc')->paginate($limit);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereIn('type', [0, 1, 2])->whereNull('service_start_at')->whereHas('card', function ($relation) {
|
||||||
$relation->whereNull('cancelled_at');
|
$relation->whereNull('cancelled_at');
|
||||||
})->where('created_at', '>=', Carbon::now()->subMonths(6))->orderBy('created_at', 'desc')->paginate($limit);
|
})->where('created_at', '>=', Carbon::now()->subMonths(6))->orderBy('created_at', 'desc')->paginate($limit);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereNotNull('service_start_at')
|
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereIn('type', [0, 1, 2])->whereNotNull('service_start_at')
|
||||||
->where('service_start_at', '<=', date('Y-m-d H:i:s'))
|
->where('service_start_at', '<=', date('Y-m-d H:i:s'))
|
||||||
->where('service_end_at', '>=', date('Y-m-d H:i:s'))
|
->where('service_end_at', '>=', date('Y-m-d H:i:s'))
|
||||||
->whereHas('card', function ($relation) {
|
->whereHas('card', function ($relation) {
|
||||||
@ -83,7 +83,7 @@ class CardService extends Service
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereNotNull('service_start_at')
|
$res = OrderCardPartition::selectRaw('DISTINCT(sim) sim, created_at')->whereIn('type', [0, 1, 2])->whereNotNull('service_start_at')
|
||||||
->where('service_start_at', '<=', date('Y-m-d H:i:s'))
|
->where('service_start_at', '<=', date('Y-m-d H:i:s'))
|
||||||
->where('service_end_at', '>=', date('Y-m-d H:i:s'))
|
->where('service_end_at', '>=', date('Y-m-d H:i:s'))
|
||||||
->whereHas('card', function ($relation) {
|
->whereHas('card', function ($relation) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user