Subversion Repositories SmartDukaan

Rev

Rev 2600 | Rev 2614 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 ashish 1
namespace java in.shop2020.model.v1.order
95 ashish 2
namespace py shop2020.thriftpy.model.v1.order
68 ashish 3
/***
4
	Order objects.
5
*/
483 rajveer 6
enum OrderStatus{
845 chandransh 7
	PAYMENT_PENDING,
8
	PAYMENT_FAILED,
483 rajveer 9
	INIT,
10
	SUBMITTED_FOR_PROCESSING,
11
	ACCEPTED,
12
	INVENTORY_LOW,
495 rajveer 13
	REJECTED,
483 rajveer 14
	BILLED,
15
	READY_FOR_SHIPPING,
16
	SHIPPED_FROM_WH,
17
	SHIPPED_TO_LOGST,
18
	IN_TRANSIT,
19
	DELIVERY_SUCCESS,
20
	DELIVERY_FAILED_FIRST_ATTEMPT,
21
	DELIVERY_FAILED_SECOND_ATTEMPT,
22
	DELIVERY_FAILED_THIRD_ATTEMPT,
23
	DELIVERY_FAILED_WORNG_ADDRESS
24
	COMPLETED,
25
	CANCELED,
2537 chandransh 26
	FAILED,
27
	SALES_RETURN_IN_TRANSIT,
2611 chandransh 28
	SALES_RET_RECEIVED,
29
	SALES_RET_RESHIPPED,
2537 chandransh 30
	DOA_PICKUP_REQUESTED,
31
	DOA_RETURN_AUTHORIZED,
32
	DOA_RETURN_IN_TRANSIT,
2600 chandransh 33
	DOA_RECEIVED,
2537 chandransh 34
	DOA_CERT_INVALID,
2611 chandransh 35
	DOA_CERT_VALID
483 rajveer 36
}
37
 
38
enum TransactionStatus{
39
	INIT,
40
	IN_PROCESS,
41
	COMPLETED,
42
	FAILED
43
}
44
 
45
 
46
struct LineItem{
47
	1:i64 id,
698 chandransh 48
	2:i64 item_id,
956 chandransh 49
	3:string productGroup
50
	4:string brand,
51
	5:string model_number,
52
	6:string color
53
	7:string model_name,
54
	8:string extra_info,
55
	9:double quantity,
56
	10:double unit_price,
57
	11:double unit_weight,
58
	12:double total_price,
1000 varun.gupt 59
	13:double transfer_price,
2382 rajveer 60
	14:double total_weight
483 rajveer 61
}
62
 
63
 
64
struct Order{
65
	1:i64 id,
66
	2:i64 warehouse_id,
67
	/**
68
		item info
69
	**/
70
	3:list<LineItem> lineitems,
71
	/**
72
	  logistics info
73
	**/
74
	4:i64 logistics_provider_id,
75
	5:string airwaybill_no,
76
	6:string tracking_id,
77
	7:i64 expected_delivery_time,
78
	/**
79
	  customer info
80
	**/
81
	8:i64 customer_id,
82
	9:string customer_name,
83
	10:string customer_mobilenumber,
84
	11:string customer_pincode,
735 chandransh 85
	12:string customer_address1,
86
	13:string customer_address2,
87
	14:string customer_email,
88
	15:string customer_city,
89
	16:string customer_state,
483 rajveer 90
 
91
	/**
92
		status and misc info
93
	**/
735 chandransh 94
	17:OrderStatus status,
95
	18:string statusDescription,
96
	19:double total_amount,
97
	20:double total_weight,
483 rajveer 98
	/**
99
		billing info
100
	**/
735 chandransh 101
	21:string invoice_number,
102
	22:string billed_by,
483 rajveer 103
	/**
104
		timestamps
105
	**/
735 chandransh 106
	23:i64 created_timestamp,
107
	24:i64 accepted_timestamp,
108
	25:i64 billing_timestamp,
109
	26:i64 shipping_timestamp,
1115 chandransh 110
	27:i64 pickup_timestamp,
111
	28:i64 delivery_timestamp,
1210 chandransh 112
	29:i64 outofstock_timestamp,
113
	30:i64 jacket_number,
1223 chandransh 114
	31:string receiver,
115
	32:i64 batchNo,
2537 chandransh 116
	33:i64 serialNo,
117
	34:bool doaFlag,
118
	35:string pickupRequestNo
483 rajveer 119
}
120
 
121
struct Transaction{
122
	1:i64 id,
123
	2:list<Order> orders,
680 rajveer 124
	3:i64 createdOn,
125
	4:TransactionStatus transactionStatus,
126
	5:string statusDescription,
127
	6:i64 shoppingCartid,
2219 varun.gupt 128
	7:i64 customer_id,
129
	8:string coupon_code
483 rajveer 130
}
131
 
132
struct Alert{
133
	1:i64 id,
134
	2:i64 order_id,
135
	3:i64 type,
136
	4:i64 time_set,
137
	5:string comment,
138
	6:i64 time_unset
139
}
140
 
141
exception TransactionServiceException{
142
	1:i32 errorCode,
143
	2:string message
144
}
145
 
146
service TransactionService{
147
 
763 rajveer 148
	/**
149
	* For closing the open session in sqlalchemy
150
	*/
151
	void closeSession(),
152
 
483 rajveer 153
	i64 createTransaction(1:Transaction transaction) throws (1:TransactionServiceException ex),
154
 
155
	//	Get transaction methods.
156
	Transaction getTransaction(1:i64 id) throws (1:TransactionServiceException ex),
157
	list<Transaction> getTransactionsForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:TransactionStatus status) throws (1:TransactionServiceException ex),
158
	list<Transaction> getTransactionsForShoppingCartId(1:i64 shoppingCartId) throws (1:TransactionServiceException ex),
159
	TransactionStatus getTransactionStatus(1:i64 transactionId) throws (1:TransactionServiceException ex),
160
	bool changeTransactionStatus(1:i64 transactionId, 2:TransactionStatus status, 3:string description) throws (1:TransactionServiceException ex),
1382 varun.gupt 161
 
1398 varun.gupt 162
	bool enqueueTransactionInfoEmail(1:i64 transactionId) throws (1:TransactionServiceException ex),
1382 varun.gupt 163
 
483 rajveer 164
	//	Order getter and setters
165
 
166
	/*
167
	list<Transaction> getTransactionsForShipmentStatus(1:ShipmentStatus status, 2:i64 from_date, 3:i64 to_date) throws (1:TransactionServiceException ex),
168
	list<Transaction> getTransactionsForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:TransactionStatus status) throws (1:TransactionServiceException ex),
169
	list<Transaction> getTransactionsForCustomerAndShipmentStatus(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:ShipmentStatus status) throws (1:TransactionServiceException ex),
170
	list<Transaction> getTransactionsForShoppingCartId(1:i64 shoppingCartId) throws (1:TransactionServiceException ex),
171
	TransactionStatus getTransactionStatus(1:i64 transactionId) throws (1:TransactionServiceException ex),
172
	bool changeTransactionStatus(1:i64 transactionId, 2:TransactionStatus status, 3:string description) throws (1:TransactionServiceException ex),
173
	*/
174
 
175
	list<Order> getAllOrders(1:OrderStatus status, 2:i64 from_date, 3:i64 to_date, 4:i64 warehouse_id) throws (1:TransactionServiceException ex),
1111 varun.gupt 176
 
1115 chandransh 177
	/**
178
	Returns orders within a range of their billing dates
179
	*/
1000 varun.gupt 180
	list<Order> getOrdersByBillingDate(1:OrderStatus status, 2:i64 start_billing_date, 3:i64 end_billing_date, 4:i64 warehouse_id) throws (1:TransactionServiceException ex),
1111 varun.gupt 181
 
1382 varun.gupt 182
	/**
183
	Returns order ids for orders which can be returned
184
	*/
185
	list<i64> getReturnableOrdersForCustomer(1:i64 customer_id, 2:i64 limit) throws (1:TransactionServiceException ex),
186
 
187
	/**
188
	Returns order ids for orders which can be cancelled
189
	*/
190
	list<i64> getCancellableOrdersForCustomer(1:i64 customer_id, 2:i64 limit) throws (1:TransactionServiceException ex),
191
 
483 rajveer 192
	bool changeOrderStatus(1:i64 orderId, 2:OrderStatus status, 3:string description) throws (1:TransactionServiceException ex),
1147 chandransh 193
 
194
	/**
195
	Add billing details such as the bill number and the biller to the Order.
196
	*/
197
	bool addBillingDetails(1:i64 orderId, 2:string invoice_number, 3:string billed_by) throws (1:TransactionServiceException ex),
198
 
199
	/**
2363 chandransh 200
	Adds jacket number and IMEI no. to the order. Doesn't update the IMEI no. if a -1 is supplied.
201
	Also marks the order as billed and sets the billing timestamp.
202
	Return false if it doesn't find the order with the given ID.
1147 chandransh 203
	*/
2382 rajveer 204
	bool addJacketNumber(1:i64 orderId, 2:i64 jacketNumber) throws (1:TransactionServiceException ex),
495 rajveer 205
 
922 rajveer 206
	bool acceptOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
207
	bool billOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
1000 varun.gupt 208
 
1529 ankur.sing 209
	/**
210
	Returns list of orders for given transaction Id. Also filters based on customer Id so that
211
	only user who owns the transaction can view its order details.
212
	*/
213
	list<Order> getOrdersForTransaction(1:i64 transactionId 2:i64 customerId)  throws (1:TransactionServiceException ex),
214
 
483 rajveer 215
	list<Order> getOrdersForCustomer(1:i64 customerId, 2:i64 from_date, 3:i64 to_date, 4:OrderStatus status) throws (1:TransactionServiceException ex),
216
	i64 createOrder(1:Order order) throws (1:TransactionServiceException ex),
217
	Order getOrder(1:i64 id) throws (1:TransactionServiceException ex),
218
	list<LineItem> getLineItemsForOrder(1:i64 orderId) throws (1:TransactionServiceException ex),
219
 
1529 ankur.sing 220
 
757 chandransh 221
	/**
1529 ankur.sing 222
	Returns an order for the order Id. Also checks if the order belongs to the customer whose Id is passed.
223
	Throws exception if either order Id is invalid or order does not below to the customer whose Id is passed.
224
	*/
225
	Order getOrderForCustomer(1:i64 orderId, 2:i64 customerId) throws (1:TransactionServiceException ex),
226
 
227
	/**
1223 chandransh 228
	 Create a batch of all the pending orders for the given warehouse.
229
	 The returned list is orderd by created_timestamp.
230
	 If there are no pending orders, an empty list is returned.
1244 chandransh 231
	 */
1223 chandransh 232
	list<Order> batchOrders(1:i64 warehouseId) throws (1:TransactionServiceException ex),
233
 
234
	/**
235
	Mark the given order as out of stock. Throws an exception if the order with the given Id couldn't be found. 
1244 chandransh 236
	*/
1210 chandransh 237
	bool markOrderAsOutOfStock(1:i64 orderId) throws (1:TransactionServiceException ex),
238
 
239
	/**
757 chandransh 240
	Marks all BILLED orders for a warehouse and a provider as SHIPPED_FROM_WH
241
	*/
242
	bool markOrdersAsManifested(1:i64 warehouseId, 2:i64 providerId) throws (1:TransactionServiceException ex),
1115 chandransh 243
 
244
	/**
245
	Marks all SHIPPED_FROM_WH orders of the previous day for a provider as SHIPPED_TO_LOGISTICS.
246
	Returns a list of orders that were shipped from warehouse but did not appear in the pick-up report.
247
	Raises an exception if we encounter report for an AWB number that we did not ship.
248
	*/
1244 chandransh 249
	list<Order> markOrdersAsPickedUp(1:i64 providerId, 2:map<string, string> pickupDetails) throws (1:TransactionServiceException ex),
1134 chandransh 250
 
251
	/**
252
	Marks all orders with AWBs in the given map as delivered. Also sets the delivery timestamp and
253
	the name of the receiver.
254
	Raises an exception if we encounter report for an AWB number that we did not ship.
255
	*/
256
	void markOrdersAsDelivered(1:i64 providerId, 2:map<string, string> deliveredOrders) throws (1:TransactionServiceException ex),
257
 
258
	/**
259
	Mark all orders with AWBs in the given map as failed. Also sets the delivery timestamp.
260
	Raises an exception if we encounter report for an AWB number that we did not ship.
261
	*/
262
	void markOrdersAsFailed(1:i64 providerId, 2:map<string, string> returnedOrders) throws (1:TransactionServiceException ex),
263
 
1244 chandransh 264
	/**
265
	Update the status description of orders whose AWB numbers are keys of the Map.
266
	*/
267
	void updateNonDeliveryReason(1:i64 providerId, 2:map<string, string> undeliveredOrders) throws (1:TransactionServiceException ex),
268
 
1407 ankur.sing 269
	/**
270
	Returns the list of orders whose delivery time has passed but have not been
271
	delivered yet for the given provider and warehouse. To get a complete list of
272
	undelivered orders, pass them as -1. 
273
	Returns an empty list if no such orders exist.
274
	*/
275
	list<Order> getUndeliveredOrders(1:i64 providerId, 2:i64 warehouseId),
276
 
483 rajveer 277
	//Alerts apis 
278
	list<Alert> getAlerts(1:i64 orderId, 2:bool valid),
279
	void setAlert(1:i64 orderId, 2:bool unset, 3:i64 type, 4: string comment),
1599 ankur.sing 280
 
281
	/**
282
	Return the number of valid orders. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
283
	*/
1628 ankur.sing 284
	i64 getValidOrderCount(),
285
 
286
	/**
287
	Returns the number of distinct customers who have done successful transactions
288
	*/
289
	i64 getNoOfCustomersWithSuccessfulTransaction(),
290
 
291
	/**
1731 ankur.sing 292
	Returns the minimum and maximum amounts of a valid order. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
293
	List contains two values, first minimum amount and second maximum amount.	
1628 ankur.sing 294
	*/
1886 ankur.sing 295
	list<double> getValidOrdersAmountRange(),
1628 ankur.sing 296
 
1886 ankur.sing 297
	/**
298
	Returns list of Orders in descending order by Order creation date. List is restricted to limit Orders.
299
	If limit is passed as 0, then all valid Orders are returned. 
300
	*/
2537 chandransh 301
	list<Order> getValidOrders(1:i64 limit),
1628 ankur.sing 302
 
2537 chandransh 303
	/**
304
	Toggle the DOA flag of an order. This should be used to flag an order for follow-up and unflag it when the follow-up is complete.
305
	Returns the final flag status.
306
	Throws an exception if the order with the given id couldn't be found or if the order status is not DELVIERY_SUCCESS. 
307
	*/
308
	bool toggleDOAFlag(1:i64 orderId) throws (1:TransactionServiceException ex),
309
 
310
	/**
311
	Sends out an email to the account manager of the original courier provider used to ship the order.
312
	If the order status was DELIVERY_SUCCESS, it is changed to be DOA_PICKUP_REQUESTED.
313
	If the order status was DOA_PICKUP_REQUESTED, it is left unchanged.
314
	For any other status, it returns false.
315
	Throws an exception if the order with the given id couldn't be found.
316
	*/
317
	bool requestPickupNumber(1:i64 orderId) throws (1:TransactionServiceException ex),
318
 
319
	/**
320
	If the order status is DOA_PICKUP_REQUESTED, it does the following
321
		1. Sends out an email to the customer with the dispatch advice that he has to print as an attachment.
322
		2. Changes order status to be DOA_PICKUP_AUTHORIZED.
323
		3. Returns true
2589 chandransh 324
	If the order is in any other status, it returns false.
2537 chandransh 325
	Throws an exception if the order with the given id couldn't be found.
326
	*/
327
	bool authorizePickup(1:i64 orderId, 2:string pickupNumber) throws (1:TransactionServiceException ex),
2589 chandransh 328
 
329
	/**
2600 chandransh 330
	If the order status is DOA_RETURN_AUTHORIZED or DOA_RETURN_IN_TRANSIT, marks the order status as DOA_RECEIVED and returns true.
2589 chandransh 331
	If the order is in any other state, it returns false.
332
	Throws an exception if the order with the given id couldn't be found.
333
	*/
334
	bool acceptDoa(1:i64 orderId) throws (1:TransactionServiceException ex),
335
 
336
	/**
2600 chandransh 337
	Used to validate the DOA certificate for an order in the DOA_RECEIVED state. If the certificate is valid,
2611 chandransh 338
	the order state is changed to DOA_CERT_VALID.
2589 chandransh 339
	If the certificate is invalid, the order state is changed to DOA_CERT_INVALID.
340
	If the order is in any other state, it returns false.
341
	Throws an exception if the order with the given id couldn't be found.
342
	*/
343
	bool validateDoa(1:i64 orderId, 2:bool isValid) throws (1:TransactionServiceException ex),
1115 chandransh 344
}