1
0

PropertyHeadAnalysisLists.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\sale;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\sale\Sale;
  17. use app\common\lists\ListsSearchInterface;
  18. use think\facade\Db;
  19. /**
  20. * Sale列表
  21. * Class SaleLists
  22. * @package app\adminapi\lists
  23. */
  24. class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearchInterface
  25. {
  26. /**
  27. * @notes 设置搜索条件
  28. * @return \string[][]
  29. * @author likeadmin
  30. * @date 2024/12/15 10:53
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '=' => ['sale_group_id', 'sale_name', 'mobile'],
  36. ];
  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/12/15 10:53
  46. */
  47. public function lists(): array
  48. {
  49. return Db::name('property_order')->alias('a')
  50. ->leftJoin('service_work b', 'a.work_id = b.id')
  51. ->leftJoin('property_head c', 'a.property_head_id = c.id')
  52. ->leftJoin('sale d', 'a.sale_id = d.id')
  53. ->field([
  54. 'a.property_head_id','c.property_name','c.village_name','c.address','c.head_name','c.head_mobile','d.sale_name',
  55. Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
  56. ])
  57. ->where('a.sale_type', 'in', [1, 2])
  58. ->where('a.order_status', 3)
  59. ->group('a.property_head_id')
  60. ->limit($this->limitOffset, $this->limitLength)
  61. ->select()->toArray();
  62. }
  63. /**
  64. * @notes 获取数量
  65. * @return int
  66. * @author likeadmin
  67. * @date 2024/12/15 10:53
  68. */
  69. public function count(): int
  70. {
  71. return Db::name('property_order')->alias('a')
  72. ->leftJoin('service_work b', 'a.work_id = b.id')
  73. ->leftJoin('sale c', 'a.sale_id = c.id')
  74. ->field([
  75. 'a.property_head_id','c.sale_name','c.mobile',
  76. Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
  77. ])
  78. ->where('a.sale_type', 'in', [1, 2])
  79. ->where('a.order_status', 3)
  80. ->group('a.property_head_id')
  81. ->count();
  82. }
  83. }