fix(partner): 县在馆下时区县拿全额,县以上酒道馆不再发管理奖
后续订单按离买家最近的县结算;馆在县下或同一人时仍按 50+50。已入账订单不重算。 Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -290,6 +290,7 @@ class PartnerConfig
|
||||
'not_maker' => '不是' . $maker . '身份',
|
||||
'not_venue' => '不是' . $venue . '身份',
|
||||
'not_county' => '不是' . $county . '身份',
|
||||
'venue_above_county' => '县以上酒道馆无收益',
|
||||
'cap_not_higher' => '等级未超过基数水位',
|
||||
'already_settled' => '幂等跳过',
|
||||
'partner_goods_off' => '商品未参与',
|
||||
@@ -302,6 +303,7 @@ class PartnerConfig
|
||||
'not_maker' => '',
|
||||
'not_venue' => '',
|
||||
'not_county' => '',
|
||||
'venue_above_county' => '县以上的酒道馆不发放管理奖',
|
||||
'cap_not_higher' => '同阶不计进阶差额,享受平级奖励',
|
||||
'already_settled' => '',
|
||||
'partner_goods_off' => '',
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
namespace addons\shopro\service\partner;
|
||||
|
||||
/**
|
||||
* 渠道管理奖(馆/县拆分):无馆有县=100;有馆有县=50+50;有馆无县=50
|
||||
* 渠道管理奖(馆/县拆分),链下标越小越靠近买家:
|
||||
* - 无馆有县:县 100
|
||||
* - 有馆无县:馆 50
|
||||
* - 最近的馆在最近的县下方,或馆与县是同一人:馆 50 + 县 50
|
||||
* - 最近的县在最近的馆下方:县 100,县以上的馆不发
|
||||
*/
|
||||
class TeamSplitReward
|
||||
{
|
||||
@@ -18,14 +22,18 @@ class TeamSplitReward
|
||||
$result = ['venue' => null, 'county' => null];
|
||||
|
||||
$venue = $this->nearest($chain, 'is_venue', $active);
|
||||
$county = $this->nearestCounty($chain, $venue, $active);
|
||||
$county = $this->nearest($chain, 'is_county', $active);
|
||||
|
||||
if (!$venue && !$county) {
|
||||
PartnerRewardService::writeSkip($order, $buyerId, 0, 'team_venue', 'system', 'not_venue', '链上无酒道馆且无区县');
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($venue) {
|
||||
// 县比馆更靠近买家时,馆在县之上,不发酒道馆管理奖
|
||||
$venueAboveCounty = $venue && $county && intval($venue['index']) > intval($county['index']);
|
||||
$venueEarns = $venue && !$venueAboveCounty;
|
||||
|
||||
if ($venueEarns) {
|
||||
if ($venue['inactive']) {
|
||||
PartnerRewardService::writeSkip($order, $buyerId, $venue['user_id'], 'team_venue', 'venue', 'inactive_30d', '酒道馆 30 日无自购');
|
||||
} else {
|
||||
@@ -34,22 +42,30 @@ class TeamSplitReward
|
||||
]);
|
||||
$result['venue'] = ['user_id' => $venue['user_id'], 'amount' => $venueSplit, 'index' => $venue['index']];
|
||||
}
|
||||
} elseif ($venueAboveCounty) {
|
||||
PartnerRewardService::writeSkip($order, $buyerId, $venue['user_id'], 'team_venue', 'venue', 'venue_above_county', '县以上酒道馆无收益');
|
||||
}
|
||||
|
||||
if ($county) {
|
||||
$amount = $venue ? $venueSplit : $countyFull;
|
||||
$amount = $venueEarns ? $venueSplit : $countyFull;
|
||||
if ($county['inactive']) {
|
||||
PartnerRewardService::writeSkip($order, $buyerId, $county['user_id'], 'team_county', 'county', 'inactive_30d', '区县 30 日无自购');
|
||||
} else {
|
||||
$formulaText = $venue
|
||||
? (($venue['user_id'] == $county['user_id']) ? "区县管理奖 {$amount}(馆兼县)" : "区县管理奖 {$amount}(馆上)")
|
||||
: "区县管理奖 {$amount}(直达)";
|
||||
if ($venue && intval($venue['user_id']) === intval($county['user_id'])) {
|
||||
$formulaText = "区县管理奖 {$amount}(馆兼县)";
|
||||
} elseif ($venueEarns) {
|
||||
$formulaText = "区县管理奖 {$amount}(馆上)";
|
||||
} elseif ($venueAboveCounty) {
|
||||
$formulaText = "区县管理奖 {$amount}(县在馆下)";
|
||||
} else {
|
||||
$formulaText = "区县管理奖 {$amount}(直达)";
|
||||
}
|
||||
PartnerRewardService::account($order, $buyerId, $county['user_id'], 'team_county', 'county', $amount, $amount, [
|
||||
'formula' => $formulaText,
|
||||
]);
|
||||
$result['county'] = ['user_id' => $county['user_id'], 'amount' => $amount, 'index' => $county['index']];
|
||||
}
|
||||
} elseif ($venue && !$county) {
|
||||
} elseif ($venue) {
|
||||
PartnerRewardService::writeSkip($order, $buyerId, 0, 'team_county', 'system', 'not_county', '有馆无区县');
|
||||
}
|
||||
|
||||
@@ -71,26 +87,4 @@ class TeamSplitReward
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function nearestCounty($chain, $venue, ActiveService $active)
|
||||
{
|
||||
// 若酒道馆节点本身兼任区县代理,允许从该酒道馆节点开始匹配(兼具双重身份场景);若未兼任,循环会自动检查其上一级
|
||||
$start = $venue ? $venue['index'] : 0;
|
||||
for ($i = $start; $i < count($chain); $i++) {
|
||||
if (!intval($chain[$i]['is_county'] ?? 0)) {
|
||||
continue;
|
||||
}
|
||||
return [
|
||||
'user_id' => $chain[$i]['user_id'],
|
||||
'index' => $i,
|
||||
'inactive' => !$active->isActive($chain[$i]['agent'] ?? $chain[$i]),
|
||||
'node' => $chain[$i],
|
||||
];
|
||||
}
|
||||
// 无馆时从链头找区县(含自购区县)
|
||||
if (!$venue) {
|
||||
return $this->nearest($chain, 'is_county', $active);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户