Browse Source

月份员工工资查询

unknown 2 weeks ago
parent
commit
f06f459dd1
1 changed files with 40 additions and 0 deletions
  1. 40 0
      application/api/controller/StaffSalary.php

+ 40 - 0
application/api/controller/StaffSalary.php

@@ -149,4 +149,44 @@ class StaffSalary extends Api
         }
         $this->success('成功', $list);
     }
+
+
+    /**
+     * 查询月份员工工资数据
+     * @ApiMethod (GET)
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function GetStaffSalaryMonth()
+    {
+        if (!$this->request->isGet()){
+            $this->error('请求方法错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['month'])) {
+            $this->error('请选择月份');
+        }
+        $where = [
+            'date' => ['like', $param['month'] . '%'],
+            'del_rq' => null,
+        ];
+        if (!empty($param['search'])) {
+            $where['staff_no|staff_name'] = ['like', '%' . $param['search'] . '%'];
+        }
+        $list = db('设备_工分计酬')
+            ->where($where)
+            ->field('staff_no,staff_name,sum(salary) as salary')
+            ->group('staff_no,staff_name')
+            ->field('staff_no,staff_name,DATE_FORMAT(date, "%Y-%m-%d") as date,sum(salary) as salary')
+            ->group('staff_no,DATE_FORMAT(date, "%Y-%m-%d")')
+            ->order('staff_no asc,date asc')
+            ->select();
+        if(empty($list)){
+            $this->error('没有数据');
+        }   
+        $this->success('成功', $list);
+    }
+
 }