cqpCow пре 1 година
родитељ
комит
115bff1a6b
2 измењених фајлова са 9 додато и 3 уклоњено
  1. 1 0
      app/Service/EmployeeService.php
  2. 8 3
      app/Service/SalesOrderService.php

+ 1 - 0
app/Service/EmployeeService.php

@@ -294,6 +294,7 @@ class EmployeeService extends Service
     public function employeeRule($data,$is_add = true){
         if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
         if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
+        if(empty($data['depart'])) return [false,'部门不能为空'];
 
         $mobile = $data['mobile'] ?? "";
         $number = $data['number'] ?? "";

+ 8 - 3
app/Service/SalesOrderService.php

@@ -7,6 +7,7 @@ use App\Model\BookingList;
 use App\Model\Construction;
 use App\Model\Customer;
 use App\Model\Employee;
+use App\Model\Product;
 use App\Model\SalesOrder;
 use App\Model\SalesOrderInfo;
 use App\Model\SalesOrderOtherFee;
@@ -866,11 +867,15 @@ class SalesOrderService extends Service
         if($bool) return [false,'合同已下施工,操作失败'];
 
         if(empty($data['dispatch_depart_two'])) return [false, '请指派总社或分社'];
-        $return = RangeService::productSeeRange(array_column($product,'product_id'));
+        $product = array_unique(array_column($product,'product_id'));
+        $return = RangeService::productSeeRange($product);
         if(empty($return)) return [false,'产品对于该总社或分社可见范围不能为空'];
+        $map = Product::whereIn('id',$product)->pluck('title','id')->toArray();
+
         foreach ($data['dispatch_depart_two'] as $value){
-            foreach ($return as $values){
-                if(! in_array($value, $values)) return [false,'产品对于该总社或分社可见范围不能为空'];
+            foreach ($return as $key => $values){
+                $tmp = $map[$key] ?? "";
+                if(! in_array($value, $values)) return [false,'产品'. $tmp .'对于该总社或分社可见范围不能为空'];
             }
         }