12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Core\App\Service;
- class OrderService {
- protected $marketplaceOrderRepository;
- protected $marketplaceProductRepository;
- protected $facturisOrderRepository;
- protected $facturisCustomerRepository;
- protected $facturisProductRepository;
- protected $settingsRepository;
- public function __construct(
- \Core\App\Repository\Marketplace\OrderInterface $marketplaceOrderRepository,
- \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
- \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
- \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
- \Core\App\Repository\Facturis\OrderInterface $facturisOrderRepository,
- \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
- )
- {
- $this->marketplaceOrderRepository = $marketplaceOrderRepository;
- $this->marketplaceProductRepository = $marketplaceProductRepository;
- $this->facturisOrderRepository = $facturisOrderRepository;
- $this->facturisCustomerRepository = $facturisCustomerRepository;
- $this->facturisProductRepository = $facturisProductRepository;
- $this->settingsRepository = $settingsRepository;
- }
- public function sync() {
- $facturisCustomers = $this->facturisCustomerRepository->getAll();
- $facturisProducts = $this->facturisProductRepository->getAll();
- $this->marketplaceOrderRepository->setRemoteCustomers($facturisCustomers);
- $this->marketplaceOrderRepository->setRemoteProducts($facturisProducts);
- $this->marketplaceOrderRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo());
- $this->marketplaceOrderRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
- $withOutDiscount = true;
- $marketplaceProducts = $this->marketplaceProductRepository->getAll($withOutDiscount);
- $this->marketplaceOrderRepository->setLocalProducts((array) $marketplaceProducts);
- $marketplaceOrders = $this->marketplaceOrderRepository->getAll();
- if(!empty($marketplaceOrders))
- {
- foreach($marketplaceOrders as $marketplaceOrder)
- {
- $this->facturisOrderRepository->add($marketplaceOrder);
- }
- }
- }
- }
|