This commit is contained in:
Akolzin Dmitry 2017-10-30 16:49:49 +03:00 committed by GitHub
parent afc2c9156c
commit 680e1c28fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 65 deletions

View File

@ -1,6 +1,11 @@
## v.2.4.0 ## v.2.4.3
* Добавлена возможность работы на 3 версиях API (v3, v4, v5) * Устранены некоторые баги, добавлен вывод ошибок при выгрузке единичных заказов
* Добавлена совместимость с Opencart 3.0
## v.2.4.2
* Улучшена синхронизация кастомных полей
* Добавлены настройки дефолтных способов доставки и оплаты
* Улучшена настройка Daemon Collector
* Доработан шаблон twig для совместимости с Opencart 3.0
## v.2.4.1 ## v.2.4.1
* Исправлена работа истории (доработана обработка адресов, добавлена обработка заказов с пустыми полями, доработана история по клиентам) * Исправлена работа истории (доработана обработка адресов, добавлена обработка заказов с пустыми полями, доработана история по клиентам)
@ -8,8 +13,7 @@
* Проверка доступных версий API через метод /api/versions * Проверка доступных версий API через метод /api/versions
* Добавлена возможность сопоставления кастомных полей(для API v5) * Добавлена возможность сопоставления кастомных полей(для API v5)
## v.2.4.2 ## v.2.4.0
* Доработана синхронизация кастомных полей * Добавлена возможность работы на 3 версиях API (v3, v4, v5)
* Добавлены настройки дефолтных способов доставки и оплаты * Добавлена совместимость с Opencart 3.0
* Доработана настройка Daemon Collector
* Доработан шаблон twig для совместимости с Opencart 3.0

View File

@ -58,3 +58,7 @@ http://youropencartsite.com/retailcrm.xml
Запустите команду единожды: Запустите команду единожды:
/usr/bin/php /path/to/opencart/system/cron/export.php /usr/bin/php /path/to/opencart/system/cron/export.php
#### Кастомизация моделей
Для создания кастомных классов скопируйте файл модели в директорию custom, в новом файле измените название класса с "ModelExtensionRetailcrmFilename" на "ModelExtensionRetailcrmCustomFilename", где "Filename" - название файла с заглавной буквы. После этого модуль будет использовать методы кастомного класса.

View File

@ -93,7 +93,12 @@ class ControllerExtensionModuleRetailcrm extends Controller
->editSetting($moduleTitle, array($moduleTitle . '_status' => 0)); ->editSetting($moduleTitle, array($moduleTitle . '_status' => 0));
$this->model_setting_setting->deleteSetting('retailcrm_history'); $this->model_setting_setting->deleteSetting('retailcrm_history');
$this->loadModels(); $this->loadModels();
$this->{'model_' . $this->modelEvent}->deleteEvent($moduleTitle);
if (version_compare(VERSION, '3.0', '<')) {
$this->{'model_' . $this->modelEvent}->deleteEvent($moduleTitle);
} else {
$this->{'model_' . $this->modelEvent}->deleteEventByCode($moduleTitle);
}
} }
/** /**
@ -545,10 +550,29 @@ class ControllerExtensionModuleRetailcrm extends Controller
$data['order_status'] = $status[$moduleTitle . '_status'][$data['order_status_id']]; $data['order_status'] = $status[$moduleTitle . '_status'][$data['order_status_id']];
$this->load->model('extension/retailcrm/order'); $this->load->model('extension/retailcrm/order');
$result = $this->model_extension_retailcrm_order->uploadOrder($data); $response = $this->model_extension_retailcrm_order->uploadOrder($data);
} }
echo json_encode($result->getStatusCode()); if (!$response->isSuccessful()) {
if (isset($response['errors'])) {
$error = implode("\n", $response['errors']);
} else {
$error = $response->getErrorMsg();
}
echo json_encode(
array(
'status_code' => $response->getStatusCode(),
'error_msg' => $error
)
);
} else {
echo json_encode(
array(
'status_code' => $response->getStatusCode()
)
);
}
} }
/** /**

View File

@ -72,7 +72,9 @@ class ModelExtensionRetailcrmOrder extends Model {
$order['email'] = $order_data['email']; $order['email'] = $order_data['email'];
} }
$order['customer']['externalId'] = $order_data['customer_id']; if ($order_data['customer_id']) {
$order['customer']['externalId'] = $order_data['customer_id'];
}
$deliveryCost = 0; $deliveryCost = 0;
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ; $orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
@ -192,12 +194,6 @@ class ModelExtensionRetailcrmOrder extends Model {
protected function createPayment($order, $order_id) protected function createPayment($order, $order_id)
{ {
$this->moduleTitle = $this->getModuleTitle(); $this->moduleTitle = $this->getModuleTitle();
if (version_compare(VERSION, '3.0', '<')) {
$settingPaid = $this->model_setting_setting->getSetting($order['payment_code']);
} else {
$settingPaid = $this->model_setting_setting->getSetting('payment_' . $order['payment_code']);
}
$payment_code = $order['payment_code']; $payment_code = $order['payment_code'];
@ -211,16 +207,6 @@ class ModelExtensionRetailcrmOrder extends Model {
'amount' => $amount 'amount' => $amount
); );
if (version_compare(VERSION, '3.0', '<')) {
if ($order['order_status_id'] == $settingPaid[$order['payment_code'] . '_order_status_id']) {
$payment['status'] = 'paid';
}
} else {
if ($order['order_status_id'] == $settingPaid['payment_' . $order['payment_code'] . '_order_status_id']) {
$payment['status'] = 'paid';
}
}
$payment['order'] = array( $payment['order'] = array(
'externalId' => $order_id 'externalId' => $order_id
); );

View File

@ -376,9 +376,10 @@
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}, },
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
if (jqXHR['responseText'] == '400') { response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.alert-danger').remove(); $('.alert-danger').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i><?php echo $text_error_order; ?></div>'); $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i><?php echo $text_error_order; ?>' + response['error_msg'] + '</div>');
$('#export_order').button('reset'); $('#export_order').button('reset');
} else { } else {
$('.alert-success').remove(); $('.alert-success').remove();

View File

@ -378,9 +378,11 @@
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}, },
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
if (jqXHR['responseText'] == '400') { response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.alert-danger').remove(); $('.alert-danger').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>{{ text_error_order }}</div>'); $('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>{{ text_error_order }}' + response['error_msg'] + '</div>');
$('#export_order').button('reset'); $('#export_order').button('reset');
} else { } else {
$('.alert-success').remove(); $('.alert-success').remove();

View File

@ -79,6 +79,8 @@ class ModelExtensionRetailcrmOrder extends Model {
if ($response->isSuccessful()) { if ($response->isSuccessful()) {
$this->createPayment($order_data, $order_id); $this->createPayment($order_data, $order_id);
} }
} elseif (isset($payment) && $payment['type'] == $this->settings[$this->moduleTitle . '_payment'][$order_data['payment_code']]) {
$this->editPayment($order_data, $order_id);
} }
} }
} }
@ -89,12 +91,6 @@ class ModelExtensionRetailcrmOrder extends Model {
$this->load->model('setting/setting'); $this->load->model('setting/setting');
$this->load->model('catalog/product'); $this->load->model('catalog/product');
$this->settings = $this->model_setting_setting->getSetting($this->moduleTitle); $this->settings = $this->model_setting_setting->getSetting($this->moduleTitle);
if (version_compare(VERSION, '3.0', '<')) {
$settingPaid = $this->model_setting_setting->getSetting($order_data['payment_code']);
} else {
$settingPaid = $this->model_setting_setting->getSetting('payment_' . $order_data['payment_code']);
}
$payment_code = $order_data['payment_code']; $payment_code = $order_data['payment_code'];
$order['externalId'] = $order_id; $order['externalId'] = $order_id;
@ -225,18 +221,6 @@ class ModelExtensionRetailcrmOrder extends Model {
$order['status'] = $this->settings[$this->moduleTitle . '_status'][$order_data['order_status_id']]; $order['status'] = $this->settings[$this->moduleTitle . '_status'][$order_data['order_status_id']];
} }
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v5') {
if (version_compare(VERSION, '3.0', '<')) {
if ($order_data['order_status_id'] == $settingPaid[$order_data['payment_code'] . '_order_status_id']) {
$order['paymentStatus'] = 'paid';
}
} else {
if ($order_data['order_status_id'] == $settingPaid['payment_' . $order_data['payment_code'] . '_order_status_id']) {
$order['paymentStatus'] = 'paid';
}
}
}
if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) { if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) {
$customFields = $order_data['custom_field']; $customFields = $order_data['custom_field'];
@ -256,13 +240,7 @@ class ModelExtensionRetailcrmOrder extends Model {
} }
protected function createPayment($order, $order_id) protected function createPayment($order, $order_id)
{ {
if (version_compare(VERSION, '3.0', '<')) {
$settingPaid = $this->model_setting_setting->getSetting($order['payment_code']);
} else {
$settingPaid = $this->model_setting_setting->getSetting('payment_' . $order['payment_code']);
}
$payment_code = $order['payment_code']; $payment_code = $order['payment_code'];
foreach ($order['totals'] as $total) { foreach ($order['totals'] as $total) {
@ -283,17 +261,13 @@ class ModelExtensionRetailcrmOrder extends Model {
} }
protected function editPayment($order, $order_id) protected function editPayment($order, $order_id)
{ {
if (version_compare(VERSION, '3.0', '<')) {
$settingPaid = $this->model_setting_setting->getSetting($order['payment_code']);
} else {
$settingPaid = $this->model_setting_setting->getSetting('payment_' . $order['payment_code']);
}
$payment_code = $order['payment_code']; $payment_code = $order['payment_code'];
foreach ($order['totals'] as $total) { foreach ($order['totals'] as $total) {
if ($total['code'] == 'total') $amount = $total['value']; if ($total['code'] == 'total') {
$amount = $total['value'];
}
} }
$payment = array( $payment = array(