예제 #1
0
 /**
  * @return JsonModel
  */
 public function balanceAction()
 {
     $user = $this->zfcUserAuthentication()->getIdentity();
     if (UserHelper::isMerchant($user) && RequestHelper::isPost($this->getRequest())) {
         $campaignId = $this->getRequest()->getPost()->get('campaignId');
         $customerCode = $this->getRequest()->getPost()->get('customerCode');
         $customerAdapter = $this->getServiceLocator()->get('customerAdapter');
         $customerAdapter->setUser($user);
         return new JsonModel(BalanceFacade::formatBalance($customerAdapter->getBalance($customerCode, $campaignId)));
     }
 }
예제 #2
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));
     }
 }