/** * @return array|null * @throws \Exception */ public function loadLanguageAction() { $user = $this->zfcUserAuthentication()->getIdentity(); if (UserHelper::isMerchant($user)) { $accountId = $user->getAccount(); $customLanguage = $this->getServiceLocator()->get('settingService')->getCustomLanguage($accountId); return new JsonModel(SettingFacade::formatCustomLanguage($customLanguage)); } }
/** * @return JsonModel */ public function itemsAction() { $user = $this->zfcUserAuthentication()->getIdentity(); if (UserHelper::isMerchant($user) && RequestHelper::isPost($this->getRequest())) { $campaignId = $this->getRequest()->getPost()->get('campaignId'); $campaignService = $this->getServiceLocator()->get('campaignService'); return new JsonModel(ItemFacace::formatItemCollection($campaignService->getBuyXRewards($campaignId))); } }
/** * @return JsonModel * @throws \Exception */ public function customFieldsAction() { $user = $this->zfcUserAuthentication()->getIdentity(); if (UserHelper::isMerchant($user)) { $customFields = $this->getServiceLocator()->get('customerService')->getCustomFields($user->getAccount()); return new JsonModel(CustomFieldFacade::formatCustomFieldCollection($customFields)); } }
/** * @return JsonModel * @throws \Exception */ public function addPointsAction() { $user = $this->zfcUserAuthentication()->getIdentity(); if (UserHelper::isMerchant($user) && RequestHelper::isPost($this->getRequest())) { $customerCode = $this->getRequest()->getPost()->get('customerCode'); $campaignId = $this->getRequest()->getPost()->get('campaignId'); $amount = $this->getRequest()->getPost()->get('amount'); $promoId = $this->getRequest()->getPost()->get('promoId'); $authorization = $this->getRequest()->getPost()->get('authorization'); $transactionAdapter = $this->getServiceLocator()->get('transactionAdapter'); $transactionAdapter->setUser($user); if ($transactionAdapter->manuallyAddPoint($customerCode, $campaignId, $amount, $authorization, $promoId)) { return new JsonModel(array('message' => 'Transaction successfully done')); } } }