|
|
@@ -6,6 +6,7 @@ namespace App\Filters;
|
|
|
|
|
|
use App\Commodity;
|
|
|
use App\Order;
|
|
|
+use App\OrderDetail;
|
|
|
use App\OrderIssue;
|
|
|
use App\OrderIssueProcessLog;
|
|
|
use App\OrderIssueRejectedBill;
|
|
|
@@ -36,6 +37,7 @@ class OrderIssueFilters
|
|
|
protected $orderIssueProcessLogQuery;
|
|
|
protected $shopQuery;
|
|
|
protected $workOrderQuery;
|
|
|
+ protected $orderDetailQuery;
|
|
|
protected $filters = [
|
|
|
'log_content',
|
|
|
'is_imported',
|
|
|
@@ -93,70 +95,78 @@ class OrderIssueFilters
|
|
|
return $this->orderQuery;
|
|
|
}
|
|
|
|
|
|
- private function getCommodityQuery()
|
|
|
+ private function getCommodityQuery(): Builder
|
|
|
{
|
|
|
if (!$this->commodityQuery)
|
|
|
$this->commodityQuery = Commodity::query()->selectRaw('id');
|
|
|
return $this->commodityQuery;
|
|
|
}
|
|
|
|
|
|
- private function getOrderPackageQuery()
|
|
|
+ private function getOrderPackageQuery(): Builder
|
|
|
{
|
|
|
if (is_null($this->orderPackageQuery))
|
|
|
$this->orderPackageQuery = OrderPackage::query()->selectRaw('order_packages.order_id');
|
|
|
return $this->orderPackageQuery;
|
|
|
}
|
|
|
|
|
|
- private function getRejectedBillQuery()
|
|
|
+ private function getRejectedBillQuery(): Builder
|
|
|
{
|
|
|
if (!$this->rejectedBillQuery)
|
|
|
$this->rejectedBillQuery = RejectedBill::query()->selectRaw('logistic_number_return');
|
|
|
return $this->rejectedBillQuery;
|
|
|
}
|
|
|
|
|
|
- private function getRejectedBillItemQuery()
|
|
|
+ private function getRejectedBillItemQuery(): Builder
|
|
|
{
|
|
|
if (!$this->rejectedBillItemQuery)
|
|
|
$this->rejectedBillItemQuery = RejectedBillItem::query()->selectRaw('id_rejected_bill');
|
|
|
return $this->rejectedBillItemQuery;
|
|
|
}
|
|
|
|
|
|
- private function getOrderPackageCommodityQuery()
|
|
|
+ private function getOrderPackageCommodityQuery(): Builder
|
|
|
{
|
|
|
if (!$this->orderPackageCommodityQuery)
|
|
|
$this->orderPackageCommodityQuery = OrderPackageCommodities::query()->selectRaw('order_package_commodities.order_package_id');
|
|
|
return $this->orderPackageCommodityQuery;
|
|
|
}
|
|
|
|
|
|
- private function getOrderIssueRejectedBillQuery()
|
|
|
+ private function getOrderIssueRejectedBillQuery(): Builder
|
|
|
{
|
|
|
if (!$this->orderIssueRejectedBIllQuery)
|
|
|
$this->orderIssueRejectedBIllQuery = OrderIssueRejectedBill::query()->selectRaw('order_issue_id');
|
|
|
return $this->orderIssueRejectedBIllQuery;
|
|
|
}
|
|
|
|
|
|
- private function getOrderIssueProcessLogQuery()
|
|
|
+ private function getOrderIssueProcessLogQuery(): Builder
|
|
|
{
|
|
|
if (!$this->orderIssueProcessLogQuery)
|
|
|
$this->orderIssueProcessLogQuery = OrderIssueProcessLog::query()->selectRaw('order_issue_id');
|
|
|
return $this->orderIssueProcessLogQuery;
|
|
|
}
|
|
|
|
|
|
- private function getShopQuery()
|
|
|
+ private function getShopQuery(): Builder
|
|
|
{
|
|
|
if (!$this->shopQuery)
|
|
|
$this->shopQuery = Shop::query()->selectRaw('id');
|
|
|
return $this->shopQuery;
|
|
|
}
|
|
|
|
|
|
- private function getWorkOrderQuery()
|
|
|
+ private function getWorkOrderQuery(): Builder
|
|
|
{
|
|
|
if (!$this->workOrderQuery)
|
|
|
$this->workOrderQuery = WorkOrder::query()->selectRaw('order_id');
|
|
|
return $this->workOrderQuery;
|
|
|
}
|
|
|
|
|
|
- public function apply($builder)
|
|
|
+ private function getOrderDetailQuery(): Builder
|
|
|
+ {
|
|
|
+ if (!$this->orderDetailQuery){
|
|
|
+ $this->orderDetailQuery = OrderDetail::query()->select('order_id');
|
|
|
+ }
|
|
|
+ return $this->orderDetailQuery;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function apply($builder): Builder
|
|
|
{
|
|
|
$this->queryBuilder = $builder;
|
|
|
$this->beforeApply();
|
|
|
@@ -209,6 +219,10 @@ class OrderIssueFilters
|
|
|
if ($this->shopQuery)
|
|
|
$this->getOrderQuery()->whereIn('shop_id', $this->shopQuery);
|
|
|
|
|
|
+ if ($this->orderDetailQuery){
|
|
|
+ $this->getOrderQuery()->whereIn('order_id',$this->orderDetailQuery);
|
|
|
+ }
|
|
|
+
|
|
|
if ($this->orderQuery)
|
|
|
$this->queryBuilder->whereIn('order_issues.order_id', $this->orderQuery);
|
|
|
|
|
|
@@ -488,7 +502,7 @@ class OrderIssueFilters
|
|
|
public function is_work_order($is_work_order)
|
|
|
{
|
|
|
if ($is_work_order == '1') {
|
|
|
- $this->queryBuilder->whereIn('order_id',$this->getWorkOrderQuery());
|
|
|
+ $this->queryBuilder->whereIn('order_id', $this->getWorkOrderQuery());
|
|
|
} else if ($is_work_order == '2') {
|
|
|
$this->queryBuilder->whereNotIn('order_id', $this->getWorkOrderQuery());
|
|
|
}
|