فهرست منبع

销售与统计

liugc 1 سال پیش
والد
کامیت
6b31dd570e

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

@@ -0,0 +1,58 @@
+<?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\controller\sale;
+
+
+use app\adminapi\controller\BaseAdminController;
+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\logic\sale\SaleLogic;
+use app\adminapi\validate\sale\SaleValidate;
+
+
+/**
+ * Sale控制器
+ * Class SaleController
+ * @package app\adminapi\controller
+ */
+class SaleAnalysisController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/12/15 10:53
+     */
+    public function saleLists()
+    {
+        return $this->dataLists(new SaleAnalysisLists());
+    }
+
+
+    public function saleGroupLists()
+    {
+        return $this->dataLists(new SaleGroupAnalysisLists());
+    }
+
+    public function propertyHeadLists()
+    {
+        return $this->dataLists(new PropertyHeadAnalysisLists());
+    }
+}

+ 96 - 0
app/adminapi/lists/sale/PropertyHeadAnalysisLists.php

@@ -0,0 +1,96 @@
+<?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 PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/12/15 10:53
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['sale_group_id', 'sale_name', 'mobile'],
+
+        ];
+    }
+
+
+    /**
+     * @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('property_head c', 'a.property_head_id = c.id')
+            ->leftJoin('sale d', 'a.sale_id = d.id')
+            ->field([
+                'a.property_head_id','c.property_name','c.village_name','c.address','c.head_name','c.head_mobile','d.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)
+            ->group('a.property_head_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.property_head_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.property_head_id')
+            ->count();
+    }
+
+}

+ 99 - 0
app/adminapi/lists/sale/SaleAnalysisLists.php

@@ -0,0 +1,99 @@
+<?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 SaleAnalysisLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/12/15 10:53
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['sale_group_id', 'sale_name', 'mobile'],
+
+        ];
+    }
+
+
+    /**
+     * @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 c', 'a.sale_id = c.id')
+            ->field([
+                'a.sale_id','c.sale_name','c.mobile',
+                Db::raw("COUNT(a.work_id) AS work_count,
+                                SUM(CASE WHEN a.sale_type = 1 THEN b.work_amount ELSE 0 END) AS amount_sales_agent,
+                                SUM(CASE WHEN a.sale_type = 2 THEN b.work_amount ELSE 0 END) AS amount_sales_individual")
+            ])
+            ->where('a.sale_type', 'in', [1, 2])
+            ->where('a.order_status', 3)
+            ->group('a.sale_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_id','c.sale_name','c.mobile',
+                Db::raw("COUNT(a.work_id) AS work_count,
+                                SUM(CASE WHEN a.sale_type = 1 THEN b.work_amount ELSE 0 END) AS amount_sales_agent,
+                                SUM(CASE WHEN a.sale_type = 2 THEN b.work_amount ELSE 0 END) AS amount_sales_individual")
+            ])
+            ->where('a.sale_type', 'in', [1, 2])
+            ->where('a.order_status', 3)
+            ->group('a.sale_id')
+            ->count();
+    }
+
+}

+ 95 - 0
app/adminapi/lists/sale/SaleGroupAnalysisLists.php

@@ -0,0 +1,95 @@
+<?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', 'sale_name', 'mobile'],
+
+        ];
+    }
+
+
+    /**
+     * @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)
+            ->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();
+    }
+
+}

+ 5 - 0
app/common/logic/TableDataLogic.php

@@ -19,6 +19,7 @@ namespace app\common\logic;
 use app\common\enum\PayEnum;
 use app\common\enum\RefundEnum;
 use app\common\model\labels\Labels;
+use app\common\model\property\PropertyHead;
 use app\common\model\recharge\RechargeOrder;
 use app\common\model\refund\RefundLog;
 use app\common\model\refund\RefundRecord;
@@ -60,5 +61,9 @@ class TableDataLogic extends BaseLogic
         return SaleGroup::where('id','>',0)->field('id,sale_name as name,id as value,"data_table_saleGroup" as type_value')->select()->toArray();
     }
 
+    public static function propertyHead()
+    {
+        return PropertyHead::where('id','>',0)->field('id,village_name as name,id as value,"data_table_propertyHead" as type_value')->select()->toArray();
+    }
 
 }