|
@@ -11,6 +11,8 @@ use App\Model\ProductCategory;
|
|
|
use App\Model\ProductInfo;
|
|
|
use App\Model\ProductIntroduction;
|
|
|
use App\Model\ProductPriceDetail;
|
|
|
+use App\Model\Role;
|
|
|
+use App\Model\RoleMenuButton;
|
|
|
use App\Model\SeeRange;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
@@ -423,9 +425,6 @@ class ProductService extends Service
|
|
|
->first();
|
|
|
if(empty($customer)) return [false,'产品不存在或已被删除'];
|
|
|
$customer = $customer->toArray();
|
|
|
- //成本隐藏
|
|
|
- $customer['cost_show'] = "*";
|
|
|
-
|
|
|
$customer['product_category'] = ! empty($customer['product_category']) ? json_decode($customer['product_category'],true): [];
|
|
|
$category = ProductCategory::where('id',$customer['product_category_id'])
|
|
|
->value('title');
|
|
@@ -436,6 +435,7 @@ class ProductService extends Service
|
|
|
->first();
|
|
|
if(! empty($in)) $customer['introduction'] = $in->introduction;
|
|
|
|
|
|
+ $data['top_depart_id'] = $user['head']['id'] ?? 0;
|
|
|
$model = BasicType::TopClear($user,$data);
|
|
|
$basic = $model->where('del_time',0)
|
|
|
->where('type',22)
|
|
@@ -454,35 +454,33 @@ class ProductService extends Service
|
|
|
$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['basic_type_id'] != $value['basic_type_id'])) {
|
|
|
- $is_show = 0;
|
|
|
- }else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
- $customer['product_price'][$value['basic_type_id']] = [
|
|
|
- 'basic_type_id' => $value['basic_type_id'],
|
|
|
- 'basic_type_title' => $title_map[$value['basic_type_id']] ?? '',
|
|
|
- 'price' => $value['price'],
|
|
|
- 'is_show' => $is_show,
|
|
|
- ];
|
|
|
- }
|
|
|
|
|
|
+ //特殊功能按钮
|
|
|
+ $special_button = $user['special_button'] ?? [];
|
|
|
+
|
|
|
+ //成本隐藏
|
|
|
+ $price = "******";
|
|
|
+ if(in_array(RoleMenuButton::special_two,$special_button)) $price = $customer['cost'];
|
|
|
+ $customer['cost_show'] = $price;
|
|
|
+
|
|
|
+ //所有金额
|
|
|
foreach ($basic as $value){
|
|
|
- if(! $is_main && ($top_depart['basic_type_id'] != $value['id'])) {
|
|
|
- $is_show = 0;
|
|
|
+ $show = 0;
|
|
|
+ if(in_array(RoleMenuButton::special_one,$special_button)){
|
|
|
+ $show = 1;
|
|
|
}else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
- if(! isset($customer['product_price'][$value['id']])){
|
|
|
- $customer['product_price'][$value['id']] = [
|
|
|
- 'basic_type_id' => $value['id'],
|
|
|
- 'basic_type_title' => $title_map[$value['id']] ?? '',
|
|
|
- 'price' => 0,
|
|
|
- 'is_show' => $is_show,
|
|
|
- ];
|
|
|
+ if($top_depart['basic_type_id'] == $value['id']) $show = 1;
|
|
|
}
|
|
|
+ $customer['product_price'][$value['id']] = [
|
|
|
+ 'basic_type_id' => $value['id'],
|
|
|
+ 'basic_type_title' => $title_map[$value['id']] ?? '',
|
|
|
+ 'price' => 0,
|
|
|
+ 'is_show' => $show,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ //展示金额
|
|
|
+ foreach ($detail as $value){
|
|
|
+ if(isset($customer['product_price'][$value['basic_type_id']])) $customer['product_price'][$value['basic_type_id']]['price'] = $value['price'];
|
|
|
}
|
|
|
|
|
|
$customer['product_price'] = array_values($customer['product_price']);
|
|
@@ -661,24 +659,19 @@ class ProductService extends Service
|
|
|
//产品使用价格
|
|
|
$detail_map = $this->getProductPrice(array_column($data['data'],'id'), $type);
|
|
|
|
|
|
- //是否总公司
|
|
|
- $is_main = $user['is_all_depart'];
|
|
|
+ //当前门店
|
|
|
$top_depart = $user['depart_top'][0] ?? [];
|
|
|
+ //特殊功能按钮
|
|
|
+ $special_button = $user['special_button'] ?? [];
|
|
|
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'])) {
|
|
|
- $is_show = 0;
|
|
|
- }else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
- if($top_depart['basic_type_id'] != $v['basic_type_id']) {
|
|
|
- $is_use = 0;
|
|
|
- }else{
|
|
|
- $is_use = 1;
|
|
|
- }
|
|
|
+ $is_show = 0;
|
|
|
+ if(in_array(RoleMenuButton::special_one,$special_button)) $is_show = 1;
|
|
|
+ $is_use = 0;
|
|
|
+ if($top_depart['basic_type_id'] == $v['basic_type_id']) $is_use = 1;
|
|
|
$tmp[] = [
|
|
|
'basic_type_id' => $v['basic_type_id'],
|
|
|
'basic_type_title' => $basic_map[$v['basic_type_id']] ?? '',
|
|
@@ -696,7 +689,9 @@ class ProductService extends Service
|
|
|
$data['data'][$key]['unit_name'] = $basic_map[$value['unit']] ?? '';
|
|
|
|
|
|
//成本隐藏
|
|
|
- $data['data'][$key]['cost_show'] = "*";
|
|
|
+ $price = "******";
|
|
|
+ if(in_array(RoleMenuButton::special_two,$special_button)) $price = $value['cost'];
|
|
|
+ $data['data'][$key]['cost_show'] = $price;
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
@@ -711,6 +706,7 @@ class ProductService extends Service
|
|
|
|
|
|
//获取产品使用价格
|
|
|
public function getProductPrice($product_id = [], $type = 1){
|
|
|
+ if(! is_array($product_id)) $product_id = [$product_id];
|
|
|
//type 1 采购 2 合同 和 活动包
|
|
|
|
|
|
$detail_map = [];
|