Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
5945 mandeep.dh 1
namespace java in.shop2020.model.v1.inventory
2
namespace py shop2020.thriftpy.model.v1.inventory
3
 
4
include "GenericService.thrift"
5
 
6
enum WarehouseLocation {
7808 anupam.sin 7
	Delhi = 0,
8
	Mumbai = 1,
5945 mandeep.dh 9
	Bangalore = 2,
10
	Kolkata = 3
11
}
12
 
13
struct Vendor {
14
	1:i64 id,
15
	2:string name
16
}
17
 
18
enum BillingType {
19
	OURS = 0,
6725 rajveer 20
	EXTERNAL = 1,
21
	OURS_EXTERNAL = 2
5945 mandeep.dh 22
}
23
 
24
enum WarehouseType {
25
    OURS = 0,
7410 amar.kumar 26
    THIRD_PARTY = 1,
27
    OURS_THIRDPARTY = 2
5945 mandeep.dh 28
}
29
 
30
enum InventoryType {
31
    GOOD = 0,
32
    BAD = 1,
33
    VIRTUAL = 2
34
}
35
 
36
enum HolidayType {
37
	WEEKLY = 0,
38
	MONTHLY = 1,
39
	SPECIFIC = 2
40
}
41
 
42
/* 
43
Warehouse fields details
44
location: it is full address
45
vendorString: some key for the warehouse
46
*/
47
struct Warehouse {
48
	1:i64 id,
49
	2:string displayName,
50
	3:string location,
51
	5:i64 addedOn,
52
	6:i64 lastCheckedOn,
53
	7:string tinNumber,
54
	8:string pincode,
55
	9:string vendorString,
56
	10:WarehouseLocation logisticsLocation,
57
	12:BillingType billingType,
58
	13:WarehouseType warehouseType,
59
	14:InventoryType inventoryType,
60
	15:Vendor vendor,
61
	16:i64 shippingWarehouseId,
62
	17:i64 billingWarehouseId,
63
	18:bool isAvailabilityMonitored,
7330 amit.gupta 64
	19:i64 transferDelayInHours,
65
	20:i64 stateId
5945 mandeep.dh 66
}
67
 
68
/* */
69
struct ItemInventory{
70
	1:i64 id,
71
	2:map<i64,i64> availability,
8182 amar.kumar 72
	3:map<i64,i64> reserved,
73
	4:map<i64,i64> held
5945 mandeep.dh 74
}
75
 
76
struct ItemInventoryHistory{
77
	1:i64 item_id,
78
	2:i64 warehouse_id,
79
	3:i64 timestamp,
80
	4:i64 availability
81
}
82
 
83
struct VendorItemPricing{
84
	1:i64 vendorId,
85
	2:i64 itemId,
86
	3:double transferPrice,
87
	4:double mop,
6747 amar.kumar 88
	5:double dealerPrice,
89
	6:double nlc
5945 mandeep.dh 90
}
91
 
92
struct VendorItemMapping{
93
	1:i64 vendorId,
94
	2:string itemKey,
95
	3:i64 itemId
96
}
97
 
98
struct AvailableAndReservedStock {
99
	1:i64 itemId,
100
	2:i64 available,
101
	3:i64 reserved,
102
	4:i64 minimumStock
103
}
104
 
6531 vikram.rag 105
struct IgnoredInventoryUpdateItems {
106
	1:i64 itemId,
107
	2:i64 warehouseId
6821 amar.kumar 108
}
109
 
110
struct ItemStockPurchaseParams{
111
	1:i64 item_id,
112
	2:i32 numOfDaysStock,
113
	3:i64 minStockLevel
114
}
115
 
5945 mandeep.dh 116
exception InventoryServiceException{
117
	1:i64 id,
118
	2:string message
119
}
120
 
6821 amar.kumar 121
struct OOSStatus {
122
	1:i64 item_id
123
	2:i64 date
124
	3:bool is_oos
125
	4:i64 num_orders
8182 amar.kumar 126
	5:i64 rto_orders
10126 amar.kumar 127
	6:i32 sourceId
6821 amar.kumar 128
}
7281 kshitij.so 129
 
130
struct AmazonInventorySnapshot {
131
    1:i64 item_id
132
    2:i64 availability
133
    3:i64 reserved
10450 vikram.rag 134
    4:bool is_oos
7281 kshitij.so 135
} 
136
 
8282 kshitij.so 137
struct AmazonFbaInventorySnapshot {
138
    1:i64 item_id
139
    2:i64 availability
10450 vikram.rag 140
    3:bool is_oos
8282 kshitij.so 141
}
142
 
8182 amar.kumar 143
struct HoldInventoryDetail {
144
	1:i64 item_id
145
	2:i64 warehouse_id
146
	3:i64 held
147
	4:i64 source
148
}
149
 
9404 vikram.rag 150
struct SnapdealInventoryItem{
151
	1:i64 item_id
152
	2:i64 availability
153
	3:i64 lastUpdatedOnSnapdeal
9495 vikram.rag 154
	4:i64 pendingOrders
10450 vikram.rag 155
	5:bool is_oos
9404 vikram.rag 156
}
157
 
10050 vikram.rag 158
struct FlipkartInventorySnapshot{
159
	1:i64 item_id
160
	2:i64 availability
161
	3:i64 createdOrders
162
	4:i64 heldOrders
10450 vikram.rag 163
	5:bool is_oos
10050 vikram.rag 164
}
9404 vikram.rag 165
 
10547 vikram.rag 166
struct SnapdealStockAtEOD{
167
	1:i64 item_id
168
	2:i64 availability
169
	3:i64 date
170
}
10050 vikram.rag 171
 
10547 vikram.rag 172
struct FlipkartStockAtEOD{
173
	1:i64 item_id
174
	2:i64 availability
175
	3:i64 date
176
}
177
 
178
 
179
 
5945 mandeep.dh 180
service InventoryService extends GenericService.GenericService{
181
 
182
	i64 addWarehouse(1:Warehouse warehouse) throws (1:InventoryServiceException cex),
183
 
184
	/**
185
	add a new vendor
186
	*/
187
	i64 addVendor(1:Vendor vendor) throws (1:InventoryServiceException cex),
188
 
189
	/**
190
	Stores the incremental warehouse updates of items.
191
	*/
192
	void updateInventoryHistory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
193
 
194
	/**
195
	Stores the final inventory stocks of items.
196
	*/
197
	void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
198
 
199
	/**
200
	Add the inventory to existing stock.
201
	*/
202
	void addInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex),
203
 
204
	//all delete methods
205
	void retireWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
206
 
207
	ItemInventory getItemInventoryByItemId(1:i64 item_id) throws (1:InventoryServiceException cex),
208
	i64 getItemAvailibilityAtWarehouse(1:i64 warehouse_id, 2:i64 item_id) throws (1:InventoryServiceException cex),
209
 
210
	/**
211
	Determines the warehouse that should be used to fulfil an order for the given item.
212
	It first checks all the warehouses which are in the logistics location given by the
213
	warehouse_loc parameter. If none of the warehouses there have any inventory, then the
214
	preferred warehouse for the item is used. 
215
 
216
	Returns an ordered list of size 4 with following elements in the given order:
217
	1. Id of the fulfillment warehouse which was finally picked up.
218
	2. Expected delay added by the category manager.
219
	3. Id of the billing warehouse which was finally picked up.
220
	 */
5978 rajveer 221
	list<i64> getItemAvailabilityAtLocation(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException isex),
5945 mandeep.dh 222
 
223
	list<Warehouse> getAllWarehouses(1:bool isActive) throws (1:InventoryServiceException cex),
224
 
225
	/**
226
	 Returns the warehouse with the given id.
227
	*/
228
	Warehouse getWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
229
	list<i64> getAllItemsForWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
230
 
231
	/**
5966 rajveer 232
	Depending on reservation in the table, verify if we can bill this order or not.
233
	*/
234
	bool isOrderBillable(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId),
235
 
236
	/**
5945 mandeep.dh 237
	 Increases the reservation count for an item in a warehouse. Should always succeed normally.
238
	*/
5966 rajveer 239
	bool reserveItemInWarehouse(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:i64 createdTimestamp, 6:i64 promisedShippingTimestamp, 7:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 240
 
241
	/**
7968 amar.kumar 242
	 Updates the reservation for Order
243
	*/
244
	bool updateReservationForOrder(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:i64 createdTimestamp, 6:i64 promisedShippingTimestamp, 7:double quantity) throws (1:InventoryServiceException cex),
245
 
246
	/**
5945 mandeep.dh 247
	 Decreases the reservation count for an item in a warehouse. Should always succeed normally.
248
	*/
5966 rajveer 249
	bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 250
 
251
	/**
252
	Returns the pricing information of an item associated with the vendor of the given warehouse.
253
	Raises an exception if either the item, vendor or the associated pricing information can't be found.
254
	*/
255
	VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
256
 
257
	/**
258
	Returns the list of vendor pricing information of an item.
259
	Raises an exception if item not found corresponding to itemId
260
	*/
261
	list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
262
 
263
 
264
	/**
265
	Adds vendor prices corresponding to the item. If pricing already exists then updates the prices. 
266
	Raises an exception if either the item or vendor can't be found corresponding to their ids.
267
	*/
268
	void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
269
 
270
	/**
271
	Returns a vendor given its id
272
	*/
273
	Vendor getVendor(1:i64 vendorId), 
274
 
275
    /**
276
    Return list of all vendors
277
    */
278
    list<Vendor> getAllVendors(), 
279
 
280
	/**
281
	Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.  
282
	*/
283
	void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
284
 
285
	/**
286
	Returns the list of vendor item mapping corresponding to itemId passed as parameter.
287
	Raises an exception if item not found corresponding to itemId
288
	*/
289
	list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
290
 
291
	/**
292
	Returns a list of inventory stock for items for which there are pending orders for the given vendor.
293
	*/
294
	list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
295
 
296
	/**
297
	 This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
298
	 getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 1 for billing warehouse 7 and shipping warehouse 7
299
	 getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
300
     getWarehouses(null, null, 3, 7, 7) would return all type warehouses with all type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
301
     getWarehouses(null, null, 0, 0, 7) would return all type warehouses with all type inventory for all vendors for all billing warehouses at shipping warehouse 7
302
	 */
303
	list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);
304
 
305
    /**
306
     * Resets availability of an item to the quantity mentioned in a warehouse.
307
     */
308
    void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);
309
 
310
    /**
311
     * Resets availability of a warehouse to zero.
312
     */
313
    void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);
314
 
315
    /**
316
     * Returns the list of item keys which need to be processed for a given warehouse.
317
     * This is currently used by Support application to send item keys whose inventory needs 
318
     * to be updated from PLB
319
     */
320
    list<string> getItemKeysToBeProcessed(1:i64 warehouseId);
321
 
322
    /**
323
     * Marks/Deletes missed inventory updates for a given key and warehouse.
324
     * This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
325
     */
326
    void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);
327
 
328
    /**
329
     * Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
330
     * and the timestamp from where alert was raised.
331
     */
332
    map<string, map<i64, i64>> getIgnoredItemKeys();
333
 
334
    /**
335
    Add the BAD type inventory to existing stock.
336
    */
337
    void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);
338
 
339
    /**
340
    Returns all shipping locations
341
    */    
342
    list<Warehouse> getShippingLocations();
343
 
344
    /**
345
     * Fetches all the vendor item mappings present.
346
     */    
347
    list<VendorItemMapping> getAllVendorItemMappings();
348
 
349
    /**
350
     * Gets items' inventory for a warehouse
351
     * If warehouse is passed as zero, items' inventory across all warehouses is sent
352
     */
353
    map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
354
 
355
    /**
356
    * Clear item availability cache.
357
    */
358
    void clearItemAvailabilityCache();
359
 
360
    void updateVendorString(1:i64 warehouseId, 2:string vendorString);
6096 amit.gupta 361
 
362
    void clearItemAvailabilityCacheForItem(1:i64 item_id);
6467 amar.kumar 363
 
7718 amar.kumar 364
    i64 getOurWarehouseIdForVendor(1:i64 vendorId, 2:i64 billingWarehouseId);
6484 amar.kumar 365
 
366
    map<i64, i64> getItemAvailabilitiesAtOurWarehouses(1:list<i64> item_ids);
6531 vikram.rag 367
 
368
    list<i64> getMonitoredWarehouseForVendors(1:list<i64> vendorIds);
369
 
370
    list<IgnoredInventoryUpdateItems> getIgnoredWarehouseidsAndItemids();
371
 
372
    bool insertItemtoIgnoreInventoryUpdatelist(1:i64 item_id,2:i64 warehouse_id);
373
 
374
    bool deleteItemFromIgnoredInventoryUpdateList(1:i64 item_id,2:i64 warehouse_id);
375
 
376
    i32 getAllIgnoredInventoryupdateItemsCount();
377
 
378
    list<i64> getIgnoredInventoryUpdateItemids(1:i32 offset,2:i32 limit);
379
 
6821 amar.kumar 380
    void updateItemStockPurchaseParams(1:i64 item_id, 2:i32 numOfDaysStock, 3:i64 minStockLevel);
381
 
382
    ItemStockPurchaseParams getItemStockPurchaseParams(1:i64 itemId);
383
 
384
    void addOosStatusForItem(1:map<i64, bool> oosStatusMap, 2: i64 date);
6832 amar.kumar 385
 
9665 rajveer 386
    list<OOSStatus> getOosStatusesForXDaysForItem(1:i64 itemId, 2:i32 sourceId, 3:i32 days);
6857 amar.kumar 387
 
10126 amar.kumar 388
    list<OOSStatus> getOosStatusesForXDays(1:i32 sourceId, 2:i32 days);
389
 
390
    list<VendorItemPricing> getAllVendorItemPricing(1:i64 itemId, 2:i64 vendorId);
391
 
6857 amar.kumar 392
    list<ItemStockPurchaseParams> getNonZeroItemStockPurchaseParams();
7149 amar.kumar 393
 
394
    /**
395
	Returns a list of inventory stock for items for which there are pending orders or have billable inventory.
396
	*/
397
	list<AvailableAndReservedStock> getBillableInventoryAndPendingOrders();
7281 kshitij.so 398
 
399
	string getWarehouseName(1:i64 warehouse_id);
400
 
401
	AmazonInventorySnapshot getAmazonInventoryForItem(1:i64 item_id);
402
 
403
	list<AmazonInventorySnapshot> getAllAmazonInventory();
404
 
10450 vikram.rag 405
	void addOrUpdateAmazonInventoryForItem(1:AmazonInventorySnapshot amazonInventorySnapshot,2:i64 time);
7281 kshitij.so 406
 
7972 amar.kumar 407
	string getLastNdaySaleForItem(1:i64 itemId, 2:i64 numberOfDays);
408
 
8282 kshitij.so 409
	void addOrUpdateAmazonFbaInventory(1:AmazonFbaInventorySnapshot amazonfbainventorysnapshot);
9482 vikram.rag 410
 
9762 amar.kumar 411
	void addUpdateHoldInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 holdQuantity, 4:i64 source)  throws (1:InventoryServiceException cex);
8182 amar.kumar 412
 
8282 kshitij.so 413
	i64 getAmazonFbaItemInventory(1:i64 itemId);
414
 
9404 vikram.rag 415
	list<AmazonFbaInventorySnapshot> getAllAmazonFbaItemInventory();
8282 kshitij.so 416
 
9404 vikram.rag 417
	list<i64> getOursGoodWarehouseIdsForLocation(1:i64 state_id);
8363 vikram.rag 418
 
9404 vikram.rag 419
	i64 getHoldInventoryDetailForItemForWarehouseIdExceptSource(1:i64 id,2:i64 warehouse_id,3:i64 source);
8959 vikram.rag 420
 
9404 vikram.rag 421
	SnapdealInventoryItem getSnapdealInventoryForItem(1:i64 item_id);
422
 
423
	void addOrUpdateSnapdealInventoryForItem(1:SnapdealInventoryItem snapdealinventoryitem)
424
 
425
	double getNlcForWarehouse(1:i64 warehouse_id,2:i64 item_id)
426
 
9640 amar.kumar 427
	map<i32, i64> getHeldInventoryMapForItem(1:i64 item_id, 2:i64 warehouse_id)
428
 
9495 vikram.rag 429
	void addOrUpdateAllAmazonFbaInventory(list<AmazonFbaInventorySnapshot> allamazonfbainventorysnapshot)
9456 vikram.rag 430
 
9495 vikram.rag 431
	void addOrUpdateAllSnapdealInventory(list<SnapdealInventoryItem> allsnapdealinventorysnapshot)
9482 vikram.rag 432
 
9495 vikram.rag 433
	list<SnapdealInventoryItem> getSnapdealInventorySnapshot()
434
 
9761 amar.kumar 435
	list<HoldInventoryDetail> getHoldInventoryDetails(1:i64 itemId, 2:i64 warehouseId, 3:i64 source)
436
 
10450 vikram.rag 437
	void addOrUpdateFlipkartInventorySnapshot(1:list<FlipkartInventorySnapshot> flipkartInventorySnapshot,2:i64 time)
10050 vikram.rag 438
 
439
	list<FlipkartInventorySnapshot> getFlipkartInventorySnapshot()
440
 
10097 kshitij.so 441
	FlipkartInventorySnapshot getFlipkartlInventoryForItem(1:i64 item_id)
442
 
10485 vikram.rag 443
	map<i64,string> getStateMaster()
444
 
10547 vikram.rag 445
	void updateSnapdealStockAtEOD(list<SnapdealStockAtEOD> allsnapdealstock)
446
 
447
	void updateFlipkartStockAtEOD(list<FlipkartStockAtEOD> allflipkartstock)
448
 
5945 mandeep.dh 449
}