|
@@ -140,7 +140,7 @@ class StatisticService extends Service
|
|
|
$allocated_salary = 0;
|
|
$allocated_salary = 0;
|
|
|
}
|
|
}
|
|
|
$item_month_list[$item_key]['allocated_salary'] += $allocated_salary;
|
|
$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){
|
|
foreach ($item_month_list as $k=>$v){
|
|
@@ -176,12 +176,12 @@ class StatisticService extends Service
|
|
|
// 聚合求和
|
|
// 聚合求和
|
|
|
DB::raw("SUM(total_work_min) as total_work")
|
|
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)
|
|
$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)
|
|
$month_employee_salary = MonthlyPsOrderDetails::wherein('main_id', $monthly_ps_order_ids)
|
|
|
->select("employee_id", "salary", "main_id")
|
|
->select("employee_id", "salary", "main_id")
|
|
|
->get()->toArray();
|
|
->get()->toArray();
|
|
@@ -218,6 +218,8 @@ class StatisticService extends Service
|
|
|
"work_minutes" => 0,
|
|
"work_minutes" => 0,
|
|
|
"total_min" => $total_min,
|
|
"total_min" => $total_min,
|
|
|
"total_salary" => $total_salary,
|
|
"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;
|
|
$allocated_salary = 0;
|
|
|
}
|
|
}
|
|
|
$item_month_list[$employee_key]['allocated_salary'] += $allocated_salary;
|
|
$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){
|
|
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();
|
|
$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_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['item_code'] = $item_code_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
|
|
|
$item['employee_title'] = $employee_key_list[$item['employee_id']] ?? "未知人员({$item['employee_id']})";
|
|
$item['employee_title'] = $employee_key_list[$item['employee_id']] ?? "未知人员({$item['employee_id']})";
|
|
|
return $item;
|
|
return $item;
|