本文整理汇总了PHP中CSaleUserAccount::Pay方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleUserAccount::Pay方法的具体用法?PHP CSaleUserAccount::Pay怎么用?PHP CSaleUserAccount::Pay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleUserAccount
的用法示例。
在下文中一共展示了CSaleUserAccount::Pay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PayOrder
function PayOrder($ID, $val, $bWithdraw = True, $bPay = True, $recurringID = 0, $arAdditionalFields = array())
{
global $DB, $USER;
$ID = IntVal($ID);
$val = $val != "Y" ? "N" : "Y";
$bWithdraw = $bWithdraw ? True : False;
$bPay = $bPay ? True : False;
$recurringID = IntVal($recurringID);
$NO_CHANGE_STATUS = "N";
if (is_set($arAdditionalFields["NOT_CHANGE_STATUS"]) && $arAdditionalFields["NOT_CHANGE_STATUS"] == "Y") {
$NO_CHANGE_STATUS = "Y";
unset($arAdditionalFields["NOT_CHANGE_STATUS"]);
}
if ($ID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_NO_ORDER_ID"), "NO_ORDER_ID");
return False;
}
$arOrder = CSaleOrder::GetByID($ID);
if (!$arOrder) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_NO_ORDER")), "NO_ORDER");
return False;
}
if ($arOrder["PAYED"] == $val) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_DUB_PAY")), "ALREADY_FLAG");
return False;
}
foreach (GetModuleEvents("sale", "OnSaleBeforePayOrder", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, $val, $bWithdraw, $bPay, $recurringID, $arAdditionalFields)) === false) {
return false;
}
}
if ($bWithdraw) {
if ($val == "Y") {
$needPaySum = DoubleVal($arOrder["PRICE"]) - DoubleVal($arOrder["SUM_PAID"]);
if ($bPay) {
if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $needPaySum, $arOrder["CURRENCY"], "OUT_CHARGE_OFF", $ID)) {
return False;
}
}
if ($needPaySum > 0 && !CSaleUserAccount::Pay($arOrder["USER_ID"], $needPaySum, $arOrder["CURRENCY"], $ID, False)) {
return False;
}
} else {
if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $arOrder["PRICE"], $arOrder["CURRENCY"], "ORDER_UNPAY", $ID)) {
return False;
}
}
}
$arFields = array("PAYED" => $val, "=DATE_PAYED" => $DB->GetNowFunction(), "EMP_PAYED_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false, "SUM_PAID" => 0);
if (count($arAdditionalFields) > 0) {
foreach ($arAdditionalFields as $addKey => $addValue) {
if (!array_key_exists($addKey, $arFields)) {
$arFields[$addKey] = $addValue;
}
}
}
$res = CSaleOrder::Update($ID, $arFields);
foreach (GetModuleEvents("sale", "OnSalePayOrder", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $val));
}
if ($val == "Y") {
CTimeZone::Disable();
$arOrder = CSaleOrder::GetByID($ID);
CTimeZone::Enable();
if ($NO_CHANGE_STATUS != "Y") {
$orderStatus = COption::GetOptionString("sale", "status_on_paid", "");
if (strlen($orderStatus) > 0 && $orderStatus != $arOrder["STATUS_ID"]) {
$dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
while ($arStatus = $dbStatus->GetNext()) {
$arStatuses[$arStatus["ID"]] = $arStatus["SORT"];
}
if ($arStatuses[$orderStatus] >= $arStatuses[$arOrder["STATUS_ID"]]) {
CSaleOrder::StatusOrder($ID, $orderStatus);
}
}
}
$userEMail = "";
$dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"], "PROP_IS_EMAIL" => "Y"));
if ($arOrderProp = $dbOrderProp->Fetch()) {
$userEMail = $arOrderProp["VALUE"];
}
if (strlen($userEMail) <= 0) {
$dbUser = CUser::GetByID($arOrder["USER_ID"]);
if ($arUser = $dbUser->Fetch()) {
$userEMail = $arUser["EMAIL"];
}
}
$arFields = array("ORDER_ID" => $ID, "ORDER_DATE" => $arOrder["DATE_INSERT_FORMAT"], "EMAIL" => $userEMail, "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"]));
$eventName = "SALE_ORDER_PAID";
$bSend = true;
foreach (GetModuleEvents("sale", "OnOrderPaySendEmail", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID, &$eventName, &$arFields)) === false) {
$bSend = false;
}
}
if ($bSend) {
$event = new CEvent();
$event->Send($eventName, $arOrder["LID"], $arFields, "N");
}
if (CModule::IncludeModule("statistic")) {
//.........这里部分代码省略.........
示例2: NextPayment
/**
* <p>Метод осуществляет продление подписки с кодом ID.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
*
*
*
*
* @param int $ID Код записи с информацией о продлении.
*
*
*
* @return bool <p>Метод возвращает <i>true</i> в случае успешного продления или <i>false</i>
* в случае ошибки.</p><br><br>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalerecurring/csalerecurring.nextpayment.php
* @author Bitrix
*/
public static 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) || count($arProduct) <= 0)
{
CSaleRecurring::CancelRecurring($arRecur["ID"], "Y", "Product is not found");
/*
$arFields = array(
"CANCELED" => "Y",
"DATE_CANCELED" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))),
"CANCELED_REASON" => "Product is not found"
);
CSaleRecurring::Update($arRecur["ID"], $arFields);
*/
//CSaleRecurring::Delete($arRecur["ID"]);
return True;
}
if ($arProduct["WITHOUT_ORDER"] == "Y" || $arRecur["SUCCESS_PAYMENT"] == "Y")
{
$baseSiteCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
$productPrice = roundEx(CCurrencyRates::ConvertCurrency($arProduct["PRICE"], $arProduct["CURRENCY"], $baseSiteCurrency), SALE_VALUE_PRECISION);
// 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"
),
//.........这里部分代码省略.........