|
@@ -10,11 +10,12 @@ use App\Model\SalesOrderInfo;
|
|
|
use App\Model\SalesOrderRange;
|
|
|
use App\Model\SportsBagRange;
|
|
|
use App\Model\SupplierInfo;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class RangeService extends Service
|
|
|
{
|
|
|
//获取客户可见数据
|
|
|
- public static function customerRange($user){
|
|
|
+ public static function customerRange($user,$search){
|
|
|
$user_id = $user['id'];
|
|
|
$depart_id = $user['depart_range'];
|
|
|
$type = implode(',',CustomerInfo::$see_man);
|
|
@@ -27,11 +28,24 @@ class RangeService extends Service
|
|
|
->where(function ($query) use($str) {
|
|
|
$query->whereRaw($str);
|
|
|
})->select('customer_id')->get()->toArray();
|
|
|
- return array_unique(array_column($customer_id,'customer_id'));
|
|
|
+
|
|
|
+ $return_id = array_unique(array_column($customer_id,'customer_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('customer')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取供应商可见数据
|
|
|
- public static function supplierRange($user){
|
|
|
+ public static function supplierRange($user,$search){
|
|
|
$user_id = $user['id'];
|
|
|
$depart_id = $user['depart_range'];
|
|
|
$type = SupplierInfo::type_two;
|
|
@@ -44,11 +58,24 @@ class RangeService extends Service
|
|
|
->where(function ($query) use($str) {
|
|
|
$query->whereRaw($str);
|
|
|
})->select('supplier_id')->get()->toArray();
|
|
|
- return array_unique(array_column($supplier_id,'supplier_id'));
|
|
|
+
|
|
|
+ $return_id = array_unique(array_column($supplier_id,'supplier_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('supplier')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取产品可见数据
|
|
|
- public static function productRange($user){
|
|
|
+ public static function productRange($user,$search){
|
|
|
$user_id = $user['id'];
|
|
|
$depart_id = $user['depart_range'];
|
|
|
$product_id = ProductRange::where('del_time',0)
|
|
@@ -57,11 +84,24 @@ class RangeService extends Service
|
|
|
->orWhereIn('depart_id', $depart_id);
|
|
|
})->select('product_id')->get()
|
|
|
->toArray();
|
|
|
- return array_unique(array_column($product_id,'product_id'));
|
|
|
+
|
|
|
+ $return_id = array_unique(array_column($product_id,'product_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('product')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取合同可见数据
|
|
|
- public static function salesOrderRange($user){
|
|
|
+ public static function salesOrderRange($user,$search){
|
|
|
//单据中选择的签订负责协同人
|
|
|
$sales_order_id = SalesOrderInfo::where('del_time',0)
|
|
|
->whereIn('type',SalesOrderInfo::$man)
|
|
@@ -78,21 +118,45 @@ class RangeService extends Service
|
|
|
->orWhereIn('depart_id', $depart_id);
|
|
|
})->select('sales_order_id')->get()
|
|
|
->toArray();
|
|
|
- return array_unique(array_merge_recursive($sales_order_id,array_column($sales_order_id2,'sales_order_id')));
|
|
|
+ $return_id = array_unique(array_merge_recursive($sales_order_id,array_column($sales_order_id2,'sales_order_id')));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('sales_order')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取施工单可见数据
|
|
|
- public static function constructionRange($user){
|
|
|
+ public static function constructionRange($user,$search){
|
|
|
//单据中选择的签订负责协同人
|
|
|
$construction_id = ConstructionInfo::where('del_time',0)
|
|
|
->where('employee_id',$user['id'])
|
|
|
->select('construction_id')
|
|
|
->get()->toArray();
|
|
|
- return array_unique(array_column($construction_id,'construction_id'));
|
|
|
+ $return_id = array_unique(array_column($construction_id,'construction_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('construction')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取退换货单可见数据
|
|
|
- public static function returnExchangeOrderRange($user){
|
|
|
+ public static function returnExchangeOrderRange($user,$search){
|
|
|
$user_id = $user['id'];
|
|
|
$depart_id = $user['depart_range'];
|
|
|
$return_exchange_id = ReturnExchangeOrderRange::where('del_time',0)
|
|
@@ -101,11 +165,24 @@ class RangeService extends Service
|
|
|
->orWhereIn('depart_id', $depart_id);
|
|
|
})->select('return_exchange_id')->get()
|
|
|
->toArray();
|
|
|
- return array_unique(array_column($return_exchange_id,'return_exchange_id'));
|
|
|
+
|
|
|
+ $return_id = array_unique(array_column($return_exchange_id,'return_exchange_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('return_exchange_order')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
|
|
|
//获取活动包可见数据
|
|
|
- public static function sportsBagRange($user){
|
|
|
+ public static function sportsBagRange($user,$search){
|
|
|
$user_id = $user['id'];
|
|
|
$depart_id = $user['depart_range'];
|
|
|
$return_exchange_id = SportsBagRange::where('del_time',0)
|
|
@@ -114,6 +191,19 @@ class RangeService extends Service
|
|
|
->orWhereIn('depart_id', $depart_id);
|
|
|
})->select('sports_bag_id')->get()
|
|
|
->toArray();
|
|
|
- return array_unique(array_column($return_exchange_id,'sports_bag_id'));
|
|
|
+
|
|
|
+ $return_id = array_unique(array_column($return_exchange_id,'sports_bag_id'));
|
|
|
+ if(! empty($search['top_depart_id'])){
|
|
|
+ $id = DB::table('sports_bag')
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->where('top_depart_id',$search['top_depart_id'])
|
|
|
+ ->select('id')->get()->toArray();
|
|
|
+ $id = array_column($id,'id');
|
|
|
+ foreach ($return_id as $key => $value){
|
|
|
+ if(! in_array($value,$id)) unset($return_id[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return_id;
|
|
|
}
|
|
|
}
|