|
|
@@ -571,95 +571,95 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
$periodNum = $this->_periodNum;
|
|
|
// 从缓存获取分页有业绩的会员信息
|
|
|
$allData = CalcCache::getHasPerfUsers($this->_periodNum, $offset, $this->_limit);
|
|
|
- if ($allData) {
|
|
|
- $insertBonusData = [];
|
|
|
- foreach ($allData as $userId) {
|
|
|
- // 从缓存中获取会员的业绩信息
|
|
|
- $perfData = CalcCache::nowPeriodPerf($userId, $periodNum);
|
|
|
- if( !$perfData ) continue;
|
|
|
- $decRoleBonusFrom = explode(',', $this->_sysConfig['decRoleBonusFrom']['VALUE']);
|
|
|
- $validPvPcs = 0;
|
|
|
- foreach ($decRoleBonusFrom as $orderType) {
|
|
|
- $orderTypeName = sprintf('PV_PCS_%s', $orderType);
|
|
|
- $orderTypeValue = $perfData[$orderTypeName] ?? 0;
|
|
|
-
|
|
|
- $coefficientName = self::ORDER_TYPE_TO_FW_COEFFICIENT[$orderType];
|
|
|
- $coefficient = $this->_sysConfig[$coefficientName]['VALUE'] ?? 1;
|
|
|
- $validPvPcs += $orderTypeValue * $coefficient;
|
|
|
-
|
|
|
- unset($orderType, $orderTypeName, $orderTypeValue, $coefficientName, $coefficient);
|
|
|
- }
|
|
|
- unset($perfData, $decRoleBonusFrom);
|
|
|
- if ( $validPvPcs <= 0 ) continue;
|
|
|
-
|
|
|
- // 查询会员产生时,填写的报单中心
|
|
|
- $bonusUserId = DecOrder::find()->where('TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $userId])->select('DEC_ID')->column();
|
|
|
- //判断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);
|
|
|
-
|
|
|
-// $this->loopRelationParentDo($userId, function ($parent) use($userId, $validPvPcs){
|
|
|
-// try {
|
|
|
-// //判断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;
|
|
|
+// if ($allData) {
|
|
|
+// $insertBonusData = [];
|
|
|
+// foreach ($allData as $userId) {
|
|
|
+// // 从缓存中获取会员的业绩信息
|
|
|
+// $perfData = CalcCache::nowPeriodPerf($userId, $periodNum);
|
|
|
+// if( !$perfData ) continue;
|
|
|
+// $decRoleBonusFrom = explode(',', $this->_sysConfig['decRoleBonusFrom']['VALUE']);
|
|
|
+// $validPvPcs = 0;
|
|
|
+// foreach ($decRoleBonusFrom as $orderType) {
|
|
|
+// $orderTypeName = sprintf('PV_PCS_%s', $orderType);
|
|
|
+// $orderTypeValue = $perfData[$orderTypeName] ?? 0;
|
|
|
//
|
|
|
-// $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;
|
|
|
+// $coefficientName = self::ORDER_TYPE_TO_FW_COEFFICIENT[$orderType];
|
|
|
+// $coefficient = $this->_sysConfig[$coefficientName]['VALUE'] ?? 1;
|
|
|
+// $validPvPcs += $orderTypeValue * $coefficient;
|
|
|
//
|
|
|
-// $fwBonus = $validPvPcs * $diffPercent / 100;
|
|
|
-// if( $fwBonus <= 0 ) return self::LOOP_CONTINUE;
|
|
|
+// unset($orderType, $orderTypeName, $orderTypeValue, $coefficientName, $coefficient);
|
|
|
+// }
|
|
|
+// unset($perfData, $decRoleBonusFrom);
|
|
|
+// if ( $validPvPcs <= 0 ) continue;
|
|
|
//
|
|
|
-// //给本人添加服务奖比例
|
|
|
-// CalcCache::fwMaxBonusPercent($userId, $this->_periodNum, $parentFwBonusPercent);
|
|
|
-// //记录奖金和奖金来源到缓存 并实现在缓存中奖金累加
|
|
|
-// CalcCache::saveFwBonusList($bonusUserId, $this->_periodNum, $fwBonus, ['fromUid'=>$userId, 'fromPvPcs'=>$validPvPcs]);
|
|
|
-// CalcCache::addHasFwBonusUsers($bonusUserId, $this->_periodNum);
|
|
|
-// } catch(Exception $e) {
|
|
|
-// var_dump($e->getMessage(), '------------');
|
|
|
-// }
|
|
|
-// unset($bonusUserId, $bonusUserInfo, $isDec, $decRoleId, $parentDecRoleLevel, $parentFwBonusPercent, $cacheMaxPercent, $diffPercent, $fwBonus);
|
|
|
-// });
|
|
|
-
|
|
|
- unset($userId, $validPvPcs);
|
|
|
- }
|
|
|
- unset($allData, $insertBonusData);
|
|
|
- return $this->calcBonusBDStepOne($offset + $this->_limit);
|
|
|
- }
|
|
|
- unset($allData);
|
|
|
+// // 查询会员产生时,填写的报单中心
|
|
|
+// $bonusUserId = DecOrder::find()->where('TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $userId])->select('DEC_ID')->column();
|
|
|
+// //判断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);
|
|
|
+//
|
|
|
+//// $this->loopRelationParentDo($userId, function ($parent) use($userId, $validPvPcs){
|
|
|
+//// try {
|
|
|
+//// //判断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);
|
|
|
+//// } catch(Exception $e) {
|
|
|
+//// var_dump($e->getMessage(), '------------');
|
|
|
+//// }
|
|
|
+//// unset($bonusUserId, $bonusUserInfo, $isDec, $decRoleId, $parentDecRoleLevel, $parentFwBonusPercent, $cacheMaxPercent, $diffPercent, $fwBonus);
|
|
|
+//// });
|
|
|
+//
|
|
|
+// unset($userId, $validPvPcs);
|
|
|
+// }
|
|
|
+// unset($allData, $insertBonusData);
|
|
|
+// return $this->calcBonusBDStepOne($offset + $this->_limit);
|
|
|
+// }
|
|
|
+// unset($allData);
|
|
|
return true;
|
|
|
}
|
|
|
|