EngineerBillLists.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. use app\common\model\master_worker\MasterWorker;
  19. use app\common\model\master_worker\MasterWorkerAccountLog;
  20. use think\facade\Db;
  21. /**
  22. * EngineerSettlement列表
  23. * Class EngineerSettlementLists
  24. * @package app\adminapi\lists
  25. */
  26. class EngineerBillLists extends BaseAdminDataLists implements ListsSearchInterface
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @return \string[][]
  31. * @author likeadmin
  32. * @date 2024/11/15 17:21
  33. */
  34. public function setSearch(): array
  35. {
  36. return [];
  37. }
  38. /**
  39. * @notes 获取列表
  40. * @return array
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\DbException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @author likeadmin
  45. * @date 2024/11/15 17:21
  46. */
  47. public function lists(): array
  48. {
  49. $firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
  50. $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
  51. return Db::name('master_worker')->alias('a')->field([
  52. 'a.id','a.real_name','a.nickname','a.worker_number','e.account_holder','e.bank_name','e.opening_branch','e.account as bank_account',
  53. Db::raw("IFNULL(c.maxid,0) as maxid"),Db::raw("IFNULL(d.left_amount,0) as left_amount")
  54. ])
  55. ->leftJoin([Db::name('master_worker_account_log')
  56. ->where('create_time','between',[strtotime($firstDay),strtotime($lastDay)])
  57. ->field('worker_id as master_worker_id, max(id) as maxid')
  58. ->group('worker_id')
  59. ->buildSql() => 'c'], 'a.id = c.master_worker_id')
  60. ->leftJoin('master_worker_account_log d', 'c.maxid = d.id')
  61. ->leftJoin('bank_account e', 'a.id = e.worker_id')
  62. //->where('d.left_amount', '>', 0)
  63. ->select()->toArray();
  64. }
  65. /**
  66. * @notes 获取数量
  67. * @return int
  68. * @author likeadmin
  69. * @date 2024/11/15 17:21
  70. */
  71. public function count(): int
  72. {
  73. $firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
  74. $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
  75. return Db::name('master_worker')->alias('a')->field([
  76. 'a.id','a.real_name','a.nickname','a.worker_number',Db::raw("IFNULL(c.maxid,0) as maxid"),Db::raw("IFNULL(d.left_amount,0) as left_amount")
  77. ])
  78. ->leftJoin([Db::name('master_worker_account_log')
  79. ->where('create_time','between',[strtotime($firstDay),strtotime($lastDay)])
  80. ->field('worker_id as master_worker_id, max(id) as maxid')
  81. ->group('worker_id')
  82. ->buildSql() => 'c'], 'a.id = c.master_worker_id')
  83. ->leftJoin('master_worker_account_log d', 'c.maxid = d.id')
  84. //->where('d.left_amount', '>', 0)
  85. ->count();
  86. }
  87. }