You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2010/02/23 03:23:41 UTC

svn commit: r915141 - in /ofbiz/trunk/specialpurpose/ebaystore: servicedef/ src/org/ofbiz/ebaystore/ webapp/ebaystore/WEB-INF/ webapp/ebaystore/WEB-INF/actions/store/ widget/

Author: hansbak
Date: Tue Feb 23 02:23:41 2010
New Revision: 915141

URL: http://svn.apache.org/viewvc?rev=915141&view=rev
Log:
Ebaystore update:
Change status of  listing  to secondChanceOffer use when 
1. Your item didn’t sell because the reserve price wasn’t met
2. You have duplicate items for sale
3. The winning bidder didn’t pay you

Removed:
    ofbiz/trunk/specialpurpose/ebaystore/widget/EbayInventoryForms.xml
Modified:
    ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
    ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/SoldAction.groovy
    ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml

Modified: ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml?rev=915141&r1=915140&r2=915141&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml Tue Feb 23 02:23:41 2010
@@ -308,7 +308,6 @@
     <service name="addEbaySecondChanceOffer" engine="java"  transaction-timeout="3600"
         location="org.ofbiz.ebaystore.EbayStore" invoke="addEbaySecondChanceOffer" auth="true">
         <attribute name="productStoreId" mode="IN" type="String" optional="false"/>
-        <attribute name="duration" mode="IN" type="String" optional="false"/>
         <attribute name="itemId" mode="IN" type="String" optional="false"/>
         <attribute name="duration" mode="IN" type="String" optional="false"/>
         <attribute name="recipientBidderUserId" mode="IN" type="String" optional="false"/>
@@ -321,4 +320,10 @@
         <attribute name="itemId" mode="IN" type="String" optional="false"/>
     	<attribute name="bidders" mode="OUT" type="List" optional="true"/>
     </service>
+	<service name="verifyEbayAddSecondChanceItem" engine="java"  transaction-timeout="3600"
+        location="org.ofbiz.ebaystore.EbayStore" invoke="verifyEbayAddSecondChanceItem" auth="true">
+        <attribute name="productStoreId" mode="IN" type="String" optional="false"/>
+        <attribute name="itemId" mode="IN" type="String" optional="false"/>
+        <attribute name="checkVerify" mode="OUT" type="Boolean" optional="false"/>
+    </service>
 </services>
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java?rev=915141&r1=915140&r2=915141&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java Tue Feb 23 02:23:41 2010
@@ -32,11 +32,6 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
@@ -44,7 +39,6 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -60,26 +54,21 @@
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.service.ServiceUtil;
-import org.ofbiz.webapp.event.EventHandlerException;
-import org.ofbiz.product.product.ProductContentWrapper;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
-import com.ebay.sdk.ApiAccount;
 import com.ebay.sdk.ApiContext;
-import com.ebay.sdk.ApiCredential;
 import com.ebay.sdk.ApiException;
-import com.ebay.sdk.ApiLogging;
 import com.ebay.sdk.SdkException;
 import com.ebay.sdk.SdkSoapException;
 import com.ebay.sdk.call.*;
-import com.ebay.sdk.helper.ui.ControlTagItem;
-import com.ebay.soap.eBLBaseComponents.AbstractRequestType;
+import com.ebay.soap.eBLBaseComponents.AmountType;
+import com.ebay.soap.eBLBaseComponents.CurrencyCodeType;
 import com.ebay.soap.eBLBaseComponents.DeleteSellingManagerTemplateRequestType;
 import com.ebay.soap.eBLBaseComponents.DeleteSellingManagerTemplateResponseType;
 import com.ebay.soap.eBLBaseComponents.DisputeExplanationCodeType;
 import com.ebay.soap.eBLBaseComponents.DisputeReasonCodeType;
+import com.ebay.soap.eBLBaseComponents.GetAllBiddersModeCodeType;
 import com.ebay.soap.eBLBaseComponents.GetSellingManagerInventoryRequestType;
 import com.ebay.soap.eBLBaseComponents.GetSellingManagerInventoryResponseType;
 import com.ebay.soap.eBLBaseComponents.GetStoreOptionsRequestType;
@@ -87,6 +76,8 @@
 import com.ebay.soap.eBLBaseComponents.GetStoreRequestType;
 import com.ebay.soap.eBLBaseComponents.GetStoreResponseType;
 import com.ebay.soap.eBLBaseComponents.MerchDisplayCodeType;
+import com.ebay.soap.eBLBaseComponents.OfferType;
+import com.ebay.soap.eBLBaseComponents.SecondChanceOfferDurationCodeType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerProductDetailsType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerProductInventoryStatusType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerProductType;
@@ -103,8 +94,6 @@
 import com.ebay.soap.eBLBaseComponents.StoreCustomCategoryType;
 import com.ebay.soap.eBLBaseComponents.StoreCustomHeaderLayoutCodeType;
 import com.ebay.soap.eBLBaseComponents.StoreCustomListingHeaderDisplayCodeType;
-import com.ebay.soap.eBLBaseComponents.StoreCustomListingHeaderLinkCodeType;
-import com.ebay.soap.eBLBaseComponents.StoreCustomListingHeaderLinkType;
 import com.ebay.soap.eBLBaseComponents.StoreCustomListingHeaderType;
 import com.ebay.soap.eBLBaseComponents.StoreFontFaceCodeType;
 import com.ebay.soap.eBLBaseComponents.StoreFontSizeCodeType;
@@ -118,18 +107,15 @@
 import com.ebay.soap.eBLBaseComponents.StoreThemeArrayType;
 import com.ebay.soap.eBLBaseComponents.StoreThemeType;
 import com.ebay.soap.eBLBaseComponents.StoreType; 
-import com.ebay.soap.eBLBaseComponents.SummaryFrequencyCodeType;
-import com.ebay.soap.eBLBaseComponents.SummaryWindowPeriodCodeType;
 import com.ebay.soap.eBLBaseComponents.TaskStatusCodeType;
+import com.ebay.soap.eBLBaseComponents.VerifyAddSecondChanceItemResponseType;
 
 import java.sql.Timestamp;
-import java.util.TimeZone;
  
 import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType;
 import com.ebay.soap.eBLBaseComponents.ItemArrayType;
 import com.ebay.soap.eBLBaseComponents.ItemListCustomizationType;
 import com.ebay.soap.eBLBaseComponents.ItemType;
-import com.ebay.soap.eBLBaseComponents.MerchDisplayCodeType;
 import com.ebay.soap.eBLBaseComponents.PaginatedItemArrayType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerSoldOrderType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerSoldTransactionType;
@@ -1877,4 +1863,115 @@
 		}
 		return result;
 	}
+	public static Map<String, Object> verifyEbayAddSecondChanceItem(DispatchContext dctx, Map<String, ? extends Object> context) {
+		Map<String, Object>result = FastMap.newInstance();
+		boolean checkVerify = false;
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		GenericValue userLogin = (GenericValue) context.get("userLogin");
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String productStoreId = (String) context.get("productStoreId");
+		String itemID = (String) context.get("itemId"); 
+		ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+		try {
+			DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
+		    		DetailLevelCodeType.RETURN_ALL,
+		    		DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
+		    		DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
+		    	};
+			VerifyAddSecondChanceItemCall verify = new VerifyAddSecondChanceItemCall(apiContext);
+			verify.setItemID(itemID);
+			verify.setDetailLevel(detailLevels);
+		
+			
+			verify.setDuration(SecondChanceOfferDurationCodeType.DAYS_1);
+			Map<String, Object>serviceMap = FastMap.newInstance();
+			serviceMap.put("itemId", itemID);
+			serviceMap.put("productStoreId", productStoreId);
+			serviceMap.put("locale", locale);
+			serviceMap.put("userLogin", userLogin);
+			Map<String, Object>bidderTest = (Map)getEbayAllBidders(dctx, serviceMap); 
+			List<Map>test = (List)bidderTest.get("allBidders");
+			if (test.size() != 0) {
+				verify.setRecipientBidderUserID((String)test.get(0).get("userId"));
+			}
+			VerifyAddSecondChanceItemResponseType verifyResult = verify.verifyAddSecondChanceItem();
+			result.put("checkVerify", true);
+		} catch (Exception e) {
+			result.put("checkVerify", checkVerify);
+			result.put("errorMessage", "This item ( " + itemID + " ) can not add second chance offer.");
+			result.put("responseMessage", "error");
+			return result;
+		}
+		return result;
+	}
+	
+	public static Map<String, Object> getEbayAllBidders(DispatchContext dctx, Map<String, ? extends Object> context) {
+		Map<String, Object>result = FastMap.newInstance();
+		List<Map>allBidders = FastList.newInstance();
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		GenericValue userLogin = (GenericValue) context.get("userLogin");
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String productStoreId = (String) context.get("productStoreId");
+		String itemID = (String) context.get("itemId"); 
+		ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+		try {
+			DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
+		    		DetailLevelCodeType.RETURN_ALL,
+		    		DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
+		    		DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
+		    	};
+			GetAllBiddersCall api = new GetAllBiddersCall(apiContext);
+			api.setDetailLevel(detailLevels);
+		    api.setItemID(itemID);
+		    api.setCallMode(GetAllBiddersModeCodeType.VIEW_ALL);
+		    OfferType[] bidders = api.getAllBidders();
+		      
+		    for (int count=0; count<bidders.length; count++) {
+		    	Map<String, Object>entry = FastMap.newInstance();
+		    	OfferType offer = bidders[count];
+		    	entry.put("userId", offer.getUser().getUserID());
+		    	allBidders.add(entry);
+		      }
+			result.put("allBidders", allBidders);
+		} catch (Exception e) {
+			Debug.logError(e.getMessage(), module);
+			result.put("allBidders", allBidders);
+			return result;
+		}
+		return result;
+	}
+	
+	public static Map<String, Object> addEbaySecondChanceOffer(DispatchContext dctx, Map<String, ? extends Object> context){
+		Map<String, Object>result = FastMap.newInstance();
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		GenericValue userLogin = (GenericValue) context.get("userLogin");
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String productStoreId = (String) context.get("productStoreId");
+		String durationString = (String) context.get("duration");
+		String itemID = (String) context.get("itemId");
+		String sellerMessage = (String) context.get("sellerMessage");
+		String recipientBidderUserID = (String) context.get("recipientBidderUserId");
+		try {
+			ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+			AddSecondChanceItemCall api = new AddSecondChanceItemCall(apiContext);
+			SecondChanceOfferDurationCodeType duration = SecondChanceOfferDurationCodeType.valueOf(durationString);
+			api.setDuration(duration);
+			AmountType buyItNowPrice = new AmountType();
+			if (UtilValidate.isNotEmpty((String) context.get("buyItNowPrice"))) {
+				buyItNowPrice.setValue(Double.parseDouble((String) context.get("buyItNowPrice")));
+				buyItNowPrice.setCurrencyID(CurrencyCodeType.USD);
+				api.setBuyItNowPrice(buyItNowPrice);
+			}
+			api.setRecipientBidderUserID(recipientBidderUserID);
+			api.setItemID(itemID);
+			api.setSellerMessage(sellerMessage);
+			api.addSecondChanceItem();
+		} catch (Exception e) {
+			return ServiceUtil.returnError(e.getMessage());
+		}
+		return ServiceUtil.returnSuccess("Add Second Chance Offer Successful.");
+	}
 }
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/SoldAction.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/SoldAction.groovy?rev=915141&r1=915140&r2=915141&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/SoldAction.groovy (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/SoldAction.groovy Tue Feb 23 02:23:41 2010
@@ -23,7 +23,7 @@
 
 actionList = FastList.newInstance();
 hasAction = false;
-
+//Unpaid Item Dispute
 if (unpaidItemStatus == null && paidTime == null && checkoutStatus != "CheckoutComplete") {
 	inMap = FastMap.newInstance();
 	inMap.put("action","openUnpaid");
@@ -31,5 +31,12 @@
 	actionList.add(inMap);
 	hasAction = true;
 }
+//Second Chance Offer
+inMap = FastMap.newInstance();
+inMap.put("action","makeSecondChanceOffer");
+inMap.put("actionName","Make Second Chance Offer");
+actionList.add(inMap);
+hasAction = true;
+
 context.actionList = actionList;
 context.hasAction = hasAction;
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml?rev=915141&r1=915140&r2=915141&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml Tue Feb 23 02:23:41 2010
@@ -231,6 +231,8 @@
     </request-map>
     <request-map uri="makeSecondChanceOffer">
     	<security auth="true" https="true"/>
+		<event type="service" invoke="verifyEbayAddSecondChanceItem"/>
+		<response name="error" type="view" value="SoldListing"/>
     	<response name="success" type="view" value="MakeSecondChanceOffer"/>
     </request-map>
     <request-map uri="addEbaySecondChanceOffer">

Modified: ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml?rev=915141&r1=915140&r2=915141&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml Tue Feb 23 02:23:41 2010
@@ -93,6 +93,23 @@
     		</hyperlink>
     	</field>
 	</form>
+    <form name="MakeSecondChanceOffer" type="single" target="addEbaySecondChanceOffer">
+    	<auto-fields-service service-name="addEbaySecondChanceOffer"/>
+    	<field name="duration">
+    		<drop-down>
+    			<option key="DAYS_1" description="a day"/>
+    			<option key="DAYS_3" description="3 days"/>
+    			<option key="DAYS_5" description="5 days"/>
+    			<option key="DAYS_7" description="7 days"/>
+    		</drop-down>
+    	</field>
+    	<field name="recipientBidderUserId">
+    		<drop-down>
+    			<list-options key-name="userId" list-name="allBidders" description="${userId}"/>
+    		</drop-down>
+    	</field>
+    	<field name="submitButton" title="${uiLabelMap.CommonAdd}"><submit/></field>
+    </form> 
     <!-- Inventory -->
     <form name="EbayStoreFacilityList" type="single" list-name="productStoreFacilityList"  target="ebayStoreInventory"
         odd-row-style="alternate-row" default-table-style="basic-table hover-bar">