Coupon discount (#58)

This commit is contained in:
Akolzin Dmitry 2017-10-30 13:33:57 +03:00 committed by GitHub
parent 023f7f7677
commit dd3c32ea4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 9 deletions

View File

@ -1,13 +1,19 @@
Changelog
=========
####v.1.0.1
* Добавлена передача скидки по купону
####v.1.0
* Улучшена модель получения способов доставки
* Устранены ошибки пакетной выгрузки
####v0.3.0
* Расширена библиотека клиента
* Добавлена возможность кастомизации моделей заказа через vqmod
* Устранены мелкие баги, проведен рефакторинг кода.
####v0.2.0
Общие изменения
@ -37,6 +43,3 @@ Changelog
* Реализована выгрузка каталога (cron only)
* Реализовано получение данных о заказах, сделанных на стороне CRM (cron only)
####v.1.0
* Доработана модель получения способов доставки
* Устранены ошибки пакетной выгрузки

View File

@ -231,6 +231,15 @@ class ModelRetailcrmHistory extends Model
$deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
if(isset($order['discount']) && $order['discount'] > 0) {
$orderTotals = $this->model_sale_order->getOrderTotals($order['externalId']);
foreach($orderTotals as $orderTotal) {
if($orderTotal['code'] == 'coupon') {
$data['order_total'][] = $orderTotal;
}
}
}
$data['order_total'] = array(
array(
'order_total_id' => '',

View File

@ -38,6 +38,8 @@ class ControllerModuleRetailcrm extends Controller
$data['products'][$key]['option'] = $productOptions;
}
$data['totals'] = $this->model_account_order->getOrderTotals($order_id);
if (!isset($data['fromApi'])) {
$this->load->model('setting/setting');
$status = $this->model_setting_setting->getSetting('retailcrm');
@ -45,11 +47,6 @@ class ControllerModuleRetailcrm extends Controller
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
}
$data['totals'][] = array(
'code' => 'shipping',
'value' => $this->session->data['shipping_method']['cost']
);
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
}
@ -77,6 +74,8 @@ class ControllerModuleRetailcrm extends Controller
$data['products'][$key]['option'] = $productOptions;
}
$data['totals'] = $this->model_account_order->getOrderTotals($order_id);
if (!isset($data['fromApi'])) {
$this->load->model('setting/setting');
$status = $this->model_setting_setting->getSetting('retailcrm');

View File

@ -58,6 +58,9 @@ class ModelRetailcrmOrder extends Model {
if ($totals['code'] == 'shipping') {
$deliveryCost = $totals['value'];
}
if ($totals['code'] == 'coupon') {
$couponTotal = abs($totals['value']);
}
}
}
@ -72,6 +75,10 @@ class ModelRetailcrmOrder extends Model {
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
}
if (isset($couponTotal)) {
$order['discount'] = $couponTotal;
}
$delivery_code = $order_data['shipping_code'];
$order['delivery'] = array(
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
@ -182,6 +189,9 @@ class ModelRetailcrmOrder extends Model {
if ($totals['code'] == 'shipping') {
$deliveryCost = $totals['value'];
}
if ($totals['code'] == 'coupon') {
$couponTotal = abs($totals['value']);
}
}
$order['createdAt'] = $order_data['date_added'];
@ -189,6 +199,10 @@ class ModelRetailcrmOrder extends Model {
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
if (isset($couponTotal)) {
$order['discount'] = $couponTotal;
}
$order['delivery'] = array(
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
'cost' => $deliveryCost,