|
|
@@ -16,6 +16,7 @@ use common\helpers\Tool;
|
|
|
use common\models\CalcBonus;
|
|
|
use common\models\CalcBonusBD;
|
|
|
use common\models\CalcBonusBS;
|
|
|
+use common\models\CalcBonusQuarter;
|
|
|
use common\models\CalcBonusBT;
|
|
|
use common\models\CalcBonusCF;
|
|
|
use common\models\CalcBonusFL;
|
|
|
@@ -314,6 +315,12 @@ class BonusCalc extends BaseObject {
|
|
|
echo('计算车奖' . ($this->_sysConfig['openGarage']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL . PHP_EOL);
|
|
|
$this->_updatePercent(69);
|
|
|
|
|
|
+ // 计算季度奖
|
|
|
+ $this->calcQuarter();
|
|
|
+ // 将用户写入缓存
|
|
|
+ $this->calcQuarterUser();
|
|
|
+ $t24 = microtime(true);
|
|
|
+ echo('计算季度奖' . ($this->_sysConfig['openQuarter']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t24 - $t23, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL . PHP_EOL);
|
|
|
|
|
|
//把奖金会员写入缓存
|
|
|
$this->loopMonthBonusUserFromDbToCache();
|
|
|
@@ -1642,6 +1649,23 @@ class BonusCalc extends BaseObject {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 季度奖计算
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function calcQuarter() {
|
|
|
+ if( !$this->_isCalcMonth || !in_array($this->_calcMonth, [3,6,9,12])) {
|
|
|
+ // 不是结算月,则不进行计算
|
|
|
+ print_r('不是季结点,进这里,不计算季度奖');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $result = \Yii::$app->db->createCommand("CALL QtrCalc(:periodNum)")
|
|
|
+ ->bindValue(':periodNum' , $this->_periodNum )
|
|
|
+ ->execute();
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
// 执行蓝星管理奖金的存储过程
|
|
|
public function calcBsProcedure() {
|
|
|
if( !$this->_isCalcMonth ) {
|
|
|
@@ -1982,6 +2006,55 @@ class BonusCalc extends BaseObject {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 季度奖写用户缓存
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public function calcQuarterUser(int $offset = 0) {
|
|
|
+ if( !$this->_isCalcMonth || !in_array($this->_calcMonth, [3,6,9,12])) {
|
|
|
+ // 不是结算月,则不进行计算
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $allData = CalcBonusQuarter::finduseDbCalc()
|
|
|
+ ->where('PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum])
|
|
|
+ ->groupBy('USER_ID')
|
|
|
+ ->offset($offset)
|
|
|
+ ->limit($this->_limit)
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
+ if ($allData){
|
|
|
+ // 达标条件:会员级别:钻卡
|
|
|
+ $config = json_decode($this->_sysConfig['openGL']['OPTIONS'], true);
|
|
|
+ $minDecLevel = $config['mntDec'] ?? [];
|
|
|
+
|
|
|
+ foreach ($allData as $user) {
|
|
|
+ // 扣除相应的复消积分和管理费
|
|
|
+ $deductData = $this->deduct($user['USER_ID'], $user['ORI_BONUS']);
|
|
|
+ $realBonusBs = $deductData['surplus']; // 扣除管理费和复消积分后的实发蓝星奖金
|
|
|
+ $manageTax = $deductData['manageTax']; // 管理费
|
|
|
+ $point = $deductData['reConsumePoints'] + $user['RECONSUME_POINTS'];// 复消积分
|
|
|
+ // 管理奖钻卡发放
|
|
|
+// if (in_array($user['LAST_DEC_LV'], $minDecLevel)) {
|
|
|
+ // 把对碰后的奖金存入缓存中
|
|
|
+ CalcCache::bonus($user['USER_ID'], $this->_periodNum, 'BONUS_QUARTER', $user['ORI_BONUS'], $deductData);
|
|
|
+ // 加入月奖的会员
|
|
|
+ CalcCache::addHasMonthBonusUsers($user['USER_ID'], $this->_periodNum);
|
|
|
+// }
|
|
|
+
|
|
|
+ // 更新蓝星奖金存储过程的实发金额数据
|
|
|
+ CalcBonusQuarter::updateAll([
|
|
|
+ 'RECONSUME_POINTS' => $point,
|
|
|
+ 'AMOUNT' => $realBonusBs,
|
|
|
+ 'MANAGE_TAX' => $manageTax],
|
|
|
+ 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
|
|
|
+ [':USER_ID' => $user['USER_ID'], ':PERIOD_NUM' => $this->_periodNum]);
|
|
|
+ }
|
|
|
+ return $this->calcQuarterUser($offset + $this->_limit);
|
|
|
+ }
|
|
|
+ unset($allData);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 蓝星管理奖金
|
|
|
* @param int $offset
|
|
|
@@ -3724,10 +3797,10 @@ class BonusCalc extends BaseObject {
|
|
|
|
|
|
$monthSumData = CalcBonus::findUseSlaves()
|
|
|
->select('SUM(BONUS_GX) AS BONUS_GX_SUM, SUM(BONUS_GL) AS BONUS_GL_SUM')
|
|
|
- ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
+ ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',
|
|
|
[
|
|
|
- 'USER_ID'=>$userId,
|
|
|
- 'CALC_MONTH'=>$this->_calcYearMonth
|
|
|
+ 'USER_ID' => $userId,
|
|
|
+ 'CALC_MONTH' => $this->_calcYearMonth
|
|
|
]
|
|
|
)
|
|
|
->asArray()
|
|
|
@@ -3742,6 +3815,11 @@ class BonusCalc extends BaseObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if( $this->_isCalcMonth ) { //季度奖
|
|
|
+ if(in_array($this->_calcMonth, [3,6,9,12])){ // 季度奖
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$result = [
|
|
|
'USER_ID' => $userId,
|
|
|
'LAST_USER_NAME' => $baseInfo['USER_NAME'],
|
|
|
@@ -3815,6 +3893,8 @@ class BonusCalc extends BaseObject {
|
|
|
'ORI_BONUS_VIP' => $bonus['ORI_BONUS_VIP'],
|
|
|
'ORI_BONUS_STANDARD' => $standardBonus,
|
|
|
'ORI_CAPPED_BONUS_QY' => $bonus['ORI_CAPPED_BONUS_QY'], // 团队奖封顶前的奖金
|
|
|
+ 'BONUS_QUARTER' => $bonus['BONUS_QUARTER'],
|
|
|
+ 'ORI_BONUS_QUARTER' => $bonus['ORI_BONUS_QUARTER'],
|
|
|
|
|
|
'BONUS_TOURISM' => $tourismBonus, // 旅游奖
|
|
|
'BONUS_VILLA' => $villaBonus, // 房奖
|