落地合伙股东收益体系,并纳入 sheep 用户端源码。

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
chen
2026-09-17 07:47:35 +08:00
父节点 7747dfaa82
当前提交 251d62296e
共有 595 个文件被更改,包括 90234 次插入 和 105 次删除

查看文件

@@ -0,0 +1,50 @@
<?php
namespace addons\shopro\service\partner;
/**
* 酒道馆 / 区县平级 10%,基数为本单该下级的团队奖
*/
class PeerShareReward
{
public function run($order, $buyerId, $chain, $teamResult, ActiveService $active)
{
$venueRate = (float) PartnerConfig::get('partner_venue_peer_rate', 0.10);
$countyRate = (float) PartnerConfig::get('partner_county_peer_rate', 0.10);
if (!empty($teamResult['venue'])) {
$this->peer($order, $buyerId, $chain, $teamResult['venue'], 'is_venue', 'venue_peer', 'venue', $venueRate, $active, '酒道馆');
}
if (!empty($teamResult['county'])) {
$this->peer($order, $buyerId, $chain, $teamResult['county'], 'is_county', 'county_peer', 'county', $countyRate, $active, '区县');
}
}
protected function peer($order, $buyerId, $chain, $from, $flag, $type, $role, $rate, ActiveService $active, $label)
{
$start = intval($from['index']) + 1;
$peer = null;
for ($i = $start; $i < count($chain); $i++) {
if (intval($chain[$i][$flag] ?? 0)) {
$peer = $chain[$i];
break;
}
}
if (!$peer) {
return;
}
$base = (float) $from['amount'];
$amount = round($base * $rate, 2);
if (!$active->isActive($peer['agent'] ?? $peer)) {
PartnerRewardService::writeSkip($order, $buyerId, $peer['user_id'], $type, $role, 'inactive_30d', "{$label}平级 30 日无自购");
return;
}
if ($amount <= 0) {
return;
}
PartnerRewardService::account($order, $buyerId, $peer['user_id'], $type, $role, $amount, $base, [
'formula' => "{$label}平级 {$base} × " . ($rate * 100) . "% = {$amount}",
'from_user_id' => $from['user_id'],
]);
}
}