账期欠款添加统计

This commit is contained in:
lewis 2025-02-15 17:10:50 +08:00
parent 36016871da
commit a70d3f7dbf
2 changed files with 21 additions and 0 deletions

View File

@ -49,4 +49,10 @@ class AccountsReceivableController extends BaseAdminController
return $this->dataLists(new AccountsReceivableInfoLists());
}
public function statistics()
{
$result = AccountsReceivableLogic::statistics();
return $this->data($result);
}
}

View File

@ -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
];
}
}