| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\adminapi\lists\sale;
- use app\adminapi\lists\BaseAdminDataLists;
- use app\common\model\sale\Sale;
- use app\common\lists\ListsSearchInterface;
- use think\facade\Db;
- /**
- * Sale列表
- * Class SaleLists
- * @package app\adminapi\lists
- */
- class SaleGroupAnalysisLists extends BaseAdminDataLists implements ListsSearchInterface
- {
- /**
- * @notes 设置搜索条件
- * @return \string[][]
- * @author likeadmin
- * @date 2024/12/15 10:53
- */
- public function setSearch(): array
- {
- return [
- '=' => ['sale_group_id', 'property_head_id','sale_type', 'sale_id'],
- ];
- }
- public function queryWhere()
- {
- $where = [];
- if(isset($this->params['time_range']) && $this->params['time_range']){
- $startDateTime = strtotime($this->params['time_range'][0]);
- $endDateTime = strtotime($this->params['time_range'][1])+86400-1;
- $where[] = ['b.finished_time','BETWEEN',[$startDateTime,$endDateTime]];
- }
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/12/15 10:53
- */
- public function lists(): array
- {
- return Db::name('property_order')->alias('a')
- ->leftJoin('service_work b', 'a.work_id = b.id')
- ->leftJoin('sale_group c', 'a.sale_group_id = c.id')
- ->field([
- 'a.sale_group_id','c.sale_name',
- Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
- ])
- ->where('a.sale_type', 'in', [1, 2])
- //->where('a.order_status', 3)
- ->where('b.service_status', 3)
- ->group('a.sale_group_id')
- ->limit($this->limitOffset, $this->limitLength)
- ->select()->toArray();
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/12/15 10:53
- */
- public function count(): int
- {
- return Db::name('property_order')->alias('a')
- ->leftJoin('service_work b', 'a.work_id = b.id')
- ->leftJoin('sale c', 'a.sale_id = c.id')
- ->field([
- 'a.sale_group_id','c.sale_name','c.mobile',
- Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
- ])
- ->where('a.sale_type', 'in', [1, 2])
- ->where('a.order_status', 3)
- ->group('a.sale_group_id')
- ->count();
- }
- }
|