Ver código fonte

[Administration] Distributions > Synchronisation Tiller : correctif synchronisation en double des commandes #1321

feature/souke
Guillaume Bourgeois 1 ano atrás
pai
commit
ddd4fa8035
2 arquivos alterados com 34 adições e 26 exclusões
  1. +24
    -22
      backend/controllers/DistributionController.php
  2. +10
    -4
      common/helpers/Tiller.php

+ 24
- 22
backend/controllers/DistributionController.php Ver arquivo

@@ -888,31 +888,33 @@ class DistributionController extends BackendController
$typePaymentTiller = 'CASH';
}

$returnTiller = $tiller->postOrder([
'externalId' => $order->id,
'type' => 1,
'status' => 'IN_PROGRESS',
'openDate' => $strDate,
'closeDate' => $strDate,
'lines' => $lines,
'payments' => [
[
'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax(
$order,
Order::AMOUNT_PAID
) * 100,
'status' => 'ACCEPTED',
'date' => $strDate
if(!$tiller->isSynchro($date, $order->id)) {
$returnTiller = $tiller->postOrder([
'externalId' => $order->id,
'type' => 1,
'status' => 'IN_PROGRESS',
'openDate' => $strDate,
'closeDate' => $strDate,
'lines' => $lines,
'payments' => [
[
'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax(
$order,
Order::AMOUNT_PAID
) * 100,
'status' => 'ACCEPTED',
'date' => $strDate
]
]
]
]);
]);

$returnTillerObject = json_decode($returnTiller);
$order->tiller_external_id = '' . $returnTillerObject->id;
$order->save();
$returnTillerObject = json_decode($returnTiller);
$order->tiller_external_id = '' . $returnTillerObject->id;
$order->save();

$return[] = $returnTiller;
$return[] = $returnTiller;
}
}
}
}

+ 10
- 4
common/helpers/Tiller.php Ver arquivo

@@ -80,12 +80,13 @@ class Tiller
}
}

public function isSynchro($date)
public function isSynchro($date, $idOrder = null)
{
$orderManager = OrderManager::getInstance();

if ($this->producer_tiller) {
$ordersTiller = $this->getOrders($date);

$ordersOpendistrib = Order::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1
@@ -115,9 +116,14 @@ class Tiller
}
}

foreach ($ordersOpendistribSynchro as $idOrder => $isSynchro) {
if (!$isSynchro) {
return false;
if($idOrder && isset($ordersOpendistribSynchro[$idOrder])) {
return $ordersOpendistribSynchro[$idOrder];
}
else {
foreach ($ordersOpendistribSynchro as $idOrder => $isSynchro) {
if (!$isSynchro) {
return false;
}
}
}


Carregando…
Cancelar
Salvar