From 7108f71630e2b4bda52eb6c9fd614cef7b587dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Thu, 30 Dec 2021 15:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=89=E4=B8=9D=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Merchant/FanController.php | 31 +++++++++++++++++++ .../Http/Resources/Merchant/FanResource.php | 26 ++++++++++++++++ app/Endpoint/Api/routes.php | 2 ++ app/Models/UserInfo.php | 15 +++++++-- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 app/Endpoint/Api/Http/Controllers/Merchant/FanController.php create mode 100644 app/Endpoint/Api/Http/Resources/Merchant/FanResource.php diff --git a/app/Endpoint/Api/Http/Controllers/Merchant/FanController.php b/app/Endpoint/Api/Http/Controllers/Merchant/FanController.php new file mode 100644 index 00000000..80ef2533 --- /dev/null +++ b/app/Endpoint/Api/Http/Controllers/Merchant/FanController.php @@ -0,0 +1,31 @@ +user() + ->fans() + ->latest('id') + ->simplePaginate($perPage); + + $fans->load('userInfo'); + + return FanResource::collection($fans); + } +} diff --git a/app/Endpoint/Api/Http/Resources/Merchant/FanResource.php b/app/Endpoint/Api/Http/Resources/Merchant/FanResource.php new file mode 100644 index 00000000..6c209366 --- /dev/null +++ b/app/Endpoint/Api/Http/Resources/Merchant/FanResource.php @@ -0,0 +1,26 @@ + (string) $this->userInfo->nickname, + 'avatar' => (string) $this->userInfo->avatar, + 'phone' => Str::mask($this->phone, '*', 3, 4), + 'agent_level_name' => (string) $this->userInfo->agent_level_name, + 'team_sales_value' => $this->userInfo?->team_sales_value, + ]; + } +} diff --git a/app/Endpoint/Api/routes.php b/app/Endpoint/Api/routes.php index 864de908..64d99496 100644 --- a/app/Endpoint/Api/routes.php +++ b/app/Endpoint/Api/routes.php @@ -182,6 +182,8 @@ Route::group([ ], ], function () { Route::get('account', [Merchant\UserController::class, 'account']); + // 粉丝列表 + Route::get('fans', [Merchant\FanController::class, 'index']); // 配额日志 Route::get('quota-logs', [Merchant\QuotaLogController::class, 'index']); // 个人销售值日志 diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 4dec2248..ea2b02ec 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -274,7 +274,7 @@ class UserInfo extends Model } // 如果成长值不足650时,不能升级 - if (bccomp($this->group_sales_value, '650') < 0) { + if (bccomp($this->growth_value, '650') < 0) { return; } @@ -283,8 +283,7 @@ class UserInfo extends Model $lvl = static::AGENT_LEVEL_VIP; } - // 总团队销售值 = 团队销售值 + 个人成长值 - $salesValue = bcadd($this->group_sales_value, $this->growth_value, 2); + $salesValue = $this->team_sales_value; if ($lvl === static::AGENT_LEVEL_VIP) { $vipsCount = $this->getVipAgentsCount(); @@ -410,4 +409,14 @@ class UserInfo extends Model { return Str::finish($this->path.$this->getKey(), '/'); } + + /** + * 获团队销售值 + * + * @return string + */ + public function getTeamSalesValueAttribute(): string + { + return bcadd($this->growth_value, $this->group_sales_value, 2); + } }