MasterWorkerCaseOutLogLists.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\tenantapi\lists\finance;
  15. use app\common\model\master_worker\MasterWorker;
  16. use app\tenantapi\lists\BaseAdminDataLists;
  17. use app\common\model\finance\MasterWorkerCaseOutLog;
  18. use app\common\lists\ListsSearchInterface;
  19. use think\db\Query;
  20. /**
  21. * MasterWorkerCaseOutLog列表
  22. * Class MasterWorkerCaseOutLogLists
  23. * @package app\tenantapi\listsfinance
  24. */
  25. class MasterWorkerCaseOutLogLists extends BaseAdminDataLists implements ListsSearchInterface
  26. {
  27. /**
  28. * @notes 设置搜索条件
  29. * @return \string[][]
  30. * @author likeadmin
  31. * @date 2024/07/23 09:30
  32. */
  33. public function setSearch(): array
  34. {
  35. return [
  36. '=' => ['sn', 'worker_id', 'review_status'],
  37. '%like%' => ['sn'],
  38. ];
  39. }
  40. public function querySearch():array
  41. {
  42. $data = [];
  43. if(isset($this->params['min_change_amount']) && is_numeric($this->params['min_change_amount'])){
  44. $where[] =['change_amount','>=',$this->params['min_change_amount']];
  45. }
  46. if(isset($this->params['max_change_amount']) && is_numeric($this->params['max_change_amount'])){
  47. $where[] =['change_amount','<=',$this->params['max_change_amount']];
  48. }
  49. return $data;
  50. }
  51. /**
  52. * @notes 获取列表
  53. * @return array
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\DbException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. * @author likeadmin
  58. * @date 2024/07/23 09:30
  59. */
  60. public function lists(): array
  61. {
  62. $ids = MasterWorker::where('tenant_id',$this->adminInfo['tenant_id'])->column('id')??[0];
  63. return MasterWorkerCaseOutLog::where($this->searchWhere)
  64. ->with(['masterWorker'=>function(Query $query){
  65. $query->field('id,nickname,worker_number');
  66. }])
  67. ->whereIn('worker_id',$ids)
  68. ->where($this->querySearch())
  69. ->field(['id', 'sn', 'worker_id', 'change_amount', 'review_status', 'remark'])
  70. ->limit($this->limitOffset, $this->limitLength)
  71. ->order(['id' => 'desc'])
  72. ->select()
  73. ->toArray();
  74. }
  75. /**
  76. * @notes 获取数量
  77. * @return int
  78. * @author likeadmin
  79. * @date 2024/07/23 09:30
  80. */
  81. public function count(): int
  82. {
  83. $ids = MasterWorker::where('tenant_id',$this->adminInfo['tenant_id'])->column('id')??[0];
  84. return MasterWorkerCaseOutLog::where($this->searchWhere)->whereIn('worker_id',$ids)->where($this->querySearch())->count();
  85. }
  86. }