From a70d3f7dbf12e6f9626baa1045319d05c0668b62 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 15 Feb 2025 17:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E6=9C=9F=E6=AC=A0=E6=AC=BE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountsReceivableController.php | 6 ++++++ app/admin/logic/AccountsReceivableLogic.php | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/admin/controller/accounts_receivable/AccountsReceivableController.php b/app/admin/controller/accounts_receivable/AccountsReceivableController.php index dba9a7996..60a085167 100644 --- a/app/admin/controller/accounts_receivable/AccountsReceivableController.php +++ b/app/admin/controller/accounts_receivable/AccountsReceivableController.php @@ -49,4 +49,10 @@ class AccountsReceivableController extends BaseAdminController return $this->dataLists(new AccountsReceivableInfoLists()); } + public function statistics() + { + $result = AccountsReceivableLogic::statistics(); + return $this->data($result); + } + } \ No newline at end of file diff --git a/app/admin/logic/AccountsReceivableLogic.php b/app/admin/logic/AccountsReceivableLogic.php index 9098dda9f..4614837ae 100644 --- a/app/admin/logic/AccountsReceivableLogic.php +++ b/app/admin/logic/AccountsReceivableLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic; use app\common\logic\BaseLogic; use app\common\model\finance\AccountsReceivable; use app\common\model\finance\AccountsReceivableInfo; +use app\common\model\system_store\SystemStore; use support\exception\BusinessException; use think\facade\Db; @@ -72,4 +73,18 @@ class AccountsReceivableLogic extends BaseLogic } + public static function statistics() + { + $query = AccountsReceivable::field('store_id,sum(total_debt) as total_debt,sum(pay_debt) as pay_debt,sum(surplus_debt) as surplus_debt')->group('store_id'); + $count = $query->count(); + $list = $query->select()->toArray(); + foreach ($list as &$item) { + $item['store_name'] = SystemStore::where('id', $item['store_id'])->value('name'); + } + return [ + 'list' => $list, + 'count' => $count + ]; + } + } \ No newline at end of file