コード例 #1
0
ファイル: OrderEngine.java プロジェクト: Richiexy/JadaSite
 public void saveOpenOrder(String step) throws Exception {
   saveOrder();
   orderHeader.setOrderAbundantLoc(step);
   if (step.equals(Constants.ORDER_STEP_SHIPPINGQUOTE)) {
     ContentSessionKey contentSessionKey = shoppingCart.getContentSessionKey();
     String shippingMethodName =
         Languages.getLangTranValue(contentSessionKey.getLangId(), "content.text.shipping.quote");
     orderHeader.setShippingMethodName(shippingMethodName);
   }
   orderHeader.setOrderStatus(Constants.ORDERSTATUS_OPEN);
 }
コード例 #2
0
ファイル: OrderEngine.java プロジェクト: Richiexy/JadaSite
  public void saveOrder() throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String userId = user == null ? Constants.USERNAME_SYSTEM : user.getUserId();
    Date current = new Date();

    saveHeader();
    orderHeader.setOrderAbundantLoc("");

    Iterator<?> iterator = null;
    iterator = orderHeader.getOrderItemDetails().iterator();
    while (iterator.hasNext()) {
      OrderItemDetail orderItemDetail = (OrderItemDetail) iterator.next();
      if (!isDirty(orderItemDetail.getItemSkuCd())) {
        continue;
      }
      if (orderItemDetail.getItem() != null) {
        InventoryEngine engine = new InventoryEngine(orderItemDetail.getItem());
        engine.adjustBookedQty(orderItemDetail.getItemOrderQty());
      }
      if (orderItemDetail.getRecCreateDatetime() == null) {
        orderItemDetail.setRecCreateBy(userId);
        orderItemDetail.setRecCreateDatetime(current);
      }
      orderItemDetail.setRecUpdateBy(userId);
      orderItemDetail.setRecUpdateDatetime(current);
      if (orderItemDetail.getOrderItemDetailId() == null) {
        em.persist(orderItemDetail);
      }

      Iterator<?> attributes = orderItemDetail.getOrderAttributeDetails().iterator();
      while (attributes.hasNext()) {
        OrderAttributeDetail orderAttributeDetail = (OrderAttributeDetail) attributes.next();
        if (orderAttributeDetail.getRecCreateDatetime() == null) {
          orderAttributeDetail.setRecCreateBy(userId);
          orderAttributeDetail.setRecCreateDatetime(current);
        }
        orderAttributeDetail.setRecUpdateBy(userId);
        orderAttributeDetail.setRecUpdateDatetime(current);
        if (orderAttributeDetail.getOrderAttribDetailId() == null) {
          em.persist(orderAttributeDetail);
        }
      }

      Iterator<?> taxes = orderItemDetail.getOrderDetailTaxes().iterator();
      while (taxes.hasNext()) {
        OrderDetailTax orderDetailTax = (OrderDetailTax) taxes.next();
        if (orderDetailTax.getRecCreateDatetime() == null) {
          orderDetailTax.setRecCreateBy(userId);
          orderDetailTax.setRecCreateDatetime(current);
        }
        orderDetailTax.setRecUpdateBy(userId);
        orderDetailTax.setRecUpdateDatetime(current);
        if (orderDetailTax.getOrderDetailTaxId() == null) {
          em.persist(orderDetailTax);
        }
      }
    }

    iterator = orderHeader.getOrderOtherDetails().iterator();
    while (iterator.hasNext()) {
      OrderOtherDetail orderOtherDetail = (OrderOtherDetail) iterator.next();
      if (isDirty(orderOtherDetail.getCoupon())) {
        if (orderOtherDetail.getRecCreateDatetime() == null) {
          orderOtherDetail.setRecCreateBy(userId);
          orderOtherDetail.setRecCreateDatetime(current);
          orderOtherDetail.setOrderHeader(orderHeader);
        }
        orderOtherDetail.setRecUpdateBy(userId);
        orderOtherDetail.setRecUpdateDatetime(current);
        if (orderOtherDetail.getOrderOtherDetailId() == null) {
          em.persist(orderOtherDetail);
        }
      }
    }

    PaymentTran paymentTran = orderHeader.getPaymentTran();
    if (paymentTran != null) {
      if (paymentTran.getRecUpdateDatetime() == null) {
        paymentTran.setRecCreateBy(userId);
        paymentTran.setRecCreateDatetime(current);
        paymentTran.setRecUpdateBy(userId);
        paymentTran.setRecUpdateDatetime(current);
        if (paymentTran.getPaymentTranId() == null) {
          em.persist(paymentTran);
        }
      }
    }
    paymentTran = orderHeader.getVoidPaymentTran();
    if (paymentTran != null) {
      if (paymentTran.getRecUpdateDatetime() == null) {
        paymentTran.setRecCreateBy(userId);
        paymentTran.setRecCreateDatetime(current);
        paymentTran.setRecUpdateBy(userId);
        paymentTran.setRecUpdateDatetime(current);
        if (paymentTran.getPaymentTranId() == null) {
          em.persist(paymentTran);
        }
      }
    }

    if (orderHeader.getCustAddress() != null) {
      OrderAddress custAddress = orderHeader.getCustAddress();
      if (custAddress.getRecCreateBy() == null) {
        custAddress.setRecCreateBy(userId);
        custAddress.setRecCreateDatetime(current);
      }
      custAddress.setRecUpdateBy(userId);
      custAddress.setRecUpdateDatetime(current);
      if (orderHeader.getCustAddress().getOrderAddressId() == null) {
        em.persist(orderHeader.getCustAddress());
      }
    }
    if (orderHeader.getShippingAddress() != null) {
      OrderAddress shippingAddress = orderHeader.getShippingAddress();
      if (shippingAddress.getRecCreateBy() == null) {
        shippingAddress.setRecCreateBy(userId);
        shippingAddress.setRecCreateDatetime(current);
      }
      shippingAddress.setRecUpdateBy(userId);
      shippingAddress.setRecUpdateDatetime(current);
      if (orderHeader.getShippingAddress().getOrderAddressId() == null) {
        em.persist(orderHeader.getShippingAddress());
      }
    }
    if (orderHeader.getBillingAddress() != null) {
      OrderAddress billingAddress = orderHeader.getBillingAddress();
      if (billingAddress.getRecCreateBy() == null) {
        billingAddress.setRecCreateBy(userId);
        billingAddress.setRecCreateDatetime(current);
      }
      billingAddress.setRecUpdateBy(userId);
      billingAddress.setRecUpdateDatetime(current);
      if (orderHeader.getBillingAddress().getOrderAddressId() == null) {
        em.persist(orderHeader.getBillingAddress());
      }
    }

    Iterator<?> taxes = orderHeader.getOrderTaxes().iterator();
    while (taxes.hasNext()) {
      OrderDetailTax orderDetailTax = (OrderDetailTax) taxes.next();
      if (orderDetailTax.getRecCreateDatetime() == null) {
        orderDetailTax.setRecCreateBy(userId);
        orderDetailTax.setRecCreateDatetime(current);
      }
      orderDetailTax.setRecUpdateBy(userId);
      orderDetailTax.setRecUpdateDatetime(current);
      if (orderDetailTax.getOrderDetailTaxId() == null) {
        em.persist(orderDetailTax);
      }
    }
    //		orderHeader.setOrderStatus(calcStatus(orderHeader));

    this.clean();
    isNew = false;
  }