本文整理汇总了PHP中CSaleOrder类的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder类的具体用法?PHP CSaleOrder怎么用?PHP CSaleOrder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSaleOrder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnBeforeUserDeleteHandler
function OnBeforeUserDeleteHandler($user_id)
{
\CModule::IncludeModule("iblock");
\CModule::IncludeModule("sale");
//Привязки к соц. сетям
$arrFilter = array("IBLOCK_ID" => USER_SOCIAL_IB, "PROPERTY_USER_ID" => $user_id);
$arSelect = array("ID");
$rsRes = \CIBlockElement::GetList($arOrder, $arrFilter, false, false, $arSelect);
while ($arItem = $rsRes->GetNext()) {
\CIBlockElement::Delete($arItem["ID"]);
}
//Удаляем записи
$result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_USER_ID" => $user_id), 'select' => array("ID")));
while ($arRecord = $result->fetch()) {
\CRecordEx::delete($arRecord["ID"]);
}
//Удаляем счет
if ($arAccount = \CSaleUserAccount::GetByUserID($user_id, "RUR")) {
\CSaleUserAccount::Delete($arAccount["ID"]);
}
//Удаляем заказы
$arFilter = array("USER_ID" => $user_id);
$db_sales = \CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
while ($ar_sales = $db_sales->Fetch()) {
\CSaleOrder::Delete($ar_sales["ID"]);
}
//Удаляем подписки
$result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_USER_ID" => $user_id), 'select' => array("ID")));
if ($arSub = $result->fetch()) {
\Hawkart\Megatv\SubscribeTable::delete($arSub["ID"]);
}
}
示例2: onFinishChange
/**
* @param \DDelivery\Order\DDeliveryOrder $order
* @throws \Bitrix\Main\ArgumentException
*/
public function onFinishChange($order)
{
global $APPLICATION;
$point = $order->getPoint();
if ($order->type == DDeliverySDK::TYPE_SELF) {
$replaceData = array('%1' => $order->cityName, '%2' => $point['address'], '%3' => $point['delivery_company_name'], '%4' => $point['_id'], '%5' => $point['type'] == 1 ? 'Постомат' : 'ПВЗ');
$replaceData = $APPLICATION->ConvertCharsetArray($replaceData, 'UTF-8', SITE_CHARSET);
$comment = GetMessage('DDELIVERY_ABOUT_SELF', $replaceData);
} else {
if ($order->type == DDeliverySDK::TYPE_COURIER) {
$replaceData = array('%1' => $order->getFullAddress(), '%2' => $point['delivery_company_name']);
$replaceData = $APPLICATION->ConvertCharsetArray($replaceData, 'UTF-8', SITE_CHARSET);
$comment = GetMessage('DDELIVERY_ABOUT_COURIER', $replaceData);
} else {
$comment = 'error';
}
}
$orderId = $this->formData['bx_order_id'];
$params = array('DD_ABOUT' => $comment, 'DD_LOCAL_ID' => $order->localId);
$orderDeliveryTableData = OrderDeliveryTable::getList(array('filter' => array('ORDER_ID' => $orderId)))->fetch();
if ($orderDeliveryTableData) {
OrderDeliveryTable::update($orderDeliveryTableData['ID'], array('PARAMS' => serialize($params)));
} else {
OrderDeliveryTable::add(array('ORDER_ID' => $orderId, 'PARAMS' => serialize($params)));
}
$order = CSaleOrder::GetByID($orderId);
$arDeliveryResult = CSaleDeliveryHandler::CalculateFull('ddelivery', 'ddelivery:all', $order, CSaleLang::GetLangCurrency(SITE_ID), SITE_ID);
if ($arDeliveryResult['RESULT'] == 'OK') {
CSaleOrder::Update($orderId, array('PRICE_DELIVERY' => $arDeliveryResult['VALUE']));
}
}
示例3: CheckFields
public static function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "ORDER_ID") || $ACTION == "ADD") && IntVal($arFields["ORDER_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOPV_EMPTY_ORDER_ID"), "EMPTY_ORDER_ID");
return false;
}
if ((is_set($arFields, "ORDER_PROPS_ID") || $ACTION == "ADD") && IntVal($arFields["ORDER_PROPS_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOPV_EMPTY_PROP_ID"), "EMPTY_ORDER_PROPS_ID");
return false;
}
if (is_set($arFields, "ORDER_ID")) {
if (!($arOrder = CSaleOrder::GetByID($arFields["ORDER_ID"]))) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["ORDER_ID"], GetMessage("SKGOPV_NO_ORDER_ID")), "ERROR_NO_ORDER");
return false;
}
}
if (is_set($arFields, "ORDER_PROPS_ID")) {
if (!($arOrder = CSaleOrderProps::GetByID($arFields["ORDER_PROPS_ID"]))) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["ORDER_PROPS_ID"], GetMessage("SKGOPV_NO_PROP_ID")), "ERROR_NO_PROPERY");
return false;
}
if (is_set($arFields, "ORDER_ID")) {
$arFilter = array("ORDER_ID" => $arFields["ORDER_ID"], "ORDER_PROPS_ID" => $arFields["ORDER_PROPS_ID"]);
if (IntVal($ID) > 0) {
$arFilter["!ID"] = $ID;
}
$dbP = CSaleOrderPropsValue::GetList(array(), $arFilter);
if ($arP = $dbP->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOPV_DUPLICATE_PROP_ID", array("#ID#" => $arFields["ORDER_PROPS_ID"], "#ORDER_ID#" => $arFields["ORDER_ID"])), "ERROR_DUPLICATE_PROP_ID");
return false;
}
}
}
return True;
}
示例4: CheckFields
public static function CheckFields($ACTION, &$arFields)
{
global $DB;
if ((is_set($arFields, "ORDER_ID") || $ACTION=="ADD") && IntVal($arFields["ORDER_ID"])<=0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_ORDER_ID"), "ERROR_NO_ORDER_ID");
return false;
}
if ((is_set($arFields, "TAX_NAME") || $ACTION=="ADD") && strlen($arFields["TAX_NAME"])<=0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_TAX_NAME"), "ERROR_NO_TAX_NAME");
return false;
}
if ((is_set($arFields, "IS_PERCENT") || $ACTION=="ADD") && $arFields["IS_PERCENT"]!="Y" && $arFields["IS_PERCENT"]!="N")
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_TAX_VALUE"), "ERROR_NO_IS_PERCENT");
return false;
}
if ((is_set($arFields, "IS_IN_PRICE") || $ACTION=="ADD") && $arFields["IS_IN_PRICE"]!="Y" && $arFields["IS_IN_PRICE"]!="N")
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_IN_PRICE"), "ERROR_NO_IS_IN_PRICE");
return false;
}
if (is_set($arFields, "VALUE") || $ACTION=="ADD")
{
$arFields["VALUE"] = str_replace(",", ".", $arFields["VALUE"]);
$arFields["VALUE"] = DoubleVal($arFields["VALUE"]);
if ($arFields["VALUE"] <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_SUM"), "ERROR_NO_VALUE");
return false;
}
}
if (is_set($arFields, "VALUE_MONEY") || $ACTION=="ADD")
{
$arFields["VALUE_MONEY"] = str_replace(",", ".", $arFields["VALUE_MONEY"]);
$arFields["VALUE_MONEY"] = DoubleVal($arFields["VALUE_MONEY"]);
}
if ((is_set($arFields, "VALUE_MONEY") || $ACTION=="ADD") && $arFields["VALUE_MONEY"]<=0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOT_EMPTY_SUM_MONEY"), "ERROR_NO_VALUE_MONEY");
return false;
}
if (is_set($arFields, "ORDER_ID"))
{
if (!($arOrder = CSaleOrder::GetByID($arFields["ORDER_ID"])))
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["ORDER_ID"], GetMessage("SKGOT_NO_ORDER")), "ERROR_NO_ORDER");
return false;
}
}
if ((is_set($arFields, "CODE") || $ACTION=="ADD") && strlen($arFields["CODE"])<=0)
$arFields["CODE"] = false;
return true;
}
示例5: OnBasketAddHandler
function OnBasketAddHandler($ID, $arFields)
{
global $USER;
\Bitrix\Main\Loader::includeModule('catalog');
\Bitrix\Main\Loader::includeModule('sale');
if ($USER->IsAuthorized()) {
$arFilter = array("USER_ID" => $USER->GetID());
$db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
$arrCount = [];
while ($ar_sales = $db_sales->Fetch()) {
$arrCount[] = $ar_sales;
}
if (is_array($arrCount) == false) {
$res = CCatalogDiscount::SetCoupon('SL-CDUEA-HI8MMPY');
//3%
} else {
if (count($arrCount) >= 1) {
$resClean = CCatalogDiscount::ClearCoupon('SL-CDUEA-HI8MMPY');
$res5 = CCatalogDiscount::SetCoupon('SL-0JG2C-XIHBEYZ');
//5%
} else {
}
}
} else {
$res = CCatalogDiscountCoupon::SetCoupon('SL-CDUEA-HI8MMPY');
//3%
}
}
示例6: DoPayOrderFromAccount
static function DoPayOrderFromAccount($userId, $currency, $orderId, $orderSum, $arOptions, &$arErrors)
{
if (!array_key_exists("ONLY_FULL_PAY_FROM_ACCOUNT", $arOptions)) {
$arOptions["ONLY_FULL_PAY_FROM_ACCOUNT"] = COption::GetOptionString("sale", "ONLY_FULL_PAY_FROM_ACCOUNT", "N");
}
$dbUserAccount = CSaleUserAccount::GetList(array(), array("USER_ID" => $userId, "CURRENCY" => $currency));
$arUserAccount = $dbUserAccount->Fetch();
if (!$arUserAccount) {
return false;
}
if ($arUserAccount["CURRENT_BUDGET"] <= 0) {
return false;
}
if ($arOptions["ONLY_FULL_PAY_FROM_ACCOUNT"] == "Y" && doubleval($arUserAccount["CURRENT_BUDGET"]) < doubleval($orderSum)) {
return false;
}
$withdrawSum = CSaleUserAccount::Withdraw($userId, $orderSum, $currency, $orderId);
if ($withdrawSum > 0) {
$arFields = array("SUM_PAID" => $withdrawSum, "USER_ID" => $userId);
CSaleOrder::Update($orderId, $arFields);
if ($withdrawSum == $orderSum) {
CSaleOrder::PayOrder($orderId, "Y", False, False);
}
return true;
}
return false;
}
示例7: chStatusOld
public static function chStatusOld($id, $status)
{
try {
self::$o_erip = new \Dm\Erip();
self::$opt_status = \Bitrix\Main\Config\Option::get(self::$module_id, "order_status_code_erip");
self::$opt_payment = \Bitrix\Main\Config\Option::get(self::$module_id, "payment_system_id");
self::$values = CSaleOrder::GetList(array(), array("ID" => $id), false, false, array("ID", "PAY_SYSTEM_ID", "PRICE", "CURRENCY", "STATUS_ID"))->Fetch();
if (self::$values["PAY_SYSTEM_ID"] == self::$opt_payment && $status != self::$values["STATUS_ID"] && $status == self::$opt_status) {
static::setTehnicalInfo();
static::setUserInfo();
static::setMoneyInfo();
$r = self::$o_erip->submit();
self::$o_response = json_decode($r);
if (isset(self::$o_response->errors)) {
throw new \Exception(self::$o_response->message);
}
if (CSaleOrder::Update($id, array("COMMENTS" => "status: " . self::$o_response->transaction->status . "\n" . "transaction_id: " . self::$o_response->transaction->transaction_id . "\n" . "order_id: " . self::$o_response->transaction->order_id . "\n" . "account_number: " . self::$o_response->transaction->erip->account_number . "\n"))) {
static::sendMail();
}
return true;
}
} catch (Exception $e) {
$GLOBALS["APPLICATION"]->ThrowException($e->getMessage());
return false;
}
}
示例8: getOrderInfo
protected static function getOrderInfo($orderId)
{
// order itself
$order = \CSaleOrder::getById($orderId);
// buyer info
$siteUserId = $order['USER_ID'];
$phone = '';
$email = '';
$result = \CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $orderId));
while ($row = $result->fetch()) {
if (empty($phone) && stripos($row['CODE'], 'PHONE') !== false) {
$stPhone = static::normalizePhoneNumber($row['VALUE']);
if (!empty($stPhone)) {
$phone = sha1($stPhone);
}
}
if (empty($email) && stripos($row['CODE'], 'EMAIL') !== false) {
if (!empty($row['VALUE'])) {
$email = sha1($row['VALUE']);
}
}
}
// products info
$products = array();
$result = \CSaleBasket::getList(array(), $arFilter = array('ORDER_ID' => $orderId), false, false, array('PRODUCT_ID'));
while ($row = $result->fetch()) {
$products[] = array('product_id' => $row['PRODUCT_ID'], 'recommendation' => '0');
}
// all together
$data = array('order_id' => $orderId, 'user_id' => $siteUserId, 'phone' => $phone, 'email' => $email, 'products' => $products);
return $data;
}
示例9: mark_order_as_error
protected function mark_order_as_error($order, array $data) {
CSaleOrder::Update($order['ID'], array(
'PS_STATUS' => 'N',
'PS_SUM' => $data['amount'],
'PS_CURRENCY' => $data['currency'],
'PS_STATUS_MESSAGE' => $data['message'],
'PS_RESPONSE_DATE' => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat('FULL', LANG))),
));
}
示例10: isDeliveryInOrders
protected static function isDeliveryInOrders($deliveryId)
{
$dbOrders = \CSaleOrder::GetList(array(), array("DELIVERY_ID" => $deliveryId), false, false, array("ID"));
if ($dbOrders->Fetch()) {
$result = true;
} else {
$result = false;
}
return $result;
}
示例11: OnSalePayOrderHandler
/**
* Обработчик события подтверждения оплаты товара
*/
function OnSalePayOrderHandler($id, $val)
{
$currentUserId = $GLOBALS['USER']->GetID();
//Идентификатор текущего пользователя, по идее администратор
$idRatingGroup = 5;
//группа акции
$curTo = "UAH";
//тип гривневой цены
$arOrder = CSaleOrder::GetByID($id);
//информация о заказе
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["SUM_PAID"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//стоимость заказа
$userId = intval($arOrder["USER_ID"]);
//пользователь, который оплатил заказ
$arUserData = CUser::GetByID($userId)->Fetch();
//Информация о пользователе
$userGroups = CUser::GetUserGroup($userId);
//ИД групп, к которым принадлежит пользователь
//Если пользователя нет в акционной группе, и он совершил заказ более чем на 900 грн, то добавить его в группу
if (!in_array($idRatingGroup, $userGroups)) {
if ($price >= 900 && $price <= 4000 && $val === 'Y') {
$userGroups[] = $idRatingGroup;
CUser::SetUserGroup($userId, $userGroups);
}
}
$points = $price * 5;
$payedUser = new CUser();
//Если оплата подтверждается, то добавить баллы
if ($val === 'Y' && in_array($idRatingGroup, $userGroups)) {
$points = intval($arUserData['UF_ACTION_POINTS']) + $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points, "UF_DATE_LAST_BUY" => $arOrder["DATE_UPDATE_FORMAT"]));
} else {
if ($val === 'N') {
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["PRICE"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//вычитаем полную стоимость
$points = $price * 5;
if ($arUserData['UF_ACTION_POINTS'] >= $points) {
$points = intval($arUserData['UF_ACTION_POINTS']) - $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points));
//Если очков стало меньше 4500, то исключаем пользователя из группы участников
if (in_array($idRatingGroup, $userGroups) && $points < 4500) {
$indexGroup = array_search($idRatingGroup, $userGroups);
if (isset($userGroups[$indexGroup])) {
unset($userGroups[$indexGroup]);
CUser::SetUserGroup($userId, $userGroups);
}
}
}
}
}
unset($payedUser);
}
示例12: OnSaleCancelOrderHandler
public static function OnSaleCancelOrderHandler($ID, $val) {
if ( $val == 'Y' && self::$cancel ) {
$arOrder = CSaleOrder::GetByID($ID);
$resPaySystemAction = CSalePaySystemAction::GetList(array(), array('PAY_SYSTEM_ID'=>$arOrder['PAY_SYSTEM_ID'], 'PERSON_TYPE_ID'=>$arOrder['PERSON_TYPE_ID']), false, false, array());
$arPaySystemAction = $resPaySystemAction->GetNext();
$urlCancel = $_SERVER['DOCUMENT_ROOT'].$arPaySystemAction['ACTION_FILE'].'/cancel.php';
if (preg_match('/\/alfabank$/', $arPaySystemAction['ACTION_FILE']) && file_exists($urlCancel)) {
include $urlCancel;
}
}
}
示例13: OnBeforeEventAddHandler
public static function OnBeforeEventAddHandler(&$event, &$lid, &$arFields)
{
if ($event == "SALE_NEW_ORDER") {
$orderId = $arFields['ORDER_ID'];
$dbOrderProps = CSaleOrderPropsValue::GetList(array("CODE" => "ASC"), array("ORDER_ID" => $orderId, "CODE" => array("ORDER_PHONE", "ORDER_ADDRESS", "ORDER_ADDRESS_DETAILS", "ORDER_NAME")));
while ($arOrderProps = $dbOrderProps->GetNext()) {
$arFields[$arOrderProps['CODE']] = $arOrderProps['~VALUE'];
}
$arFields["ORDER_DESCRIPTION"] = trim(CSaleOrder::GetByID($orderId)["USER_DESCRIPTION"]);
}
}
示例14: OnSalePayOrder
public static function OnSalePayOrder($id, $paid)
{
if (Loader::includeModule('conversion') && ($row = \CSaleOrder::GetById($id))) {
if ($paid == 'Y') {
$context = DayContext::getEntityItemInstance('sale_order', $id);
$context->addCurrencyCounter('sale_payment_sum_add', $row['PRICE'], $row['CURRENCY']);
if (defined('ADMIN_SECTION') && ADMIN_SECTION === true) {
$context->addCounter('sale_payment_add_day', 1);
} else {
$context->addDayCounter('sale_payment_add_day', 1);
}
}
}
}
示例15: getEdit
public static function getEdit(Order $order, \CUser $user, $showCancel, $showSaveButton)
{
$data = self::prepareData($order);
if ($showCancel) {
$bUserCanCancelOrder = \CSaleOrder::CanUserCancelOrder($order->getId(), $user->GetUserGroupArray(), $user->GetID());
} else {
$bUserCanCancelOrder = false;
}
$result = '
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adm-detail-content-table edit-table">
<tbody>
<tr>
<td class="adm-detail-content-cell-l" width="40%">' . Loc::getMessage("SALE_ORDER_STATUS_CREATED") . ':</td>
<td class="adm-detail-content-cell-r">
<div>' . $data["DATE_INSERT"] . ' <a href="/bitrix/admin/user_edit.php?lang=' . LANGUAGE_ID . '&ID=' . $data["CREATOR_USER_ID"] . '">' . htmlspecialcharsbx($data["CREATOR_USER_NAME"]) . '</a>
</div>
</td>
</tr>
<tr>
<td class="adm-detail-content-cell-l">' . Loc::getMessage("SALE_ORDER_STATUS_LAST_MODIF") . ':</td>
<td class="adm-detail-content-cell-r"><div>' . $data["DATE_UPDATE"] . '</div></td>
</tr>
<tr>
<td class="adm-detail-content-cell-l">' . Loc::getMessage("SALE_ORDER_STATUS_SITE") . ':</td>
<td class="adm-detail-content-cell-r"><div>' . htmlspecialcharsbx(\Bitrix\Sale\Helpers\Admin\OrderEdit::getSiteName($order->getSiteId())) . '</div></td>
</tr>';
if (strlen($data['SOURCE_NAME']) > 0) {
$result .= '<tr>' . '<td class="adm-detail-content-cell-l">' . Loc::getMessage("SALE_ORDER_STATUS_SOURCE") . ':</td>' . '<td class="adm-detail-content-cell-r">' . $data['SOURCE_NAME'] . '</td>' . '</tr>';
}
$result .= '<tr>
<td class="adm-detail-content-cell-l">' . Loc::getMessage("SALE_ORDER_STATUS") . ':</td>
<td class="adm-detail-content-cell-r">' . \Bitrix\Sale\Helpers\Admin\OrderEdit::makeSelectHtml("STATUS_ID", self::getStatusesList($user->GetID(), $data["STATUS_ID"]), $data["STATUS_ID"], false, array("class" => "adm-bus-select", "id" => "STATUS_ID"));
if ($showSaveButton) {
$result .= '
<span id="save_status_button" class="adm-btn" onclick="BX.Sale.Admin.OrderEditPage.onSaveStatusButton(\'' . $order->getId() . '\',\'STATUS_ID\');">
' . Loc::getMessage("SALE_ORDER_STATUS_SAVE") . '
</span>';
}
$result .= '</td>
</tr>';
if ($showCancel && $bUserCanCancelOrder) {
$result .= self::getCancelBlockHtml($order, $data);
}
$result .= '</tbody>
</table>
';
return $result;
}