Subversion Repositories SmartDukaan

Rev

Rev 9687 | Rev 9836 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9687 Rev 9835
Line 106... Line 106...
106
            Client catalogClient = catalogServiceClient.getClient();
106
            Client catalogClient = catalogServiceClient.getClient();
107
 
107
 
108
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllIgnoredInventoryUpdateItemsList(offset, limit);
108
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllIgnoredInventoryUpdateItemsList(offset, limit);
109
 
109
 
110
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
110
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
111
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
111
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
112
            }
112
            }
113
        } catch (Exception e) {
113
        } catch (Exception e) {
114
            logger.error("Error while getting all items from the catalog service", e);
114
            logger.error("Error while getting all items from the catalog service", e);
115
        }
115
        }
116
        return itemList;
116
        return itemList;
Line 140... Line 140...
140
            Client catalogClient = catalogServiceClient.getClient();
140
            Client catalogClient = catalogServiceClient.getClient();
141
 
141
 
142
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
142
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
143
 
143
 
144
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
144
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
145
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
145
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
146
            }
146
            }
147
        } catch (Exception e) {
147
        } catch (Exception e) {
148
            logger.error("Error while getting all items from the catalog service", e);
148
            logger.error("Error while getting all items from the catalog service", e);
149
        }
149
        }
150
        return itemList;
150
        return itemList;
Line 180... Line 180...
180
            CatalogClient catalogServiceClient = new CatalogClient();
180
            CatalogClient catalogServiceClient = new CatalogClient();
181
            Client catalogClient = catalogServiceClient.getClient();
181
            Client catalogClient = catalogServiceClient.getClient();
182
 
182
 
183
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
183
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
184
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
184
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
185
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
185
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
186
            }
186
            }
187
        } catch(Exception e){
187
        } catch(Exception e){
188
            logger.error("Error while getting the best deals from the catalog service", e);
188
            logger.error("Error while getting the best deals from the catalog service", e);
189
        }
189
        }
190
        //Collections.sort(itemList, new ItemsComparator());
190
        //Collections.sort(itemList, new ItemsComparator());
Line 198... Line 198...
198
            CatalogClient catalogServiceClient = new CatalogClient();
198
            CatalogClient catalogServiceClient = new CatalogClient();
199
            Client catalogClient = catalogServiceClient.getClient();
199
            Client catalogClient = catalogServiceClient.getClient();
200
 
200
 
201
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
201
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
202
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
202
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
203
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
203
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
204
            }
204
            }
205
        } catch(Exception e){
205
        } catch(Exception e){
206
            logger.error("Error while getting the risky items from the catalog service", e);
206
            logger.error("Error while getting the risky items from the catalog service", e);
207
        }
207
        }
208
        Collections.sort(itemList, new ItemsComparator());
208
        Collections.sort(itemList, new ItemsComparator());
Line 216... Line 216...
216
            CatalogClient catalogServiceClient = new CatalogClient();
216
            CatalogClient catalogServiceClient = new CatalogClient();
217
            Client catalogClient = catalogServiceClient.getClient();
217
            Client catalogClient = catalogServiceClient.getClient();
218
 
218
 
219
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
219
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
220
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
220
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
221
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
221
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
222
            }
222
            }
223
        } catch(Exception e){
223
        } catch(Exception e){
224
            logger.error("Error while getting the best sellers from the catalog service", e);
224
            logger.error("Error while getting the best sellers from the catalog service", e);
225
        }
225
        }
226
        return itemList;        
226
        return itemList;        
Line 262... Line 262...
262
            Client catalogClient = catalogServiceClient.getClient();
262
            Client catalogClient = catalogServiceClient.getClient();
263
 
263
 
264
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
264
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
265
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
265
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
266
                //List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
266
                //List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
267
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
267
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
268
            }
268
            }
269
        } catch(Exception e){
269
        } catch(Exception e){
270
            logger.error("Error while getting the latest arrivals from the catalog service", e);
270
            logger.error("Error while getting the latest arrivals from the catalog service", e);
271
        }
271
        }
272
        return itemList;
272
        return itemList;
Line 280... Line 280...
280
            CatalogClient catalogServiceClient = new CatalogClient();
280
            CatalogClient catalogServiceClient = new CatalogClient();
281
            Client catalogClient = catalogServiceClient.getClient();
281
            Client catalogClient = catalogServiceClient.getClient();
282
 
282
 
283
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
283
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
284
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
284
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
285
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "",null));
285
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null,null));
286
            }
286
            }
287
        } catch(Exception e){
287
        } catch(Exception e){
288
            logger.error("Error while getting the search results from the catalog service", e);
288
            logger.error("Error while getting the search results from the catalog service", e);
289
        }
289
        }
290
        return itemList;
290
        return itemList;
Line 327... Line 327...
327
            List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
327
            List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
328
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
328
            List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
329
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
329
            List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
330
            in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
330
            in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
331
            ItemStockPurchaseParams stockPurchaseParams = inventoryClient.getItemStockPurchaseParams(thriftItem.getId());
331
            ItemStockPurchaseParams stockPurchaseParams = inventoryClient.getItemStockPurchaseParams(thriftItem.getId());
332
            String lastNdaySale = "";
332
            Map<Long, String> saleHistory = new HashMap<Long, String>();
-
 
333
            List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 0, 5);
333
            for(int sid: Arrays.asList(0,1,3,6,7,8)){
334
            String lastNdaySale = getOosString(oosStatuses);
334
            	lastNdaySale = "S" + sid + ":";
335
            saleHistory.put(0L,lastNdaySale);
335
	            List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), sid, 5);
336
            List<OOSStatus> webOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 1, 5);
336
	            for(OOSStatus oosStatus : oosStatuses){
337
            String webLastNdaySale = getOosString(webOosStatuses);
337
	            	if(oosStatus.isIs_oos()){
338
            saleHistory.put(1L,webLastNdaySale);
-
 
339
            List<OOSStatus> amzOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 3, 5);
338
	            		lastNdaySale += "X-";
340
            String amzLastNdaySale = getOosString(amzOosStatuses);
339
	            	}else{
341
            saleHistory.put(3L,amzLastNdaySale);
-
 
342
            List<OOSStatus> ebayOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 6, 5);
340
	            		lastNdaySale += oosStatus.getNum_orders() + "-";
343
            String ebayLastNdaySale = getOosString(ebayOosStatuses);
341
	            	}
344
            saleHistory.put(6L,ebayLastNdaySale);
-
 
345
            List<OOSStatus> spdOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 7, 5);
-
 
346
            String spdLastNdaySale = getOosString(spdOosStatuses);
342
	            }
347
            saleHistory.put(7L,spdLastNdaySale);
-
 
348
            List<OOSStatus> fktOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 8, 5);
343
	            lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
349
            String fktLastNdaySale = getOosString(fktOosStatuses);
344
	            lastNdaySale += "\n";
350
            saleHistory.put(8L,fktLastNdaySale);
345
            }
351
            
346
            lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
-
 
347
            
352
            
348
            Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
353
            Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
349
            List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
354
            List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
350
            Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, lastNdaySale, freebieItemId);
355
            Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, saleHistory, freebieItemId);
351
            it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
356
            it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
352
            return it;
357
            return it;
353
        }catch(Exception e){
358
        }catch(Exception e){
354
            logger.error("Error while getting the item from the catalog service", e);
359
            logger.error("Error while getting the item from the catalog service", e);
355
        }
360
        }
356
        return null;
361
        return null;
357
    }
362
    }
-
 
363
    
-
 
364
    private String getOosString(List<OOSStatus> oosStatuses){
-
 
365
    	String lastNdaySale = "";
-
 
366
        for(OOSStatus oosStatus : oosStatuses){
-
 
367
        	if(oosStatus.isIs_oos()){
-
 
368
        		lastNdaySale += "X-";
-
 
369
        	}else{
-
 
370
        		lastNdaySale += oosStatus.getNum_orders() + "-";
-
 
371
        	}
-
 
372
        }
-
 
373
        lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
-
 
374
        return lastNdaySale;
-
 
375
    }
358
 
376
 
359
    @Override
377
    @Override
360
    public boolean updateItem(Item item) {
378
    public boolean updateItem(Item item) {
361
        logger.info("Updating item with Id: " + item.getId());
379
        logger.info("Updating item with Id: " + item.getId());
362
        try{
380
        try{
Line 989... Line 1007...
989
            Client catalogClient = catalogServiceClient.getClient();
1007
            Client catalogClient = catalogServiceClient.getClient();
990
 
1008
 
991
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
1009
            List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
992
 
1010
 
993
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
1011
            for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
994
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, "", null));
1012
                itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null));
995
            }
1013
            }
996
        } catch (Exception e) {
1014
        } catch (Exception e) {
997
            logger.error("Error while getting items by status: " + st, e);
1015
            logger.error("Error while getting items by status: " + st, e);
998
        }
1016
        }
999
        return itemList;
1017
        return itemList;
Line 1017... Line 1035...
1017
            List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
1035
            List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
1018
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
1036
            List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
1019
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems, 
1037
            List<in.shop2020.model.v1.catalog.Item> tSimilarItems, 
1020
            in.shop2020.model.v1.inventory.ItemInventory tItemInventory, 
1038
            in.shop2020.model.v1.inventory.ItemInventory tItemInventory, 
1021
            List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings, 
1039
            List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings, 
1022
            ItemStockPurchaseParams tStockPurchaseParams, String lastNdaySale, Long freebieItemId){
1040
            ItemStockPurchaseParams tStockPurchaseParams, Map<Long,String> saleHistory, Long freebieItemId){
1023
 
1041
 
1024
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
1042
        Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
1025
        VendorItemMapping vItemMapping;
1043
        VendorItemMapping vItemMapping;
1026
        if(tVendorMappings != null) {
1044
        if(tVendorMappings != null) {
1027
            for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
1045
            for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
Line 1174... Line 1192...
1174
                sourcePricingMap,
1192
                sourcePricingMap,
1175
                SimilarItemslist,
1193
                SimilarItemslist,
1176
                voucherMap, 
1194
                voucherMap, 
1177
                stockPurchaseParams.getNumOfDaysStock(), 
1195
                stockPurchaseParams.getNumOfDaysStock(), 
1178
                stockPurchaseParams.getMinStockLevel(), 
1196
                stockPurchaseParams.getMinStockLevel(), 
1179
                lastNdaySale, 
1197
                saleHistory, 
1180
                freebieItemId,
1198
                freebieItemId,
1181
                thriftItem.getAsin(),
1199
                thriftItem.getAsin(),
1182
                thriftItem.getHoldInventory(),
1200
                thriftItem.getHoldInventory(),
1183
                thriftItem.getDefaultInventory());
1201
                thriftItem.getDefaultInventory());
1184
        return item;
1202
        return item;