MasterWorkerRetentionMoneyLogLists.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @author 林海涛
  4. * @date 2024/7/28 上午11:30
  5. */
  6. namespace app\workerapi\lists;
  7. use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
  8. class MasterWorkerRetentionMoneyLogLists extends BaseWorkerDataLists
  9. {
  10. public function queryWhere()
  11. {
  12. $where = [];
  13. if(isset($this->params['worker_id'])){
  14. $where[]= ['worker_id','=',$this->params['worker_id']];
  15. } else{
  16. $where[]= ['worker_id','=',$this->userId];
  17. }
  18. if(isset($this->params['create_time']) && !empty($this->params['create_time'])){
  19. $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
  20. $where[] = ['create_time', 'between', $time];
  21. }
  22. if(isset($this->params['month']) && !empty($this->params['month'])){
  23. $firstDay =date("Y-m-d 00:00:00", strtotime("first day of {$this->params['month']}"));
  24. $lastDay = date("Y-m-d 23:59:59", strtotime("{$this->params['month']} +1 month -1 day"));
  25. $firstTime = strtotime($firstDay);
  26. $lastTime = strtotime($lastDay);
  27. $where[] = ['create_time','between',[$firstTime,$lastTime]];
  28. }
  29. return $where;
  30. }
  31. public function lists(): array
  32. {
  33. $lists = MasterWorkerRetentionMoneyLog::where($this->searchWhere)
  34. ->where($this->queryWhere())
  35. ->append(['action_text'])
  36. ->field(['id', 'sn','action','amount','remark','work_id','create_time','update_time'])
  37. ->order(['id' => 'desc'])
  38. ->select()
  39. ->toArray();
  40. foreach ($lists as &$item) {
  41. $item['amount'] = $item['action_text'] . $item['amount'];
  42. }
  43. return $lists;
  44. }
  45. public function count(): int
  46. {
  47. return MasterWorkerRetentionMoneyLog::where($this->queryWhere())->count();
  48. }
  49. }