| 32724 |
amit.gupta |
1 |
package com.spice.profitmandi.service.transaction;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
import com.spice.profitmandi.dao.entity.transaction.ReturnTransaction;
|
|
|
5 |
import in.shop2020.model.v1.catalog.ItemCondition;
|
|
|
6 |
import org.springframework.stereotype.Service;
|
|
|
7 |
|
|
|
8 |
@Service
|
|
|
9 |
public interface ReturnService {
|
|
|
10 |
ReturnTransaction createReturnTransaction(in.shop2020.model.v1.order.ReturnTransaction tReturnTransaction, ItemCondition itemCondition) throws ProfitMandiBusinessException;
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
/*void receiveReturn(int orderId, receiveCondition, receiveFreebie, serialNumbers)
|
|
|
14 |
order = get_order(order_id)
|
|
|
15 |
scanFreebie = False
|
|
|
16 |
grouppedOrdersList = []
|
|
|
17 |
if order.logisticsTransactionId:
|
|
|
18 |
grouppedOrdersList = get_group_orders_by_logistics_txn_id(order.logisticsTransactionId)
|
|
|
19 |
else:
|
|
|
20 |
grouppedOrdersList.append(order)
|
|
|
21 |
orderCurrentStatus = order.status
|
|
|
22 |
|
|
|
23 |
if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
|
|
24 |
if receiveCondition == 0:
|
|
|
25 |
order.status = OrderStatus.DOA_RECEIVED_PRESTINE
|
|
|
26 |
order.statusDescription = "DOA package received"
|
|
|
27 |
scanFreebie = receiveFreebie
|
|
|
28 |
elif receiveCondition == 1:
|
|
|
29 |
order.status = OrderStatus.DOA_RECEIVED_DAMAGED
|
|
|
30 |
order.statusDescription = "DOA received damaged"
|
|
|
31 |
elif receiveCondition == 2:
|
|
|
32 |
order.status = OrderStatus.DOA_LOST_IN_TRANSIT
|
|
|
33 |
order.statusDescription = "DOA lost in transit"
|
|
|
34 |
order.received_return_timestamp = datetime.datetime.now()
|
|
|
35 |
elif order.status in [OrderStatus.RET_PICKUP_CONFIRMED, OrderStatus.RET_RETURN_IN_TRANSIT]:
|
|
|
36 |
if receiveCondition == 0:
|
|
|
37 |
order.status = OrderStatus.RET_RECEIVED_PRESTINE
|
|
|
38 |
order.statusDescription = "RETURN package received"
|
|
|
39 |
scanFreebie = receiveFreebie
|
|
|
40 |
elif receiveCondition == 1:
|
|
|
41 |
order.status = OrderStatus.RET_RECEIVED_DAMAGED
|
|
|
42 |
order.statusDescription = "RETURN received damaged"
|
|
|
43 |
elif receiveCondition == 2:
|
|
|
44 |
order.status = OrderStatus.RET_LOST_IN_TRANSIT
|
|
|
45 |
order.statusDescription = "RETURN lost in transit"
|
|
|
46 |
order.received_return_timestamp = datetime.datetime.now()
|
|
|
47 |
elif order.status == OrderStatus.RTO_IN_TRANSIT :
|
|
|
48 |
for orderObj in grouppedOrdersList:
|
|
|
49 |
if receiveCondition == 0:
|
|
|
50 |
orderObj.status = OrderStatus.RTO_RECEIVED_PRESTINE
|
|
|
51 |
orderObj.statusDescription = "Returned to origin"
|
|
|
52 |
if orderObj.freebieItemId:
|
|
|
53 |
scanFreebie = True
|
|
|
54 |
elif receiveCondition == 1:
|
|
|
55 |
orderObj.status = OrderStatus.RTO_RECEIVED_DAMAGED
|
|
|
56 |
orderObj.statusDescription = "RTO received damaged"
|
|
|
57 |
elif receiveCondition == 2:
|
|
|
58 |
orderObj.status = OrderStatus.RTO_LOST_IN_TRANSIT
|
|
|
59 |
orderObj.statusDescription = "RTO lost in transit"
|
|
|
60 |
orderObj.received_return_timestamp = datetime.datetime.now()
|
|
|
61 |
|
|
|
62 |
else:
|
|
|
63 |
return False
|
|
|
64 |
|
|
|
65 |
# For OUR warehouses, we need to scan in items for every return
|
|
|
66 |
inventoryClient = InventoryClient().get_client()
|
|
|
67 |
warehouse = inventoryClient.getWarehouse(order.warehouse_id)
|
|
|
68 |
if warehouse.billingType == BillingType.OURS or warehouse.billingType == BillingType.OURS_EXTERNAL:
|
|
|
69 |
scanMap = {
|
|
|
70 |
OrderStatus.RTO_RECEIVED_PRESTINE : ScanType.SALE_RET,
|
|
|
71 |
OrderStatus.RTO_RECEIVED_DAMAGED : ScanType.SALE_RET_UNUSABLE,
|
|
|
72 |
OrderStatus.RTO_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT,
|
|
|
73 |
OrderStatus.DOA_RECEIVED_PRESTINE : ScanType.DOA_IN,
|
|
|
74 |
OrderStatus.DOA_RECEIVED_DAMAGED : ScanType.DOA_IN,
|
|
|
75 |
OrderStatus.DOA_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT
|
|
|
76 |
}
|
|
|
77 |
if orderCurrentStatus == OrderStatus.RTO_IN_TRANSIT:
|
|
|
78 |
order = grouppedOrdersList[0]
|
|
|
79 |
|
|
|
80 |
if order.transaction.payment_option == capitalFloatPayMethod:
|
|
|
81 |
total_amount = 0
|
|
|
82 |
for ordObj in grouppedOrdersList:
|
|
|
83 |
total_amount = total_amount + ordObj.total_amount + ordObj.shippingCost - ordObj.gvAmount
|
|
|
84 |
|
|
|
85 |
creditObj = __creditHistoryObj(order.customer_id, 1, order.transaction.id, total_amount, CreditTxnType.BLOCKED_REVERSED, order.logisticsTransactionId)
|
|
|
86 |
creditTxns = []
|
|
|
87 |
creditTxns.append(creditObj)
|
|
|
88 |
try:
|
|
|
89 |
process_credit_transaction(order.transaction.id, order.customer_id, 1, creditTxns)
|
|
|
90 |
except:
|
|
|
91 |
traceback.print_exc()
|
|
|
92 |
session.rollback()
|
|
|
93 |
return False
|
|
|
94 |
|
|
|
95 |
for orderObj in grouppedOrdersList:
|
|
|
96 |
if scanMap.has_key(orderObj.status):
|
|
|
97 |
scanType = scanMap[orderObj.status]
|
|
|
98 |
lineitem = orderObj.lineitems[0]
|
|
|
99 |
catalogClient = CatalogClient().get_client()
|
|
|
100 |
item = catalogClient.getItem(lineitem.item_id)
|
|
|
101 |
warehouseClient = WarehouseClient().get_client()
|
|
|
102 |
if warehouse.billingType == BillingType.OURS or scanType != ScanType.SALE_RET:
|
|
|
103 |
if item.type == ItemType.SERIALIZED:
|
|
|
104 |
if lineitem.quantity > 1:
|
|
|
105 |
serialNoList = lineitem.serial_number.split(',')
|
|
|
106 |
for serialNumber in serialNoList:
|
|
|
107 |
warehouseClient.scanSerializedItemForOrder(serialNumber, scanType, orderObj.id, orderObj.fulfilmentWarehouseId, 1, orderObj.warehouse_id)
|
|
|
108 |
else:
|
|
|
109 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, orderObj.id, orderObj.fulfilmentWarehouseId, lineitem.quantity, orderObj.warehouse_id)
|
|
|
110 |
else:
|
|
|
111 |
warehouseClient.scanForOrder(None, scanType, lineitem.quantity, orderObj.id, orderObj.fulfilmentWarehouseId, orderObj.warehouse_id)
|
|
|
112 |
if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
|
|
|
113 |
warehouseClient.scanForOursExternalSaleReturn(orderObj.id, lineitem.transfer_price)
|
|
|
114 |
if scanFreebie:
|
|
|
115 |
warehouseClient.scanfreebie(orderObj.id, orderObj.freebieItemId, 0, scanType)
|
|
|
116 |
else:
|
|
|
117 |
if scanMap.has_key(order.status):
|
|
|
118 |
scanType = scanMap[order.status]
|
|
|
119 |
lineitem = order.lineitems[0]
|
|
|
120 |
catalogClient = CatalogClient().get_client()
|
|
|
121 |
item = catalogClient.getItem(lineitem.item_id)
|
|
|
122 |
warehouseClient = WarehouseClient().get_client()
|
|
|
123 |
if warehouse.billingType == BillingType.OURS or scanType != ScanType.SALE_RET:
|
|
|
124 |
if item.type == ItemType.SERIALIZED:
|
|
|
125 |
if lineitem.quantity > 1:
|
|
|
126 |
if serialNumbers is None or len(serialNumbers)==0:
|
|
|
127 |
return False
|
|
|
128 |
else:
|
|
|
129 |
serialNoList = serialNumbers.split(',')
|
|
|
130 |
for serialNumber in serialNoList:
|
|
|
131 |
warehouseClient.scanSerializedItemForOrder(serialNumber, scanType, order.id, order.fulfilmentWarehouseId, 1, order.warehouse_id)
|
|
|
132 |
else:
|
|
|
133 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
|
|
134 |
else:
|
|
|
135 |
warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
|
|
136 |
if warehouse.billingType == BillingType.OURS_EXTERNAL and scanType == ScanType.SALE_RET:
|
|
|
137 |
warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
|
|
|
138 |
if scanFreebie:
|
|
|
139 |
warehouseClient.scanfreebie(order.id, order.freebieItemId, 0, scanType)
|
|
|
140 |
|
|
|
141 |
session.commit()
|
|
|
142 |
return True*/
|
|
|
143 |
}
|