Пример #1
0
  Long calculatePriceLocal(ShopOrder order) {
    order.setShippingCosts(0);
    /* order.setMarketIdTgt(order.getMarketIdSrc());*/
    order.setRate(1.0);
    order.setShippingCosts(0);
    order.setFrgPrice((long) 0);

    Product prd =
        (Product) wirc.getByID("localhost:8180", "Product", new Long(order.getProductID()));
    Long itemPrice = prd.getPrice();

    System.out.println("localhostItemPrice: " + itemPrice);

    order.setPrice(order.getQty() * itemPrice);

    return new Long(itemPrice);
  }
Пример #2
0
  Long calculatePriceRemote(ShopOrder order, Stock stock, double rate) {
    long result = 0;

    order.setShippingCosts(0);
    /** ** order.setMarketIdTgt(order.getMarketIdSrc()); */
    System.out.println("localhostItemPrice: " + 0);

    order.setFrgPrice((long) (order.getQty() * 1));

    return new Long(result);
  }
Пример #3
0
  public List<ShopOrder> priceOrders(List<ShopOrder> allOrders) {

    Marketplace lmp = null;

    System.out.println("priceOrders:allOrders" + allOrders);

    for (ShopOrder odr : allOrders) {

      if (lmp == null)
        lmp =
            (Marketplace)
                wirc.getByID("localhost:8180", "Marketplace", new Long(odr.getMarketIdSrc()));

      Marketplace fmp =
          (Marketplace)
              wirc.getByID("localhost:8180", "Marketplace", new Long(odr.getMarketIdTgt()));

      if (odr.getMarketIdSrc().equals(odr.getMarketIdTgt())) {
        calculatePriceLocal(odr);
        odr.setTotalPrice(odr.getPrice().intValue());
      } else {

        calculatePriceLocal(odr);

        FXRate rt =
            (FXRate)
                wirc.getByPath(
                    "localhost:8180",
                    FXRate.class.getSimpleName(),
                    "convert/" + lmp.getCCY(),
                    fmp.getCCY());

        Product fprd =
            (Product) wirc.getByID(fmp.getURL(), "Product", new Long(odr.getProductID()));

        System.out.println("fprd:" + fprd);
        System.out.println("rate:" + rt);

        double rate = rt.getRate();

        odr.setRate(rate);

        odr.setFrgPrice(new Long((long) (odr.getQty() * rate * fprd.getPrice())));
        odr.setShippingCosts((int) fmp.getShippingCosts());

        odr.setTotalPrice((int) (odr.getFrgPrice() + odr.getShippingCosts()));
      }
    }

    return allOrders;
  }