|
Author: jleroux
Date: Tue Jan 25 13:23:19 2011 New Revision: 1063265 URL: http://svn.apache.org/viewvc?rev=1063265&view=rev Log: A patch from Arun Patidar "Some misc issues in ebayStore component." (https://issues.apache.org/jira/browse/OFBIZ-4118) - OFBIZ-4118 one more patch to fix following issues in ebay and ebayStore components 1 Fixed issue of set complete order status in ebay when we complete order in ofbiz. 2 Created record of OrderPaymentPreference in PAYMENT_RECEIVED status. 3 Updated qty of cart item, if same product is adding again in cart during import order from ebay. 4 Set transactionId in cart. Modified: ofbiz/trunk/applications/party/widget/partymgr/CommunicationEventForms.xml ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java ofbiz/trunk/specialpurpose/ebay/widget/CommonScreens.xml ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java Modified: ofbiz/trunk/applications/party/widget/partymgr/CommunicationEventForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/CommunicationEventForms.xml?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/CommunicationEventForms.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/CommunicationEventForms.xml Tue Jan 25 13:23:19 2011 @@ -918,7 +918,7 @@ under the License. <field name="delContentDataResource"><hidden value="Y"/></field> <field name="communicationEventId"><hidden/></field> <field name="subject" widget-style="buttontext" widget-area-style="fieldWidth300"> - <hyperlink description="${subject}" target="${parameters._LAST_VIEW_NAME_}"> + <hyperlink description="${subject}" target="${parameters._LAST_VIEW_NAME_}" also-hidden="true"> <parameter param-name="communicationEventId"/> <parameter param-name="partyId"/> <parameter param-name="my" value="My"/> Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java Tue Jan 25 13:23:19 2011 @@ -192,7 +192,7 @@ public class EbayHelper { } public static boolean createPaymentFromPaymentPreferences(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, - String orderId, String externalId, Timestamp orderDate, String partyIdFrom) { + String orderId, String externalId, Timestamp orderDate, BigDecimal amount, String partyIdFrom) { List<GenericValue> paymentPreferences = null; try { Map<String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_RECEIVED", @@ -207,7 +207,25 @@ public class EbayHelper { if (!okay) return false; } - } + } else { + paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED", + "paymentMethodTypeId", "EXT_EBAY"); + paymentPreferences = delegator.findByAnd("OrderPaymentPreference", paymentFields); + if (UtilValidate.isNotEmpty(paymentPreferences)) { + Iterator<GenericValue> i = paymentPreferences.iterator(); + while (i.hasNext()) { + GenericValue pref = (GenericValue) i.next(); + if (UtilValidate.isNotEmpty(amount)) { + pref.set("statusId", "PAYMENT_RECEIVED"); + pref.set("maxAmount", amount); + pref.store(); + } + boolean okay = createPayment(dispatcher, userLogin, pref, orderId, externalId, orderDate, partyIdFrom); + if (!okay) + return false; + } + } + } } catch (Exception e) { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); return false; Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java Tue Jan 25 13:23:19 2011 @@ -871,6 +871,7 @@ public class EbayOrderServices { } else { orderCtx.put("externalId", "EBT_" + transactionId); } + orderCtx.put("transactionId", "EBI_" + itemId); GenericValue orderExist = externalOrderExists(delegator, (String)orderCtx.get("externalId")); if (orderExist != null) { @@ -1006,12 +1007,14 @@ public class EbayOrderServices { // set the external id with the eBay Item Id String externalId = (String) context.get("externalId"); + String transactionId = (String) context.get("transactionId"); if (UtilValidate.isNotEmpty(externalId)) { if (externalOrderExists(delegator, externalId) != null && create) { return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.externalIdAlreadyExist", locale)); } cart.setExternalId(externalId); + cart.setTransactionId(transactionId); } else { return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.externalIdNotAvailable", locale)); } @@ -1232,7 +1235,7 @@ public class EbayOrderServices { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", module); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); Debug.logInfo("Payment created.", module); } } @@ -1274,20 +1277,36 @@ public class EbayOrderServices { HashMap<Object, Object> attrs = new HashMap<Object, Object>(); attrs.put("shipGroup", groupIdx); - int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE); - ShoppingCartItem cartItem = cart.findCartItem(idx); - cartItem.setQuantity(qty, dispatcher, cart, true, false); - // locate the price verify it matches the expected price - BigDecimal cartPrice = cartItem.getBasePrice(); - cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding); - if (price.doubleValue() != cartPrice.doubleValue()) { - // does not match; honor the price but hold the order for manual review - cartItem.setIsModifiedPrice(true); - cartItem.setBasePrice(price); - cart.setHoldOrder(true); - cart.addInternalOrderNote("Price received [" + price + "] (for item # " + productId + ") from eBay Checkout does not match the price in the database [" + cartPrice + "]. Order is held for manual review."); + // Checking if previously added same product exists in the cart + ShoppingCartItem previouslyAddedItemInCart = null; + if (cart.size() != 0) { + Iterator cartiter = cart.iterator(); + while (cartiter != null && cartiter.hasNext()) { + ShoppingCartItem cartItem = (ShoppingCartItem) cartiter.next(); + if (cartItem.getProductId().equals(productId)) { + previouslyAddedItemInCart = cartItem; + } + } } - // assign the item to its ship group - cart.setItemShipGroupQty(cartItem, qty, groupIdx); - } + if (previouslyAddedItemInCart != null) { + BigDecimal newQuantity = previouslyAddedItemInCart.getQuantity().add(qty); + previouslyAddedItemInCart.setQuantity(newQuantity, dispatcher, cart); + } else { + int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE); + ShoppingCartItem cartItem = cart.findCartItem(idx); + cartItem.setQuantity(qty, dispatcher, cart, true, false); + // locate the price verify it matches the expected price + BigDecimal cartPrice = cartItem.getBasePrice(); + cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding); + if (price.doubleValue() != cartPrice.doubleValue()) { + // does not match; honor the price but hold the order for manual review + cartItem.setIsModifiedPrice(true); + cartItem.setBasePrice(price); + cart.setHoldOrder(true); + cart.addInternalOrderNote("Price received [" + price + "] (for item # " + productId + ") from eBay Checkout does not match the price in the database [" + cartPrice + "]. Order is held for manual review."); + } + // assign the item to its ship group + cart.setItemShipGroupQty(cartItem, qty, groupIdx); + } + } } Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java Tue Jan 25 13:23:19 2011 @@ -129,6 +129,7 @@ public class ImportOrdersFromEbay { Locale locale = (Locale) context.get("locale"); String orderId = (String) context.get("orderId"); String externalId = (String) context.get("externalId"); + String transactionId = ""; Map<String, Object> result = FastMap.newInstance(); try { if (orderId == null && externalId == null) { @@ -153,6 +154,7 @@ public class ImportOrdersFromEbay { // get externalId from OrderHeader externalId = (String)orderHeader.get("externalId"); + transactionId = orderHeader.getString("transactionId"); String productStoreId = (String) orderHeader.get("productStoreId"); if (UtilValidate.isNotEmpty(productStoreId)) { context.put("productStoreId", productStoreId); @@ -163,8 +165,9 @@ public class ImportOrdersFromEbay { StringBuffer completeSaleXml = new StringBuffer(); - if (!ServiceUtil.isFailure(buildCompleteSaleRequest(delegator, locale, externalId, context, completeSaleXml, eBayConfigResult.get("token").toString()))) { + if (!ServiceUtil.isFailure(buildCompleteSaleRequest(delegator, locale, externalId, transactionId, context, completeSaleXml, eBayConfigResult.get("token").toString()))) { result = EbayHelper.postItem(eBayConfigResult.get("xmlGatewayUri").toString(), completeSaleXml, eBayConfigResult.get("devID").toString(), eBayConfigResult.get("appID").toString(), eBayConfigResult.get("certID").toString(), "CompleteSale", eBayConfigResult.get("compatibilityLevel").toString(), eBayConfigResult.get("siteID").toString()); + String successMessage = (String)result.get("successMessage"); if (successMessage != null) { return readCompleteSaleResponse(successMessage, locale); @@ -247,12 +250,12 @@ public class ImportOrdersFromEbay { return ServiceUtil.returnSuccess(); } - public static Map<String, Object> buildCompleteSaleRequest(Delegator delegator, Locale locale, String transactionId, Map<String, Object> context, StringBuffer dataItemsXml, String token) { + public static Map<String, Object> buildCompleteSaleRequest(Delegator delegator, Locale locale, String externalId, String transactionId, Map<String, Object> context, StringBuffer dataItemsXml, String token) { String paid = (String)context.get("paid"); String shipped = (String)context.get("shipped"); try { - if (transactionId == null) { + if (externalId == null) { return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.errorDuringBuildItemAndTransactionIdFromExternalId", locale)); } @@ -261,22 +264,26 @@ public class ImportOrdersFromEbay { transElem.setAttribute("xmlns", "urn:ebay:apis:eBLBaseComponents"); EbayHelper.appendRequesterCredentials(transElem, transDoc, token); - - if (transactionId.startsWith("EBT_")) { - UtilXml.addChildElementValue(transElem, "TransactionID", transactionId.substring(4), transDoc); - UtilXml.addChildElementValue(transElem, "ItemID", "0", transDoc); - } else if (transactionId.startsWith("EBO_")) { - UtilXml.addChildElementValue(transElem, "OrderID", transactionId.substring(4), transDoc); + if (externalId.startsWith("EBT_")) { + UtilXml.addChildElementValue(transElem, "TransactionID", externalId.substring(4), transDoc); + UtilXml.addChildElementValue(transElem, "ItemID", transactionId.substring(4), transDoc); + } else if (externalId.startsWith("EBO_")) { + UtilXml.addChildElementValue(transElem, "OrderID", externalId.substring(4), transDoc); UtilXml.addChildElementValue(transElem, "TransactionID", "0", transDoc); UtilXml.addChildElementValue(transElem, "ItemID", "0", transDoc); - } else if (transactionId.startsWith("EBI_")) { - UtilXml.addChildElementValue(transElem, "ItemID", transactionId.substring(4), transDoc); + } else if (externalId.startsWith("EBI_")) { + UtilXml.addChildElementValue(transElem, "ItemID", externalId.substring(4), transDoc); + UtilXml.addChildElementValue(transElem, "TransactionID", "0", transDoc); + } else if (externalId.startsWith("EBS_")) { + //UtilXml.addChildElementValue(transElem, "OrderID", externalId.substring(4), transDoc); UtilXml.addChildElementValue(transElem, "TransactionID", "0", transDoc); + UtilXml.addChildElementValue(transElem, "ItemID", externalId.substring(4), transDoc); } // default shipped = Y (call from eca during order completed) if (paid == null && shipped == null) { shipped = "Y"; + paid = "Y"; } // Set item id to paid or not paid @@ -499,6 +506,7 @@ public class ImportOrdersFromEbay { } else { order.put("externalId", "EBT_" + transactionId); } + order.put("transactionId", "EBI_" + itemId); GenericValue orderExist = externalOrderExists(delegator, (String)order.get("externalId")); if (orderExist != null) { @@ -799,7 +807,7 @@ public class ImportOrdersFromEbay { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", module); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); Debug.logInfo("Payment created.", module); } } Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Tue Jan 25 13:23:19 2011 @@ -309,6 +309,11 @@ public class ProductsExportToEbay { Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument); UtilXml.addChildElementValue(primaryCatElem, "CategoryID", primaryCategoryId, itemDocument); + UtilXml.addChildElementValue(itemElem, "ConditionID", "1000", itemDocument); + Element itemSpecificsElem = UtilXml.addChildElement(itemElem, "ItemSpecifics", itemDocument); + Element nameValueListElem = UtilXml.addChildElement(itemSpecificsElem, "NameValueList", itemDocument); + UtilXml.addChildElementValue(nameValueListElem, "Name", "Condition", itemDocument); + UtilXml.addChildElementValue(nameValueListElem, "Value", "New: With Tags", itemDocument); //Debug.logInfo("The generated string is ======= " + UtilXml.writeXmlDocument(itemDocument), module); dataItemsXml.append(UtilXml.writeXmlDocument(itemDocument)); Modified: ofbiz/trunk/specialpurpose/ebay/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/widget/CommonScreens.xml?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/widget/CommonScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/widget/CommonScreens.xml Tue Jan 25 13:23:19 2011 @@ -28,6 +28,7 @@ under the License. <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/> <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/> <property-map resource="WorkEffortUiLabels" map-name="uiLabelMap" global="true"/> + <property-map resource="GoogleBaseUiLabels" map-name="uiLabelMap" global="true"/> <set field="activeApp" value="ebay" global="true"/> <set field="layoutSettings.companyName" from-field="uiLabelMap.EbayCompanyName" global="true"/> <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.EbayApplication" global="true"/> Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java?rev=1063265&r1=1063264&r2=1063265&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java (original) +++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOrder.java Tue Jan 25 13:23:19 2011 @@ -300,7 +300,7 @@ public class EbayStoreOrder { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", module); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); Debug.logInfo("Payment created.", module); } } @@ -542,7 +542,7 @@ public class EbayStoreOrder { // create the payment from the preference if (approved) { Debug.logInfo("Creating payment for approved order.", module); - EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId); + EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId); Debug.logInfo("Payment created.", module); } } |
| Free forum by Nabble | Edit this page |
