Package com.jada.order.cart

Examples of com.jada.order.cart.ShoppingCart


    public ActionForward cancel(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
     
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      shoppingCart.cancelTransaction();
      PaymentEngine paymentEngine = shoppingCart.getPaymentEngine();
      if (paymentEngine != null) {
        paymentEngine.abort();
      }
    createEmptySecureTemplateInfo(request);
      ContentBean contentBean = getContentBean(request);
View Full Code Here


            HttpServletResponse response)
        throws Throwable {
     
    createEmptySecureTemplateInfo(request);
    ShoppingCartNewUserActionForm form = (ShoppingCartNewUserActionForm) actionForm;
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
   
      ActionMessages messages = validate(form);
      if (messages.size() > 0) {
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
      ContentBean contentBean = getContentBean(request);
      Long defaultSiteDomainId = contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteDomainId();
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();

      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String siteId = site.getSiteId();
    String sql = "from   Customer customer " +
           "where  customer.siteDomain.siteDomainId = :siteDomainId " +
           "and    custEmail = :custEmail";
        Query query = em.createQuery(sql);
        if (singleCheckout == Constants.VALUE_YES) {
            query.setParameter("siteDomainId", defaultSiteDomainId);
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
        query.setParameter("custEmail", form.getCustEmail());
        List<?> list = query.getResultList();
        if (list.size() != 0) {
          messages.add("emailDuplicate", new ActionMessage("content.error.email.duplicate"));
        }
       
        sql = "from   Customer customer " +
            "where  customer.siteDomain.siteDomainId = :siteDomainId " +
            "and    custPublicName = :custPublicName";
        query = em.createQuery(sql);
        if (singleCheckout == Constants.VALUE_YES) {
            query.setParameter("siteDomainId", defaultSiteDomainId);
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
        query.setParameter("custPublicName", form.getCustPublicName());
        list = query.getResultList();
        if (list.size() != 0) {
          messages.add("custPublicName", new ActionMessage("content.error.publicName.duplicate"));
        }
        if (messages.size() > 0) {
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
       
    sql = "from     CustomerClass customerClass " +
            "where    customerClass.site.siteId = :siteId " +
            "and      customerClass.systemRecord = 'Y'";
    query = em.createQuery(sql);
    query.setParameter("siteId", siteId);
    CustomerClass customerClass = (CustomerClass) query.getSingleResult();
       
        Customer customer = new Customer();
        customer.setSite(site);
    if (singleCheckout == Constants.VALUE_YES) {
      SiteDomain siteDomain = (SiteDomain) em.find(SiteDomain.class, defaultSiteDomainId);
      customer.setSiteDomain(siteDomain);
    }
    else {
      customer.setSiteDomain(contentBean.getSiteDomain());
    }
        customer.setCustEmail(form.getCustEmail());
        customer.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
        customer.setCustPublicName(form.getCustPublicName());
        customer.setCustSource(Constants.CUSTOMER_SOURCE_REGISTER);
        customer.setCustSourceRef("");
        customer.setActive(Constants.ACTIVE_YES);
        customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customer.setRecCreateBy(Constants.USERNAME_CUSTOMER);
        customer.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        customer.setCustomerClass(customerClass);
       
        CustomerAddress customerAddress = shoppingCart.getEstimateAddress();
        if (customerAddress == null) {
          customerAddress = new CustomerAddress();
        }
        customer.setCustAddress(customerAddress);
        customer.getCustAddresses().add(customerAddress);
        customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
        customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
        customerAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customerAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
        customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);

        em.persist(customer);
        em.flush();
       
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
    shoppingCart.setCustomer(new CustomerDAO(customer));
    shoppingCart.setCustAddress(customerAddress);

        ActionForward actionForward = actionMapping.findForward("createSuccess");
        return actionForward;
    }
View Full Code Here

        actionForward = actionMapping.findForward("success");
      }
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
    createEmptySecureTemplateInfo(request);
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
    if (form.getCash() != null && form.getCash().equals(String.valueOf(Constants.VALUE_YES))) {
      shoppingCart.setCashPaymentOrder(true);
    }
    else {
      shoppingCart.setCashPaymentOrder(false);
    }
    ActionMessages messages = new ActionMessages();
    this.initCartInfo(form, site, shoppingCart, request, messages);
        return actionForward;
    }
View Full Code Here

        throws Throwable {
     
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
        ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();
    createEmptySecureTemplateInfo(request);
      ActionMessages messages = validate((ShoppingCartActionForm) actionForm);
      if (messages.size() > 0) {
        this.initCartInfo(form, site, shoppingCart, request, messages);
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
      IdSecurity idSecurity = new IdSecurity(site, form.getCustEmail(), true);
      if (idSecurity.isSuspened()) {
        idSecurity.fail();
          form.setCustPassword("");
        this.initCartInfo(form, site, shoppingCart, request, messages);
          messages.add("login", new ActionMessage("content.error.login.suspended.temporary", String.valueOf(Constants.ID_SUSPEND_TIME / 1000 / 60)));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }

    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    String sql = "from     Customer customer " +
           "where   customer.siteDomain.siteDomainId = :siteDomainId " +
           "and     custEmail = :custEmail " +
           "and    custPassword = :custPassword ";
        Query query = em.createQuery(sql);
        if (singleCheckout == Constants.VALUE_YES) {
          Long defaultSiteDomainId = contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteDomainId();
          query.setParameter("siteDomainId", defaultSiteDomainId);
        }
        else {
          query.setParameter("siteDomainId", contentBean.getSiteDomain().getSiteDomainId());
        }
        query.setParameter("custEmail", form.getCustEmail());
        query.setParameter("custPassword", AESEncoder.getInstance().encode(form.getCustPassword()));
       
        List<?> list = query.getResultList();
        if (list.size() == 0) {
          idSecurity.fail();
          form.setCustPassword("");
        this.initCartInfo(form, site, shoppingCart, request, messages);
          messages.add("login", new ActionMessage("content.error.login.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        idSecurity.reset();
       
        Customer customer = (Customer) list.get(0);
        if (!customer.getActive().equals(Constants.VALUE_YES)) {
          messages.add("login", new ActionMessage("content.error.login.suspended"));
      saveMessages(request, messages);
            ActionForward actionForward = null;
            if (shoppingCart.isShippingQuoteLock()) {
              actionForward = actionMapping.findForward("quote");
                return actionForward;
            }
            actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
        shoppingCart.initCustomer(customer, contentBean);
        shoppingCart.setShippingPickUp(shoppingCart.isEstimatePickUp());
        shoppingCart.setShippingMethod(null);
       
        OrderHeader orderHeader = shoppingCart.locateAbundentOrder();
        if (orderHeader != null) {
          shoppingCart.mergeOrder(orderHeader.getOrderHeaderId(), contentBean);
        }
       
        ActionForward actionForward = new ActionForward();
        if (shoppingCart.isShippingQuoteLock()) {
          actionForward = actionMapping.findForward("quote");
            return actionForward;
        }
       
    this.initCartInfo(form, site, shoppingCart, request, messages);
View Full Code Here

      init(request);
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();

    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
    ActionMessages messages = new ActionMessages();
    this.initAddressInfo(form, site, shoppingCart, request, messages);
    this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
   
    if (shoppingCart.isShippingPickUp()) {
      form.setShippingMethodId(Constants.SHOPPING_CART_SHIPPING_PICKUP);
    }
   
    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

      init(request);
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
     
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
     
      String shippingMethodId = form.getShippingMethodId();
      if (shippingMethodId.equals(Constants.SHOPPING_CART_SHIPPING_PICKUP)) {
        shoppingCart.setShippingPickUp(true);
        shoppingCart.setShippingMethod(null);
      }
      else {
        shoppingCart.setShippingPickUp(false);
          ShippingMethod shippingMethod = null;
          if (shippingMethodId != null) {
            shippingMethod = ShippingMethodDAO.load(site.getSiteId(), Format.getLong(shippingMethodId));
          }
          shoppingCart.setShippingMethod(shippingMethod);
      }
      shoppingCart.recalculate(contentBean);

      ActionMessages messages = new ActionMessages();
    this.initAddressInfo(form, site, shoppingCart, request, messages);
      this.initCartInfo(form, site, shoppingCart, request, messages);
        saveMessages(request, messages);
       
    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      String couponCode = form.getCouponCode();
    createEmptySecureTemplateInfo(request);
      ActionMessages messages = new ActionMessages();
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      if (Format.isNullOrEmpty(couponCode)) {
        this.initAddressInfo(form, site, shoppingCart, request, messages);
        this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.string.required"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
        Coupon coupon = CouponDAO.loadByCouponCode(site.getSiteId(), couponCode);
        if (coupon == null) {
        this.initAddressInfo(form, site, shoppingCart, request, messages);
          this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.coupon.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
       
    try {
      shoppingCart.addCoupon(coupon, contentBean);
    }
    catch (CouponNotApplicableException e1) {
      this.initAddressInfo(form, site, shoppingCart, request, messages);
      this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.coupon.notApplicable"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
    }
    catch (CouponUserNotRegisterException e2) {
      this.initAddressInfo(form, site, shoppingCart, request, messages);
      this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.coupon.notRegister"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
    }

    form.setCouponCode("");
    this.initCartInfo(form, site, shoppingCart, request, messages);
   
    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
    shoppingCart.removeItem(form.getItemNaturalKey(), contentBean);
    this.initAddressInfo(form, site, shoppingCart, request, messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
   
    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
    this.initAddressInfo(form, site, shoppingCart, request, messages);
      this.initCartInfo(form, site, shoppingCart, request, messages);
    shoppingCart.removeCoupon(Format.getLong(form.getCouponId()), contentBean);
   
    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
    this.initAddressInfo(form, site, shoppingCart, request, messages);
      this.initCartInfo(form, site, shoppingCart, request, messages);
      Language language = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileClass().getLanguage();
      boolean hasError = validateUpdateQty(form, getContentBean(request));
      if (hasError) {
          String itemNaturalKeys[] = form.getItemNaturalKeys();
          String itemQtys[] = form.getItemQtys();
        for (int i = 0; i < itemNaturalKeys.length; i++) {
          ShoppingCartItemBean bean = (ShoppingCartItemBean) form.getShoppingCartItemInfos().elementAt(i);
          bean.setItemQty(itemQtys[i]);
        }
      }
      else {
          String itemNaturalKeys[] = form.getItemNaturalKeys();
          String itemQtys[] = form.getItemQtys();
          if (itemNaturalKeys != null) {
            for (int i = 0; i < itemNaturalKeys.length; i++) {
              int qty = 0;
              if (itemQtys[i].trim().length() != 0) {
                qty = Format.getInt(itemQtys[i]);
              }
          Item item = DataApi.getInstance().getItem(site.getSiteId(), itemNaturalKeys[i]);
          try {
            shoppingCart.setItemQty(item, qty, null, contentBean, true);
            } catch (ItemNotAvailiableException itemNotAvailiableException) {
              String value = Languages.getLangTranValue(language.getLangId(), "content.text.itemQuatityNotAvailable");
              ShoppingCartItemBean itemInfo = (ShoppingCartItemBean) form.getShoppingCartItemInfos().elementAt(i);
              itemInfo.setItemQtyError(value);
              hasError = true;
            }
            }
        }
          if (!hasError) {
            this.initCartInfo(form, site, shoppingCart, request, messages);
          }
      }

    if (shoppingCart.isShippingQuoteLock()) {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_QUOTE_REVIEWPURCHASE);
    }
    else {
      this.saveOpenOrder(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
    }
View Full Code Here

TOP

Related Classes of com.jada.order.cart.ShoppingCart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.