|
|
@@ -83,6 +83,54 @@ class AuxiliaryAccountService extends Service
|
|
|
}
|
|
|
|
|
|
private function employeeMonthAmount($month,$user,$monthStart,$monthEnd){
|
|
|
+ $data['top_depart_id'] = $user['top_depart_id'];
|
|
|
+ $month_ps_order = MonthlyPsOrder::Clear($user,$data);
|
|
|
+ $month_ps_order_id = $month_ps_order->where('del_time',0)->where("month",$monthStart)->first();
|
|
|
+ if(empty($month_ps_order_id)){
|
|
|
+ return [false,"请补充对应月份人员月度工资信息"];
|
|
|
+ }else{
|
|
|
+ $month_ps_order_id = $month_ps_order_id->id;
|
|
|
+ }
|
|
|
+ $model = MonthlyPsOrderDetails::Clear($user,$data);
|
|
|
+ $totals = $model->where('main_id', $month_ps_order_id)
|
|
|
+ ->where('del_time', 0)
|
|
|
+ ->selectRaw('
|
|
|
+ employee_id,
|
|
|
+ SUM(
|
|
|
+ IFNULL(base_salary, 0) +
|
|
|
+ IFNULL(other, 0) +
|
|
|
+ IFNULL(performance_salary, 0) +
|
|
|
+ IFNULL(bonus, 0)
|
|
|
+ ) as total
|
|
|
+ ')
|
|
|
+ ->groupBy('employee_id')
|
|
|
+ ->pluck('total' , 'employee_id')
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $entrust_type_map = Employee::whereIn('id', array_keys($totals))
|
|
|
+ ->pluck('entrust_type', 'id')
|
|
|
+ ->toArray();
|
|
|
+ $total_amount = $entrust_in_amount = $entrust_out_amount = 0;
|
|
|
+ foreach ($totals as $employee_id => $amount){
|
|
|
+ $total_amount = bcadd($amount, $total_amount, 2);
|
|
|
+ if(! empty($entrust_type_map[$employee_id])){
|
|
|
+ $tmp = $entrust_type_map[$employee_id];
|
|
|
+ if($tmp == Employee::WT_TYPE_ONE){
|
|
|
+ $entrust_in_amount = bcadd($amount, $entrust_in_amount, 2);
|
|
|
+ }elseif($tmp == Employee::WT_TYPE_TWO){
|
|
|
+ $entrust_out_amount = bcadd($amount, $entrust_out_amount, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true,[
|
|
|
+ "total_amount" => $total_amount,
|
|
|
+ "entrust_in_amount" => $entrust_in_amount,
|
|
|
+ "entrust_out_amount" => $entrust_out_amount,
|
|
|
+ ]];
|
|
|
+ }
|
|
|
+
|
|
|
+ private function employeeMonthAmount1($month,$user,$monthStart,$monthEnd){
|
|
|
$data['top_depart_id'] = $user['top_depart_id'];
|
|
|
$month_ps_order = MonthlyPsOrder::Clear($user,$data);
|
|
|
$month_ps_order_id = $month_ps_order->where('del_time',0)->where("month",$monthStart)->first();
|