SaleGroupAnalysisLists.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 SaleGroupAnalysisLists 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('sale_group c', 'a.sale_group_id = c.id')
  52. ->field([
  53. 'a.sale_group_id','c.sale_name',
  54. Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
  55. ])
  56. ->where('a.sale_type', 'in', [1, 2])
  57. ->where('a.order_status', 3)
  58. ->group('a.sale_group_id')
  59. ->limit($this->limitOffset, $this->limitLength)
  60. ->select()->toArray();
  61. }
  62. /**
  63. * @notes 获取数量
  64. * @return int
  65. * @author likeadmin
  66. * @date 2024/12/15 10:53
  67. */
  68. public function count(): int
  69. {
  70. return Db::name('property_order')->alias('a')
  71. ->leftJoin('service_work b', 'a.work_id = b.id')
  72. ->leftJoin('sale c', 'a.sale_id = c.id')
  73. ->field([
  74. 'a.sale_group_id','c.sale_name','c.mobile',
  75. Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
  76. ])
  77. ->where('a.sale_type', 'in', [1, 2])
  78. ->where('a.order_status', 3)
  79. ->group('a.sale_group_id')
  80. ->count();
  81. }
  82. }