Quellcode durchsuchen

增加字段,月业绩增加小组业绩

root vor 3 Jahren
Ursprung
Commit
5686bd225e
2 geänderte Dateien mit 50 neuen und 1 gelöschten Zeilen
  1. 49 0
      common/helpers/bonus/CalcServeBonusCalc.php
  2. 1 1
      common/models/User.php

+ 49 - 0
common/helpers/bonus/CalcServeBonusCalc.php

@@ -186,6 +186,11 @@ class CalcServeBonusCalc extends BaseObject {
                 $this->loopUpdateMonthPerf();
             }
 
+            // 月业绩表,增加个人小组业绩字段
+            if ($this->_isCalcMonth) {
+                $this->loopMonthPerfBsPGS();
+            }
+
             if($this->_sysConfig['openFW']['VALUE']) {
                 $this->calcBonusBDStepOne();
                 $this->calcBonusBDStepTwo();
@@ -428,6 +433,50 @@ class CalcServeBonusCalc extends BaseObject {
         return true;
     }
 
+    // 月业绩表,增加个人小组业绩字段
+    // 此字段根据AR_CALC_BONUS_BS_DETAIL中GPV10字段来更新用户,如果月业绩表中无此用户,则新增一条数据。
+    public function loopMonthPerfBsPGS($offset = 0) {
+        echo sprintf("时间:[%s]月业绩表个人小组业绩更新,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        $allData = CalcBonusBsDetail::findUseDbCalc()
+        ->where('PERIOD_NUM=:PERIOD_NUM AND CALC_MONTH=:CALC_MONTH', [':PERIOD_NUM' => $this->_periodNum, ':CALC_MONTH' => $this->_calcYearMonth])
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            foreach ($allData as $data) {
+                $insertData=[];
+                // 查询月业绩表中是否有此用户数据
+                $hasMonthPerfInfo = PerfMonth::find()
+                ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID'=>$data['USER_ID'], ':CALC_MONTH' => $this->_calcYearMonth])
+                ->asArray()
+                ->one();
+                if ($hasMonthPerfInfo) {
+                    //存在数据,则更新月业绩表中的个人小组业绩
+                    // 期结算结果
+                    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
+                    ]);
+                } else {
+                    // 如果不存在,则月业绩表中添加一条数据进去
+                    $insertData[] = [
+                        'USER_ID' => $data['USER_ID'],
+                        'DIRECTOR_BONUS_PGS' => $data['GPV10'],
+                        'CALC_MONTH' => $this->_calcYearMonth,
+                        'CREATED_AT' => Date::nowTime()
+                    ];
+                    PerfMonth::batchInsert($insertData);
+                }
+            }
+            unset($allData);
+            return $this->loopMonthPerfBsPGS($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
+
     /**
      * 推广奖
      * @param int $offset

+ 1 - 1
common/models/User.php

@@ -468,6 +468,6 @@ class User extends \common\components\ActiveRecord
         ['USER_ID'=>$userId, 'CALC_MONTH'=>$calcYearMonth, 'PERIOD_NUM'=>$periodNum])
         ->SUM('PV_PCS');
 
-        return $pv >= $sysConfig['monthPcsPvFxCondition']['VALUE'];
+        return $pv >= $sysConfig['monthPcsPvFxCondition']['VALUE'] ? 1 : 0;
     }
 }