|
|
@@ -844,42 +844,71 @@ class BonusCalc extends BaseObject {
|
|
|
unset($perfData, $decRoleBonusFrom);
|
|
|
if ( $validPvPcs <= 0 ) continue;
|
|
|
|
|
|
- $this->loopRelationParentDo($userId, function ($parent) use($userId, $validPvPcs){
|
|
|
-
|
|
|
- //判断parent的报单中心级别 和 服务奖比例
|
|
|
- $bonusUserId = $parent['PARENT_UID'];
|
|
|
- //计算级别之后更新过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);
|
|
|
+ // 查询会员产生时,填写的报单中心
|
|
|
+ $bonusUserId = DecOrder::find()->where('TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $userId])->select('DEC_ID')->column();
|
|
|
+ LoggerTool::debug(['bonusCalc', $userId, $bonusUserId]);
|
|
|
+ //判断parent的报单中心级别 和 服务奖比例
|
|
|
+ //计算级别之后更新过userInfo的缓存,缓存中级别发生了变化
|
|
|
+ $bonusUserInfo = CalcCache::getUserInfo($bonusUserId, $this->_periodNum);
|
|
|
+ $isDec = $bonusUserInfo['IS_DEC'];
|
|
|
+ if ($isDec == 0) {
|
|
|
+ return self::LOOP_CONTINUE; // 如果不是报单中心则跳过循环
|
|
|
+ }
|
|
|
|
|
|
- //达到最大的比例就不在向上找了
|
|
|
-// if( $parentFwBonusPercent >= $maxLevelPercent ) return self::LOOP_FINISH;
|
|
|
- unset($bonusUserId, $bonusUserInfo, $isDec, $decRoleId, $parentDecRoleLevel, $parentFwBonusPercent, $cacheMaxPercent, $diffPercent, $fwBonus);
|
|
|
- });
|
|
|
+ $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);
|
|
|
+
|
|
|
+// $this->loopRelationParentDo($userId, function ($parent) use($userId, $validPvPcs) {
|
|
|
+// //判断parent的报单中心级别 和 服务奖比例
|
|
|
+// $bonusUserId = $parent['PARENT_UID'];
|
|
|
+// //计算级别之后更新过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);
|
|
|
+//
|
|
|
+// //达到最大的比例就不在向上找了
|
|
|
+//// if( $parentFwBonusPercent >= $maxLevelPercent ) return self::LOOP_FINISH;
|
|
|
+// unset($bonusUserId, $bonusUserInfo, $isDec, $decRoleId, $parentDecRoleLevel, $parentFwBonusPercent, $cacheMaxPercent, $diffPercent, $fwBonus);
|
|
|
+// });
|
|
|
|
|
|
unset($userId, $validPvPcs);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
unset($allData, $insertBonusData);
|
|
|
return $this->calcBonusBDStepOne($offset + $this->_limit);
|
|
|
}
|