liugc 1 rok temu
rodzic
commit
d94234ed4a

+ 8 - 0
app/adminapi/controller/sale/SaleAnalysisController.php

@@ -21,6 +21,7 @@ use app\adminapi\lists\sale\PropertyHeadAnalysisLists;
 use app\adminapi\lists\sale\SaleAnalysisLists;
 use app\adminapi\lists\sale\SaleGroupAnalysisLists;
 use app\adminapi\lists\sale\SaleLists;
+use app\adminapi\lists\sale\SalePerformanceLists;
 use app\adminapi\logic\sale\SaleLogic;
 use app\adminapi\validate\sale\SaleValidate;
 
@@ -33,6 +34,7 @@ use app\adminapi\validate\sale\SaleValidate;
 class SaleAnalysisController extends BaseAdminController
 {
 
+    public array $notNeedLogin = ['performanceLists'];
 
     /**
      * @notes 获取列表
@@ -55,4 +57,10 @@ class SaleAnalysisController extends BaseAdminController
     {
         return $this->dataLists(new PropertyHeadAnalysisLists());
     }
+
+    public function performanceLists()
+    {
+        return $this->dataLists(new SalePerformanceLists());
+    }
+
 }

+ 138 - 0
app/adminapi/lists/sale/SalePerformanceLists.php

@@ -0,0 +1,138 @@
+<?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;
+
+
+/**
+ * SalePerformanceLists列表
+ * Class SalePerformanceLists
+ * @package app\adminapi\lists
+ */
+class SalePerformanceLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    public $count = 0;
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/12/15 10:53
+     */
+    public function setSearch(): array
+    {
+        return [];
+    }
+
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['time_range']) && $this->params['time_range']){
+
+        }
+        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
+    {
+        $directWorkerCountSub = Db::table('la_master_worker_register')
+            ->field(['sale_id', Db::raw('COUNT(DISTINCT worker_id) AS direct_worker_count')])
+            ->where('worker_id', '>', 0)
+            ->where('sale_id', '>', 0)
+            ->group('sale_id')
+            ->buildSql();
+        $tenantWorkerCountSub = Db::table('la_tenant_register')
+            ->alias('lr')
+            ->leftJoin('la_master_worker mw', 'lr.tenant_id = mw.tenant_id')
+            ->field(['lr.sale_id', Db::raw('COUNT(DISTINCT mw.id) AS tenant_worker_count')])
+            ->where('lr.tenant_id', '>', 0)
+            ->group('lr.sale_id')
+            ->buildSql();
+        return Db::table('la_sale')
+            ->alias('s')
+            ->leftJoin([$directWorkerCountSub => 'dwc'], 's.id = dwc.sale_id')
+            ->leftJoin([$tenantWorkerCountSub => 'twc'], 's.id = twc.sale_id')
+            ->field([
+                's.id',
+                's.sale_name',
+                Db::raw('COALESCE(dwc.direct_worker_count, 0) AS direct_worker_count'),
+                Db::raw('COALESCE(twc.tenant_worker_count, 0) AS tenant_worker_count'),
+                Db::raw('COALESCE(dwc.direct_worker_count, 0) + COALESCE(twc.tenant_worker_count, 0) AS total_worker_count')
+            ])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/12/15 10:53
+     */
+    public function count(): int
+    {
+        $directWorkerCountSub = Db::table('la_master_worker_register')
+            ->field(['sale_id', Db::raw('COUNT(DISTINCT worker_id) AS direct_worker_count')])
+            ->where('worker_id', '>', 0)
+            ->where('sale_id', '>', 0)
+            ->group('sale_id')
+            ->buildSql();
+        $tenantWorkerCountSub = Db::table('la_tenant_register')
+            ->alias('lr')
+            ->leftJoin('la_master_worker mw', 'lr.tenant_id = mw.tenant_id')
+            ->field(['lr.sale_id', Db::raw('COUNT(DISTINCT mw.id) AS tenant_worker_count')])
+            ->where('lr.tenant_id', '>', 0)
+            ->group('lr.sale_id')
+            ->buildSql();
+        return Db::table('la_sale')
+            ->alias('s')
+            ->leftJoin([$directWorkerCountSub => 'dwc'], 's.id = dwc.sale_id')
+            ->leftJoin([$tenantWorkerCountSub => 'twc'], 's.id = twc.sale_id')
+            ->field([
+                's.id',
+                's.sale_name',
+                Db::raw('COALESCE(dwc.direct_worker_count, 0) AS direct_worker_count'),
+                Db::raw('COALESCE(twc.tenant_worker_count, 0) AS tenant_worker_count'),
+                Db::raw('COALESCE(dwc.direct_worker_count, 0) + COALESCE(twc.tenant_worker_count, 0) AS total_worker_count')
+            ])
+            ->count();
+    }
+
+    public function setExcelComplexFields(): array
+    {
+        $zh_cn_fields = [];
+        $data_fields = [];
+        return [
+            'zh_cn_fields' => $zh_cn_fields,
+            'data_fields' => $data_fields
+        ];
+    }
+}