@Override
  public void executeAction(final B2BApprovalProcessModel process) throws RetryLaterException {
    OrderModel order = null;
    try {
      order = process.getOrder();
      Assert.notNull(
          order,
          String.format("Order of BusinessProcess %s should have be set for accelerator", process));
      final B2BCustomerModel user = (B2BCustomerModel) order.getUser();
      if (LOG.isDebugEnabled()) {
        LOG.debug(
            String.format(
                "Process for accelerator: %s in step %s order: %s user: %s ",
                process.getCode(), getClass(), order.getUnit(), user.getUid()));
      }
    } catch (final Exception exception) {
      LOG.error(exception.getMessage(), exception);
      this.handleError(order, exception);

      throw new RuntimeException(exception.getMessage(), exception);
    }
  }
 protected void checkForGuestCustomer(final OrderModel source, final OrderData target) {
   if (CustomerType.GUEST.equals(((CustomerModel) source.getUser()).getType())) {
     target.setGuestCustomer(true);
   }
 }
示例#3
0
  public ru.technonikol.ws.orders.Order convert(final OrderModel source)
      throws ConversionException {
    final ru.technonikol.ws.orders.Order target = new ru.technonikol.ws.orders.Order();
    final SimpleDateFormat serviceDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");

    try {
      if (source.getDeliveryAddress() != null) {
        final String fullAddress =
            source.getDeliveryAddress().getPostalcode()
                + ","
                + source.getDeliveryAddress().getTown()
                + ","
                + source.getDeliveryAddress().getLine2()
                + ","
                + source.getDeliveryAddress().getLine2();
        target.setAddress(fullAddress);
        target.setHouse(source.getDeliveryAddress().getLine2());
        target.setCountry(source.getDeliveryAddress().getCountry().getIsocode());
        target.setStreet(source.getDeliveryAddress().getStreetname());
        target.setTown(source.getDeliveryAddress().getTown());
        target.setAddressCode(source.getDeliveryAddress().getPostalcode());
        target.setRegion(source.getDeliveryAddress().getTown());
      } else {
        target.setAddress("");
        target.setHouse("");
        target.setCountry("");
        target.setStreet("");
        target.setTown("");
        target.setAddressCode("");
        target.setRegion("");
      }
      target.setCountryCode("695");
      target.setApartment("");
      target.setBuilding("");
      target.setCity("");
      target.setCityCode("");
      target.setRegionCode("77");

      target.setObjectType("664b64d0-403f-11e2-8e4e-005056010274"); // TODO no data now
      target.setConstructionType("1"); // TODO no data now

      target.setDate(serviceDateFormat.format(source.getCreationtime()));

      target.setPaymentType(source.getPaymentMethod().getCode());

      LOG.debug("User uid: " + source.getUser().getUid());
      target.setIDPartner(getPartnerID(source.getUser()));
      target.setNumber(source.getCode());
      target.setWarehouseGUID("");

      if (!CollectionUtils.isEmpty(source.getEntries())) {
        if (source.getEntries().get(0).getDeliveryPointOfService() != null) {
          final List<WarehouseModel> wrhs =
              source.getEntries().get(0).getDeliveryPointOfService().getWarehouses();
          if (!CollectionUtils.isEmpty(wrhs)) {
            target.setWarehouseGUID(wrhs.get(0).getCode());
          }
        }
      }

      final Materials materials = new Materials();

      for (final AbstractOrderEntryModel entry : source.getEntries()) {
        final MaterialsRow row = new MaterialsRow();

        row.setDeliveryDate("");
        if (source.getProvidedDeliveryDate() != null) {
          final Date entryDate = serviceDateFormat.parse(source.getProvidedDeliveryDate());
          row.setDeliveryDate(serviceDateFormat.format(entryDate));
        }
        double discountValue = 0;
        for (final DiscountValue discount : entry.getDiscountValues()) {
          discountValue += discount.getAppliedValue();
        }
        row.setDiscount(String.valueOf(discountValue));
        row.setEKN(entry.getProduct().getCode());
        row.setLineTotal(entry.getTotalPrice().toString());
        row.setPackage("");
        row.setPrice(entry.getBasePrice().toString());
        row.setQnty(entry.getQuantity().toString());
        row.setUserGroup("");
        materials.getRow().add(row);
      }
      target.setMaterials(materials);
    } catch (final Exception ex) {
      throw new ConversionException(
          "Error when trying to convert de.hybris.platform.core.model.order.OrderModel to ru.technonikol.ws.orders.Order",
          ex);
    }

    return target;
  }