Merge pull request #132 from sergeygw1990/master

v3.2.2
This commit is contained in:
Alex Lushpai 2019-02-14 13:26:27 +03:00 committed by GitHub
commit 24c6de76ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## v.3.2.2
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.
## v.3.2.1
* Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента.

View File

@ -1 +1 @@
3.2.1
3.2.2

View File

@ -92,7 +92,6 @@ class ModelExtensionRetailcrmOrder extends Model {
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'],

View File

@ -38,7 +38,6 @@ 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'],

View File

@ -183,6 +183,8 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
$this->assertArrayHasKey('payments', $orderSend);
$this->assertArrayHasKey('customerComment', $orderSend);
$this->assertArrayHasKey('customer', $orderSend);
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
$this->assertArrayHasKey('id', $orderSend['customer']);
$this->assertNotEmpty($orderSend['payments']);
}
}

View File

@ -163,6 +163,56 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
$this->assertArrayHasKey('customerComment', $orderSend);
}
public function testOrderCreateWithoutCustomerTest()
{
$order_id = self::ORDER_ID;
$orderCheckoutModel = $this->loadModel('checkout/order');
$orderAccountModel = $this->loadModel('account/order');
$order = $orderCheckoutModel->getOrder($order_id);
$order['products'] = $orderAccountModel->getOrderProducts($order_id);
$order['totals'] = $orderAccountModel->getOrderTotals($order_id);
foreach($order['products'] as $key => $product) {
$order['products'][$key]['option'] = $orderAccountModel->getOrderOptions($product['order_id'], $product['order_product_id']);
}
$responseCustomerCreate = new \RetailcrmApiResponse(
201,
json_encode(
array(
'success' => true,
'id' => 1
)
)
);
$responseCustomerList = new \RetailcrmApiResponse(
201,
json_encode(
array(
'success' => true,
"pagination"=> [
"limit"=>20,
"totalCount"=> 0,
"currentPage"=> 1,
"totalPageCount"=> 0
],
"customers"=> []
)
)
);
$this->apiClientMock->expects($this->any())->method('customersList')->willReturn($responseCustomerList);
$this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn($responseCustomerCreate);
$orderProcess = $this->orderModel->processOrder($order);
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock, $order);
$this->assertArrayHasKey('customer', $orderSend);
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
$this->assertArrayHasKey('id', $orderSend['customer']);
$this->assertEquals(1, $orderSend['customer']['id']);
}
protected function setSetting($code, $data, $store_id = 0) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");