本文整理汇总了PHP中CSaleOrder::GetNextAccountNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder::GetNextAccountNumber方法的具体用法?PHP CSaleOrder::GetNextAccountNumber怎么用?PHP CSaleOrder::GetNextAccountNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrder
的用法示例。
在下文中一共展示了CSaleOrder::GetNextAccountNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAccountNumber
/**
* @internal
* @param $id
*
* @return Sale\Result
* @throws Exception
* @throws \Bitrix\Main\ArgumentNullException
*/
protected static function generateAccountNumber($id)
{
$result = new Sale\Result();
$id = intval($id);
if ($id <= 0) {
$result->addError(new Sale\ResultError(Loc::getMessage('SALE_ORDER_GENERATE_ACCOUNT_NUMBER_ORDER_NUMBER_WRONG_ID'), 'SALE_ORDER_GENERATE_ACCOUNT_NUMBER_ORDER_NUMBER_WRONG_ID'));
return $result;
}
$type = \Bitrix\Main\Config\Option::get("sale", "account_number_template", "");
$param = \Bitrix\Main\Config\Option::get("sale", "account_number_data", "");
$isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
$res = false;
$value = null;
if ($type != "") {
for ($i = 0; $i < 10; $i++) {
$value = CSaleOrder::GetNextAccountNumber($id, $type, $param);
if ($value) {
if ($isOrderConverted == "Y") {
try {
/** @var \Bitrix\Sale\Result $r */
$r = \Bitrix\Sale\Internals\OrderTable::update($id, array("ACCOUNT_NUMBER" => $value));
$res = $r->isSuccess();
} catch (\Bitrix\Main\DB\SqlQueryException $exception) {
$res = false;
}
} else {
$res = CSaleOrder::Update($id, array("ACCOUNT_NUMBER" => $value), false);
}
if ($res) {
break;
}
}
}
}
if (!$res) {
$result->addError(new Sale\ResultError(Loc::getMessage('SALE_ORDER_GENERATE_ACCOUNT_NUMBER_ORDER_NUMBER_IS_NOT_SET'), 'SALE_ORDER_GENERATE_ACCOUNT_NUMBER_ORDER_NUMBER_IS_NOT_SET'));
return $result;
}
$result->setData(array('VALUE' => strval($value) != '' ? $value : null));
return $result;
}
示例2: SetAccountNumber
/**
* Sets order account number
* Use OnBeforeOrderAccountNumberSet event to generate custom account number.
* Account number value must be unique! By default order ID is used if generated value is incorrect
*
* @param int $ID - order ID
* @return bool - true if account number is set successfully
*/
public static function SetAccountNumber($ID)
{
$ID = intval($ID);
if ($ID <= 0)
return false;
$type = COption::GetOptionString("sale", "account_number_template", "");
$param = COption::GetOptionString("sale", "account_number_data", "");
$bCustomAlgorithm = false;
foreach(GetModuleEvents("sale", "OnBeforeOrderAccountNumberSet", true) as $arEvent)
{
$tmpRes = ExecuteModuleEventEx($arEvent, Array($ID, $type));
if ($tmpRes !== false)
{
$bCustomAlgorithm = true;
$value = $tmpRes;
}
}
if ($bCustomAlgorithm)
{
$res = CSaleOrder::Update($ID, array("ACCOUNT_NUMBER" => $value), false);
}
else
{
$res = false;
if ($type != "") // if special template is selected
{
for ($i = 0; $i < 10; $i++)
{
$value = CSaleOrder::GetNextAccountNumber($ID, $type, $param);
if ($value)
{
$res = CSaleOrder::Update($ID, array("ACCOUNT_NUMBER" => $value), false);
if ($res)
break;
}
}
}
}
if ($type == "" || !$res) // if no special template is used or error occured
{
$res = CSaleOrder::Update($ID, array("ACCOUNT_NUMBER" => $ID), false);
}
return $res;
}