|
|
@@ -13,6 +13,7 @@ use App\WorkOrder;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
+use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
class WorkOrderFilters
|
|
|
{
|
|
|
@@ -75,17 +76,31 @@ class WorkOrderFilters
|
|
|
}
|
|
|
|
|
|
$user = Auth::user();
|
|
|
+
|
|
|
+ // 当前用户可见 承运商
|
|
|
$logistic_ids = App('UserService')->getPermittingLogisticIds($user);
|
|
|
+ // 当前用户可见 货主
|
|
|
$owner_id = app('UserService')->getPermittingOwnerIds($user);
|
|
|
- if (count($logistic_ids)>=0 && count($owner_id) == 0){
|
|
|
- $orderIssueIds = OrderIssue::query()->select('id')->whereIn('name',['破损','快递丢件'])->get()->toArray();
|
|
|
- $orderIssueIds = array_intersect($orderIssueIds,$this->array_filter['order_issue_type']);
|
|
|
- if (count($orderIssueIds) == 0) unset($this->array_filter['order_issue_type']);
|
|
|
- else $this->array_filter['order_issue_type'] = $orderIssueIds;
|
|
|
+
|
|
|
+ $orderQuery = $this->getOrderQuery();
|
|
|
+
|
|
|
+ // 承运商筛选前置
|
|
|
+ if(Gate::allows('订单管理-工单处理-客服编辑') || Gate::allows('订单管理-工单处理-货主编辑')){
|
|
|
+ // 筛选 客服 和 货主可见 承运商
|
|
|
+ // $orderQuery->whereIn('logistic_id',$logistic_ids);
|
|
|
+ } else if (Gate::allows('订单管理-工单处理-承运商编辑')){
|
|
|
+ // 筛选承运商用户可见
|
|
|
+ $orderQuery->whereIn('logistic_id',$logistic_ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 货主筛选前置
|
|
|
+ if(Gate::allows('订单管理-工单处理-客服编辑') || Gate::allows('订单管理-工单处理-承运商编辑')){
|
|
|
+ // 筛选 客服 和 承运商可见 货主
|
|
|
+ // $orderQuery->whereIn('owner_id',$owner_id);
|
|
|
+ }else if(Gate::allows('订单管理-工单处理-货主编辑')){
|
|
|
+ // 筛选 货主 用户可见
|
|
|
+ $orderQuery->whereIn('owner_id',$owner_id);
|
|
|
}
|
|
|
- $this->getOrderQuery()->where(function($query)use ($owner_id,$logistic_ids){
|
|
|
- $query->whereIn('owner_id',$owner_id)->orWhereIn('logistic_id',$logistic_ids);
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
public function beforeApply()
|
|
|
@@ -196,7 +211,8 @@ class WorkOrderFilters
|
|
|
$this->queryBuilder->whereNotIn('order_id',$orderIssueQuery);
|
|
|
}
|
|
|
}
|
|
|
- // 承运商
|
|
|
+
|
|
|
+ // 承运商筛选
|
|
|
public function logistic($logistic)
|
|
|
{
|
|
|
$orderQuery = $this->getOrderQuery()->whereIn('id',WorkOrder::query()->select('order_id'));
|