Ejemplo n.º 1
0
 private function insertTemp()
 {
     global $DB;
     $uid = $DB->val('SELECT uid FROM account WHERE id = ?i', $this->params['customerNumber']);
     if (!$uid) {
         $this->message = 'Not found user account (customerNumber)';
         return 200;
     }
     //проверка возможности зачисления по ID заказа
     //и если транзакция была раньше то проверяется и не был ли куплен заказ
     //если куплен то все ок если нет и делаем проверку checkOrder
     if ($this->params['orderId']) {
         $billing = new billing($uid);
         if (!$billing->checkOrder($this->params)) {
             $billing->cancelReserveById($this->params['orderId']);
             $this->message = 'Failed check order';
             return 200;
         }
     }
     $dups = $DB->val('SELECT id FROM account_operations_yd WHERE invoice_id = ?', $this->params['invoiceId']);
     if (!$dups) {
         $shopParams = $this->getShopParams();
         $descr = "Платеж через Яндекс.Кассу. Сумма - {$this->params['orderSumAmount']}, номер покупки - {$this->params['invoiceId']}";
         $descr .= $shopParams['op_descr'];
         $DB->insert('account_operations_yd', array('billing_id' => $this->params['customerNumber'], 'op_date' => $this->params['requestDatetime'], 'op_code' => $shopParams['op_code'], 'ammount' => $shopParams['ammount'], 'trs_sum' => $this->params['orderSumAmount'], 'descr' => $descr, 'invoice_id' => $this->params['invoiceId']), 'id');
         if ($DB->error) {
             //@todo: может лучше юзать techMessage ?
             //message в ЯД нигде не отображается случаем?
             $this->message = $DB->error;
             return 200;
         }
     }
     //если все ок
     return 0;
 }