- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/internals/userbudgetpool.php
- Класс: BitrixSaleInternalsUserBudgetPool
- Вызов: UserBudgetPool::onUserBudgetSave
static function onUserBudgetSave($userId)
{
$result = new SaleResult();
$pool = static::getUserBudgetPool($userId);
if ($pool->isStatusLockEarlier())
{
return $result->addError(
new SaleResultError(
Loc::getMessage('SALE_PROVIDER_USER_BUDGET_LOCKED')
)
);
}
foreach ($pool->get() as $key => $budgetDat)
{
$orderId = null;
$paymentId = null;
if (isset($budgetDat['ORDER'])
&& ($budgetDat['ORDER'] instanceof SaleOrderBase))
{
$orderId = $budgetDat['ORDER']->getId();
}
if (isset($budgetDat['PAYMENT'])
&& ($budgetDat['PAYMENT'] instanceof SalePayment))
{
$paymentId = $budgetDat['PAYMENT']->getId();
}
if (!CSaleUserAccount::UpdateAccount($userId, $budgetDat['SUM'], $budgetDat['CURRENCY'], $budgetDat['TYPE'], $orderId, '', $paymentId))
{
$result->addError( new SaleResultError(Loc::getMessage("SALE_PROVIDER_USER_BUDGET_".$budgetDat['TYPE']."_ERROR"), "SALE_PROVIDER_USER_BUDGET_".$budgetDat['TYPE']."_ERROR") );
}
$pool->delete($key);
}
return $result;
}