- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/order/payment.php
- Класс: Bitrix\Crm\Order\Payment
- Вызов: Payment::onAfterSave
protected function onAfterSave($isNew)
{
if ($isNew)
{
$this->addTimelineEntryOnCreate();
$this->savePaymentStageOnCreate();
}
elseif ($this->fields->isChanged('SUM') || $this->fields->isChanged('CURRENCY') )
{
$this->updateTimelineCreationEntity();
}
if ($this->fields->isChanged('PAID'))
{
if ($this->isPaid() && Crm\Automation\Factory::isAutomationAvailable(\CCrmOwnerType::Order))
{
Crm\Automation\Trigger\PaymentTrigger::execute(
[['OWNER_TYPE_ID' => \CCrmOwnerType::Order, 'OWNER_ID' => $this->getOrderId()]],
['PAYMENT' => $this]
);
}
if (!$isNew && !$this->getOrder()->isNew())
{
$timelineParams = [
'FIELDS' => $this->getFieldValues(),
'SETTINGS' => [
'FIELDS' => [
'ORDER_PAID' => $this->getField('PAID'),
'ORDER_DONE' => 'N'
]
],
'BINDINGS' => $this->getTimelineBindings(),
'ENTITY' => $this,
];
Crm\Timeline\OrderPaymentController::getInstance()->onPaid($this->getId(), $timelineParams);
$this->savePaymentStageOnUpdate();
}
if ($this->isPaid())
{
Activity\Provider\Payment::addActivity($this);
$this->sendOrderPaidSmsToClient();
}
}
if(Main\Loader::includeModule('pull'))
{
\CPullWatch::AddToStack(
'CRM_ENTITY_ORDER_PAYMENT',
[
'module_id' => 'crm',
'command' => 'onOrderPaymentSave',
'params' => [
'FIELDS' => $this->getFieldValues()
]
]
);
}
}