本文整理汇总了PHP中CSaleOrderTax::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrderTax::Update方法的具体用法?PHP CSaleOrderTax::Update怎么用?PHP CSaleOrderTax::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrderTax
的用法示例。
在下文中一共展示了CSaleOrderTax::Update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DoSaveOrderTax
static function DoSaveOrderTax($orderId, $taxList, &$arErrors)
{
$duplicateList = array();
$idList = array();
$res = CSaleOrderTax::GetList(array('ID' => 'ASC'), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "CODE"));
while ($data = $res->Fetch()) {
$hash = $data["TAX_NAME"] . "|" . $data["CODE"];
if (!array_key_exists($hash, $idList)) {
$idList[$data["TAX_NAME"] . "|" . $data["CODE"]] = $data["ID"];
} else {
$duplicateList[$hash] = $data['ID'];
}
}
if (is_array($taxList)) {
foreach ($taxList as $itemData) {
$fields = array("ORDER_ID" => $orderId, "TAX_NAME" => $itemData["NAME"], "IS_PERCENT" => $itemData["IS_PERCENT"], "VALUE" => $itemData["VALUE"], "VALUE_MONEY" => $itemData["VALUE_MONEY"], "APPLY_ORDER" => $itemData["APPLY_ORDER"], "IS_IN_PRICE" => $itemData["IS_IN_PRICE"], "CODE" => $itemData["CODE"]);
$hash = $itemData["NAME"] . "|" . $itemData["CODE"];
if (array_key_exists($hash, $idList)) {
CSaleOrderTax::Update($idList[$hash], $fields);
unset($idList[$hash]);
} elseif (!array_key_exists($hash, $duplicateList)) {
CSaleOrderTax::Add($fields);
}
}
}
foreach ($idList as $code => $id) {
CSaleOrderTax::Delete($id);
}
if (!empty($duplicateList)) {
foreach ($duplicateList as $hash => $id) {
CSaleOrderTax::Delete($id);
}
}
}
示例2: nodeHandler
function nodeHandler(CDataXML $value)
{
$value = $value->GetArray();
$value = $value[GetMessage("CC_BSC1_DOCUMENT")];
if ($value["#"][GetMessage("CC_BSC1_OPERATION")][0]["#"] == GetMessage("CC_BSC1_ORDER")) {
$orderId = IntVal($value["#"][GetMessage("CC_BSC1_NUMBER")][0]["#"]);
$arOrder = array();
$arItem = array();
$arOrder["AMOUNT"] = $value["#"][GetMessage("CC_BSC1_SUMM")][0]["#"];
$arOrder["AMOUNT"] = str_replace($SumFormat, ".", $arOrder["AMOUNT"]);
$arOrder["COMMENT"] = $value["#"][GetMessage("CC_BSC1_COMMENT")][0]["#"];
foreach ($value["#"][GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val) {
$arOrder["TRAITS"][$val["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
$taxValue = 0;
$taxValueTmp = 0;
$taxName = "";
if (is_array($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")])) {
foreach ($value["#"][GetMessage("CC_BSC1_ITEMS")][0]["#"][GetMessage("CC_BSC1_ITEM")] as $val) {
$val = $val["#"];
$productID = $val[GetMessage("CC_BSC1_ID")][0]["#"];
$bGood = false;
$discountPrice = "";
$priceAll = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_SUMM")][0]["#"]);
$priceone = str_replace($SumFormat, ".", $val[GetMessage("CC_BSC1_PRICE_PER_UNIT")][0]["#"]);
$quantity = str_replace($QuantityFormat, ".", $val[GetMessage("CC_BSC1_QUANTITY")][0]["#"]);
$price = $priceAll / $quantity;
if ($priceone != $price) {
$discountPrice = $priceone - $price;
}
//DISCOUNTS!
$arItem[$productID] = array("NAME" => $val[GetMessage("CC_BSC1_NAME")][0]["#"], "PRICE" => $price, "QUANTITY" => $quantity, "DISCOUNT_PRICE" => $discountPrice);
if (is_array($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")])) {
foreach ($val[GetMessage("CC_BSC1_PROPS_ITEMS")][0]["#"][GetMessage("CC_BSC1_PROP_ITEM")] as $val1) {
$arItem[$productID]["ATTRIBUTES"][$val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"]] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
}
if (is_array($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")])) {
foreach ($val[GetMessage("CC_BSC1_REK_VALUES")][0]["#"][GetMessage("CC_BSC1_REK_VALUE")] as $val1) {
if ($val1["#"][GetMessage("CC_BSC1_NAME")][0]["#"] == GetMessage("CC_BSC1_ITEM_TYPE")) {
$arItem[$productID]["TYPE"] = $val1["#"][GetMessage("CC_BSC1_VALUE")][0]["#"];
}
}
}
if (strlen($value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"]) > 0) {
$taxValueTmp = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_TAX_VALUE")][0]["#"];
$arItem[$productID]["VAT_RATE"] = $taxValueTmp / 100;
if (IntVal($taxValueTmp) > IntVal($taxValue)) {
$taxName = $val[GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_NAME")][0]["#"];
$taxValue = $taxValueTmp;
}
}
}
}
if (IntVal($taxValue) > 0) {
$price = str_replace($SumFormat, ".", $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_SUMM")][0]["#"]);
$arOrder["TAX"] = array("NAME" => $taxName, "VALUE" => $taxValue, "IS_IN_PRICE" => $value["#"][GetMessage("CC_BSC1_TAXES")][0]["#"][GetMessage("CC_BSC1_TAX")][0]["#"][GetMessage("CC_BSC1_IN_PRICE")][0]["#"] == "true" ? "Y" : "N", "VALUE_MONEY" => $price);
}
$arOrder["items"] = $arItem;
$v = $arOrder;
if ($orderInfo = CSaleOrder::GetByID($orderId)) {
if ($orderInfo["PAYED"] != "Y" && $orderInfo["ALLOW_DELIVERY"] != "Y" && $orderInfo["STATUS_ID"] != "F") {
$dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE"));
$bTaxFound = false;
if ($arOrderTax = $dbOrderTax->Fetch()) {
$bTaxFound = true;
if (IntVal($arOrderTax["VALUE_MONEY"]) != IntVal($v["TAX"]["VALUE_MONEY"]) || IntVal($arOrderTax["VALUE"]) != IntVal($v["TAX"]["VALUE"]) || $arOrderTax["IS_IN_PRICE"] != $v["TAX"]["IS_IN_PRICE"]) {
if (IntVal($v["TAX"]["VALUE"]) > 0) {
$arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"], "CODE" => "VAT1C", "APPLY_ORDER" => "100");
CSaleOrderTax::Update($arOrderTax["ID"], $arFields);
CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
} else {
CSaleOrderTax::Delete($arOrderTax["ID"]);
CSaleOrder::Update($orderId, array("TAX_VALUE" => 0));
}
}
}
if (!$bTaxFound) {
if (IntVal($v["TAX"]["VALUE"]) > 0) {
$arFields = array("TAX_NAME" => $v["TAX"]["NAME"], "ORDER_ID" => $orderId, "VALUE" => $v["TAX"]["VALUE"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $v["TAX"]["IS_IN_PRICE"], "VALUE_MONEY" => $v["TAX"]["VALUE_MONEY"]);
CSaleOrderTax::Add($arFields);
CSaleOrder::Update($orderId, array("TAX_VALUE" => $v["TAX"]["VALUE_MONEY"]));
}
}
$dbBasket = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderId));
$basketSum = 0;
while ($arBasket = $dbBasket->Fetch()) {
$arFields = array();
if (!empty($v["items"][$arBasket["PRODUCT_XML_ID"]])) {
if ($arBasket["QUANTITY"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"]) {
$arFields["QUANTITY"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["QUANTITY"];
}
if ($arBasket["PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"]) {
$arFields["PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["PRICE"];
}
if ($arBasket["VAT_RATE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"]) {
$arFields["VAT_RATE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["VAT_RATE"];
}
if ($arBasket["DISCOUNT_PRICE"] != $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"]) {
$arFields["DISCOUNT_PRICE"] = $v["items"][$arBasket["PRODUCT_XML_ID"]]["DISCOUNT_PRICE"];
//.........这里部分代码省略.........
示例3: nodeHandler
function nodeHandler(CDataXML $value)
{
$value = $value->GetArray();
if(!empty($value[GetMessage("CC_BSC1_DOCUMENT")]))
{
$value = $value[GetMessage("CC_BSC1_DOCUMENT")];
$arOrder = $this->collectOrderInfo($value);
if(!empty($arOrder))
{
if(strlen($arOrder["ID"]) <= 0 && strlen($arOrder["ID_1C"]) > 0)//try to search order from 1C
{
$dbOrder = CSaleOrder::GetList(array("ID" => "DESC"), array("ID_1C" => $arOrder["ID_1C"]), false, false, array("ID", "ID_1C"));
if($orderInfo = $dbOrder->Fetch())
{
$arOrder["ID"] = $orderInfo["ID"];
}
}
if(strlen($arOrder["ID"]) > 0) // exists site order
{
$dbOrder = CSaleOrder::GetList(array(), array("ACCOUNT_NUMBER" => $arOrder["ID"]), false, false, array("ID", "LID", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "CANCELED", "DATE_CANCELED", "REASON_CANCELED", "STATUS_ID", "DATE_STATUS", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "DATE_INSERT", "DATE_INSERT_FORMAT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "COMMENTS", "TAX_VALUE", "DELIVERY_DOC_NUM", "DELIVERY_DOC_DATE", "STORE_ID", "ACCOUNT_NUMBER", "VERSION", "VERSION_1C", "ID_1C"));
if($orderInfo = $dbOrder->Fetch())
{
if($arOrder["VERSION_1C"] != $orderInfo["VERSION_1C"] || (strlen($orderInfo["VERSION_1C"]) <= 0 || strlen($arOrder["VERSION_1C"]) <= 0)) // skip update if the same version
{
$arOrderFields = array();
$orderId = $orderInfo["ID"];
CSaleOrderChange::AddRecord($orderId, "ORDER_1C_IMPORT");
if($arOrder["ID_1C"] != $orderInfo["ID_1C"])
$arOrderFields["ID_1C"] = $arOrder["ID_1C"];
$arOrderFields["VERSION_1C"] = $arOrder["VERSION_1C"];
if($orderInfo["PAYED"] != "Y" && $orderInfo["ALLOW_DELIVERY"] != "Y" && $orderInfo["STATUS_ID"] != "F")
{
$dbOrderTax = CSaleOrderTax::GetList(
array(),
array("ORDER_ID" => $orderId),
false,
false,
array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE")
);
$bTaxFound = false;
if($arOrderTax = $dbOrderTax->Fetch())
{
$bTaxFound = true;
if(IntVal($arOrderTax["VALUE_MONEY"]) != IntVal($arOrder["TAX"]["VALUE_MONEY"]) || IntVal($arOrderTax["VALUE"]) != IntVal($arOrder["TAX"]["VALUE"]) || ($arOrderTax["IS_IN_PRICE"] != $arOrder["TAX"]["IS_IN_PRICE"]))
{
if(IntVal($arOrder["TAX"]["VALUE"])>0)
{
$arFields = Array(
"TAX_NAME" => $arOrder["TAX"]["NAME"],
"ORDER_ID" => $orderId,
"VALUE" => $arOrder["TAX"]["VALUE"],
"IS_PERCENT" => "Y",
"IS_IN_PRICE" => $arOrder["TAX"]["IS_IN_PRICE"],
"VALUE_MONEY" => $arOrder["TAX"]["VALUE_MONEY"],
"CODE" => "VAT1C",
"APPLY_ORDER" => "100"
);
CSaleOrderTax::Update($arOrderTax["ID"], $arFields);
$arOrderFields["TAX_VALUE"] = $arOrder["TAX"]["VALUE_MONEY"];
}
else
{
CSaleOrderTax::Delete($arOrderTax["ID"]);
$arOrderFields["TAX_VALUE"] = 0;
}
}
}
if(!$bTaxFound)
{
if(IntVal($arOrder["TAX"]["VALUE"])>0)
{
$arFields = Array(
"TAX_NAME" => $arOrder["TAX"]["NAME"],
"ORDER_ID" => $orderId,
"VALUE" => $arOrder["TAX"]["VALUE"],
"IS_PERCENT" => "Y",
"IS_IN_PRICE" => $arOrder["TAX"]["IS_IN_PRICE"],
"VALUE_MONEY" => $arOrder["TAX"]["VALUE_MONEY"]
);
CSaleOrderTax::Add($arFields);
$arOrderFields["TAX_VALUE"] = $arOrder["TAX"]["VALUE_MONEY"];
}
}
$arShoppingCart = array();
$bNeedUpdate = false;
$dbBasket = CSaleBasket::GetList(
array("NAME" => "ASC"),
array("ORDER_ID" => $orderId),
false,
false,
array(
"ID",
"QUANTITY",
"CANCEL_CALLBACK_FUNC",
//.........这里部分代码省略.........
示例4: array
CSaleBasket::Delete($key);
}
}
if (strlen($errorMessage) <= 0) {
$arOldTaxList = array();
$dbTax = CSaleOrderTax::GetList(array("APPLY_ORDER" => "ASC"), array("ORDER_ID" => $ID), false, false, array("*"));
while ($arTax = $dbTax->Fetch()) {
$arOldTaxList[IntVal($arTax["ID"])] = "Y";
}
for ($i = 0; $i < count($arIDs); $i++) {
for ($j = 0; $j < count($arTaxList); $j++) {
$arFields = array("ORDER_ID" => $arIDs[$i], "TAX_NAME" => $arTaxList[$j]["TAX_NAME"], "VALUE" => $arTaxList[$j]["VALUE"], "VALUE_MONEY" => $arOrderTaxList[$i][$j]["VALUE_MONEY"], "APPLY_ORDER" => $arTaxList[$j]["APPLY_ORDER"], "IS_PERCENT" => "Y", "IS_IN_PRICE" => $arTaxList[$j]["IS_IN_PRICE"], "CODE" => $arTaxList[$j]["CODE"]);
$res = False;
if ($arTaxList[$j]["ID"] > 0) {
if (array_key_exists($arTaxList[$j]["ID"], $arOldTaxList)) {
$res = CSaleOrderTax::Update($arTaxList[$j]["ID"], $arFields);
unset($arOldTaxList[$arTaxList[$j]["ID"]]);
} else {
$errorMessage .= GetMessage("SOE_INTERNAL_RFITH68") . ". ";
}
} else {
$res = CSaleOrderTax::Add($arFields) > 0;
}
if (!$res) {
if ($ex = $APPLICATION->GetException()) {
$errorMessage .= $ex->GetString();
} else {
$errorMessage .= str_replace("#NAME#", $arTaxList[$j]["TAX_NAME"], GetMessage("SOE_ERROR_SAVE_TAX")) . ". ";
}
}
}
示例5: DoSaveOrderTax
static function DoSaveOrderTax($orderId, $arTaxList, &$arErrors)
{
$arIDs = array();
$dbResult = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "CODE"));
while ($arResult = $dbResult->Fetch()) {
$arIDs[$arResult["TAX_NAME"] . "|" . $arResult["CODE"]] = $arResult["ID"];
}
if (is_array($arTaxList)) {
foreach ($arTaxList as $arItem) {
$arFields = array("ORDER_ID" => $orderId, "TAX_NAME" => $arItem["NAME"], "IS_PERCENT" => $arItem["IS_PERCENT"], "VALUE" => $arItem["VALUE"], "VALUE_MONEY" => $arItem["VALUE_MONEY"], "APPLY_ORDER" => $arItem["APPLY_ORDER"], "IS_IN_PRICE" => $arItem["IS_IN_PRICE"], "CODE" => $arItem["CODE"]);
if (array_key_exists($arItem["NAME"] . "|" . $arItem["CODE"], $arIDs)) {
CSaleOrderTax::Update($arIDs[$arItem["NAME"] . "|" . $arItem["CODE"]], $arFields);
unset($arIDs[$arItem["NAME"] . "|" . $arItem["CODE"]]);
} else {
CSaleOrderTax::Add($arFields);
}
}
}
foreach ($arIDs as $id) {
CSaleOrderTax::Delete($id);
}
}
示例6: DoSaveOrderTax
static function DoSaveOrderTax($orderId, $taxList, &$arErrors)
{
$duplicateList = array();
$idList = array();
$res = CSaleOrderTax::GetList(array('ID' => 'ASC'), array("ORDER_ID" => $orderId), false, false, array("ID", "TAX_NAME", "CODE"));
while ($data = $res->Fetch()) {
$hash = $data["TAX_NAME"] . "|" . $data["CODE"];
if (!array_key_exists($hash, $idList)) {
$idList[$data["TAX_NAME"] . "|" . $data["CODE"]] = $data["ID"];
} else {
$duplicateList[$hash] = $data['ID'];
}
}
$isChanged = false;
if (is_array($taxList)) {
foreach ($taxList as $itemData) {
$fields = array("ORDER_ID" => $orderId, "TAX_NAME" => $itemData["NAME"], "IS_PERCENT" => $itemData["IS_PERCENT"], "VALUE" => $itemData["VALUE"], "VALUE_MONEY" => $itemData["VALUE_MONEY"], "APPLY_ORDER" => $itemData["APPLY_ORDER"], "IS_IN_PRICE" => $itemData["IS_IN_PRICE"], "CODE" => $itemData["CODE"]);
$hash = $itemData["NAME"] . "|" . $itemData["CODE"];
$isNew = false;
if (array_key_exists($hash, $idList)) {
$taxId = CSaleOrderTax::Update($idList[$hash], $fields);
unset($idList[$hash]);
} elseif (!array_key_exists($hash, $duplicateList)) {
$isNew = true;
$taxId = CSaleOrderTax::Add($fields);
}
if ($orderId > 0) {
\Bitrix\Sale\OrderHistory::addLog('TAX', $orderId, $isNew ? 'TAX_ADD' : 'TAX_UPDATE', $taxId, null, array("NAME" => $itemData["NAME"], "CODE" => $itemData["CODE"]), \Bitrix\Sale\OrderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1);
$isChanged = true;
}
}
}
foreach ($idList as $code => $id) {
CSaleOrderTax::Delete($id);
if ($orderId > 0) {
\Bitrix\Sale\OrderHistory::addLog('TAX', $orderId, 'TAX_DELETED', $id, null, array(), \Bitrix\Sale\OrderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1);
}
}
if (!empty($duplicateList)) {
foreach ($duplicateList as $hash => $id) {
CSaleOrderTax::Delete($id);
\Bitrix\Sale\OrderHistory::addLog('TAX', $orderId, 'TAX_DUPLICATE_DELETED', $id, null, array(), \Bitrix\Sale\OrderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1);
}
}
if ($isChanged) {
\Bitrix\Sale\OrderHistory::addAction('TAX', $orderId, "TAX_SAVED");
}
}