From 6efdbd37882f7e8c2f7af5aeb41b9ae600286fd2 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Thu, 4 Mar 2010 10:55:48 +0000 Subject: [PATCH] Ebaystore update: Function to send an automatic notification by email when an item is shipped. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@918929 13f79535-47bb-0310-9956-ffa450edef68 --- ebaystore/config/EbayStoreUiLabels.xml | 3 + ebaystore/data/DemoEbayStoreData.xml | 16 ++++- ebaystore/data/EbayStoreTypeData.xml | 6 +- .../org/ofbiz/ebaystore/EbayStoreEvents.xml | 41 +++++++++++++ ebaystore/servicedef/services.xml | 6 ++ .../ebaystore/EbayStoreAutoPreferences.java | 59 +++++++++++++++++++ .../webapp/ebaystore/WEB-INF/controller.xml | 6 ++ ebaystore/widget/EbaySellingManagerForms.xml | 12 ++++ .../widget/EbaySellingManagerScreens.xml | 3 + 9 files changed, 148 insertions(+), 4 deletions(-) diff --git a/ebaystore/config/EbayStoreUiLabels.xml b/ebaystore/config/EbayStoreUiLabels.xml index 75ef193bc..b5e45527b 100644 --- a/ebaystore/config/EbayStoreUiLabels.xml +++ b/ebaystore/config/EbayStoreUiLabels.xml @@ -272,4 +272,7 @@ Combine Orders Setting + + Automatic send item dispatched notification email + \ No newline at end of file diff --git a/ebaystore/data/DemoEbayStoreData.xml b/ebaystore/data/DemoEbayStoreData.xml index 8de770468..391ed57c9 100644 --- a/ebaystore/data/DemoEbayStoreData.xml +++ b/ebaystore/data/DemoEbayStoreData.xml @@ -80,9 +80,21 @@ - + + + + + Demo : Automatic send item dispatched notification email when user mark sold listing as dispatched. + ]]> + + + + + - + + diff --git a/ebaystore/data/EbayStoreTypeData.xml b/ebaystore/data/EbayStoreTypeData.xml index e903cde25..91928c701 100644 --- a/ebaystore/data/EbayStoreTypeData.xml +++ b/ebaystore/data/EbayStoreTypeData.xml @@ -40,10 +40,12 @@ under the License. - + + - + + diff --git a/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml b/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml index 94471f2b8..aa21bcbdc 100644 --- a/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml +++ b/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml @@ -197,6 +197,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ebaystore/servicedef/services.xml b/ebaystore/servicedef/services.xml index 1165e3025..b9472badb 100644 --- a/ebaystore/servicedef/services.xml +++ b/ebaystore/servicedef/services.xml @@ -378,4 +378,10 @@ under the License. + + Automatic service to send item dispatched notification email when user mark sold listing as dispatched + + + \ No newline at end of file diff --git a/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java b/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java index e2e6ba44b..a60160bf6 100644 --- a/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java +++ b/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java @@ -967,4 +967,63 @@ public class EbayStoreAutoPreferences { } return result; } + + public static Map autoSendItemDispatchedNotification(DispatchContext dctx, Map context) { + Map 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"); + + try { + Map resultSold = dispatcher.runSync("getEbaySoldItems", context); + List soldItems = (List) resultSold.get("soldItems"); + if (soldItems.size() != 0) { + for (int i = 0; i < soldItems.size(); i++) { + Map item = (Map) soldItems.get(i); + String shippedStatus = item.get("shippedStatus").toString(); + Timestamp lastestTime = UtilDateTime.getDayStart(UtilDateTime.nowTimestamp(), 1); + Date shippedTime = (Date) item.get("shippedTime"); + Timestamp shippedTimestamp = UtilDateTime.toTimestamp(shippedTime); + + if ("SHIPPED".equals(shippedStatus) && shippedTimestamp.equals(lastestTime)) { + String buyerUserId = item.get("buyerUserId").toString(); + String buyerEmail = item.get("buyerEmail").toString(); + + Map sendMap = FastMap.newInstance(); + GenericValue productStoreEmail = delegator.findByPrimaryKey("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", "EBAY_ITEM_DISPATCH")); + String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation"); + sendMap.put("bodyScreenUri", bodyScreenLocation); + String subjectString = productStoreEmail.getString("subject"); + sendMap.put("userLogin", userLogin); + sendMap.put("subject", subjectString); + sendMap.put("contentType", productStoreEmail.get("contentType")); + sendMap.put("sendFrom", productStoreEmail.get("fromAddress")); + sendMap.put("sendCc", productStoreEmail.get("ccAddress")); + sendMap.put("sendBcc", productStoreEmail.get("bccAddress")); + sendMap.put("sendTo", buyerEmail); + + Map bodyParameters = FastMap.newInstance(); + bodyParameters.put("buyerUserId", buyerUserId); + sendMap.put("bodyParameters", bodyParameters); + + try { + dispatcher.runAsync("sendMailFromScreen", sendMap); + } catch (Exception e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); + } + + } + } + } + result = ServiceUtil.returnSuccess(); + } catch (GenericServiceException e) { + result = ServiceUtil.returnError(e.getMessage()); + } catch (Exception e) { + return ServiceUtil.returnError(e.getMessage()); + } + return result; + } } diff --git a/ebaystore/webapp/ebaystore/WEB-INF/controller.xml b/ebaystore/webapp/ebaystore/WEB-INF/controller.xml index a67c98ade..557793fcc 100644 --- a/ebaystore/webapp/ebaystore/WEB-INF/controller.xml +++ b/ebaystore/webapp/ebaystore/WEB-INF/controller.xml @@ -187,6 +187,12 @@ + + + + + + diff --git a/ebaystore/widget/EbaySellingManagerForms.xml b/ebaystore/widget/EbaySellingManagerForms.xml index 15fb880fc..89f79f76a 100644 --- a/ebaystore/widget/EbaySellingManagerForms.xml +++ b/ebaystore/widget/EbaySellingManagerForms.xml @@ -358,6 +358,18 @@ value="${bsh:billingAccount != null ? org.ofbiz.accounting.payment.BillingAccoun +
+ + + + + + + + + + +
diff --git a/ebaystore/widget/EbaySellingManagerScreens.xml b/ebaystore/widget/EbaySellingManagerScreens.xml index 5b90e5911..251f4680c 100644 --- a/ebaystore/widget/EbaySellingManagerScreens.xml +++ b/ebaystore/widget/EbaySellingManagerScreens.xml @@ -263,6 +263,9 @@ + + +