Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3d21245
Added handling to identify refund and cancellation from refund payload
Prerakghatode Dec 29, 2025
00cb1d4
updated item approved check only when order exists
Prerakghatode Dec 29, 2025
3d07ea8
Added job data and generate ExchangeFeed service
parnikarangnekar Dec 29, 2025
7983d8a
Fixed the typo in exchange feed generation file
parnikarangnekar Dec 30, 2025
5102d8b
Refactored generate exchange feed service and added template/graphQL/…
parnikarangnekar Dec 30, 2025
e55828f
added return tranformation file along with service call for cancellat…
Prerakghatode Dec 30, 2025
0c410e3
removed testing code
Prerakghatode Dec 30, 2025
adfe548
Updated the job and system message data for exchange order
parnikarangnekar Dec 31, 2025
13f50ad
Added upgrade data and ReturnedOrderIdsQuery.ftl
parnikarangnekar Dec 31, 2025
e3a8422
Updated data
parnikarangnekar Dec 31, 2025
53a64d6
updated returns and cancellation creation handling
Prerakghatode Dec 31, 2025
6c53aac
Merge branch '222-create-service-for-shopify-graphQL-fetch-and-return…
gurveenbagga Dec 31, 2025
c6df1bf
Improved: Did some code refactoring and added ToDos to handle
gurveenbagga Dec 31, 2025
b1c7dca
Revert "Improved: Did some code refactoring and added ToDos to handle"
gurveenbagga Dec 31, 2025
a04c70d
Revert "Revert "Improved: Did some code refactoring and added ToDos t…
gurveenbagga Dec 31, 2025
9c72787
Revert "Revert "Revert "Improved: Did some code refactoring and added…
gurveenbagga Dec 31, 2025
8a2545d
Updated job data and service name
parnikarangnekar Dec 31, 2025
b77a9d6
Removed changes pushed by mistake
gurveenbagga Dec 31, 2025
7cb2a20
Added customer and orignal price set in get exchange order feed
parnikarangnekar Jan 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/ShopifyServiceJobData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ under the License.
<parameters parameterName="additionalParameters" parameterValue=""/>
<parameters parameterName="runAsBatch" parameterValue="true"/>
</moqui.service.job.ServiceJob>
<!-- ServiceJob data for queuing exchanged orderIds feed -->
<moqui.service.job.ServiceJob jobName="queue_ReturnedOrderIdsFeedForExchange" description="Queue exchanged orderIds feed"
serviceName="co.hotwax.shopify.system.ShopifySystemMessageServices.queue#FeedSystemMessage" cronExpression="0 0 * * * ?" paused="Y">
<parameters parameterName="systemMessageTypeId" parameterValue="GenerateReturnedOrderIdsFeedForExchange"/>
<parameters parameterName="systemMessageRemoteId" parameterValue=""/>
<parameters parameterName="fromDate" parameterValue=""/>
<parameters parameterName="thruDate" parameterValue=""/>
<parameters parameterName="additionalParameters" parameterValue=""/>
<parameters parameterName="runAsBatch" parameterValue="true"/>
</moqui.service.job.ServiceJob>

<!-- ServiceJob data for queuing Appeasement Ids feed -->
<moqui.service.job.ServiceJob jobName="queue_AppeasementIdsFeed" description="Queue Appeasement Ids feed"
Expand Down
25 changes: 25 additions & 0 deletions data/ShopifySetupSeedData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,31 @@ under the License.
consumeServiceName="co.hotwax.shopify.system.ShopifySystemMessageServices.generate#ReturnsAndExchangeFeed">
<parameters parameterName="sendSmrId" parameterValue="" systemMessageRemoteId=""/>
</moqui.service.message.SystemMessageType>
<moqui.service.message.SystemMessageType systemMessageTypeId="GenerateReturnedOrderIdsFeedForExchange"
description="Generate Exchange Order Ids Feed"
sendPath="component://shopify-connector/template/graphQL/ReturnedOrderIdsQuery.ftl"
sendServiceName="co.hotwax.shopify.system.ShopifySystemMessageServices.generate#ReturnedOrderIdsFeed"
receivePath="${contentRoot}/shopify/ReturnedOrderIdsFeedForExchange/ExchangedOrderIdsFeed-${dateTime}-${systemMessageId}.json"/>

<!-- SystemMessageType record for generating Exchange Order Feed -->
<moqui.service.message.SystemMessageType systemMessageTypeId="GenerateExchangeOrderFeed"
description="Generate Exchange Feed"
parentTypeId="LocalFeedFile"
sendPath="${contentRoot}/shopify/ExchangeOrderFeed/ExchangeOrderFeed-${dateTime}-${systemMessageId}.json"
consumeServiceName="co.hotwax.shopify.system.ShopifySystemMessageServices.generate#ExchangeOrderFeed">
</moqui.service.message.SystemMessageType>
<moqui.basic.Enumeration description="Send Exchange Order Feed" enumId="SendExchangeOrderFeed" enumTypeId="ShopifyMessageTypeEnum"/>
<moqui.basic.Enumeration description="Generate Exchange Order Feed" enumId="GenerateExchangeOrderFeed" enumTypeId="ShopifyMessageTypeEnum" relatedEnumId="SendExchangeOrderFeed" relatedEnumTypeId="ShopifyMessageTypeEnum"/>
<moqui.basic.Enumeration description="Generate Exchanged Order Ids Feed" enumId="GenerateReturnedOrderIdsFeedForExchange" enumTypeId="ShopifyMessageTypeEnum" relatedEnumId="GenerateExchangeOrderFeed" relatedEnumTypeId="ShopifyMessageTypeEnum"/>
<moqui.service.message.SystemMessageType systemMessageTypeId="SendExchangeOrderFeed"
description="Send Exchange Order Feed"
parentTypeId="LocalFeedFile"
sendServiceName="co.hotwax.ofbiz.SystemMessageServices.send#SystemMessageFileSftp"
sendPath="/home/${sftpUsername}/hotwax/shopify/ExchangeOrderFeed/"/>
<moqui.service.message.SystemMessageTypeParameter systemMessageTypeId="GenerateExchangeOrderFeed"
parameterName="sendSmrId"
parameterValue=""
systemMessageRemoteId=""/>

<moqui.service.message.SystemMessageType systemMessageTypeId="SendReturnsAndExchangeFeed"
description="Send Returns and Exchange Feed"
Expand Down
4 changes: 3 additions & 1 deletion service/co/hotwax/shopify/return/ShopifyReturnServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ under the License.
<set field="exchanges" from="[]"/>
<while condition="hasNextPage">
<script>
queryText = ec.resourceFacade.template("dbresource://shopify/template/graphQL/ExchangesByOrderIDQuery.ftl", "")
queryText = ec.resourceFacade.template("component://shopify-connector/template/graphQL/ReturnedOrderIdsQuery.ftl", "")
</script>
<service-call name="co.hotwax.shopify.common.ShopifyHelperServices.send#ShopifyGraphqlRequest" in-map="[systemMessageRemoteId:systemMessageRemoteId, queryText:queryText]" out-map="exchangeResponse"/>
<if condition="!exchangeResponse.response.node">
Expand All @@ -468,6 +468,8 @@ under the License.
</while>
<set field="orderExchanges.id" from="exchangeResponse.response.node.id"/>
<set field="orderExchanges.name" from="exchangeResponse.response.node.name"/>
<set field="orderExchanges.customer" from="exchangeResponse.response.node.customer"/>
<set field="orderExchanges.originalTotalPriceSet" from="exchangeResponse.response.node.originalTotalPriceSet"/>
<set field="orderExchanges.exchanges" from="exchanges"/>
</actions>
</service>
Expand Down
99 changes: 99 additions & 0 deletions service/co/hotwax/shopify/system/ShopifySystemMessageServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,105 @@ under the License.
</if>
</actions>
</service>
<service verb="generate" noun="ExchangeOrderFeed" authenticate="anonymous-all" transaction-timeout="1800">
<implements service="org.moqui.impl.SystemMessageServices.consume#SystemMessage"/>
<actions>
<entity-find-one entity-name="moqui.service.message.SystemMessageAndType" value-field="systemMessage"/>

<entity-find-one entity-name="moqui.service.message.SystemMessageTypeParameter" value-field="sendSmrParam">
<field-map field-name="systemMessageTypeId" from="systemMessage.systemMessageTypeId"/>
<field-map field-name="parameterName" value="sendSmrId"/>
<field-map field-name="systemMessageRemoteId" from="systemMessage.systemMessageRemoteId"/>
</entity-find-one>
<entity-find-one entity-name="moqui.service.message.SystemMessageRemote" value-field="systemMessageRemote">
<field-map field-name="systemMessageRemoteId" from="systemMessage.systemMessageRemoteId"/>
</entity-find-one>
<set field="shopId" from="systemMessageRemote?.internalId"/>
<if condition="sendSmrParam">
<set field="sendSmrId" from="sendSmrParam.parameterValue"/>
</if>

<if condition="sendSmrId">
<!-- Find SystemMessageType related to systemMessage.systemMessageType to produce corresponding system message -->
<entity-find-one entity-name="moqui.basic.Enumeration" value-field="enumValue">
<field-map field-name="enumId" from="systemMessage.systemMessageTypeId"/>
</entity-find-one>

<if condition="enumValue &amp;&amp; enumValue.relatedEnumId">
<entity-find-one entity-name="moqui.service.message.SystemMessageType" value-field="relatedSystemMessageType">
<field-map field-name="systemMessageTypeId" from="enumValue.relatedEnumId"/>
</entity-find-one>
<if condition="!relatedSystemMessageType"><log level="warn" message="Could not find SystemMessageType with ID ${enumValue.relatedEnumId}, not producing related system message."/></if>
<else>
<log level="warn" message="Related SystemMessageType to produce for ${systemMessage.systemMessageTypeId} not defined, not producing related system message."/>
</else>
</if>
<else>
<log level="warn" message="sendSmrId not defined for ${systemMessage.systemMessageTypeId} not defined, not producing related system message."/>
</else>
</if>

<set field="fileText" from="ec.resource.getLocationReference(systemMessage.messageText).getText()"/>
<set field="orders" from="org.moqui.impl.context.ContextJavaUtil.jacksonMapper.readValue(fileText, List.class)"/>

<if condition="!orders">
<return type="warning" message="System message [${systemMessageId}] for Type [${systemMessage?.systemMessageTypeId}] has messageText [${systemMessage.messageText}], with ReturnedOrderIdsFeed file having incorrect data and may contain null, not generating order exchange feed file."/>
</if>

<set field="nowDate" from="ec.user.nowTimestamp"/>
<set field="jsonFilePathRef" from="ec.resource.expand(systemMessage.sendPath, null,
[contentRoot: ec.user.getPreference('mantle.content.root') ?: 'dbresource://datamanager', date:ec.l10n.format(nowDate, 'yyyy-MM-dd'),
dateTime:ec.l10n.format(nowDate, 'yyyy-MM-dd-HH-mm-ss-SSS')], false)"/>
<set field="jsonFilePath" from="ec.resource.getLocationReference(jsonFilePathRef).getUri().getPath()"/>
<script>
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.JsonFactory
import com.fasterxml.jackson.databind.ObjectMapper
import java.nio.charset.StandardCharsets

try {
//json file
ec.logger.info("jsonFilePath:" +jsonFilePath)

This comment was marked as outdated.

File feedFile = new File(jsonFilePath)
if (!feedFile.parentFile.exists()) feedFile.parentFile.mkdirs()
JsonFactory jfactory = new JsonFactory()

/* Declaring the PrintWriter and JsonGenerator resources in the try statement,
so that they are automatically closed regardless of whether the try statement completes normally or abruptly. */
try (PrintWriter pw = new PrintWriter(StandardCharsets.UTF_8, feedFile);
JsonGenerator jGenerator = jfactory.createGenerator(pw)) {
jGenerator.writeStartArray()
</script>

<iterate list="orders" entry="order">
<set field="orderMap" from="[:]"/>
<service-call name="co.hotwax.shopify.return.ShopifyReturnServices.get#ExchangesByOrderId" in-map="[systemMessageRemoteId:systemMessage.systemMessageRemoteId, shopifyOrderId:order.id]"
out-map="orderExchangesResponse" ignore-error="true" transaction="force-new"/>
<set field="orderMap" from="orderExchangesResponse.orderExchanges"/>
<set field="orderMap.shopId" from="shopId"/>
<script>
new ObjectMapper()
.setDateFormat(new java.text.SimpleDateFormat(System.getProperty('default_date_time_format')))
.writerWithDefaultPrettyPrinter().writeValue(jGenerator, orderMap)
</script>
</iterate>
<script>
jGenerator.writeEndArray()
}
} catch (IOException e) {
logger.error("Error preparing Exchange Feed file", e)
}
</script>

<if condition="relatedSystemMessageType">
<service-call name="org.moqui.impl.SystemMessageServices.queue#SystemMessage"
in-map="[systemMessageTypeId:relatedSystemMessageType.systemMessageTypeId, systemMessageRemoteId:sendSmrId,
messageText:jsonFilePathRef, remoteMessageId: jsonFilePathRef.substring(jsonFilePathRef.lastIndexOf('/')+1), sendNow:true]"
out-map="queueSystemMessageOut" ignore-error="true" transaction="force-new"/>
</if>
</actions>
</service>

<service verb="queue" noun="OrderIdsByTagFeed" authenticate="anonymous-all">
<in-parameters>
<parameter name="systemMessageTypeId" required="true"/>
Expand Down
Loading