MasterWorkerAccountLogLists.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\enum\worker\WorkerAccountLogEnum;
  4. use app\common\model\master_worker\MasterWorkerAccountLog;
  5. /**
  6. * @author 林海涛
  7. * @date 2024/7/23 下午2:16
  8. */
  9. class MasterWorkerAccountLogLists extends BaseWorkerDataLists
  10. {
  11. public function queryWhere()
  12. {
  13. $where = [];
  14. if(isset($this->params['month'])){
  15. $firstDay =date("Y-m-d 00:00:00", strtotime("first day of {$this->params['month']}"));
  16. $lastDay = date("Y-m-d 23:59:59", strtotime("{$this->params['month']} +1 month -1 day"));
  17. $firstTime = strtotime($firstDay);
  18. $lastTime = strtotime($lastDay);
  19. $where[] = ['create_time','between',[$firstTime,$lastTime]];
  20. }
  21. $where[] = ['worker_id', '=', $this->userId];
  22. if(isset($this->params['change_types']) && is_array($this->params['change_types'])){
  23. $where[] = ['change_type','in',$this->params['change_types']];
  24. }
  25. return $where;
  26. }
  27. public function lists():array
  28. {
  29. return MasterWorkerAccountLog::where($this->queryWhere())
  30. ->field('sn,title,change_type,action,work_sn,change_amount,create_time')
  31. ->order(['id' => 'dasc'])
  32. ->append(['action_text'])
  33. ->limit($this->limitOffset, $this->limitLength)
  34. ->select()
  35. ->toArray();
  36. }
  37. public function count(): int
  38. {
  39. return MasterWorkerAccountLog::where($this->queryWhere())->count();
  40. }
  41. }