gogs 2 месяцев назад
Родитель
Сommit
26f0db15a3
3 измененных файлов с 12 добавлено и 10 удалено
  1. 2 2
      app/Service/ExpenseClaimsService.php
  2. 9 7
      app/Service/StatisticService.php
  3. 1 1
      routes/api.php

+ 2 - 2
app/Service/ExpenseClaimsService.php

@@ -90,7 +90,7 @@ class ExpenseClaimsService extends Service
                     'claim_date' => $value['claim_date'],
                     'entrust_type' => $value['entrust_type'],
                     'expense_type' => $value['expense_type'],
-                    'expense_attachments' => $value['expense_attachments'],
+//                    'expense_attachments' => $value['expense_attachments'],
                     'voucher_no' => $data['voucher_no']??"",
                     'file_url' => $data['file_url']??"",
                     'file_name' => $data['file_name']??"",
@@ -117,7 +117,7 @@ class ExpenseClaimsService extends Service
             // 判断:claim_date 必须早于 month
             // 如果 claim_date 是 2026-02-28,而 month 是 2026-03-01,则校验通过
             if ($claimTime < $monthStart || $claimTime > $monthEnd) {
-                return [false, "第" . ($index + 1) . "项报销日期必须早于当前结算月份(" . $data['month'] . ")"];
+                return [false, "第" . ($index + 1) . "项报销日期必须在当前月份内(" . $data['month'] . ")"];
             }
         }
         return [true,""];

+ 9 - 7
app/Service/StatisticService.php

@@ -140,7 +140,7 @@ class StatisticService extends Service
                 $allocated_salary = 0;
             }
             $item_month_list[$item_key]['allocated_salary'] += $allocated_salary;
-            $item_month_list[$item_key]['work_minutes'] += $total_min;
+            $item_month_list[$item_key]['work_minutes'] += $item['total_work'];
         }
 
         foreach ($item_month_list as $k=>$v){
@@ -176,12 +176,12 @@ class StatisticService extends Service
                 // 聚合求和
                 DB::raw("SUM(total_work_min) as total_work")
             )
-            ->groupBy("order_month", "item_id", "employee_id")->toArray();
+            ->groupBy( DB::raw("FROM_UNIXTIME(order_time, '%Y-%m')"), "item_id", "employee_id")->get()->toArray();
         //查询所有人员工资
-        $monthly_ps_order_ids = MonthlyPsOrder::Clear($user, $data)->where('del_time', 0)->where("month", ">=", $month_start)->where("month", "<", $month_end)
-            ->pluck('id')->toArray();
+        $monthly_ps_order_ids = MonthlyPsOrder::Clear($user, $data)->where('del_time', 0)->where("month", ">=", $month_start)->where("month", "<", $month_end)->pluck('id')->toArray();
         $monthly_ps_order_key_list = MonthlyPsOrder::Clear($user, $data)->where('del_time', 0)->where("month", ">=", $month_start)->where("month", "<", $month_end)
-            ->pluck(DB::raw("FROM_UNIXTIME(month, '%Y-%m') as month"), 'id')->toArray();
+            ->select('id', DB::raw("FROM_UNIXTIME(month, '%Y-%m') as month_str"))
+            ->pluck('month_str', 'id')->toArray();
         $month_employee_salary = MonthlyPsOrderDetails::wherein('main_id', $monthly_ps_order_ids)
             ->select("employee_id", "salary", "main_id")
             ->get()->toArray();
@@ -218,6 +218,8 @@ class StatisticService extends Service
                     "work_minutes" => 0,
                     "total_min" => $total_min,
                     "total_salary" => $total_salary,
+                    "item_id" => $item['item_id'],
+                    "employee_id" => $item['employee_id'],
                 ];
             }
 
@@ -231,7 +233,7 @@ class StatisticService extends Service
                 $allocated_salary = 0;
             }
             $item_month_list[$employee_key]['allocated_salary'] += $allocated_salary;
-            $item_month_list[$employee_key]['work_minutes'] += $total_min;
+            $item_month_list[$employee_key]['work_minutes'] += $item['total_work'];
         }
 
         foreach ($item_month_list as $k=>$v){
@@ -250,7 +252,7 @@ class StatisticService extends Service
         $employee_key_list = $employee->wherein('id', $employee_ids)->pluck("title", "id")->toArray();
 
         $item_month_list = collect($item_month_list)->transform(function ($item) use ($item_title_key_list, $item_code_key_list,$employee_key_list) {
-            $item['item_title'] = $item_key_list[$item_title_key_list['item_id']] ?? "未知项目({$item['item_id']})";
+            $item['item_title'] = $item_title_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
             $item['item_code'] = $item_code_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
             $item['employee_title'] = $employee_key_list[$item['employee_id']] ?? "未知人员({$item['employee_id']})";
             return $item;

+ 1 - 1
routes/api.php

@@ -183,7 +183,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
 
 
     //统计类
-    ///人员月度工时统计表(日维度)
+    ///人员工时统计表(日维度)
     $route->any('employeeDayHourStatistic', 'Api\StatisticController@employeeDayHourStatistic');
     ///人员工资统计表(月维度)
     $route->any('employeeMonthSalaryStatistic', 'Api\StatisticController@employeeMonthSalaryStatistic');