EngineerSettlementLists.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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\adminapi\lists\master_worker;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\master_worker\EngineerSettlement;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * EngineerSettlement列表
  20. * Class EngineerSettlementLists
  21. * @package app\adminapi\lists
  22. */
  23. class EngineerSettlementLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2024/11/15 17:21
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['batch_number','master_worker_id', 'worker_number', 'engineer_name', 'original_balance', 'total_settlement_amount', 'deduction_amount', 'final_settlement_amount', 'settlement_details_remarks'],
  35. ];
  36. }
  37. public function queryWhere()
  38. {
  39. $where = [];
  40. if(isset($this->params['settlement_time']) && $this->params['settlement_time']){
  41. $where[] = ['settlement_time','=',date('Y-m-d H:i:s',strtotime($this->params['settlement_time']))];
  42. }
  43. if(isset($this->params['create_time']) && $this->params['create_time']){
  44. $startDateTime = strtotime($this->params['create_time']);
  45. $endDateTime = strtotime('+1 day', $startDateTime)-1;
  46. $where[] = ['create_time','BETWEEN',[$startDateTime,$endDateTime]];
  47. }
  48. return $where;
  49. }
  50. /**
  51. * @notes 获取列表
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @author likeadmin
  57. * @date 2024/11/15 17:21
  58. */
  59. public function lists(): array
  60. {
  61. return EngineerSettlement::where('is_export',2)->where($this->queryWhere())->where($this->searchWhere)
  62. ->field(['id', 'master_worker_id', 'worker_number', 'engineer_name', 'original_balance', 'total_settlement_amount', 'deduction_amount','deduction_describe', 'final_settlement_amount', 'settlement_time', 'settlement_details_remarks','batch_number'])
  63. ->limit($this->limitOffset, $this->limitLength)
  64. ->order(['id' => 'desc'])
  65. ->select()
  66. ->toArray();
  67. }
  68. /**
  69. * @notes 获取数量
  70. * @return int
  71. * @author likeadmin
  72. * @date 2024/11/15 17:21
  73. */
  74. public function count(): int
  75. {
  76. return EngineerSettlement::where($this->searchWhere)->where($this->queryWhere())->count();
  77. }
  78. }