/**订单列表 0 已删除 1执行中 2 已过期
*
* @param Request $request
*
* @return IlluminateContractsViewFactory|IlluminateViewView
* @author lxw
*/
public function getOrderList( Request $request )
{
$this->closeSqlFullMode();
$query = $this->buildingPayment->query();
$status = $request['status'] ?? '1';
switch( $status ) {
case '1': //执行中
$query->whereDate('duetime', '>', date('Y-m-d', time()));
break;
case '2': //已到期
$query->whereDate('duetime', '<=', date('Y-m-d', time()));
break;
case '0': //已删除
$query->onlyTrashed();
break;
default:
$query->whereDate('duetime', '>', date('Y-m-d', time()));
}
// $orderLists = $query->groupBy('order_id')->orderBy('created_at', 'desc')->paginate(env('PAGE_LIMIT'));
//优化后
$orderLists = $query->groupBy('order_id')->with(['companies:id,username','manages:id,username','buildings:id,name'])->orderBy('created_at', 'desc')->paginate(env('PAGE_LIMIT'));
return view('Manage.Payment.PaymentList', ['orderLists' => $orderLists, 'links' => ['status' => $status]]);
}