当前位置: 首页>>代码示例>>PHP>>正文


PHP CSaleUserAccount::UnLock方法代码示例

本文整理汇总了PHP中CSaleUserAccount::UnLock方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleUserAccount::UnLock方法的具体用法?PHP CSaleUserAccount::UnLock怎么用?PHP CSaleUserAccount::UnLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSaleUserAccount的用法示例。


在下文中一共展示了CSaleUserAccount::UnLock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: UpdateAccount

 function UpdateAccount($userID, $sum, $currency, $description = "", $orderID = 0, $notes = "")
 {
     global $DB;
     $userID = IntVal($userID);
     if ($userID <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_EMPTYID"), "EMPTY_USER_ID");
         return False;
     }
     $dbUser = CUser::GetByID($userID);
     if (!$dbUser->Fetch()) {
         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $userID, GetMessage("SKGU_NO_USER")), "ERROR_NO_USER_ID");
         return False;
     }
     $sum = str_replace(",", ".", $sum);
     $sum = DoubleVal($sum);
     $currency = Trim($currency);
     if (strlen($currency) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_EMPTY_CUR"), "EMPTY_CURRENCY");
         return False;
     }
     $orderID = IntVal($orderID);
     if (!CSaleUserAccount::Lock($userID, $currency)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_ACCOUNT_NOT_WORK"), "ACCOUNT_NOT_LOCKED");
         return False;
     }
     $result = false;
     $dbUserAccount = CSaleUserAccount::GetList(array(), array("USER_ID" => $userID, "CURRENCY" => $currency));
     if ($arUserAccount = $dbUserAccount->Fetch()) {
         $arFields = array("CURRENT_BUDGET" => $arUserAccount["CURRENT_BUDGET"] + $sum);
         $result = CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
     } else {
         $arFields = array("USER_ID" => $userID, "CURRENT_BUDGET" => $sum, "CURRENCY" => $currency, "LOCKED" => "Y", "DATE_LOCKED" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))));
         $result = CSaleUserAccount::Add($arFields);
     }
     if ($result) {
         $arFields = array("USER_ID" => $userID, "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))), "AMOUNT" => $sum > 0 ? $sum : -$sum, "CURRENCY" => $currency, "DEBIT" => $sum > 0 ? "Y" : "N", "ORDER_ID" => $orderID > 0 ? $orderID : False, "DESCRIPTION" => strlen($description) > 0 ? $description : False, "NOTES" => strlen($notes) > 0 ? $notes : False, "EMPLOYEE_ID" => $GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : False);
         CSaleUserTransact::Add($arFields);
     }
     CSaleUserAccount::UnLock($userID, $currency);
     return $result;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:41,代码来源:user.php

示例2: UpdateAccount


//.........这里部分代码省略.........
  *
  * @param string $notes = ""]]] 
  *
  * @return int <p>Метод возвращает код пользовательского счета или <i>false</i> в
  * случае ошибки.</p> <p></p><div class="note"> <b>Замечания:</b> <ul> <li>Деньги
  * снимаются только со счета той же валюты, которая передается
  * параметром в метод. Счета пользователя в другой валюте не
  * затрагиваются.</li> <li>Если счета в данной валюте раньше у
  * пользователя не было, то он автоматически создастся (и будет
  * возвращен код созданного счета).</li> </ul> </div> <a name="examples"></a>
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // Напишем функцию обратного вызова, которая будет вызываться при изменении
  * // флага "Доставка разрешена" заказа и добавлять (или снимать) 100 USD на счет
  * 
  * function MyDeliveryOrderCallback($productID, $userID, $bPaid, $orderID)
  * {
  *     global $DB;
  * 
  *     // Обработаем входные параметры
  *     $productID = IntVal($productID);    // Код заказанного товара
  *     $userID = IntVal($userID);  // Код пользователя-покупателя
  *     $bPaid = ($bPaid ? True : False);   // Устанавливается или снимается флаг доставки
  *     $orderID = IntVal($orderID);    // Код заказа
  * 
  *     if ($userID &lt;= 0)
  *         return False;
  * 
  *     if ($orderID &lt;= 0)
  *         return False;
  * 
  *     // Внесем (снимем) деньги на счет
  *     if (!CSaleUserAccount::UpdateAccount(
  *             $userID,
  *             ($bPaid ? 100 : -100),
  *             "USD",
  *             "MANUAL",
  *             $orderID
  *         ))
  *         return False;
  * 
  *     return True;
  * }
  * ?&gt;
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleuseraccount/csaleuseraccount.updateaccount.php
  * @author Bitrix
  */
 public static function UpdateAccount($userID, $sum, $currency, $description = "", $orderID = 0, $notes = "", $paymentId = null)
 {
     global $DB, $APPLICATION;
     $userID = (int) $userID;
     if ($userID <= 0) {
         $APPLICATION->ThrowException(GetMessage("SKGU_EMPTYID"), "EMPTY_USER_ID");
         return False;
     }
     $dbUser = CUser::GetByID($userID);
     if (!$dbUser->Fetch()) {
         $APPLICATION->ThrowException(str_replace("#ID#", $userID, GetMessage("SKGU_NO_USER")), "ERROR_NO_USER_ID");
         return False;
     }
     $sum = (double) str_replace(",", ".", $sum);
     $currency = trim($currency);
     if ($currency === '') {
         $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_CUR"), "EMPTY_CURRENCY");
         return False;
     }
     $orderID = (int) $orderID;
     $paymentId = (int) $paymentId;
     if (!CSaleUserAccount::Lock($userID, $currency)) {
         $APPLICATION->ThrowException(GetMessage("SKGU_ACCOUNT_NOT_WORK"), "ACCOUNT_NOT_LOCKED");
         return False;
     }
     $currentBudget = 0.0;
     $result = false;
     $dbUserAccount = CSaleUserAccount::GetList(array(), array("USER_ID" => $userID, "CURRENCY" => $currency));
     if ($arUserAccount = $dbUserAccount->Fetch()) {
         $currentBudget = floatval($arUserAccount["CURRENT_BUDGET"]);
         $arFields = array("CURRENT_BUDGET" => $arUserAccount["CURRENT_BUDGET"] + $sum);
         $result = CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
     } else {
         $currentBudget = floatval($sum);
         $arFields = array("USER_ID" => $userID, "CURRENT_BUDGET" => $sum, "CURRENCY" => $currency, "LOCKED" => "Y", "DATE_LOCKED" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))));
         $result = CSaleUserAccount::Add($arFields);
     }
     if ($result) {
         if (isset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_" . $userID . "_" . $currency])) {
             unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_" . $userID . "_" . $currency]);
         }
         $arFields = array("USER_ID" => $userID, "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))), "CURRENT_BUDGET" => $currentBudget, "AMOUNT" => $sum > 0 ? $sum : -$sum, "CURRENCY" => $currency, "DEBIT" => $sum > 0 ? "Y" : "N", "ORDER_ID" => $orderID > 0 ? $orderID : False, "PAYMENT_ID" => $paymentId > 0 ? $paymentId : false, "DESCRIPTION" => strlen($description) > 0 ? $description : False, "NOTES" => strlen($notes) > 0 ? $notes : False, "EMPLOYEE_ID" => $GLOBALS["USER"]->IsAuthorized() ? $GLOBALS["USER"]->GetID() : False);
         CSaleUserTransact::Add($arFields);
     }
     CSaleUserAccount::UnLock($userID, $currency);
     return $result;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:user.php

示例3: str_replace

     $arUserAccount = $dbUserAccount->Fetch();
     $currentLocked = $arUserAccount["LOCKED"];
     $CURRENT_BUDGET = str_replace(",", ".", $CURRENT_BUDGET);
     $CURRENT_BUDGET = DoubleVal($CURRENT_BUDGET);
     $updateSum = $CURRENT_BUDGET - $OLD_BUDGET;
     if (!CSaleUserAccount::UpdateAccount($USER_ID, $updateSum, $CURRENCY, "MANUAL", 0, $CHANGE_REASON)) {
         if ($ex = $APPLICATION->GetException()) {
             $errorMessage .= $ex->GetString() . ".<br>";
         } else {
             $errorMessage .= GetMessage("SAE_ERROR_SAVING") . ".<br>";
         }
     }
 }
 if (strlen($errorMessage) <= 0 and $currentLocked != "") {
     if ($_POST["UNLOCK"] == "Y") {
         CSaleUserAccount::UnLock($USER_ID, $CURRENCY);
     }
     if ($_POST["UNLOCK"] == "N" or $currentLocked == "Y" and !isset($_POST["UNLOCK"])) {
         CSaleUserAccount::Lock($USER_ID, $CURRENCY);
     }
 }
 if (strlen($errorMessage) <= 0) {
     $arUserAccount = CSaleUserAccount::GetByUserID($USER_ID, $CURRENCY);
     if (DoubleVal($arUserAccount["CURRENT_BUDGET"]) != $CURRENT_BUDGET) {
         $errorMessage .= GetMessage("SAE_ERROR_SAVING_SUM") . ".<br>";
     }
 }
 if (strlen($errorMessage) <= 0) {
     $ID = IntVal($arUserAccount["ID"]);
     $arFields = array("NOTES" => strlen($NOTES) > 0 ? $NOTES : False);
     if (!CSaleUserAccount::Update($ID, $arFields)) {
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:account_edit.php


注:本文中的CSaleUserAccount::UnLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。