Explorar el Código

Merge remote-tracking branch 'origin/master'

cqp hace 2 meses
padre
commit
1d24419897
Se han modificado 1 ficheros con 19 adiciones y 8 borrados
  1. 19 8
      app/Service/StatisticService.php

+ 19 - 8
app/Service/StatisticService.php

@@ -700,12 +700,17 @@ class StatisticService extends Service
         $month_employee_list = $collect->transform(function ($item, $index) use (&$employee_count,&$all_salary) {
 
             // 如果不是最后一条
+
             $key = $item['employee_id'] . '_' . $item['month'];
-            if (--$employee_count[$key] > 0) {
-                $all_salary[$key] -= $item['allocated_salary'];
-            } else {
-                $item['allocated_salary'] = $all_salary[$key];
+            if(!isset($all_salary[$key])) $item['allocated_salary'] = 0;
+            else{
+                if (--$employee_count[$key] > 0) {
+                    $all_salary[$key] -= $item['allocated_salary'];
+                } else {
+                    $item['allocated_salary'] = $all_salary[$key];
+                }
             }
+
             return $item;
         })->all();
         $return_item_list = [];
@@ -967,7 +972,9 @@ class StatisticService extends Service
         foreach ($fee_amount as $v) {
             //人工费用
             if ($v['type'] == 1 || $v['type'] == 2) {
+//                var_dump();
                 foreach ($item_key_list as $vv) {
+                    if(!isset($item_salary[$vv['id'] . "_" . date("Y-m", $v['voucher_date'])]['allocated_salary'])) continue;
                     $detail = [
                         "code" => $vv['code'],
                         "title" => $vv['title'],
@@ -1170,11 +1177,15 @@ class StatisticService extends Service
 
             // 如果不是最后一条
             $key = $item['employee_id'] . '_' . $item['month'];
-            if (--$employee_count[$key] > 0) {
-                $all_salary[$key] -= $item['allocated_salary'];
-            } else {
-                $item['allocated_salary'] = $all_salary[$key];
+            if(!isset($all_salary[$key]))  $item['allocated_salary'] = 0;
+            else {
+                if (--$employee_count[$key] > 0) {
+                    $all_salary[$key] -= $item['allocated_salary'];
+                } else {
+                    $item['allocated_salary'] = $all_salary[$key];
+                }
             }
+
             return $item;
         })->all();
         $return_item_list = [];