Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

592 rindas
24KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Builder\Order;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
  5. use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent;
  6. use Lc\CaracoleBundle\Factory\File\DocumentFactory;
  7. use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory;
  8. use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
  9. use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory;
  10. use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory;
  11. use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory;
  12. use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
  13. use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory;
  14. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  15. use Lc\CaracoleBundle\Model\File\DocumentInterface;
  16. use Lc\CaracoleBundle\Model\File\DocumentModel;
  17. use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
  18. use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
  19. use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
  20. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  21. use Lc\CaracoleBundle\Model\Order\OrderStatusInterface;
  22. use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
  23. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  24. use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
  25. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  26. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  27. use Lc\CaracoleBundle\Model\Section\OpeningModel;
  28. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  29. use Lc\CaracoleBundle\Model\Section\SectionModel;
  30. use Lc\CaracoleBundle\Model\User\VisitorInterface;
  31. use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
  32. use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
  33. use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
  34. use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
  35. use Lc\CaracoleBundle\Resolver\OpeningResolver;
  36. use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
  37. use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
  38. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  39. use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic;
  40. use Lc\SovBundle\Model\User\UserInterface;
  41. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  42. use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
  43. class OrderShopBuilder
  44. {
  45. protected EntityManagerInterface $entityManager;
  46. protected OrderStatusStore $orderStatusStore;
  47. protected OrderProductStore $orderProductStore;
  48. protected OrderShopStore $orderShopStore;
  49. protected OrderShopSolver $orderShopSolver;
  50. protected ProductFamilyStore $productFamilyStore;
  51. protected PriceSolver $priceSolver;
  52. protected OrderProductBuilder $orderProductBuilder;
  53. protected DocumentBuilder $documentBuilder;
  54. protected EventDispatcherInterface $eventDispatcher;
  55. protected FlashBagInterface $flashBag;
  56. protected OpeningResolver $openingResolver;
  57. public function __construct(
  58. EntityManagerInterface $entityManager,
  59. OrderShopStore $orderShopStore,
  60. OrderShopSolver $orderShopSolver,
  61. OrderStatusStore $orderStatusStore,
  62. OrderProductStore $orderProductStore,
  63. ProductFamilyStore $productFamilyStore,
  64. OrderProductBuilder $orderProductBuilder,
  65. DocumentBuilder $documentBuilder,
  66. PriceSolver $priceSolver,
  67. EventDispatcherInterface $eventDispatcher,
  68. FlashBagInterface $flashBag,
  69. OpeningResolver $openingResolver
  70. ) {
  71. $this->entityManager = $entityManager;
  72. $this->orderShopStore = $orderShopStore;
  73. $this->orderShopSolver = $orderShopSolver;
  74. $this->orderStatusStore = $orderStatusStore;
  75. $this->orderProductStore = $orderProductStore;
  76. $this->productFamilyStore = $productFamilyStore;
  77. $this->orderProductBuilder = $orderProductBuilder;
  78. $this->documentBuilder = $documentBuilder;
  79. $this->priceSolver = $priceSolver;
  80. $this->eventDispatcher = $eventDispatcher;
  81. $this->flashBag = $flashBag;
  82. $this->openingResolver = $openingResolver;
  83. }
  84. public function create(
  85. SectionInterface $section,
  86. UserInterface $user = null,
  87. VisitorInterface $visitor = null
  88. ): OrderShopInterface {
  89. $orderShopFactory = new OrderShopFactory();
  90. $orderShop = $orderShopFactory->create($section, $user, $visitor);
  91. $this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART);
  92. //TODO flush ???
  93. return $orderShop;
  94. }
  95. public function createIfNotExist(
  96. SectionInterface $section,
  97. UserInterface $user = null,
  98. VisitorInterface $visitor = null
  99. ): OrderShopInterface {
  100. $cart = $this->orderShopStore->getCartBy(
  101. [
  102. 'section' => $section,
  103. 'user' => $user,
  104. 'visitor' => $visitor
  105. ]
  106. );
  107. if (!$cart) {
  108. $cart = $this->create($section, $user, $visitor);
  109. }
  110. return $cart;
  111. }
  112. public function setOrderStatus(
  113. OrderShopInterface $orderShop,
  114. string $alias,
  115. bool $forceByAdmin = false
  116. ): OrderShopInterface {
  117. $orderStatus = $this->orderStatusStore->getRepositoryQuery()->findOneByAlias($alias);
  118. if ($orderStatus) {
  119. if ($orderShop->getOrderStatus() === null
  120. || $orderShop->getOrderStatus()->getNextStatusAllowed()->contains($orderStatus)) {
  121. $this->applyChangeOrderStatus($orderShop, $orderStatus, $forceByAdmin);
  122. }
  123. } else {
  124. throw new \ErrorException('La statut demandé n\'existe pas.');
  125. }
  126. return $orderShop;
  127. }
  128. public function applyChangeOrderStatus(
  129. OrderShopInterface $orderShop,
  130. OrderStatusInterface $orderStatus,
  131. bool $forceByAdmin = false
  132. ): void {
  133. $this->eventDispatcher->dispatch(
  134. new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
  135. OrderShopChangeStatusEvent::PRE_CHANGE_STATUS
  136. );
  137. $orderShop->setOrderStatusProtected($orderStatus);
  138. $orderStatusHistoryFactory = new OrderStatusHistoryFactory();
  139. $orderStatusHistory = $orderStatusHistoryFactory->create($orderShop, $orderStatus);
  140. $orderShop->addOrderStatusHistory($orderStatusHistory);
  141. $this->eventDispatcher->dispatch(
  142. new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
  143. OrderShopChangeStatusEvent::POST_CHANGE_STATUS
  144. );
  145. }
  146. public function addOrderProduct(
  147. OrderShopInterface $orderShop,
  148. OrderProductInterface $orderProductAdd,
  149. bool $persist = true
  150. ): bool {
  151. $return = false;
  152. if ($this->orderProductStore->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) {
  153. if ($orderProductAdd->getQuantityOrder() > 0) {
  154. $updated = false;
  155. $this->orderProductBuilder->init($orderProductAdd);
  156. $productFamily = $this->productFamilyStore->getOneBySlug(
  157. $orderProductAdd->getProduct()->getProductFamily()->getSlug()
  158. );
  159. if ($productFamily) {
  160. $reductionCatalog = $productFamily->getReductionCatalog();
  161. if ($reductionCatalog) {
  162. $orderProductReductionCatalogFactory = new OrderProductReductionCatalogFactory();
  163. $orderProductReductionCatalog = $orderProductReductionCatalogFactory->create(
  164. $reductionCatalog->getTitle(),
  165. $reductionCatalog->getValue(),
  166. $reductionCatalog->getUnit(),
  167. $reductionCatalog->getBehaviorTaxRate()
  168. );
  169. $orderProductAdd->setOrderProductReductionCatalog($orderProductReductionCatalog);
  170. }
  171. }
  172. foreach ($orderShop->getOrderProducts() as $orderProduct) {
  173. if ($orderProduct->getProduct()->getId() == $orderProductAdd->getProduct()->getId()
  174. && $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery()
  175. && (string)$this->priceResolver->getPrice($orderProduct)
  176. == (string)$this->priceResolver->getPrice($orderProductAdd)
  177. && $orderProduct->getOrderProductReductionCatalog()->compare(
  178. $orderProductAdd->getOrderProductReductionCatalog()
  179. )) {
  180. $orderProduct->setQuantityOrder(
  181. $orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
  182. );
  183. if ($persist) {
  184. $this->entityManager->persist($orderProduct);
  185. }
  186. $updated = true;
  187. $return = true;
  188. break;
  189. }
  190. }
  191. if (!$updated) {
  192. $orderShop->addOrderProduct($orderProductAdd);
  193. if ($persist) {
  194. if (isset($orderProductReductionCatalog)) {
  195. $this->entityManager->create($orderProductReductionCatalog);
  196. }
  197. //TODO est-ce un update ou un create ???
  198. $this->entityManager->update($orderProductAdd);
  199. $this->entityManager->update($orderShop);
  200. }
  201. $return = true;
  202. }
  203. if ($persist) {
  204. $this->entityManager->flush();
  205. }
  206. // @TODO : dispatch event cart change
  207. //$this->eventCartChange($orderShop);
  208. }
  209. } else {
  210. // @TODO : retourner le message d'erreur et faire le addFlash dans le contrôleur
  211. /*$availableQuantity = $orderProductAdd->getProduct()->getAvailableQuantityInherited();
  212. $textError = "Le produit <strong>" . $orderProductAdd->getTitleOrderShop(
  213. ) . "</strong> n'est pas disponible";
  214. if ($availableQuantity !== false && $availableQuantity > 0) {
  215. $unit = '';
  216. if ($orderProductAdd->getProduct()->getProductFamily()->getBehaviorCountStock(
  217. ) == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
  218. $unit = $orderProductAdd->getProduct()->getUnitInherited()->getUnitReference()->getUnit();
  219. }
  220. $textError .= ' dans cette quantité ';
  221. $user = $this->security->getUser();
  222. if ($user && $user->hasRole('ROLE_USER')) {
  223. $textError .= '<br />' . $availableQuantity . $unit . ' disponible(s) dont ' . $this->getQuantityOrderByProduct(
  224. $orderShop,
  225. $orderProductAdd->getProduct()
  226. ) . $unit . ' déjà dans votre panier.';
  227. }
  228. }
  229. $this->utils->addFlash('error', $textError);*/
  230. }
  231. return $return;
  232. }
  233. public function merge(
  234. OrderShopInterface $orderShop1,
  235. OrderShopInterface $orderShop2,
  236. $persist = true
  237. ): OrderShopInterface {
  238. if ($orderShop1 && $orderShop2) {
  239. foreach ($orderShop2->getOrderProducts() as $orderProduct) {
  240. $orderProductAlreadyInCart = $orderShop1->hasOrderProductAlreadyInCart($orderProduct);
  241. if ($orderProductAlreadyInCart) {
  242. if ($orderProduct->getQuantityOrder() > $orderProductAlreadyInCart->getQuantityOrder()) {
  243. $orderShop1->removeOrderProduct($orderProductAlreadyInCart);
  244. $this->addOrderProduct($orderShop1, $orderProduct);
  245. }
  246. } else {
  247. $this->addOrderProduct($orderShop1, $orderProduct);
  248. }
  249. if ($persist) {
  250. $this->entityManager->delete($orderProduct);
  251. }
  252. }
  253. if ($persist) {
  254. $this->entityManager->delete($orderShop2);
  255. $this->entityManager->update($orderShop1);
  256. $this->entityManager->flush();
  257. }
  258. return $orderShop1;
  259. }
  260. }
  261. public function addPayment(OrderShopInterface $orderShop, string $meanPayment, float $amount): OrderShopInterface
  262. {
  263. $orderPaymentFactory = new OrderPaymentFactory();
  264. $orderPayment = $orderPaymentFactory->create($orderShop, $meanPayment, $amount);
  265. $orderShop->addOrderPayment($orderPayment);
  266. if ($this->orderSh->isPaid($orderShop)) {
  267. $nextStatus = OrderStatusModel::ALIAS_PAID;
  268. } else {
  269. $nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT;
  270. }
  271. if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) {
  272. $orderShop = $this->changeOrderStatus($orderShop, $nextStatus);
  273. }
  274. $this->entityManager->create($orderPayment);
  275. $this->entityManager->update($orderShop);
  276. $this->entityManager->flush();
  277. return $orderShop;
  278. }
  279. public function initStatsInfo(OrderShopInterface $orderShop, $flush = true)
  280. {
  281. $orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
  282. $orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
  283. $orderShop->setStatTotalOrderProductsWithReductions(
  284. $this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
  285. );
  286. $orderShop->setStatTotalOrderProductsWithTaxAndReductions(
  287. $this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
  288. );
  289. $orderShop->setStatMarginOrderProductsWithReductions(
  290. $this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
  291. );
  292. $orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
  293. $orderShop->setStatDeliveryPriceWithTaxAndReduction(
  294. $this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
  295. );
  296. $this->entityManager->persist($orderShop);
  297. if ($flush) {
  298. $this->entityManager->flush();
  299. }
  300. }
  301. public function initCycleNumber(OrderShopInterface $orderShop): void
  302. {
  303. $cycleNumber = null;
  304. $deliveryDate = $orderShop->getDeliveryDate();
  305. switch ($orderShop->getSection()->getCycle()) {
  306. case SectionModel::CYCLE_DAY:
  307. $cycleNumber = $deliveryDate->format('z');
  308. break;
  309. case SectionModel::CYCLE_WEEK:
  310. $cycleNumber = $deliveryDate->format('W');
  311. break;
  312. }
  313. $orderShop->setCycleNumber($cycleNumber);
  314. }
  315. public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface
  316. {
  317. $documentFactory = new DocumentFactory();
  318. $document = $documentFactory->create(DocumentModel::TYPE_INVOICE);
  319. $this->documentBuilder->initFromOrderShop($document, $orderShop);
  320. return $document;
  321. }
  322. public function addReductionCart(
  323. OrderShopInterface $orderShop,
  324. ReductionCartInterface $reductionCart
  325. ): ?OrderReductionCartInterface {
  326. $orderReductionCartFactory = new OrderReductionCartFactory();
  327. $orderReductionCart = $orderReductionCartFactory->create($orderShop, $reductionCart);
  328. $orderShop->addOrderReductionCart($orderReductionCart);
  329. if ($this->orderShopStore->isPositiveAmount($orderShop)
  330. && $this->isPositiveAmountRemainingToBePaid($orderShop)) {
  331. $this->entityManager->create($orderReductionCart);
  332. $this->entityManager->flush();
  333. return $orderReductionCart;
  334. } else {
  335. //TODO vérifier ce case ! Avec le null en valeur de retour
  336. $orderShop->removeOrderReductionCart($orderReductionCart);
  337. return null;
  338. }
  339. }
  340. // createOrderReductionCredit
  341. public function addReductionCredit(
  342. OrderShopInterface $orderShop,
  343. ReductionCreditInterface $reductionCredit
  344. ): ?OrderReductionCreditInterface {
  345. $orderReductionCreditFactory = new OrderReductionCreditFactory();
  346. $orderReductionCredit = $orderReductionCreditFactory->create($orderShop, $reductionCredit);
  347. $orderShop->addOrderReductionCredit($orderReductionCredit);
  348. if ($this->isOrderShopPositiveAmount($orderShop)
  349. && $this->isOrderShopPositiveAmountRemainingToBePaid($orderShop)) {
  350. $this->entityManager->create($orderReductionCredit);
  351. $this->entityManager->flush();
  352. return $orderReductionCredit;
  353. } else {
  354. $orderShop->removeOrderReductionCredit($orderReductionCredit);
  355. return null;
  356. }
  357. }
  358. public function deductAvailabilityProduct(OrderShopInterface $orderShop): void
  359. {
  360. foreach ($orderShop->getOrderProducts() as $orderProduct) {
  361. $this->applyDeductAvailabilityProduct($orderShop, $orderProduct);
  362. }
  363. }
  364. public function applyDeductAvailabilityProduct(
  365. OrderShopInterface $orderShop,
  366. OrderProductInterface $orderProduct
  367. ): void {
  368. switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) {
  369. case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE :
  370. //Disponibilité par unité de référence
  371. $oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
  372. $newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder(
  373. ) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()));
  374. $productFamily = $orderProduct->getProduct()->getProductFamily();
  375. $productFamily->setAvailableQuantity($newAvailability);
  376. $productFamily->setUpdatedBy($orderShop->getUser());
  377. $this->entityManager->update($productFamily);
  378. break;
  379. case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :
  380. $oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
  381. $newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();
  382. $productFamily = $orderProduct->getProduct()->getProductFamily();
  383. $productFamily->setAvailableQuantity($newAvailability);
  384. $productFamily->setUpdatedBy($orderShop->getUser());
  385. $this->entityManager->update($productFamily);
  386. break;
  387. case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
  388. $oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
  389. $newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();
  390. $product = $orderProduct->getProduct();
  391. $product->setAvailableQuantity($newAvailability);
  392. $product->setUpdatedBy($orderShop->getUser());
  393. $this->entityManager->update($product);
  394. break;
  395. }
  396. $this->entityManager->flush();
  397. }
  398. public function updatePriceByProductFamily(ProductFamilyInterface $productFamily)
  399. {
  400. // @TODO : faire la vérification isOpenSale depuis la méthode appelante
  401. if (!$this->openingResolver->isOpenSale($productFamily->getSection(), null, OpeningResolver::OPENING_CONTEXT_BACKEND)) {
  402. $countOrderProductUpdated = 0;
  403. foreach ($productFamily->getProducts() as $product) {
  404. $orderProducts = $this->orderProductStore->getInCartsByProduct($product);
  405. foreach ($orderProducts as $orderProduct) {
  406. $quantityOrder = $orderProduct->getQuantityOrder();
  407. $orderShop = $orderProduct->getOrderShop();
  408. $orderShop->removeOrderProduct($orderProduct);
  409. $this->entityManager->delete($orderProduct);
  410. $this->entityManager->flush();
  411. $this->entityManager->refresh($orderShop);
  412. $orderProductFactory = new OrderProductFactory();
  413. $addOrderProduct = $orderProductFactory->create($product, $quantityOrder);
  414. $this->addOrderProduct($orderShop, $addOrderProduct);
  415. $countOrderProductUpdated++;
  416. }
  417. }
  418. if ($countOrderProductUpdated) {
  419. // @TODO : faire le add flash dans le controller
  420. /*$this->utils->addFlash(
  421. 'success',
  422. 'success.OrderShop.orderProductUpdated',
  423. array(),
  424. array('%count%' => $countOrderProductUpdated)
  425. );*/
  426. $this->entityManager->flush();
  427. }
  428. return $countOrderProductUpdated;
  429. }
  430. }
  431. public function setStatsInfo(OrderShopInterface $orderShop, $flush = true)
  432. {
  433. $orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
  434. $orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
  435. $orderShop->setStatTotalOrderProductsWithReductions(
  436. $this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
  437. );
  438. $orderShop->setStatTotalOrderProductsWithTaxAndReductions(
  439. $this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
  440. );
  441. $orderShop->setStatMarginOrderProductsWithReductions(
  442. $this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
  443. );
  444. $orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
  445. $orderShop->setStatDeliveryPriceWithTaxAndReduction(
  446. $this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
  447. );
  448. $this->entityManager->update($orderShop);
  449. if ($flush) {
  450. $this->entityManager->flush();
  451. }
  452. }
  453. public function setHasReach(int $reachStep, OrderShopInterface $orderShop)
  454. {
  455. if ($orderShop->getHasReach() === null || $orderShop->getHasReach() < $reachStep) {
  456. $orderShop->setHasReach($reachStep);
  457. $this->entityManager->persist($orderShop);
  458. $this->entityManager->flush($orderShop);
  459. }
  460. }
  461. public function initComplementaryOrderShop(OrderShopInterface $orderShop, OrderShopInterface $mainOrderShop): void
  462. {
  463. $orderShop->setMainOrderShop($mainOrderShop);
  464. $orderShop->setDeliveryPrice(0);
  465. if ($mainOrderShop->getDeliveryAddress()) {
  466. $this->initDeliveryAddress($orderShop, $mainOrderShop->getDeliveryAddress());
  467. }
  468. $orderShop->setInvoiceAddress($mainOrderShop->getInvoiceAddress());
  469. }
  470. // setDeliveryAddress
  471. public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address):void
  472. {
  473. $orderShop->setDeliveryAddress($address);
  474. $orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null);
  475. }
  476. // resetOrderShopInfos
  477. public function reset(OrderShopInterface $orderShop)
  478. {
  479. $this->initDeliveryAddress($orderShop, null);
  480. $orderShop->setMainOrderShop(null);
  481. $orderShop->setDeliveryPrice(null);
  482. $orderShop->setInvoiceAddress(null);
  483. $orderShop->setDeclineComplementaryOrderShop(false);
  484. }
  485. public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
  486. {
  487. $productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek);
  488. $productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver);
  489. $productsSalesStatistic->populateProperties($this->orderShopStore);
  490. return $productsSalesStatistic->getAsArray();
  491. }
  492. }