Пример #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
 public static function executeAction($actionId, $profileId, $arOrder, $arConfig)
 {
     $reqResult = array();
     $result = array();
     switch ($actionId) {
         case "REQUEST_SELF":
             $controller = 'preregistration';
             $action = 'submit';
             $data = Adapter::preparePreregistrationReqData($arOrder, $profileId, $arConfig);
             $reqResult = static::sendRequest($arConfig["LOGIN"]["VALUE"], $arConfig["KEY"]["VALUE"], $controller, $action, $data);
             if (isset($reqResult["DATA"]["cargos"][0]["cargoCode"])) {
                 $result["TRACKING_NUMBER"] = $reqResult["DATA"]["cargos"][0]["cargoCode"];
                 if (isset($reqResult["DATA"]["documentId"])) {
                     $result["DELIVERY_DOC_NUM"] = $reqResult["DATA"]["documentId"];
                 }
                 $phoneAndEmail = static::getPhoneEmail($arOrder["ID"]);
                 $subsData = Adapter::prepareSubscribeReqData(array($reqResult["DATA"]["cargos"][0]["cargoCode"]), $phoneAndEmail["EMAIL"], $phoneAndEmail["PHONE"]);
                 $subsResult = static::sendRequest($arConfig["LOGIN"]["VALUE"], $arConfig["KEY"]["VALUE"], "notification", "cargosubscribe", $subsData);
             }
             break;
         case "REQUEST_STATUS":
             $controller = 'cargos';
             $action = 'status';
             $data = array('cargoCodes' => array($arOrder['TRACKING_NUMBER']));
             $reqResult = static::sendRequest($arConfig["LOGIN"]["VALUE"], $arConfig["KEY"]["VALUE"], $controller, $action, $data);
             break;
         case "REQUEST_TAKE":
             $reqResult = array("RESULT" => "ERROR", "TEXT" => "");
             break;
     }
     $result["RESULT"] = $reqResult["RESULT"];
     if (isset($reqResult["TEXT"])) {
         $result["TEXT"] = $reqResult["TEXT"];
     }
     if (isset($reqResult["DATA"])) {
         $result["DATA"] = $reqResult["DATA"];
     }
     return $result;
 }