예제 #1
0
 /**
  * @return JsonModel
  */
 public function listAction()
 {
     $user = $this->zfcUserAuthentication()->getIdentity();
     if (UserHelper::isMerchant($user)) {
         $campaignsSQLResult = $this->getServiceLocator()->get('campaignService')->getActiveCampaigns($user->getAccount());
         return new JsonModel(CampaignFacade::formatCampaignList($campaignsSQLResult));
     }
 }
 /**
  * @param $accountId
  */
 public function deleteCampaignSettings($accountId)
 {
     $campaigns = CampaignFacade::formatCampaignList($this->serviceLocator->get('campaignService')->getActiveCampaigns($accountId));
     foreach ($campaigns as $campaign) {
         $customCampaignSettings = $this->entityManager->getRepository(self::CAMPAIGN_SETTINGS_ENTITY)->findOneBy(array('campaign_id' => $campaign['id']));
         if ($customCampaignSettings != null) {
             try {
                 $this->entityManager->remove($customCampaignSettings);
                 $this->entityManager->flush();
             } catch (\Exception $ex) {
                 throw new \Exception($ex->getMessage());
             }
         }
     }
 }
예제 #3
0
 /**
  * @return JsonModel
  */
 public function balancesAction()
 {
     $user = $this->zfcUserAuthentication()->getIdentity();
     if (UserHelper::isMerchant($user) && RequestHelper::isPost($this->getRequest())) {
         $customerCode = $this->getRequest()->getPost()->get('customerCode');
         $campaigns = \Campaign\Facade\CampaignFacade::formatCampaignList($this->getServiceLocator()->get('campaignService')->getActiveCampaigns($user->getAccount()));
         $customerAdapter = $this->getServiceLocator()->get('customerAdapter');
         $customerAdapter->setUser($user);
         foreach ($campaigns as $campaign) {
             $balances[] = $customerAdapter->getBalance($customerCode, $campaign['id']);
         }
         return new JsonModel(BalanceFacade::formatBalanceCollection($balances));
     }
 }