Ebaystore component update:

- update code and format in java file
- function update status of product(active,sold,unsold) from ebay inventory
- function and screen for cancel  quantities that reservation


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@906373 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hans Bakker
2010-02-04 06:01:06 +00:00
parent 5793183ff1
commit bbcd2194d4
9 changed files with 417 additions and 362 deletions
+3
View File
@@ -183,4 +183,7 @@
<property key="EbayUpdateInventory">
<value xml:lang="en">Update To Ebay Inventory</value>
</property>
<property key="EbayUpdateInventoryStatus">
<value xml:lang="en">Update Inventory Status</value>
</property>
</resource>
+1
View File
@@ -23,6 +23,7 @@ under the License.
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<classpath type="dir" location="config"/>
<classpath type="jar" location="lib/*"/>
<classpath type="jar" location="build/lib/*"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
@@ -43,8 +43,8 @@
</simple-method>
<!-- Store Inventory Services -->
<simple-method method-name="reserveEbayStoreInventory" short-description="Reserve ofbiz Store product Inventory">
<!-- ebay Store Inventory Services -->
<simple-method method-name="reserveEbayProductInventory" short-description="Reserve product from ofbiz Store Inventory">
<entity-one entity-name="Product" value-field="product" use-cache="true"/>
<entity-one entity-name="ProductStore" value-field="productStore" >
<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
@@ -62,7 +62,13 @@
<return response-code="success"/>
</if-compare>
<call-simple-method method-name="isStoreInventoryRequiredInline"/>
<set from-field="product.requireInventory" field="requireInventory"/>
<if-empty field="requireInventory">
<set from-field="productStore.requireInventory" field="requireInventory"/>
</if-empty>
<if-empty field="requireInventory">
<set value="Y" field="requireInventory"/>
</if-empty>
<set from-field="parameters.facilityId" field="facilityId"/>
<if-not-empty field="facilityId">
@@ -94,11 +100,13 @@
<set from-field="facilityId" field="callServiceMap.facilityId"/>
<set from-field="requireInventory" field="callServiceMap.requireInventory"/>
<set from-field="productStore.reserveOrderEnumId" field="callServiceMap.reserveOrderEnumId"/>
<set value="EBAY_INV_RES" field="callServiceMap.reserveReasonEnumId"/>
<call-service service-name="reserveEbayProductInventoryByStoreFacility" in-map-name="callServiceMap">
<results-to-map map-name="resultMap"/>
<result-to-field result-name="quantityNotReserved" field="qtyNotReserve"/>
<result-to-field result-name="successMessage" field="returnSuccessMessage"/>
</call-service>
<set field="defaultReserve" default-value="0"/>
<!-- if quantityNotReserved greater than 0 then ATP in ofbiz stock not have, it should be return message or log warring-->
<if-compare-field field="qtyNotReserve" operator="equals" type="BigDecimal" to-field="defaultReserve">
@@ -174,281 +182,145 @@
</else>
</if-empty>
</simple-method>
<simple-method method-name="isStoreInventoryRequiredInline" short-description="Is Store Inventory Required" login-required="false">
<set from-field="product.requireInventory" field="requireInventory"/>
<if-empty field="requireInventory">
<set from-field="productStore.requireInventory" field="requireInventory"/>
<simple-method method-name="updateEbayProductQtyReserved" short-description="Update or cancel an Product which are reserved quantity from inventory">
<entity-one entity-name="EbayProductStoreInventory" value-field="ebayProductStoreInventory">
<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
<field-map field-name="facilityId" from-field="parameters.facilityId"/>
<field-map field-name="productId" from-field="parameters.productId"/>
</entity-one>
<if-empty field="ebayProductStoreInventory">
<add-error><fail-message message="No Product found with id ${parameters.productId}."/></add-error>
<check-errors/>
</if-empty>
<if-empty field="requireInventory">
<set value="Y" field="requireInventory"/>
</if-empty>
</simple-method>
<simple-method method-name="reserveEbayProductInventory" short-description="Reserve Inventory for a Product">
<now-timestamp field="nowTimestamp"/>
<!-- check the product; make sure its a physical item -->
<entity-one entity-name="Product" value-field="product"/>
<entity-one entity-name="Facility" value-field="facility" use-cache="true"/>
<get-related-one value-field="product" relation-name="ProductType" to-value-field="productType"/>
<if-compare field="productType.isPhysical" operator="equals" value="N">
<set field="parameters.quantityNotReserved" value="0" type="BigDecimal"/>
<set field="actionType" from-field="parameters.actionType"/>
<set field="qtyInp" default-value="0" from-field="parameters.quantity"/>
<set field="atpListing" default-value="0" from-field="ebayProductStoreInventory.availableToPromiseListing"/>
<set field="qohReserved" default-value="0" from-field="ebayProductStoreInventory.quantityReserved"/>
<!--check qty input for increase or decrease -->
<!--field-to-result field="parameters.productStoreId" result-name="productStoreId"/>
<field-to-result field="parameters.facilityId" result-name="facilityId"/>
<field-to-result field="parameters.productId" result-name="productId"/-->
<if-compare field="actionType" value="ADD" operator="equals">
<set-service-fields service-name="reserveEbayProductInventory" map="parameters" to-map="reservedEbayProduct"/>
<call-service service-name="reserveEbayProductInventory" in-map-name="reservedEbayProduct"></call-service>
<return/>
<else>
<set value="EBAY_INV_RES" field="parameters.reserveReasonEnumId"/>
<set value="+datetimeReceived" field="orderByString"/>
<set from-field="parameters.quantity" field="parameters.quantityNotReserved"/>
<!-- first reserve against InventoryItems in FLT_PICKLOC type locations, then FLT_BULK locations, then InventoryItems with no locations -->
<entity-condition entity-name="InventoryItemAndLocation" list="inventoryItemAndLocations">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
<condition-expr field-name="locationTypeEnumId" operator="equals" value="FLT_PICKLOC"/>
</condition-list>
<order-by field-name="${orderByString}"/>
</entity-condition>
<iterate entry="inventoryItemAndLocation" list="inventoryItemAndLocations">
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double">
<!-- this is a little trick to get the InventoryItem value object without doing a query, possible since all fields on InventoryItem are also on InventoryItemAndLocation with the same names -->
<make-value entity-name="InventoryItem" map="inventoryItemAndLocation" value-field="inventoryItem"/>
<call-simple-method method-name="reserveForInventoryItemInline"/>
</if-compare>
</iterate>
<!-- still some left? try the FLT_BULK locations -->
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
<entity-condition entity-name="InventoryItemAndLocation" list="inventoryItemAndLocations">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
<condition-expr field-name="locationTypeEnumId" operator="equals" value="FLT_BULK"/>
</condition-list>
<order-by field-name="${orderByString}"/>
</entity-condition>
<iterate entry="inventoryItemAndLocation" list="inventoryItemAndLocations">
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double">
<!-- this is a little trick to get the InventoryItem value object without doing a query, possible since all fields on InventoryItem are also on InventoryItemAndLocation with the same names -->
<make-value entity-name="InventoryItem" map="inventoryItemAndLocation" value-field="inventoryItem"/>
<call-simple-method method-name="reserveForInventoryItemInline"/>
</if-compare>
</iterate>
</if-compare>
<!-- last of all try reserving in InventoryItems that have no locationSeqId, ie are not in any particular location -->
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
<entity-condition entity-name="InventoryItem" list="inventoryItems">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="facilityId" from-field="parameters.facilityId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
<condition-expr field-name="locationSeqId" operator="equals" from-field="nullField"/>
</condition-list>
<order-by field-name="${orderByString}"/>
</entity-condition>
<iterate entry="inventoryItem" list="inventoryItems">
<if>
<condition>
<and>
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="Double"/>
<if-empty field="inventoryItem.locationSeqId"/>
</and>
</condition>
<then>
<call-simple-method method-name="reserveForInventoryItemInline"/>
</then>
</if>
</iterate>
</if-compare>
<!--
if inventory is not required for purchase and quantityNotReserved != 0:
- subtract the remaining quantityNotReserved from the availableToPromise of the last non-serialized inventory item
- or if none was found create a non-ser InventoryItem with availableToPromise = -quantityNotReserved
-->
<if-compare field="parameters.quantityNotReserved" operator="not-equals" value="0" type="BigDecimal">
<if-compare field="parameters.requireInventory" operator="equals" value="Y">
<!-- use this else pattern to accomplish the anything but Y logic, ie if not specified default to inventory NOT required -->
<!-- calculate for qty is used to create listing already, can not remove that qty until list is end or cancel listing-->
<calculate field="qtyToUsed" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="qohReserved"/>
<calcop operator="negative" field="atpListing"/>
</calcop>
</calculate>
<calculate field="qtyCanRemv" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="qohReserved"/>
<calcop operator="negative" field="qtyToUsed"/>
</calcop>
</calculate>
<if-compare field="qtyCanRemv" operator="greater" value="0">
<!-- auto remove only real qtys that we can remove then return quantity are remove to stock follow productStore, facility and productId -->
<set field="qtyToRemove" type="BigDecimal" default-value="0" value="${qtyInp}"/>
<if-compare field="qtyCanRemv" value="${qtyToRemove}" operator="greater-equals">
<call-simple-method method-name="removeEbayProductQtyReserved"/>
<log level="info" message="(${qtyToRemove}) product quantity was cancel from inventory with this transaction"></log>
<else>
<if-not-empty field="lastNonSerInventoryItem">
<!-- subtract from quantityNotReserved from the availableToPromise of existing inventory item -->
<!-- instead of updating InventoryItem, add an InventoryItemDetail -->
<set from-field="lastNonSerInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
<set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.quantityNotReserved" operator="negative"/>
</calculate>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
<!-- get the promiseDatetime -->
<get-related-one value-field="lastNonSerInventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
<clear-field field="daysToShip"/>
<set field="daysToShip" from-field="productFacility.daysToShip"/>
<if-empty field="daysToShip">
<!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
<if-not-empty field="facility.defaultDaysToShip">
<set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
<else>
<set field="daysToShip" value="30" type="Long"/>
</else>
</if-not-empty>
</if-empty>
<!-- TODO: Convert this to a <set-calendar> operation -->
<call-bsh><![CDATA[
java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
cal.setTimeInMillis(orderDate.getTime());
cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
]]></call-bsh>
<else>
<!-- no non-ser inv item, create a non-ser InventoryItem with availableToPromise = -quantityNotReserved -->
<clear-field field="createInventoryItemInMap"/>
<clear-field field="createInventoryItemOutMap"/>
<!-- the createInventoryItem service is run by the the system user here -->
<entity-one entity-name="UserLogin" value-field="permUserLogin">
<field-map field-name="userLoginId" value="system"/>
</entity-one>
<set from-field="parameters.productId" field="createInventoryItemInMap.productId"/>
<set from-field="parameters.facilityId" field="createInventoryItemInMap.facilityId"/>
<set from-field="parameters.containerId" field="createInventoryItemInMap.containerId"/>
<set value="NON_SERIAL_INV_ITEM" field="createInventoryItemInMap.inventoryItemTypeId"/>
<set from-field="permUserLogin" field="createInventoryItemInMap.userLogin"/>
<call-service service-name="createInventoryItem" in-map-name="createInventoryItemInMap" include-user-login="false">
<result-to-field result-name="inventoryItemId" field="createInventoryItemOutMap.inventoryItemId"/>
</call-service>
<entity-one entity-name="InventoryItem" value-field="newNonSerInventoryItem">
<field-map field-name="inventoryItemId" from-field="createInventoryItemOutMap.inventoryItemId"/>
</entity-one>
<!-- also create a detail record with the quantities -->
<set from-field="newNonSerInventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
<set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.quantityNotReserved" operator="negative"/>
</calculate>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
<!-- get the promiseDatetime -->
<get-related-one value-field="newNonSerInventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
<clear-field field="daysToShip"/>
<set field="daysToShip" from-field="productFacility.daysToShip"/>
<if-empty field="daysToShip">
<!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
<if-not-empty field="facility.defaultDaysToShip">
<set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
<else>
<set field="daysToShip" value="30" type="Long"/>
</else>
</if-not-empty>
</if-empty>
<!-- TODO: Convert this to a <set-calendar> operation -->
<call-bsh><![CDATA[
java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
cal.setTimeInMillis(orderDate.getTime());
cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
]]></call-bsh>
</else>
</if-not-empty>
<set field="parameters.quantityNotReserved" value="0" type="BigDecimal"/>
<!-- calculate for over qty want to remove -->
<calculate field="qtyOverRemv" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="qtyToRemove"/>
<calcop operator="negative" field="qtyCanRemv"/>
</calcop>
</calculate>
<set field="qtyToRemove" type="BigDecimal" default-value="0" from-field="qtyCanRemv"/>
<call-simple-method method-name="removeEbayProductQtyReserved"/>
<set field="successMessage" value="${returnSuccessMessage} (${qtyToRemove}) product qty was canceled from this transaction and (${qtyOverRemv}) was fail because you reserved in inventory only ${qtyToRemove}. "/>
<field-to-result field="successMessage"/>
</else>
</if-compare>
<!-- update values in EbayProductStoreInventory -->
<calculate field="ebayProductStoreInventory.quantityReserved" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="qohReserved"/>
<calcop operator="negative" field="qtyToRemove"/>
</calcop>
</calculate>
<calculate field="ebayProductStoreInventory.availableToPromiseListing" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="atpListing"/>
<calcop operator="negative" field="qtyToRemove"/>
</calcop>
</calculate>
<store-value value-field="ebayProductStoreInventory"/>
<else>
<add-error><fail-message message="can not decrease quantity of product ${parameters.productId} because it already to used created listing."/></add-error>
<return/>
</else>
</if-compare>
</else>
</if-compare>
<field-to-result field="parameters.quantityNotReserved" result-name="quantityNotReserved"/>
</simple-method>
<simple-method method-name="reserveForInventoryItemInline" short-description="Does a reservation for one InventoryItem, meant to be called in-line">
<!-- only do something with this inventoryItem if there is more inventory to reserve -->
<if-compare field="parameters.quantityNotReserved" operator="greater" value="0" type="BigDecimal">
<if-compare value="SERIALIZED_INV_ITEM" operator="equals" field="inventoryItem.inventoryItemTypeId">
<if-compare value="INV_AVAILABLE" operator="equals" field="inventoryItem.statusId">
<!-- change status on inventoryItem -->
<set value="INV_PROMISED" field="inventoryItem.statusId"/>
<store-value value-field="inventoryItem"/>
<clear-field field="reserveOisgirMap"/>
<calculate field="parameters.quantityNotReserved">
<calcop field="parameters.quantityNotReserved" operator="subtract"><number value="1.0"/></calcop>
</calculate>
</if-compare>
</if-compare>
<if-compare field="inventoryItem.inventoryItemTypeId" operator="equals" value="NON_SERIAL_INV_ITEM">
<!-- reduce atp on inventoryItem if availableToPromise greater than 0, if not the code at the end of this method will handle it -->
<if>
<condition>
<and>
<if-compare field="inventoryItem.statusId" operator="not-equals" value="ON_HOLD_NS"/>
<if-compare field="inventoryItem.statusId" operator="not-equals" value="DEFECTIVE_NS"/>
<not><if-empty field="inventoryItem.availableToPromiseTotal"/></not>
<if-compare field="inventoryItem.availableToPromiseTotal" operator="greater" value="0" type="BigDecimal"/>
</and>
</condition>
<then>
<if-compare-field field="parameters.quantityNotReserved" to-field="inventoryItem.availableToPromiseTotal" operator="greater" type="BigDecimal">
<set from-field="inventoryItem.availableToPromiseTotal" field="parameters.deductAmount"/>
<else>
<set from-field="parameters.quantityNotReserved" field="parameters.deductAmount"/>
</else>
</if-compare-field>
<!-- instead of updating InventoryItem, add an InventoryItemDetail -->
<set from-field="inventoryItem.inventoryItemId" field="createDetailMap.inventoryItemId"/>
<set from-field="parameters.reserveReasonEnumId" field="createDetailMap.reasonEnumId"/>
<calculate field="createDetailMap.availableToPromiseDiff">
<calcop field="parameters.deductAmount" operator="negative"/>
</calculate>
<call-service service-name="createInventoryItemDetail" in-map-name="createDetailMap"/>
<clear-field field="createDetailMap"/>
<calculate field="parameters.quantityNotReserved">
<calcop operator="subtract" field="parameters.quantityNotReserved">
<calcop operator="get" field="parameters.deductAmount"/>
</calcop>
</calculate>
</then>
</if>
<!-- keep track of the last non-serialized inventory item for use if inventory is not required for purchase -->
<!-- use env variable named lastNonSerInventoryItem -->
<set from-field="inventoryItem" field="lastNonSerInventoryItem"/>
</if-compare>
</if-compare>
</simple-method>
<simple-method method-name="getPromisedDateTime" short-description="Get Inventory Promised Date/Time">
<!-- get the promiseDatetime -->
<get-related-one value-field="inventoryItem" relation-name="ProductFacility" to-value-field="productFacility"/>
<set field="daysToShip" from-field="productFacility.daysToShip"/>
<if-empty field="daysToShip">
<!-- if the product does not have its own days to ship, use Facility.defaultDaysToShip, if not then use 30 days as a USA industry default -->
<set field="daysToShip" from-field="facility.defaultDaysToShip" type="Long"/>
</if-empty>
<if-empty field="daysToShip">
<set field="daysToShip" value="30" type="Long"/>
</if-empty>
<!-- TODO: Convert this to a <set-calendar> operation -->
<call-bsh><![CDATA[
java.sql.Timestamp orderDate = orderHeader.getTimestamp("orderDate");
com.ibm.icu.util.Calendar cal = com.ibm.icu.util.Calendar.getInstance();
cal.setTimeInMillis(orderDate.getTime());
cal.add(com.ibm.icu.util.Calendar.DAY_OF_YEAR, daysToShip.intValue());
return org.ofbiz.base.util.UtilMisc.toMap("promisedDatetime", new java.sql.Timestamp(cal.getTimeInMillis()));
]]></call-bsh>
<simple-method method-name="removeEbayProductQtyReserved" short-description="remove reserved product qty and return quantity to inventory">
<!--for InventoryItems that have no locationSeqId -->
<set value="+datetimeReceived" field="orderByString"/>
<entity-condition entity-name="InventoryItem" list="inventoryItems">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="parameters.productId"/>
<condition-expr field-name="facilityId" from-field="parameters.facilityId"/>
<condition-expr field-name="containerId" from-field="parameters.containerId" ignore-if-empty="true" ignore-if-null="true"/>
<condition-expr field-name="quantityOnHandTotal" operator="greater" value="0.0"/>
<condition-expr field-name="locationSeqId" operator="equals" from-field="nullField"/>
</condition-list>
<order-by field-name="${orderByString}"/>
</entity-condition>
<set field="qtyless" type="BigDecimal" default-value="0" from-field="qtyToRemove"/>
<iterate entry="inventoryItem" list="inventoryItems">
<if>
<condition>
<and>
<if-empty field="inventoryItem.locationSeqId"/>
</and>
</condition>
<then>
<get-related value-field="inventoryItem" relation-name="InventoryItemDetail" list="inventoryItemDetails"/>
<if-not-empty field="inventoryItemDetails">
<iterate entry="inventoryItemDetail" list="inventoryItemDetails">
<if>
<condition>
<and>
<if-compare field="inventoryItemDetail.reasonEnumId" value="EBAY_INV_RES" operator="equals"></if-compare>
<if-empty field="inventoryItemDetail.orderId"></if-empty>
<if-empty field="inventoryItemDetail.orderItemSeqId"></if-empty>
<if-compare field="inventoryItemDetail.availableToPromiseDiff" value="0" operator="not-equals"></if-compare>
</and>
</condition>
<then>
<if-compare field="qtyless" value="0" operator="greater">
<calculate field="qtyResult" type="BigDecimal" >
<calcop operator="add">
<calcop operator="get" field="inventoryItemDetail.availableToPromiseDiff"/>
<calcop operator="get" field="${qtyless}"/>
</calcop>
</calculate>
<if-compare field="qtyResult" value="0" operator="greater-equals">
<remove-value value-field="inventoryItemDetail"/>
<else>
<set field="inventoryItemDetail.availableToPromiseDiff" type="BigDecimal" from-field="qtyResult"/>
<store-value value-field="inventoryItemDetail"/>
</else>
</if-compare>
<set field="qtyless" type="BigDecimal" value="${qtyResult}"/>
<else>
<return/>
</else>
</if-compare>
</then>
</if>
</iterate>
</if-not-empty>
</then>
</if>
</iterate>
</simple-method>
</simple-methods>
+29 -5
View File
@@ -103,7 +103,7 @@ under the License.
<attribute name="storeDescFontSize" mode="IN" type="String" optional="true"/>
<attribute name="storeDescFontColor" mode="IN" type="String" optional="true"/>
<attribute name="storeCustomHeaderLayout" mode="IN" type="String" optional="false"/>
<attribute name="storeCustomHeader" mode="IN" type="String" optional="false"/>
<attribute name="storeCustomHeader" mode="IN" type="String" allow-html="any" optional="true"/>
<attribute name="storeHeaderStyle" mode="IN" type="String" optional="false"/>
<attribute name="storeItemLayout" mode="IN" type="String" optional="false"/>
<attribute name="storeItemSortOrder" mode="IN" type="String" optional="false"/>
@@ -189,8 +189,8 @@ under the License.
<attribute name="itemBlocked" type="Map" mode="OUT" optional="true"/>
</service>
<!-- ebay inventory -->
<service name="reserveEbayStoreInventory" engine="simple"
location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayStoreInventory">
<service name="reserveEbayProductInventory" engine="simple"
location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayProductInventory">
<description>Reserve Inventory in a Product Store</description>
<attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute>
<attribute name="productId" type="String" mode="IN" optional="false"></attribute>
@@ -199,18 +199,23 @@ under the License.
<attribute name="quantityNotReserved" type="BigDecimal" mode="OUT" optional="false"></attribute>
</service>
<service name="reserveEbayProductInventoryByStoreFacility" engine="simple"
location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="reserveEbayProductInventory" auth="true">
<description>Reserve Inventory for a Product By Facility
location="component://product/script/org/ofbiz/product/inventory/InventoryReserveServices.xml" invoke="reserveProductInventory" auth="true">
<description>Reserve product for ebay Inventory and make reserve for a Product By Facility
If requireInventory is Y the quantity not reserved is returned, if N then a negative
availableToPromise will be used to track quantity ordered beyond what is in stock.
</description>
<attribute name="productId" type="String" mode="IN" optional="false"/>
<attribute name="facilityId" type="String" mode="IN" optional="false"/>
<attribute name="orderId" type="String" mode="IN" optional="true"/>
<attribute name="orderItemSeqId" type="String" mode="IN" optional="true"/>
<attribute name="shipGroupSeqId" type="String" mode="IN" optional="true"/>
<attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/>
<attribute name="reservedDatetime" type="Timestamp" mode="IN" optional="true"/>
<attribute name="requireInventory" type="String" mode="IN" optional="false"/>
<attribute name="reserveOrderEnumId" type="String" mode="IN" optional="true"/>
<attribute name="reserveReasonEnumId" type="String" mode="IN" optional="false"/>
<attribute name="sequenceId" type="Long" mode="IN" optional="true"/>
<attribute name="priority" type="String" mode="IN" optional="true"/>
<attribute name="quantityNotReserved" type="BigDecimal" mode="OUT" optional="false"/>
</service>
<service name="updateEbayStoreInventory" engine="java" transaction-timeout="3600"
@@ -227,5 +232,24 @@ under the License.
<attribute name="productStoreId" type="String" mode="IN" optional="false"/>
<attribute name="folderId" type="String" mode="OUT" optional="false"></attribute>
</service>
<service name="updateEbayInventoryStatusByProductId" default-entity-name="EbayProductStoreInventory" engine="java" transaction-timeout="3600"
location="org.ofbiz.ebaystore.EbayStoreInventoryServices" invoke="updateEbayInventoryStatusByProductId" auth="true">
<description>update status Inventory from ebay store inventory</description>
<auto-attributes mode="INOUT" optional="false" include="pk"></auto-attributes>
<attribute name="folderId" type="String" mode="INOUT" optional="false"></attribute>
<attribute name="ebayProductId" type="Long" mode="IN" optional="false"></attribute>
</service>
<service name="updateEbayInventoryStatus" engine="java" transaction-timeout="7200"
location="org.ofbiz.ebaystore.EbayStoreInventoryServices" invoke="updateEbayInventoryStatus" auth="true">
<attribute name="productStoreId" type="String" mode="IN" optional="false"></attribute>
<attribute name="facilityId" type="String" mode="IN" optional="false"></attribute>
</service>
<service name="updateEbayProductQtyReserved" default-entity-name="EbayProductStoreInventory" engine="simple"
location="component://ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml" invoke="updateEbayProductQtyReserved" auth="true">
<description>Update/cancel an Product quantity that reserved from inventory</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
<attribute name="quantity" type="BigDecimal" mode="IN" optional="false"></attribute>
<attribute name="actionType" type="String" mode="IN" optional="false"></attribute>
</service>
</services>
@@ -466,14 +466,14 @@ public class EbayStore {
String userLoginId = null;
String password = null;
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
String partyId = null;
try {
List<GenericValue> productStoreRoles = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", context.get("productStoreId").toString(),"roleTypeId","EBAY_ACCOUNT"));
if(productStoreRoles!=null){
if (productStoreRoles!=null) {
partyId= (String)productStoreRoles.get(0).get("partyId");
List<GenericValue> userLogin = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId));
if(userLogin!=null){
if (userLogin!=null) {
userLoginId = (String)userLogin.get(0).get("userLoginId");
password = (String)userLogin.get(0).get("currentPassword");
}
@@ -490,10 +490,10 @@ public class EbayStore {
try {
resp = (GetStoreResponseType)call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedStoreType = resp.getStore();
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale));
//result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale));
// update product store in ofbiz
updateProductStore(dctx, context,returnedStoreType,(String)context.get("productStoreId"));
Map<String,Object> ebayResp = FastMap.newInstance();
@@ -501,7 +501,7 @@ public class EbayStore {
ebayResp.put("storeUrl", returnedStoreType.getURL());
ebayResp.put("storeUrlPath", returnedStoreType.getURLPath());
String desc = returnedStoreType.getDescription();
if(desc!=null) desc = desc.trim();
if (desc!=null) desc = desc.trim();
ebayResp.put("storeDesc", desc);
StoreLogoType logoType = returnedStoreType.getLogo();
@@ -526,13 +526,13 @@ public class EbayStore {
ebayResp.put("storeNameColor",fontType.getNameColor());
ebayResp.put("storeTitleColor",fontType.getTitleColor());
if(fontType!=null){// basic & advance theme
if (fontType!=null) {// basic & advance theme
String themeId = themeType.getThemeID().toString().concat("-").concat(colorSchemeType.getColorSchemeID().toString());
context.put("themeId", themeId);
Map<String,Object> results = retrieveThemeColorSchemeByThemeId(dctx,context);
if(results!=null){
if (results!=null) {
Map<String,Object> storeFontScheme = (Map<String,Object>)results.get("storeFontScheme");
if(storeFontScheme!=null){
if (storeFontScheme!=null) {
ebayResp.put("storeDescFontFace",storeFontScheme.get("storeFontTypeFontDescValue"));
ebayResp.put("storeDescSizeCode", storeFontScheme.get("storeDescSizeValue"));
@@ -548,10 +548,10 @@ public class EbayStore {
StoreHeaderStyleCodeType storeHeaderStyleCodeType = returnedStoreType.getHeaderStyle();
ebayResp.put("storeHeaderStyle", storeHeaderStyleCodeType.value());
StoreHeaderStyleCodeType[] storeHeaderStyleCodeList = storeHeaderStyleCodeType.values();
if(storeHeaderStyleCodeList != null){
if (storeHeaderStyleCodeList != null) {
List<Map<String,Object>> storeHeaderStyleList = FastList.newInstance();
int i=0;
while(i<storeHeaderStyleCodeList.length){
while (i<storeHeaderStyleCodeList.length) {
Map<String,Object> storeHeaderStyleMap = FastMap.newInstance();
StoreHeaderStyleCodeType storeHeaderStyleCode = storeHeaderStyleCodeList[i];
storeHeaderStyleMap.put("storeHeaderStyleName",storeHeaderStyleCode.name());
@@ -567,10 +567,10 @@ public class EbayStore {
StoreItemListLayoutCodeType storeItemListLayoutCodeType = returnedStoreType.getItemListLayout();
ebayResp.put("storeItemLayoutSelected", storeItemListLayoutCodeType.value());
StoreItemListLayoutCodeType[] storeItemListLayoutCodeTypeList = storeItemListLayoutCodeType.values();
if(storeItemListLayoutCodeTypeList!=null){
if (storeItemListLayoutCodeTypeList!=null) {
List<Map<String,Object>> storeItemListLayoutCodeList = FastList.newInstance();
int i=0;
while(i<storeItemListLayoutCodeTypeList.length){
while (i<storeItemListLayoutCodeTypeList.length) {
Map<String,Object> storeItemListLayoutCodeMap = FastMap.newInstance();
StoreItemListLayoutCodeType storeItemListLayoutCode = storeItemListLayoutCodeTypeList[i];
storeItemListLayoutCodeMap.put("storeItemLayoutName",storeItemListLayoutCode.name());
@@ -583,10 +583,10 @@ public class EbayStore {
StoreItemListSortOrderCodeType storeItemListSortOrderCodeType = returnedStoreType.getItemListSortOrder();
ebayResp.put("storeItemSortOrderSelected", storeItemListSortOrderCodeType.value());
StoreItemListSortOrderCodeType[] storeItemListSortOrderCodeTypeList = storeItemListSortOrderCodeType.values();
if(storeItemListSortOrderCodeTypeList!=null){
if (storeItemListSortOrderCodeTypeList!=null) {
List<Map<String,Object>> storeItemSortOrderCodeList = FastList.newInstance();
int i=0;
while(i<storeItemListSortOrderCodeTypeList.length){
while (i<storeItemListSortOrderCodeTypeList.length) {
Map<String,Object> storeItemSortOrderCodeMap = FastMap.newInstance();
StoreItemListSortOrderCodeType storeItemListLayoutCode = storeItemListSortOrderCodeTypeList[i];
storeItemSortOrderCodeMap.put("storeItemSortLayoutName",storeItemListLayoutCode.name());
@@ -601,10 +601,10 @@ public class EbayStore {
StoreCustomHeaderLayoutCodeType storeCustomHeaderLayoutCodeType = returnedStoreType.getCustomHeaderLayout();
ebayResp.put("storeCustomHeaderLayout",storeCustomHeaderLayoutCodeType.value());
StoreCustomHeaderLayoutCodeType[] storeCustomHeaderLayoutCodeTypeList = storeCustomHeaderLayoutCodeType.values();
if(storeCustomHeaderLayoutCodeTypeList!=null){
if (storeCustomHeaderLayoutCodeTypeList!=null) {
List<Map<String,Object>> storeCustomHeaderLayoutList = FastList.newInstance();
int i=0;
while(i<storeCustomHeaderLayoutCodeTypeList.length){
while (i<storeCustomHeaderLayoutCodeTypeList.length) {
Map<String,Object> storeCustomHeaderLayoutMap = FastMap.newInstance();
StoreCustomHeaderLayoutCodeType StoreCustomHeaderLayoutCode = storeCustomHeaderLayoutCodeTypeList[i];
storeCustomHeaderLayoutMap.put("storeCustomHeaderLayoutName",StoreCustomHeaderLayoutCode.name());
@@ -616,7 +616,7 @@ public class EbayStore {
}
StoreCustomListingHeaderType storeCustomListingHeaderType = returnedStoreType.getCustomListingHeader();
if(storeCustomListingHeaderType!=null){
if (storeCustomListingHeaderType!=null) {
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCodeType = storeCustomListingHeaderType.getDisplayType();
ebayResp.put("isLogo",storeCustomListingHeaderType.isLogo());
ebayResp.put("isSearchBox",storeCustomListingHeaderType.isSearchBox());
@@ -626,10 +626,10 @@ public class EbayStore {
ebayResp.put("storeCustomListingHeaderDisplayName",storeCustomListingHeaderDisplayCodeType.name());
ebayResp.put("storeCustomListingHeaderDisplayValue",storeCustomListingHeaderDisplayCodeType.value());
StoreCustomListingHeaderDisplayCodeType[] storeCustomListingHeaderDisplayCodeTypeList = storeCustomListingHeaderDisplayCodeType.values();
if(storeCustomListingHeaderDisplayCodeTypeList != null){
if (storeCustomListingHeaderDisplayCodeTypeList != null) {
List<Map<String,Object>> storeCustomListingHeaderDisplayCodeList = FastList.newInstance();
int i=0;
while(i<storeCustomListingHeaderDisplayCodeTypeList.length){
while (i<storeCustomListingHeaderDisplayCodeTypeList.length) {
Map<String,Object> storeCustomListingHeaderDisplayCodeMap = FastMap.newInstance();
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCode = storeCustomListingHeaderDisplayCodeTypeList[i];
storeCustomListingHeaderDisplayCodeMap.put("storeCustomHeaderLayoutName",storeCustomListingHeaderDisplayCode.name());
@@ -645,10 +645,10 @@ public class EbayStore {
MerchDisplayCodeType merchDisplayCodeType = returnedStoreType.getMerchDisplay();
ebayResp.put("storeMerchDisplay",merchDisplayCodeType.value());
MerchDisplayCodeType[] merchDisplayCodeTypeList = merchDisplayCodeType.values();
if(merchDisplayCodeTypeList!=null){
if (merchDisplayCodeTypeList!=null) {
List<Map<String,Object>> merchDisplayCodeList = FastList.newInstance();
int i=0;
while(i<merchDisplayCodeTypeList.length){
while (i<merchDisplayCodeTypeList.length) {
Map<String,Object> merchDisplayCodeMap = FastMap.newInstance();
MerchDisplayCodeType merchDisplayCode = merchDisplayCodeTypeList[i];
merchDisplayCodeMap.put("merchDisplayCodeName",merchDisplayCode.name());
@@ -663,10 +663,10 @@ public class EbayStore {
ebayResp.put("storeLastOpenedTime", calendar.getTime().toString());
ebayResp.put("storeSubscriptionLevel",returnedStoreType.getSubscriptionLevel().value());
StoreSubscriptionLevelCodeType[] storeSubscriptionlevelList = returnedStoreType.getSubscriptionLevel().values();
if(storeSubscriptionlevelList!=null){
if (storeSubscriptionlevelList!=null) {
List<Map<String,Object>> storeSubscriptionLevelCodeList = FastList.newInstance();
int i=0;
while(i<storeSubscriptionlevelList.length){
while (i<storeSubscriptionlevelList.length) {
Map<String,Object> storeSubscriptionLevelCodeMap = FastMap.newInstance();
StoreSubscriptionLevelCodeType storeSubscriptionLevelCode= storeSubscriptionlevelList[i];
storeSubscriptionLevelCodeMap.put("storeSubscriptionLevelCodeName", storeSubscriptionLevelCode.name());
@@ -678,7 +678,7 @@ public class EbayStore {
}
result.put("ebayStore", ebayResp);
}else{
} else {
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
result.put(ModelService.ERROR_MESSAGE,resp.getAck().toString()+":"+resp.getMessage());
}
@@ -698,7 +698,6 @@ public class EbayStore {
public static void updateProductStore(DispatchContext dctx,Map<String,Object> context,StoreType returnStoreType,String productStoreId){
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
try{
Map<String,Object> inMap = FastMap.newInstance();
if(returnStoreType != null){
@@ -723,17 +722,16 @@ public class EbayStore {
GetStoreOptionsRequestType req = null;
GetStoreOptionsResponseType resp = null;
StoreThemeArrayType returnedBasicThemeArray = null;
StoreThemeArrayType returnedAdvanceThemeArray = null;
try {
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
String themeId = (String)context.get("themeId");
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedBasicThemeArray = resp.getBasicThemeArray();
StoreThemeType[] storeBasicTheme = returnedBasicThemeArray.getTheme();
@@ -743,14 +741,12 @@ public class EbayStore {
themeId = themeId.substring(0,themeId.indexOf("-"));
Map<String,Object> storeColorSchemeMap = null;
boolean flag = false;
while(i<storeBasicTheme.length){
while (i<storeBasicTheme.length) {
StoreThemeType storeThemeType = (StoreThemeType)storeBasicTheme[i];
if(themeId.equals(storeThemeType.getThemeID().toString())){
if (themeId.equals(storeThemeType.getThemeID().toString())) {
StoreColorSchemeType colorSchemeType = storeThemeType.getColorScheme();
if(colorSchemeType!=null){
if(colorSchemeId.equals(colorSchemeType.getColorSchemeID().toString())){
if (colorSchemeType!=null) {
if (colorSchemeId.equals(colorSchemeType.getColorSchemeID().toString())) {
// get font,size and color
storeColorSchemeMap = FastMap.newInstance();
StoreFontType storeFontType = colorSchemeType.getFont();
@@ -762,7 +758,6 @@ public class EbayStore {
storeColorSchemeMap.put("storeFontTypeFontDescValue",storeFontType.getDescFace().value());
storeColorSchemeMap.put("storeDescSizeValue",storeFontType.getDescSize().value());
flag=true;
break;
}
}
@@ -791,18 +786,18 @@ public class EbayStore {
StoreLogoArrayType returnedLogoArray = null;
GetStoreOptionsResponseType resp = null;
try {
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedLogoArray = resp.getLogoArray();
int i=0;
List<Map<String,Object>> logoList = FastList.newInstance();
while(i<returnedLogoArray.getLogoLength()){
while (i<returnedLogoArray.getLogoLength()) {
Map<String,Object> logo = FastMap.newInstance();
StoreLogoType storeLogoType = (StoreLogoType)returnedLogoArray.getLogo(i);
logo.put("storeLogoId", storeLogoType.getLogoID());
@@ -832,18 +827,18 @@ public class EbayStore {
StoreThemeArrayType returnedBasicThemeArray = null;
GetStoreOptionsResponseType resp = null;
try {
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
GetStoreOptionsCall call = new GetStoreOptionsCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetStoreOptionsRequestType();
resp = (GetStoreOptionsResponseType) call.execute(req);
StoreColorSchemeType storeFontColorSchemeType = null;
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedBasicThemeArray = resp.getBasicThemeArray();
int i=0;
List<Map<String,Object>> themeList = FastList.newInstance();
while(i<returnedBasicThemeArray.getThemeLength()){
while (i<returnedBasicThemeArray.getThemeLength()) {
Map<String,Object> basictheme = FastMap.newInstance();
StoreThemeType storeBasicThemeType = (StoreThemeType)returnedBasicThemeArray.getTheme(i);
basictheme.put("storeThemeId", storeBasicThemeType.getThemeID());
@@ -853,10 +848,9 @@ public class EbayStore {
basictheme.put("storeColorSchemeId",storeColorSchemeType.getColorSchemeID());
basictheme.put("storeColorSchemeName",storeColorSchemeType.getName());
if(storeFontColorSchemeType == null){
if (storeFontColorSchemeType == null) {
storeFontColorSchemeType = storeBasicThemeType.getColorScheme();
}
themeList.add(basictheme);
i++;
}
@@ -1,5 +1,7 @@
package org.ofbiz.ebaystore;
import java.math.BigDecimal;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javolution.util.FastMap;
@@ -9,6 +11,8 @@ import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
import com.ebay.sdk.ApiException;
import com.ebay.sdk.SdkException;
@@ -30,6 +34,7 @@ import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductRequestType;
import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductResponseType;
import com.ebay.soap.eBLBaseComponents.SellingManagerFolderDetailsType;
import com.ebay.soap.eBLBaseComponents.SellingManagerProductDetailsType;
import com.ebay.soap.eBLBaseComponents.SellingManagerProductInventoryStatusType;
import com.ebay.soap.eBLBaseComponents.SellingManagerProductType;
public class EbayStoreInventoryServices {
@@ -50,7 +55,7 @@ public class EbayStoreInventoryServices {
boolean checkProd = false;
boolean status = false;
try {
if(context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null){
if (context.get("productStoreId") == null || context.get("productId") == null || context.get("folderId") == null) {
result = ServiceUtil.returnError("The process was required productStoreId, productId and ebay inventory folderId.");
result.put("productStoreId", context.get("productStoreId"));
result.put("facilityId", context.get("facilityId"));
@@ -61,17 +66,17 @@ public class EbayStoreInventoryServices {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
// start upload/update products which selected to an ebay inventory
if(folderId != null){
if (folderId != null) {
GetSellingManagerInventoryCall invenCall = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
invenReq = new GetSellingManagerInventoryRequestType();
invenResp = (GetSellingManagerInventoryResponseType) invenCall.execute(invenReq);
if(invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())){
if (invenResp != null && "SUCCESS".equals(invenResp.getAck().toString())) {
GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId")));
SellingManagerProductType[] sellingManagerProductTypeList = invenResp.getSellingManagerProduct();
for(SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){
for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList){
SellingManagerProductDetailsType sellingManagerProductDetailsType = sellingManagerProductType.getSellingManagerProductDetails();
if(String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){
if (String.valueOf(sellingManagerProductDetailsType.getFolderID()).equals(folderId) && String.valueOf(sellingManagerProductDetailsType.getProductID()).equals(String.valueOf(ebayProductStoreInventory.getLong("ebayProductId"))) && String.valueOf(sellingManagerProductDetailsType.getCustomLabel()).equals(productId)){
checkProd = true;
break;
}
@@ -79,15 +84,15 @@ public class EbayStoreInventoryServices {
}
// checkProduct is true then update detail but is false do create new one.
if(checkProd == true){
if (checkProd) {
status = updateProductInEbayInventoryFolder(dctx,context);
}else {
} else {
status = createNewProductInEbayInventoryFolder(dctx,context);
}
if(status == true){
if (status) {
Debug.logInfo("Done to updated product ".concat(context.get("productId").toString()), module);
result = ServiceUtil.returnSuccess("Updated ebay store inventory in folder "+context.get("folderId")+" success..");
}else{
} else {
result = ServiceUtil.returnError("Fail to update ebay store inventory.");
}
}
@@ -115,7 +120,7 @@ public class EbayStoreInventoryServices {
boolean flag = false;
try {
if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){
if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
AddSellingManagerProductCall productCall = new AddSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
@@ -127,16 +132,16 @@ public class EbayStoreInventoryServices {
sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName"));
//Must keep productId in SKU NUMBER because ebay allow productId field only long value.
sellingManagerProductDetailsType.setCustomLabel(productId);
if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
productReq.setSellingManagerProductDetails(sellingManagerProductDetailsType);
productResp = (AddSellingManagerProductResponseType) productCall.execute(productReq);
if(productResp != null && "SUCCESS".equals(productResp.getAck().toString())){
if (productResp != null && "SUCCESS".equals(productResp.getAck().toString())) {
flag = true;
ebayProductStoreInventory.put("ebayProductId", productResp.getSellingManagerProductDetails().getProductID());
ebayProductStoreInventory.put("folderId", folderId);
ebayProductStoreInventory.store();
}else{
} else {
Debug.logError("Fail to create inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(productResp.getMessage()), module);
}
}
@@ -161,7 +166,7 @@ public class EbayStoreInventoryServices {
boolean flag = false;
try {
if(context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null){
if (context.get("productStoreId") != null && context.get("productId")!=null && context.get("folderId")!=null) {
String productId = (String)context.get("productId");
String folderId = (String)context.get("folderId");
ReviseSellingManagerProductCall call = new ReviseSellingManagerProductCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
@@ -169,11 +174,11 @@ public class EbayStoreInventoryServices {
SellingManagerProductDetailsType sellingManagerProductDetailsType = new SellingManagerProductDetailsType();
GenericValue ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",context.get("facilityId"),"productStoreId",context.get("productStoreId")));
Long ebayProductId = null;
if(ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null){
if (ebayProductStoreInventory !=null && ebayProductStoreInventory.getLong("ebayProductId")==null) {
Debug.logError("Can not update product "+productId+" has no ebay product Id in EbayProductStoreInventory. ", module);
return flag;
}
if(ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null){
if (ebayProductStoreInventory!=null && ebayProductStoreInventory.getLong("ebayProductId")!=null) {
ebayProductId = ebayProductStoreInventory.getLong("ebayProductId");
}
sellingManagerProductDetailsType.setProductID(ebayProductId);
@@ -181,16 +186,16 @@ public class EbayStoreInventoryServices {
sellingManagerProductDetailsType.setProductName((delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId))).getString("internalName"));
//Must keep productId in SKU NUMBER because ebay allow productId field only long value.
sellingManagerProductDetailsType.setCustomLabel(productId);
if(ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
if (ebayProductStoreInventory!=null) sellingManagerProductDetailsType.setQuantityAvailable(ebayProductStoreInventory.getBigDecimal("availableToPromiseListing").intValue());
req.setSellingManagerProductDetails(sellingManagerProductDetailsType);
resp = (ReviseSellingManagerProductResponseType) call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
flag = true;
ebayProductStoreInventory.put("ebayProductId", ebayProductId);
ebayProductStoreInventory.put("folderId", folderId);
ebayProductStoreInventory.store();
}else{
} else {
Debug.logError("Fail to update inventory product ".concat(productId).concat("in productStore ").concat(context.get("productStoreId").toString()).concat(" message from ebay : ").concat(resp.getMessage()), module);
}
}
@@ -215,24 +220,24 @@ public class EbayStoreInventoryServices {
boolean flag = false;
try {
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
GetSellingManagerInventoryFolderCall call = new GetSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new GetSellingManagerInventoryFolderRequestType();
resp = (GetSellingManagerInventoryFolderResponseType) call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())){
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
SellingManagerFolderDetailsType sellingManagerFolderDetailsType = resp.getFolder();
if(sellingManagerFolderDetailsType!=null){
if (sellingManagerFolderDetailsType!=null) {
SellingManagerFolderDetailsType[] SellingManagerFolderDetailsTypeList = sellingManagerFolderDetailsType.getChildFolder();
for(SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList){
for (SellingManagerFolderDetailsType sellingManagerFolderDetails : SellingManagerFolderDetailsTypeList) {
Debug.logInfo("ebay inventory folders name ".concat(sellingManagerFolderDetails.getFolderName()), module);
if(sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)){
if (sellingManagerFolderDetails.getFolderName().equals(defaultFolderName)) {
folderId = String.valueOf(sellingManagerFolderDetails.getFolderID());
flag = true;
break;
}
}
}
if(flag == false){
if (!flag) {
folderId = createNewFolderInEbayStoreInventory(dctx,context);
}
}
@@ -245,7 +250,7 @@ public class EbayStoreInventoryServices {
} catch (SdkException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
if(result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null;
if (result.get("responseMessage")!=null && result.get("responseMessage").equals("fail")) folderId = null;
result.put("folderId", folderId);
Debug.logInfo("service return result "+ result, module);
return result;
@@ -259,14 +264,14 @@ public class EbayStoreInventoryServices {
AddSellingManagerInventoryFolderResponseType resp = null;
try {
if(context.get("productStoreId") != null){
if (context.get("productStoreId") != null) {
AddSellingManagerInventoryFolderCall call = new AddSellingManagerInventoryFolderCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
req = new AddSellingManagerInventoryFolderRequestType();
req.setFolderName(defaultFolderName);//req.setComment(value);//req.setParentFolderID(value)
resp = (AddSellingManagerInventoryFolderResponseType) call.execute(req);
if(resp != null && "SUCCESS".equals(resp.getAck().toString())) {
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
folderId = String.valueOf(resp.getFolderID());
}else {
} else {
Debug.logError("The problem with create new folder on ebay site.", module);
return folderId;
}
@@ -280,4 +285,84 @@ public class EbayStoreInventoryServices {
}
return folderId;
}
/* update inventory status from ebay store inventory */
public static Map<String,Object> updateEbayInventoryStatusByProductId(DispatchContext dctx, Map<String,Object> context){
Locale locale = (Locale) context.get("locale");
Map<String,Object> result = FastMap.newInstance();
Delegator delegator = dctx.getDelegator();
String productStoreId = (String)context.get("productStoreId");
String facilityId = (String)context.get("facilityId");
String folderId = (String)context.get("folderId");
String productId = (String)context.get("productId");
String ebayProductId = null;
GetSellingManagerInventoryRequestType req = null;
GetSellingManagerInventoryResponseType resp = null;
GenericValue ebayProductStoreInventory = null;
if (context.get("ebayProductId") != null) {
ebayProductId = String.valueOf(context.get("ebayProductId"));
}
try {
if (productStoreId != null && ebayProductId != null) {
ebayProductStoreInventory = delegator.findByPrimaryKey("EbayProductStoreInventory", UtilMisc.toMap("productId", productId,"facilityId",facilityId,"productStoreId",productStoreId));
GetSellingManagerInventoryCall call = new GetSellingManagerInventoryCall(EbayStoreHelper.getApiContext(productStoreId, locale, delegator));
req = new GetSellingManagerInventoryRequestType();
resp = (GetSellingManagerInventoryResponseType) call.execute(req);
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
SellingManagerProductType[] sellingManagerProductTypeList = resp.getSellingManagerProduct();
for (SellingManagerProductType sellingManagerProductType : sellingManagerProductTypeList) {
SellingManagerProductDetailsType productDetail = sellingManagerProductType.getSellingManagerProductDetails();
if (String.valueOf(productDetail.getFolderID()).equals(folderId) && String.valueOf(productDetail.getProductID()).equals(ebayProductId) && String.valueOf(productDetail.getCustomLabel()).equals(productId)) {
SellingManagerProductInventoryStatusType prodInventoryStatus = sellingManagerProductType.getSellingManagerProductInventoryStatus();
ebayProductStoreInventory.put("activeListing",new BigDecimal(prodInventoryStatus.getQuantityActive()));
ebayProductStoreInventory.put("scheduled",new BigDecimal(prodInventoryStatus.getQuantityScheduled()));
ebayProductStoreInventory.put("sold",new BigDecimal(prodInventoryStatus.getQuantitySold()));
ebayProductStoreInventory.put("unSold",new BigDecimal(prodInventoryStatus.getQuantityUnsold()));
ebayProductStoreInventory.store();
result = ServiceUtil.returnSuccess("Updated inventory status of product ".concat(productId));
break;
}
}
} else {
Debug.logError("The problem with get manage inventory detail from ebay site.", module);
}
}
} catch (ApiException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkSoapException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (SdkException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (GenericEntityException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
result.put("productStoreId", context.get("productStoreId"));
result.put("facilityId", context.get("facilityId"));
result.put("folderId", context.get("folderId"));
result.put("productId", productId);
return result;
}
public static Map<String,Object> updateEbayInventoryStatus(DispatchContext dctx, Map<String,Object> context){
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String,Object> result = FastMap.newInstance();
Delegator delegator = dctx.getDelegator();
List<GenericValue> ebayProductStoreInventoryList = null;
try {
if (context.get("productStoreId") != null && context.get("facilityId") != null) {
ebayProductStoreInventoryList = delegator.findByAnd("EbayProductStoreInventory", UtilMisc.toMap("facilityId",(String)context.get("facilityId"),"productStoreId",(String)context.get("productStoreId")));
for (GenericValue ebayProductStoreInventory : ebayProductStoreInventoryList) {
if (ebayProductStoreInventory.get("ebayProductId") != null) {
dispatcher.runSync("updateEbayInventoryStatusByProductId",UtilMisc.toMap("productStoreId",(String)context.get("productStoreId"),"facilityId",(String)context.get("facilityId"),"folderId",ebayProductStoreInventory.get("folderId"),"productId",ebayProductStoreInventory.get("productId"),"ebayProductId",ebayProductStoreInventory.get("ebayProductId"),"userLogin",context.get("userLogin")));
}
}
}
} catch (GenericEntityException e) {
result = ServiceUtil.returnFailure(e.getMessage());
} catch (GenericServiceException e) {
result = ServiceUtil.returnFailure(e.getMessage());
}
result = ServiceUtil.returnSuccess();
return result;
}
}
@@ -139,13 +139,32 @@
</request-map>
<request-map uri="reserveProductInventory">
<security https="true" auth="true"/>
<event type="service" invoke="reserveEbayStoreInventory"/>
<event type="service" invoke="reserveEbayProductInventory"/>
<response name="success" type="view" value="reserveEbayProductInventory"/>
</request-map>
<request-map uri="updateEbayStoreInventory">
<security https="true" auth="true"/>
<event type="service-multi" invoke="updateEbayStoreInventory"/>
<response name="success" type="view" value="ebayLoadStoreInventory"/>
</request-map>
<request-map uri="updateEbayStoreInventory">
<security https="true" auth="true"/>
<event type="service-multi" invoke="updateEbayStoreInventory"/>
<response name="success" type="view" value="ebayLoadStoreInventory"/>
</request-map>
<request-map uri="updateEbayInventoryStatus">
<security https="true" auth="true"/>
<event type="service" invoke="updateEbayInventoryStatus"/>
<response name="success" type="view" value="ebayLoadStoreInventory"/>
</request-map>
<request-map uri="updateQuantityReserved">
<security https="true" auth="true"/>
<response name="success" type="view" value="updateQuantityReserved"/>
</request-map>
<request-map uri="updateProductQuantityReserved">
<security https="true" auth="true"/>
<event type="service" invoke="updateEbayProductQtyReserved"/>
<response name="success" type="view" value="ebayLoadStoreInventory"/>
</request-map>
<!-- end of request mappings -->
@@ -172,5 +191,6 @@
<view-map name="ebayStoreInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#ebayStoreInventory"/>
<view-map name="ebayLoadStoreInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#ebayLoadStoreInventory"/>
<view-map name="reserveEbayProductInventory" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#reserveEbayProductInventory"/>
<view-map name="updateQuantityReserved" type="screen" page="component://ebaystore/widget/EbayStoreScreens.xml#updateQuantityReserved"/>
<!-- end of view mappings -->
</site-conf>
+28 -3
View File
@@ -44,15 +44,22 @@
<form name="ListEbayProductInventoryDetail" type="multi" use-row-submit="true" target="updateEbayStoreInventory" title="" list-name="ebayProductStoreInventoryList"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<field name="_rowSubmit" position="1" title="${uiLabelMap.CommonSelect}"><check/></field>
<field name="productStoreId"><hidden/></field>
<field name="facilityId"><hidden/></field>
<field name="folderId"><hidden value="${parameters.folderId}"/></field>
<field name="_rowSubmit" title="${uiLabelMap.CommonSelect}"><check/></field>
<field name="folderId" use-when="ebayfolderId != null"><hidden value="${ebayfolderId}"/></field>
<field name="folderId" use-when="ebayfolderId == null"><hidden value="${folderId}"/></field>
<field name="productId"><display></display></field>
<field name="productName" entry-name="productId">
<display-entity entity-name="Product" key-field-name="productId" description="${productName}"></display-entity>
</field>
<field name="quantityReserved"><display></display></field>
<field name="quantityReserved" >
<hyperlink target="updateQuantityReserved" description="${quantityReserved}">
<parameter param-name="productStoreId"/>
<parameter param-name="facilityId"/>
<parameter param-name="productId"/>
</hyperlink>
</field>
<field name="availableToPromiseListing"><display></display></field>
<field name="scheduled"><display></display></field>
<field name="ebayProductId"><display></display></field>
@@ -62,4 +69,22 @@
<field name="reservedDate"><display></display></field>
<field name="updateButton" title="${uiLabelMap.EbayUpdateInventory}"><submit button-type="button"/></field>
</form>
<form name="updateQuantityReserved" type="single" target="updateProductQuantityReserved" default-entity-name="EbayProductStoreInventory" default-map-name="ebayProductStoreInventory"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<field name="productStoreId"><display></display></field>
<field name="facilityId"><display></display></field>
<field name="productId"><display></display></field>
<field name="productName" entry-name="productId">
<display-entity entity-name="Product" key-field-name="productId" description="${productName}"></display-entity>
</field>
<field name="quantity" required-field="true"><text default-value="${ebayProductStoreInventory.quantityReserved}"></text></field>
<field name="actionType">
<drop-down allow-empty="false">
<option key="ADD" description="Add"/>
<option key="REMOVE" description="Remove"/>
</drop-down>
</field>
<field name="submitButton"><submit button-type="button"/></field>
</form>
</forms>
+42 -11
View File
@@ -297,12 +297,12 @@ under the License.
<service service-name="getFolderInEbayStoreInventory" result-map="result">
<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
</service>
<set field="parameters.folderId" value="${result.folderId}"/>
<set field="ebayfolderId" value="${result.folderId}"/>
</actions>
<widgets>
<section>
<condition>
<not><if-empty field="parameters.folderId"/></not>
<not><if-empty field="ebayfolderId"/></not>
</condition>
<widgets><include-screen name="ViewInventoryItemDetail"/></widgets>
<fail-widgets><include-screen name="ebayStoreInventoryFail"/></fail-widgets>
@@ -345,9 +345,9 @@ under the License.
<widgets>
<section>
<actions>
<set field="facilityId" value="parameters.facilityId"/>
<set field="parameters.productStoreId" from-field="parameters.productStoreId"/>
<set field="folderId" value="parameters.folderId"/>
<set field="facilityId" from-field="parameters.facilityId"/>
<set field="productStoreId" from-field="parameters.productStoreId"/>
<set field="ebayfolderId" from-field="parameters.folderId"/>
</actions>
<widgets><include-screen name="ViewInventoryItemDetail"/></widgets>
</section>
@@ -384,10 +384,18 @@ under the License.
<decorator-screen name="permission-decorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
<screenlet title="${uiLabelMap.ProductInventoryDetails} ${uiLabelMap.ProductStoreNameId} : ${productStore.storeName}[${productStore.productStoreId}] ${uiLabelMap.FacilityFacility} : ${facility.facilityName}">
<link target="reserveEbayProductInventory" style="buttontext" text="${uiLabelMap.EbayReserveProductInventory}">
<parameter param-name="productStoreId" from-field="productStoreId"/>
<parameter param-name="facilityId" from-field="facilityId"/>
</link>
<section>
<widgets>
<link name="updateEbayInventoryStatus" secure="true" target="updateEbayInventoryStatus" style="buttontext" text="${uiLabelMap.EbayUpdateInventoryStatus}">
<parameter param-name="productStoreId" from-field="productStoreId"/>
<parameter param-name="facilityId" from-field="facilityId"/>
</link>
<link name="reserveEbayProductInventory" target="reserveEbayProductInventory" style="buttontext" text="${uiLabelMap.EbayReserveProductInventory}">
<parameter param-name="productStoreId" from-field="productStoreId"/>
<parameter param-name="facilityId" from-field="facilityId"/>
</link>
</widgets>
</section>
<include-form name="ListEbayProductInventoryDetail" location="component://ebaystore/widget/EbayInventoryForms.xml"/>
</screenlet>
</decorator-section>
@@ -429,10 +437,11 @@ under the License.
<decorator-section name="body">
<screenlet title="notes">
<label style="label" text="Please subscribed to Selling Manager Pro before you use this function because ebay product inventory will open when you start selling manager pro on ebay site."></label>
<label style="label" text="if you subscribed already then still can not use, please check you internet connection."></label>
<label text="- To subscribe for production site"></label>
<link target="link : http://pages.ebay.com/selling_manager_pro" text="http://pages.ebay.com/selling_manager_pro" target-window="_BLANK" url-mode="plain"></link>
<link target="http://pages.ebay.com/selling_manager_pro" text="http://pages.ebay.com/selling_manager_pro" target-window="_BLANK" url-mode="plain"></link>
<label text="- To upgrade store level sandbox site"></label>
<link target="link : http://k2b-bulk.sandbox.ebay.com/ws/eBayISAPI.dll?MyeBaySellingPendingListings" target-window="_BLANK" url-mode="plain" text="http://k2b-bulk.sandbox.ebay.com/ws/eBayISAPI.dll?MyeBaySellingPendingListings"></link>
<link target="http://k2b-bulk.sandbox.ebay.com/ws/eBayISAPI.dll?MyeBaySellingPendingListings" target-window="_BLANK" url-mode="plain" text="http://k2b-bulk.sandbox.ebay.com/ws/eBayISAPI.dll?MyeBaySellingPendingListings"></link>
</screenlet>
<screenlet title="How to upgrade sandbox store level?">
<label text="- Click on the link &quot;To upgrade store level for sandbox site&quot;"></label>
@@ -447,4 +456,26 @@ under the License.
</widgets>
</section>
</screen>
<screen name="updateQuantityReserved">
<section>
<actions>
<set field="headerItem" value="ebayStore"/>
<set field="tabButtonItem" value="inventory"/>
<entity-one entity-name="EbayProductStoreInventory" value-field="ebayProductStoreInventory">
<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
<field-map field-name="facilityId" from-field="parameters.facilityId"/>
<field-map field-name="productId" from-field="parameters.productId"/>
</entity-one>
</actions>
<widgets>
<decorator-screen name="permission-decorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
<screenlet title="Inventory Quantities">
<include-form name="updateQuantityReserved" location="component://ebaystore/widget/EbayInventoryForms.xml"/>
</screenlet>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>