Пример #1
0
 public function checkifgoodpublish($reqId)
 {
     $tbl = new Application_Model_DbTable_Transactions(Np_Db::slave());
     $select = $tbl->select();
     $select->where('request_id=?', $reqId)->where('message_type = "Publish_response" ')->where("reject_reason_code is NULL OR reject_reason_code = '' ");
     $result = $select->query();
     $rows = $result->fetchAll();
     foreach ($rows as $row) {
         $publish_update_result = Application_Model_Cron::updateGoodPublish($row['request_id'], substr($row['trx_no'], 0, 2));
     }
     return;
 }
Пример #2
0
 /**
  * saveTransactionDB saves data to Transactions table in db
  * @return bool db Success or Failure 
  */
 protected function saveTransactionsDB($TRX = FALSE)
 {
     $tbl = new Application_Model_DbTable_Transactions(Np_Db::master());
     if ($TRX != FALSE) {
         $trxNo = $TRX;
     } else {
         $trxNo = $this->request->getHeaderField("TRX_NO");
     }
     $msgType = $this->request->getHeaderField("MSG_TYPE");
     $portTime = $this->request->getBodyField('PORT_TIME');
     $rejectReasonCode = $this->request->getRejectReasonCode();
     $reqId = $this->request->getHeaderField('REQUEST_ID');
     if ($trxNo) {
         $data = array('trx_no' => $trxNo, 'request_id' => $reqId, 'message_type' => $msgType, 'ack_code' => $this->request->getAck(), 'target' => $this->request->getHeaderField("TO"));
         if (!$rejectReasonCode || $rejectReasonCode === NULL || $rejectReasonCode == "") {
             // do nothing
         } else {
             $data['reject_reason_code'] = $rejectReasonCode;
         }
         if ($msgType == "Update" || $msgType == "Request") {
             $data['requested_transfer_time'] = Application_Model_General::getDateTimeInSqlFormat($portTime);
         }
         if ($msgType == "Publish") {
             $data['donor'] = Application_Model_General::getDonorByReqId($reqId);
         }
         $res = $tbl->insert($data);
         return $res;
     } else {
         //this request if from internal - have to add trx_no
         //save to Transactions table trx_no  has to be consisten to id of the table
         $adapter = $tbl->getAdapter();
         $adapter->beginTransaction();
         try {
             $temp_trx_no = Application_Model_General::createRandKey(14);
             if (isset($this->data['request_id'])) {
                 $reqId = $this->data['request_id'];
             }
             $row_insert = array('trx_no' => $temp_trx_no, 'request_id' => $reqId, 'message_type' => $this->request->getHeaderField("MSG_TYPE"), 'ack_code' => $this->request->getAck(), 'target' => $this->request->getHeaderField("TO"));
             if (!$rejectReasonCode || $rejectReasonCode === NULL || $rejectReasonCode == "") {
                 // do nothing
             } else {
                 $row_insert['reject_reason_code'] = $rejectReasonCode;
             }
             if ($msgType == "Update" || $msgType == "Request" || $msgType == "Check" && Application_Model_General::isAutoCheck($reqId)) {
                 $row_insert['requested_transfer_time'] = Application_Model_General::getDateTimeInSqlFormat($portTime);
             }
             if ($msgType == "Publish") {
                 $row_insert['donor'] = Application_Model_General::getDonorByReqId($reqId);
             }
             $_id = $tbl->insert($row_insert);
             $id = substr("00000000000" . $_id, -12, 12);
             $trx_no = Application_Model_General::getSettings('InternalProvider') . $id;
             $ret = $tbl->update(array('trx_no' => $trx_no), "id = " . $_id);
             $this->request->setTrxNo($trx_no);
             $adapter->commit();
             return true;
         } catch (Exception $e) {
             error_log("Error on create record in transactions table: " . $e->getMessage());
             $adapter->rollBack();
             return false;
         }
     }
 }
Пример #3
0
 public function getTransActionsByRequestID($reqId = FALSE)
 {
     foreach ($reqId as $row => $val) {
         $request_ids[$row] = $reqId[$row]['request_id'];
     }
     $tbl = new Application_Model_DbTable_Transactions(Np_Db::slave());
     $select = $tbl->select();
     $select->where('request_id IN (?)', $request_ids)->order('id DESC');
     $result = $select->query()->fetchAll();
     //take the last one
     if ($result) {
         return $result;
     }
     return null;
 }
Пример #4
0
 /**
  * search transaction by request id and stage ()
  * @param string $request_id the id of the request
  * @param string $stage check, request, execute, etc
  * @param string $reject_reason_code
  */
 public static function getTransactions($request_id, $stage = null, $reject_reason_code = null)
 {
     $tbl = new Application_Model_DbTable_Transactions(Np_Db::slave());
     $select = $tbl->select();
     $select->where("request_id = ? ", (string) $request_id);
     if ($stage) {
         $select->where("message_type = ?", (string) $stage);
     }
     if ($reject_reason_code === 'null') {
         $select->where("reject_reason_code IS NULL OR reject_reason_code =''");
     } else {
         if (!empty($reject_reason_code)) {
             $select->where("reject_reason_code = ?", (string) $reject_reason_code);
         }
     }
     $results = $select->order('id DESC')->limit(1000)->query()->fetchAll();
     return $results;
 }