示例#1
0
 private function setDescr()
 {
     $oModelVOrderJournal = new Borrower_Model_VOrderJournal();
     $oModelOrderCart = new Borrower_Model_OrderCart();
     $oModelOrderJournalOrderCart = new Borrower_Model_OrderJournalOrderCart();
     $oUserOrderJournal = $oModelVOrderJournal->getUserOrderJournal($this->getUserId());
     $nOrderCartId = $oModelOrderCart->getOrderCartId($this->getUserId());
     //pobiera id koszyka użytkownika
     foreach ($oUserOrderJournal as $oValue) {
         //sprawdza czy na pewno wszystkie zamówienia znajdują się w koszyku
         $bIsExists = $oModelOrderJournalOrderCart->findOrderJournal($oValue->id, $nOrderCartId);
         if (!$bIsExists) {
             $oModelOrderJournalOrderCart->addOrderJournalOrderCart(array("order_journal_id" => $oValue->id, "order_cart_id" => $nOrderCartId));
         }
     }
     $oCart = $oModelOrderJournalOrderCart->getCartJournals($nOrderCartId);
     //pobiera id czasopism znajdujących się w koszyku
     $nCartCount = $oCart->count();
     foreach ($oCart as $oValue) {
         $sPaymentDesc .= $oValue->order_journal_id;
         if ($nCartCount > 1) {
             $sPaymentDesc .= "; ";
         }
     }
     $sPaymentDesc = trim($sPaymentDesc);
     $this->_sDescr = "Zamówienie nr {$sPaymentDesc}";
 }
 public function makeactionAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper("layout")->disableLayout();
     $aJson = null;
     $oModelOrderJournal = new User_Model_OrderJournal();
     //$oModelSybase = new User_Model_Sybase();
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         $nOrderStatusId = (int) $aPostData["order_status_id"];
         $nOrderId = (int) $aPostData["order_id"];
         $bIsCanceled = $aPostData["is_canceled"];
         $aParam = $aPostData["param"];
         $nNewOrderStatusId = $nOrderStatusId + 1;
         if ($nOrderStatusId == 2) {
             if ($bIsCanceled === "true") {
                 $nNewOrderStatusId = 7;
                 $nItemId = $oModelOrderJournal->getOrderItemId($nOrderId);
                 //$oModelSybase->setItemStatusAndRequestable($nItemId, "s", "0");
                 $aJson = $oModelOrderJournal->changeStatus($nOrderId, $nNewOrderStatusId);
             } else {
                 if ($aParam["outer_magazine"] === "true") {
                     $nNewOrderStatusId = 2;
                     $aJson = $oModelOrderJournal->changeStatus($nOrderId, $nNewOrderStatusId);
                 } else {
                     $aJson = $oModelOrderJournal->changeStatus($nOrderId, $nNewOrderStatusId);
                 }
             }
         } else {
             if ($nOrderStatusId == 4) {
                 $oModelOrderCart = new Borrower_Model_OrderCart();
                 $oModelOrderJournalOrderCart = new Borrower_Model_OrderJournalOrderCart();
                 $nUserId = $oModelOrderJournal->getOrderUserId($nOrderId);
                 $nOrderCartId = $oModelOrderCart->addOrderCart($nUserId);
                 if (isset($nOrderCartId)) {
                     $nItemId = $oModelOrderJournal->getOrderItemId($nOrderId);
                     //$oModelSybase->setItemStatusAndRequestable($nItemId, "s", "0");
                     $oModelOrderJournalOrderCart->addOrderJournalOrderCart(array("order_journal_id" => $nOrderId, "order_cart_id" => $nOrderCartId));
                     $aJson = $oModelOrderJournal->changeStatus($nOrderId, $nNewOrderStatusId);
                 }
             }
         }
     }
     header("Content-type: application/json");
     echo Zend_Json::encode($aJson);
     exit;
 }
 public function statusAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper("layout")->disableLayout();
     if ($this->_request->isPost()) {
         $aPostData = $this->_request->getPost();
         $sHash = md5($aPostData["transaction_id"] . $aPostData["merchant_id"] . $aPostData["order_id"] . $aPostData["product_id"] . $aPostData["user_id"] . $aPostData["amount"] . $aPostData["descr"] . $aPostData["client_ip"] . $aPostData["time"] . $this->_sAuthKey2);
         if ($sHash === $aPostData["hash"]) {
             $oModelOrderPayment = new User_Model_OrderPayment();
             $oModelOrderJournal = new User_Model_OrderJournal();
             $oModelOrderFile = new User_Model_OrderFile();
             $oModelOrderCart = new Borrower_Model_OrderCart();
             $oModelOrderJournalOrderCart = new Borrower_Model_OrderJournalOrderCart();
             $oModelVOrderPaymentHistory = new User_Model_VOrderPaymentHistory();
             $sPathOld = APPLICATION_PATH . "/../files_scanned/";
             $sPathNew = APPLICATION_PATH . "/../../public_html/files_scanned/";
             $nOrderPaymentId = (int) $aPostData["order_id"];
             $nUserId = (int) $aPostData["user_id"];
             $nAmount = (int) $aPostData["amount"];
             $oOrderPayment = $oModelOrderPayment->getRow($nOrderPaymentId);
             if ($oOrderPayment->user_id === $nUserId && $oOrderPayment->amount === $nAmount && $oOrderPayment->is_ending !== 1) {
                 $oDb = Zend_Db_Table::getDefaultAdapter();
                 try {
                     if (!@is_dir($sPathNew)) {
                         if (!@mkdir($sPathNew, 0777)) {
                             throw new Zend_Exception();
                         }
                     }
                     if (!@is_dir($sPathOld)) {
                         throw new Zend_Exception();
                     }
                     $oDb->beginTransaction();
                     $oOrderJournal = $oModelVOrderPaymentHistory->getOrderJournal($nOrderPaymentId);
                     foreach ($oOrderJournal as $oRow) {
                         $nOrderJournalId = $oRow->order_journal_id;
                         if (!@is_dir($sPathNew . "user_id_" . $nUserId)) {
                             if (!@mkdir($sPathNew . "user_id_" . $nUserId, 0777)) {
                                 throw new Zend_Exception();
                             }
                         }
                         $oOrderFile = $oModelOrderFile->getRow($oRow->order_file_id);
                         if (!@copy($sPathOld . $oOrderFile->name, $sPathNew . "user_id_" . $nUserId . "/" . $oOrderFile->name)) {
                             throw new Zend_Exception();
                         }
                         $oModelOrderJournal->setOrderPaymentSuccess($nOrderJournalId);
                         $oMail = new AppCms2_Controller_Plugin_Mail();
                         $oMail->sendBorrowerOrderStatusInfo($nOrderJournalId, 5);
                     }
                     $oModelOrderPayment->editRow($nOrderPaymentId, array("is_ending" => 1, "date_is_ending" => time()));
                     $nOrderCartId = $oModelOrderCart->getOrderCartId($nUserId);
                     $oModelOrderJournalOrderCart->deleteCartJournals($nOrderCartId);
                     $oDb->commit();
                     echo "ACK";
                 } catch (Zend_Exception $e) {
                     $oDb->rollBack();
                 }
             }
         }
     }
     exit;
 }