feat: 支持订单列表独立搜索快递单号和用户电话
This commit is contained in:
@@ -18,6 +18,8 @@ class OrdersController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$keyword = trim((string)$request->input('keyword', ''));
|
||||
$trackingNo = trim((string)$request->input('tracking_no', ''));
|
||||
$userMobile = trim((string)$request->input('user_mobile', ''));
|
||||
$status = trim((string)$request->input('status', ''));
|
||||
$serviceProvider = trim((string)$request->input('service_provider', ''));
|
||||
$sourceChannel = $this->normalizeOrderSourceChannel((string)$request->input('source_channel', ''));
|
||||
@@ -62,6 +64,30 @@ class OrdersController
|
||||
});
|
||||
}
|
||||
|
||||
if ($trackingNo !== '') {
|
||||
$query->whereRaw(
|
||||
"EXISTS (SELECT 1 FROM order_logistics ol WHERE ol.order_id = o.id AND ol.logistics_type IN ('send_to_center', 'return_to_user') AND ol.tracking_no LIKE :tracking_no)",
|
||||
[
|
||||
'tracking_no' => "%{$trackingNo}%",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($userMobile !== '') {
|
||||
$query->leftJoin('users u', 'u.id = o.user_id')
|
||||
->leftJoin('order_return_addresses ra', 'ra.order_id = o.id');
|
||||
|
||||
$query->where(function ($builder) use ($userMobile) {
|
||||
$builder->whereRaw(
|
||||
'(u.mobile LIKE :user_mobile OR ra.mobile LIKE :return_mobile)',
|
||||
[
|
||||
'user_mobile' => "%{$userMobile}%",
|
||||
'return_mobile' => "%{$userMobile}%",
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
$warehouseStatusFilters = [
|
||||
'warehouse_active',
|
||||
'warehouse_pending_inbound',
|
||||
|
||||
Reference in New Issue
Block a user