cqpCow před 1 rokem
rodič
revize
988f4a3245

+ 3 - 0
app/Model/Customer.php

@@ -25,11 +25,14 @@ class Customer extends Model
     public static $is_search = false;
     public static $is_pond_state = true;
     public static $limitKey = "customerPondState";
+    const range_function = 'customerRange';
+
     public function __construct(array $attributes = [])
     {
         if(! empty($attributes['userData'])) {
             self::$user = $attributes['userData'];
             self::$search = $attributes['search'];
+            self::$user['range_function'] = self::range_function;
             self::$is_search = true;
             if(! empty(self::$search['pond_state'])) self::$is_pond_state = false;
         }

+ 7 - 8
app/Scopes/DepartmentScope.php

@@ -1,7 +1,6 @@
 <?php
 namespace App\Scopes;
 
-use App\Service\EmployeeService;
 use App\Service\RangeService;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model;
@@ -23,29 +22,29 @@ class DepartmentScope implements Scope
     {
         //权限范围内的部门
         $depart_range = $this->user['depart_range'] ?? [];
+        //我可见的
+        $is_see = $this->search['is_see'] ?? 0;
 
         //可见范围方法
         $range_function = $this->user['range_function'] ?? "";
         $is_function_range = $this->hasMethod(new RangeService(),$range_function);
 
-        //确认顶级部门
+        //顶级部门
         $search_depart_id = $this->search['top_depart_id'] ?? 0; //顶级公司
         if(empty($search_depart_id)){
-            //默认进来 只显示自己公司下的 自己权限范围下的部门数据
+            //默认进来 自身顶级公司
             $top_depart_id = $this->user['depart_top'][0] ?? [];
             $top_depart_id = $top_depart_id['depart_id'] ?? 0;
         }else{
-            //查询给的公司下的 自己权限范围下的部门数据
+            //查询 顶级公司
             $top_depart_id = $search_depart_id;
         }
-        //确认顶级部门 结束  =》   $top_depart_id
 
-        //顶级部门下 权限部门内所有数据
+        //顶级部门下 权限范围内部门的所有数据
         $builder->where('top_depart_id', $top_depart_id)
             ->whereIn('depart_id', $depart_range);
 
-        $is_see = $this->search['is_see'] ?? 0; //我可见的
-        //可见范围 部门 人 过滤后返回的数据id
+        //加上可见范围 部门 人以后的数据
         $id = [];
         if($is_see && $is_function_range) $id = RangeService::$range_function($this->user);
         $builder->orWhereIn('id', $id);

+ 4 - 29
app/Service/CheckService.php

@@ -56,7 +56,6 @@ class CheckService extends Service
     public static $opt_case = [
         self::two => 'confirmInvoiceOrder',
         self::three => 'confirmPurchaseOrder',
-        self::four => 'confirmSalesOrder',
         self::five => 'confirmConstruction',
         self::six => 'confirmReturnExchangeOrder',
     ];
@@ -164,14 +163,14 @@ class CheckService extends Service
         return [true,''];
     }
 
-    public function createPurchaseOrderSales($data, $order){
+    public function createPurchaseOrderSales($data, $order){//todo
         if(empty($order['is_purchase_to_main'])) return [true, ''];
         $prefix = SalesOrder::$prefix[SalesOrder::Model_type_two];
         $order_number = OrderNoService::createSalesOrderNumber($prefix);
         $product = PurchaseOrderInfo::where('del_time',0)
             ->where('purchase_order_id',$order['id'])
             ->get()->toArray();
-        if(empty($product)) return [false, '确实采购订单产品数据'];
+        if(empty($product)) return [false, '采购订单产品数据不能为空'];
 
         $model = new SalesOrder();
         $model->model_type = SalesOrder::Model_type_two;
@@ -185,24 +184,16 @@ class CheckService extends Service
         $model->contract_fee = $order['purchase_total'];
         $model->save();
 
-        $pro = Product::whereIn('id',array_column($product,'product_id'))
-            ->select('cost','id','retail_price')
-            ->get()->toArray();
-        $pro = array_column($pro,null,'id');
+        $map = (new ProductService())->getProductDetail(array_column($product,'product_id'));
 
         $insert = [];
         foreach ($product as $value){
-            $tmp = $pro[$value['product_id']] ?? [];
+            $tmp = $map[$value['product_id']] ?? [];
             $insert[] = [
                 'sales_order_id' => $model->id,
                 'product_id' => $value['product_id'],
                 'number' => $value['number'],
                 'price' => $value['price'],
-                'title' => $value['title'],
-                'code' => $value['code'],
-                'size' => $value['size'],
-                'unit' => $value['unit'],
-                'bar_code' => $value['bar_code'],
                 'cost' => $tmp['cost'] ?? 0,
                 'retail_price' => $tmp['retail_price'] ?? 0,
             ];
@@ -214,22 +205,6 @@ class CheckService extends Service
         return [true,''];
     }
 
-    public function confirmSalesOrder($data){
-        $model = SalesOrder::where('id',$data['id'])->where('del_time',0)->first();
-        if(empty($model)) return [false, '合同不存在或已被删除'];
-
-        if($data['type'] == self::TYPE_ONE){
-            if($model->state == SalesOrder::State_one) return [false,'已锁定,操作失败!'];
-            $model->state = SalesOrder::State_one;
-        }else{
-            if($model->state == SalesOrder::State_zero) return [false,'未锁定,操作失败!'];
-            $model->state = SalesOrder::State_zero;
-        }
-        $model->save();
-
-        return [true,$model->toArray()];
-    }
-
     public function confirmConstruction($data){
         $model = Construction::where('id',$data['id'])
             ->where('del_time',0)

+ 13 - 10
app/Service/ConstructionService.php

@@ -95,16 +95,13 @@ class ConstructionService extends Service
                         'construction_id' => $model->id,
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'mark' => $value['mark'] ?? '',
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'] ?? 0,
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ConstructionProductInfo::insert($insert);
@@ -194,16 +191,13 @@ class ConstructionService extends Service
                         'construction_id' => $model->id,
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'mark' => $value['mark'] ?? '',
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'] ?? 0,
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ConstructionProductInfo::insert($insert);
@@ -333,7 +327,16 @@ class ConstructionService extends Service
         $p_info = ConstructionProductInfo::where('del_time',0)
             ->where('construction_id',$construction['id'])
             ->get()->toArray();
+        $basic_price = BasicType::whereIn('id',array_unique(array_column($p_info,'basic_type_id')))->pluck('title','id')->toArray();
+        $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
         foreach ($p_info as $value){
+            $tmp = $map[$value['product_id']] ?? [];
+            $value['title'] = $tmp['title'] ?? "";
+            $value['code'] = $tmp['code'] ?? "";
+            $value['size'] = $tmp['size'] ?? "";
+            $value['unit'] = $tmp['unit'] ?? "";
+            $value['bar_code'] = $tmp['bar_code'] ?? "";
+            $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
             $construction['product'][] = $value;
         }
         $construction['crt_name'] = $emp_map[$construction['crt_id']] ?? '';

+ 0 - 18
app/Service/CustomerService.php

@@ -504,24 +504,6 @@ class CustomerService extends Service
         if(! empty($data['pond_state'])) {
             // 进入公海池的客户 所有人可见
             $model->where('pond_state', '>',0);
-        }else{
-            // 未进入公海池的   getALL传入后无视设置范围
-            if(empty($data['getAll']) && $user['id'] != Employee::SPECIAL_ADMIN) {
-                $user_id = $user['id'];
-                $depart_id = $user['depart_range'];
-                $type = implode(',',CustomerInfo::$man);
-                $type2 = CustomerInfo::type_eight;
-                $depart_str = implode(',',$depart_id);
-                $str = "(data_id = $user_id AND type IN({$type})) OR (data_id IN({$depart_str}) AND type = {$type2})";
-
-                // 销售人员/负责人 3协同人  可见部门 可见人 可以看见
-                $customer_id = CustomerInfo::where('del_time',0)
-                    ->where(function ($query) use($str) {
-                        $query->whereRaw($str);
-                    })->select('customer_id')->get()->toArray();
-                $emp_id = array_unique(array_column($customer_id,'customer_id'));
-                $model->whereIn('id', $emp_id);
-            }
         }
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
         if(! empty($data['time_type'])) {

+ 27 - 2
app/Service/ProductService.php

@@ -579,6 +579,18 @@ class ProductService extends Service
         if(empty($data['retail_price'])) return [false,'零售价不能为空'];
         $res = $this->checkNumber($data['retail_price']);
         if(! $res) return [false,'零售价格请输入不超过两位小数并且大于0的数值'];
+        if(! empty($data['product_price'])){
+            $map = BasicType::whereIn('id',array_column($data['product_price'],'basic_type_id'))
+                ->pluck('title','id')
+                ->toArray();
+            foreach ($data['product_price'] as $value){
+                if(! empty($value['price'])) {
+                    $tmp = $map[$value['basic_type_id']] ?? '';
+                    $res = $this->checkNumber($value['price']);
+                    if(! $res) return [false, $tmp . '请输入不超过两位小数并且大于0的数值'];
+                }
+            }
+        }
 
         //所属部门 以及 顶级部门
         if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
@@ -615,7 +627,7 @@ class ProductService extends Service
             ->pluck('title','id')
             ->toArray();
         $detail = ProductPriceDetail::where('del_time',0)
-            ->where('product_id',array_unique(array_column($data['data'],'id')))
+            ->whereIn('product_id',array_unique(array_column($data['data'],'id')))
             ->select('product_id','basic_type_id','price')
             ->get()->toArray();
         $basic_map = BasicType::whereIn('id',array_unique(array_merge_recursive(array_column($data['data'],'unit'),array_column($detail,'basic_type_id'))))
@@ -639,11 +651,17 @@ class ProductService extends Service
                     }else{
                         $is_show = 1;
                     }
+                    if($top_depart['basic_type_id'] != $v['basic_type_id']) {
+                        $is_use = 0;
+                    }else{
+                        $is_use = 1;
+                    }
                     $tmp[] = [
                         'basic_type_id' => $v['basic_type_id'],
                         'basic_type_title' => $basic_map[$v['basic_type_id']] ?? '',
                         'price' => $v['price'],
-                        'is_show' => $is_show
+                        'is_show' => $is_show,
+                        'is_use' => $is_use
                     ];
                 }
             }
@@ -657,4 +675,11 @@ class ProductService extends Service
 
         return $data;
     }
+
+    //获取产品字典
+    public function getProductDetail($product_id = []){
+        if(empty($product_id)) return [];
+        $pro = Product::whereIn('id', $product_id)->get()->toArray();
+        return array_column($pro,null,'id');
+    }
 }

+ 18 - 0
app/Service/RangeService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\ConstructionInfo;
+use App\Model\CustomerInfo;
 use App\Model\ProductRange;
 use App\Model\ReturnExchangeOrderRange;
 use App\Model\SalesOrderInfo;
@@ -10,6 +11,23 @@ use App\Model\SalesOrderRange;
 
 class RangeService extends Service
 {
+    //获取客户可见数据
+    public static function customerRange($user){
+        $user_id = $user['id'];
+        $depart_id = $user['depart_range'];
+        $type = implode(',',CustomerInfo::$man);
+        $type2 = CustomerInfo::type_eight;
+        $depart_str = implode(',',$depart_id);
+        $str = "(data_id = $user_id AND type IN({$type})) OR (data_id IN({$depart_str}) AND type = {$type2})";
+
+        // 销售人员/负责人 3协同人  可见部门 可见人 可以看见
+        $customer_id = CustomerInfo::where('del_time',0)
+            ->where(function ($query) use($str) {
+                $query->whereRaw($str);
+            })->select('customer_id')->get()->toArray();
+        return array_unique(array_column($customer_id,'customer_id'));
+    }
+
     //获取产品可见数据
     public static function productRange($user){
         $user_id = $user['id'];

+ 18 - 21
app/Service/ReturnExchangeOrderService.php

@@ -2,6 +2,7 @@
 
 namespace App\Service;
 
+use App\Model\BasicType;
 use App\Model\Depart;
 use App\Model\Employee;
 use App\Model\ReturnExchangeOrder;
@@ -39,16 +40,13 @@ class ReturnExchangeOrderService extends Service
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
                         'mark' => $value['mark'] ?? '',
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'return_or_exchange' => ReturnExchangeOrderProductInfo::type_one,
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'],
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ReturnExchangeOrderProductInfo::insert($sub);
@@ -62,16 +60,13 @@ class ReturnExchangeOrderService extends Service
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
                         'mark' => $value['mark'] ?? '',
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'return_or_exchange' => ReturnExchangeOrderProductInfo::type_two,
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'],
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ReturnExchangeOrderProductInfo::insert($sub);
@@ -146,16 +141,13 @@ class ReturnExchangeOrderService extends Service
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
                         'mark' => $value['mark'] ?? '',
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'return_or_exchange' => ReturnExchangeOrderProductInfo::type_one,
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'],
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ReturnExchangeOrderProductInfo::insert($sub);
@@ -169,16 +161,13 @@ class ReturnExchangeOrderService extends Service
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
                         'mark' => $value['mark'] ?? '',
-                        'title' => $value['title'],
-                        'code' => $value['code'] ?? '',
-                        'size' => $value['size'] ?? '',
-                        'unit' => $value['unit'] ?? 0,
-                        'bar_code' => $value['bar_code'] ?? '',
                         'cost' => $value['cost'] ?? 0,
                         'retail_price' => $value['retail_price'] ?? 0,
                         'return_or_exchange' => ReturnExchangeOrderProductInfo::type_two,
                         'crt_time' => $time,
                         'storehouse_id' => $data['storehouse_id'],
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 ReturnExchangeOrderProductInfo::insert($sub);
@@ -240,9 +229,17 @@ class ReturnExchangeOrderService extends Service
         $order['product_one'] = $order['product_two'] = $order['depart'] = $order['employee'] = [];
         $info = ReturnExchangeOrderProductInfo::where('del_time',0)
             ->where('return_exchange_id',$data['id'])
-            ->select('id','return_exchange_id','product_id','product_id','number','mark','title','code','size','unit','bar_code','cost','retail_price','return_or_exchange')
             ->get()->toArray();
+        $basic_price = BasicType::whereIn('id',array_unique(array_column($info,'basic_type_id')))->pluck('title','id')->toArray();
+        $map = (new ProductService())->getProductDetail(array_column($info,'product_id'));
         foreach ($info as $value){
+            $tmp = $map[$value['product_id']] ?? [];
+            $value['title'] = $tmp['title'] ?? "";
+            $value['code'] = $tmp['code'] ?? "";
+            $value['size'] = $tmp['size'] ?? "";
+            $value['unit'] = $tmp['unit'] ?? "";
+            $value['bar_code'] = $tmp['bar_code'] ?? "";
+            $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
             if($value['return_or_exchange'] == ReturnExchangeOrderProductInfo::type_one){
                 $order['product_one'][] = $value;
             }else{

+ 50 - 36
app/Service/SalesOrderService.php

@@ -117,26 +117,18 @@ class SalesOrderService extends Service
             }
 
             if(! empty($data['product'])){
-                $pro = Product::whereIn('id',array_column($data['product'],'product_id'))
-                    ->select('bar_code','code','cost','size','title','id','retail_price','unit','top_depart_id')
-                    ->get()->toArray();
-                $pro = array_column($pro,null,'id');
                 $insert = [];
                 foreach ($data['product'] as $value){
-                    $tmp = $pro[$value['product_id']] ?? [];
                     $insert[] = [
                         'sales_order_id' => $model->id,
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
-                        'title' => $tmp['title'],
-                        'code' => $tmp['code'] ?? '',
-                        'size' => $tmp['size'] ?? '',
-                        'unit' => $tmp['unit'] ?? 0,
-                        'bar_code' => $tmp['bar_code'] ?? '',
-                        'cost' => $tmp['cost'] ?? 0,
-                        'retail_price' => $tmp['retail_price'] ?? 0,
+                        'cost' => $value['cost'] ?? 0,
+                        'retail_price' => $value['retail_price'] ?? 0,
                         'mark' => $value['mark'] ?? '',
                         'crt_time' => $time,
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 SalesOrderProductInfo::insert($insert);
@@ -242,26 +234,18 @@ class SalesOrderService extends Service
             }
 
             if(! empty($data['product'])){
-                $pro = Product::whereIn('id',array_column($data['product'],'product_id'))
-                    ->select('bar_code','code','cost','size','title','id','retail_price','unit','top_depart_id')
-                    ->get()->toArray();
-                $pro = array_column($pro,null,'id');
                 $insert = [];
                 foreach ($data['product'] as $value){
-                    $tmp = $pro[$value['product_id']] ?? [];
                     $insert[] = [
                         'sales_order_id' => $model->id,
                         'product_id' => $value['product_id'],
                         'number' => $value['number'],
-                        'title' => $tmp['title'],
-                        'code' => $tmp['code'] ?? '',
-                        'size' => $tmp['size'] ?? '',
-                        'unit' => $tmp['unit'] ?? 0,
-                        'bar_code' => $tmp['bar_code'] ?? '',
-                        'cost' => $tmp['cost'] ?? 0,
-                        'retail_price' => $tmp['retail_price'] ?? 0,
+                        'cost' => $value['cost'] ?? 0,
+                        'retail_price' => $value['retail_price'] ?? 0,
                         'mark' => $value['mark'] ?? '',
                         'crt_time' => $time,
+                        'basic_type_id' => $value['basic_type_id'],
+                        'price' => $value['price'],
                     ];
                 }
                 SalesOrderProductInfo::insert($insert);
@@ -382,7 +366,16 @@ class SalesOrderService extends Service
         $sales_p_info = SalesOrderProductInfo::where('del_time',0)
             ->where('sales_order_id',$sales['id'])
             ->get()->toArray();
+        $basic_price = BasicType::whereIn('id',array_unique(array_column($sales_p_info,'basic_type_id')))->pluck('title','id')->toArray();
+        $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
         foreach ($sales_p_info as $value){
+            $tmp = $map[$value['product_id']] ?? [];
+            $value['title'] = $tmp['title'] ?? "";
+            $value['code'] = $tmp['code'] ?? "";
+            $value['size'] = $tmp['size'] ?? "";
+            $value['unit'] = $tmp['unit'] ?? "";
+            $value['bar_code'] = $tmp['bar_code'] ?? "";
+            $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
             $sales['product'][] = $value;
         }
         $sales['crt_name'] = $emp_map[$sales['crt_id']] ?? '';
@@ -479,23 +472,27 @@ class SalesOrderService extends Service
         if(! empty($data['expire_time'])) $data['expire_time'] = $this->changeDateToDateMin($data['expire_time']);
 //        if(empty($data['contract_state'])) return [false,'请选择合同状态'];
 //        if(empty($data['employee_two'])) return [false,'请选择负责人'];
-        if(empty($data['product'])) return [false,'请选择产品'];
-        foreach ($data['product'] as $value){
-            if(empty($value['number'])) return [false,'产品数量不能为空'];
-            $res = $this->checkNumber($value['number']);
-            if(! $res) return [false,'请输入正确的产品数量'];
-
-            if(empty($value['retail_price'])) return [false,'产品零售价不能为空'];
-            $res = $this->checkNumber($value['retail_price']);
-            if(! $res) return [false,'产品零售价请输入不超过两位小数并且大于0的数值'];
+//        if(empty($data['product'])) return [false,'请选择产品'];
+        if(! empty($data['product'])){
+            foreach ($data['product'] as $value){
+                if(empty($value['number'])) return [false,'产品数量不能为空'];
+                $res = $this->checkNumber($value['number']);
+                if(! $res) return [false,'请输入正确的产品数量'];
+
+                if(empty($value['retail_price'])) return [false,'产品零售价不能为空'];
+                $res = $this->checkNumber($value['retail_price']);
+                if(! $res) return [false,'产品零售价请输入不超过两位小数并且大于0的数值'];
+            }
         }
-        if(empty($data['contract_fee'])) return [false,'合同金额不能为空'];
-        $res = $this->checkNumber($data['contract_fee']);
-        if(! $res) return [false, '合同金额请输入不超过两位小数并且大于0的数值'];
+
         if(! empty($data['rate'])){
             $res = $this->checkNumber($data['rate']);
             if(! $res) return [false, '整单扣除率请输入不超过两位小数并且大于0的数值'];
         }
+        if(! empty($data['contract_fee'])){
+            $res = $this->checkNumber($data['contract_fee']);
+            if(! $res) return [false, '合同金额请输入不超过两位小数并且大于0的数值'];
+        }
         if(! empty($data['other_fee'])){
             $res = $this->checkNumber($data['other_fee']);
             if(! $res) return [false, '其它费用请输入不超过两位小数并且大于0的数值'];
@@ -571,7 +568,16 @@ class SalesOrderService extends Service
             $sales_p_info = SalesOrderProductInfo::where('del_time',0)
                 ->where('sales_order_id',array_column($data['data'],'id'))
                 ->get()->toArray();
+            $basic_price = BasicType::whereIn('id',array_unique(array_column($sales_p_info,'basic_type_id')))->pluck('title','id')->toArray();
+            $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
             foreach ($sales_p_info as $value){
+                $tmp = $map[$value['product_id']] ?? [];
+                $value['title'] = $tmp['title'] ?? "";
+                $value['code'] = $tmp['code'] ?? "";
+                $value['size'] = $tmp['size'] ?? "";
+                $value['unit'] = $tmp['unit'] ?? "";
+                $value['bar_code'] = $tmp['bar_code'] ?? "";
+                $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
                 $product[$value['sales_order_id']][] = $value;
             }
             $sales_o_info = SalesOrderOtherFee::where('del_time',0)
@@ -685,6 +691,10 @@ class SalesOrderService extends Service
         $sale = $sale->toArray();
         if($sale['sales_order_type'] != SalesOrder::Order_type_one) return [false,'非安装件合同,操作失败'];
         if($sale['state'] > SalesOrder::State_one) return [false,'请确认合同状态,操作失败'];
+        $bool = SalesOrderProductInfo::where('del_time',0)
+            ->where('sales_order_id',$data['id'])
+            ->exists();
+        if(! $bool) return [false,'合同产品不能为空'];
         if(empty($data['dispatch_depart_one']) && empty($data['dispatch_employee'])) return [false, '请指派部门或人员'];
 
         return [true, $sale];
@@ -756,6 +766,10 @@ class SalesOrderService extends Service
         $sale = $sale->toArray();
         if($sale['sales_order_type'] != SalesOrder::Order_type_one) return [false,'非安装件合同,操作失败'];
         if($sale['state'] > SalesOrder::State_two) return [false,'请确认合同状态,操作失败'];
+        $bool = SalesOrderProductInfo::where('del_time',0)
+            ->where('sales_order_id',$data['id'])
+            ->exists();
+        if(! $bool) return [false,'合同产品不能为空'];
 
         $bool = Construction::where('del_time',0)
             ->where('sales_order_id',$data['id'])