|
@@ -208,13 +208,13 @@ class BonusSend extends BaseObject {
|
|
|
$this->_updatePercent(20);
|
|
$this->_updatePercent(20);
|
|
|
//Yii::$app->db->close();
|
|
//Yii::$app->db->close();
|
|
|
//Yii::$app->dbShop->close();
|
|
//Yii::$app->dbShop->close();
|
|
|
- // 更新聘级
|
|
|
|
|
|
|
+ // 更新StarDirectory
|
|
|
$this->updateEmpLevel();
|
|
$this->updateEmpLevel();
|
|
|
$this->_updatePercent(40);
|
|
$this->_updatePercent(40);
|
|
|
$t4 = microtime(true);
|
|
$t4 = microtime(true);
|
|
|
echo('更新聘级完成,耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
echo('更新聘级完成,耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
|
|
|
|
|
- // 更新星级
|
|
|
|
|
|
|
+ // 更新StarCrown
|
|
|
$this->updateCrownLevel();
|
|
$this->updateCrownLevel();
|
|
|
$this->_updatePercent(50);
|
|
$this->_updatePercent(50);
|
|
|
$t41 = microtime(true);
|
|
$t41 = microtime(true);
|
|
@@ -620,6 +620,7 @@ class BonusSend extends BaseObject {
|
|
|
*/
|
|
*/
|
|
|
public function updateCrownLevel(int $offset = 0)
|
|
public function updateCrownLevel(int $offset = 0)
|
|
|
{
|
|
{
|
|
|
|
|
+ $starCrownLv = StarCrownLevel::getIdConvertLevelSortCache();
|
|
|
$allData = CalcBonusQY::findUseDbCalc()
|
|
$allData = CalcBonusQY::findUseDbCalc()
|
|
|
->yearMonth($this->_calcYearMonth)
|
|
->yearMonth($this->_calcYearMonth)
|
|
|
->where(
|
|
->where(
|
|
@@ -635,18 +636,43 @@ class BonusSend extends BaseObject {
|
|
|
->limit($this->_limit)
|
|
->limit($this->_limit)
|
|
|
->all();
|
|
->all();
|
|
|
|
|
|
|
|
|
|
+ $defaultEmpLv = StarCrownLevel::getDefaultLevelId();
|
|
|
if ($allData) {
|
|
if ($allData) {
|
|
|
$transaction = Yii::$app->db->beginTransaction();
|
|
$transaction = Yii::$app->db->beginTransaction();
|
|
|
try {
|
|
try {
|
|
|
foreach ($allData as $data) {
|
|
foreach ($allData as $data) {
|
|
|
- User::updateAll(['CROWN_LV' => $data['LAST_CROWN_LV']], 'ID = :USER_ID', [':USER_ID' => $data['USER_ID']]);
|
|
|
|
|
|
|
+ // 默认级别不更新
|
|
|
|
|
+ if( $data['LAST_CROWN_LV'] === $defaultEmpLv ) continue;
|
|
|
|
|
+
|
|
|
|
|
+ $modernCrownLv = $data['LAST_CROWN_LV']; // 本期计算出的最新级别
|
|
|
|
|
+
|
|
|
|
|
+ $user = CalcCache::getUserInfo($data['USER_ID'], $this->_periodNum);
|
|
|
|
|
+ $originCrownLv = $user['CROWN_LV']; // 用户的历史最高crown级别
|
|
|
|
|
+ $originCrownLvSort = $starCrownLv[$originCrownLv]; // 历史最高crown级别值
|
|
|
|
|
+ $modernCrownLvSort = $starCrownLv[$modernCrownLv]; // 当前计算的crown级别值
|
|
|
|
|
+ if ($modernCrownLvSort > $originCrownLvSort) {
|
|
|
|
|
+ $columns = [
|
|
|
|
|
+ 'CROWN_LV' => $data['LAST_CROWN_LV'],
|
|
|
|
|
+ 'LAST_CROWN_LV' => $data['LAST_CROWN_LV'],
|
|
|
|
|
+ 'LAST_CROWN_LV_UPDATED_AT' => time(),
|
|
|
|
|
+ 'LAST_CROWN_LV_UPDATED_PERIOD' => $this->_periodNum,
|
|
|
|
|
+ ];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $columns = [
|
|
|
|
|
+ 'LAST_CROWN_LV' => $data['LAST_CROWN_LV'],
|
|
|
|
|
+ 'LAST_CROWN_LV_UPDATED_AT' => time(),
|
|
|
|
|
+ 'LAST_CROWN_LV_UPDATED_PERIOD' => $this->_periodNum,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ User::updateAll($columns, 'ID = :USER_ID', [':USER_ID' => $data['USER_ID']]);
|
|
|
User::deleteBaseInfoFromRedis($data['USER_ID']);
|
|
User::deleteBaseInfoFromRedis($data['USER_ID']);
|
|
|
unset($data);
|
|
unset($data);
|
|
|
}
|
|
}
|
|
|
$transaction->commit();
|
|
$transaction->commit();
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
$transaction->rollBack();
|
|
$transaction->rollBack();
|
|
|
- $this->addError('updateStarCrownLevel', '更新星级失败,原因:' . $e->getMessage());
|
|
|
|
|
|
|
+ $this->addError('updateStarCrownLevel', '更新StartCrown失败,原因:' . $e->getMessage());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
unset($transaction, $allData);
|
|
unset($transaction, $allData);
|