|
|
@@ -71,38 +71,46 @@ class WorkOrderFilters
|
|
|
if(isset($this->params['data']))
|
|
|
$this->id(explode(',',$this->params['data']));
|
|
|
|
|
|
- if (!isset($this->params['owner'])){
|
|
|
- $this->getOrderQuery()->whereIn('owner_id', app('UserService')->getPermittingOwnerIds(Auth::user())??[]);
|
|
|
- }
|
|
|
+ // 可见过滤
|
|
|
+ $this->afterFilter();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function afterFilter(){
|
|
|
+ $orderQuery = $this->getOrderQuery();
|
|
|
|
|
|
$user = Auth::user();
|
|
|
|
|
|
- // 当前用户可见 承运商
|
|
|
$logistic_ids = App('UserService')->getPermittingLogisticIds($user);
|
|
|
- // 当前用户可见 货主
|
|
|
- $owner_id = app('UserService')->getPermittingOwnerIds($user);
|
|
|
|
|
|
- $orderQuery = $this->getOrderQuery();
|
|
|
+ $owner_ids = app('UserService')->getPermittingOwnerIds($user);
|
|
|
|
|
|
- // 承运商筛选前置
|
|
|
- if(Gate::allows('订单管理-工单处理-客服编辑') || Gate::allows('订单管理-工单处理-货主编辑')){
|
|
|
- // 筛选 客服 和 货主可见 承运商
|
|
|
- // $orderQuery->whereIn('logistic_id',$logistic_ids);
|
|
|
- } else if (Gate::allows('订单管理-工单处理-承运商编辑')){
|
|
|
- // 筛选承运商用户可见
|
|
|
- $orderQuery->whereIn('logistic_id',$logistic_ids);
|
|
|
- }
|
|
|
+ $this->afterFilterLogistic($orderQuery,$owner_ids,$logistic_ids);
|
|
|
|
|
|
- // 货主筛选前置
|
|
|
+ $this->afterFilterOwner($orderQuery,$owner_ids,);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function afterFilterOwner($orderQuery,$owner_ids)
|
|
|
+ {
|
|
|
if(Gate::allows('订单管理-工单处理-客服编辑') || Gate::allows('订单管理-工单处理-承运商编辑')){
|
|
|
- // 筛选 客服 和 承运商可见 货主
|
|
|
- // $orderQuery->whereIn('owner_id',$owner_id);
|
|
|
}else if(Gate::allows('订单管理-工单处理-货主编辑')){
|
|
|
- // 筛选 货主 用户可见
|
|
|
- $orderQuery->whereIn('owner_id',$owner_id);
|
|
|
+ $orderQuery->whereIn('owner_id',$owner_ids);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function afterFilterLogistic($orderQuery,$owner_ids,$logistic_ids)
|
|
|
+ {
|
|
|
+ if(Gate::allows('订单管理-工单处理-客服编辑') || Gate::allows('订单管理-工单处理-货主编辑')){
|
|
|
+ if (!isset($this->params['owner'])){
|
|
|
+ $this->getOrderQuery()->whereIn('owner_id', $owner_ids);
|
|
|
+ }
|
|
|
+ } else if (Gate::allows('订单管理-工单处理-承运商编辑')){
|
|
|
+ $orderQuery->whereIn('logistic_id',array_values($logistic_ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public function beforeApply()
|
|
|
{
|
|
|
if ($this->orderPackageQuery){
|