public ActionForward alert( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { String commentId = request.getParameter("commentId"); String alertType = request.getParameter("alertType"); Customer customer = getCustomer(request); if (customer == null) { JSONEscapeObject jsonResult = new JSONEscapeObject(); jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED); MessageResources resources = this.getResources(request); jsonResult.put("message", resources.getMessage("error.content.signin")); String jsonString = jsonResult.toHtmlString(); streamWebService(response, jsonString); return null; } EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); Comment comment = (Comment) em.find(Comment.class, Format.getLong(commentId)); if (alertType.equals(Constants.ALERT_TYPE_MODERATOR)) { comment.setModeration(Constants.VALUE_YES); em.persist(comment); } else { Iterator<?> iterator = comment.getAgreeCustomers().iterator(); while (iterator.hasNext()) { Customer c = (Customer) iterator.next(); if (c.getCustId().equals(customer.getCustId())) { iterator.remove(); break; } } iterator = comment.getDisagreeCustomers().iterator(); while (iterator.hasNext()) { Customer c = (Customer) iterator.next(); if (c.getCustId().equals(customer.getCustId())) { iterator.remove(); break; } } if (alertType.equals(Constants.ALERT_TYPE_AGREE)) { comment.getAgreeCustomers().add(customer); } else { comment.getDisagreeCustomers().add(customer); } } JSONEscapeObject jsonResult = new JSONEscapeObject(); jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS); jsonResult.put("agreeCount", comment.getAgreeCustomers().size()); jsonResult.put("disagreeCount", comment.getDisagreeCustomers().size()); jsonResult.put("moderation", String.valueOf(comment.getModeration())); String jsonString = jsonResult.toHtmlString(); streamWebService(response, jsonString); return null; }
public void removeOpenOrder() throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); if (isNew) { return; } for (OrderItemDetail orderItemDetail : orderHeader.getOrderItemDetails()) { for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) { em.remove(orderAttributeDetail); } for (OrderDetailTax orderDetailTax : orderItemDetail.getOrderDetailTaxes()) { em.remove(orderDetailTax); } em.remove(orderItemDetail); } em.remove(orderHeader); }
public ActionForward rate( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Throwable { String itemNaturalKey = (String) request.getParameter("itemNaturalKey"); String value = (String) request.getParameter("rate"); ContentSessionBean contentSessionBean = getContentBean(request).getContentSessionBean(); Site site = contentSessionBean.getSiteDomain().getSite(); String siteId = site.getSiteId(); if (value != null) { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); Item item = ItemDAO.loadNatural(siteId, itemNaturalKey); int itemRatingCount = item.getItemRatingCount().intValue(); float itemRating = item.getItemRating().floatValue(); int rate = Integer.parseInt(value); if (itemRatingCount != 0) { itemRating = ((itemRating * itemRatingCount) + rate) / (itemRatingCount + 1); itemRatingCount += 1; } else { itemRatingCount = 1; itemRating = rate; } item.setItemRating(new Float(itemRating)); item.setItemRatingCount(new Integer(itemRatingCount)); em.persist(item); } ActionForward forward = actionMapping.findForward("success"); forward = new ActionForward( forward.getPath() + contentSessionBean.getSiteDomain().getSiteDomainPrefix() + "/" + contentSessionBean .getSiteProfile() .getSiteProfileClass() .getSiteProfileClassName() + "/item/" + itemNaturalKey, forward.getRedirect()); return forward; }
public void saveHeader() throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); String userId = user == null ? Constants.USERNAME_SYSTEM : user.getUserId(); Date current = new Date(); if (isNew) { orderHeader.setOrderNum( generateNumber(orderHeader.getSiteDomain().getSite(), Constants.SEQUENCE_ORDER)); orderHeader.setRecCreateBy(userId); orderHeader.setRecCreateDatetime(current); orderHeader.setOrderStatus(Constants.ORDERSTATUS_OPEN); } orderHeader.setRecUpdateBy(userId); orderHeader.setRecUpdateDatetime(current); if (orderHeader.getOrderHeaderId() == null) { em.persist(orderHeader); } isNew = false; }
public void extract(AdminListingActionForm actionForm, HttpServletRequest request) throws Throwable { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); SiteCurrencyClassListingActionForm form = (SiteCurrencyClassListingActionForm) actionForm; Site site = getAdminBean(request).getSite(); Query query = null; String sql = "select siteCurrencyClass " + "from SiteCurrencyClass siteCurrencyClass " + "where siteCurrencyClass.site.siteId = :siteId "; if (!Format.isNullOrEmpty(form.getSrSiteCurrencyClassName())) { sql += "and siteCurrencyClassName like :siteCurrencyClassName "; } query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); if (!Format.isNullOrEmpty(form.getSrSiteCurrencyClassName())) { query.setParameter("siteCurrencyClassName", form.getSrSiteCurrencyClassName()); } Iterator<?> iterator = query.getResultList().iterator(); Vector<SiteCurrencyClassDisplayForm> vector = new Vector<SiteCurrencyClassDisplayForm>(); while (iterator.hasNext()) { SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next(); SiteCurrencyClassDisplayForm siteCurrencyClassDisplay = new SiteCurrencyClassDisplayForm(); siteCurrencyClassDisplay.setSiteCurrencyClassId( siteCurrencyClass.getSiteCurrencyClassId().toString()); siteCurrencyClassDisplay.setSiteCurrencyClassName( siteCurrencyClass.getSiteCurrencyClassName()); String localeName = getLocaleName( siteCurrencyClass.getCurrencyLocaleLanguage(), siteCurrencyClass.getCurrencyLocaleCountry()); siteCurrencyClassDisplay.setLocaleName(localeName); siteCurrencyClassDisplay.setSystemRecord(String.valueOf(siteCurrencyClass.getSystemRecord())); vector.add(siteCurrencyClassDisplay); } SiteCurrencyClassDisplayForm siteCurrencyClasses[] = new SiteCurrencyClassDisplayForm[vector.size()]; vector.copyInto(siteCurrencyClasses); form.setSiteCurrencyClasses(siteCurrencyClasses); }
public ActionForward remove( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Throwable { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); SiteCurrencyClassListingActionForm form = (SiteCurrencyClassListingActionForm) actionForm; try { SiteCurrencyClassDisplayForm siteCurrencyClasses[] = form.getSiteCurrencyClasses(); if (siteCurrencyClasses != null) { for (int i = 0; i < siteCurrencyClasses.length; i++) { if (!siteCurrencyClasses[i].isRemove()) { continue; } SiteCurrencyClass siteCurrencyClass = new SiteCurrencyClass(); siteCurrencyClass = SiteCurrencyClassDAO.load( Format.getLong(siteCurrencyClasses[i].getSiteCurrencyClassId())); CategorySearchUtil.removeSiteCurrencyClass( getAdminBean(request).getSite().getSiteId(), siteCurrencyClass); em.remove(siteCurrencyClass); } em.getTransaction().commit(); } } catch (Exception e) { if (Utility.isConstraintViolation(e)) { ActionMessages errors = new ActionMessages(); errors.add("error", new ActionMessage("error.remove.siteCurrencyClasss.constraint")); saveMessages(request, errors); ActionForward forward = actionMapping.findForward("removeError"); return forward; } throw e; } ActionForward forward = new ActionForward(); forward = new ActionForward(request.getServletPath() + "?process=list", true); return forward; }
public ActionForward performAction( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); Site site = getAdminBean(request).getSite(); JSONEscapeObject jsonResult = new JSONEscapeObject(); Vector<JSONEscapeObject> countries = new Vector<JSONEscapeObject>(); Query query = em.createQuery("from Country country where siteId = :siteId order by countryName"); query.setParameter("siteId", site.getSiteId()); Iterator<?> iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Country country = (Country) iterator.next(); JSONEscapeObject jsonCountry = new JSONEscapeObject(); jsonCountry.put("countryId", country.getCountryId()); jsonCountry.put("countryCode", country.getCountryCode()); jsonCountry.put("countryName", country.getCountryName()); Iterator<?> iterator1 = country.getStates().iterator(); Vector<JSONEscapeObject> states = new Vector<JSONEscapeObject>(); while (iterator1.hasNext()) { State state = (State) iterator1.next(); JSONEscapeObject jsonState = new JSONEscapeObject(); jsonState.put("stateId", state.getStateId()); jsonState.put("stateCode", state.getStateCode()); jsonState.put("stateName", state.getStateName()); states.add(jsonState); } jsonCountry.put("states", states); countries.add(jsonCountry); } jsonResult.put("countries", countries); String jsonString = jsonResult.toHtmlString(); streamWebService(response, jsonString); return null; }
public OrderEngine(ShoppingCart shoppingCart, User user) throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); this.shoppingCart = shoppingCart; this.user = user; isNew = true; String siteId = shoppingCart.getContentSessionKey().getSiteId(); ContentSessionKey contentSessionKey = shoppingCart.getContentSessionKey(); if (shoppingCart.getOrderNum() != null) { orderHeader = OrderHeaderDAO.load(siteId, shoppingCart.getOrderNum()); isNew = false; } else { orderHeader = new OrderHeader(); orderHeader.setOrderStatus(Constants.ORDERSTATUS_OPEN); } Customer customer = shoppingCart.getCustomer(); if (customer != null) { OrderAddress custAddress = null; if (orderHeader.getCustAddress() != null) { custAddress = orderHeader.getCustAddress(); } else { custAddress = new OrderAddress(); custAddress.setRecCreateBy(Constants.USERNAME_SYSTEM); custAddress.setRecCreateDatetime(new Date()); } CustomerAddress adddress = customer.getCustAddress(); custAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN); custAddress.setCustPrefix(adddress.getCustPrefix()); custAddress.setCustFirstName(adddress.getCustFirstName()); custAddress.setCustMiddleName(adddress.getCustMiddleName()); custAddress.setCustLastName(adddress.getCustLastName()); custAddress.setCustSuffix(adddress.getCustSuffix()); custAddress.setCustAddressLine1(adddress.getCustAddressLine1()); custAddress.setCustAddressLine2(adddress.getCustAddressLine2()); custAddress.setCustCityName(adddress.getCustCityName()); custAddress.setCustStateName(adddress.getCustStateName()); custAddress.setCustStateCode(adddress.getCustStateCode()); custAddress.setCustCountryName(adddress.getCustCountryName()); custAddress.setCustCountryCode(adddress.getCustCountryCode()); custAddress.setCustStateName(adddress.getCustStateName()); custAddress.setCustZipCode(adddress.getCustZipCode()); custAddress.setCustPhoneNum(adddress.getCustPhoneNum()); custAddress.setCustFaxNum(adddress.getCustFaxNum()); custAddress.setRecUpdateBy(Constants.USERNAME_SYSTEM); custAddress.setRecUpdateDatetime(new Date()); Country country = CountryDAO.loadByCountryCode(siteId, adddress.getCustCountryCode()); custAddress.setCountry(country); if (adddress.getCustStateCode() != null) { State state = StateDAO.loadByStateCode(siteId, adddress.getCustStateCode()); custAddress.setState(state); } em.persist(custAddress); orderHeader.setCustAddress(custAddress); } CustomerAddress billingAddress = shoppingCart.getBillingAddress(); if (billingAddress != null) { OrderAddress address = null; if (orderHeader.getBillingAddress() != null) { address = orderHeader.getBillingAddress(); } else { address = new OrderAddress(); address.setRecCreateBy(Constants.USERNAME_SYSTEM); address.setRecCreateDatetime(new Date()); } address.setCustUseAddress(billingAddress.getCustUseAddress()); address.setCustPrefix(billingAddress.getCustPrefix()); address.setCustFirstName(billingAddress.getCustFirstName()); address.setCustMiddleName(billingAddress.getCustMiddleName()); address.setCustLastName(billingAddress.getCustLastName()); address.setCustSuffix(billingAddress.getCustSuffix()); address.setCustAddressLine1(billingAddress.getCustAddressLine1()); address.setCustAddressLine2(billingAddress.getCustAddressLine2()); address.setCustCityName(billingAddress.getCustCityName()); address.setCustStateName(billingAddress.getCustStateName()); address.setCustStateCode(billingAddress.getCustStateCode()); address.setCustCountryName(billingAddress.getCustCountryName()); address.setCustCountryCode(billingAddress.getCustCountryCode()); address.setCustStateName(billingAddress.getCustStateName()); address.setCustZipCode(billingAddress.getCustZipCode()); address.setCustPhoneNum(billingAddress.getCustPhoneNum()); address.setCustFaxNum(billingAddress.getCustFaxNum()); address.setRecUpdateBy(Constants.USERNAME_SYSTEM); address.setRecUpdateDatetime(new Date()); Country country = CountryDAO.loadByCountryCode(siteId, billingAddress.getCustCountryCode()); address.setCountry(country); if (billingAddress.getCustStateCode() != null) { State state = StateDAO.loadByStateCode(siteId, billingAddress.getCustStateCode()); address.setState(state); } em.persist(address); orderHeader.setBillingAddress(address); } CustomerAddress shippingAddress = shoppingCart.getShippingAddress(); if (shippingAddress != null) { OrderAddress address = null; if (orderHeader.getShippingAddress() != null) { address = orderHeader.getShippingAddress(); } else { address = new OrderAddress(); address.setRecCreateBy(Constants.USERNAME_SYSTEM); address.setRecCreateDatetime(new Date()); } address.setCustUseAddress(shippingAddress.getCustUseAddress()); address.setCustPrefix(shippingAddress.getCustPrefix()); address.setCustFirstName(shippingAddress.getCustFirstName()); address.setCustMiddleName(shippingAddress.getCustMiddleName()); address.setCustLastName(shippingAddress.getCustLastName()); address.setCustSuffix(shippingAddress.getCustSuffix()); address.setCustAddressLine1(shippingAddress.getCustAddressLine1()); address.setCustAddressLine2(shippingAddress.getCustAddressLine2()); address.setCustCityName(shippingAddress.getCustCityName()); address.setCustStateName(shippingAddress.getCustStateName()); address.setCustStateCode(shippingAddress.getCustStateCode()); address.setCustCountryName(shippingAddress.getCustCountryName()); address.setCustCountryCode(shippingAddress.getCustCountryCode()); address.setCustStateName(shippingAddress.getCustStateName()); address.setCustZipCode(shippingAddress.getCustZipCode()); address.setCustPhoneNum(shippingAddress.getCustPhoneNum()); address.setCustFaxNum(shippingAddress.getCustFaxNum()); address.setRecUpdateBy(Constants.USERNAME_SYSTEM); address.setRecUpdateDatetime(new Date()); Country country = CountryDAO.loadByCountryCode(siteId, shippingAddress.getCustCountryCode()); address.setCountry(country); if (shippingAddress.getCustStateCode() != null) { State state = StateDAO.loadByStateCode(siteId, shippingAddress.getCustStateCode()); address.setState(state); } em.persist(address); orderHeader.setShippingAddress(address); } if (customer != null) { orderHeader.setCustEmail(customer.getCustEmail()); } orderHeader.setShippingTotal(Float.valueOf(shoppingCart.getShippingOrderTotal())); orderHeader.setShippingDiscountTotal(shoppingCart.getShippingDiscountTotal()); orderHeader.setOrderTotal(Float.valueOf(shoppingCart.getOrderTotal())); orderHeader.setOrderDate(new Date()); orderHeader.setPaymentGatewayProvider(null); orderHeader.setCreditCardDesc(null); orderHeader.setCustCreditCardNum(null); if (!shoppingCart.isCashPaymentOrder()) { if (shoppingCart.getPaymentEngine() != null) { orderHeader.setPaymentGatewayProvider( shoppingCart.getPaymentEngine().getClass().getSimpleName()); } } CustomerCreditCard custCreditCard = shoppingCart.getCustCreditCard(); if (!shoppingCart.isCashPaymentOrder() && custCreditCard != null) { orderHeader.setCreditCardDesc(custCreditCard.getCreditCard().getCreditCardDesc()); orderHeader.setCustCreditCardNum(custCreditCard.getCustCreditCardNum()); creditCardInfo = new CreditCardInfo(); creditCardInfo.setCreditCardNum( AESEncoder.getInstance().decode(custCreditCard.getCustCreditCardNum())); creditCardInfo.setCreditCardFullName(custCreditCard.getCustCreditCardFullName()); creditCardInfo.setCreditCardVerNum(custCreditCard.getCustCreditCardVerNum()); creditCardInfo.setCreditCardExpiryMonth(custCreditCard.getCustCreditCardExpiryMonth()); creditCardInfo.setCreditCardExpiryYear(custCreditCard.getCustCreditCardExpiryYear()); } if (shoppingCart.getShippingMethod() != null) { orderHeader.setShippingMethodName( shoppingCart.getShippingMethod().getShippingMethodLanguage().getShippingMethodName()); if (!contentSessionKey.isSiteProfileClassDefault()) { for (ShippingMethodLanguage language : shoppingCart.getShippingMethod().getShippingMethodLanguages()) { if (language .getSiteProfileClass() .getSiteProfileClassId() .equals(contentSessionKey.getSiteProfileClassId())) { if (language.getShippingMethodName() != null) { orderHeader.setShippingMethodName(language.getShippingMethodName()); } break; } } } } orderHeader.setShippingPickUp(Constants.VALUE_NO); if (shoppingCart.isShippingPickUp()) { orderHeader.setShippingPickUp(Constants.VALUE_YES); String shippingMethodName = Languages.getLangTranValue(contentSessionKey.getLangId(), "content.text.shipping.pickUp"); orderHeader.setShippingMethodName(shippingMethodName); } // orderHeader.setOrderStatus(Constants.ORDERSTATUS_OPEN); orderHeader.setSiteDomain(shoppingCart.getSiteDomain()); orderHeader.setCustomer(customer); orderHeader.setSiteCurrency(shoppingCart.getSiteCurrency()); orderHeader.setSiteProfile(shoppingCart.getSiteProfile()); orderHeader.setShppingMethod(shoppingCart.getShippingMethod()); for (OrderItemDetail orderItemDetail : orderHeader.getOrderItemDetails()) { for (OrderDetailTax orderDetailTax : orderItemDetail.getOrderDetailTaxes()) { em.remove(orderDetailTax); } orderItemDetail.getOrderDetailTaxes().clear(); for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) { em.remove(orderAttributeDetail); } orderItemDetail.getOrderAttributeDetails().clear(); em.remove(orderItemDetail); } orderHeader.getOrderItemDetails().clear(); for (OrderOtherDetail orderOtherDetail : orderHeader.getOrderOtherDetails()) { em.remove(orderOtherDetail); } orderHeader.getOrderOtherDetails().clear(); for (OrderDetailTax orderTax : orderHeader.getOrderTaxes()) { em.remove(orderTax); } orderHeader.getOrderTaxes().clear(); Iterator<?> shoppingCartItems = shoppingCart.getShoppingCartItems().iterator(); int seqNum = 0; while (shoppingCartItems.hasNext()) { ShoppingCartItem shoppingCartItem = (ShoppingCartItem) shoppingCartItems.next(); OrderItemDetail orderItemDetail = new OrderItemDetail(); Item item = shoppingCartItem.getItem(); Item master = item; if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) { master = item.getItemSkuParent(); } orderItemDetail.setSeqNum(Integer.valueOf(seqNum++)); orderItemDetail.setItemNum(item.getItemNum()); orderItemDetail.setItemUpcCd(item.getItemUpcCd()); orderItemDetail.setItemSkuCd(item.getItemSkuCd()); orderItemDetail.setItemShortDesc(master.getItemLanguage().getItemShortDesc()); if (master.getItemLanguage().getItemShortDesc().length() > 128) { orderItemDetail.setItemShortDesc( master.getItemLanguage().getItemShortDesc().substring(0, 127)); } if (!contentSessionKey.isSiteProfileClassDefault()) { for (ItemLanguage language : master.getItemLanguages()) { if (language .getSiteProfileClass() .getSiteProfileClassId() .equals(contentSessionKey.getSiteProfileClassId())) { if (language.getItemShortDesc() != null) { orderItemDetail.setItemShortDesc(language.getItemShortDesc()); } break; } } } orderItemDetail.setItemTierQty(shoppingCartItem.getTierPrice().getItemTierQty()); orderItemDetail.setItemTierPrice(shoppingCartItem.getTierPrice().getItemTierPrice()); orderItemDetail.setItemOrderQty(shoppingCartItem.getItemQty()); orderItemDetail.setItemDetailAmount(shoppingCartItem.getItemPriceTotal()); orderItemDetail.setItemDetailDiscountAmount(shoppingCartItem.getItemDiscountAmount()); setDirty(shoppingCartItem.getItem().getItemSkuCd()); if (shoppingCartItem.getItem().getItemId() != -1L) { orderItemDetail.setItem(item); } orderItemDetail.setOrderHeader(orderHeader); Iterator<?> iterator = shoppingCartItem.getItemAttributeInfos().iterator(); while (iterator.hasNext()) { ItemAttributeInfo itemAttributeInfo = (ItemAttributeInfo) iterator.next(); ItemAttributeDetail itemAttributeDetail = (ItemAttributeDetail) em.find(ItemAttributeDetail.class, itemAttributeInfo.getItemAttribDetailId()); char customAttribTypeCode = itemAttributeDetail .getCustomAttributeDetail() .getCustomAttribute() .getCustomAttribTypeCode(); if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) { continue; } if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) { continue; } if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) { continue; } OrderAttributeDetail orderAttributeDetail = new OrderAttributeDetail(); orderAttributeDetail.setOrderItemDetail(orderItemDetail); orderAttributeDetail.setCustomAttributeDetail( itemAttributeDetail.getCustomAttributeDetail()); if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_SELECT_DROPDOWN) { CustomAttributeOption customAttributeOption = (CustomAttributeOption) em.find(CustomAttributeOption.class, itemAttributeInfo.getCustomAttribOptionId()); orderAttributeDetail.setCustomAttributeOption(customAttributeOption); } if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) { orderAttributeDetail.setOrderAttribValue(itemAttributeInfo.getItemAttribDetailValue()); } orderItemDetail.getOrderAttributeDetails().add(orderAttributeDetail); } orderHeader.getOrderItemDetails().add(orderItemDetail); ItemTax taxes[] = shoppingCartItem.getTaxes(); for (int i = 0; i < taxes.length; i++) { OrderDetailTax orderDetailTax = new OrderDetailTax(); orderDetailTax.setTaxName(taxes[i].getTax().getTaxLanguage().getTaxName()); if (!contentSessionKey.isSiteProfileClassDefault()) { for (TaxLanguage language : taxes[i].getTax().getTaxLanguages()) { if (language .getSiteProfileClass() .getSiteProfileClassId() .equals(contentSessionKey.getSiteProfileClassId())) { if (language.getTaxName() != null) { orderDetailTax.setTaxName(language.getTaxName()); } break; } } } orderDetailTax.setTaxAmount(taxes[i].getTaxAmount()); orderDetailTax.setTax(taxes[i].getTax()); orderDetailTax.setOrderItemDetail(orderItemDetail); orderDetailTax.setOrderHeader(orderHeader); orderItemDetail.getOrderDetailTaxes().add(orderDetailTax); orderHeader.getOrderTaxes().add(orderDetailTax); } } Iterator<?> shoppingCartCoupons = shoppingCart.getShoppingCartCoupons().iterator(); seqNum = 0; while (shoppingCartCoupons.hasNext()) { ShoppingCartCoupon shoppingCartCoupon = (ShoppingCartCoupon) shoppingCartCoupons.next(); OrderOtherDetail orderOtherDetail = new OrderOtherDetail(); Coupon coupon = shoppingCartCoupon.getCoupon(); orderOtherDetail.setCoupon(coupon); orderOtherDetail.setSeqNum(seqNum++); orderOtherDetail.setOrderOtherDetailNum(coupon.getCouponCode()); orderOtherDetail.setOrderOtherDetailDesc(coupon.getCouponLanguage().getCouponName()); if (!contentSessionKey.isSiteProfileClassDefault()) { for (CouponLanguage language : coupon.getCouponLanguages()) { if (language .getSiteProfileClass() .getSiteProfileClassId() .equals(contentSessionKey.getSiteProfileClassId())) { if (language.getCouponName() != null) { orderOtherDetail.setOrderOtherDetailDesc(language.getCouponName()); } break; } } } orderOtherDetail.setOrderOtherDetailAmount(shoppingCartCoupon.getCouponAmount()); setDirty(coupon); orderHeader.getOrderOtherDetails().add(orderOtherDetail); } ItemTax shippingTaxes[] = shoppingCart.getShippingTaxes(); if (shippingTaxes != null) { for (int i = 0; i < shippingTaxes.length; i++) { OrderDetailTax orderDetailTax = new OrderDetailTax(); orderDetailTax.setTaxName(shippingTaxes[i].getTax().getTaxLanguage().getTaxName()); if (!contentSessionKey.isSiteProfileClassDefault()) { for (TaxLanguage language : shippingTaxes[i].getTax().getTaxLanguages()) { if (language .getSiteProfileClass() .getSiteProfileClassId() .equals(contentSessionKey.getSiteProfileClassId())) { if (language.getTaxName() != null) { orderDetailTax.setTaxName(language.getTaxName()); } break; } } } orderDetailTax.setTaxAmount(shippingTaxes[i].getTaxAmount()); orderDetailTax.setTax(shippingTaxes[i].getTax()); orderDetailTax.setOrderHeader(orderHeader); orderHeader.getOrderTaxes().add(orderDetailTax); } } // orderHeader.setOrderStatus(calcStatus(orderHeader)); }
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; }
public void unlockShippingQuote() throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); orderHeader.setShippingValidUntil(null); em.persist(orderHeader); }