(OFBIZ-10370)
Currently promotion rule engine works with :
entities ProductPromoCond et ProductPromoAction
java linear function ProductPromoWorker.checkCondition() (ProductPromoWorker:910) and ProductPromoWorker.performAction (ProductPromoWorker:1423)
Enumeration list to indicate on java function what piece of code to activate the control or action
The problem with this structure is when you want to create a new case of condition or action, you need to modify the framework code base.
We convert the 2 big java leaner function to service representation with one service by case. To realize it we introduce a relation with CustomMethod :
ProductPromoRule --> ProductPromoCond -> CustomMethod
-> ProductPromoAction -> CustomMethod
Each functions's case are converted to service with a related CustomMethod.
With this pattern now you can write your own condition rule and action rule on your plugin and link it on the promo engine
For backward compatibility purpose, current "PPIP" enumeration entries receive in enumCode data the new corresponding customMethodId reference, to ensure that old data works fine with the new engine
on EntityData
<CustomMethod customMethodId="PPC_PRODUCT_AMOUNT" customMethodTypeId="PRODUCT_PROMO_COND" customMethodName="productPromoCondProductAmount" description="Product amount"/>
<Enumeration enumId="PPIP_PRODUCT_AMOUNT" enumCode="PPC_PRODUCT_AMOUNT"/><!--link enumeration with customMethod for backward compatibility-->
on Java
//for backward compatibility resolve customMethodId from enumCode
GenericValue condEnum = EntityQuery.use(delegator).from("Enumeration").where("enumId", inputParamEnumId).cache().queryOne();
if (condEnum != null) {
customMethod = EntityQuery.use(delegator).from("CustomMethod").where("customMethodId", condEnum.get("enumCode")).cache().queryOne();
if (customMethod == null) {
Debug.logWarning("The oldest enumeration " + inputParamEnumId + " for promo " + productPromoCond.getPkShortValueString() + " haven't the new customMethod to use, please check your data or load seed data", module);
return false;
}
serviceName = customMethod.getString("customMethodName");
}
Many thanks to Ziri Khalifa and Leila Mekika for their helping work
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1831783 13f79535-47bb-0310-9956-ffa450edef68
176 lines
11 KiB
XML
176 lines
11 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
|
|
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd">
|
|
<description>Order (ShoppingCart) Services</description>
|
|
<vendor>OFBiz</vendor>
|
|
<version>1.0</version>
|
|
|
|
<service name="assignItemShipGroup" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="assignItemShipGroup">
|
|
<description>Assign a ShoppingCartItem -> Quantity to a ship group</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="fromGroupIndex" type="Integer" mode="IN" optional="false"/>
|
|
<attribute name="toGroupIndex" type="Integer" mode="IN" optional="false"/>
|
|
<attribute name="itemIndex" type="Integer" mode="IN" optional="false"/>
|
|
<attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/>
|
|
<attribute name="clearEmptyGroups" type="Boolean" mode="IN" optional="true"/>
|
|
</service>
|
|
|
|
<service name="setCartShippingOptions" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="setShippingOptions">
|
|
<description>Sets The ShoppingCart Shipping Options</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="groupIndex" type="Integer" mode="IN" optional="false"/>
|
|
<attribute name="shippingContactMechId" type="String" mode="IN" optional="false">
|
|
<type-validate>
|
|
<fail-property resource="OrderUiLabels" property="checkhelper.select_shipping_destination"/>
|
|
</type-validate>
|
|
</attribute>
|
|
<attribute name="shipmentMethodString" type="String" mode="IN" optional="false">
|
|
<type-validate>
|
|
<fail-property resource="OrderUiLabels" property="checkhelper.select_shipping_method"/>
|
|
</type-validate>
|
|
</attribute>
|
|
<attribute name="shippingInstructions" type="String" mode="IN" optional="true"/>
|
|
<attribute name="maySplit" type="Boolean" mode="IN" optional="false">
|
|
<type-validate>
|
|
<fail-property resource="OrderUiLabels" property="checkhelper.select_splitting_preference"/>
|
|
</type-validate>
|
|
</attribute>
|
|
<attribute name="isGift" type="Boolean" mode="IN" optional="false">
|
|
<type-validate>
|
|
<fail-property resource="OrderUiLabels" property="checkhelper.specify_if_order_is_gift"/>
|
|
</type-validate>
|
|
</attribute>
|
|
<attribute name="giftMessage" type="String" mode="IN" optional="true"/>
|
|
</service>
|
|
|
|
<service name="setCartShippingAddress" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="setShippingOptions">
|
|
<description>Sets The ShoppingCart Shipping Options</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="groupIndex" type="Integer" mode="IN" optional="false"/>
|
|
<attribute name="shippingContactMechId" type="String" mode="IN" optional="false">
|
|
<type-validate>
|
|
<fail-property resource="OrderUiLabels" property="checkhelper.select_shipping_destination"/>
|
|
</type-validate>
|
|
</attribute>
|
|
</service>
|
|
|
|
<service name="setCartPaymentOptions" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="setPaymentOptions">
|
|
<description>Sets the ShoppingCart Payment Options</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="paymentInfoId" type="String" mode="IN" optional="false"/>
|
|
<attribute name="amount" type="BigDecimal" mode="IN" optional="true"/>
|
|
<attribute name="refNum" type="String" mode="IN" optional="true"/>
|
|
</service>
|
|
|
|
<service name="setCartOtherOptions" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="setOtherOptions">
|
|
<description>Sets the ShoppingCart Other Options (besided payment and shipping)</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="orderAdditionalEmails" type="String" mode="IN" optional="true"/>
|
|
<attribute name="correspondingPoId" type="String" mode="IN" optional="true"/>
|
|
</service>
|
|
|
|
<service name="loadCartFromOrder" engine="java" auth="true"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="loadCartFromOrder">
|
|
<description>Create a ShoppingCart Object based on an existing order</description>
|
|
<attribute name="orderId" type="String" mode="IN" optional="false"/>
|
|
<attribute name="createAsNewOrder" type="String" mode="IN" default-value="N"/>
|
|
<attribute name="skipInventoryChecks" type="Boolean" mode="IN" optional="true"/>
|
|
<attribute name="skipProductChecks" type="Boolean" mode="IN" optional="true"/>
|
|
<attribute name="includePromoItems" type="Boolean" mode="IN" optional="true"/>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="OUT" optional="false"/>
|
|
</service>
|
|
|
|
<service name="loadCartFromQuote" engine="java" auth="true"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="loadCartFromQuote">
|
|
<description>Create a ShoppingCart Object based on an existing quote. If applyQuoteAdjustments is set to false then standard cart adjustments are generated.</description>
|
|
<attribute name="quoteId" type="String" mode="IN" optional="false"/>
|
|
<attribute name="applyQuoteAdjustments" type="String" mode="IN" optional="true"/>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="OUT" optional="false"/>
|
|
</service>
|
|
<service name="loadCartFromShoppingList" engine="java" auth="true"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="loadCartFromShoppingList">
|
|
<description>Create a ShoppingCart Object based on an existing shopping list.</description>
|
|
<attribute name="shoppingListId" type="String" mode="IN" optional="false"/>
|
|
<attribute name="applyStorePromotions" type="String" mode="IN" optional="true"/>
|
|
<attribute name="orderPartyId" type="String" mode="IN" optional="true"/>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="OUT" optional="false"/>
|
|
</service>
|
|
|
|
<service name="getShoppingCartData" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="getShoppingCartData">
|
|
<description>Get the ShoppingCart data</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="totalQuantity" type="BigDecimal" mode="OUT" optional="true"/>
|
|
<attribute name="currencyIsoCode" type="String" mode="OUT" optional="true"/>
|
|
<attribute name="subTotal" type="BigDecimal" mode="OUT" optional="true"/>
|
|
<attribute name="subTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/>
|
|
<attribute name="totalShipping" type="BigDecimal" mode="OUT" optional="true"/>
|
|
<attribute name="totalShippingCurrencyFormatted" type="String" mode="OUT" optional="true"/>
|
|
<attribute name="totalSalesTax" type="BigDecimal" mode="OUT" optional="true"/>
|
|
<attribute name="totalSalesTaxCurrencyFormatted" type="String" mode="OUT" optional="true"/>
|
|
<attribute name="displayGrandTotal" type="BigDecimal" mode="OUT" optional="true"/>
|
|
<attribute name="displayGrandTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/>
|
|
<attribute name="cartItemData" type="Map" mode="OUT"/>
|
|
<attribute name="displayOrderAdjustmentsTotalCurrencyFormatted" type="String" mode="OUT" optional="true"/>
|
|
</service>
|
|
|
|
<service name="getShoppingCartItemIndex" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="getShoppingCartItemIndex">
|
|
<description>Get the ShoppingCart info from the productId</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
<attribute name="productId" type="String" mode="IN" optional="false"/>
|
|
<attribute name="itemIndex" type="String" mode="OUT" optional="true"/>
|
|
</service>
|
|
|
|
<service name="resetShipGroupItems" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="resetShipGroupItems">
|
|
<description>Reset the ship Groups in the cart and put the items in default group</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
</service>
|
|
|
|
<service name="prepareVendorShipGroups" engine="java" auth="false"
|
|
location="org.apache.ofbiz.order.shoppingcart.ShoppingCartServices" invoke="prepareVendorShipGroups">
|
|
<description>Split the default shipgroup to individual shipgroups that are unique to a vendor</description>
|
|
<attribute name="shoppingCart" type="org.apache.ofbiz.order.shoppingcart.ShoppingCart" mode="IN" optional="false"/>
|
|
</service>
|
|
|
|
<service name="createCartAbandonedLine" default-entity-name="CartAbandonedLine" engine="entity-auto" invoke="create" auth="true">
|
|
<description>Create CartAbandonedLine record</description>
|
|
<auto-attributes include="pk" mode="IN"/>
|
|
<auto-attributes include="nonpk" mode="IN" optional="true"/>
|
|
</service>
|
|
<service name="updateCartAbandonedLine" default-entity-name="CartAbandonedLine" engine="entity-auto" invoke="update" auth="true">
|
|
<description>Update CartAbandonedLine record</description>
|
|
<auto-attributes include="pk" mode="IN"/>
|
|
<auto-attributes include="nonpk" mode="IN" optional="true"/>
|
|
</service>
|
|
<service name="deleteCartAbandonedLine" default-entity-name="CartAbandonedLine" engine="entity-auto" invoke="delete" auth="true">
|
|
<description>Delete CartAbandonedLine record</description>
|
|
<auto-attributes include="pk" mode="IN"/>
|
|
</service>
|
|
</services>
|