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
This commit is contained in:
@@ -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>
|
||||
@@ -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="ofbiztest@yahoo.com" bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#WinnigBuyerNotification" fromAddress="ofbiztest@yahoo.com" subject="OFBiz Demo - Winnig Buyer Notification #${buyerUserId}" xslfoAttachScreenLocation=""/>
|
||||
<ProductStoreEmailSetting productStoreId="90100" emailType="EBAY_PAY_RECIEVED" bccAddress="ofbiztest@yahoo.com" bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#PaymentRecieved" fromAddress="ofbiztest@yahoo.com" subject="OFBiz Demo - PaymentRecieved #${buyerUserId}" xslfoAttachScreenLocation=""/>
|
||||
<ProductStoreEmailSetting productStoreId="90100" emailType="EBAY_FEEBACK_REMIN" bccAddress="ofbiztest@yahoo.com" bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#FeedbackReminder" fromAddress="ofbiztest@yahoo.com" subject="OFBiz Demo - Feedback Reminder #${buyerUserId}" xslfoAttachScreenLocation=""/>
|
||||
|
||||
<ProductStoreEmailSetting productStoreId="90100" emailType="EBAY_ITEM_DISPATCH" bccAddress="ofbiztest@yahoo.com" bodyScreenLocation="component://ebaystore/widget/EbayEmailScreens.xml#EbayEmailTemplate" fromAddress="ofbiztest@yahoo.com" subject="OFBiz Demo - Item Dispatched Notification #${buyerUserId}" xslfoAttachScreenLocation=""/>
|
||||
|
||||
</entity-engine-xml>
|
||||
|
||||
@@ -40,10 +40,12 @@ under the License.
|
||||
<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>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -378,4 +378,10 @@ under the License.
|
||||
<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>
|
||||
@@ -967,4 +967,63 @@ public class EbayStoreAutoPreferences {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -358,6 +358,18 @@ value="${bsh:billingAccount != null ? org.ofbiz.accounting.payment.BillingAccoun
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user