Author: hansbak
Date: Thu Mar 4 10:55:48 2010
New Revision: 918929
URL: http://svn.apache.org/viewvc?rev=918929&view=rev
Log:
Ebaystore update: Function to send an automatic notification by email when an
item is shipped.
Modified:
ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml
ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml
ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml
ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml
Modified: ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml Thu Mar
4 10:55:48 2010
@@ -272,4 +272,7 @@
<property key="EbayCombineOrderSetting">
<value xml:lang="en">Combine Orders Setting</value>
</property>
+ <property key="EbayAutoSendItemDispatchEmail">
+ <value xml:lang="en">Automatic send item dispatched notification
email</value>
+ </property>
</resource>
\ No newline at end of file
Modified: ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml Thu Mar 4
10:55:48 2010
@@ -80,9 +80,21 @@
</ElectronicText>
<Content contentId="EBAY_FEEBACK_REMIN" contentTypeId="DOCUMENT"
dataResourceId="EBAY_FEEBACK_REMIN" ownerContentId="EBAY_FEEBACK_REMIN"
statusId="CTNT_IN_PROGRESS"/>
<ContentRole contentId="EBAY_FEEBACK_REMIN" partyId="DemoEbayAccount"
roleTypeId="OWNER" fromDate="2010-01-01 00:00:00.000"/>
-
+
+ <DataResource dataResourceId="EBAY_ITEM_DISPATCH"
dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="FTL"/>
+ <ElectronicText dataResourceId="EBAY_ITEM_DISPATCH">
+ <textData><![CDATA[
+ <span style="color: rgb(255, 51, 0);">
+ Demo : Automatic send item dispatched notification email when
user mark sold listing as dispatched.
+ </span>]]>
+ </textData>
+ </ElectronicText>
+ <Content contentId="EBAY_ITEM_DISPATCH" contentTypeId="DOCUMENT"
dataResourceId="EBAY_ITEM_DISPATCH" ownerContentId="EBAY_ITEM_DISPATCH"
statusId="CTNT_IN_PROGRESS"/>
+ <ContentRole contentId="EBAY_ITEM_DISPATCH" partyId="DemoEbayAccount"
roleTypeId="OWNER" fromDate="2010-01-01 00:00:00.000"/>
+
<ProductStoreEmailSetting productStoreId="90100"
emailType="EBAY_WIN_BUYER_NOTI" bccAddress="[email protected]"
bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#WinnigBuyerNotification"
fromAddress="[email protected]" subject="OFBiz Demo - Winnig Buyer
Notification #${buyerUserId}" xslfoAttachScreenLocation=""/>
<ProductStoreEmailSetting productStoreId="90100"
emailType="EBAY_PAY_RECIEVED" bccAddress="[email protected]"
bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#PaymentRecieved"
fromAddress="[email protected]" subject="OFBiz Demo - PaymentRecieved
#${buyerUserId}" xslfoAttachScreenLocation=""/>
<ProductStoreEmailSetting productStoreId="90100"
emailType="EBAY_FEEBACK_REMIN" bccAddress="[email protected]"
bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#FeedbackReminder"
fromAddress="[email protected]" subject="OFBiz Demo - Feedback Reminder
#${buyerUserId}" xslfoAttachScreenLocation=""/>
-
+ <ProductStoreEmailSetting productStoreId="90100"
emailType="EBAY_ITEM_DISPATCH" bccAddress="[email protected]"
bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#EbayEmailTemplate"
fromAddress="[email protected]" subject="OFBiz Demo - Item Dispatched
Notification #${buyerUserId}" xslfoAttachScreenLocation=""/>
+
</entity-engine-xml>
Modified: ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml Thu Mar 4
10:55:48 2010
@@ -40,10 +40,12 @@
<Enumeration enumId="EBAY_WIN_BUYER_NOTI" description="Automatically
send a Winning Buyer Notification email to your winning buyer(s) after item has
sold." enumTypeId="PRDS_EMAIL"/>
<Enumeration enumId="EBAY_PAY_RECIEVED" description="Automatically send
Payment Received email when payment has been received."
enumTypeId="PRDS_EMAIL"/>
<Enumeration enumId="EBAY_FEEBACK_REMIN" description="Automatically
send a Feedback Reminder email if feedback has not been received. Please choose
how many days after shipping you want this email sent."
enumTypeId="PRDS_EMAIL"/>
- <!-- Content main for specify Enumeration -->
+ <Enumeration enumId="EBAY_ITEM_DISPATCH" description="Automatic send item
dispatched notification email when user mark sold listing as dispatched"
enumTypeId="PRDS_EMAIL"/>
+ <!-- Content main for specify Enumeration -->
<Content contentId="EBAY_WIN_BUYER_NOTI" contentTypeId="TEMPLATE"
description="Automatically send a Winning Buyer Notification email to your
winning buyer(s) after item has sold."/>
<Content contentId="EBAY_PAY_RECIEVED" contentTypeId="TEMPLATE"
description="Automatically send Payment Received email when payment has been
received."/>
<Content contentId="EBAY_FEEBACK_REMIN" contentTypeId="TEMPLATE"
description="Automatically send a Feedback Reminder email if feedback has not
been received. Please choose how many days after shipping you want this email
sent"/>
-
+ <Content contentId="EBAY_ITEM_DISPATCH" contentTypeId="TEMPLATE"
description="Automatic send item dispatched notification email when user mark
sold listing as dispatched"/>
+
<ProductType productTypeId="EBAY_ITEM" description="Product From eBay"/>
</entity-engine-xml>
Modified:
ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml
(original)
+++
ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml
Thu Mar 4 10:55:48 2010
@@ -197,6 +197,47 @@
<field-to-request field="parameters.productStoreId"
request-name="productStoreId"/>
</simple-method>
+ <simple-method method-name="settingSendItemDispatchedNotification"
login-required="false" short-description="Set Automatic send item dispatched
email">
+ <entity-one entity-name="ProductStore" value-field="productStore" >
+ <field-map field-name="productStoreId"
from-field="parameters.productStoreId"/>
+ </entity-one>
+ <if-empty field="productStore">
+ <add-error><fail-message message="No ProductStore found with id
${parameters.productStoreId}."/></add-error>
+ <check-errors/>
+ </if-empty>
+
+ <entity-one entity-name="EbayProductStorePref"
value-field="ebayProdStorePref">
+ <field-map field-name="productStoreId"
from-field="parameters.productStoreId"/>
+ <field-map field-name="autoPrefEnumId"
value="EBAY_AUTO_ITEM_DISP"/>
+ </entity-one>
+
+ <if-not-empty field="ebayProdStorePref">
+ <set field="parameters.productStoreId" type="String"
default-value="parameters.productStoreId"
from-field="ebayProdStorePref.productStoreId"/>
+ <else>
+ <set field="parameters.productStoreId" type="String"
from-field="parameters.productStoreId"/>
+ </else>
+ </if-not-empty>
+ <set field="parameters.autoPrefEnumId" type="String"
value="EBAY_AUTO_ITEM_DISP"/>
+ <if-not-empty field="ebayProdStorePref">
+ <if-not-empty field="ebayProdStorePref.autoPrefJobId">
+ <set field="parameters.autoPrefJobId" type="String"
from-field="ebayProdStorePref.autoPrefJobId"/>
+ </if-not-empty>
+ </if-not-empty>
+ <set field="parameters.enabled" default-value="N" type="String"
from-field="parameters.isRunItemDispatchNotify"/>
+ <set field="parameters.serviceName"
default-value="autoSendItemDispatchedNotification" type="String"/>
+ <session-to-field field="context.userLogin" session-name="userLogin"/>
+
+ <if-empty field="ebayProdStorePref">
+ <set-service-fields service-name="createEbayProductStorePref"
map="parameters" to-map="ebayProductStorePref"/>
+ <call-service service-name="createEbayProductStorePref"
in-map-name="ebayProductStorePref" ></call-service>
+ <else>
+ <set-service-fields service-name="updateEbayProductStorePref"
map="parameters" to-map="ebayProductStorePref"/>
+ <call-service service-name="updateEbayProductStorePref"
in-map-name="ebayProductStorePref"></call-service>
+ </else>
+ </if-empty>
+ <field-to-request field="parameters.productStoreId"
request-name="productStoreId"/>
+ </simple-method>
+
<simple-method method-name="createEmailTemplate" short-description="Create
Email Template">
<!-- create content -->
<set field="parameters.dataTemplateTypeId" value="FTL"/>
Modified: ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml Thu Mar 4
10:55:48 2010
@@ -378,4 +378,10 @@
<attribute name="jobId" mode="IN" type="String" optional="false"/>
<attribute name="productStoreId" mode="IN" type="String"
optional="false"/>
</service>
+ <service name="autoSendItemDispatchedNotification" engine="java"
transaction-timeout="7200"
+ location="org.ofbiz.ebaystore.EbayStoreAutoPreferences"
invoke="autoSendItemDispatchedNotification" auth="false">
+ <description>Automatic service to send item dispatched notification
email when user mark sold listing as dispatched</description>
+ <attribute name="jobId" mode="IN" type="String" optional="false"/>
+ <attribute name="productStoreId" mode="IN" type="String"
optional="false"/>
+ </service>
</services>
\ No newline at end of file
Modified:
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
(original)
+++
ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
Thu Mar 4 10:55:48 2010
@@ -967,4 +967,63 @@
}
return result;
}
+
+ public static Map<String, Object>
autoSendItemDispatchedNotification(DispatchContext dctx, Map<String, 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");
+
+ try {
+ Map<String, Object> resultSold =
dispatcher.runSync("getEbaySoldItems", context);
+ List soldItems = (List) resultSold.get("soldItems");
+ if (soldItems.size() != 0) {
+ for (int i = 0; i < soldItems.size(); i++) {
+ Map<String, Object> item = (Map<String, Object>)
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<String, Object> 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<String, Object> 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;
+ }
}
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=918929&r1=918928&r2=918929&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
(original)
+++
ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml
Thu Mar 4 10:55:48 2010
@@ -187,6 +187,12 @@
<response name="success" type="request-redirect"
value="automationPreferences"/>
<response name="error" type="view" value="AutomationPreferences"/>
</request-map>
+ <request-map uri="settingSendItemDispatchedNotification">
+ <security https="true" auth="true"/>
+ <event type="simple"
path="component://ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml"
invoke="settingSendItemDispatchedNotification"/>
+ <response name="success" type="request-redirect"
value="automationPreferences"/>
+ <response name="error" type="view" value="AutomationPreferences"/>
+ </request-map>
<!-- Block item out of stock -->
<request-map uri="blockItemOutOfStock">
<security https="true" auth="true"/>
Modified:
ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
(original)
+++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml Thu
Mar 4 10:55:48 2010
@@ -358,6 +358,18 @@
<field name="isRunWinnerNotify" position="1" title="Enable send winner
buyer notification automatically"><check></check></field>
<field name="submitButton" title="${uiLabelMap.CommonSave}"><submit
button-type="button"/></field>
</form>
+ <form name="itemDispatchedNotification" type="single"
target="settingSendItemDispatchedNotification" header-row-style="header-row"
default-table-style="basic-table">
+ <actions>
+ <entity-one entity-name="EbayProductStorePref"
value-field="ebayPrefCombine">
+ <field-map field-name="productStoreId"
from-field="parameters.productStoreId"/>
+ <field-map field-name="autoPrefEnumId"
value="EBAY_AUTO_ITEM_DISP"/>
+ </entity-one>
+ <set field="isRunItemDispatchNotify" type="String"
from-field="ebayPrefCombine.enabled"/>
+ </actions>
+ <field name="productStoreId"><hidden
value="${parameters.productStoreId}"/></field>
+ <field name="isRunItemDispatchNotify" position="1" title="Enable send
item dispatched email"><check></check></field>
+ <field name="submitButton" title="${uiLabelMap.CommonSave}"><submit
button-type="button"/></field>
+ </form>
<form name="EditEmailTemplate" type="single" target="createEmailTemplate"
header-row-style="header-row" default-table-style="basic-table">
<actions>
Modified:
ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml?rev=918929&r1=918928&r2=918929&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml
(original)
+++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml
Thu Mar 4 10:55:48 2010
@@ -263,6 +263,9 @@
<screenlet
title="${uiLabelMap.EbayAutoSendWinBuyerEmail}" id="winningBuyerNotification"
collapsible="true" initially-collapsed="true">
<include-form name="winningBuyerNotification"
location="component://ebaystore/widget/EbaySellingManagerForms.xml"/>
</screenlet>
+ <screenlet
title="${uiLabelMap.EbayAutoSendItemDispatchEmail}"
id="itemDispatchedNotification" collapsible="true" initially-collapsed="true">
+ <include-form name="itemDispatchedNotification"
location="component://ebaystore/widget/EbaySellingManagerForms.xml"/>
+ </screenlet>
</decorator-section>
</decorator-screen>
</widgets>