|
|
@@ -20,6 +20,7 @@ use common\models\CalcBonusCF;
|
|
|
use common\models\CalcBonusFL;
|
|
|
use common\models\CalcBonusFW;
|
|
|
use common\models\CalcBonusFX;
|
|
|
+use common\models\CalcBonusGarage;
|
|
|
use common\models\CalcBonusGL;
|
|
|
use common\models\CalcBonusGX;
|
|
|
use common\models\CalcBonusHB;
|
|
|
@@ -28,11 +29,11 @@ use common\models\CalcBonusLX;
|
|
|
use common\models\CalcBonusQY;
|
|
|
use common\models\CalcBonusStandard;
|
|
|
use common\models\CalcBonusTG;
|
|
|
+use common\models\CalcBonusTourism;
|
|
|
use common\models\CalcBonusVIP;
|
|
|
use common\models\CalcBonusXF;
|
|
|
use common\models\CalcBonusYC;
|
|
|
use common\models\CalcBonusYJ;
|
|
|
-use common\models\CalcBonusZone;
|
|
|
use common\models\CalcMonthBonusUser;
|
|
|
use common\models\Config;
|
|
|
use common\models\FlowDeductZR;
|
|
|
@@ -182,15 +183,17 @@ class BonusCalc extends BaseObject {
|
|
|
$this->_updatePercent(5);
|
|
|
$t3 = microtime(true);
|
|
|
$this->_updatePercent(10);
|
|
|
- // 奖金部分
|
|
|
- if($this->_sysConfig['openFW']['VALUE']) {
|
|
|
- $this->calcBonusBDStepOne();
|
|
|
- $this->calcBonusBDStepTwo();
|
|
|
- }
|
|
|
+
|
|
|
+// // 奖金部分
|
|
|
+// if($this->_sysConfig['openFW']['VALUE']) {
|
|
|
+// $this->calcBonusBDStepOne();
|
|
|
+// $this->calcBonusBDStepTwo();
|
|
|
+// }
|
|
|
$t4 = microtime(true);
|
|
|
- echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(15);
|
|
|
+// echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(15);
|
|
|
|
|
|
+ // 销售奖/推广奖
|
|
|
if($this->_sysConfig['openTG']['VALUE']) {
|
|
|
$this->calcBonusTG();
|
|
|
}
|
|
|
@@ -198,117 +201,115 @@ class BonusCalc extends BaseObject {
|
|
|
echo('计算推广奖'.($this->_sysConfig['openTG']['VALUE']?'完成':'关闭').',耗时:' . round($t5 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(20);
|
|
|
|
|
|
- if($this->_sysConfig['openXF']['VALUE']) {
|
|
|
- if( $this->_sysConfig['consumeRecPercent']['VALUE'] > 0 ) {
|
|
|
- $this->calcBonusXFToRec();
|
|
|
- }
|
|
|
- if( $this->_sysConfig['consumeSelfPercent']['VALUE'] > 0 ) {
|
|
|
- $this->calcBonusXFToSelf();
|
|
|
- }
|
|
|
- }
|
|
|
- $t6 = microtime(true);
|
|
|
- echo('计算消费奖'.($this->_sysConfig['openXF']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(25);
|
|
|
-
|
|
|
- if($this->_sysConfig['openYJ']['VALUE']) {
|
|
|
- $this->calcBonusBdYJ();
|
|
|
- }
|
|
|
- $t7 = microtime(true);
|
|
|
- echo('计算报单业绩奖'.($this->_sysConfig['openYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(30);
|
|
|
-
|
|
|
- if($this->_sysConfig['fxOpenYJ']['VALUE']) {
|
|
|
- $this->calcBonusFxYJ();
|
|
|
- }
|
|
|
+// if($this->_sysConfig['openXF']['VALUE']) {
|
|
|
+// if( $this->_sysConfig['consumeRecPercent']['VALUE'] > 0 ) {
|
|
|
+// $this->calcBonusXFToRec();
|
|
|
+// }
|
|
|
+// if( $this->_sysConfig['consumeSelfPercent']['VALUE'] > 0 ) {
|
|
|
+// $this->calcBonusXFToSelf();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $t6 = microtime(true);
|
|
|
+// echo('计算消费奖'.($this->_sysConfig['openXF']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(25);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['openYJ']['VALUE']) {
|
|
|
+// $this->calcBonusBdYJ();
|
|
|
+// }
|
|
|
+// $t7 = microtime(true);
|
|
|
+// echo('计算报单业绩奖'.($this->_sysConfig['openYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(30);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['fxOpenYJ']['VALUE']) {
|
|
|
+// $this->calcBonusFxYJ();
|
|
|
+// }
|
|
|
$t8 = microtime(true);
|
|
|
- echo('计算复消业绩奖'.($this->_sysConfig['fxOpenYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(35);
|
|
|
-
|
|
|
+// echo('计算复消业绩奖'.($this->_sysConfig['fxOpenYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(35);
|
|
|
|
|
|
+ // 绩效奖/团队奖
|
|
|
if($this->_sysConfig['openQY']['VALUE']) {
|
|
|
$this->calcBonusQY();
|
|
|
- $this->calcBonusBdQY();
|
|
|
- $this->calcBonusFxQY();
|
|
|
+// $this->calcBonusBdQY();
|
|
|
+// $this->calcBonusFxQY();
|
|
|
}
|
|
|
$t9 = microtime(true);
|
|
|
echo('计算团队奖'.($this->_sysConfig['openQY']['VALUE']?'完成':'关闭').',耗时:' . round($t9 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(65);
|
|
|
|
|
|
- if($this->_sysConfig['openGX']['VALUE']) {
|
|
|
- $this->calcBonusGXBefore();
|
|
|
- $this->calcBonusGX();
|
|
|
- }
|
|
|
- $t11 = microtime(true);
|
|
|
- echo('计算共享奖'.($this->_sysConfig['openGX']['VALUE']?'完成':'关闭').',耗时:' . round($t11 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(68);
|
|
|
-
|
|
|
- if($this->_sysConfig['openGL']['VALUE']) {
|
|
|
- $this->calcBonusBdGL();
|
|
|
- }
|
|
|
- $t13 = microtime(true);
|
|
|
- echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(50);
|
|
|
-
|
|
|
+// if($this->_sysConfig['openGX']['VALUE']) {
|
|
|
+// $this->calcBonusGXBefore();
|
|
|
+// $this->calcBonusGX();
|
|
|
+// }
|
|
|
+// $t11 = microtime(true);
|
|
|
+// echo('计算共享奖'.($this->_sysConfig['openGX']['VALUE']?'完成':'关闭').',耗时:' . round($t11 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(68);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['openGL']['VALUE']) {
|
|
|
+// $this->calcBonusBdGL();
|
|
|
+// }
|
|
|
+// $t13 = microtime(true);
|
|
|
+// echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(50);
|
|
|
+//
|
|
|
// if($this->_sysConfig['fxOpenGL']['VALUE']) {
|
|
|
// $this->calcBonusFxGL();
|
|
|
// }
|
|
|
// $t14 = microtime(true);
|
|
|
// echo('计算复消管理奖'.($this->_sysConfig['fxOpenGL']['VALUE']?'完成':'关闭').',耗时:' . round($t14 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
// $this->_updatePercent(70);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['openYC']['VALUE']) {
|
|
|
+// $this->calcBonusYCStepOne();
|
|
|
+// $this->calcBonusYCStepTwo();
|
|
|
+// }
|
|
|
+// $t16 = microtime(true);
|
|
|
+// echo('计算荣衔奖'.($this->_sysConfig['openYC']['VALUE']?'完成':'关闭').',耗时:' . round($t16 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(55);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['openVIP']['VALUE']) {
|
|
|
+// $this->calcBonusVIP();
|
|
|
+// }
|
|
|
+// $t17 = microtime(true);
|
|
|
+// echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(60);
|
|
|
+//
|
|
|
+// if($this->_sysConfig['openJXS']['VALUE']) {
|
|
|
+// $this->calcBonusStandard();
|
|
|
+// }
|
|
|
+// $t18 = microtime(true);
|
|
|
+// echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+// $this->_updatePercent(65);
|
|
|
|
|
|
- if($this->_sysConfig['openYC']['VALUE']) {
|
|
|
- $this->calcBonusYCStepOne();
|
|
|
- $this->calcBonusYCStepTwo();
|
|
|
- }
|
|
|
- $t16 = microtime(true);
|
|
|
- echo('计算荣衔奖'.($this->_sysConfig['openYC']['VALUE']?'完成':'关闭').',耗时:' . round($t16 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(55);
|
|
|
-
|
|
|
- if($this->_sysConfig['openVIP']['VALUE']) {
|
|
|
- $this->calcBonusVIP();
|
|
|
- }
|
|
|
- $t17 = microtime(true);
|
|
|
- echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(60);
|
|
|
-
|
|
|
- if($this->_sysConfig['openJXS']['VALUE']) {
|
|
|
- $this->calcBonusStandard();
|
|
|
- }
|
|
|
- $t18 = microtime(true);
|
|
|
- echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(65);
|
|
|
-
|
|
|
+ $t19 = microtime(true);
|
|
|
// 蓝星奖入库,实际上是插入有奖金会员数据缓存中.
|
|
|
+ echo('计算蓝星奖开始,' . date('Y-m-d H:i:s', $t19) . PHP_EOL);
|
|
|
// 调用存储过程,计算蓝星管理奖金
|
|
|
$this->calcBsProcedure();
|
|
|
// 将有【蓝星业绩奖金】的用户加入到有奖金缓存用户中
|
|
|
$this->calcBonusBsYJ();
|
|
|
// 将有【蓝星管理奖金】的用户加入到有奖金缓存用户中
|
|
|
$this->calcBonusBsGL();
|
|
|
- $t18temp = microtime(true);
|
|
|
- echo('计算蓝星奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t18temp - $t18, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
- $this->_updatePercent(65);
|
|
|
-
|
|
|
- $this->calcBonusZoneBS($this->_sysConfig['openTravel']);
|
|
|
- $t18travel = microtime(true);
|
|
|
- echo('计算旅游奖' . ($this->_sysConfig['openTravel']['VALUE'] ? '完成' : '关闭') . ',耗时:' . round($t18travel - $t18temp, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $t20 = microtime(true);
|
|
|
+ echo('计算蓝星奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t20 - $t19, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(67);
|
|
|
|
|
|
- $this->calcBonusZoneBS($this->_sysConfig['openCar']);
|
|
|
- $t18car = microtime(true);
|
|
|
- echo('计算名车奖' . ($this->_sysConfig['openCar']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t18car - $t18travel, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $this->calcBonusTourism($this->_sysConfig['openTourism']);
|
|
|
+ $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);
|
|
|
|
|
|
- $this->calcBonusZoneBS($this->_sysConfig['openHouse']);
|
|
|
- $t18house = microtime(true);
|
|
|
- echo('计算豪宅奖' . ($this->_sysConfig['openHouse']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t18house - $t18car, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $this->calcBonusGarage($this->_sysConfig['openGarage']);
|
|
|
+ $t22 = microtime(true);
|
|
|
+ echo('计算车房奖' . ($this->_sysConfig['openGarage']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t22 - $t21, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(69);
|
|
|
|
|
|
|
|
|
+
|
|
|
//把奖金会员写入缓存
|
|
|
$this->loopMonthBonusUserFromDbToCache();
|
|
|
- $t19 = microtime(true);
|
|
|
- echo('奖金会员写入缓存完成,耗时:' . round($t19 - $t18, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $t30 = microtime(true);
|
|
|
+ echo('奖金会员写入缓存完成,耗时:' . round($t30 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(70);
|
|
|
|
|
|
//奖金写库
|
|
|
@@ -318,13 +319,13 @@ class BonusCalc extends BaseObject {
|
|
|
$this->loopCalcBlueEmpLv();
|
|
|
$this->_updatePercent(75);
|
|
|
unset($calcWrite);
|
|
|
- $t20 = microtime(true);
|
|
|
- echo('奖金写库操作完成,耗时:' . round($t20 - $t19, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $t31 = microtime(true);
|
|
|
+ echo('奖金写库操作完成,耗时:' . round($t31 - $t30, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
|
|
|
//把本期奖金会员入库 - 把缓存中的月奖用户信息存到数据库.存储过程的入库不在这里进行,这里代码取的缓存,存储过程没有缓存,在上面进行入库
|
|
|
$this->loopMonthBonusUserToDb();
|
|
|
- $t21 = microtime(true);
|
|
|
- echo('奖金会员入库完成,耗时:' . round($t21 - $t20, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $t32 = microtime(true);
|
|
|
+ echo('奖金会员入库完成,耗时:' . round($t32 - $t31, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(80);
|
|
|
|
|
|
// 计算基础积分,不可以奖金入库之前计算这样可能会丢掉只有本期的奖金的会员
|
|
|
@@ -338,11 +339,8 @@ class BonusCalc extends BaseObject {
|
|
|
// $this->_updatePercent(100);
|
|
|
// $t23 = microtime(true);
|
|
|
// echo('积分写库操作完成,耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
-
|
|
|
- //@todo 计算房产奖
|
|
|
-
|
|
|
- $t30 = microtime(true);
|
|
|
- echo('结算全部完成,共耗时:' . round($t30 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
+ $t35 = microtime(true);
|
|
|
+ echo('结算全部完成,共耗时:' . round($t35 - $t34, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
} catch (\Exception $e) {
|
|
|
$this->errorCalcTask();
|
|
|
$this->addError('calc', $e->getMessage());
|
|
|
@@ -444,7 +442,8 @@ class BonusCalc extends BaseObject {
|
|
|
CalcBonusVIP::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
CalcBonusStandard::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
ScoreMonth::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
- CalcBonusZone::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
+ CalcBonusTourism::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
+ CalcBonusGarage::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1632,8 +1631,8 @@ class BonusCalc extends BaseObject {
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- // 执行旅游奖、名车奖、豪宅奖的计算
|
|
|
- public function calcBonusZoneBS(array $bonusConfig) {
|
|
|
+ // 执行旅游奖的计算
|
|
|
+ public function calcBonusTourism(array $bonusConfig) {
|
|
|
// 月结,如果不是月结点,则直接退出
|
|
|
if (!$this->_isCalcMonth) {
|
|
|
return true;
|
|
|
@@ -1662,38 +1661,105 @@ class BonusCalc extends BaseObject {
|
|
|
$userBonusData = CalcBonusBS::find()
|
|
|
->yearMonth($this->_calcYearMonth)
|
|
|
->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
|
|
|
- ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS,RECONSUME_POINTS')
|
|
|
+ ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS')
|
|
|
->groupBy('USER_ID')
|
|
|
->asArray()
|
|
|
->all();
|
|
|
|
|
|
- // 获奖会员数
|
|
|
- $userBonusNumber = count($userBonusData);
|
|
|
- if (!$userBonusNumber) {
|
|
|
- return true;
|
|
|
+ $insertBonusData = [];
|
|
|
+ foreach($userBonusData as $userBonus) {
|
|
|
+ // TODO:基于绩效奖,获取会员starCrown级别,计算奖金
|
|
|
+ $startCrownPoint = (mt_rand(10, 75) / 10) / 100;
|
|
|
+ $amount = Tool::formatPrice(($monthTotalPV * $mate) * $startCrownPoint);
|
|
|
+ if ($amount <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 会员级别+聘级都达到要求才会发放奖金
|
|
|
+ if (in_array($userBonus['LAST_DEC_LV'], $minDecLevel) && in_array($userBonus['LEVEL_ID'], $minEmpLevel)) {
|
|
|
+ // 放入缓存
|
|
|
+ CalcCache::tourismBonus($userBonus['USER_ID'], $this->_periodNum, $amount);
|
|
|
+ // 加入月奖的会员
|
|
|
+ CalcCache::addHasMonthBonusUsers($userBonus['USER_ID'], $this->_periodNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ $insertBonusData[] = [
|
|
|
+ 'ID' => SnowFake::instance()->generateId(),
|
|
|
+ 'USER_ID' => $userBonus['USER_ID'],
|
|
|
+ 'LEVEL_ID' => $userBonus['LEVEL_ID'],
|
|
|
+ 'LAST_DEC_LV' => $userBonus['LAST_DEC_LV'],
|
|
|
+ 'LAST_EMP_LV' => $userBonus['LAST_EMP_LV'],
|
|
|
+ 'LAST_STATUS' => $userBonus['LAST_STATUS'],
|
|
|
+ 'AMOUNT' => $amount,
|
|
|
+ 'PERIOD_NUM' => $this->_periodNum,
|
|
|
+ 'CALC_YEAR' => $this->_calcYear,
|
|
|
+ 'CALC_MONTH' => $this->_calcYearMonth,
|
|
|
+ 'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
|
|
|
+ 'CREATED_AT' => Date::nowTime(),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 数据写入总表
|
|
|
+ if ($insertBonusData) {
|
|
|
+ CalcBonusTourism::batchInsert($insertBonusData);
|
|
|
}
|
|
|
|
|
|
- // 计算奖金:(公司月总PV * 奖金比) / 得奖人数
|
|
|
- $amount = Tool::formatPrice(($monthTotalPV * $mate) / $userBonusNumber);
|
|
|
- if ($amount <= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行车房奖的计算
|
|
|
+ public function calcBonusGarage($bonusConfig) {
|
|
|
+ // 月结,如果不是月结点,则直接退出
|
|
|
+ if (!$this->_isCalcMonth) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- // 奖金标识
|
|
|
- if ($bonusConfig['CONFIG_NAME'] == 'openTravel') {
|
|
|
- $bonusCacheKey = 'calc:travel:bonus_';
|
|
|
- } else if ($bonusConfig['CONFIG_NAME'] == 'openCar') {
|
|
|
- $bonusCacheKey = 'calc:car:bonus_';
|
|
|
- } else {
|
|
|
- $bonusCacheKey = 'calc:house:bonus_';
|
|
|
+ // 达标条件:聘级、级别、奖项比例
|
|
|
+ $config = json_decode($bonusConfig['OPTIONS'], true);
|
|
|
+ // 奖金总比例
|
|
|
+ $mate = $bonusConfig['VALUE'] / 100;
|
|
|
+ // 会员级别
|
|
|
+ $minDecLevel = $config['OPTIONS']['declarationLevel'] ?? [];
|
|
|
+ // 会员聘级
|
|
|
+ $minEmpLevel = $config['OPTIONS']['employLevel'] ?? [];
|
|
|
+ // 个人奖金封顶
|
|
|
+ $capBonus = intval($this->_sysConfig['openGarageCap']['VALUE'] ?? 0);
|
|
|
+
|
|
|
+ // 月度公司总PV
|
|
|
+ $monthTotalPV = PerfMonth::find()
|
|
|
+ ->yearMonth($this->_calcYearMonth)
|
|
|
+ ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
|
|
|
+ ->sum('PV_PCS');
|
|
|
+
|
|
|
+ if ($monthTotalPV <= 0) {
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
+ // 基于蓝星奖结果计算符合获奖条件的会员
|
|
|
+ $userBonusData = CalcBonusBS::find()
|
|
|
+ ->yearMonth($this->_calcYearMonth)
|
|
|
+ ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
|
|
|
+ ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS,RECONSUME_POINTS')
|
|
|
+ ->groupBy('USER_ID')
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
+
|
|
|
$insertBonusData = [];
|
|
|
foreach($userBonusData as $userBonus) {
|
|
|
+ // TODO:基于绩效奖,获取会员starCrown级别,计算奖金
|
|
|
+ $startCrownPoint = mt_rand(1, 10) / 100;
|
|
|
+ $amount = Tool::formatPrice(($monthTotalPV * $mate) * $startCrownPoint);
|
|
|
+ if ($amount <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 奖金数不能大于封顶值
|
|
|
+ $amount = ($amount > $capBonus) ? $capBonus : $amount;
|
|
|
+
|
|
|
// 会员级别+聘级都达到要求才会发放奖金
|
|
|
if (in_array($userBonus['LAST_DEC_LV'], $minDecLevel) && in_array($userBonus['LEVEL_ID'], $minEmpLevel)) {
|
|
|
// 放入缓存
|
|
|
- CalcCache::zoneBonus($userBonus['USER_ID'], $this->_periodNum, $bonusCacheKey, $amount);
|
|
|
+ CalcCache::garageBonus($userBonus['USER_ID'], $this->_periodNum, $amount);
|
|
|
// 加入月奖的会员
|
|
|
CalcCache::addHasMonthBonusUsers($userBonus['USER_ID'], $this->_periodNum);
|
|
|
}
|
|
|
@@ -1711,13 +1777,12 @@ class BonusCalc extends BaseObject {
|
|
|
'CALC_MONTH' => $this->_calcYearMonth,
|
|
|
'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
|
|
|
'CREATED_AT' => Date::nowTime(),
|
|
|
- 'BONUS_TYPE' => $bonusConfig['CONFIG_NAME'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
// 数据写入总表
|
|
|
if ($insertBonusData) {
|
|
|
- CalcBonusZone::batchInsert($insertBonusData);
|
|
|
+ CalcBonusGarage::batchInsert($insertBonusData);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
@@ -3379,9 +3444,8 @@ class BonusCalc extends BaseObject {
|
|
|
$standardBonus = CalcCache::standardBonus($userId, $this->_periodNum);
|
|
|
$baseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
|
|
|
$perfData = CalcCache::nowPeriodPerf($userId, $this->_periodNum);
|
|
|
- $travelBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_TRAVEL_BONUS);
|
|
|
- $carBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_CAR_BONUS);
|
|
|
- $houseBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_HOUSE_BONUS);
|
|
|
+ $tourismBonus = CalcCache::tourismBonus($userId, $this->_periodNum);
|
|
|
+ $garageBonus = CalcCache::garageBonus($userId, $this->_periodNum);
|
|
|
$empLv = $baseInfo['EMP_LV'];
|
|
|
// if($this->_isCalcMonth){
|
|
|
// $empLv = $this->nowMonthPerfData($userId)['LAST_EMP_LV'];
|
|
|
@@ -3553,9 +3617,8 @@ class BonusCalc extends BaseObject {
|
|
|
'ORI_BONUS_VIP' => $bonus['ORI_BONUS_VIP'],
|
|
|
'ORI_BONUS_STANDARD' => $standardBonus,
|
|
|
|
|
|
- 'BONUS_TRAVEL' => $travelBonus, // 旅游奖
|
|
|
- 'BONUS_CAR' => $carBonus, // 名车奖
|
|
|
- 'BONUS_HOUSE' => $houseBonus, // 豪宅奖
|
|
|
+ 'BONUS_TOURISM' => $tourismBonus, // 旅游奖
|
|
|
+ 'BONUS_GARAGE' => $garageBonus, // 车房奖
|
|
|
|
|
|
//以下没有用
|
|
|
'BONUS_FW' => 0,
|