예제 #1
0
 public static function preparePreregistrationReqData($arOrder, $profileId, $arConfig)
 {
     $result = array();
     $result["sender"] = array("inn" => $arConfig["INN"]["VALUE"], "city" => static::getFilialAndCity($arConfig["CITY_DELIVERY"]["VALUE"]), "title" => $arConfig["NAME"]["VALUE"], "phone" => $arConfig["PHONE"]["VALUE"]);
     $inn = "";
     $city = "";
     $title = "";
     $phone = "";
     $address = "";
     if (isset($extraParams["location"])) {
         $city = $extraParams["location"];
     }
     $dbOrderProps = \CSaleOrderPropsValue::GetOrderProps($arOrder["ID"]);
     while ($arOrderProps = $dbOrderProps->Fetch()) {
         if ($arOrderProps["CODE"] == "COMPANY" || $arOrderProps["CODE"] == "FIO") {
             $title = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "INN") {
             $inn = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "PHONE") {
             $phone = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "LOCATION") {
             $location = $arOrderProps["VALUE"];
             $locDelivery = Adapter::mapLocation($location);
             // todo: if more than one
             $city = static::getFilialAndCity(key($locDelivery));
         }
         if ($arOrderProps["CODE"] == "ADDRESS") {
             $address = $arOrderProps["VALUE"];
         }
     }
     $arPacks = \CSaleDeliveryHelper::getBoxesFromConfig($profileId, $arConfig);
     $arPackagesParams = \CSaleDeliveryHelper::getRequiredPacks($arOrder["ITEMS"], $arPacks, 0);
     $result["cargos"] = array(array("common" => array("positionsCount" => count($arPackagesParams), "decription" => GetMessage("SALE_DH_PECOM_DESCRIPTION_GOODS"), "orderNumber" => $arOrder["ACCOUNT_NUMBER"], "paymentForm" => $arConfig["PAYMENT_FORM"]["VALUE"], "accompanyingDocuments" => false), "receiver" => array("inn" => $inn, "city" => $city, "title" => $title, "phone" => $phone, "addressStock" => $address), "services" => array("transporting" => array("payer" => array("type" => 1)), "hardPacking" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_RIGID_PACKING'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_RIGID_PAYER'))), "palletTransporting" => array("enabled" => !\CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_RIGID_PACKING') && \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_PALLETE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_PALLETE_PAYER'))), "insurance" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_INSURANCE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_INSURANCE_PAYER')), "cost" => intval($arOrder["PRICE"])), "sealing" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_PLOMBIR_ENABLE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_PLOMBIR_PAYER'))), "strapping" => array("enabled" => false), "documentsReturning" => array("enabled" => false), "delivery" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_DELIVERY_ENABLED'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_DELIVERY_PAYER'))))));
     return $result;
 }
예제 #2
0
 protected function createCalcParams()
 {
     if (!isset($this->arOrder["WEIGHT"])) {
         throw new \Exception(GetMessage("SALE_DH_PECOM_EXCPT_WEIGHT"));
     }
     $locationTo = "";
     $arLocation = Adapter::mapLocation($this->arOrder["LOCATION_TO"]);
     if (empty($arLocation)) {
         throw new \Exception(GetMessage("SALE_DH_PECOM_EXCPT_EMPTY_LOCATION"));
     }
     if (count($arLocation) > 1 && isset($this->arOrder["EXTRA_PARAMS"]["location"])) {
         $locationTo = $this->arOrder["EXTRA_PARAMS"]["location"];
     } elseif (count($arLocation) > 1 && !isset($this->arOrder["EXTRA_PARAMS"]["location"])) {
         throw new \Exception(GetMessage("SALE_DH_PECOM_EXCPT_MANY_LOCATIONS"));
     }
     if (count($arLocation) == 1) {
         $locationTo = key($arLocation);
     }
     if (!isset($this->arOrder["ITEMS"]) || !is_array($this->arOrder["ITEMS"]) || empty($this->arOrder["ITEMS"])) {
         throw new \Exception(GetMessage("SALE_DH_PECOM_EXCPT_EMPTY_ITEMS"));
     }
     $measureCoeff = 1000;
     $itemsStr = "";
     $loadingRange = true;
     $rigidPacking = \CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_OTHER_RIGID_PACKING');
     $arPacks = \CSaleDeliveryHelper::getBoxesFromConfig($this->profileId, $this->arConfig);
     $arPackagesParams = \CSaleDeliveryHelper::getRequiredPacks($this->arOrder["ITEMS"], $arPacks, 0);
     $this->packsCount = count($arPackagesParams);
     for ($i = $this->packsCount - 1; $i >= 0; $i--) {
         $item = $arPackagesParams[$i];
         $width = round(floatval($item["DIMENSIONS"]["WIDTH"]) / $measureCoeff, 2);
         $lenght = round(floatval($item["DIMENSIONS"]["LENGTH"]) / $measureCoeff, 2);
         $height = round(floatval($item["DIMENSIONS"]["HEIGHT"]) / $measureCoeff, 2);
         $volume = floatval($item["VOLUME"] / pow($measureCoeff, 3));
         if ($width > \CDeliveryPecom::$EXTRA_DIMENSIONS_SIZE || $lenght > \CDeliveryPecom::$EXTRA_DIMENSIONS_SIZE || $height > \CDeliveryPecom::$EXTRA_DIMENSIONS_SIZE || $item["WEIGHT"] > \CDeliveryPecom::$EXTRA_DEMENSIONS_WEIGHT) {
             $loadingRange = false;
         }
         $itemsStr .= 'places[' . $i . '][]=' . strval($width) . '&places[' . $i . '][]=' . strval($lenght) . '&places[' . $i . '][]=' . strval($height) . '&places[' . $i . '][]=' . strval($volume) . '&places[' . $i . '][]=' . strval($item["WEIGHT"] / 1000) . '&places[' . $i . '][]=' . ($loadingRange ? '1' : '0') . '&places[' . $i . '][]=' . ($rigidPacking && \CDeliveryPecom::getConfValue($this->arConfig, 'SERVICE_OTHER_RIGID_PAYER') == \CDeliveryPecom::$PAYER_BUYER ? '1' : '0');
     }
     if (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_OTHER_PLOMBIR_ENABLE') && \CDeliveryPecom::getConfValue($this->arConfig, 'SERVICE_OTHER_PLOMBIR_PAYER') == \CDeliveryPecom::$PAYER_BUYER) {
         $plombir = strval(intval(\CDeliveryPecom::getConfValue($this->arConfig, 'SERVICE_OTHER_PLOMBIR_COUNT')));
     } else {
         $plombir = "0";
     }
     if (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_OTHER_INSURANCE') && \CDeliveryPecom::getConfValue($this->arConfig, 'SERVICE_OTHER_INSURANCE_PAYER') == \CDeliveryPecom::$PAYER_BUYER) {
         $insurance = strval($this->arOrder["PRICE"]);
     } else {
         $insurance = "0";
     }
     $result = $itemsStr . '&take[town]=' . $this->arConfig["CITY_DELIVERY"]["VALUE"] . '&take[tent]=' . (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_TAKE_ENABLED') && \CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_TAKE_TENT_ENABLED') ? '1' : '0') . '&take[gidro]=' . (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_TAKE_ENABLED') && \CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_TAKE_HYDRO_ENABLED') ? '1' : '0') . '&take[speed]=0' . '&take[moscow]=0' . '&deliver[town]=' . $locationTo . '&deliver[tent]=' . (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_DELIVERY_ENABLED') && \CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_DELIVERY_TENT_ENABLED') ? '1' : '0') . '&delideliver[gidro]=' . (\CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_DELIVERY_ENABLED') && \CDeliveryPecom::isConfCheckedVal($this->arConfig, 'SERVICE_DELIVERY_HYDRO_ENABLED') ? '1' : '0') . '&deliver[speed]=0' . '&deliver[moscow]=0' . '&plombir=' . $plombir . '&strah=' . $insurance . '&ashan=0';
     return $result;
 }