// Улицата е еднозначно определена
             echo "<br>";
             echo "Намерен e точно една улица с посочения критерий.<br>";
             $receiverAddress->setStreetId($arrStreets[0]->getId());
         } else {
             // Улицата не е еднозначно определена и потребителят е необходимо да избере от възможностите
             echo "<br>";
             echo "Намерени са няколко улици с посочения критерий. Необходимо е да се избере една от възможностите.<br>";
             echo "За целите на този пример е избрана първата улица от резултатния списък.<br>";
             $receiverAddress->setStreetId($arrStreets[0]->getId());
         }
     }
 }
 $receiverAddress->setBlockNo($recieverData->address->blockNo);
 $receiverAddress->setStreetNo($recieverData->address->streetNo);
 $receiverAddress->setEntranceNo($recieverData->address->entranceNo);
 $receiverAddress->setFloorNo($recieverData->address->floorNo);
 $receiverAddress->setApartmentNo($recieverData->address->apartmentNo);
 echo "<br><br><br><br>";
 echo "Адрес на получател:<br>";
 echo "-------------------<br>";
 var_dump($receiverAddress);
 //-------------------------------------------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------------------------------------------
 // ОПРЕДЕЛЯНЕ НА ДАННИ ЗА ПОДАТЕЛ И ПОЛУЧАТЕЛ И ОТКРИВАНЕ НА ТОВАРИТЕЛНИЦА
 // ПОДАТЕЛ: Клиент на EPS
 // ПОЛУЧАТЕЛ: ИВАНОВИ ООД, с лице за контакт ИВАН ИВАНОВ, тел. 0888 888 888
 //-------------------------------------------------------------------------------------------------------------------
 // Данни за подател
 $sender = new ParamClientData();
 $sender->setClientId($senderClientData->getClientId());
function validateAddress($eps)
{
    $paramAddress = new ParamAddress();
    $paramAddress->setSiteId($_REQUEST['siteId']);
    $paramAddress->setStreetName($_REQUEST['streetName']);
    $paramAddress->setStreetType($_REQUEST['streetType']);
    $paramAddress->setStreetId($_REQUEST['streetId']);
    $paramAddress->setQuarterName($_REQUEST['quarterName']);
    $paramAddress->setQuarterType($_REQUEST['quarterType']);
    $paramAddress->setQuarterId($_REQUEST['quarterId']);
    $paramAddress->setStreetNo($_REQUEST['streetNo']);
    $paramAddress->setBlockNo($_REQUEST['blockNo']);
    $paramAddress->setEntranceNo($_REQUEST['entranceNo']);
    $paramAddress->setFloorNo($_REQUEST['floorNo']);
    $paramAddress->setApartmentNo($_REQUEST['apartmentNo']);
    $paramAddress->setAddressNote($_REQUEST['addressNote']);
    $paramAddress->setCommonObjectId((double) $_REQUEST['commonObjectId']);
    $paramAddress->setCoordX($_REQUEST['coordX']);
    $paramAddress->setCoordY($_REQUEST['coordY']);
    $arrJson = null;
    try {
        $result = $eps->validateAddress($paramAddress, 0);
        if ($result) {
            $arrJson = array("status" => 0, "message" => "OK", "exception" => "", "result" => "" + $result);
        } else {
            $arrJson = array("status" => 1, "message" => "Address is invalid", "exception" => "", "result" => "" + $result);
        }
    } catch (Exception $sf) {
        $arrJson = array("status" => 2, "message" => "Address is invalid", "exception" => $sf->getMessage(), "result" => "none");
    }
    return $arrJson;
}
示例#3
0
 /** Creates bill of loading
  * @param $data
  * @param $order
  * @return array
  */
 public function createBillOfLading($data, $order)
 {
     require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamCalculation.class.php';
     $this->_error = '';
     $bol = array();
     if (isset($this->resultLogin)) {
         try {
             $sender = new \ParamClientData();
             $sender->setClientId($this->resultLogin->getClientId());
             if ($this->config->get('speedy_telephone')) {
                 $senderPhone = new \ParamPhoneNumber();
                 $senderPhone->setNumber($this->config->get('speedy_telephone'));
                 $sender->setPhones(array(0 => $senderPhone));
             }
             $receiverAddress = new \ParamAddress();
             $receiverAddress->setSiteId($data['city_id']);
             if ($data['quarter']) {
                 $receiverAddress->setQuarterName($data['quarter']);
             }
             if ($data['quarter_id']) {
                 $receiverAddress->setQuarterId($data['quarter_id']);
             }
             if ($data['street']) {
                 $receiverAddress->setStreetName($data['street']);
             }
             if ($data['street_id']) {
                 $receiverAddress->setStreetId($data['street_id']);
             }
             if ($data['street_no']) {
                 $receiverAddress->setStreetNo($data['street_no']);
             }
             if ($data['block_no']) {
                 $receiverAddress->setBlockNo($data['block_no']);
             }
             if ($data['entrance_no']) {
                 $receiverAddress->setEntranceNo($data['entrance_no']);
             }
             if ($data['floor_no']) {
                 $receiverAddress->setFloorNo($data['floor_no']);
             }
             if ($data['apartment_no']) {
                 $receiverAddress->setApartmentNo($data['apartment_no']);
             }
             if ($data['note']) {
                 $receiverAddress->setAddressNote($data['note']);
             }
             $receiver = new \ParamClientData();
             $receiver->setPartnerName($order['firstname'] . ' ' . $order['lastname']);
             $receiverPhone = new \ParamPhoneNumber();
             $receiverPhone->setNumber($order['telephone']);
             $receiver->setPhones(array(0 => $receiverPhone));
             $receiver->setEmail($order['email']);
             $picking = new \ParamPicking();
             $picking->setClientSystemId(1310221100);
             //OpenCart
             $picking->setRef1($order['order_id']);
             if ($data['depth'] || $data['height'] || $data['width']) {
                 $size = new Size();
                 if ($data['depth']) {
                     $size->setDepth($data['depth']);
                 }
                 if ($data['height']) {
                     $size->setHeight($data['height']);
                 }
                 if ($data['width']) {
                     $size->setWidth($data['width']);
                 }
                 $picking->setSize($size);
             }
             if (!empty($data['fixed_time'])) {
                 $picking->setFixedTimeDelivery($data['fixed_time']);
             }
             $picking->setServiceTypeId($data['shipping_method_id']);
             if ($data['to_office'] && $data['office_id']) {
                 $picking->setOfficeToBeCalledId($data['office_id']);
             } else {
                 $receiver->setAddress($receiverAddress);
                 $picking->setOfficeToBeCalledId(null);
             }
             $picking->setBackDocumentsRequest($this->config->get('speedy_back_documents'));
             $picking->setBackReceiptRequest($this->config->get('speedy_back_receipt'));
             if ($this->config->get('speedy_from_office') && $this->config->get('speedy_office_id')) {
                 $picking->setWillBringToOffice(true);
                 $picking->setWillBringToOfficeId($this->config->get('speedy_office_id'));
             } else {
                 $picking->setWillBringToOffice(false);
             }
             $picking->setParcelsCount($data['count']);
             $picking->setWeightDeclared($data['weight']);
             $picking->setContents($data['contents']);
             $picking->setPacking($data['packing']);
             $picking->setPackId(null);
             $picking->setDocuments($this->config->get('speedy_documents'));
             $picking->setPalletized(false);
             $payerType = $this->getPayerType($order['order_id'], $data['shipping_method_cost']);
             if ($data['insurance']) {
                 if ($data['fragile']) {
                     $picking->setFragile(true);
                 } else {
                     $picking->setFragile(false);
                 }
                 $picking->setAmountInsuranceBase($data['totalNoShipping']);
                 /*
                                     if ($this->config->get('speedy_pricing') == 'free' || $this->config->get('speedy_pricing') == 'fixed') {
                                         $picking->setPayerTypeInsurance($payerType);
                                     } else {
                                         $picking->setPayerTypeInsurance($payerType);
                                     } */
                 $picking->setPayerTypeInsurance($payerType);
             } else {
                 $picking->setFragile(false);
             }
             $picking->setSender($sender);
             $picking->setReceiver($receiver);
             /*
                             if ($this->config->get('speedy_pricing') == 'free' || $this->config->get('speedy_pricing') == 'fixed') {
                                 $picking->setPayerType($payerType);
                             } else {
                                   $picking->setPayerType($payerType);
                             }
             */
             $picking->setPayerType($payerType);
             $picking->setTakingDate($data['taking_date']);
             if ($data['deffered_days']) {
                 $picking->setDeferredDeliveryWorkDays($data['deffered_days']);
             }
             if ($data['client_note']) {
                 $picking->setNoteClient($data['client_note']);
             }
             if ($data['cod']) {
                 $picking->setAmountCodBase($data['total']);
             } else {
                 $picking->setAmountCodBase(0);
             }
             $result = $this->ePSFacade->createBillOfLading($picking);
             $parcels = $result->getGeneratedParcels();
             $bol['bol_id'] = $parcels[0]->getParcelId();
             $bol['total'] = $result->getAmounts()->getTotal();
         } catch (\Exception $e) {
             $this->_error = $e->getMessage();
             $this->log->addError('Speedy :: createBillOfLading :: ' . $e->getMessage());
         }
     }
     return $bol;
 }