|
@@ -471,17 +471,14 @@ class ProductService extends Service
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
//是否总公司
|
|
|
- $is_main = EmployeeService::isMain($user['id']);
|
|
|
+ $is_main = $user['is_all_depart'];
|
|
|
+ $top_depart = $user['depart_top'][0] ?? [];
|
|
|
+ $customer['is_edit'] = $customer['top_depart_id'] == $top_depart['depart_id'] ? 1 : 0;
|
|
|
$customer['product_price'] = [];
|
|
|
//展示金额
|
|
|
foreach ($detail as $value){
|
|
|
- if(! $is_main){
|
|
|
- $top_depart = $user['depart_top'][0] ?? [];
|
|
|
- if($top_depart['basic_type_id'] != $value['basic_type_id']){
|
|
|
- $is_show = 0;
|
|
|
- }else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
+ if(! $is_main && ($top_depart['basic_type_id'] != $value['basic_type_id'])) {
|
|
|
+ $is_show = 0;
|
|
|
}else{
|
|
|
$is_show = 1;
|
|
|
}
|
|
@@ -557,21 +554,6 @@ class ProductService extends Service
|
|
|
->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','state','crt_id','crt_time','mark','depart_id','top_depart_id')
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
- if($user['id'] != Employee::SPECIAL_ADMIN ) {
|
|
|
- $user_id = $user['id'];
|
|
|
- $depart_id = $user['depart_range'];
|
|
|
- $product_id = ProductRange::where('del_time',0)
|
|
|
- ->where(function ($query) use($user_id, $depart_id) {
|
|
|
- $query->where('employee_id',$user_id)
|
|
|
- ->orWhereIn('depart_id', $depart_id);
|
|
|
- })->select('product_id')->get()
|
|
|
- ->toArray();
|
|
|
- $product_id = array_unique(array_column($product_id,'product_id'));
|
|
|
- //可见范围
|
|
|
- $model->when(! empty($sales_order_id), function ($query) use ($product_id) {
|
|
|
- return $query->orWhereIn('id', $product_id);
|
|
|
- });
|
|
|
- }
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(isset($data['state'])) $model->where('state', $data['state']);
|
|
|
|
|
@@ -641,23 +623,27 @@ class ProductService extends Service
|
|
|
->toArray();
|
|
|
$detail_map = [];
|
|
|
foreach ($detail as $value){
|
|
|
- $detail_map[$value['product_id']] = $value;
|
|
|
+ $detail_map[$value['product_id']][] = $value;
|
|
|
}
|
|
|
|
|
|
//是否总公司
|
|
|
- $is_main = EmployeeService::isMain($user['id']);
|
|
|
+ $is_main = $user['is_all_depart'];
|
|
|
$top_depart = $user['depart_top'][0] ?? [];
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
$tmp = [];
|
|
|
if(isset($detail_map[$value['id']])){
|
|
|
$d = $detail_map[$value['id']];
|
|
|
foreach ($d as $v){
|
|
|
- //不是总公司 不是公司设置的金额 就不展示
|
|
|
- if(! $is_main && ($top_depart['basic_type_id'] != $v['basic_type_id'])) continue;
|
|
|
+ if(! $is_main && ($top_depart['basic_type_id'] != $v['basic_type_id'])) {
|
|
|
+ $is_show = 0;
|
|
|
+ }else{
|
|
|
+ $is_show = 1;
|
|
|
+ }
|
|
|
$tmp[] = [
|
|
|
- 'basic_type_id' => $value['basic_type_id'],
|
|
|
- 'basic_type_title' => $basic_map[$value['basic_type_id']] ?? '',
|
|
|
- 'price' => $value['price'],
|
|
|
+ 'basic_type_id' => $v['basic_type_id'],
|
|
|
+ 'basic_type_title' => $basic_map[$v['basic_type_id']] ?? '',
|
|
|
+ 'price' => $v['price'],
|
|
|
+ 'is_show' => $is_show
|
|
|
];
|
|
|
}
|
|
|
}
|