mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 22:26:06 +03:00
v3.2.1
This commit is contained in:
parent
ee36226b31
commit
ed5de5186e
@ -26,7 +26,7 @@ before_script:
|
||||
- composer install
|
||||
- composer setup
|
||||
- bin/robo project:deploy
|
||||
- (php -S localhost:8000 -t www &) 2> /dev/null > /dev/null
|
||||
- (php -S localhost:8000 -t www &) 2> /dev/null > /dev/null(php -S localhost:8000 -t www &) 2> /dev/null > /dev/null
|
||||
- sleep 2
|
||||
|
||||
script:
|
||||
|
@ -1,3 +1,6 @@
|
||||
## v.3.2.1
|
||||
* Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента.
|
||||
|
||||
## v.3.2.0
|
||||
* Добавлена выгрузка картинок для категорий в ICML
|
||||
* Добавлена настройка для выбора валюты, в которой будет выгружаться цена в ICML
|
||||
|
@ -777,6 +777,11 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
foreach ($customers as $customer) {
|
||||
$customer_id = $customer['externalId'];
|
||||
$customerData = $this->model_customer_customer->getCustomer($customer_id);
|
||||
|
||||
if (!$customerData) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$customerData['password'] = false;
|
||||
|
||||
$customerData['firstname'] = $customer['firstName'];
|
||||
|
@ -90,6 +90,37 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
unset($customers);
|
||||
}
|
||||
|
||||
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
|
||||
$new_customer = array(
|
||||
'externalId' => uniqid(),
|
||||
'firstName' => $order_data['firstname'],
|
||||
'lastName' => $order_data['lastname'],
|
||||
'email' => $order_data['email'],
|
||||
'createdAt' => $order_data['date_added'],
|
||||
'address' => array(
|
||||
'countryIso' => $order_data['payment_iso_code_2'],
|
||||
'index' => $order_data['payment_postcode'],
|
||||
'city' => $order_data['payment_city'],
|
||||
'region' => $order_data['payment_zone'],
|
||||
'text' => $order_data['payment_address_1'] . ' ' . $order_data['payment_address_2']
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($order_data['telephone'])) {
|
||||
$new_customer['phones'] = array(
|
||||
array(
|
||||
'number' => $order_data['telephone']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$res = $retailcrmApiClient->customersCreate($new_customer);
|
||||
|
||||
if ($res->isSuccessful() && isset($res['id'])) {
|
||||
$order['customer']['id'] = $res['id'];
|
||||
}
|
||||
}
|
||||
|
||||
self::$lastRepsonse = $retailcrmApiClient->ordersCreate($order);
|
||||
|
||||
return $order;
|
||||
@ -152,8 +183,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
$order['externalId'] = $order_data['order_id'];
|
||||
$order['firstName'] = $order_data['firstname'];
|
||||
$order['lastName'] = $order_data['lastname'];
|
||||
$order['firstName'] = $order_data['shipping_firstname'];
|
||||
$order['lastName'] = $order_data['shipping_lastname'];
|
||||
$order['phone'] = $order_data['telephone'];
|
||||
$order['customerComment'] = $order_data['comment'];
|
||||
|
||||
|
@ -48,23 +48,21 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($data['fromApi'])) {
|
||||
$this->load->model('setting/setting');
|
||||
$status = $this->model_setting_setting->getSetting($moduleTitle);
|
||||
$this->load->model('setting/setting');
|
||||
$status = $this->model_setting_setting->getSetting($moduleTitle);
|
||||
|
||||
if (isset($data['order_status_id']) && $data['order_status_id'] > 0) {
|
||||
$data['order_status'] = $status[$moduleTitle . '_status'][$data['order_status_id']];
|
||||
}
|
||||
if (isset($data['order_status_id']) && $data['order_status_id'] > 0) {
|
||||
$data['order_status'] = $status[$moduleTitle . '_status'][$data['order_status_id']];
|
||||
}
|
||||
|
||||
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
||||
$this->load->model('extension/retailcrm/custom/order');
|
||||
$order = $this->model_extension_retailcrm_custom_order->processOrder($data);
|
||||
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $this->retailcrmApiClient);
|
||||
} else {
|
||||
$this->load->model('extension/retailcrm/order');
|
||||
$order = $this->model_extension_retailcrm_order->processOrder($data);
|
||||
$this->model_extension_retailcrm_order->sendToCrm($order, $this->retailcrmApiClient);
|
||||
}
|
||||
if (file_exists(DIR_APPLICATION . 'model/extension/retailcrm/custom/order.php')) {
|
||||
$this->load->model('extension/retailcrm/custom/order');
|
||||
$order = $this->model_extension_retailcrm_custom_order->processOrder($data);
|
||||
$this->model_extension_retailcrm_custom_order->sendToCrm($order, $data, $this->retailcrmApiClient);
|
||||
} else {
|
||||
$this->load->model('extension/retailcrm/order');
|
||||
$order = $this->model_extension_retailcrm_order->processOrder($data);
|
||||
$this->model_extension_retailcrm_order->sendToCrm($order, $data, $this->retailcrmApiClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,13 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
*
|
||||
* @param array $order
|
||||
* @param \RetailcrmProxy $retailcrmApiClient
|
||||
* @param array $data
|
||||
* @param bool $create (default = true)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendToCrm($order, $retailcrmApiClient, $create = true) {
|
||||
if (isset($this->request->post['fromApi']) || $retailcrmApiClient === false) {
|
||||
public function sendToCrm($order, $retailcrmApiClient, $data, $create = true) {
|
||||
if ($retailcrmApiClient === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -35,6 +36,37 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
|
||||
$new_customer = array(
|
||||
'externalId' => uniqid(),
|
||||
'firstName' => $data['firstname'],
|
||||
'lastName' => $data['lastname'],
|
||||
'email' => $data['email'],
|
||||
'createdAt' => $data['date_added'],
|
||||
'address' => array(
|
||||
'countryIso' => $data['payment_iso_code_2'],
|
||||
'index' => $data['payment_postcode'],
|
||||
'city' => $data['payment_city'],
|
||||
'region' => $data['payment_zone'],
|
||||
'text' => $data['payment_address_1'] . ' ' . $data['payment_address_2']
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($data['telephone'])) {
|
||||
$new_customer['phones'] = array(
|
||||
array(
|
||||
'number' => $data['telephone']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$res = $retailcrmApiClient->customersCreate($new_customer);
|
||||
|
||||
if ($res->isSuccessful() && isset($res['id'])) {
|
||||
$order['customer']['id'] = $res['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($create) {
|
||||
$retailcrmApiClient->ordersCreate($order);
|
||||
} else {
|
||||
@ -98,8 +130,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($order_data['payment_iso_code_2'])) {
|
||||
$order['countryIso'] = $order_data['payment_iso_code_2'];
|
||||
if (!empty($order_data['shipping_iso_code_2'])) {
|
||||
$order['countryIso'] = $order_data['shipping_iso_code_2'];
|
||||
}
|
||||
|
||||
if (isset($this->settings[$this->moduleTitle . '_order_number'])
|
||||
@ -109,8 +141,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
$order['externalId'] = $order_id;
|
||||
$order['firstName'] = $order_data['firstname'];
|
||||
$order['lastName'] = $order_data['lastname'];
|
||||
$order['firstName'] = $order_data['shipping_firstname'];
|
||||
$order['lastName'] = $order_data['shipping_lastname'];
|
||||
$order['phone'] = $order_data['telephone'];
|
||||
$order['customerComment'] = $order_data['comment'];
|
||||
|
||||
|
@ -166,6 +166,7 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
|
||||
);
|
||||
|
||||
$this->apiClientMock->expects($this->any())->method('ordersCreate')->willReturn($response);
|
||||
$this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn($response);
|
||||
$orderSend = $this->orderModel->uploadOrder($order, $this->apiClientMock);
|
||||
|
||||
$this->assertArrayHasKey('status', $orderSend);
|
||||
@ -181,7 +182,7 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
|
||||
$this->assertContains('#', $orderSend['items'][0]['offer']['externalId']);
|
||||
$this->assertArrayHasKey('payments', $orderSend);
|
||||
$this->assertArrayHasKey('customerComment', $orderSend);
|
||||
$this->assertArrayNotHasKey('customer', $orderSend);
|
||||
$this->assertArrayHasKey('customer', $orderSend);
|
||||
$this->assertNotEmpty($orderSend['payments']);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
||||
'ordersEdit',
|
||||
'ordersGet',
|
||||
'ordersPaymentEdit',
|
||||
'customersList'
|
||||
'customersList',
|
||||
'customersCreate'
|
||||
))
|
||||
->getMock();
|
||||
|
||||
@ -65,7 +66,7 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
||||
}
|
||||
|
||||
$orderProcess = $this->orderModel->processOrder($order);
|
||||
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock);
|
||||
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock, $order);
|
||||
|
||||
$this->assertArrayHasKey('status', $orderSend);
|
||||
$this->assertEquals('new', $orderSend['status']);
|
||||
@ -135,8 +136,9 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
||||
|
||||
$this->apiClientMock->expects($this->any())->method('ordersEdit')->willReturn($orderEditResponse);
|
||||
$this->apiClientMock->expects($this->any())->method('ordersGet')->willReturn($ordersGetResponse);
|
||||
$this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn($orderEditResponse);
|
||||
$orderProcess = $this->orderModel->processOrder($order);
|
||||
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock, false);
|
||||
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock, $order, false);
|
||||
|
||||
$this->assertArrayHasKey('status', $orderSend);
|
||||
$this->assertEquals('new', $orderSend['status']);
|
||||
|
Loading…
Reference in New Issue
Block a user