1
0
mirror of synced 2024-12-04 19:06:03 +03:00
* add delivery price

* Update events.php

* fix cron task

* fix cron task

* fix customer

* fix order number
This commit is contained in:
Vitaly Artemev 2017-01-23 02:08:20 +03:00 committed by Alex Lushpai
parent f7ed84d781
commit e0c23b0852
5 changed files with 26 additions and 15 deletions

View File

@ -23,7 +23,7 @@ Module allows integrate UMI.CMS with [RetailCRM](http://www.retailcrm.pro)
Add to cron:
```
* */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
0 */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
```
#### Getting changes in orders

View File

@ -20,7 +20,7 @@ UMI.CMS module
Добавьте в крон запись вида
```
* */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
0 */4 * * * /usr/bin/php /path_to_site/public_html/cron.php RetailCRM icml
```
#### Получение изменение из RetailCRM

View File

@ -43,7 +43,7 @@ class RCrmActions
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
$crmOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $umiOrderDeliveryId);
$customer = customer::get($order->getCustomerId());
$customer = new umiObject($order->getCustomerId());
$orderItems = $order->getItems();
$orderItemsToCrm = array();
@ -98,7 +98,7 @@ class RCrmActions
$oneClickObj = new umiObject($order->getObject()->getValue('purchaser_one_click'));
$orderToCrm = array(
'number' => $order->getObject()->getName(),
'number' => $order->getObject()->getValue('number'),
'externalId' => $order->getId(),
'phone' => $oneClickObj->getValue('phone'),
'customer' => array(
@ -169,7 +169,7 @@ class RCrmActions
}
$orderToCrm = array(
'number' => $order->getObject()->getName(),
'number' => $order->getObject()->getValue('number'),
'externalId' => $order->getId(),
'lastName' => $customer->getValue('lname'),
'firstName' => $customer->getValue('fname'),

View File

@ -225,6 +225,10 @@ class RCrmHistory
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
}
if (isset($crmOrder['delivery']['cost'])) {
$order->getObject()->getPropByName('delivery_price')->setValue($crmOrder['delivery']['cost']);
}
if (isset($crmOrder['delivery']['code'])) {
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
@ -379,6 +383,10 @@ class RCrmHistory
$order->getObject()->getPropByName('payment_status_id')->setValue($umiOrderPaymentStatus);
}
if (isset($crmOrder['delivery']['cost'])) {
$order->getObject()->getPropByName('delivery_price')->setValue($crmOrder['delivery']['cost']);
}
if (isset($crmOrder['delivery']['code'])) {
$relationOrderDeliveryTypesMap = $retailcrm->getRelationMap($config->get('retailcrm', 'orderDeliveryTypeMap'));
$umiOrderDeliveryType = $retailcrm->getRelationByMap($relationOrderDeliveryTypesMap, $crmOrder['delivery']['code'], true);
@ -467,4 +475,4 @@ class RCrmHistory
{
}
}
}

View File

@ -1,15 +1,18 @@
<?php
global $argv;
if ((!isset($argv[2]) || $argv[2] == 'icml') && !isset($_GET['module']) || (isset($_GET['action']) && $_GET['action'] == 'icml')) {
new umiEventListener('cron', 'RetailCRM', 'onCronGenerateICML');
$eventHandlers = array(
'icml' => 'onCronGenerateICML',
'history' => 'onCronSyncHistory',
);
if (isset($_SERVER['argv'][2]) || isset($eventHandlers[$_SERVER['argv'][2]])) {
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_SERVER['argv'][2]]);
}
if ((!isset($argv[2]) || $argv[2] == 'history') && !isset($_GET['module']) || (isset($_GET['action']) && $_GET['action'] == 'history')) {
new umiEventListener('cron', 'RetailCRM', 'onCronSyncHistory');
if (isset($_GET['action']) && isset($eventHandlers[$_GET['action']])) {
new umiEventListener('cron', 'RetailCRM', $eventHandlers[$_GET['action']]);
}
new umiEventListener('systemModifyPropertyValue', 'RetailCRM', 'onModifyProperty');
new umiEventListener('systemModifyObject', 'RetailCRM', 'onModifyObject');
new umiEventListener('order-status-changed', 'RetailCRM', 'onOrderStatusChanged');
?>
?>