AttendanceRecord.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class AttendanceRecord extends Base
  7. {
  8. // 列表
  9. public function list(){
  10. $page = input('page/d',1);
  11. $size = input('size/d',10);
  12. $name = input('name','','trim');
  13. $startTime = input('startTime','','trim');
  14. $endTime = input('endTime','','trim');
  15. $ret = model('AttendanceRecord')->lists($page,$size,$name,$startTime,$endTime,$this->orgId);
  16. HelpHander::success($ret);
  17. }
  18. // 手机打卡
  19. public function save(){
  20. model('AttendanceRecord')->sjsign();
  21. HelpHander::success([],'操作成功');
  22. }
  23. // 绑定设备
  24. public function bundleDevice(){
  25. $deviceSn = input('deviceSn','','trim');
  26. model('AttendanceRecord')->bundleDevice($this->userId,$deviceSn);
  27. HelpHander::success([],'操作成功');
  28. }
  29. // 解绑设备
  30. public function unBundleDevice(){
  31. $uId = input('uId/d',0);
  32. model('AttendanceRecord')->unBundleDevice($uId);
  33. HelpHander::success([],'操作成功');
  34. }
  35. public function listByStaffId(){
  36. $page = input('page/d',1);
  37. $size = input('size/d',10);
  38. $startTime = input('startTime','','trim');
  39. $endTime = input('endTime','','trim');
  40. $uid = input('staffId/d',0);
  41. $ret = model('AttendanceRecord')->listByStaffId($page,$size,$this->orgId,$uid,$startTime,$endTime);
  42. HelpHander::success($ret);
  43. }
  44. public function attendanceStatistics(){
  45. $month = input('month','','trim');
  46. $page = input('page/d',1);
  47. $size = input('size/d',10);
  48. $userName = input('userName','','trim');
  49. $ret = model('AttendanceRecordResult')->attendanceStatistics($month,$page,$size,$this->orgId,$userName);
  50. HelpHander::success($ret);
  51. }
  52. public function changeAttendance(){
  53. $data = [
  54. "type" => input('type/d',1),
  55. "time" => input('time','',''),
  56. "min" => input('min/d',0),
  57. "id" => input('id/d',0),
  58. "cate" => input('cate/d',0),
  59. "status" => input('status/d',0)
  60. ];
  61. if($data['type'] == 2&&$data['min'] <= 0){
  62. HelpHander::error('分钟数不能为0');
  63. }
  64. if(!$data['time']){
  65. HelpHander::error('参数错误');
  66. }
  67. model('AttendanceUserClass')->changeAttendance($data,$this->orgId);
  68. HelpHander::success([],'操作成功');
  69. }
  70. //考勤报表导出
  71. public function attendanceExport(){
  72. $month = input('month','','trim');
  73. $userName = input('userName','','trim');
  74. $ret = model('AttendanceRecordResult')->attendanceExport($month,$this->orgId,$userName);
  75. HelpHander::success($ret);
  76. }
  77. }