コード例 #1
0
 protected function changeGroup() {
     $newGroupId = $this->rule->getCommissionGroupId();
     $this->getUserCommissionGroup()->setCommissionGroupId($newGroupId);
     if(!$this->getUserCommissionGroup()->isPersistent()) {
         $this->getUserCommissionGroup()->insert();
         $this->logMessage(sprintf('User was added to commission group %', $newGroupId));
         return;
     }
     $this->getUserCommissionGroup()->update(array(Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID));
     $this->logMessage(sprintf('Commission group for user %s in campaign %s was changed to %s',
         $this->getCurrentUserId(), $this->transaction->getCampaignId(), $newGroupId));
 }
コード例 #2
0
    /**
     * @param Pap_Db_Transaction $transaction
     * @return Pap_Db_Commission
     */
    protected function getCommissionForTransaction(Pap_Db_Transaction $transaction) {
        $commission = new Pap_Db_Commission();
        $commission->setCommissionTypeId($transaction->getCommissionTypeId());
        $commission->setGroupId($transaction->getCommissionGroupId());
        $commission->setTier($transaction->getTier());
        try {
            $commission->loadFromData(array(Pap_Db_Table_Commissions::TYPE_ID, Pap_Db_Table_Commissions::GROUP_ID));
        } catch (Gpf_Exception $e) {
            $userInGroup = Pap_Db_Table_UserInCommissionGroup::getInstance()->getUserCommissionGroup($transaction->getUserId(), $transaction->getCampaignId());
            $commission->setGroupId($userInGroup->getCommissionGroupId());
            try {
                $commission->loadFromData(array(Pap_Db_Table_Commissions::TYPE_ID, Pap_Db_Table_Commissions::GROUP_ID, Pap_Db_Table_Commissions::TIER));
            } catch (Gpf_Exception $e) {
                throw new Gpf_Exception($this->_('Unable to find commision for transaction id=' . $transaction->getId()));
            }
        }

        return $commission;
    }