예제 #1
0
 /**
  * Return standard class from this class
  * @return stdClass
  */
 public function toStdClass()
 {
     $stdClass = new stdClass();
     $stdClass->clientId = $this->_clientId;
     $stdClass->partnerName = $this->_partnerName;
     $stdClass->objectName = $this->_objectName;
     if (isset($this->_address)) {
         $stdClass->address = $this->_address->toStdClass();
     }
     $stdClass->contactName = $this->_contactName;
     $arrStdClassParamPhoneNumber = array();
     if (isset($this->_phones)) {
         if (is_array($this->_phones)) {
             for ($i = 0; $i < count($this->_phones); $i++) {
                 $arrStdClassParamPhoneNumber[$i] = $this->_phones[$i]->toStdClass();
             }
         } else {
             $arrStdClassParamPhoneNumber[0] = $this->_phones->toStdClass();
         }
     }
     $stdClass->phones = $arrStdClassParamPhoneNumber;
     $stdClass->email = $this->_email;
     return $stdClass;
 }
     } else {
         throw new ClientException("Липса на резултат от паралелна калкулация за множество услуги.");
     }
 }
 echo "<br><br><br><br>";
 echo "Избрана услуга и дата на вземане:<br>";
 echo "---------------------------------<br>";
 echo "    Идентификатор на услуга: " . $serviceTypeID . "<br>";
 echo "    Дата на вземане        : " . $pickingData->takingDate . "<br>";
 //-------------------------------------------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------------------------------------------
 // ОПРЕДЕЛЯНЕ АДРЕС НА ПОЛУЧАТЕЛ
 //-------------------------------------------------------------------------------------------------------------------
 // Примерен адрес на получател: гр.БУРГАС, жк. СЛАВЕЙКОВ, бл.62, вх.2, ет.4, ап.12
 // Задаване на адрес на получател
 $receiverAddress = new ParamAddress();
 $receiverAddress->setSiteId($receiverSiteId);
 // При разбит адрес определяме компонентите на адреса
 // Ако адресът не е разбит на компоненти е позволено подаването на целия адрес в полето addressNote
 //     $receiverAddress->setAddressNote("к-с СЛАВЕЙКОВ, бл.62, вх.2, ет.4, ап.12, МЕТАЛНАТА РЕШЕТКА СРЕЩУ АСАНСЬОРА")
 // В addressNote се попълва само адреса в рамките на населеното място (т.е. без самото наименование на населеното място)
 // Използването на този метод на работа не се препоръчва, защото при послдващата обработка на пратката може да се получи
 // нееднозначност на адреса, която от своя страна може да доведе до евентуално забавяне на доставката
 // Определяне на квартал
 if (!is_null($recieverData->address->quarter)) {
     echo "<br><br>";
     echo "Извличане на квартали [listQuarters]:<br>";
     echo "-------------------------------------<br>";
     echo "Параметри:<br>";
     echo "    {name}  : " . $recieverData->address->quarter . "<br>";
     echo "    {siteId}: " . $receiverSiteId . "<br>";
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;
}
예제 #4
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;
 }