|
|
@@ -157,6 +157,16 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
}
|
|
|
$t5 = microtime(true);
|
|
|
echo('计算蓝星奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t5 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+
|
|
|
+ // 更新期业绩表中用户的聘级
|
|
|
+ if ($this->_isCalcMonth) {
|
|
|
+ $this->loopUpdatePeriod();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新月业绩表中用户的最新聘级
|
|
|
+ if ($this->_isCalcMonth) {
|
|
|
+ $this->loopUpdateMonthPerf();
|
|
|
+ }
|
|
|
|
|
|
if($this->_sysConfig['openFW']['VALUE']) {
|
|
|
$this->calcBonusBDStepOne();
|
|
|
@@ -320,6 +330,60 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 修正期业绩表中,用户的最新聘级字段
|
|
|
+ public function loopUpdatePeriod($offset = 0) {
|
|
|
+ echo sprintf("时间:[%s]修正期业绩表最新聘级字段,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
|
|
|
+ $allData = PerfPeriod::findUseDbCalc()
|
|
|
+ ->where('PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum])
|
|
|
+ ->offset($offset)
|
|
|
+ ->limit($this->_limit)
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
+ if ($allData) {
|
|
|
+ foreach ($allData as $data) {
|
|
|
+ $nowBsEmpLv = $this->_nowLastEmpLv($data['USER_ID']);
|
|
|
+ // 期结算结果
|
|
|
+ PerfPeriod::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
|
|
|
+ [
|
|
|
+ ':USER_ID' => $data['USER_ID'],
|
|
|
+ ':PERIOD_NUM' => $this->_periodNum
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ unset($allData);
|
|
|
+ return $this->loopUpdatePeriod($offset + $this->_limit);
|
|
|
+ }
|
|
|
+ unset($allData);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修正月业绩表中,用户最新聘级
|
|
|
+ public function loopUpdateMonthPerf($offset = 0) {
|
|
|
+ echo sprintf("时间:[%s]修正月业绩表最新聘级字段,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
|
|
|
+ $allData = PerfMonth::findUseDbCalc()
|
|
|
+ ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcMonth])
|
|
|
+ ->offset($offset)
|
|
|
+ ->limit($this->_limit)
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
+ if ($allData) {
|
|
|
+ foreach ($allData as $data) {
|
|
|
+ $nowBsEmpLv = $this->_nowLastEmpLv($data['USER_ID']);
|
|
|
+ // 期结算结果
|
|
|
+ PerfMonth::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
+ [
|
|
|
+ ':USER_ID' => $data['USER_ID'],
|
|
|
+ ':CALC_MONTH' => $this->_calcMonth
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ unset($allData);
|
|
|
+ return $this->loopUpdateMonthPerf($offset + $this->_limit);
|
|
|
+ }
|
|
|
+ unset($allData);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 推广奖
|
|
|
* @param int $offset
|
|
|
@@ -359,7 +423,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
'USER_ID' => $bonusUserId,
|
|
|
'LAST_DEC_LV' => $userBaseInfo['DEC_LV'],
|
|
|
- 'LAST_EMP_LV' => $userBaseInfo['LAST_EMP_LV'],
|
|
|
+ 'LAST_EMP_LV' => $this->_nowLastEmpLv($userId),
|
|
|
'LAST_STATUS' => $userBaseInfo['STATUS'],
|
|
|
'FROM_USER_ID' => $userId,
|
|
|
'LAST_FROM_DEC_LV' => $fromUserInfo['DEC_LV'],
|
|
|
@@ -488,7 +552,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
'USER_ID' => $userId,
|
|
|
'LAST_DEC_LV' => $userBaseInfo['DEC_LV'],
|
|
|
- 'LAST_EMP_LV' => $userBaseInfo['LAST_EMP_LV'],
|
|
|
+ 'LAST_EMP_LV' => $this->_nowLastEmpLv($userId),
|
|
|
'LAST_STATUS' => $userBaseInfo['STATUS'],
|
|
|
'FROM_USER_ID' => $userId,
|
|
|
'LAST_FROM_DEC_LV' => $userBaseInfo['DEC_LV'],
|
|
|
@@ -596,7 +660,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'USER_ID' => $userId,
|
|
|
'ORI_CAPPED_BONUS_QY' => $capBonusQy,
|
|
|
'LAST_DEC_LV' => $userBaseInfo['DEC_LV'],
|
|
|
- 'LAST_EMP_LV' => $userBaseInfo['LAST_EMP_LV'],
|
|
|
+ 'LAST_EMP_LV' => $this->_nowLastEmpLv($userId),
|
|
|
'LAST_CROWN_LV' => $lastCrownLv,
|
|
|
'LAST_STATUS' => $userBaseInfo['STATUS'],
|
|
|
'AMOUNT' => $oriBonus,
|
|
|
@@ -818,12 +882,11 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
if ($item['LAST_DEC_LV'] != $minDecLevel) {
|
|
|
continue;
|
|
|
}
|
|
|
- $userBaseInfo = CalcCache::getUserInfo($item['USER_ID'], $this->_periodNum);
|
|
|
$insertBonusData[] = [
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
'USER_ID' => $item['USER_ID'],
|
|
|
'LAST_DEC_LV' => $item['LAST_DEC_LV'] ?? '',
|
|
|
- 'LAST_EMP_LV' => $userBaseInfo['LAST_EMP_LV'],
|
|
|
+ 'LAST_EMP_LV' => $this->_nowLastEmpLv($item['USER_ID']),
|
|
|
'LAST_STATUS' => $item['LAST_STATUS'] ?? 0,
|
|
|
'LAST_CROWN_LV' => $item['LAST_CROWN_LV'] ?? '',
|
|
|
'AMOUNT' => 0,
|
|
|
@@ -1316,7 +1379,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'LAST_USER_NAME' => $baseInfo['USER_NAME'],
|
|
|
'LAST_REAL_NAME' => $baseInfo['REAL_NAME'],
|
|
|
'LAST_DEC_LV' => $baseInfo['DEC_LV'],
|
|
|
- 'LAST_EMP_LV' => $baseInfo['LAST_EMP_LV'],
|
|
|
+ 'LAST_EMP_LV' => $this->_nowLastEmpLv($userId),
|
|
|
'LAST_CROWN_LV' => $starCrownLv ?? StarCrownLevel::getDefaultLevelId(),
|
|
|
'RECONSUME_POINTS' => $deductReconsumePoints,
|
|
|
'MANAGE_TAX' => $deductManageTax, // 管理费
|
|
|
@@ -1387,4 +1450,25 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
|
|
|
return $pv >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE'];
|
|
|
}
|
|
|
+
|
|
|
+ // 获取用户当期最新聘级
|
|
|
+ // 非结算月,直接获取传过来的用户级别.如果是结算月,bs流水表无数据则是无级别.有数据,则直接取缓存中数据.因为第一步计算bs奖已更新缓存数据
|
|
|
+ public function _nowLastEmpLv($userId) {
|
|
|
+ // 如果是结算月,且蓝星奖流水没记录,则为无级别
|
|
|
+ $lastEmpLv = EmployLevel::getDefaultLevelId();
|
|
|
+ $userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
|
|
|
+ if( $this->_isCalcMonth ) {
|
|
|
+ $hasBs = CalcBonusBS::findUseDbCalc()
|
|
|
+ ->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $this->_periodNum, ':USER_ID' => $userId])
|
|
|
+ ->asArray()
|
|
|
+ ->one();
|
|
|
+ if (!empty($hasBs)) {
|
|
|
+ $lastEmpLv = $userBaseInfo['LAST_EMP_LV'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $lastEmpLv = $userBaseInfo['LAST_EMP_LV'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $lastEmpLv;
|
|
|
+ }
|
|
|
}
|