|
|
|
|
|
|
|
|
OrderShopInterface $orderShop2, |
|
|
OrderShopInterface $orderShop2, |
|
|
$persist = true |
|
|
$persist = true |
|
|
): OrderShopInterface { |
|
|
): OrderShopInterface { |
|
|
//TODO essayer de comprendre prk on doit faire un refresh ici ??? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO essayer de comprendre pourquoi on doit faire un refresh ici |
|
|
$this->entityManager->refresh($orderShop1); |
|
|
$this->entityManager->refresh($orderShop1); |
|
|
$this->entityManager->refresh($orderShop2); |
|
|
$this->entityManager->refresh($orderShop2); |
|
|
if ($orderShop1 && $orderShop2) { |
|
|
|
|
|
foreach ($orderShop2->getOrderProducts() as $orderProduct) { |
|
|
|
|
|
$orderProductAlreadyInCart = $this->orderShopSolver->hasOrderProductAlreadyInCart( |
|
|
|
|
|
$orderShop1, |
|
|
|
|
|
$orderProduct |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($orderProductAlreadyInCart) { |
|
|
|
|
|
if ($orderProduct->getQuantityOrder() > $orderProductAlreadyInCart->getQuantityOrder()) { |
|
|
|
|
|
$orderShop1->removeOrderProduct($orderProductAlreadyInCart); |
|
|
|
|
|
$this->addOrderProduct($orderShop1, $orderProduct); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
$this->addOrderProduct($orderShop1, $orderProduct); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($persist) { |
|
|
|
|
|
$this->entityManager->delete($orderProduct); |
|
|
|
|
|
|
|
|
foreach ($orderShop2->getOrderProducts() as $orderProduct) { |
|
|
|
|
|
$orderProductAlreadyInCart = $this->orderShopSolver->hasOrderProductAlreadyInCart( |
|
|
|
|
|
$orderShop1, |
|
|
|
|
|
$orderProduct |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($orderProductAlreadyInCart) { |
|
|
|
|
|
if ($orderProduct->getQuantityOrder() > $orderProductAlreadyInCart->getQuantityOrder()) { |
|
|
|
|
|
$orderShop1->removeOrderProduct($orderProductAlreadyInCart); |
|
|
|
|
|
$this->addOrderProduct($orderShop1, $orderProduct); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
$this->addOrderProduct($orderShop1, $orderProduct); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($persist) { |
|
|
if ($persist) { |
|
|
$this->entityManager->delete($orderShop2); |
|
|
|
|
|
$this->entityManager->update($orderShop1); |
|
|
|
|
|
$this->entityManager->flush(); |
|
|
|
|
|
|
|
|
$this->entityManager->delete($orderProduct); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $orderShop1; |
|
|
|
|
|
|
|
|
if ($persist) { |
|
|
|
|
|
$this->entityManager->delete($orderShop2); |
|
|
|
|
|
$this->entityManager->update($orderShop1); |
|
|
|
|
|
$this->entityManager->flush(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $orderShop1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function addPayment(OrderShopInterface $orderShop, string $meanPayment, float $amount): OrderShopInterface |
|
|
public function addPayment(OrderShopInterface $orderShop, string $meanPayment, float $amount): OrderShopInterface |