123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- /**
- * 2007-2021 PrestaShop
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@prestashop.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
- * versions in the future. If you wish to customize PrestaShop for your
- * needs please refer to http://www.prestashop.com for more information.
- *
- * @author PrestaShop SA <contact@prestashop.com>
- * @copyright 2007-2021 PrestaShop SA
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
- * International Registered Trademark & Property of PrestaShop SA
- */
- namespace Core\App\Service;
- class AvizeService
- {
- protected $marketplaceAvizeRepository;
- protected $marketplaceProductRepository;
- protected $facturisAvizeRepository;
- protected $facturisCustomerRepository;
- protected $facturisProductRepository;
- protected $settingsRepository;
- public function __construct(
- \Core\App\Repository\Marketplace\AvizeInterface $marketplaceAvizeRepository,
- \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
- \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
- \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
- \Core\App\Repository\Facturis\AvizeInterface $facturisAvizeRepository,
- \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
- ) {
- $this->marketplaceAvizeRepository = $marketplaceAvizeRepository;
- $this->marketplaceProductRepository = $marketplaceProductRepository;
- $this->facturisAvizeRepository = $facturisAvizeRepository;
- $this->facturisCustomerRepository = $facturisCustomerRepository;
- $this->facturisProductRepository = $facturisProductRepository;
- $this->settingsRepository = $settingsRepository;
- }
- public function sync()
- {
- $facturisCustomers = $this->facturisCustomerRepository->getAll();
- $facturisProducts = $this->facturisProductRepository->getAll();
- $this->marketplaceAvizeRepository->setRemoteCustomers($facturisCustomers);
- $this->marketplaceAvizeRepository->setRemoteProducts($facturisProducts);
- $this->marketplaceAvizeRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo());
- $this->marketplaceAvizeRepository->setAvizeSerie(
- $this->settingsRepository->getOptionAvizeSerie()
- );
- $withOutDiscount = true;
- $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount);
- $this->marketplaceAvizeRepository->setLocalProducts((array) $marketplaceProducts);
- $this->marketplaceAvizeRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
- $marketplaceAvizes = $this->marketplaceAvizeRepository->getAll();
- if (!empty($marketplaceAvizes)) {
- foreach ($marketplaceAvizes as $marketplaceAvize) {
- $result = $this->facturisAvizeRepository->add($marketplaceAvize);
- // $this->marketplaceAvizeRepository->addAvize($marketplaceAvize, $result);
- }
- }
- }
- public function add($orderId)
- {
- $result = array();
- $facturisCustomers = $this->facturisCustomerRepository->getAll();
- $facturisProducts = $this->facturisProductRepository->getAll();
- $this->marketplaceAvizeRepository->setRemoteCustomers($facturisCustomers);
- $this->marketplaceAvizeRepository->setRemoteProducts($facturisProducts);
- $avizeSerie2 = $this->settingsRepository->getOptionAvizeSerie2();
- if (!empty($avizeSerie2)) {
- $this->marketplaceAvizeRepository->setAvizeSerie($avizeSerie2);
- } else {
- $this->marketplaceAvizeRepository->setAvizeSerie($this->settingsRepository->getOptionAvizeSerie());
- }
-
- $withOutDiscount = true;
- $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount);
- $this->marketplaceAvizeRepository->setLocalProducts((array) $marketplaceProducts);
- $this->marketplaceAvizeRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
-
- $marketplaceAvize = $this->marketplaceAvizeRepository->getByOrderId($orderId);
- if (!empty($marketplaceAvize)) {
- $result = $this->facturisAvizeRepository->add($marketplaceAvize);
- $this->marketplaceAvizeRepository->addAvize($marketplaceAvize, $result);
- return $result;
- }
- return $result;
- }
- }
|