Bug fixes in customer search (#27)

* multi module for api v4, v5

* bug fix empty payment in history

* add module key for marketplace

* fix for validation on marketplace, edit validation form for saving settings

* Bug fix

* Bug fixes in customer search
This commit is contained in:
Akolzin Dmitry 2018-01-12 12:51:46 +03:00 committed by Alex Lushpai
parent 87a6c6ee34
commit 3d3d55a9d1
6 changed files with 48 additions and 10 deletions

View File

@ -3,7 +3,7 @@
* @author Retail Driver LCC * @author Retail Driver LCC
* @copyright RetailCRM * @copyright RetailCRM
* @license GPL * @license GPL
* @version 2.1.1 * @version 2.1.3
* @link https://retailcrm.ru * @link https://retailcrm.ru
* *
*/ */

View File

@ -3,7 +3,7 @@
* @author Retail Driver LCC * @author Retail Driver LCC
* @copyright RetailCRM * @copyright RetailCRM
* @license GPL * @license GPL
* @version 2.1.1 * @version 2.1.3
* @link https://retailcrm.ru * @link https://retailcrm.ru
* *
*/ */

View File

@ -3,7 +3,7 @@
* @author Retail Driver LCC * @author Retail Driver LCC
* @copyright RetailCRM * @copyright RetailCRM
* @license GPL * @license GPL
* @version 2.1.1 * @version 2.1.3
* @link https://retailcrm.ru * @link https://retailcrm.ru
* *
*/ */

View File

@ -3,7 +3,7 @@
* @author Retail Driver LCC * @author Retail Driver LCC
* @copyright RetailCRM * @copyright RetailCRM
* @license GPL * @license GPL
* @version 2.1.1 * @version 2.1.3
* @link https://retailcrm.ru * @link https://retailcrm.ru
* *
*/ */
@ -103,6 +103,7 @@ if ($history->isSuccessful() && count($history->history) > 0) {
if (!isset($paymentId) || !$paymentId) { if (!isset($paymentId) || !$paymentId) {
$paymentId = $paymentDefault; $paymentId = $paymentDefault;
} }
if (!$paymentType) { if (!$paymentType) {
if ($paymentDefault) { if ($paymentDefault) {
if (Module::getInstanceByName($paymentDefault)) { if (Module::getInstanceByName($paymentDefault)) {
@ -116,6 +117,7 @@ if ($history->isSuccessful() && count($history->history) > 0) {
3, 3,
_PS_ROOT_DIR_ . '/retailcrm.log' _PS_ROOT_DIR_ . '/retailcrm.log'
); );
continue; continue;
} }
} }
@ -135,7 +137,7 @@ if ($history->isSuccessful() && count($history->history) > 0) {
$customer = new Customer(); $customer = new Customer();
if (!empty($order['customer']['email'])) { if (!empty($order['customer']['email'])) {
$customer->getByEmail($order['customer']['email']); $customer->getByEmail($order['customer']['email'], null, false);
} }
if (!array_key_exists('externalId', $order['customer'])) { if (!array_key_exists('externalId', $order['customer'])) {
@ -408,6 +410,7 @@ if ($history->isSuccessful() && count($history->history) > 0) {
/* /*
* check payment type * check payment type
*/ */
if (!empty($order['paymentType']) && $apiVersion != 5) { if (!empty($order['paymentType']) && $apiVersion != 5) {
$ptype = $order['paymentType']; $ptype = $order['paymentType'];
@ -445,6 +448,36 @@ if ($history->isSuccessful() && count($history->history) > 0) {
WHERE WHERE
`id_order` = ' . (int)$order['externalId']); `id_order` = ' . (int)$order['externalId']);
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_payment`
(`payment_method`, `order_reference` , `amount`, `date_add`)
VALUES
(\'' . $payType . '\',
\'' . $orderToUpdate->reference . '\',
\'' . $payment['amount'] . '\',
\'' . $payment['paidAt'] . '\')');
}
}
}
}
} elseif (!empty($order['payments']) && $apiVersion == 5) {
if ($order['payments']) {
foreach ($order['payments'] as $payment) {
if (!isset($payment['externalId']) && $payment['status'] == 'paid') {
$ptype = $payment['type'];
$ptypes = $references->getSystemPaymentModules();
if ($payments[$ptype] != null) {
foreach ($ptypes as $pay) {
if ($pay['code'] == $payments[$ptype]) {
$payType = $pay['name'];
}
}
$paymentType = Module::getModuleName($payments[$ptype]);
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'orders`
SET
`payment` = \'' . ($paymentType != null ? $paymentType : $payments[$ptype]). '\'
WHERE
`id_order` = ' . (int)$order['externalId']);
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_payment` Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'order_payment`
(`payment_method`, `order_reference` , `amount`, `date_add`) (`payment_method`, `order_reference` , `amount`, `date_add`)
VALUES VALUES
@ -503,6 +536,7 @@ if ($history->isSuccessful() && count($history->history) > 0) {
if (isset($item['discount']) || if (isset($item['discount']) ||
isset($item['discountPercent']) || isset($item['discountPercent']) ||
isset($item['discountTotal'])) { isset($item['discountTotal'])) {
$product = new Product((int) $product_id, false, $default_lang); $product = new Product((int) $product_id, false, $default_lang);
$tax = new TaxCore($product->id_tax_rules_group); $tax = new TaxCore($product->id_tax_rules_group);

View File

@ -25,7 +25,7 @@ class RetailCRM extends Module
{ {
$this->name = 'retailcrm'; $this->name = 'retailcrm';
$this->tab = 'export'; $this->tab = 'export';
$this->version = '2.1.2'; $this->version = '2.1.3';
$this->author = 'Retail Driver LCC'; $this->author = 'Retail Driver LCC';
$this->displayName = $this->l('RetailCRM'); $this->displayName = $this->l('RetailCRM');
$this->description = $this->l('Integration module for RetailCRM'); $this->description = $this->l('Integration module for RetailCRM');
@ -156,7 +156,9 @@ class RetailCRM extends Module
'name' => 'v5' 'name' => 'v5'
) )
); );
$fields_form = array(); $fields_form = array();
/* /*
* Network connection form * Network connection form
*/ */
@ -503,6 +505,7 @@ class RetailCRM extends Module
$arProp = array(); $arProp = array();
$count = 0; $count = 0;
$arAttr = explode(",", $item['attributes']); $arAttr = explode(",", $item['attributes']);
foreach ($arAttr as $valAttr) { foreach ($arAttr as $valAttr) {
$arItem = explode(":", $valAttr); $arItem = explode(":", $valAttr);
$arProp[$count]['name'] = trim($arItem[0]); $arProp[$count]['name'] = trim($arItem[0]);
@ -645,6 +648,7 @@ class RetailCRM extends Module
private function validateCrmAddress($address) private function validateCrmAddress($address)
{ {
if (preg_match("/https:\/\/(.*).retailcrm.ru/", $address) === 1) { if (preg_match("/https:\/\/(.*).retailcrm.ru/", $address) === 1) {
return true; return true;
} }