|
|
@@ -154,7 +154,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
$this->setCalcStatus('start');
|
|
|
// 清空所有本期结算用到的缓存
|
|
|
CalcCache::clearCalcBonusCache($this->_periodNum);
|
|
|
-
|
|
|
+
|
|
|
// 日志----记录清除的流水表数据
|
|
|
ServeLog::clearTableBonus($this->_periodNum, $this->_calcYearMonth, $this->_isCalcMonth);
|
|
|
// 清空相关表数据
|
|
|
@@ -174,7 +174,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
ServeLog::bonusBSData($this->_periodNum, $this->_calcYearMonth);
|
|
|
$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();
|
|
|
@@ -197,10 +197,10 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
$this->calcBonusBDStepTwo();
|
|
|
}
|
|
|
// 日志----服务奖数据
|
|
|
- ServeLog::bonusBDData($this->_periodNum, $this->_calcYearMonth);
|
|
|
- $t6 = microtime(true);
|
|
|
- echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(15);
|
|
|
+// ServeLog::bonusBDData($this->_periodNum, $this->_calcYearMonth);
|
|
|
+// $t6 = microtime(true);
|
|
|
+// echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(15);
|
|
|
|
|
|
// 销售奖/推广奖
|
|
|
if($this->_sysConfig['openTG']['VALUE']) {
|
|
|
@@ -228,39 +228,44 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
// $t21 = microtime(true);
|
|
|
// echo('计算旅游奖' . ($this->_sysConfig['openTourism']['VALUE'] ? '完成' : '关闭') . ',耗时:' . round($t21 - $t20, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
// $this->_updatePercent(68);
|
|
|
- if($this->_sysConfig['openVilla']['VALUE']) {
|
|
|
- $this->calcBonusVilla();
|
|
|
- }
|
|
|
- $t22 = microtime(true);
|
|
|
- echo('计算房奖' . ($this->_sysConfig['openVilla']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t22 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// if($this->_sysConfig['openVilla']['VALUE']) {
|
|
|
+// $this->calcBonusVilla();
|
|
|
+// }
|
|
|
+// $t22 = microtime(true);
|
|
|
+// echo('计算房奖' . ($this->_sysConfig['openVilla']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t22 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(45);
|
|
|
// 日志----房奖数据
|
|
|
- ServeLog::bonusVillaData($this->_periodNum, $this->_calcYearMonth);
|
|
|
+// ServeLog::bonusVillaData($this->_periodNum, $this->_calcYearMonth);
|
|
|
|
|
|
- if($this->_sysConfig['openGarage']['VALUE']) {
|
|
|
- $this->calcBonusGarage();
|
|
|
- }
|
|
|
+// if($this->_sysConfig['openGarage']['VALUE']) {
|
|
|
+// $this->calcBonusGarage();
|
|
|
+// }
|
|
|
// 日志----车奖数据
|
|
|
- ServeLog::bonusGarageData($this->_periodNum, $this->_calcYearMonth);
|
|
|
- $t23 = microtime(true);
|
|
|
- echo('计算车奖' . ($this->_sysConfig['openGarage']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// ServeLog::bonusGarageData($this->_periodNum, $this->_calcYearMonth);
|
|
|
+// $t23 = microtime(true);
|
|
|
+// echo('计算车奖' . ($this->_sysConfig['openGarage']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(55);
|
|
|
|
|
|
// 计算季度奖
|
|
|
- if($this->_sysConfig['openQuarter']['VALUE']) {
|
|
|
- $this->calcQuarter();
|
|
|
- }
|
|
|
- $t24 = microtime(true);
|
|
|
- echo('计算季度奖' . ($this->_sysConfig['openQuarter']['VALUE'] ? '开启调用存储过程' : '关闭').',耗时:' . round($t24 - $t23, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// if($this->_sysConfig['openQuarter']['VALUE']) {
|
|
|
+// $this->calcQuarter();
|
|
|
+// }
|
|
|
+// $t24 = microtime(true);
|
|
|
+// echo('计算季度奖' . ($this->_sysConfig['openQuarter']['VALUE'] ? '开启调用存储过程' : '关闭').',耗时:' . round($t24 - $t23, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
// 将用户写入缓存
|
|
|
- if($this->_sysConfig['openQuarter']['VALUE']) {
|
|
|
- $this->calcQuarterUser();
|
|
|
- }
|
|
|
+// if($this->_sysConfig['openQuarter']['VALUE']) {
|
|
|
+// $this->calcQuarterUser();
|
|
|
+// }
|
|
|
// 日志----季度奖数据
|
|
|
- ServeLog::bonusQuarterData($this->_periodNum, $this->_calcYearMonth);
|
|
|
+// ServeLog::bonusQuarterData($this->_periodNum, $this->_calcYearMonth);
|
|
|
$this->_updatePercent(65);
|
|
|
- $t25 = microtime(true);
|
|
|
- echo('计算季度奖' . ($this->_sysConfig['openQuarter']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t25 - $t24, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $t25 = microtime(true);
|
|
|
+// echo('计算季度奖' . ($this->_sysConfig['openQuarter']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t25 - $t24, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+
|
|
|
+ $this->calcStockistBonus();
|
|
|
+ echo('计算报单中心奖(8%奖)'. PHP_EOL);
|
|
|
+
|
|
|
+ $this->_updatePercent(70);
|
|
|
|
|
|
// 奖金写库
|
|
|
$this->loopBonusUsers();
|
|
|
@@ -405,7 +410,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
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',
|
|
|
+ PerfPeriod::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
|
|
|
[
|
|
|
':USER_ID' => $data['USER_ID'],
|
|
|
':PERIOD_NUM' => $this->_periodNum
|
|
|
@@ -432,7 +437,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
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',
|
|
|
+ PerfMonth::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
[
|
|
|
':USER_ID' => $data['USER_ID'],
|
|
|
':CALC_MONTH' => $this->_calcYearMonth
|
|
|
@@ -467,7 +472,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
if ($hasMonthPerfInfo) {
|
|
|
//存在数据,则更新月业绩表中的个人小组业绩
|
|
|
// 期结算结果
|
|
|
- PerfMonth::updateAll(['DIRECTOR_BONUS_PGS' => $data['GPV10']], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
+ PerfMonth::updateAll(['DIRECTOR_BONUS_PGS' => $data['GPV10']], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
[
|
|
|
':USER_ID' => $data['USER_ID'],
|
|
|
':CALC_MONTH' => $this->_calcYearMonth
|
|
|
@@ -520,7 +525,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
|
|
|
// 获取会员的报单级别
|
|
|
$userBaseInfo = CalcCache::getUserInfo($bonusUserId, $this->_periodNum);
|
|
|
- CalcCache::bonus($bonusUserId, $this->_periodNum, 'BONUS_TG', $recBonus);
|
|
|
+ CalcCache::bonus($bonusUserId, $this->_periodNum, 'BONUS_TG', $recBonus);
|
|
|
|
|
|
//来源会员信息
|
|
|
$fromUserInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
|
|
|
@@ -652,7 +657,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
try {
|
|
|
$userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
|
|
|
CalcCache::bonus($userId, $this->_periodNum, 'BONUS_BD', $fwBonus);
|
|
|
-
|
|
|
+
|
|
|
$decRoleId = $userBaseInfo['DEC_ROLE_ID'];
|
|
|
$insertBonusData[] = [
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
@@ -747,8 +752,8 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
//判断级别上限,个人奖金封顶限制
|
|
|
$teamBonus = $this->declarationLevelCap($teamBonus, $userId, $userBaseInfo['DEC_LV']);
|
|
|
if( $teamBonus <= 0 ) continue;
|
|
|
- // 将封顶前的金额加入用户奖金缓存中,此金额不能发放(总奖金,总实际奖金)
|
|
|
- CalcCache::bonus($userId, $periodNum, 'CAPPED_BONUS_QY', $capBonusQy);
|
|
|
+ // 将封顶前的金额加入用户奖金缓存中,此金额不能发放(总奖金,总实际奖金)
|
|
|
+ CalcCache::bonus($userId, $periodNum, 'CAPPED_BONUS_QY', $capBonusQy);
|
|
|
|
|
|
// TODO:取小腿值
|
|
|
$payLeg = min([$perfArr['SURPLUS_1L'], $perfArr['SURPLUS_2L']]);
|
|
|
@@ -759,7 +764,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
$isActive = User::isPerfActive($userId, $this->_periodNum, $this->_calcYearMonth);
|
|
|
$oriBonus = $isActive ? $teamBonus : 0;
|
|
|
$lastCrownLv = $isActive ? $starCrown['ID'] : StarCrownLevel::getDefaultLevelId();
|
|
|
-
|
|
|
+
|
|
|
//团队奖流水
|
|
|
$insertBonusData[] = [
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
@@ -825,10 +830,10 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
// 不是结算月,则不进行计算
|
|
|
return false;
|
|
|
}
|
|
|
- $result = \Yii::$app->db->createCommand("CALL CalcBlue(:periodNum)")
|
|
|
+ $result = \Yii::$app->db->createCommand("CALL CalcBlue(:periodNum)")
|
|
|
->bindValue(':periodNum' , $this->_periodNum )
|
|
|
->execute();
|
|
|
-
|
|
|
+
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
@@ -889,7 +894,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
if ($bonusPoint <= 0) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$insertBonusData[] = [
|
|
|
'ID' => SnowFake::instance()->generateId(),
|
|
|
'USER_ID' => $userId,
|
|
|
@@ -1085,7 +1090,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
->having(1)
|
|
|
->orderBy('USER_ID ASC, SORT DESC');
|
|
|
$userStarCrownObj = (new Query())->from(['u' => $subQuery])->select('USER_ID,LAST_DEC_LV,LAST_CROWN_LV,LAST_STATUS,LEVEL_NAME,SORT')->groupBy('USER_ID')->indexBy('USER_ID')->all();
|
|
|
-
|
|
|
+
|
|
|
// 合并用户ID,去重
|
|
|
$bonusUsers = array_unique(array_merge(array_keys($userStarDirectorObj), array_keys($userStarCrownObj)));
|
|
|
sort($bonusUsers);
|
|
|
@@ -1244,7 +1249,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'ORI_BONUS_MNT' => $isActive ? $user['ORI_BONUS_MNT'] : 0,
|
|
|
'ORI_BONUS_ABBR' => $isActive ? $user['ORI_BONUS_ABBR'] : 0,
|
|
|
],
|
|
|
- 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
|
|
|
+ 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
|
|
|
[':USER_ID' => $user['USER_ID'], ':PERIOD_NUM' => $this->_periodNum]);
|
|
|
// 修改用户缓存中记录的用户的最新级别
|
|
|
// $userInfo = CalcCache::getUserInfo($user['USER_ID'], $this->_periodNum);
|
|
|
@@ -1311,6 +1316,21 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
return $resultArr;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 报单中心8%奖励
|
|
|
+ */
|
|
|
+ public function calcStockistBonus(){
|
|
|
+ if( !$this->_isCalcMonth ) {
|
|
|
+ // 不是结算月,则不进行计算
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $result = \Yii::$app->db->createCommand("CALL StockistBonus(:CalcYearMonth)")
|
|
|
+ ->bindValue(':CalcYearMonth' , $this->_calcYearMonth )
|
|
|
+ ->execute();
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 循环父级并执行回调函数
|
|
|
* @param $userId
|
|
|
@@ -1433,7 +1453,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
echo sprintf("时间:[%s]缓存奖金数据入库,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
|
|
|
// 从缓存列表里面从底层往上倒序获取会员
|
|
|
$allData = CalcCache::getHasBonusUsers($this->_periodNum, $offset, $this->_limit);
|
|
|
-
|
|
|
+
|
|
|
if($allData){
|
|
|
$insertDataBonus = [];
|
|
|
foreach($allData as $userId){
|
|
|
@@ -1452,7 +1472,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
unset($insertDataBonus, $allData);
|
|
|
return $this->loopBonusUsers($offset + $this->_limit);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -1470,17 +1490,17 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
$villaBonus = CalcCache::villaBonus($userId, $this->_periodNum);
|
|
|
$pervSurplusPerf = CalcCache::surplusPerf($userId, $this->_periodNum);
|
|
|
$starCrownLv = CalcCache::getUserStarCrown($userId, $this->_periodNum);// 星级
|
|
|
- $bonusReal = '0.000'; // 总实发
|
|
|
- $deductManageTaxItems = Config::DEDUCT_MANAGE_TAX; // 扣除管理费的列表
|
|
|
+ $bonusReal = '0.000'; // 总实发
|
|
|
+ $deductManageTaxItems = Config::DEDUCT_MANAGE_TAX; // 扣除管理费的列表
|
|
|
$deductReconsumePointsItems = Config::DEDUCT_RECONSUME_POINTS;// 扣除复消积分的列表
|
|
|
$totalReconsumePointSum = $totalManageSum = '0.000'; // 需要扣除的奖金项,扣除完之后的实发金额
|
|
|
$deductManageTax = '0.000'; // 扣除的管理费
|
|
|
- $deductReconsumePoints = '0.000'; // 扣除的复消积分
|
|
|
+ $deductReconsumePoints = '0.000'; // 扣除的复消积分
|
|
|
foreach($deductManageTaxItems as $v) {
|
|
|
$totalManageSum+= $bonus[$v]; // 需要扣除管理费的累计之和
|
|
|
}
|
|
|
foreach($deductReconsumePointsItems as $v) {
|
|
|
- $totalReconsumePointSum+= $bonus[$v]; // 需要扣除复消积分的累计之和
|
|
|
+ $totalReconsumePointSum+= $bonus[$v]; // 需要扣除复消积分的累计之和
|
|
|
}
|
|
|
|
|
|
// 扣除管理费
|
|
|
@@ -1538,7 +1558,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
'CALC_MONTH' => $this->_calcYearMonth,
|
|
|
'CREATED_AT' => Date::nowTime(),
|
|
|
];
|
|
|
-
|
|
|
+
|
|
|
} catch(Exception $e) {
|
|
|
var_dump($e->getMessage(),'-----------------------------------------------',$userId);
|
|
|
}
|
|
|
@@ -1550,7 +1570,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
// 判断是否满足月最低消费
|
|
|
public function _isMonthPerfLimit($userId) {
|
|
|
$userMonthTotal = PerfMonth::find()->where(
|
|
|
- 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
+ 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
['USER_ID'=>$userId, 'CALC_MONTH'=>$this->_calcYearMonth]
|
|
|
)
|
|
|
->asArray()
|
|
|
@@ -1559,7 +1579,7 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
if (isset($userMonthTotal['PV_PCS']) && $userMonthTotal['PV_PCS'] >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE']) {
|
|
|
$fxPvStatus = true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return $fxPvStatus;
|
|
|
}
|
|
|
|
|
|
@@ -1583,4 +1603,4 @@ class CalcServeBonusCalc extends BaseObject {
|
|
|
|
|
|
return $lastEmpLv;
|
|
|
}
|
|
|
-}
|
|
|
+}
|