Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function update(EntityInterface $entity, EntityInterface $existent = null)
 {
     parent::update($entity, $existent);
     $factory204 = function ($message) {
         return new Response(['raw' => '{"message":"' . $message . '"}', 'httpStatusCode' => 204]);
     };
     if (empty($existent)) {
         $existent = $this->resolvePrevious($entity);
     }
     if ($entity->getOrderStatus() === $existent->getOrderStatus()) {
         $this->log('info', 'Order sem atualização');
         return $factory204('Order status not changed!');
     }
     if ('processing' === $entity->getOrderStatus()) {
         return $factory204('Order status not used!');
     }
     $entity = $this->normalizeShipping($entity, $existent);
     if (in_array($entity->getOrderStatus(), ['approved', 'canceled', 'delivered', 'invoiced', 'shipped'], true)) {
         $decorator = $this->factoryDecorator($entity, 'Status\\' . ucfirst($entity->getOrderStatus()));
         $json = $decorator->toJson();
         $mapKey = 'to' . ucfirst($entity->getOrderStatus());
         $shipping = $entity->getShipping();
         $code = $shipping->getShippingCode();
         $shipping->toJson();
         $map = $this->factoryMap($mapKey, ['orderNumber' => $entity->getOrderNumber(), 'itemId' => $entity->getOrderNumber(), 'shippingCode' => $code]);
         return $this->execute($map, $json);
     }
     throw new \InvalidArgumentException('Order Status [' . $entity->getOrderStatus() . '] não suportado', 1);
 }
Esempio n. 2
0
 public function findById($itemId)
 {
     $product = parent::findById($itemId);
     if (empty($product)) {
         return false;
     }
     $sm = $this->skuManager();
     $product->getSkus()->forAll(function ($key, $element) use($sm) {
         $sm->hydrate($element);
     });
     return $product;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function update(EntityInterface $entity, EntityInterface $existent = null)
 {
     parent::update($entity, $existent);
     if (empty($existent)) {
         $existent = $this->resolvePrevious($entity);
     }
     $response = ['sku' => $entity->getId(), 'bypassed' => [], 'code' => [], 'updated' => []];
     $list = ['updateDetails'];
     if (true === $this->strategy['info']) {
         $list[] = 'updateInfo';
     }
     foreach ($list as $method) {
         $response = $this->{$method}($entity, $existent, $response);
     }
     $this->log('info', 'Operação de Atualização', $response);
     return $response;
 }