diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 3e35dd52..2eaeeb43 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -350,9 +350,10 @@ class UserInfo extends Model * 变更预收益成长值 * * @param float $growthValue + * @param bool $downgrade * @return void */ - public function incrPreGrowthValue($growthValue) + public function incrPreGrowthValue($growthValue, $downgrade = true) { if (bccomp($growthValue, '0', 2) === 0) { return; @@ -365,9 +366,11 @@ class UserInfo extends Model $compared = bccomp($totalGrowthValue, config('agent.upgrade_rules.vip.sales_value'), 2); if ($this->agent_level === static::AGENT_LEVEL_VIP && $compared < 0) { - $this->update([ - 'agent_level' => static::AGENT_LEVEL_CIVILIAN, - ]); + if ($downgrade) { + $this->update([ + 'agent_level' => static::AGENT_LEVEL_CIVILIAN, + ]); + } } elseif ($this->agent_level === static::AGENT_LEVEL_CIVILIAN && $compared >= 0) { $this->update([ 'agent_level' => static::AGENT_LEVEL_VIP, diff --git a/app/Services/PayService.php b/app/Services/PayService.php index 97564489..030d93c9 100644 --- a/app/Services/PayService.php +++ b/app/Services/PayService.php @@ -90,7 +90,7 @@ class PayService ]); // 增加用户的预成长值 - $payable->user->userInfo->incrPreGrowthValue($payable->sales_value); + $payable->user->userInfo->incrPreGrowthValue($payable->sales_value, false); DistributionPreIncomeJob::create([ 'jobable_id' => $payable->id,