标签:
1 <eca service="updateReturnHeader" event="return"> 2 <condition field-name="statusId" operator="equals" value="RETURN_ACCEPTED"/> 3 <!-- The quickReceiveReturn service checks this, and some status update calls may not pass it in, so don‘t 4 check it here or the option may be ignored. 5 <condition field-name="needsInventoryReceive" operator="equals" value="Y"/> --> 6 <action service="quickReceiveReturn" mode="sync"/> 7 </eca> 8 <eca service="updateReturnHeader" event="commit"> 9 <condition field-name="statusId" operator="equals" value="RETURN_ACCEPTED"/> 10 <condition field-name="oldStatusId" operator="not-equals" value="RETURN_ACCEPTED"/> 11 <action service="processWaitReplacementReservedReturn" mode="sync"/> 12 <action service="processReplaceImmediatelyReturn" mode="sync"/> 13 <action service="createShipmentAndItemsForReturn" mode="sync"/> 14 <action service="processCrossShipReplacementReturn" mode="sync"/> 15 <action service="createTrackingCodeOrderReturns" mode="sync" run-as-user="system"/> 16 <action service="sendReturnAcceptNotification" mode="async" persist="true"/> 17 <action service="processRefundImmediatelyReturn" mode="sync"/> 18 <action service="createReturnStatus" mode="sync"/> 19 </eca>
首先当触发event事件并且statusId状态为RETURN_ACCEPTED的时候,就会调用quickReceiveReturn服务,下面为该服务的逻辑判断,如果嫌长可以快速掠过。
1 <simple-method method-name="quickReceiveReturn" short-description="Quick Receive Entire Return"> 2 <entity-one entity-name="ReturnHeader" value-field="returnHeader"> 3 <field-map field-name="returnId" from-field="parameters.returnId"/> 4 </entity-one> 5 6 <if-compare field="returnHeader.needsInventoryReceive" operator="equals" value="Y"> 7 <!-- before receiving inventory, check to see if there is inventory information in this database --> 8 <entity-count entity-name="InventoryItem" count-field="iiCount"> 9 <condition-expr field-name="facilityId" operator="equals" from-field="returnHeader.destinationFacilityId"/> 10 </entity-count> 11 12 <if-compare field="iiCount" operator="greater" value="0" type="Integer"> 13 <!-- create a return shipment for this return --> 14 <set field="shipmentCtx.returnId" from-field="parameters.returnId"/> 15 <call-service service-name="createShipmentForReturn" in-map-name="shipmentCtx"> 16 <result-to-field result-name="shipmentId"/> 17 </call-service> 18 <log level="info" message="Created new shipment ${shipmentId}"/> 19 20 <entity-condition entity-name="ReturnItem" list="returnItems"> 21 <condition-expr field-name="returnId" operator="equals" from-field="returnHeader.returnId"/> 22 </entity-condition> 23 24 <!-- if no inventory item type specified, get default from facility --> 25 <if-empty field="parameters.inventoryItemTypeId"> 26 <get-related-one value-field="returnHeader" relation-name="Facility" to-value-field="facility"/> 27 <set field="parameters.inventoryItemTypeId" from-field="facility.defaultInventoryItemTypeId" default-value="NON_SERIAL_INV_ITEM"/> 28 </if-empty> 29 30 <now-timestamp field="nowTimestamp"/> 31 32 <entity-count entity-name="ReturnItem" count-field="returnItemCount"> 33 <condition-expr field-name="returnId" operator="equals" from-field="returnHeader.returnId"/> 34 </entity-count> 35 <set field="nonProductItems" type="Long" value="0"/> 36 37 <iterate entry="returnItem" list="returnItems"> 38 <!-- record this return item on the return shipment as well. not sure if this is actually necessary... --> 39 <clear-field field="shipItemCtx"/> 40 <set from-field="shipmentId" field="shipItemCtx.shipmentId"/> 41 <set from-field="returnItem.productId" field="shipItemCtx.productId"/> 42 <set from-field="returnItem.returnQuantity" field="shipItemCtx.quantity"/> 43 <log level="info" message="calling create shipment item with ${shipItemCtx}"/> 44 <call-service service-name="createShipmentItem" in-map-name="shipItemCtx"> 45 <result-to-field result-name="shipmentItemSeqId"/> 46 </call-service> 47 </iterate> 48 <iterate entry="returnItem" list="returnItems"> 49 <clear-field field="receiveCtx"/> 50 51 <if-empty field="returnItem.expectedItemStatus"> 52 <set value="INV_RETURNED" field="returnItem.expectedItemStatus" type="String"/> 53 </if-empty> 54 <get-related-one value-field="returnItem" relation-name="OrderItem" to-value-field="orderItem"/> 55 <if-not-empty field="orderItem.productId"> 56 <set field="costCtx.returnItemSeqId" from-field="returnItem.returnItemSeqId"/> 57 <set field="costCtx.returnId" from-field="returnItem.returnId"/> 58 <call-service service-name="getReturnItemInitialCost" in-map-name="costCtx"> 59 <result-to-field result-name="initialItemCost" field="receiveCtx.unitCost"/> 60 </call-service> 61 <!--check if the items already have SERIALIZED inventory. If so, it still puts them back as SERIALIZED with status "Accepted."--> 62 <entity-count entity-name="InventoryItem" count-field="serializedItemCount"> 63 <condition-list combine="and"> 64 <condition-expr field-name="productId" operator="equals" from-field="returnItem.productId"/> 65 <condition-expr field-name="facilityId" operator="equals" from-field="returnHeader.destinationFacilityId"/> 66 <condition-expr field-name="inventoryItemTypeId" operator="equals" value="SERIALIZED_INV_ITEM"/> 67 </condition-list> 68 </entity-count> 69 <set field="setNonSerial" value="false"/> 70 <if-compare field="parameters.inventoryItemTypeId" value="NON_SERIAL_INV_ITEM" operator="equals"> 71 <if-compare field="serializedItemCount" value="0" operator="equals"> 72 <set field="parameters.inventoryItemTypeId" value="NON_SERIAL_INV_ITEM"/> 73 <set field="setNonSerial" value="true"/> 74 </if-compare> 75 </if-compare> 76 <if-compare field="setNonSerial" value="false" operator="equals"> 77 <set field="parameters.inventoryItemTypeId" value="SERIALIZED_INV_ITEM"/> 78 <set field="returnItem.returnQuantity" value="1" type="BigDecimal"/> 79 </if-compare> 80 81 <set from-field="parameters.inventoryItemTypeId" field="receiveCtx.inventoryItemTypeId"/> 82 <set from-field="returnItem.expectedItemStatus" field="receiveCtx.statusId"/> 83 <set from-field="returnItem.productId" field="receiveCtx.productId"/> 84 <set from-field="returnItem.returnItemSeqId" field="receiveCtx.returnItemSeqId"/> 85 <set from-field="returnItem.returnId" field="receiveCtx.returnId"/> 86 <set from-field="returnItem.returnQuantity" field="receiveCtx.quantityAccepted"/> 87 <set from-field="returnHeader.destinationFacilityId" field="receiveCtx.facilityId"/> 88 <!-- important: associate ShipmentReceipt with return shipment created --> 89 <set field="receiveCtx.shipmentId" from-field="shipmentId"/> 90 91 <set field="receiveCtx.comments" value="Returned Item RA# ${returnItem.returnId}"/> 92 <set field="receiveCtx.datetimeReceived" from-field="nowTimestamp"/> 93 <set field="receiveCtx.quantityRejected" value="0" type="BigDecimal"/> 94 95 <call-service service-name="receiveInventoryProduct" in-map-name="receiveCtx"/> 96 <else> 97 <calculate field="nonProductItems" type="Long"> 98 <calcop operator="add"> 99 <number value="1"/> 100 </calcop> 101 </calculate> 102 </else> 103 </if-not-empty> 104 </iterate> 105 106 <!-- now that the receive is done; set the need flag to N --> 107 <refresh-value value-field="returnHeader"/> 108 <set field="returnHeader.needsInventoryReceive" value="N"/> 109 <store-value value-field="returnHeader"/> 110 111 <!-- always check/update the ReturnHeader status, even though it might have been from the receiving above, just make sure --> 112 <if-compare field="returnHeader.statusId" operator="not-equals" value="RETURN_RECEIVED"> 113 <set field="retStCtx.returnId" from-field="returnHeader.returnId"/> 114 <set field="retStCtx.statusId" value="RETURN_RECEIVED"/> 115 <call-service service-name="updateReturnHeader" in-map-name="retStCtx"/> 116 </if-compare> 117 <else> 118 <log level="info" message="Not receiving inventory for returnId ${returnHeader.returnId}, no inventory information available."/> 119 </else> 120 </if-compare> 121 </if-compare> 122 </simple-method>
大概分析下该simple-method方法,判断returnHeader退货头的needsInventoryReceive字段(需要仓库接收 ),如果是的话,判断退货头的DESTINATION_FACILITY_ID是否等于facilityId,如果等于,就获取库存项的数目,如果库存量大于0,则调用createShipmentForReturn(创建针对退货的装运头)的服务,生成shipmentId,然后判断参数parameters.inventoryItemTypeId是否为空,如果为空,就给默认值NON_SERIAL_INV_ITEM,获取退货项的数目,循环退货项的列表,调用createShipmentItem(装运项)服务,接着继续根据退货项列表循环调用receiveInventoryProduct(创建新的库存项目接收库存(S))服务。
然后还会调好多的别的服务,我就实在没有心思一一仔细阅读了,最后还需要调用这个createReturnStatus服务,这个服务就跟流程日志一样,不管是创建还是针对该对象进行的任何修改操作,都会新增一条这样的状态,用于跟踪退货单的流程。
ofbiz进击 。 ofbiz 退货流程(包含获取可退货项流程分析 以及 取消退货项的过程分析)
标签:
原文地址:http://www.cnblogs.com/wangqc/p/ofbiz_returnOrder.html