fix(commission): 修复分销商升级规则中下级分销商等级未向上兼容累计统计导致无法晋升的问题
这个提交包含在:
@@ -337,13 +337,32 @@ class Agent
|
||||
// 团队用户人数 = 一级用户人数 + 一级用户的团队用户人数
|
||||
$this->agent->child_user_count_all = $this->agent->child_user_count_1 + array_sum(array_column($nextAgentTeam, 'child_user_count_all'));
|
||||
|
||||
// 一级分销商人数
|
||||
$this->agent->child_agent_count_1 = count($nextAgentTeam);
|
||||
// 一级有效分销商与等级统计 (优化:等级 1 品酒师必须有自购计奖商品 child_order_count_0 >= 1 才算有效品酒师)
|
||||
$effectiveNextLevels = [];
|
||||
$effectiveAgentCount1 = 0;
|
||||
foreach ($nextAgentTeam as $agMember) {
|
||||
$agLv = intval($agMember['level'] ?? 1);
|
||||
$selfBuyOrderCount = intval($agMember['child_order_count_0'] ?? 0);
|
||||
|
||||
if ($agLv === 1) {
|
||||
if ($selfBuyOrderCount >= 1) {
|
||||
$effectiveNextLevels[] = 1;
|
||||
$effectiveAgentCount1++;
|
||||
}
|
||||
// 未自购计奖商品者属于普通游客,不计入品酒师,亦不计入一级分销商人数
|
||||
} elseif ($agLv >= 2) {
|
||||
$effectiveNextLevels[] = $agLv;
|
||||
$effectiveAgentCount1++;
|
||||
}
|
||||
}
|
||||
|
||||
// 一级有效分销商人数
|
||||
$this->agent->child_agent_count_1 = $effectiveAgentCount1;
|
||||
|
||||
// 二级分销商人数 = 一级分销商的一级分销商人数
|
||||
$this->agent->child_agent_count_2 = array_sum(array_column($nextAgentTeam, 'child_agent_count_1'));
|
||||
|
||||
// 团队分销商人数 = 一级分销商人数 + 一级分销商的团队分销商人数
|
||||
// 团队分销商人数 = 一级有效分销商人数 + 一级所有分销商的团队分销商人数
|
||||
$this->agent->child_agent_count_all = $this->agent->child_agent_count_1 + array_sum(array_column($nextAgentTeam, 'child_agent_count_all'));
|
||||
|
||||
// 二级分销订单金额 = 一级分销商的一级分销订单金额 + 一级分销商的自购订单金额
|
||||
@@ -358,8 +377,8 @@ class Agent
|
||||
// 团队分销订单数量 = 自购分销订单数量 + 一级分销订单数量 + 一级所有分销商的团队分销订单总数量
|
||||
$this->agent->child_order_count_all = $this->agent->child_order_count_0 + $this->agent->child_order_count_1 + array_sum(array_column($nextAgentTeam, 'child_order_count_all'));
|
||||
|
||||
// 一级分销商等级统计
|
||||
$child_agent_level_1 = array_count_values(array_column($nextAgentTeam, 'level'));
|
||||
// 一级分销商等级统计 (仅统计自购了计奖商品的有效品酒师及创客)
|
||||
$child_agent_level_1 = array_count_values($effectiveNextLevels);
|
||||
ksort($child_agent_level_1);
|
||||
$this->agent->child_agent_level_1 = $child_agent_level_1;
|
||||
|
||||
@@ -520,11 +539,26 @@ class Agent
|
||||
case 'child_agent_level_all': // 团队分销商等级统计
|
||||
$match[$name] = true;
|
||||
if (count($value) > 0) {
|
||||
if (empty($this->agent->$name)) {
|
||||
$currentLevelDist = $this->agent->$name;
|
||||
if (is_string($currentLevelDist)) {
|
||||
$currentLevelDist = json_decode($currentLevelDist, true) ?: [];
|
||||
}
|
||||
$currentLevelDist = (array)$currentLevelDist;
|
||||
|
||||
if (empty($currentLevelDist)) {
|
||||
$match[$name] = false;
|
||||
} else {
|
||||
foreach ($value as $k => $row) {
|
||||
if (!isset(($this->agent->$name)[$row['level']]) || ($this->agent->$name)[$row['level']] < $row['count']) {
|
||||
$targetLevel = intval($row['level'] ?? 0);
|
||||
$targetCount = intval($row['count'] ?? 0);
|
||||
$actualCount = 0;
|
||||
// 向上兼容累计:当下级达到或超过目标等级时,均符合该等级的人数考核要求
|
||||
foreach ($currentLevelDist as $curLv => $cnt) {
|
||||
if (intval($curLv) >= $targetLevel) {
|
||||
$actualCount += intval($cnt);
|
||||
}
|
||||
}
|
||||
if ($actualCount < $targetCount) {
|
||||
$match[$name] = false;
|
||||
break;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户