cqpCow 1 ano atrás
pai
commit
598469a6b4
2 arquivos alterados com 62 adições e 0 exclusões
  1. 13 0
      app/Model/ConstructionFile.php
  2. 49 0
      app/Service/ConstructionService.php

+ 13 - 0
app/Model/ConstructionFile.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ConstructionFile extends Model
+{
+    protected $table = "construction_file"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}

+ 49 - 0
app/Service/ConstructionService.php

@@ -4,12 +4,14 @@ namespace App\Service;
 
 use App\Model\BasicType;
 use App\Model\Construction;
+use App\Model\ConstructionFile;
 use App\Model\ConstructionInfo;
 use App\Model\ConstructionProductInfo;
 use App\Model\Customer;
 use App\Model\Depart;
 use App\Model\Employee;
 use App\Model\SalesOrder;
+use App\Model\SalesOrderInfo;
 use App\Model\SalesOrderProductInfo;
 use App\Model\ScheduleInfo;
 use App\Model\SeeRange;
@@ -71,6 +73,9 @@ class ConstructionService extends Service
             ConstructionProductInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => $time]);
+            ConstructionFile::where('del_time',0)
+                ->where('construction_id',$data['id'])
+                ->update(['del_time' => $time]);
 
             if(! empty($data['construction_contact'])){
                 $insert = [];
@@ -124,6 +129,20 @@ class ConstructionService extends Service
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
 
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'construction_id' => $data['id'],
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'mark' => $value['mark'] ?? "",
+                        'crt_time' => $time,
+                    ];
+                }
+                ConstructionFile::insert($insert);
+            }
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -229,6 +248,20 @@ class ConstructionService extends Service
 
             if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
 
+            if(! empty($data['file'])){
+                $insert = [];
+                foreach ($data['file'] as $value){
+                    $insert[] = [
+                        'construction_id' => $data['id'],
+                        'file' => $value['url'],
+                        'name' => $value['name'],
+                        'mark' => $value['mark'] ?? "",
+                        'crt_time' => $time,
+                    ];
+                }
+                ConstructionFile::insert($insert);
+            }
+
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
@@ -261,6 +294,9 @@ class ConstructionService extends Service
             ConstructionInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => time()]);
+            ConstructionFile::where('del_time',0)
+                ->where('construction_id',$data['id'])
+                ->update(['del_time' => $time]);
             ConstructionProductInfo::where('del_time',0)
                 ->where('construction_id',$data['id'])
                 ->update(['del_time' => time()]);
@@ -343,6 +379,19 @@ class ConstructionService extends Service
         }
         $construction = $construction[0];
 
+        $construction['file'] = [];
+        $file = ConstructionFile::where('del_time',0)
+            ->where('construction_id',$construction['id'])
+            ->select('id','construction_id','file','name','mark')
+            ->get()->toArray();
+        foreach ($file as $value){
+            $construction['file'][] = [
+                'url' => $value['file'],
+                'name' => $value['name'],
+                'mark' => $value['mark'],
+            ];
+        }
+
         $construction_info = ConstructionInfo::where('del_time',0)
             ->where('construction_id',$construction['id'])
             ->select('id','construction_id','employee_id','type','contact_type','contact_info')