本文整理汇总了PHP中CSaleDelivery::getCodeById方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleDelivery::getCodeById方法的具体用法?PHP CSaleDelivery::getCodeById怎么用?PHP CSaleDelivery::getCodeById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleDelivery
的用法示例。
在下文中一共展示了CSaleDelivery::getCodeById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NextPayment
function NextPayment($ID)
{
global $DB;
global $USER;
$ID = IntVal($ID);
if ($ID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGR_NO_RECID"), "NO_RECORD_ID");
return False;
}
$arRecur = CSaleRecurring::GetByID($ID);
if (!$arRecur) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGR_NO_RECID1")), "NO_RECORD");
return False;
}
$arOrder = CSaleOrder::GetByID($arRecur["ORDER_ID"]);
if (!$arOrder) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arRecur["ORDER_ID"], GetMessage("SKGR_NO_ORDER1")), "NO_ORDER");
return False;
}
$bSuccess = True;
$newOrderID = IntVal($arRecur["ORDER_ID"]);
/** @var $productProvider IBXSaleProductProvider */
if ($productProvider = CSaleBasket::GetProductProvider($arRecur)) {
$arProduct = $productProvider::RecurringOrderProduct(array("PRODUCT_ID" => $arRecur["PRODUCT_ID"], "USER_ID" => $arOrder["USER_ID"]));
} else {
$arProduct = CSaleRecurring::ExecuteCallbackFunction($arRecur["CALLBACK_FUNC"], $arRecur["MODULE"], $arRecur["PRODUCT_ID"], $arOrder["USER_ID"]);
}
if (!$arProduct || !is_array($arProduct) || empty($arProduct)) {
CSaleRecurring::CancelRecurring($arRecur["ID"], "Y", "Product is not found");
return true;
}
if ($arProduct["WITHOUT_ORDER"] == "Y" || $arRecur["SUCCESS_PAYMENT"] == "Y") {
$baseSiteCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
$productPrice = \Bitrix\Sale\PriceMaths::roundPrecision(CCurrencyRates::ConvertCurrency($arProduct["PRICE"], $arProduct["CURRENCY"], $baseSiteCurrency));
// Delivery
$deliveryPrice = 0;
$deliveryID = 0;
$arOrder["DELIVERY_ID"] = IntVal($arOrder["DELIVERY_ID"]);
if ($arOrder["DELIVERY_ID"] > 0) {
$deliveryLocation = 0;
$dbOrderPropValues = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arRecur["ORDER_ID"], "PROP_IS_LOCATION" => "Y"), false, false, array("VALUE"));
if ($arOrderPropValues = $dbOrderPropValues->Fetch()) {
$deliveryLocation = IntVal($arOrderPropValues["VALUE"]);
}
$dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => $arOrder["LID"], "WEIGHT" => DoubleVal($arProduct["WEIGHT"]) * DoubleVal($arProduct["QUANTITY"]), "ORDER_PRICE" => $productPrice * DoubleVal($arProduct["QUANTITY"]), "ACTIVE" => "Y", "LOCATION" => $deliveryLocation));
while ($arDelivery = $dbDelivery->Fetch()) {
$deliveryPriceTmp = \Bitrix\Sale\PriceMaths::roundPrecision(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $baseSiteCurrency));
if (IntVal($arDelivery["ID"]) == $arOrder["DELIVERY_ID"]) {
$deliveryID = IntVal($arDelivery["ID"]);
$deliveryPrice = $deliveryPriceTmp;
break;
}
if ($deliveryPriceTmp < $deliveryPrice || $deliveryID <= 0) {
$deliveryID = IntVal($arDelivery["ID"]);
$deliveryPrice = $deliveryPriceTmp;
}
}
if ($deliveryID <= 0) {
$deliveryID = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
if ($deliveryID > 0) {
$deliveryID = \CSaleDelivery::getCodeById($deliveryID);
}
}
if ($deliveryID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGR_NO_DELIVERY"), "NO_DELIVERY");
return False;
}
}
// Sale discounts
$discount = 0;
$discountPrice = $productPrice;
$discountProduct = 0;
$dbDiscount = CSaleDiscount::GetList(array("SORT" => "ASC"), array("LID" => $arOrder["LID"], "ACTIVE" => "Y", "!>ACTIVE_FROM" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))), "!<ACTIVE_TO" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))), "<=PRICE_FROM" => $productPrice, ">=PRICE_TO" => $productPrice, "USER_GROUPS" => $USER->GetUserGroup($arOrder['USER_ID'])));
if ($arDiscount = $dbDiscount->Fetch()) {
if ($arDiscount["DISCOUNT_TYPE"] == "P") {
$discountProduct = \Bitrix\Sale\PriceMaths::roundPrecision($productPrice * $arDiscount["DISCOUNT_VALUE"] / 100);
$discount = \Bitrix\Sale\PriceMaths::roundPrecision($discountProduct * DoubleVal($arProduct["QUANTITY"]));
// Changed by Sigurd, 2007-08-16
$discountPrice = $productPrice - $discountProduct;
} else {
$discountValue = CCurrencyRates::ConvertCurrency($arDiscount["DISCOUNT_VALUE"], $arDiscount["CURRENCY"], $baseSiteCurrency);
$discountValue = \Bitrix\Sale\PriceMaths::roundPrecision($discountValue);
$discountProduct = \Bitrix\Sale\PriceMaths::roundPrecision(1.0 * $discountValue / DoubleVal($arProduct["QUANTITY"]));
// Changed by Sigurd, 2007-08-16
$discount = \Bitrix\Sale\PriceMaths::roundPrecision($curDiscount * DoubleVal($arProduct["QUANTITY"]));
$discountPrice = $productPrice - $discountProduct;
}
}
$bUseVat = false;
$vatRate = 0;
if (DoubleVal($arProduct["VAT_RATE"]) > 0) {
$bUseVat = true;
$vatRate = $arProduct["VAT_RATE"];
}
// Tax
$arTaxExempt = array();
$dbUserGroups = CUser::GetUserGroupEx($arOrder["USER_ID"]);
while ($arUserGroups = $dbUserGroups->Fetch()) {
$dbTaxExemptTmp = CSaleTax::GetExemptList(array("GROUP_ID" => $arUserGroups["GROUP_ID"]));
while ($arTaxExemptTmp = $dbTaxExemptTmp->Fetch()) {
//.........这里部分代码省略.........
示例2: processAdditionalInfoShipmentEdit
public function processAdditionalInfoShipmentEdit(Shipment $shipment, array $requestData)
{
if (empty($requestData['REQUEST_SELF']) || $requestData['REQUEST_SELF'] != 'Y') {
return null;
}
$shipmentId = $shipment->getId();
if (intval($shipmentId) <= 0) {
return null;
}
$dt = new \Bitrix\Main\Type\DateTime();
$arResult = CSaleDeliveryHandler::executeAction(\CSaleDelivery::getCodeById($shipment->getDeliveryId()), 'REQUEST_SELF', \CAllSaleDelivery::convertOrderNewToOld($shipment));
if (!$arResult) {
return null;
}
$res = \Bitrix\Sale\Internals\OrderDeliveryReqTable::add(array("SHIPMENT_ID" => $shipmentId, "ORDER_ID" => $shipment->getCollection()->getOrder()->getId(), "DATE_REQUEST" => $dt, "PARAMS" => array("TYPE" => "REQUEST_SELF", "RESULT" => $arResult)));
if (!$res->isSuccess()) {
return null;
}
if (isset($arResult["TRACKING_NUMBER"])) {
$shipment->setField("TRACKING_NUMBER", $arResult["TRACKING_NUMBER"]);
}
if (isset($arResult["DELIVERY_DOC_NUM"])) {
$shipment->setField("DELIVERY_DOC_NUM", $arResult["DELIVERY_DOC_NUM"]);
$shipment->setField("DELIVERY_DOC_DATE", $dt);
}
return $shipment;
}
示例3: GetList
public static function GetList($arFilter = array(), $arGroupBy = false, $arSelectFields = array())
{
$params = array();
if (is_array($arFilter) && !empty($arFilter)) {
if (isset($arFilter["DELIVERY_ID"]) || $arFilter["DELIVERY_PROFILE_ID"]) {
$ids = self::convertDeliveryIds(isset($arFilter["DELIVERY_ID"]) ? $arFilter["DELIVERY_ID"] : array(), isset($arFilter["DELIVERY_PROFILE_ID"]) ? $arFilter["DELIVERY_PROFILE_ID"] : array());
if (!empty($ids)) {
$arFilter["=DELIVERY_ID"] = $ids;
}
unset($arFilter["DELIVERY_ID"]);
unset($arFilter["DELIVERY_PROFILE_ID"]);
}
if (isset($arFilter["PAYSYSTEM_ID"])) {
$arFilter["=PAYSYSTEM_ID"] = $arFilter["PAYSYSTEM_ID"];
unset($arFilter["PAYSYSTEM_ID"]);
}
$params['filter'] = $arFilter;
}
//todo:
if (is_array($arGroupBy) && !empty($arGroupBy)) {
$params['group'] = array_intersect($arGroupBy, array("DELIVERY_ID", "PAYSYSTEM_ID"));
}
$params["select"] = array("DELIVERY_ID", "PAYSYSTEM_ID", "LINK_DIRECTION");
$deliveryChildrenList = self::getDeliveryChildrenList();
$records = array();
$res = DeliveryPaySystemTable::getList($params);
$restricted = array('D' => array(), 'P' => array());
while ($record = $res->fetch()) {
if ($record['LINK_DIRECTION'] == 'D') {
if (!in_array($record["DELIVERY_ID"], $restricted['D'])) {
$restricted['D'][] = $record["DELIVERY_ID"];
}
} elseif ($record['LINK_DIRECTION'] == 'P') {
if (!in_array($record["DELIVERY_ID"], $restricted['P'])) {
$restricted['P'][] = $record["PAYSYSTEM_ID"];
}
}
$deliveryId = $record["DELIVERY_ID"];
$linkDirection = $record["LINK_DIRECTION"];
unset($record["LINK_DIRECTION"]);
$deliveryCode = \CSaleDelivery::getCodeById($record["DELIVERY_ID"]);
$delivery = CSaleDeliveryHelper::getDeliverySIDAndProfile($deliveryCode);
$record["DELIVERY_ID"] = $delivery["SID"];
$record["DELIVERY_PROFILE_ID"] = isset($delivery["PROFILE"]) ? $delivery["PROFILE"] : null;
$records[] = $record;
if (!empty($deliveryChildrenList[$deliveryId])) {
foreach ($deliveryChildrenList[$deliveryId] as $childrenId) {
if ($linkDirection == 'D' && !in_array($childrenId, $restricted['D'])) {
$restricted['D'][] = $childrenId;
}
$deliveryCode = \CSaleDelivery::getCodeById($childrenId);
$delivery = CSaleDeliveryHelper::getDeliverySIDAndProfile($deliveryCode);
$record["DELIVERY_ID"] = $delivery["SID"];
$record["DELIVERY_PROFILE_ID"] = isset($delivery["PROFILE"]) ? $delivery["PROFILE"] : null;
$records[] = $record;
}
}
}
foreach (self::getFullDeliveryList() as $dlvId) {
if (in_array($dlvId, $restricted['D'])) {
continue;
}
$deliveryCode = \CSaleDelivery::getCodeById($dlvId);
$delivery = CSaleDeliveryHelper::getDeliverySIDAndProfile($deliveryCode);
$record = array("DELIVERY_ID" => $delivery["SID"], "DELIVERY_PROFILE_ID" => isset($delivery["PROFILE"]) ? $delivery["PROFILE"] : null);
foreach (self::getFullPaySystemList() as $psId) {
if (in_array($psId, $restricted['P'])) {
continue;
}
if (self::isRecordExists($record["DELIVERY_ID"], $record["DELIVERY_PROFILE_ID"], $psId, $records)) {
continue;
}
$record["PAYSYSTEM_ID"] = $psId;
$records[] = $record;
}
}
$result = new \CDBResult();
$result->InitFromArray($records);
return $result;
}