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