unknown před 2 týdny
rodič
revize
2348b808f7
1 změnil soubory, kde provedl 14 přidání a 3 odebrání
  1. 14 3
      application/api/controller/StaffSalary.php

+ 14 - 3
application/api/controller/StaffSalary.php

@@ -51,6 +51,11 @@ class StaffSalary extends Api
 
     /**
      * 查询员工工资列表
+     * @ApiMethod (GET)
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
      */
     public function GetStaffSalaryList()
     {
@@ -66,9 +71,13 @@ class StaffSalary extends Api
         }
         //获取大工序员工列表
         $staff = db('人员_基本资料')
-            ->where('big_process',$param['big_process'])
-            ->where('status',1)
-            ->field('staff_no,staff_name')
+            ->alias('a')
+            ->join('设备_工分计酬 b','a.staff_no = b.staff_no','left')
+            ->where('a.big_process',$param['big_process'])
+            ->where('a.status',1)
+            ->where('b.date', 'like', $param['month'] . '%')
+            ->field('a.staff_no,a.staff_name,sum(b.salary) as salary')
+            ->group('a.staff_no,a.staff_name')
             ->select();
         if(empty($staff)){
             $this->error('该部门没有员工');
@@ -97,6 +106,7 @@ class StaffSalary extends Api
                 $name = !empty($row['staff_name']) ? $row['staff_name'] : (isset($staffMap[$staffNo]) ? $staffMap[$staffNo] : '');
                 $grouped[$staffNo] = [
                     'staff' => $staffNo . '-' . $name,
+                    'total_salary' => 0,
                     'children' => [],
                 ];
             }
@@ -106,6 +116,7 @@ class StaffSalary extends Api
                 '日期' => $row['date'],
                 '工资' => $row['salary'],
             ];
+            $grouped[$staffNo]['total_salary'] += $row['salary'];
         }
 
         $this->success('成功', array_values($grouped));