|
|
|
@ -223,9 +223,9 @@ class CommissionScoreLog |
|
|
|
|
$canUpgradeLevel = $this->checkAgentUpgradeLevel($currentAgent); |
|
|
|
|
\think\Log::info('当前分销商升级信息=' . $canUpgradeLevel . '] ---start'.'---循环次数---'.$currentCommissionLevel); |
|
|
|
|
if ($canUpgradeLevel) { |
|
|
|
|
$this->agent->level = $canUpgradeLevel; |
|
|
|
|
LogModel::add($this->user->id, 'agent', ['type' => 'level', 'level' => LevelModel::find($canUpgradeLevel)]); |
|
|
|
|
$this->agent->save(); |
|
|
|
|
$currentAgent->agent->level = $canUpgradeLevel; |
|
|
|
|
LogModel::add($currentAgent->user->id, 'agent', ['type' => 'level', 'level' => LevelModel::find($canUpgradeLevel)]); |
|
|
|
|
$currentAgent->agent->save(); |
|
|
|
|
} |
|
|
|
|
$parentUserId = $currentAgent->getParentUserId(); |
|
|
|
|
if ($parentUserId) { |
|
|
|
@ -274,11 +274,16 @@ class CommissionScoreLog |
|
|
|
|
$nextAgentLevel = $this->getNextAgentLevel($agent); |
|
|
|
|
\think\Log::info('当前分销商升级信息=' . json_encode($nextAgentLevel, true)); |
|
|
|
|
if (count($nextAgentLevel)) { |
|
|
|
|
|
|
|
|
|
$checkLevel = []; |
|
|
|
|
foreach ($nextAgentLevel as $level) { |
|
|
|
|
$checkLevel[$level->level] = $this->isMatchUpgradeLevelRule($level, $agent); |
|
|
|
|
\think\Log::info('当前等级是否可以升级=' . json_encode($checkLevel, true)); |
|
|
|
|
// 用户不允许越级升级 |
|
|
|
|
if($level->level == self::LEVEL_2) { |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
$checkLevel[$level->level] = $this->isMatchUpgradeLevelRule($level, $agent); |
|
|
|
|
\think\Log::info('当前等级是否可以升级=' . json_encode($checkLevel, true)); |
|
|
|
|
// if (!$this->config->isUpgradeJump()) break; |
|
|
|
|
} |
|
|
|
|
$checkLevel = array_reverse($checkLevel, true); |
|
|
|
@ -293,8 +298,8 @@ class CommissionScoreLog |
|
|
|
|
|
|
|
|
|
public function isMatchUpgradeLevelRule($level, $agent) { |
|
|
|
|
$is_level = false; |
|
|
|
|
\think\Log::info('当前用户消费总金额=' .($agent->user->total_consume + $this->getNextTeamTotal($agent->user->id)) ); |
|
|
|
|
\think\Log::info('当前等级升级'.$level->level.'金额条件=' .$level->total_consume); |
|
|
|
|
\think\Log::info('当前用户消费'.$agent->user->id.'总金额=' .($agent->user->total_consume + $this->getNextTeamTotal($agent->user->id)) ); |
|
|
|
|
\think\Log::info('当前等级升级'.$agent->user->id.'--'.$level->level.'金额条件=' .$level->total_consume); |
|
|
|
|
if (($agent->user->total_consume + $this->getNextTeamTotal($agent->user->id)) > $level->total_consume) { |
|
|
|
|
$is_level = true; |
|
|
|
|
} |
|
|
|
|