|
|
@@ -51,6 +51,7 @@ class OrderPackageFilters
|
|
|
];
|
|
|
|
|
|
protected $orderIssueQuery;
|
|
|
+ protected $orderQuery;
|
|
|
|
|
|
public function __construct(Request $request)
|
|
|
{
|
|
|
@@ -66,14 +67,31 @@ class OrderPackageFilters
|
|
|
$this->queryBuilder
|
|
|
->whereIn('status', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, null])
|
|
|
->whereIn('exception_status', [0, 1, 2, 3, 4, 5, 6, 7, null]);
|
|
|
+ $this->getOrderQuery();
|
|
|
+
|
|
|
foreach ($filters as $filter => $value) {
|
|
|
if (method_exists($this, $filter)) {
|
|
|
$this->$filter($value, $this->queryBuilder);
|
|
|
}
|
|
|
}
|
|
|
+ $this->after();
|
|
|
return $this->queryBuilder;
|
|
|
}
|
|
|
|
|
|
+ public function after(){
|
|
|
+ if($this->orderQuery){
|
|
|
+ $this->queryBuilder->whereIn('order_id',$this->orderQuery);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getOrderQuery(): Builder
|
|
|
+ {
|
|
|
+ if (!$this->orderQuery) {
|
|
|
+ $this->orderQuery = Order::query()->select('id')->where('wms_status', '!=','订单取消');
|
|
|
+ }
|
|
|
+ return $this->orderQuery;
|
|
|
+ }
|
|
|
+
|
|
|
public function getOrderIssueQuery(): Builder
|
|
|
{
|
|
|
if (!$this->orderIssueQuery) {
|
|
|
@@ -135,9 +153,7 @@ class OrderPackageFilters
|
|
|
private function logistic($logistic_id)
|
|
|
{
|
|
|
$logistic_ids = array_filter(preg_split('/[,, ]+/is', $logistic_id));
|
|
|
- $this->queryBuilder->whereIn('order_id', function ($query) use ($logistic_ids) {
|
|
|
- $query->from('orders')->select('id')->whereIn('logistic_id', $logistic_ids);
|
|
|
- });
|
|
|
+ $this->getOrderQuery()->whereIn('logistic_id',$logistic_ids);
|
|
|
}
|
|
|
|
|
|
private function owner($owner_id)
|
|
|
@@ -168,16 +184,13 @@ class OrderPackageFilters
|
|
|
|
|
|
public function default_date()
|
|
|
{
|
|
|
- $this->queryBuilder->where('created_at', '>=', now()->startOfDay()->subDays(15))->where('created_at', '<', now()->startOfDay()->addDay());
|
|
|
+ $this->queryBuilder->where('created_at', '>=', now()->startOfDay()->subDays(15))
|
|
|
+ ->where('created_at', '<', now()->startOfDay()->addDay());
|
|
|
}
|
|
|
|
|
|
public function default_logistics()
|
|
|
{
|
|
|
- $this->queryBuilder->whereIn('order_id', function ($query) {
|
|
|
- $query->from('orders')
|
|
|
- ->select('id')
|
|
|
- ->whereNotIn('logistic_id', [13, 24, 25, 26, 27, 30, 31, 32, 33, 34, 60, 63, 65, 66, 68, 70, 102, 105, 107, 116, 10]);
|
|
|
- });
|
|
|
+ $this->getOrderQuery()->whereNotIn('logistic_id', [13, 24, 25, 26, 27, 30, 31, 32, 33, 34, 60, 63, 65, 66, 68, 70, 102, 105, 107, 116, 10]);
|
|
|
}
|
|
|
|
|
|
public function is_issue($is_issue)
|
|
|
@@ -237,10 +250,8 @@ class OrderPackageFilters
|
|
|
|
|
|
public function order_notes($order_notes)
|
|
|
{
|
|
|
- $ordernos = OracleDOCOrderHeader::query()->select('orderno')->where('notes', 'like', $order_notes)->pluck('orderno');
|
|
|
- $this->queryBuilder->whereIn('order_id', function ($query) use ($ordernos) {
|
|
|
- $query->from('orders')->select('order_id')->whereIn('code', $ordernos);
|
|
|
- });
|
|
|
+ $orderNos = OracleDOCOrderHeader::query()->select('orderno')->where('notes', 'like', $order_notes)->pluck('orderno');
|
|
|
+ $this->getOrderQuery()->whereIn('code',$orderNos);
|
|
|
}
|
|
|
|
|
|
public function exception_status($exception_status)
|
|
|
@@ -274,14 +285,11 @@ class OrderPackageFilters
|
|
|
}
|
|
|
|
|
|
public function warehouse($warehouseId){
|
|
|
- $this->queryBuilder->whereIn('order_id', function ($query) use ($warehouseId) {
|
|
|
- $query->from('orders')->select('id');
|
|
|
- $this->searchWay($query, $warehouseId, 'orders.warehouse_id');
|
|
|
- });
|
|
|
+ $this->searchWay($this->getOrderQuery(),$warehouseId,'warehouse_id');
|
|
|
}
|
|
|
|
|
|
public function virtual_receive()
|
|
|
{
|
|
|
- $this->queryBuilder->where('collecting_status', 1)->where('route_length', '<', 3);
|
|
|
+ $this->queryBuilder->where('route_length', '>', 1)->where('route_length', '<', 3);
|
|
|
}
|
|
|
}
|