PropertyOrderAnalysis.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\property;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\property\PropertyHead;
  17. use app\common\model\property\PropertyOrder;
  18. use app\common\lists\ListsSearchInterface;
  19. use app\common\model\property\PropertyUser;
  20. use app\common\model\works\ServiceWork;
  21. use think\facade\Db;
  22. /**
  23. * PropertyOrderAnalysis列表
  24. * Class PropertyOrderAnalysis
  25. * @package app\adminapi\lists
  26. */
  27. class PropertyOrderAnalysis extends BaseAdminDataLists implements ListsSearchInterface
  28. {
  29. /**
  30. * @notes 设置搜索条件
  31. * @return \string[][]
  32. * @author likeadmin
  33. * @date 2024/09/19 14:48
  34. */
  35. public function setSearch(): array
  36. {
  37. return [
  38. ];
  39. }
  40. public function queryWhere()
  41. {
  42. $where = [];
  43. return $where;
  44. }
  45. /**
  46. * @notes 获取列表
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @author likeadmin
  52. * @date 2024/09/19 14:48
  53. */
  54. public function lists(): array
  55. {
  56. $workIds = PropertyOrder::where('order_status',3)->column('work_id');
  57. if(empty($workIds)){
  58. return [];
  59. }
  60. $startDateTime = strtotime(date('Y-m-01'));
  61. if(isset($this->params['start_month']) && $this->params['start_month']){
  62. $startDateTime = strtotime($this->params['start_month']);
  63. }
  64. $endDateTime = strtotime('+1 month', strtotime($startDateTime))-1;
  65. // with(['propertyHead'])->
  66. $serviceWork = ServiceWork::with(['propertyHead'])->where([['id','in',$workIds],['work_pay_status','=',2],['approval','=',1]])
  67. //->where('finished_time','BETWEEN',[$startDateTime,$endDateTime])
  68. ->where('finished_time','>',0)
  69. ->where('user_id','>',0)
  70. ->field(Db::raw('user_id,DATE_FORMAT(FROM_UNIXTIME(finished_time), "%Y-%m") AS month_format,COUNT(id) as month_num, SUM(work_amount) as month_amount'))
  71. ->group('user_id,month_format')
  72. ->select()->toArray();
  73. return $serviceWork;
  74. }
  75. /**
  76. * @notes 获取数量
  77. * @return int
  78. * @author likeadmin
  79. * @date 2024/09/19 14:48
  80. */
  81. public function count(): int
  82. {
  83. return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->count();
  84. }
  85. }