Advertisement
nop1984

Untitled

Aug 24th, 2022
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1.     public function receiveSettlementReport($data, $no_throw) {
  2.         /** @todo clarify what we need to do
  3.          * this report is kind of "consolidated finantion operation data", we dont need this, client can see on ESAL website
  4.          */
  5.  
  6.         $result = [];
  7.  
  8.         foreach($data['billerReconUploadRq']['pmtBankRec'] as $rec1) {
  9.             foreach($rec1['pmtBranchRec'] as $rec2) {
  10.                 foreach($rec2['pmtRec'] as $rec3) {
  11.                     $sadadBillId = $rec3['pmtInfo']['billNumber'];
  12.  
  13.                     $result[$sadadBillId] = [
  14.                         'order_id' => null,
  15.                         'info' => $rec3
  16.                     ];
  17.  
  18.                     /** @var \Drupal\commerce_order\Entity\OrderInterface $order  */
  19.                     $order = \Drupal::entityTypeManager()->getStorage('commerce_order')->loadByProperties([
  20.                         'field_sadad_bills_id' => $sadadBillId
  21.                     ]);
  22.                     $order = @reset($order);
  23.                     if(empty($order)) {
  24.                         $ex = new OrderLoadFailException('field_sadad_bills_id', $sadadBillId);
  25.                         $this->logger->error($ex->getMessage());
  26.                         if($no_throw)
  27.                             continue;
  28.                         else {
  29.                             throw $ex; 
  30.                         }
  31.                     }
  32.  
  33.                     $result[$sadadBillId]['order_id'] = $order->id();
  34.  
  35.                     $order->field_esal_reports[] = json_encode($rec3);
  36.                     $order->save();
  37.                 }
  38.             }
  39.         }
  40.  
  41.         return $result;
  42.     }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement