コード例 #1
0
  protected boolean checkDeliveryOptions(final OrderModel order) {
    if (order.getDeliveryMode() == null) {
      // Order must have an overall delivery mode
      return false;
    }

    if (order.getDeliveryAddress() == null) {
      for (final AbstractOrderEntryModel entry : order.getEntries()) {
        if (entry.getDeliveryPointOfService() == null && entry.getDeliveryAddress() == null) {
          // Order and Entry have no delivery address and some entries are not for pickup
          return false;
        }
      }
    }

    return true;
  }
コード例 #2
0
ファイル: CreateOrderRunnable.java プロジェクト: raliev2/tn
  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;
  }