邀请分享绑定和等级升级

main
ztt 10 months ago
parent d2109c0387
commit 28df9dcce7
  1. 2
      addons/shopro/controller/third/Wechat.php
  2. 6
      addons/shopro/listener/Commission.php
  3. 19
      addons/shopro/service/CommissionScoreLog.php

@ -15,7 +15,7 @@ class Wechat extends Common
protected $payload = [];
protected $wechat;
protected $platform;
public function _initialize()
{
parent::_initialize();

@ -19,8 +19,10 @@ class Commission
*/
public function userRegisterAfter($payload)
{
$shareInfo = request()->param('shareInfo/a');
\think\Log::info('分享参数:'.urldecode(json_encode($shareInfo)));
// $shareInfo = request()->param('shareInfo/a');
$shareInfo = request()->param('shareInfo');
\think\Log::info('分享参数:'.$shareInfo['shareId']);
if ($shareInfo) {
// 注册后添加分享信息
ShareModel::log($payload['user'], $shareInfo);

@ -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;
}

Loading…
Cancel
Save