时间筛选

This commit is contained in:
邓皓元 2019-12-16 17:15:15 +08:00
parent 23148bdc64
commit 08d19b03e7

View File

@ -101,19 +101,39 @@ trait OrderCardConcern
}
if (isset($conditions['service_start_starttime'])) {
$query->where('service_start_at', '>=', Carbon::parse($conditions['service_start_starttime']));
$date = Carbon::parse($conditions['service_start_starttime']);
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MIN(service_start_at) >= '%s')", $date);
$this->model = $this->model->whereNotNull('service_start_at')
->whereRaw($havingRaw);
// $query->where('service_start_at', '>=', Carbon::parse($conditions['service_start_starttime']));
}
if (isset($conditions['service_start_endtime'])) {
$query->where('service_start_at', '<=', Carbon::parse($conditions['service_start_endtime']));
$date = Carbon::parse($conditions['service_start_starttime']);
$havingRaw = sprintf("sim in (SELECT sim FROM virtual_order_cards_partition GROUP BY sim HAVING MIN(service_start_at) <= '%s')", $date);
$this->model = $this->model->whereNotNull('service_start_at')
->whereRaw($havingRaw);
// $query->where('service_start_at', '<=', Carbon::parse($conditions['service_start_endtime']));
}
if (isset($conditions['service_end_starttime'])) {
$query->where('service_end_at', '>=', Carbon::parse($conditions['service_end_starttime']));
$date = Carbon::parse($conditions['service_end_starttime']);
$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);
// $query->where('service_end_at', '>=', Carbon::parse($conditions['service_end_starttime']));
}
if (isset($conditions['service_end_endtime'])) {
$query->where('service_end_at', '<=', Carbon::parse($conditions['service_end_endtime']));
$date = Carbon::parse($conditions['service_end_starttime']);
$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);
// $query->where('service_end_at', '<=', Carbon::parse($conditions['service_end_endtime']));
}
if (isset($conditions['refunded_starttime'])) {