From 02fc86c0bdd0be93ea46040156b08fd3a4025639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Thu, 30 Dec 2021 11:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=80=BB=E9=A2=84=E6=94=B6?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/Account/WalletController.php | 2 +- app/Models/User.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Endpoint/Api/Http/Controllers/Account/WalletController.php b/app/Endpoint/Api/Http/Controllers/Account/WalletController.php index b83c3d83..7c62327b 100644 --- a/app/Endpoint/Api/Http/Controllers/Account/WalletController.php +++ b/app/Endpoint/Api/Http/Controllers/Account/WalletController.php @@ -41,7 +41,7 @@ class WalletController extends Controller public function index(Request $request) { return response()->json([ - 'distribution_pre' => $request->user()->distributionPreIncomes()->pending()->sum('total_revenue'), + 'distribution_pre' => $request->user()->getTotalPreRevenue(), 'wallet_balance'=> $request->user()->wallet?->balance_format ?? 0, ]); } diff --git a/app/Models/User.php b/app/Models/User.php index 60796f54..2476c05b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -296,6 +296,16 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac $this->attributes['password'] = $value; } + /** + * 获取此用户的总预收入 + * + * @return string + */ + public function getTotalPreRevenue(): string + { + return $this->distributionPreIncomes()->unsettlement()->sum('total_revenue'); + } + /** * 确认给定的密码是否正确 *