protected Transition executeAction(final OrderProcessModel process) {
    ServicesUtil.validateParameterNotNull(process, "Process cannot be null");
    LOG.info("Process: " + process.getCode() + " in step " + getClass().getSimpleName());

    final OrderModel order = process.getOrder();
    ServicesUtil.validateParameterNotNull(order, "Order in process cannot be null");
    ServicesUtil.validateParameterNotNull(
        order.getFraudulent(), "Fraudulent value in order cannot be null");

    final OrderHistoryEntryModel historyLog =
        createHistoryLog("Order Manually checked by CSA - Fraud = " + order.getFraudulent(), order);
    modelService.save(historyLog);

    LOG.info(
        "The fraud condition of the order "
            + order.getCode()
            + " is "
            + order.getFraudulent().booleanValue());
    if (order.getFraudulent().booleanValue()) {
      order.setStatus(OrderStatus.SUSPENDED);
      getModelService().save(order);
      return Transition.NOK;
    } else {
      order.setStatus(OrderStatus.FRAUD_CHECKED);
      getModelService().save(order);
      return Transition.OK;
    }
  }
  @Override
  public List<Map<String, Object>> createRows(final OrderModel order) {
    final Map<String, Object> row = new HashMap<>();

    row.put(OrderCsvColumns.ORDER_ID, order.getCode());
    row.put(OrderCsvColumns.DATE, order.getDate());
    row.put(OrderCsvColumns.ORDER_CURRENCY_ISO_CODE, order.getCurrency().getIsocode());
    final DeliveryModeModel deliveryMode = order.getDeliveryMode();
    row.put(OrderCsvColumns.DELIVERY_MODE, deliveryMode != null ? deliveryMode.getCode() : "");
    row.put(OrderCsvColumns.BASE_STORE, order.getStore().getUid());
    return Arrays.asList(row);
  }
 @Override
 protected void onSiteEvent(final OrderCancelledEvent event) {
   final OrderModel orderModel = event.getProcess().getOrder();
   final OrderProcessModel orderProcessModel =
       (OrderProcessModel)
           getBusinessProcessService()
               .createProcess(
                   "sendOrderCancelledEmailProcess-"
                       + orderModel.getCode()
                       + "-"
                       + System.currentTimeMillis(),
                   "sendOrderCancelledEmailProcess");
   orderProcessModel.setOrder(orderModel);
   getModelService().save(orderProcessModel);
   getBusinessProcessService().startProcess(orderProcessModel);
 }
 @Override
 protected void onSiteEvent(final OrderPlacedEvent orderPlacedEvent) {
   final OrderModel orderModel = orderPlacedEvent.getProcess().getOrder();
   final OrderProcessModel orderProcessModel =
       (OrderProcessModel)
           getBusinessProcessService()
               .createProcess(
                   "b2bOrderConfirmationEmailProcess"
                       + "-"
                       + orderModel.getCode()
                       + "-"
                       + System.currentTimeMillis(),
                   "b2bOrderConfirmationEmailProcess");
   orderProcessModel.setOrder(orderModel);
   getModelService().save(orderProcessModel);
   getBusinessProcessService().startProcess(orderProcessModel);
 }
예제 #5
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;
  }