gogs 1 месяц назад
Родитель
Сommit
3999c03e35
1 измененных файлов с 30 добавлено и 23 удалено
  1. 30 23
      app/Service/StatisticService.php

+ 30 - 23
app/Service/StatisticService.php

@@ -715,19 +715,23 @@ class StatisticService extends StatisticCommonService
         })->map(function ($group) {
             return $group->count();
         })->toArray();
-        $month_employee_list = $collect->transform(function ($item) use (&$employee_count,&$salary_map) {
+        $sums = [
+            "salary_map" => $salary_map
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_salary",
+                "value" => "allocated_salary",
+                "type" => "money",
+            ]
+        ];
+        $employee_count = [
+            'salary_map' => $employee_count
+        ];
+        $month_employee_list = $collect->transform(function ($item) use (&$employee_count,&$sums,$word_keys) {
             // 如果不是最后一条
             $key = $item['employee_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $salary_map
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_salary",
-                    "value" => "allocated_salary",
-                    "type" => "money",
-                ]
-            ];
+
             $this->calculateClosure($key,$item,$employee_count,$sums,$word_keys);
             return $item;
         })->all();
@@ -760,20 +764,23 @@ class StatisticService extends StatisticCommonService
         })->map(function ($group) {
             return $group->count();
         })->toArray();
-
-        $month_employee_list = $collect->transform(function ($item) use (&$device_count,&$depreciation_map) {
+        $sums = [
+            "salary_map" => $depreciation_map
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_depreciation",
+                "value" => "depreciation",
+                "type" => "money",
+            ]
+        ];
+        $device_count = [
+            'salary_map' => $device_count
+        ];
+        $month_employee_list = $collect->transform(function ($item) use (&$device_count,&$sums,$word_keys) {
 
             $key = $item['device_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $depreciation_map
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_depreciation",
-                    "value" => "depreciation",
-                    "type" => "money",
-                ]
-            ];
+
             $this->calculateClosure($key,$item,$device_count,$sums,$word_keys);
             return $item;
         })->all();