|
|
@@ -579,8 +579,10 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
LoggerTool::debug(json_encode(['FWBonusPerfData-P1', $userId]));
|
|
|
// 从缓存中获取会员的业绩信息
|
|
|
$perfData = CalcCache::nowPeriodPerf($userId, $periodNum);
|
|
|
-// LoggerTool::debug(json_encode(['FWBonusPerfData-P2', $userId, $perfData]));
|
|
|
+LoggerTool::debug(json_encode(['FWBonusPerfData-P2', $userId, $perfData]));
|
|
|
if( !$perfData ) continue;
|
|
|
+
|
|
|
+ // 服务奖来源
|
|
|
$decRoleBonusFrom = explode(',', $this->_sysConfig['decRoleBonusFrom']['VALUE']);
|
|
|
$validPvPcs = 0;
|
|
|
foreach ($decRoleBonusFrom as $orderType) {
|
|
|
@@ -596,38 +598,36 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
unset($perfData, $decRoleBonusFrom);
|
|
|
if ( $validPvPcs <= 0 ) continue;
|
|
|
|
|
|
- // 查询会员产生时,填写的报单中心
|
|
|
- $bonusUserId = DecOrder::find()->where('TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $userId])->select('DEC_ID')->orderBy('CREATED_AT DESC')->scalar();
|
|
|
-//LoggerTool::debug(json_encode(['FWBonus-1', $userId, $bonusUserId]));
|
|
|
- //判断parent的报单中心级别 和 服务奖比例
|
|
|
- //计算级别之后更新过userInfo的缓存,缓存中级别发生了变化
|
|
|
- $bonusUserInfo = CalcCache::getUserInfo($bonusUserId, $this->_periodNum);
|
|
|
- $isDec = $bonusUserInfo['IS_DEC'];
|
|
|
- if ($isDec == 0) {
|
|
|
- return self::LOOP_CONTINUE; // 如果不是报单中心则跳过循环
|
|
|
- }
|
|
|
-
|
|
|
- $decRoleId = $bonusUserInfo['DEC_ROLE_ID'];
|
|
|
- if( !$decRoleId ) return self::LOOP_CONTINUE;
|
|
|
- if( !isset($this->_decRoleConfig[$decRoleId]) ) return self::LOOP_CONTINUE;
|
|
|
-
|
|
|
- // 取报单中心级别对应的拿奖比例
|
|
|
- $parentDecRoleLevel = $this->_decRoleConfig[$decRoleId];
|
|
|
- $parentFwBonusPercent = $parentDecRoleLevel['FW_BONUS_PERCENT'] ?? 0;
|
|
|
- $cacheMaxPercent = CalcCache::fwMaxBonusPercent($userId, $this->_periodNum);
|
|
|
- $diffPercent = $parentFwBonusPercent - $cacheMaxPercent;
|
|
|
- if( $diffPercent <= 0 ) return self::LOOP_CONTINUE;
|
|
|
-
|
|
|
- $fwBonus = $validPvPcs * $diffPercent / 100;
|
|
|
- if( $fwBonus <= 0 ) return self::LOOP_CONTINUE;
|
|
|
-
|
|
|
- // 给本人添加服务奖比例
|
|
|
- CalcCache::fwMaxBonusPercent($userId, $this->_periodNum, $parentFwBonusPercent);
|
|
|
- //记录奖金和奖金来源到缓存 并实现在缓存中奖金累加
|
|
|
- CalcCache::saveFwBonusList($bonusUserId, $this->_periodNum, $fwBonus, ['fromUid'=>$userId, 'fromPvPcs'=>$validPvPcs]);
|
|
|
- CalcCache::addHasFwBonusUsers($bonusUserId, $this->_periodNum);
|
|
|
-//LoggerTool::debug(json_encode(['FWBonus-2', $userId, $bonusUserId, $validPvPcs, $fwBonus, $parentFwBonusPercent]));
|
|
|
- unset($userId, $bonusUserId, $validPvPcs);
|
|
|
+ $this->loopRelationDecDo($userId, function ($bonusUserId) use($userId, $validPvPcs) {
|
|
|
+ //判断报单中心级别 和 服务奖比例
|
|
|
+ //计算级别之后更新过userInfo的缓存,缓存中级别发生了变化
|
|
|
+ $bonusUserInfo = CalcCache::getUserInfo($bonusUserId, $this->_periodNum);
|
|
|
+ $isDec = $bonusUserInfo['IS_DEC'];
|
|
|
+ if($isDec == 0) return self::LOOP_CONTINUE;
|
|
|
+ $decRoleId = $bonusUserInfo['DEC_ROLE_ID'];
|
|
|
+ if( !$decRoleId ) return self::LOOP_CONTINUE;
|
|
|
+ if( !isset($this->_decRoleConfig[$decRoleId]) ) return self::LOOP_CONTINUE;
|
|
|
+
|
|
|
+ $parentDecRoleLevel = $this->_decRoleConfig[$decRoleId];
|
|
|
+ $parentFwBonusPercent = $parentDecRoleLevel['FW_BONUS_PERCENT'] ?? 0;
|
|
|
+ $cacheMaxPercent = CalcCache::fwMaxBonusPercent($userId, $this->_periodNum);
|
|
|
+ $diffPercent = $parentFwBonusPercent - $cacheMaxPercent;
|
|
|
+ if( $diffPercent <= 0 ) return self::LOOP_CONTINUE;
|
|
|
+
|
|
|
+ $fwBonus = $validPvPcs * $diffPercent / 100;
|
|
|
+ if( $fwBonus <= 0 ) return self::LOOP_CONTINUE;
|
|
|
+
|
|
|
+ //给本人添加服务奖比例
|
|
|
+ CalcCache::fwMaxBonusPercent($userId, $this->_periodNum, $parentFwBonusPercent);
|
|
|
+ //记录奖金和奖金来源到缓存 并实现在缓存中奖金累加
|
|
|
+ CalcCache::saveFwBonusList($bonusUserId, $this->_periodNum, $fwBonus, ['fromUid'=>$userId, 'fromPvPcs'=>$validPvPcs]);
|
|
|
+ CalcCache::addHasFwBonusUsers($bonusUserId, $this->_periodNum);
|
|
|
+
|
|
|
+ //达到最大的比例就不在向上找了
|
|
|
+ unset($bonusUserId, $bonusUserInfo, $isDec, $decRoleId, $parentDecRoleLevel, $parentFwBonusPercent, $cacheMaxPercent, $diffPercent, $fwBonus);
|
|
|
+ });
|
|
|
+
|
|
|
+ unset($userId, $validPvPcs);
|
|
|
}
|
|
|
|
|
|
unset($allData, $insertBonusData);
|
|
|
@@ -1373,6 +1373,12 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public function loopRelationDecDo($userId, callable $callbackFunc) {
|
|
|
+ // 查询会员产生时,填写的报单中心
|
|
|
+ return DecOrder::find()->where('TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $userId])->select('DEC_ID')->orderBy('CREATED_AT DESC')->scalar();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 按级别的收入上限
|
|
|
* 新的需求调整: 改成不按月进行限制,并且去掉vip奖
|