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 []; + } + /** * 代理等级排名 *