From 25329b3246f9416263bd1dd0ce28aba88a4a6b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Wed, 29 Dec 2021 11:07:04 +0800 Subject: [PATCH] WIP --- app/Models/UserInfo.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 17999385..5cde3f0a 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -147,20 +147,6 @@ class UserInfo extends Model return $this->hasMany(DistributionPreIncome::class, 'user_id', 'user_id'); } - /** - * 获取此用户的所有父级ID - * - * @return array - */ - public function getParentIdsAttribute(): array - { - if ($path = trim($this->path, '/')) { - return explode('/', $path); - } - - return []; - } - /** * 变更预收益成长值 * @@ -178,17 +164,31 @@ class UserInfo extends Model $compared = bccomp(bcadd($this->growth_value, $this->pre_growth_value, 2), '650', 2); - if ($this->agent_level === 1 && $compared < 0) { + if ($this->agent_level === static::AGENT_LEVEL_VIP && $compared < 0) { $this->update([ - 'agent_level' => 0, + 'agent_level' => static::AGENT_LEVEL_CIVILIAN, ]); - } elseif ($this->agent_level === 0 && $compared >= 0) { + } elseif ($this->agent_level === static::AGENT_LEVEL_CIVILIAN && $compared >= 0) { $this->update([ - 'agent_level' => 1, + 'agent_level' => static::AGENT_LEVEL_VIP, ]); } } + /** + * 获取此用户的所有父级ID + * + * @return array + */ + public function getParentIdsAttribute(): array + { + if ($path = trim($this->path, '/')) { + return explode('/', $path); + } + + return []; + } + /** * 代理等级排名 *