cqp 2 сар өмнө
parent
commit
5808eb700f

+ 1 - 1
app/Http/Controllers/Api/PersonSalaryController.php

@@ -38,7 +38,7 @@ class PersonSalaryController extends BaseController
     {
         $service = new PersonSalaryService();
         $user = $request->userData;
-        list($status,$data) = $service->monthlyPsOrderDel($request->all());
+        list($status,$data) = $service->monthlyPsOrderDel($request->all(), $user);
 
         if($status){
             return $this->json_return(200,'',$data);

+ 15 - 1
app/Service/PersonSalaryService.php

@@ -113,13 +113,22 @@ class PersonSalaryService extends Service
         return $detail;
     }
 
-    public function MonthlyPsOrderDel($data){
+    public function MonthlyPsOrderDel($data, $user){
         if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
 
         try {
             DB::beginTransaction();
             $time = time();
 
+            $month = MonthlyPsOrder::where('del_time',0)
+                ->whereIn('id',$data['id'])
+                ->pluck('month')
+                ->toArray();
+
+            //归档
+            list($status, $msg) = ArchiveService::isArchive($month, $user);
+            if(! $status) return [false, $msg];
+
             MonthlyPsOrder::where('del_time',0)
                 ->whereIn('id',$data['id'])
                 ->update(['del_time' => $time]);
@@ -191,6 +200,11 @@ class PersonSalaryService extends Service
         $data['month'] = $this->changeDateToDate($data['month']);
 
         $data['top_depart_id'] = $user['top_depart_id'];
+
+        //归档
+        list($status, $msg) = ArchiveService::isArchive($data['month'], $user);
+        if(! $status) return [false, $msg];
+
         if(empty($data['details'])) return [false, '人员月度工时单明细不能为空'];
         foreach ($data['details'] as $key => $value){
             if(empty($value['employee_id'])) return [false, '人员不能为空'];