1
0
mirror of synced 2024-11-25 06:46:08 +03:00

Merge pull request #90 from Evgeniy-Goroh/dublicate-item

обработка дублирующих товаров по externalId
This commit is contained in:
Alex Lushpai 2019-12-20 13:57:45 +03:00 committed by GitHub
commit 0956021d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View File

@ -654,11 +654,11 @@ class RetailCrmHistory
$orderTemp = $response['order'];
$ditems = [];
foreach ($orderTemp['items'] as $item) {
$ditems[$item['offer']['xmlId']]['quantity'] += $item['quantity'];
$ditems[$item['offer']['xmlId']]['discountTotal'] += $item['quantity'] * $item['discountTotal'];
$ditems[$item['offer']['xmlId']]['initialPrice'] = (float)$item['initialPrice'];
$ditems[$item['offer']['xmlId']]['price_sum'] = $ditems[$item['offer']['xmlId']]['initialPrice'] * $ditems[$item['offer']['xmlId']]['quantity'] - $ditems[$item['offer']['xmlId']]['discountTotal'];
$ditems[$item['offer']['xmlId']]['price_item'] = $ditems[$item['offer']['xmlId']]['price_sum'] / $ditems[$item['offer']['xmlId']]['quantity'];
$ditems[$item['offer']['externalId']]['quantity'] += $item['quantity'];
$ditems[$item['offer']['externalId']]['discountTotal'] += $item['quantity'] * $item['discountTotal'];
$ditems[$item['offer']['externalId']]['initialPrice'] = (float)$item['initialPrice'];
$ditems[$item['offer']['externalId']]['price_sum'] = $ditems[$item['offer']['externalId']]['initialPrice'] * $ditems[$item['offer']['externalId']]['quantity'] - $ditems[$item['offer']['externalId']]['discountTotal'];
$ditems[$item['offer']['externalId']]['price_item'] = $ditems[$item['offer']['externalId']]['price_sum'] / $ditems[$item['offer']['externalId']]['quantity'];
}
unset($orderTemp);
}
@ -666,8 +666,8 @@ class RetailCrmHistory
$log->write($ditems, 'duplicateItemsOrderHistory');
foreach ($order['items'] as $product) {
if($ditems[$product['offer']['xmlId']]['quantity']){
$product['quantity'] = $ditems[$product['offer']['xmlId']]['quantity'];
if($ditems[$product['offer']['externalId']]['quantity']){
$product['quantity'] = $ditems[$product['offer']['externalId']]['quantity'];
}
$item = self::getExistsItem($basket, 'catalog', $product['offer']['externalId']);
@ -703,7 +703,7 @@ class RetailCrmHistory
}
if ($product['delete']) {
if ($ditems[$product['offer']['xmlId']]['quantity'] <= 0) {
if ($ditems[$product['offer']['externalId']]['quantity'] <= 0) {
$item->delete();
continue;
@ -737,8 +737,8 @@ class RetailCrmHistory
$item->setField('PRICE', $itemCost - $resultDiscount);
//set price dublicate item
if ($ditems[$product['offer']['xmlId']]['price_item']) {
$item->setField('PRICE', $ditems[$product['offer']['xmlId']]['price_item']);
if ($ditems[$product['offer']['externalId']]['price_item']) {
$item->setField('PRICE', $ditems[$product['offer']['externalId']]['price_item']);
$item->setField('DISCOUNT_PRICE', '');
}
}

View File

@ -1,3 +1 @@
- Исправление при обработке полученных изменений о контрагенте
- При обработки истории по клиентам добавлены кастомные поля
- Исправлены мелкие ошибки и недочеты
- При обработке истории сбор по дублирующим товарам заменен на "externalId"