|
@@ -391,6 +391,8 @@ class StoreOrderSuccessServices extends BaseServices
|
|
|
$spotUpLimit = sys_config('gift_spot_bonus_up', 15);
|
|
$spotUpLimit = sys_config('gift_spot_bonus_up', 15);
|
|
|
$currentUid = $order['uid']; // 从当前用户开始
|
|
$currentUid = $order['uid']; // 从当前用户开始
|
|
|
$currentRelation = $userRelation; // 当前用户的推荐关系
|
|
$currentRelation = $userRelation; // 当前用户的推荐关系
|
|
|
|
|
+ $originalPid = $userRelation['pid']; // 记录原始用户的真直推上级
|
|
|
|
|
+ $splitRatio = sys_config('gift_fake_pid_split_ratio', 50); // 假直推上级分成比例(给真直推上级的比例)
|
|
|
|
|
|
|
|
for ($i = 0; $i < $spotUpLimit; $i++) {
|
|
for ($i = 0; $i < $spotUpLimit; $i++) {
|
|
|
$nextUid = null;
|
|
$nextUid = null;
|
|
@@ -406,18 +408,53 @@ class StoreOrderSuccessServices extends BaseServices
|
|
|
// 找不到上级,退出循环
|
|
// 找不到上级,退出循环
|
|
|
if (!$nextUid) break;
|
|
if (!$nextUid) break;
|
|
|
|
|
|
|
|
- // 给上级发放见点奖
|
|
|
|
|
- $currentBrokerage = $userServices->getOne(['uid' => $nextUid]);
|
|
|
|
|
- $userServices->bcInc($nextUid, 'brokerage_price', $spotBrokerage, 'uid');
|
|
|
|
|
- $balance = bcadd($currentBrokerage['brokerage_price'], $spotBrokerage);
|
|
|
|
|
- $userBrokerageServices->income('get_spot_brokerage', $nextUid, [
|
|
|
|
|
- 'nickname' => $userInfo['nickname'],
|
|
|
|
|
- 'pay_price' => floatval($order['pay_price']),
|
|
|
|
|
- 'number' => $spotBrokerage,
|
|
|
|
|
- 'frozen_time' => $frozenTime
|
|
|
|
|
- ], $balance, $order['id']);
|
|
|
|
|
|
|
+ // 判断是否需要分成(如果上级是fake_pid且不等于原始用户的pid)
|
|
|
|
|
+ $needSplit = false;
|
|
|
|
|
+ if (!empty($currentRelation['fake_pid']) && $nextUid == $currentRelation['fake_pid'] && $currentRelation['fake_pid'] != $originalPid) {
|
|
|
|
|
+ $needSplit = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @file_put_contents('quanju4.txt', '向上发放见点奖: uid=' . $nextUid . ', 金额=' . $spotBrokerage . "\r\n", 8);
|
|
|
|
|
|
|
+ if ($needSplit) {
|
|
|
|
|
+ // 需要分成:给真直推上级和假直推上级分别发放
|
|
|
|
|
+ $splitAmount = $spotBrokerage * ($splitRatio / 100); // 给真直推上级的份额
|
|
|
|
|
+ $remainderAmount = $spotBrokerage - $splitAmount; // 给假直推上级的份额
|
|
|
|
|
+
|
|
|
|
|
+ // 给真直推上级发放
|
|
|
|
|
+ $pidBrokerage = $userServices->getOne(['uid' => $originalPid]);
|
|
|
|
|
+ $userServices->bcInc($originalPid, 'brokerage_price', $splitAmount, 'uid');
|
|
|
|
|
+ $balance = bcadd($pidBrokerage['brokerage_price'], $splitAmount, 2);
|
|
|
|
|
+ $userBrokerageServices->income('get_spot_brokerage', $originalPid, [
|
|
|
|
|
+ 'nickname' => $userInfo['nickname'],
|
|
|
|
|
+ 'pay_price' => floatval($order['pay_price']),
|
|
|
|
|
+ 'number' => $splitAmount,
|
|
|
|
|
+ 'frozen_time' => $frozenTime
|
|
|
|
|
+ ], $balance, $order['id']);
|
|
|
|
|
+ @file_put_contents('quanju4.txt', '向上发放见点奖给真直推上级: uid=' . $originalPid . ', 金额=' . $splitAmount . "\r\n", 8);
|
|
|
|
|
+
|
|
|
|
|
+ // 给假直推上级发放
|
|
|
|
|
+ $currentBrokerage = $userServices->getOne(['uid' => $nextUid]);
|
|
|
|
|
+ $userServices->bcInc($nextUid, 'brokerage_price', $remainderAmount, 'uid');
|
|
|
|
|
+ $balance = bcadd($currentBrokerage['brokerage_price'], $remainderAmount, 2);
|
|
|
|
|
+ $userBrokerageServices->income('get_spot_brokerage', $nextUid, [
|
|
|
|
|
+ 'nickname' => $userInfo['nickname'],
|
|
|
|
|
+ 'pay_price' => floatval($order['pay_price']),
|
|
|
|
|
+ 'number' => $remainderAmount,
|
|
|
|
|
+ 'frozen_time' => $frozenTime
|
|
|
|
|
+ ], $balance, $order['id']);
|
|
|
|
|
+ @file_put_contents('quanju4.txt', '向上发放见点奖给假直推上级: uid=' . $nextUid . ', 金额=' . $remainderAmount . "\r\n", 8);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 不需要分成:全部给上级
|
|
|
|
|
+ $currentBrokerage = $userServices->getOne(['uid' => $nextUid]);
|
|
|
|
|
+ $userServices->bcInc($nextUid, 'brokerage_price', $spotBrokerage, 'uid');
|
|
|
|
|
+ $balance = bcadd($currentBrokerage['brokerage_price'], $spotBrokerage);
|
|
|
|
|
+ $userBrokerageServices->income('get_spot_brokerage', $nextUid, [
|
|
|
|
|
+ 'nickname' => $userInfo['nickname'],
|
|
|
|
|
+ 'pay_price' => floatval($order['pay_price']),
|
|
|
|
|
+ 'number' => $spotBrokerage,
|
|
|
|
|
+ 'frozen_time' => $frozenTime
|
|
|
|
|
+ ], $balance, $order['id']);
|
|
|
|
|
+ @file_put_contents('quanju4.txt', '向上发放见点奖: uid=' . $nextUid . ', 金额=' . $spotBrokerage . "\r\n", 8);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 查找下一个上级的推荐关系
|
|
// 查找下一个上级的推荐关系
|
|
|
$currentRelation = $giftGroupService->getOne([
|
|
$currentRelation = $giftGroupService->getOne([
|