chenqp 1 년 전
부모
커밋
04d7efe6d0
3개의 변경된 파일19개의 추가작업 그리고 26개의 파일을 삭제
  1. 4 4
      app/Model/Construction.php
  2. 5 0
      app/Service/CheckService.php
  3. 10 22
      app/Service/ConstructionService.php

+ 4 - 4
app/Model/Construction.php

@@ -8,15 +8,15 @@ class Construction extends UseScopeBaseModel
     const CREATED_AT = 'crt_time';
     const UPDATED_AT = 'upd_time';
     protected $dateFormat = 'U';
-    const Model_type_one = 1; // 总部安装
-    const Model_type_two = 2; // 分社网点安装
+    const Model_type_one = 1; // 到店安装
+    const Model_type_two = 2; // 仅施工
     public static $model_type = [
         self::Model_type_one,
         self::Model_type_two,
     ];
     public static $model_type_title = [
-        self::Model_type_one => '总部安装',
-        self::Model_type_two => '分社网点安装',
+        self::Model_type_one => '到店安装',
+        self::Model_type_two => '仅施工',
     ];
 
     public static $prefix = [

+ 5 - 0
app/Service/CheckService.php

@@ -737,6 +737,8 @@ class CheckService extends Service
     }
 
     public function recordConstruction($data, $order){
+        //仅施工不需要库存流水
+        if($order['model_type'] == Construction::Model_type_two) return [true, self::minus_one];
         $result = ConstructionProductInfo::where('del_time',0)
             ->where('construction_id',$order['id'])
             ->get()->toArray();
@@ -1076,6 +1078,9 @@ class CheckService extends Service
     }
 
     public function reject_record_construction($data,$order){
+        //仅施工不需要库存流水
+        if($order['model_type'] == Construction::Model_type_two) return [true, self::minus_one];
+
         //获取单据最新数据时间 正常施工数据
         $crt_time = 0;
         $latest = InOutRecord::where('del_time',0)

+ 10 - 22
app/Service/ConstructionService.php

@@ -146,7 +146,7 @@ class ConstructionService extends Service
                 ConstructionProductInfo::insert($insert);
 
                 //锁定库存
-                ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
+                if($data['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
             }
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
@@ -286,7 +286,7 @@ class ConstructionService extends Service
                 ConstructionProductInfo::insert($insert);
 
                 //锁定库存
-                ProductInventoryService::changeLockNumber($user,$msg[0],[]);
+                if($data['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,$msg[0],[]);
             }
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
@@ -368,7 +368,7 @@ class ConstructionService extends Service
             (new RangeService())->RangeDelete($data['id'],SeeRange::type_two);
 
             //锁定库存释放
-            ProductInventoryService::changeLockNumber($user,[],$product_save);
+            if($construction['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,[],$product_save);
 
             //排班修改
 //            $schedule = ScheduleInfo::where('del_time',0)
@@ -446,7 +446,7 @@ class ConstructionService extends Service
             ->select('b.title','a.contact_info')
             ->get()->toArray();
         $construction['customer_array'] = $info;
-        $construction['storehouse_title'] = Storehouse::where('id',$construction['storehouse_id'])->value('title');
+        $construction['storehouse_title'] = $construction['storehouse_id'] > 0 ? Storehouse::where('id',$construction['storehouse_id'])->value('title') : "";
         $emp_title = Employee::where('id',$construction['customer_contact_id'])->value('emp_name');
         $construction['customer_contact_title'] = $emp_title;
         $construction['employee_two'] = $construction['employee_one'] = $construction['construction_contact'] = $construction['product'] = [];
@@ -632,7 +632,7 @@ class ConstructionService extends Service
         if(empty($data['model_type'])) return [false,'工单模板类型不能为空'];
         if(! in_array($data['model_type'],Construction::$model_type)) return [false,'工单模板类型错误'];
         if(empty($data['order_number'])) return [false,'工单编号不能为空'];
-        if(empty($data['storehouse_id'])) return [false,'请选择仓库'];
+        if($data['model_type'] == Construction::Model_type_one && empty($data['storehouse_id'])) return [false,'请选择仓库'];
         if(empty($data['menu_id'])) return [false, '菜单信息不能为空'];
         if(empty($data['sales_order_id'])) return [false,'请选择合同'];
         $sale = SalesOrder::where('del_time',0)->where('id',$data['sales_order_id'])->first();
@@ -711,35 +711,23 @@ class ConstructionService extends Service
         //是否校验库存
         ProductInventoryService::is_check($user,$data);
 
-        list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
-        if(! $status) return [false, $msg];
+        if($data['model_type'] == Construction::Model_type_one){
+            //到店安装 才校验库存
+            list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
+            if(! $status) return [false, $msg];
+        }
 
-        $start_time = date("Y-m-d H:i",$data['start_time']);
-        $end_time = date("Y-m-d H:i",$data['end_time']);
         if($is_add){
             $bool = Construction::where('del_time',0)
                 ->where('order_number',$data['order_number'])
                 ->exists();
             if($bool) return [false,'工单编号已存在,请重新获取'];
-//            $bool = Construction::where('del_time',0)
-//                ->where('sales_order_id',$data['sales_order_id'])
-//                ->where('start_time', '<=', $data['end_time'])
-//                ->where('end_time', '>=', $data['start_time'])
-//                ->exists();
-//            if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
             $construction = Construction::where('del_time',0)
                 ->where('id',$data['id'])->first();
             if(empty($construction)) return [false, '施工单单据不存在或已被删除'];
             if($construction->state > Construction::STATE_ZERO) return [false,'请确认施工单单据状态,修改失败'];
-//            $bool = Construction::where('del_time',0)
-//                ->where('id','<>',$data['id'])
-//                ->where('sales_order_id',$data['sales_order_id'])
-//                ->where('start_time', '<=', $data['end_time'])
-//                ->where('end_time', '>=', $data['start_time'])
-//                ->exists();
-//            if($bool)  return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
         }
 
         return [true, [$product_submit, $product_save]];