|
|
@@ -860,14 +860,27 @@ class BonusCalc extends BaseObject {
|
|
|
return false;
|
|
|
}
|
|
|
echo sprintf("时间:[%s]店服务奖金计算--紧缩方式,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
|
|
|
- $allData = CalcCache::getHasPerfUsers($this->_periodNum, $offset, $this->_limit);
|
|
|
+// $allData = CalcCache::getHasPerfUsers($this->_periodNum, $offset, $this->_limit);
|
|
|
+ $condition = 'PERIOD_NUM=:PERIOD_NUM AND CALC_MONTH=:CALC_MONTH AND IS_STUDIO=:IS_STUDIO';
|
|
|
+ $params = [
|
|
|
+ ':PERIOD_NUM' => $this->_periodNum,
|
|
|
+ ':CALC_MONTH' => $this->_calcYearMonth,
|
|
|
+ ':IS_STUDIO' => 1,
|
|
|
+ ];
|
|
|
+ // 查询店铺
|
|
|
+ $allData = StorePerfLog::find()
|
|
|
+ ->where($condition, $params)
|
|
|
+ ->select('USER_ID, MONTH_PV, GROUP_PV')
|
|
|
+ ->asArray()
|
|
|
+ ->all();
|
|
|
|
|
|
if ($allData) {
|
|
|
$insertBonusData = [];
|
|
|
- foreach ($allData as $userId) {
|
|
|
- $storeBonus = $this->verifyStorePerf($userId);
|
|
|
- LoggerTool::debug(['calcStoreBonusReduce-0', $userId, $storeBonus]);
|
|
|
+ foreach ($allData as $data) {
|
|
|
+ $userId = $data['USER_ID'];
|
|
|
+ $storeBonus = $this->verifyStorePerfNew($userId, $data['GROUP_PV']);
|
|
|
if (empty($storeBonus)) continue;
|
|
|
+
|
|
|
// 判断此店铺是否是活跃用户,如果不活跃,则往上找一个活跃的店铺获得此奖
|
|
|
$isActive = $this->_isMonthPerfLimit($userId);
|
|
|
// 聘级列表
|
|
|
@@ -902,7 +915,7 @@ class BonusCalc extends BaseObject {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- $realBonusUserId = $bonusUserId ? $bonusUserId : $userId;
|
|
|
+ $realBonusUserId = $bonusUserId ?: $userId;
|
|
|
//扣除相应的复消积分和管理费
|
|
|
$deductData = $this->deduct($realBonusUserId, $storeBonus);
|
|
|
// 把对碰后的奖金存入缓存中
|
|
|
@@ -991,6 +1004,24 @@ class BonusCalc extends BaseObject {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public function verifyStorePerfNew($userId, $groupPv) {
|
|
|
+ // 业绩乘以比例为奖金
|
|
|
+ $storeBonus = Tool::formatPrice($groupPv * $this->_sysConfig['storePercent']['VALUE'] / 100);
|
|
|
+ if ($storeBonus <= 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 获取会员的报单级别
|
|
|
+ $userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
|
|
|
+ $storeBonus = $this->bonusTotalLimit($storeBonus, $userId, $userBaseInfo['REC_NUM'], $userBaseInfo['ZC_AMOUNT']);
|
|
|
+ if( $storeBonus <= 0 ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($perfPv, $userBaseInfo, $userId);
|
|
|
+
|
|
|
+ return $storeBonus;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过用户id,校验店服务奖,此用户是否有原奖金
|
|
|
*/
|
|
|
@@ -998,7 +1029,6 @@ class BonusCalc extends BaseObject {
|
|
|
// 从缓存中获取会员的业绩信息
|
|
|
$perfData = CalcCache::nowPeriodPerf($userId, $this->_periodNum);
|
|
|
if( !$perfData ) {
|
|
|
- LoggerTool::debug('verifyStorePerf-1-' . $userId);
|
|
|
return false;
|
|
|
}
|
|
|
// 获取小组+自己的业绩
|