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 ## v.3.2.1
* Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента. * Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента.

View File

@ -1 +1 @@
3.2.1 3.2.2

View File

@ -48,7 +48,7 @@ class ModelExtensionRetailcrmOrder extends Model {
/** /**
* Send one order by id * Send one order by id
* *
* @param array $order_data * @param array $order_data
* @param \RetailcrmProxy $retailcrmApiClient * @param \RetailcrmProxy $retailcrmApiClient
* *
@ -92,7 +92,6 @@ class ModelExtensionRetailcrmOrder extends Model {
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) { if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
$new_customer = array( $new_customer = array(
'externalId' => uniqid(),
'firstName' => $order_data['firstname'], 'firstName' => $order_data['firstname'],
'lastName' => $order_data['lastname'], 'lastName' => $order_data['lastname'],
'email' => $order_data['email'], 'email' => $order_data['email'],
@ -128,9 +127,9 @@ class ModelExtensionRetailcrmOrder extends Model {
/** /**
* Process order * Process order
* *
* @param array $order_data * @param array $order_data
* *
* @return array $order * @return array $order
*/ */
private function process($order_data) { private function process($order_data) {

View File

@ -38,7 +38,6 @@ class ModelExtensionRetailcrmOrder extends Model {
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) { if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
$new_customer = array( $new_customer = array(
'externalId' => uniqid(),
'firstName' => $data['firstname'], 'firstName' => $data['firstname'],
'lastName' => $data['lastname'], 'lastName' => $data['lastname'],
'email' => $data['email'], 'email' => $data['email'],
@ -227,7 +226,7 @@ class ModelExtensionRetailcrmOrder extends Model {
'value' => $option['value'] 'value' => $option['value']
); );
} }
if (!in_array($option['type'], $offerOptions)) continue; if (!in_array($option['type'], $offerOptions)) continue;
foreach($productOptions as $productOption) { foreach($productOptions as $productOption) {
if($productOption['product_option_id'] = $option['product_option_id']) { if($productOption['product_option_id'] = $option['product_option_id']) {

View File

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

View File

@ -163,6 +163,56 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
$this->assertArrayHasKey('customerComment', $orderSend); $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) { 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) . "'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");