brook 3 yıl önce
ebeveyn
işleme
c6edf5f4dc

+ 0 - 1
common/helpers/bonus/Calc/BaseBusiness.php

@@ -31,7 +31,6 @@ class BaseBusiness
             $this->_calcYear = $periodObj->getYear($periodNum);
             $this->_calcMonth     = $periodObj->getMonth($periodNum);
             $this->_calcYearMonth = $periodObj->getYearMonth($periodNum);
-            $this->_periodId = $periodObj->getPeriodIdByNumber($periodNum);
         } else {
             //todo
             return false;

+ 26 - 16
common/helpers/bonus/Calc/PullCalcBonusData.php

@@ -34,12 +34,12 @@ class PullCalcBonusData extends BaseBusiness
         'calcBonusQuarter' => ['type' => 'same', 'table' => 'AR_CALC_BONUS_QUARTER'],
         'calcBonusTourism' => ['type' => 'same', 'table' => 'AR_CALC_BONUS_TOURISM'],
 
-        'AR_BS_BONUS_103_CALC_1'        => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_1', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID'],
-        'AR_BS_BONUS_103_CALC_EVENT'    => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_EVENT'],
-        'AR_BS_BONUS_103_CALC_NET'      => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_NET'],
-        'AR_BS_BONUS_103_CALC_NET_1'    => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_NET_1'],
-        'AR_BS_BONUS_103_TEST'          => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_TEST'],
-        'AR_BS_BONUS_103_TEST_NET'      => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_TEST_NET'],
+        'AR_BS_BONUS_103_CALC_1'        => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_1', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_BS_BONUS_103_CALC_EVENT'    => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_EVENT', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_BS_BONUS_103_CALC_NET'      => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_NET', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_BS_BONUS_103_CALC_NET_1'    => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_NET_1', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_BS_BONUS_103_TEST'          => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_TEST', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_BS_BONUS_103_TEST_NET'      => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_TEST_NET', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
         'AR_CALC_BONUS_BS_CALC'         => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_CALC'],
         'AR_CALC_BONUS_BS_CHECKING'     => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_CHECKING'],
         'AR_CALC_BONUS_BS_DETAIL'       => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_DETAIL'],
@@ -47,17 +47,17 @@ class PullCalcBonusData extends BaseBusiness
         'AR_CALC_BONUS_BS_DETAIL_CALC'  => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_DETAIL_CALC'],
         'AR_CALC_BONUS_BS_DETAIL_GPV'   => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_DETAIL_GPV'],
         'AR_CALC_BONUS_BS_STAT'         => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_STAT'],
-        'AR_QTR_CALC_RECORD'            => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_RECORD'],
-        'AR_QTR_CALC_SCORE'             => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_SCORE'],
-        'AR_QTR_CALC_USER'              => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_USER'],
-        'AR_QTR_CALC_WEIGHT'            => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_WEIGHT'],
+
+        'AR_QTR_CALC_RECORD' => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_RECORD', 'condition_type' => 'id', 'condition_field' => 'CALC_PERIOD_ID', 'param_name' => '_periodNum'],
+        'AR_QTR_CALC_SCORE'  => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_SCORE', 'condition_type' => 'custom', 'condition' => 'group'],//2个 where
+        'AR_QTR_CALC_USER'   => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_USER'],
+        'AR_QTR_CALC_WEIGHT' => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_QTR_CALC_WEIGHT'],
 
         'calcBonusBd'     => ['type' => 'calc_month', 'table' => 'AR_CALC_BONUS_BD'],
         'calcBonusQy'     => ['type' => 'calc_month', 'table' => 'AR_CALC_BONUS_QY'],
         'calcBonusTg'     => ['type' => 'calc_month', 'table' => 'AR_CALC_BONUS_TG'],
         'calcBonusVilla'  => ['type' => 'calc_month', 'table' => 'AR_CALC_BONUS_VILLA'],
         'calcBonusGarage' => ['type' => 'calc_month', 'table' => 'AR_CALC_BONUS_GARAGE'],
-
     ];
 
     public function __construct($periodNum)
@@ -80,7 +80,14 @@ class PullCalcBonusData extends BaseBusiness
                     $_offset = 0;
                     sameBonus:
                     $offset = $_offset * $this->_limit;
-                    $data   = \Yii::$app->$db->createCommand("SELECT * from $table where PERIOD_NUM = $this->_periodNum limit $this->_limit offset $offset;")->queryAll();
+                    if (isset($info['condition_type']) && $info['condition_type'] == 'id' && isset($info['param_name '])) {
+                        $param = $info['param_name'];
+                        $data  = \Yii::$app->$db->createCommand("SELECT * from $table where " . $info['condition_field'] . " = $this->$param) limit $this->_limit offset $offset;")->queryAll();
+                    } elseif (isset($info['condition_type']) && $info['condition_type'] == 'custom' && $info['condition'] == 'group') {
+                        $data = \Yii::$app->$db->createCommand("SELECT * from $table where CALC_MONTH = $this->_calcMonth and CALC_YEAR=$this->_calcYear limit $this->_limit offset $offset;")->queryAll();
+                    } else {
+                        $data = \Yii::$app->$db->createCommand("SELECT * from $table where PERIOD_NUM = $this->_periodNum limit $this->_limit offset $offset;")->queryAll();
+                    }
                     if (!empty($data)) {
                         $fieldArray = array_keys($data[0]);
                         $_offset    += 1;
@@ -293,11 +300,15 @@ class PullCalcBonusData extends BaseBusiness
 
         foreach (self::BASE_INFO_METHODS as $info) {
             if ('same' == $info['same'] && isset($info['general_clear']) && $info['general_clear']) {
-                if (isset($info['condition_type']) && $info['condition_type'] == 'id') {
-                    $res = self::pageDeleteAll($info['table'], $info['condition_field'] . '=' . $this->_periodId);
+                if (isset($info['condition_type']) && $info['condition_type'] == 'id' && isset($info['param_name '])) {
+                    $param = $info['param_name'];
+                    $res   = self::pageDeleteAll($info['table'], $info['condition_field'] . '=' . $this->$param);
+                } else if (isset($info['condition_type']) && $info['condition_type'] == 'custom' && $info['condition'] == 'group') {
+                    $res = self::pageDeleteAll($info['table'], "CALC_MONTH = $this->_calcMonth and CALC_YEAR=$this->_calcYear")->queryAll();
                 } else {
                     $res = self::pageDeleteAll($info['table'], 'PERIOD_NUM=' . $this->_periodNum);
                 }
+
                 if (!$res) {
                     CalcRecord::record($this->_periodNum, '第' . $this->_periodNum . '期的' . $info['table'] . '表清理失败');
                 }
@@ -328,11 +339,10 @@ class PullCalcBonusData extends BaseBusiness
         if (empty($table)) {
             return false;
         }
-        $db    = self::CALC_DB_NAME;
         $limit = 10000;
         $sql   = sprintf('DELETE FROM %s WHERE %s LIMIT %d', $table, $where, $limit);
         try {
-            $affectRow = Yii::$app->$db->createCommand($sql)->execute();
+            $affectRow = Yii::$app->db->createCommand($sql)->execute();
         } catch (\Exception $e) {
             return false;
         }

+ 0 - 15
common/models/Period.php

@@ -892,19 +892,4 @@ class Period extends \common\components\ActiveRecord
 
         return false;
     }
-
-    /**
-     * 是否是结算月节点
-     * @param $periodNum
-     * @return mixed
-     * @throws Exception
-     */
-    public function getPeriodIdByNumber($periodNum = null){
-        $period = $this->setPeriodNum($periodNum);
-        if($period){
-            return $period['ID'];
-        } else {
-            throw new Exception('id对应的期数不存在');
-        }
-    }
 }