|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace common\helpers\bonus\Calc;
|
|
|
|
|
|
+use common\components\ActiveRecord;
|
|
|
use common\helpers\Date;
|
|
|
use common\models\CalcBonus;
|
|
|
use common\models\CalcBonusBD;
|
|
|
@@ -33,6 +34,23 @@ 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'],
|
|
|
+ 'AR_BS_BONUS_103_CALC_EVENT' => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_BS_BONUS_103_CALC_EVENT'],
|
|
|
+ '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_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'],
|
|
|
+ 'AR_CALC_BONUS_BS_DETAIL_BONUS' => ['type' => 'same', 'general_clear' => true, 'table' => 'AR_CALC_BONUS_BS_DETAIL_BONUS'],
|
|
|
+ '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'],
|
|
|
+
|
|
|
'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'],
|
|
|
@@ -270,6 +288,16 @@ class PullCalcBonusData extends BaseBusiness
|
|
|
// CalcBonusYJ::pageDeleteAll('PERIOD_NUM=' . $this->_periodNum);
|
|
|
// CalcBonusGX::pageDeleteAll('PERIOD_NUM=' . $this->_periodNum);
|
|
|
// CalcBonusGL::pageDeleteAll('PERIOD_NUM=' . $this->_periodNum);
|
|
|
+
|
|
|
+ foreach (self::BASE_INFO_METHODS as $info) {
|
|
|
+ if ('same' == $info['same'] && isset($info['general_clear']) && $info['general_clear']) {
|
|
|
+ $res = self::pageDeleteAll($info['table'], 'PERIOD_NUM=' . $this->_periodNum);
|
|
|
+ if (!$res) {
|
|
|
+ CalcRecord::record($this->_periodNum, '第' . $this->_periodNum . '期的' . $info['table'] . '表清理失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 月结时要清空的数据
|
|
|
if ($this->_isCalcMonth) {
|
|
|
// CalcBonusYC::pageDeleteAll('PERIOD_NUM=' . $this->_periodNum);
|
|
|
@@ -282,4 +310,33 @@ class PullCalcBonusData extends BaseBusiness
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $table
|
|
|
+ * @param $where
|
|
|
+ * @return bool
|
|
|
+ * @see ActiveRecord::pageDeleteAll()
|
|
|
+ */
|
|
|
+ public static function pageDeleteAll($table = null, $where = '')
|
|
|
+ {
|
|
|
+ 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();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ($affectRow == $limit) {
|
|
|
+ unset($limit, $sql, $affectRow);
|
|
|
+ return self::pageDeleteAll($table, $where);
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($limit, $sql, $affectRow);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|