Browse Source

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

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
ddd4fa8035
2 changed files with 34 additions and 26 deletions
  1. +24
    -22
      backend/controllers/DistributionController.php
  2. +10
    -4
      common/helpers/Tiller.php

+ 24
- 22
backend/controllers/DistributionController.php View File

$typePaymentTiller = 'CASH'; $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 View File

} }
} }


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


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

$ordersOpendistrib = Order::searchAll([ $ordersOpendistrib = Order::searchAll([
'distribution.date' => $date, 'distribution.date' => $date,
'order.tiller_synchronization' => 1 'order.tiller_synchronization' => 1
} }
} }


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;
}
} }
} }



Loading…
Cancel
Save