Author: hansbak
Date: Fri Feb 26 07:12:37 2010 New Revision: 916591 URL: http://svn.apache.org/viewvc?rev=916591&view=rev Log: EBay store update: function to automatically send a Feedback Reminder email from ofbiz to the ebaybuyer if a feedback has not been received.(after shipping to the seller) Modified: 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/data/EbayStoreTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml?rev=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml Fri Feb 26 07:12:37 2010 @@ -31,5 +31,6 @@ <Enumeration enumId="EBAY_AUTO_DISPUTE2" description="Automatic Dispute not pay" enumTypeId="EBAY_AUTO_PREF"/> <Enumeration enumId="EBAY_AUTO_RELISTING" description="Automatic Relisting" enumTypeId="EBAY_AUTO_PREF"/> <Enumeration enumId="EBAY_AUTO_PIT_FB" description="Automatic leave positive feedback when buyer has paid for item" enumTypeId="EBAY_AUTO_PREF"/> + <Enumeration enumId="EBAY_AUTO_FB_RMD" description="Automatic send reminder email if feedback has not been received after day? shipping" enumTypeId="EBAY_AUTO_PREF"/> </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=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml Fri Feb 26 07:12:37 2010 @@ -23,5 +23,50 @@ <simple-method method-name="checkEbayAction" short-description="Check eBay Action"> <set field="resultResponse" from-field="parameters.action"/> <return response-code="${resultResponse}"/> - </simple-method> + </simple-method> + <!-- start automatically service send a Feedback Reminder email if feedback has not been received. and check how many days after shipping you want this email sent? --> + <simple-method method-name="autoSendFeedbackReminder" login-required="false" short-description="Automatically send a Feedback Reminder email if feedback has not been received"> + <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_FB_RMD"/> + </entity-one> + <!-- map field from screen --> + <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_FB_RMD"/> + <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.isAutoFeedbackReminder"/> + <set field="parameters.condition1" type="Integer" default-value="5" from-field="parameters.afterDays"/> + <set field="parameters.condition2" default-value="N" type="String" from-field="parameters.isSendCopyEmailToSeller"/> + <if-compare field="parameters.enabled" value="N" type="String" operator="equals"> + <set field="parameters.condition2" value="N" type="String" /> + </if-compare> + <set field="parameters.serviceName" default-value="autoSendFeedbackReminderEmail" type="String"/> + <session-to-field field="context.userLogin" session-name="userLogin"/> + <!-- create new automatically store preferences --> + <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> + </simple-method> + </simple-methods> \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml?rev=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml Fri Feb 26 07:12:37 2010 @@ -353,4 +353,8 @@ location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="autoPrefLeaveFeedbackOption" auth="true"> <attribute name="productStoreId" mode="IN" type="String" optional="false"/> </service> + <service name="autoSendFeedbackReminderEmail" engine="java" transaction-timeout="10800" + location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="autoSendFeedbackReminderEmail" auth="true"> + <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=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java (original) +++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java Fri Feb 26 07:12:37 2010 @@ -18,6 +18,8 @@ */ package org.ofbiz.ebaystore; +import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Locale; @@ -31,6 +33,7 @@ import javolution.util.FastList; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; @@ -53,6 +56,8 @@ import com.ebay.soap.eBLBaseComponents.FeedbackDetailType; import com.ebay.soap.eBLBaseComponents.SellingManagerOrderStatusType; import com.ebay.soap.eBLBaseComponents.SellingManagerPaidStatusCodeType; +import com.ebay.soap.eBLBaseComponents.SellingManagerShippedStatusCodeType; +import com.ebay.soap.eBLBaseComponents.SellingManagerSoldListingsSortTypeCodeType; import com.ebay.soap.eBLBaseComponents.SellingManagerSoldOrderType; import com.ebay.soap.eBLBaseComponents.SellingManagerSoldTransactionType; @@ -228,4 +233,80 @@ return "success"; } + + /* start automatically service send a Feedback Reminder email if feedback has not been received. and check how many days after shipping you want this email sent? */ + public static Map<String, Object> autoSendFeedbackReminderEmail(DispatchContext dctx, Map<String, ? extends Object> context) throws ApiException, SdkException, Exception{ + Delegator delegator = dctx.getDelegator(); + Locale locale = (Locale) context.get("locale"); + + if (UtilValidate.isEmpty(context.get("productStoreId"))){ + return ServiceUtil.returnFailure("Required productStoreId for get api context to connect with ebay site."); + } + + String productStoreId = (String) context.get("productStoreId"); + String isAutoFeedbackReminder = "N"; + int afterDays = 0; + String isAlsoSendCopyToSeller = "N"; + GenericValue ebayProductStorePref = null; + List<String> list = FastList.newInstance(); + String dateTimeFormat = UtilDateTime.DATE_TIME_FORMAT; + SimpleDateFormat formatter = new SimpleDateFormat(dateTimeFormat); + + try { + ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator); + ebayProductStorePref = delegator.findByPrimaryKey("EbayProductStorePref", UtilMisc.toMap("productStoreId", productStoreId,"autoPrefEnumId","EBAY_AUTO_FB_RMD")); + if (UtilValidate.isNotEmpty(ebayProductStorePref)) { + isAutoFeedbackReminder = ebayProductStorePref.getString("enabled"); + // if isAutoPositiveFeedback is N that means not start this job run service + if ("Y".equals(isAutoFeedbackReminder)) { + afterDays = Integer.parseInt(ebayProductStorePref.getString("condition1")); + isAlsoSendCopyToSeller = ebayProductStorePref.getString("condition2"); + + // start getting sold item list from ebay follow your site + GetSellingManagerSoldListingsCall sellingManagerSoldListings = new GetSellingManagerSoldListingsCall(apiContext); + List<SellingManagerSoldOrderType> items = FastList.newInstance(); + SellingManagerSoldOrderType[] sellingManagerSoldOrders = sellingManagerSoldListings.getSellingManagerSoldListings(); + if (UtilValidate.isNotEmpty(sellingManagerSoldOrders)) { + for(SellingManagerSoldOrderType solditem :sellingManagerSoldOrders){ + SellingManagerOrderStatusType orderStatus = solditem.getOrderStatus(); + if (orderStatus != null && !orderStatus.isFeedbackSent()) { + SellingManagerPaidStatusCodeType paidStatus = orderStatus.getPaidStatus(); + CommentTypeCodeType commentType = orderStatus.getFeedbackReceived(); + SellingManagerShippedStatusCodeType shippedStatus = orderStatus.getShippedStatus(); + + //Buyer has paid for this item. && Seller shipped items but feedback has not been received from buyer more than days condition + if (SellingManagerPaidStatusCodeType.PAID.equals(paidStatus) && SellingManagerShippedStatusCodeType.SHIPPED.equals(shippedStatus)) { + Calendar right_now = Calendar.getInstance(); + Calendar shippedTime = orderStatus.getShippedTime(); + Calendar afterShippedTime = orderStatus.getShippedTime(); + afterShippedTime.add(afterShippedTime.DAY_OF_MONTH, afterDays); + Debug.logInfo("Verify date for send reminder feedback eamil by auto service: buyer "+solditem.getBuyerID()+" seller shippedTime " + + ""+formatter.format(shippedTime)+" codition days "+afterDays+" after shippedTime :"+formatter.format(afterShippedTime)+" now date"+formatter.format(right_now), module); + // if now date is after shipped time follow after days condition would be send reminder email to buyer + if (right_now.after(afterShippedTime)) items.add(solditem); + } + } + } + + // call service send email (get template follow productStoreId) + GetUserCall getUserCall = new GetUserCall(apiContext); + String sellerUser = getUserCall.getUser().getUserID(); + for(SellingManagerSoldOrderType item :items){ + // start leave feedbacks + SellingManagerSoldTransactionType[] soldTrans = item.getSellingManagerSoldTransaction(); + if (UtilValidate.isNotEmpty(soldTrans)) { + for(SellingManagerSoldTransactionType soldTran : soldTrans){ + // call send + } + } + } + } + } + } + }catch (Exception e) { + return ServiceUtil.returnFailure("Problems to connect with ebay site message:"+e); + } + + return ServiceUtil.returnSuccess(); + } } 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=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/controller.xml Fri Feb 26 07:12:37 2010 @@ -143,6 +143,12 @@ <response name="success" type="view" value="AutomationPreferences"/> <response name="error" type="view" value="AutomationPreferences"/> </request-map> + <request-map uri="autoSendFeedbackReminder"> + <security auth="true" https="true"/> + <event type="simple" path="component://ebaystore/script/org/ofbiz/ebaystore/EbayStoreEvents.xml" invoke="autoSendFeedbackReminder"/> + <response name="success" type="view" 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=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml Fri Feb 26 07:12:37 2010 @@ -289,5 +289,28 @@ <field name="comment_4" title=" " position="1"><text size="80"></text></field> <field name="submitButton" title="${uiLabelMap.CommonApply}"><submit button-type="button"/></field> </form> + <!-- Automatically send a Feedback Reminder email if feedback has not been received. Please choose how many days after shipping you want this email sent? --> + <form name="autoSendFeedbackReminder" type="single" target="autoSendFeedbackReminder" + header-row-style="header-row" default-table-style="basic-table"> + <actions> + <entity-one entity-name="EbayProductStorePref" value-field="ebayProductStorePref"> + <field-map field-name="productStoreId" from-field="parameters.productStoreId"/> + <field-map field-name="autoPrefEnumId" value="EBAY_AUTO_FB_RMD"/> + </entity-one> + <set field="isAutoFeedbackReminder" type="String" from-field="ebayProductStorePref.enabled"/> + <set field="afterDays" type="String" from-field="ebayProductStorePref.condition1"/> + <set field="isSendCopyEmailToSeller" type="String" from-field="ebayProductStorePref.condition2"/> + </actions> + <field name="productStoreId"><hidden value="${parameters.productStoreId}"/></field> + <field name="isAutoFeedbackReminder" tooltip="${uiLabelMap.EbayIsAutoFeedbackReminderTooltip}" position="1" title="${uiLabelMap.EbayIsAutoFeedbackReminder}"><check></check></field> + <field name="afterDays" title="${uiLabelMap.EbayAfter}" position="1" tooltip="${uiLabelMap.CommonDays} ${uiLabelMap.EbayIsSendCopyEmailTooltip}" ><text default-value="5" size="5" maxlength="2"></text></field> + <field name="isSendCopyEmailToSeller" position="1" title="${uiLabelMap.EbayIsSendCopyEmailToSeller}"><check></check></field> + <field name="emailTemplate" title="Email" tooltip="Edit Feedback Reminder email template"> + <hyperlink target="#" description="Edit Email Template"> + <parameter param-name="productStoreId" from-field="parameters.productStoreId"/> + </hyperlink> + </field> + <field name="submitButton" title="${uiLabelMap.CommonApply}"><submit button-type="button"/></field> + </form> </forms> \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml?rev=916591&r1=916590&r2=916591&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml Fri Feb 26 07:12:37 2010 @@ -252,6 +252,9 @@ <screenlet title="${uiLabelMap.EbayTxtAutoPositiveFeedbackBuyer}" id="autoPositiveFeedback" collapsible="false" initially-collapsed="true"> <include-form name="autoPositiveFeedbackForBuyers" location="component://ebaystore/widget/EbaySellingManagerForms.xml"/> </screenlet> + <screenlet title="${uiLabelMap.EbayIsAutoFeedbackReminder}" id="autoSendFeedbackReminder" collapsible="false" initially-collapsed="true"> + <include-form name="autoSendFeedbackReminder" location="component://ebaystore/widget/EbaySellingManagerForms.xml"/> + </screenlet> </decorator-section> </decorator-screen> </widgets> |
Free forum by Nabble | Edit this page |