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

View File

@ -58,3 +58,7 @@ http://youropencartsite.com/retailcrm.xml
Запустите команду единожды:
/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));
$this->model_setting_setting->deleteSetting('retailcrm_history');
$this->loadModels();
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']];
$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'];
}
if ($order_data['customer_id']) {
$order['customer']['externalId'] = $order_data['customer_id'];
}
$deliveryCost = 0;
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
@ -193,12 +195,6 @@ class ModelExtensionRetailcrmOrder extends Model {
{
$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'];
foreach ($order['totals'] as $total) {
@ -211,16 +207,6 @@ class ModelExtensionRetailcrmOrder extends Model {
'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(
'externalId' => $order_id
);

View File

@ -376,9 +376,10 @@
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
},
success: function(data, textStatus, jqXHR) {
if (jqXHR['responseText'] == '400') {
response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.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');
} else {
$('.alert-success').remove();

View File

@ -378,9 +378,11 @@
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
},
success: function(data, textStatus, jqXHR) {
if (jqXHR['responseText'] == '400') {
response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.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');
} else {
$('.alert-success').remove();

View File

@ -79,6 +79,8 @@ class ModelExtensionRetailcrmOrder extends Model {
if ($response->isSuccessful()) {
$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);
}
}
}
@ -90,12 +92,6 @@ class ModelExtensionRetailcrmOrder extends Model {
$this->load->model('catalog/product');
$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'];
$order['externalId'] = $order_id;
$order['firstName'] = $order_data['firstname'];
@ -225,18 +221,6 @@ class ModelExtensionRetailcrmOrder extends Model {
$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']) {
$customFields = $order_data['custom_field'];
@ -257,12 +241,6 @@ class ModelExtensionRetailcrmOrder extends Model {
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'];
foreach ($order['totals'] as $total) {
@ -284,16 +262,12 @@ class ModelExtensionRetailcrmOrder extends Model {
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'];
foreach ($order['totals'] as $total) {
if ($total['code'] == 'total') $amount = $total['value'];
if ($total['code'] == 'total') {
$amount = $total['value'];
}
}
$payment = array(