Merge pull request #108 from iyzoer/master

v3.1.1
This commit is contained in:
Alex Lushpai 2018-08-03 12:12:59 +03:00 committed by GitHub
commit 4174195128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 17 deletions

View File

@ -1,3 +1,6 @@
## v.3.1.1
* Добавлено создание клиента при ручной выгрузке заказа из админки
## v.3.1.0 ## v.3.1.0
* Переработан дизайн шаблона twig * Переработан дизайн шаблона twig
* Добавлена настройка передачи номера заказа в retailCRM * Добавлена настройка передачи номера заказа в retailCRM

View File

@ -1 +1 @@
3.1.0 3.1.1

View File

@ -65,6 +65,27 @@ class ModelExtensionRetailcrmCustomer extends Model {
return $customerToCrm; return $customerToCrm;
} }
/**
* Create customer
*
* @param array $customer
* @param \RetailcrmProxy $retailcrmApiClient
*
* @return mixed
*/
public function sendToCrm($customer, $retailcrmApiClient)
{
if ($retailcrmApiClient === false || empty($customer)) {
return false;
}
$customerToCrm = $this->process($customer);
$retailcrmApiClient->customersCreate($customerToCrm);
return $customerToCrm;
}
/** /**
* Process customer * Process customer
* *

View File

@ -64,24 +64,31 @@ class ModelExtensionRetailcrmOrder extends Model {
return false; return false;
} }
$customers = $retailcrmApiClient->customersList(
array(
'name' => $order_data['telephone'],
'email' => $order_data['email']
),
1,
100
);
$order = $this->process($order_data); $order = $this->process($order_data);
if ($customers) { if (isset($order['customer']['externalId'])) {
foreach ($customers['customers'] as $customer) { $this->load->model('extension/retailcrm/customer');
$order['customer']['id'] = $customer['id']; $this->load->model('customer/customer');
} $customer = $this->model_customer_customer->getCustomer($order['customer']['externalId']);
} $this->model_extension_retailcrm_customer->sendToCrm($customer, $retailcrmApiClient);
} else {
$customers = $retailcrmApiClient->customersList(
array(
'name' => $order_data['telephone'],
'email' => $order_data['email']
),
1,
100
);
unset($customers); if ($customers) {
foreach ($customers['customers'] as $customer) {
$order['customer']['id'] = $customer['id'];
}
}
unset($customers);
}
self::$lastRepsonse = $retailcrmApiClient->ordersCreate($order); self::$lastRepsonse = $retailcrmApiClient->ordersCreate($order);

View File

@ -23,7 +23,8 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
'ordersUpload', 'ordersUpload',
'customersList', 'customersList',
'ordersCreate', 'ordersCreate',
'ordersPaymentCreate' 'ordersPaymentCreate',
'customersCreate'
)) ))
->getMock(); ->getMock();