diff --git a/ebaystore/config/EbayStoreUiLabels.xml b/ebaystore/config/EbayStoreUiLabels.xml index 0861af765..ef19d09cb 100644 --- a/ebaystore/config/EbayStoreUiLabels.xml +++ b/ebaystore/config/EbayStoreUiLabels.xml @@ -183,4 +183,7 @@ Update To Ebay Inventory + + Update Inventory Status + diff --git a/ebaystore/ofbiz-component.xml b/ebaystore/ofbiz-component.xml index 638f846c9..95d350902 100644 --- a/ebaystore/ofbiz-component.xml +++ b/ebaystore/ofbiz-component.xml @@ -23,6 +23,7 @@ under the License. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd"> + diff --git a/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml b/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml index b5e3185fa..f35bf6f6d 100644 --- a/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml +++ b/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml @@ -43,8 +43,8 @@ - - + + @@ -62,7 +62,13 @@ - + + + + + + + @@ -94,11 +100,13 @@ + + @@ -174,281 +182,145 @@ - - - - - + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ebaystore/servicedef/services.xml b/ebaystore/servicedef/services.xml index 0284d11ec..f6198cd37 100644 --- a/ebaystore/servicedef/services.xml +++ b/ebaystore/servicedef/services.xml @@ -103,7 +103,7 @@ under the License. - + @@ -189,8 +189,8 @@ under the License. - + Reserve Inventory in a Product Store @@ -199,18 +199,23 @@ under the License. - Reserve Inventory for a Product By Facility + location="component://product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml" invoke="reserveProductInventory" auth="true"> + Reserve product for ebay Inventory and make reserve for a Product By Facility If requireInventory is Y the quantity not reserved is returned, if N then a negative availableToPromise will be used to track quantity ordered beyond what is in stock. + + + + + + + update status Inventory from ebay store inventory + + + + + + + + + + Update/cancel an Product quantity that reserved from inventory + + + + \ No newline at end of file diff --git a/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java b/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java index 48832cee7..f0760f1bb 100644 --- a/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java +++ b/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java @@ -466,14 +466,14 @@ public class EbayStore { String userLoginId = null; String password = null; - if(context.get("productStoreId") != null){ + if (context.get("productStoreId") != null) { String partyId = null; try { List productStoreRoles = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", context.get("productStoreId").toString(),"roleTypeId","EBAY_ACCOUNT")); - if(productStoreRoles!=null){ + if (productStoreRoles!=null) { partyId= (String)productStoreRoles.get(0).get("partyId"); List userLogin = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId)); - if(userLogin!=null){ + if (userLogin!=null) { userLoginId = (String)userLogin.get(0).get("userLoginId"); password = (String)userLogin.get(0).get("currentPassword"); } @@ -490,10 +490,10 @@ public class EbayStore { try { resp = (GetStoreResponseType)call.execute(req); - if(resp != null && "SUCCESS".equals(resp.getAck().toString())){ + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { returnedStoreType = resp.getStore(); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); - result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale)); + //result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale)); // update product store in ofbiz updateProductStore(dctx, context,returnedStoreType,(String)context.get("productStoreId")); Map ebayResp = FastMap.newInstance(); @@ -501,7 +501,7 @@ public class EbayStore { ebayResp.put("storeUrl", returnedStoreType.getURL()); ebayResp.put("storeUrlPath", returnedStoreType.getURLPath()); String desc = returnedStoreType.getDescription(); - if(desc!=null) desc = desc.trim(); + if (desc!=null) desc = desc.trim(); ebayResp.put("storeDesc", desc); StoreLogoType logoType = returnedStoreType.getLogo(); @@ -526,13 +526,13 @@ public class EbayStore { ebayResp.put("storeNameColor",fontType.getNameColor()); ebayResp.put("storeTitleColor",fontType.getTitleColor()); - if(fontType!=null){// basic & advance theme + if (fontType!=null) {// basic & advance theme String themeId = themeType.getThemeID().toString().concat("-").concat(colorSchemeType.getColorSchemeID().toString()); context.put("themeId", themeId); Map results = retrieveThemeColorSchemeByThemeId(dctx,context); - if(results!=null){ + if (results!=null) { Map storeFontScheme = (Map)results.get("storeFontScheme"); - if(storeFontScheme!=null){ + if (storeFontScheme!=null) { ebayResp.put("storeDescFontFace",storeFontScheme.get("storeFontTypeFontDescValue")); ebayResp.put("storeDescSizeCode", storeFontScheme.get("storeDescSizeValue")); @@ -548,10 +548,10 @@ public class EbayStore { StoreHeaderStyleCodeType storeHeaderStyleCodeType = returnedStoreType.getHeaderStyle(); ebayResp.put("storeHeaderStyle", storeHeaderStyleCodeType.value()); StoreHeaderStyleCodeType[] storeHeaderStyleCodeList = storeHeaderStyleCodeType.values(); - if(storeHeaderStyleCodeList != null){ + if (storeHeaderStyleCodeList != null) { List> storeHeaderStyleList = FastList.newInstance(); int i=0; - while(i storeHeaderStyleMap = FastMap.newInstance(); StoreHeaderStyleCodeType storeHeaderStyleCode = storeHeaderStyleCodeList[i]; storeHeaderStyleMap.put("storeHeaderStyleName",storeHeaderStyleCode.name()); @@ -567,10 +567,10 @@ public class EbayStore { StoreItemListLayoutCodeType storeItemListLayoutCodeType = returnedStoreType.getItemListLayout(); ebayResp.put("storeItemLayoutSelected", storeItemListLayoutCodeType.value()); StoreItemListLayoutCodeType[] storeItemListLayoutCodeTypeList = storeItemListLayoutCodeType.values(); - if(storeItemListLayoutCodeTypeList!=null){ + if (storeItemListLayoutCodeTypeList!=null) { List> storeItemListLayoutCodeList = FastList.newInstance(); int i=0; - while(i storeItemListLayoutCodeMap = FastMap.newInstance(); StoreItemListLayoutCodeType storeItemListLayoutCode = storeItemListLayoutCodeTypeList[i]; storeItemListLayoutCodeMap.put("storeItemLayoutName",storeItemListLayoutCode.name()); @@ -583,10 +583,10 @@ public class EbayStore { StoreItemListSortOrderCodeType storeItemListSortOrderCodeType = returnedStoreType.getItemListSortOrder(); ebayResp.put("storeItemSortOrderSelected", storeItemListSortOrderCodeType.value()); StoreItemListSortOrderCodeType[] storeItemListSortOrderCodeTypeList = storeItemListSortOrderCodeType.values(); - if(storeItemListSortOrderCodeTypeList!=null){ + if (storeItemListSortOrderCodeTypeList!=null) { List> storeItemSortOrderCodeList = FastList.newInstance(); int i=0; - while(i storeItemSortOrderCodeMap = FastMap.newInstance(); StoreItemListSortOrderCodeType storeItemListLayoutCode = storeItemListSortOrderCodeTypeList[i]; storeItemSortOrderCodeMap.put("storeItemSortLayoutName",storeItemListLayoutCode.name()); @@ -601,10 +601,10 @@ public class EbayStore { StoreCustomHeaderLayoutCodeType storeCustomHeaderLayoutCodeType = returnedStoreType.getCustomHeaderLayout(); ebayResp.put("storeCustomHeaderLayout",storeCustomHeaderLayoutCodeType.value()); StoreCustomHeaderLayoutCodeType[] storeCustomHeaderLayoutCodeTypeList = storeCustomHeaderLayoutCodeType.values(); - if(storeCustomHeaderLayoutCodeTypeList!=null){ + if (storeCustomHeaderLayoutCodeTypeList!=null) { List> storeCustomHeaderLayoutList = FastList.newInstance(); int i=0; - while(i storeCustomHeaderLayoutMap = FastMap.newInstance(); StoreCustomHeaderLayoutCodeType StoreCustomHeaderLayoutCode = storeCustomHeaderLayoutCodeTypeList[i]; storeCustomHeaderLayoutMap.put("storeCustomHeaderLayoutName",StoreCustomHeaderLayoutCode.name()); @@ -616,7 +616,7 @@ public class EbayStore { } StoreCustomListingHeaderType storeCustomListingHeaderType = returnedStoreType.getCustomListingHeader(); - if(storeCustomListingHeaderType!=null){ + if (storeCustomListingHeaderType!=null) { StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCodeType = storeCustomListingHeaderType.getDisplayType(); ebayResp.put("isLogo",storeCustomListingHeaderType.isLogo()); ebayResp.put("isSearchBox",storeCustomListingHeaderType.isSearchBox()); @@ -626,10 +626,10 @@ public class EbayStore { ebayResp.put("storeCustomListingHeaderDisplayName",storeCustomListingHeaderDisplayCodeType.name()); ebayResp.put("storeCustomListingHeaderDisplayValue",storeCustomListingHeaderDisplayCodeType.value()); StoreCustomListingHeaderDisplayCodeType[] storeCustomListingHeaderDisplayCodeTypeList = storeCustomListingHeaderDisplayCodeType.values(); - if(storeCustomListingHeaderDisplayCodeTypeList != null){ + if (storeCustomListingHeaderDisplayCodeTypeList != null) { List> storeCustomListingHeaderDisplayCodeList = FastList.newInstance(); int i=0; - while(i storeCustomListingHeaderDisplayCodeMap = FastMap.newInstance(); StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCode = storeCustomListingHeaderDisplayCodeTypeList[i]; storeCustomListingHeaderDisplayCodeMap.put("storeCustomHeaderLayoutName",storeCustomListingHeaderDisplayCode.name()); @@ -645,10 +645,10 @@ public class EbayStore { MerchDisplayCodeType merchDisplayCodeType = returnedStoreType.getMerchDisplay(); ebayResp.put("storeMerchDisplay",merchDisplayCodeType.value()); MerchDisplayCodeType[] merchDisplayCodeTypeList = merchDisplayCodeType.values(); - if(merchDisplayCodeTypeList!=null){ + if (merchDisplayCodeTypeList!=null) { List> merchDisplayCodeList = FastList.newInstance(); int i=0; - while(i merchDisplayCodeMap = FastMap.newInstance(); MerchDisplayCodeType merchDisplayCode = merchDisplayCodeTypeList[i]; merchDisplayCodeMap.put("merchDisplayCodeName",merchDisplayCode.name()); @@ -663,10 +663,10 @@ public class EbayStore { ebayResp.put("storeLastOpenedTime", calendar.getTime().toString()); ebayResp.put("storeSubscriptionLevel",returnedStoreType.getSubscriptionLevel().value()); StoreSubscriptionLevelCodeType[] storeSubscriptionlevelList = returnedStoreType.getSubscriptionLevel().values(); - if(storeSubscriptionlevelList!=null){ + if (storeSubscriptionlevelList!=null) { List> storeSubscriptionLevelCodeList = FastList.newInstance(); int i=0; - while(i storeSubscriptionLevelCodeMap = FastMap.newInstance(); StoreSubscriptionLevelCodeType storeSubscriptionLevelCode= storeSubscriptionlevelList[i]; storeSubscriptionLevelCodeMap.put("storeSubscriptionLevelCodeName", storeSubscriptionLevelCode.name()); @@ -678,7 +678,7 @@ public class EbayStore { } result.put("ebayStore", ebayResp); - }else{ + } else { result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); result.put(ModelService.ERROR_MESSAGE,resp.getAck().toString()+":"+resp.getMessage()); } @@ -698,7 +698,6 @@ public class EbayStore { public static void updateProductStore(DispatchContext dctx,Map context,StoreType returnStoreType,String productStoreId){ LocalDispatcher dispatcher = dctx.getDispatcher(); - Delegator delegator = dctx.getDelegator(); try{ Map inMap = FastMap.newInstance(); if(returnStoreType != null){ @@ -723,17 +722,16 @@ public class EbayStore { GetStoreOptionsRequestType req = null; GetStoreOptionsResponseType resp = null; StoreThemeArrayType returnedBasicThemeArray = null; - StoreThemeArrayType returnedAdvanceThemeArray = null; try { - if(context.get("productStoreId") != null){ + if (context.get("productStoreId") != null) { String themeId = (String)context.get("themeId"); GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); req = new GetStoreOptionsRequestType(); resp = (GetStoreOptionsResponseType) call.execute(req); - if(resp != null && "SUCCESS".equals(resp.getAck().toString())){ + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { returnedBasicThemeArray = resp.getBasicThemeArray(); StoreThemeType[] storeBasicTheme = returnedBasicThemeArray.getTheme(); @@ -743,14 +741,12 @@ public class EbayStore { themeId = themeId.substring(0,themeId.indexOf("-")); Map storeColorSchemeMap = null; - boolean flag = false; - while(i> logoList = FastList.newInstance(); - while(i logo = FastMap.newInstance(); StoreLogoType storeLogoType = (StoreLogoType)returnedLogoArray.getLogo(i); logo.put("storeLogoId", storeLogoType.getLogoID()); @@ -832,18 +827,18 @@ public class EbayStore { StoreThemeArrayType returnedBasicThemeArray = null; GetStoreOptionsResponseType resp = null; try { - if(context.get("productStoreId") != null){ + if (context.get("productStoreId") != null) { GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); req = new GetStoreOptionsRequestType(); resp = (GetStoreOptionsResponseType) call.execute(req); StoreColorSchemeType storeFontColorSchemeType = null; - if(resp != null && "SUCCESS".equals(resp.getAck().toString())){ + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { returnedBasicThemeArray = resp.getBasicThemeArray(); int i=0; List> themeList = FastList.newInstance(); - while(i basictheme = FastMap.newInstance(); StoreThemeType storeBasicThemeType = (StoreThemeType)returnedBasicThemeArray.getTheme(i); basictheme.put("storeThemeId", storeBasicThemeType.getThemeID()); @@ -853,10 +848,9 @@ public class EbayStore { basictheme.put("storeColorSchemeId",storeColorSchemeType.getColorSchemeID()); basictheme.put("storeColorSchemeName",storeColorSchemeType.getName()); - if(storeFontColorSchemeType == null){ + if (storeFontColorSchemeType == null) { storeFontColorSchemeType = storeBasicThemeType.getColorScheme(); } - themeList.add(basictheme); i++; } diff --git a/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java b/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java index a1da2bae9..4acca70e7 100644 --- a/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java +++ b/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java @@ -1,5 +1,7 @@ package org.ofbiz.ebaystore; +import java.math.BigDecimal; +import java.util.List; import java.util.Locale; import java.util.Map; import javolution.util.FastMap; @@ -9,6 +11,8 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; import com.ebay.sdk.ApiException; import com.ebay.sdk.SdkException; @@ -30,6 +34,7 @@ import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductRequestType; import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductResponseType; import com.ebay.soap.eBLBaseComponents.SellingManagerFolderDetailsType; import com.ebay.soap.eBLBaseComponents.SellingManagerProductDetailsType; +import com.ebay.soap.eBLBaseComponents.SellingManagerProductInventoryStatusType; import com.ebay.soap.eBLBaseComponents.SellingManagerProductType; public class EbayStoreInventoryServices { @@ -50,7 +55,7 @@ public class EbayStoreInventoryServices { boolean checkProd = false; boolean status = false; try { - if(context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null){ + if (context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null) { result = ServiceUtil.returnError("The process was required productStoreId, productId and ebay inventory folderId."); result.put("productStoreId", context.get("productStoreId")); result.put("facilityId", context.get("facilityId")); @@ -61,17 +66,17 @@ public class EbayStoreInventoryServices { String productId = (String)context.get("productId"); String folderId = (String)context.get("folderId"); // start upload/update products which selected to an ebay inventory - if(folderId != null){ + if (folderId != null) { GetSellingManagerInventoryCall invenCall = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); invenReq = new GetSellingManagerInventoryRequestType(); invenResp = (GetSellingManagerInventoryResponseType) invenCall.execute(invenReq); - if(invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())){ + if (invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())) { GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId"))); SellingManagerProductType[] sellingManagerProductTypeList = invenResp.getSellingManagerProduct(); - for(SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){ + for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){ SellingManagerProductDetailsType sellingManagerProductDetailsType = sellingManagerProductType.getSellingManagerProductDetails(); - if(String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){ + if (String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){ checkProd = true; break; } @@ -79,15 +84,15 @@ public class EbayStoreInventoryServices { } // checkProduct is true then update detail but is false do create new one. - if(checkProd == true){ + if (checkProd) { status = updateProductInEbayInventoryFolder(dctx,context); - }else { + } else { status = createNewProductInEbayInventoryFolder(dctx,context); } - if(status == true){ + if (status) { Debug.logInfo("Done to updated product ".concat(context.get("productId").toString()), module); result = ServiceUtil.returnSuccess("Updated ebay store inventory in folder "+context.get("folderId")+" success.."); - }else{ + } else { result = ServiceUtil.returnError("Fail to update ebay store inventory."); } } @@ -115,7 +120,7 @@ public class EbayStoreInventoryServices { boolean flag = false; try { - if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){ + if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) { String productId = (String)context.get("productId"); String folderId = (String)context.get("folderId"); AddSellingManagerProductCall productCall = new AddSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); @@ -127,16 +132,16 @@ public class EbayStoreInventoryServices { sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName")); //Must keep productId in SKU NUMBER because ebay allow productId field only long value. sellingManagerProductDetailsType.setCustomLabel(productId); - if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue()); + if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue()); productReq.setSellingManagerProductDetails(sellingManagerProductDetailsType); productResp = (AddSellingManagerProductResponseType) productCall.execute(productReq); - if(productResp != null && "SUCCESS".equals(productResp.getAck().toString())){ + if (productResp != null && "SUCCESS".equals(productResp.getAck().toString())) { flag = true; ebayProductStoreInventory.put("ebayProductId", productResp.getSellingManagerProductDetails().getProductID()); ebayProductStoreInventory.put("folderId", folderId); ebayProductStoreInventory.store(); - }else{ + } else { Debug.logError("Fail to create inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(productResp.getMessage()), module); } } @@ -161,7 +166,7 @@ public class EbayStoreInventoryServices { boolean flag = false; try { - if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){ + if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) { String productId = (String)context.get("productId"); String folderId = (String)context.get("folderId"); ReviseSellingManagerProductCall call = new ReviseSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); @@ -169,11 +174,11 @@ public class EbayStoreInventoryServices { SellingManagerProductDetailsType sellingManagerProductDetailsType = new SellingManagerProductDetailsType(); GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId"))); Long ebayProductId = null; - if(ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null){ + if (ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null) { Debug.logError("Can not update product "+productId+" has no ebay product Id in EbayProductStoreInventory. ", module); return flag; } - if(ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null){ + if (ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null) { ebayProductId = ebayProductStoreInventory.getLong("ebayProductId"); } sellingManagerProductDetailsType.setProductID(ebayProductId); @@ -181,16 +186,16 @@ public class EbayStoreInventoryServices { sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName")); //Must keep productId in SKU NUMBER because ebay allow productId field only long value. sellingManagerProductDetailsType.setCustomLabel(productId); - if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue()); + if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue()); req.setSellingManagerProductDetails(sellingManagerProductDetailsType); resp = (ReviseSellingManagerProductResponseType) call.execute(req); - if(resp != null && "SUCCESS".equals(resp.getAck().toString())){ + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { flag = true; ebayProductStoreInventory.put("ebayProductId", ebayProductId); ebayProductStoreInventory.put("folderId", folderId); ebayProductStoreInventory.store(); - }else{ + } else { Debug.logError("Fail to update inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(resp.getMessage()), module); } } @@ -215,24 +220,24 @@ public class EbayStoreInventoryServices { boolean flag = false; try { - if(context.get("productStoreId") != null){ + if (context.get("productStoreId") != null) { GetSellingManagerInventoryFolderCall call = new GetSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); req = new GetSellingManagerInventoryFolderRequestType(); resp = (GetSellingManagerInventoryFolderResponseType) call.execute(req); - if(resp != null && "SUCCESS".equals(resp.getAck().toString())){ + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { SellingManagerFolderDetailsType sellingManagerFolderDetailsType = resp.getFolder(); - if(sellingManagerFolderDetailsType!=null){ + if (sellingManagerFolderDetailsType!=null) { SellingManagerFolderDetailsType[] SellingManagerFolderDetailsTypeList = sellingManagerFolderDetailsType.getChildFolder(); - for(SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList){ + for (SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList) { Debug.logInfo("ebay inventory folders name ".concat(sellingManagerFolderDetails.getFolderName()), module); - if(sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)){ + if (sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)) { folderId = String.valueOf(sellingManagerFolderDetails.getFolderID()); flag = true; break; } } } - if(flag == false){ + if (!flag) { folderId = createNewFolderInEbayStoreInventory(dctx,context); } } @@ -245,7 +250,7 @@ public class EbayStoreInventoryServices { } catch (SdkException e) { result = ServiceUtil.returnFailure(e.getMessage()); } - if(result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null; + if (result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null; result.put("folderId", folderId); Debug.logInfo("service return result "+ result, module); return result; @@ -259,14 +264,14 @@ public class EbayStoreInventoryServices { AddSellingManagerInventoryFolderResponseType resp = null; try { - if(context.get("productStoreId") != null){ + if (context.get("productStoreId") != null) { AddSellingManagerInventoryFolderCall call = new AddSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator)); req = new AddSellingManagerInventoryFolderRequestType(); req.setFolderName(defaultFolderName);//req.setComment(value);//req.setParentFolderID(value) resp = (AddSellingManagerInventoryFolderResponseType) call.execute(req); - if(resp != null && "SUCCESS".equals(resp.getAck().toString())) { + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { folderId = String.valueOf(resp.getFolderID()); - }else { + } else { Debug.logError("The problem with create new folder on ebay site.", module); return folderId; } @@ -280,4 +285,84 @@ public class EbayStoreInventoryServices { } return folderId; } + /* update inventory status from ebay store inventory */ + public static Map updateEbayInventoryStatusByProductId(DispatchContext dctx, Map context){ + Locale locale = (Locale) context.get("locale"); + Map result = FastMap.newInstance(); + Delegator delegator = dctx.getDelegator(); + String productStoreId = (String)context.get("productStoreId"); + String facilityId = (String)context.get("facilityId"); + String folderId = (String)context.get("folderId"); + String productId = (String)context.get("productId"); + String ebayProductId = null; + GetSellingManagerInventoryRequestType req = null; + GetSellingManagerInventoryResponseType resp = null; + GenericValue ebayProductStoreInventory = null; + + if (context.get("ebayProductId") != null) { + ebayProductId = String.valueOf(context.get("ebayProductId")); + } + try { + if (productStoreId != null && ebayProductId != null) { + ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",facilityId,"productStoreId",productStoreId)); + GetSellingManagerInventoryCall call = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext(productStoreId, locale, delegator)); + req = new GetSellingManagerInventoryRequestType(); + resp = (GetSellingManagerInventoryResponseType) call.execute(req); + if (resp != null && "SUCCESS".equals(resp.getAck().toString())) { + SellingManagerProductType[] sellingManagerProductTypeList = resp.getSellingManagerProduct(); + for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList) { + SellingManagerProductDetailsType productDetail = sellingManagerProductType.getSellingManagerProductDetails(); + if (String.valueOf(productDetail.getFolderID()).equals(folderId) && String.valueOf(productDetail.getProductID()).equals(ebayProductId) && String.valueOf(productDetail.getCustomLabel()).equals(productId)) { + SellingManagerProductInventoryStatusType prodInventoryStatus = sellingManagerProductType.getSellingManagerProductInventoryStatus(); + ebayProductStoreInventory.put("activeListing",new BigDecimal(prodInventoryStatus.getQuantityActive())); + ebayProductStoreInventory.put("scheduled",new BigDecimal(prodInventoryStatus.getQuantityScheduled())); + ebayProductStoreInventory.put("sold",new BigDecimal(prodInventoryStatus.getQuantitySold())); + ebayProductStoreInventory.put("unSold",new BigDecimal(prodInventoryStatus.getQuantityUnsold())); + ebayProductStoreInventory.store(); + result = ServiceUtil.returnSuccess("Updated inventory status of product ".concat(productId)); + break; + } + } + } else { + Debug.logError("The problem with get manage inventory detail from ebay site.", module); + } + } + } catch (ApiException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } catch (SdkSoapException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } catch (SdkException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } catch (GenericEntityException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } + result.put("productStoreId", context.get("productStoreId")); + result.put("facilityId", context.get("facilityId")); + result.put("folderId", context.get("folderId")); + result.put("productId", productId); + return result; + } + public static Map updateEbayInventoryStatus(DispatchContext dctx, Map context){ + LocalDispatcher dispatcher = dctx.getDispatcher(); + Map result = FastMap.newInstance(); + Delegator delegator = dctx.getDelegator(); + List ebayProductStoreInventoryList = null; + + try { + if (context.get("productStoreId") != null && context.get("facilityId") != null) { + ebayProductStoreInventoryList = delegator.findByAnd("EbayProductStoreInventory", UtilMisc.toMap("facilityId",(String)context.get("facilityId"),"productStoreId",(String)context.get("productStoreId"))); + for (GenericValue ebayProductStoreInventory : ebayProductStoreInventoryList) { + if (ebayProductStoreInventory.get("ebayProductId") != null) { + dispatcher.runSync("updateEbayInventoryStatusByProductId",UtilMisc.toMap("productStoreId",(String)context.get("productStoreId"),"facilityId",(String)context.get("facilityId"),"folderId",ebayProductStoreInventory.get("folderId"),"productId",ebayProductStoreInventory.get("productId"),"ebayProductId",ebayProductStoreInventory.get("ebayProductId"),"userLogin",context.get("userLogin"))); + } + } + } + } catch (GenericEntityException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } catch (GenericServiceException e) { + result = ServiceUtil.returnFailure(e.getMessage()); + } + result = ServiceUtil.returnSuccess(); + return result; + } } diff --git a/ebaystore/webapp/ebaystore/WEB-INF/controller.xml b/ebaystore/webapp/ebaystore/WEB-INF/controller.xml index 1c73382ad..78b93e4c3 100644 --- a/ebaystore/webapp/ebaystore/WEB-INF/controller.xml +++ b/ebaystore/webapp/ebaystore/WEB-INF/controller.xml @@ -139,13 +139,32 @@ - + + + + + + + + + + + + + + + + + + + + @@ -172,5 +191,6 @@ + diff --git a/ebaystore/widget/EbayInventoryForms.xml b/ebaystore/widget/EbayInventoryForms.xml index 2da312b5d..61e0f31c4 100644 --- a/ebaystore/widget/EbayInventoryForms.xml +++ b/ebaystore/widget/EbayInventoryForms.xml @@ -44,15 +44,22 @@
+ - - + + - + + + + + + + @@ -62,4 +69,22 @@
+ +
+ + + + + + + + + + + + +
diff --git a/ebaystore/widget/EbayStoreScreens.xml b/ebaystore/widget/EbayStoreScreens.xml index c77c32863..f77c8e844 100644 --- a/ebaystore/widget/EbayStoreScreens.xml +++ b/ebaystore/widget/EbayStoreScreens.xml @@ -297,12 +297,12 @@ under the License. - +
- + @@ -345,9 +345,9 @@ under the License.
- - - + + +
@@ -384,10 +384,18 @@ under the License. - - - - +
+ + + + + + + + + + +
@@ -429,10 +437,11 @@ under the License. + - + - + @@ -447,4 +456,26 @@ under the License.
+ +
+ + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file