Merge pull request #146 from sergeygw1990/master

v3.3.0
This commit is contained in:
Alex Lushpai 2019-03-21 16:59:53 +03:00 committed by GitHub
commit 702c18d757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 2 deletions

View File

@ -1,6 +1,7 @@
## v.3.3.0
* Добавена настройка записи истории изменения заказов в Opencart
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
* Добавлена передача типа цены при создании и редактировании заказа
## v.3.2.4
* Добавлена возможность передачи акционных цен для нескольких групп пользователей

View File

@ -92,6 +92,8 @@ class ModelExtensionRetailcrmOrder extends Model {
public function processOrder($order_data, $create = true) {
$this->load->model('setting/setting');
$this->load->model('catalog/product');
$this->load->model('account/customer');
$this->load->model('extension/retailcrm/product');
$this->settings = $this->model_setting_setting->getSetting($this->moduleTitle);
$order_id = $order_data['order_id'];
@ -255,8 +257,24 @@ class ModelExtensionRetailcrmOrder extends Model {
),
'productName' => $product['name'],
'initialPrice' => $product['price'],
'quantity' => $product['quantity'],
'quantity' => $product['quantity']
);
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
if (!empty($specials)) {
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
foreach ($specials as $special) {
if (isset($customer['customer_group_id'])) {
if ($special['customer_group_id'] == $customer['customer_group_id']) {
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
}
}
}
}
}
} else {
$item = array(
'productName' => $product['name'],

View File

@ -0,0 +1,10 @@
<?php
class ModelExtensionRetailcrmProduct extends Model
{
public function getProductSpecials($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' ORDER BY priority, price");
return $query->rows;
}
}

View File

@ -43,7 +43,10 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
),
$this->retailcrm->getModuleTitle() . '_payment' => array(
'cod' => 'cod'
)
),
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2',
$this->retailcrm->getModuleTitle() . '_special_3' => 'special3'
)
);
}
@ -88,6 +91,12 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
$this->assertArrayHasKey('items', $orderSend);
foreach($orderSend['items'] as $item) {
$this->assertArrayHasKey('priceType', $item);
$this->assertEquals('special1', $item['priceType']['code']);
}
$this->assertArrayHasKey('customerComment', $orderSend);
$this->assertArrayHasKey('customer', $orderSend);
$this->assertArrayHasKey('externalId', $orderSend['customer']);
@ -160,6 +169,12 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
$this->assertArrayHasKey('items', $orderSend);
foreach($orderSend['items'] as $item) {
$this->assertArrayHasKey('priceType', $item);
$this->assertEquals('special1', $item['priceType']['code']);
}
$this->assertArrayHasKey('customerComment', $orderSend);
}
@ -211,6 +226,10 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
$this->assertArrayHasKey('id', $orderSend['customer']);
$this->assertEquals(1, $orderSend['customer']['id']);
foreach($orderSend['items'] as $item) {
$this->assertArrayNotHasKey('priceType', $item);
}
}
protected function setSetting($code, $data, $store_id = 0) {

View File

@ -51,5 +51,6 @@ INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `va
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('40', '1', '1', '50.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
TRUNCATE TABLE `oc_order_voucher`;