3namespace Bitrix\Sale\Delivery\Pecom;
38 $arInfo = json_decode($jsonInfo,
true);
40 if(isset($arInfo[
"auto"]))
43 if(isset($arInfo[
"avia"]))
58 $jsonInfo = $this->
send($strParams);
67 'TEXT' => $e->getMessage()
77 $arInfo = json_decode($jsonInfo,
true);
79 if(is_array($arInfo) && !empty($arInfo))
81 if(isset($arInfo[$this->profileId][2]))
85 $price += intval($arInfo[$this->profileId][2]);
88 $price += intval($arInfo[
"take"][2]);
92 $price += intval($arInfo[
"deliver"][2]);
94 foreach($arInfo as
$key => $value)
95 if(mb_substr(
$key, 0, 3) ==
"ADD")
96 $price += intval($arInfo[
$key][2]);
101 'PACKS_COUNT' => $this->packsCount
106 if($this->profileId ==
"auto" && !empty($arInfo[
"periods"]))
107 $period = $arInfo[
"periods"];
108 elseif($this->profileId ==
"avia" && !empty($arInfo[
"aperiods"]))
109 $period = $arInfo[
"aperiods"];
113 $pos = mb_strpos($period,
':');
117 $CBXSanitizer = new \CBXSanitizer;
118 $CBXSanitizer->DelAllTags();
119 $arResult[
"TRANSIT"] =
" (".GetMessage(
"SALE_DH_PECOM_PERIOD_DAYS").
") ".$CBXSanitizer->SanitizeHtml(mb_substr($period, $pos + 1));
125 if(isset($arInfo[
"error"]))
127 $error = implode(
"<br>", $arInfo[
"error"]);
144 'TEXT' =>
GetMessage(
"SALE_DH_PECOM_ERROR_NO_RESULTS")
151 protected static function send($strParams)
153 $http = new \Bitrix\Main\Web\HttpClient(
array(
155 "socketTimeout" => 30,
156 "streamTimeout" => 30,
159 "disableSslVerification" =>
true
162 $jsnData = $http->get(
"http://calc.pecom.ru/bitrix/components/pecom/calc/ajax.php?".$strParams);
166 if (!$jsnData && !empty(
$errors))
170 foreach(
$errors as $errorCode => $errMes)
174 "SEVERITY" =>
"ERROR",
175 "AUDIT_TYPE_ID" =>
"SALE_DELIVERY",
176 "MODULE_ID" =>
"sale",
177 "ITEM_ID" =>
"PECOM_CALCULATOR_SEND",
199 '&take[town]='.$this->arConfig[
"CITY_DELIVERY"][
"VALUE"].
206 '&delideliver[gidro]=0'.
208 '&deliver[moscow]=0'.
223 if(!isset($this->arOrder[
"WEIGHT"]))
224 throw new \Exception(
GetMessage(
"SALE_DH_PECOM_EXCPT_WEIGHT"));
230 throw new \Exception(
GetMessage(
"SALE_DH_PECOM_EXCPT_EMPTY_LOCATION"));
232 if(
count(
$arLocation) > 1 && isset($this->arOrder[
"EXTRA_PARAMS"][
"location"]))
234 $locationTo = $this->arOrder[
"EXTRA_PARAMS"][
"location"];
238 throw new \Exception(
GetMessage(
"SALE_DH_PECOM_EXCPT_MANY_LOCATIONS"));
246 if(!isset($this->arOrder[
"ITEMS"]) || !is_array($this->arOrder[
"ITEMS"]) || empty($this->arOrder[
"ITEMS"]))
247 throw new \Exception(
GetMessage(
"SALE_DH_PECOM_EXCPT_EMPTY_ITEMS"));
249 $measureCoeff = 1000;
251 $loadingRange =
true;
257 $this->arOrder[
"ITEMS"],
261 $this->packsCount =
count($arPackagesParams);
263 for(
$i = $this->packsCount-1;
$i >= 0;
$i--)
265 $item = $arPackagesParams[
$i];
266 $width = round(floatval($item[
"DIMENSIONS"][
"WIDTH"])/$measureCoeff, 2);
267 $lenght = round(floatval($item[
"DIMENSIONS"][
"LENGTH"])/$measureCoeff, 2);
268 $height = round(floatval($item[
"DIMENSIONS"][
"HEIGHT"])/$measureCoeff, 2);
269 $volume = floatval($item[
"VOLUME"]/(pow($measureCoeff,3)));
276 $loadingRange =
false;
281 $itemsStr .=
'places['.$i.
'][]='.strval(
$width).
282 '&places['.$i.
'][]='.strval($lenght).
283 '&places['.$i.
'][]='.strval($height).
284 '&places['.$i.
'][]='.strval($volume).
285 '&places['.$i.
'][]='.strval($item[
"WEIGHT"]/1000).
286 '&places['.$i.
'][]='.($loadingRange ?
'1' :
'0').
296 $insurance = strval($this->arOrder[
"PRICE"]);
301 '&take[town]='.$this->arConfig[
"CITY_DELIVERY"][
"VALUE"].
302 '&take[tent]='.(\CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_TAKE_ENABLED') && \
CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_TAKE_TENT_ENABLED') ?
'1' :
'0').
303 '&take[gidro]='.(\CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_TAKE_ENABLED') && \
CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_TAKE_HYDRO_ENABLED') ?
'1' :
'0').
306 '&deliver[town]='.$locationTo.
307 '&deliver[tent]='.(\CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_DELIVERY_ENABLED') && \
CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_DELIVERY_TENT_ENABLED') ?
'1' :
'0').
308 '&delideliver[gidro]='.(\CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_DELIVERY_ENABLED') && \
CDeliveryPecom::isConfCheckedVal($this->arConfig,
'SERVICE_DELIVERY_HYDRO_ENABLED') ?
'1' :
'0').
310 '&deliver[moscow]=0'.
311 '&plombir='.$plombir.
312 '&strah='.$insurance.
static mapLocation($locationId, $cleanCache=false)
parseCalcResult($jsonInfo)
__construct($arOrder, $arConfig, $profileId="")
static $EXTRA_DEMENSIONS_WEIGHT
static getConfValue(&$arConfig, $key)
static $EXTRA_DIMENSIONS_SIZE
static isConfCheckedVal(&$arConfig, $key)
static getRequiredPacks(&$arItems, $arPacks, $maxWeight, $reservedSpace=0.15)
static getBoxesFromConfig($profile, &$arConfig)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
$arLocation['REGION_NAME']