Jelajahi Sumber

feat: NG-71: 会员奖金计算调整

kevin 1 tahun lalu
induk
melakukan
a5f59490fd
1 mengubah file dengan 2 tambahan dan 30 penghapusan
  1. 2 30
      common/helpers/bonus/BonusSend.php

+ 2 - 30
common/helpers/bonus/BonusSend.php

@@ -313,11 +313,8 @@ class BonusSend extends BaseObject {
         $periodNum = $this->_periodNum;
         // 从奖金结算表中获取当期未发放的所有数据
         $allData = CalcBonus::find()
-            ->yearMonth($this->_calcYearMonth)
             ->select('ID, USER_ID, PERIOD_NUM, BONUS_TOTAL, MANAGE_TAX, BONUS_PB')
-            ->where('(IS_SENT=0 OR IS_SENT=2) AND CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM',
-                [':CALC_MONTH' => $this->_calcYearMonth, ':PERIOD_NUM' => $this->_periodNum]
-            )
+            ->where('IS_SENT=0 AND PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum])
             ->asArray()
             ->all();
 
@@ -351,19 +348,15 @@ class BonusSend extends BaseObject {
 
                     unset($key, $data);
                 }
+
                 $transaction->commit();
             } catch (Exception $e) {
                 $transaction->rollBack();
                 $this->addError('sendBonus', '奖金发放失败,原因:' . $e->getFile() . ' ' . $e->getLine() . '  ' . $e->getMessage());
                 return false;
             }
-
-            unset($allData, $transaction);
-            $page++;
-            return $this->sendBonusLoop($page);
         }
 
-        unset($allData);
         return true;
     }
 
@@ -855,27 +848,6 @@ SQL;
         return false;
     }
 
-    /**
-     * 点位合作奖金
-     * @param $userId
-     * @param $amount
-     * @param null $type
-     * @return bool
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    private function _teamworkBonus($userId, $amount, $key) {
-        if (!$teamwork = UserTeamwork::findAllAsArray('USER_ID!=:MAIN_UID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userId], 'USER_ID,DIVIDE_PERCENT')) return false;
-        $fromUserInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
-        foreach ($teamwork as $value) {
-            $bonus = Tool::formatPrice($amount * $value['DIVIDE_PERCENT'] * 0.01);
-            if ($bonus <= 0) continue;
-            $toUserInfo = CalcCache::getUserInfo($value['USER_ID'], $this->_periodNum);
-            Balance::changeUserBonus($userId, 'bonus', -abs($bonus), ['SORT' => $key*10+1, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_OUT, 'REMARK' => 'To:' . $toUserInfo['USER_NAME'] . ' Per:' . $value['DIVIDE_PERCENT'] . '%']);
-            Balance::changeUserBonus($value['USER_ID'], 'bonus', abs($bonus), ['SORT' => $key*10+2, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_IN, 'REMARK' => 'From: ' . $fromUserInfo['USER_NAME'] . ' Per:' . $value['DIVIDE_PERCENT'] . '%']);
-        }
-    }
-
     /**
      * 发送短信
      * @param int $offset