Subversion Repositories SmartDukaan

Rev

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

Rev 12920 Rev 12948
Line 136... Line 136...
136
    private String isFbg;
136
    private String isFbg;
137
    private String fbgPrice;
137
    private String fbgPrice;
138
    private String suppressFbgPriceUpdate;
138
    private String suppressFbgPriceUpdate;
139
    private String fbgPromoPrice;
139
    private String fbgPromoPrice;
140
    private String isFbgPromotionActive;
140
    private String isFbgPromotionActive;
141
    
141
 
142
    public String getOtherCost() {
142
    public String getOtherCost() {
143
        return otherCost;
143
        return otherCost;
144
    }
144
    }
145
 
145
 
146
    public void setOtherCost(String otherCost) {
146
    public void setOtherCost(String otherCost) {
Line 291... Line 291...
291
 
291
 
292
        if (amazonlisted.isAutoDecrement()!=Boolean.valueOf(autoDecrement)){
292
        if (amazonlisted.isAutoDecrement()!=Boolean.valueOf(autoDecrement)){
293
            amazonlisted.setAutoDecrement(Boolean.valueOf(autoDecrement));
293
            amazonlisted.setAutoDecrement(Boolean.valueOf(autoDecrement));
294
            commit=true;
294
            commit=true;
295
        }
295
        }
296
        
296
 
297
        if (amazonlisted.isAutoIncrement()!=Boolean.valueOf(autoIncrement)){
297
        if (amazonlisted.isAutoIncrement()!=Boolean.valueOf(autoIncrement)){
298
            amazonlisted.setAutoIncrement(Boolean.valueOf(autoIncrement));
298
            amazonlisted.setAutoIncrement(Boolean.valueOf(autoIncrement));
299
            commit=true;
299
            commit=true;
300
        }
300
        }
301
        
301
 
302
        if (amazonlisted.isManualFavourite()!=Boolean.valueOf(manualFavourite)){
302
        if (amazonlisted.isManualFavourite()!=Boolean.valueOf(manualFavourite)){
303
            amazonlisted.setManualFavourite(Boolean.valueOf(manualFavourite));
303
            amazonlisted.setManualFavourite(Boolean.valueOf(manualFavourite));
304
            commit=true;
304
            commit=true;
305
        }
305
        }
306
 
306
 
Line 312... Line 312...
312
 
312
 
313
        if (amazonlisted.getExceptionalWanlc()!=Double.valueOf(exceptionalWanlc)){
313
        if (amazonlisted.getExceptionalWanlc()!=Double.valueOf(exceptionalWanlc)){
314
            amazonlisted.setExceptionalWanlc(Double.valueOf(exceptionalWanlc));
314
            amazonlisted.setExceptionalWanlc(Double.valueOf(exceptionalWanlc));
315
            commit=true;
315
            commit=true;
316
        }
316
        }
317
        
317
 
318
        if (amazonlisted.getOtherCost()!=Double.valueOf(otherCost)){
318
        if (amazonlisted.getOtherCost()!=Double.valueOf(otherCost)){
319
            amazonlisted.setOtherCost(Double.valueOf(otherCost));
319
            amazonlisted.setOtherCost(Double.valueOf(otherCost));
320
            commit=true;
320
            commit=true;
321
        }
321
        }
322
        
322
 
323
        if(!StringUtils.equals(amazonlisted.getFbgtaxCode(), fbgTaxCode)){
323
        if(!StringUtils.equals(amazonlisted.getFbgtaxCode(), fbgTaxCode)){
324
            amazonlisted.setFbgtaxCode(fbgTaxCode);
324
            amazonlisted.setFbgtaxCode(fbgTaxCode);
325
            commit=true;
325
            commit=true;
326
        }
326
        }
327
 
327
 
Line 347... Line 347...
347
            logger.info("Nothing new to commit");
347
            logger.info("Nothing new to commit");
348
        }
348
        }
349
        return "index";
349
        return "index";
350
 
350
 
351
    }
351
    }
352
    
352
 
353
    public String updatePromo() throws NumberFormatException, TException{
353
    public String updatePromo() throws NumberFormatException, TException{
354
        
354
 
355
        Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
355
        Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
356
        Amazonlisted amazonlisted = catalogClient.getAmazonItemDetails(Long.valueOf(promoItemId));
356
        Amazonlisted amazonlisted = catalogClient.getAmazonItemDetails(Long.valueOf(promoItemId));
357
        
357
 
358
        logger.info(isFbaPromotionActive);
-
 
359
        logger.info(isFbbPromotionActive);
-
 
360
        
358
 
361
        if(Boolean.valueOf(isFbaPromotionActive)){
359
        if(Boolean.valueOf(isFbaPromotionActive)){
362
            amazonlisted.setFbaPromoPrice(Double.valueOf(fbaPromoPrice));
360
            amazonlisted.setFbaPromoPrice(Double.valueOf(fbaPromoPrice));
363
        }
361
        }
364
        
362
 
365
        if(Boolean.valueOf(isFbbPromotionActive)){
363
        if(Boolean.valueOf(isFbbPromotionActive)){
366
            amazonlisted.setFbbPromoPrice(Double.valueOf(fbbPromoPrice));
364
            amazonlisted.setFbbPromoPrice(Double.valueOf(fbbPromoPrice));
367
        }
365
        }
368
        
366
 
369
        if(Boolean.valueOf(isFbgPromotionActive)){
367
        if(Boolean.valueOf(isFbgPromotionActive)){
370
            amazonlisted.setFbgPromoPrice(Double.valueOf(fbgPromoPrice));
368
            amazonlisted.setFbgPromoPrice(Double.valueOf(fbgPromoPrice));
371
        }
369
        }
372
        
370
 
373
        catalogClient.updateAmazonItemDetails(amazonlisted);
371
        catalogClient.updateAmazonItemDetails(amazonlisted);
374
        return "index";
372
        return "index";
375
    }
373
    }
376
 
374
 
377
    public void upload() throws IOException, TException {
375
    public void upload() throws IOException, TException {
Line 436... Line 434...
436
            amazonPromotion.setAddedOn(timeNow);
434
            amazonPromotion.setAddedOn(timeNow);
437
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
435
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
438
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
436
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
439
        }
437
        }
440
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
438
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
441
        if (!cc.addAmazonPromotion(amazonPromoMap)){
439
        List<String> notAddedItems = cc.addAmazonPromotion(amazonPromoMap);
-
 
440
        
-
 
441
        StringBuilder sb = new StringBuilder();
-
 
442
        
-
 
443
        if (notAddedItems.size() > 0){
-
 
444
            sb.append("Following Items were not added : \n");
442
            throw new CatalogServiceException();
445
            for (String notAddedItem:notAddedItems){
-
 
446
                amazonPromoMap.remove(notAddedItem);
-
 
447
                sb.append("Amazon Sku "+notAddedItem+"\n");
-
 
448
            }
-
 
449
        }
-
 
450
        else{
-
 
451
            sb.append("All Items Uploaded Successfully");
443
        }
452
        }
444
 
453
 
445
        if (promotionType.equalsIgnoreCase("LONGTERM")){
454
        if (promotionType.equalsIgnoreCase("LONGTERM")){
446
            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
455
            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
447
            PromotionFeed pm = new PromotionFeed(list);
456
            PromotionFeed pm = new PromotionFeed(list);
448
            pm.start();
457
            pm.start();
449
        }
458
        }
-
 
459
        
-
 
460
        File file = new File("/tmp/amazon-promo");
-
 
461
        FileWriter writer = new FileWriter(file);
-
 
462
        writer.append(sb.toString());
-
 
463
        writer.close();
-
 
464
        byte[] buffer = new byte[(int)file.length()];
-
 
465
        InputStream input = null;
-
 
466
        try {
-
 
467
            int totalBytesRead = 0;
-
 
468
            input = new BufferedInputStream(new FileInputStream(file));
-
 
469
            while(totalBytesRead < buffer.length){
-
 
470
                int bytesRemaining = buffer.length - totalBytesRead;
-
 
471
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
-
 
472
                if (bytesRead > 0){
-
 
473
                    totalBytesRead = totalBytesRead + bytesRead;
-
 
474
                }
-
 
475
            }
-
 
476
        }
-
 
477
        finally {
-
 
478
            input.close();
-
 
479
            file.delete();
-
 
480
        }
-
 
481
 
-
 
482
        response.setHeader("Content-Type", "text/javascript");
-
 
483
 
-
 
484
        ServletOutputStream sos;
-
 
485
        try {
-
 
486
            sos = response.getOutputStream();
-
 
487
            sos.write(buffer);
-
 
488
            sos.flush();
-
 
489
        } catch (IOException e) {
-
 
490
            System.out.println("Unable to stream the manifest file");
-
 
491
        }   
450
    }
492
    }
451
 
493
 
452
    private void changeItemInventory() throws NumberFormatException, TException {
494
    private void changeItemInventory() throws NumberFormatException, TException {
453
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
495
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
454
 
496
 
Line 506... Line 548...
506
    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
548
    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
507
        LogisticsClient logisticsClient = new LogisticsClient();
549
        LogisticsClient logisticsClient = new LogisticsClient();
508
        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
550
        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
509
        //return 0L;
551
        //return 0L;
510
    }
552
    }
511
    
553
 
512
    
554
 
513
    public double getWanlcForItem(String itemId){
555
    public double getWanlcForItem(String itemId){
514
        InventoryClient inventoryServiceClient;
556
        InventoryClient inventoryServiceClient;
515
        try {
557
        try {
516
            inventoryServiceClient = new InventoryClient();
558
            inventoryServiceClient = new InventoryClient();
517
        } catch (TTransportException e1) {
559
        } catch (TTransportException e1) {
Line 559... Line 601...
559
        Process process = testProcess.start();
601
        Process process = testProcess.start();
560
        process.waitFor();
602
        process.waitFor();
561
        logger.info(String.valueOf(process.exitValue()));
603
        logger.info(String.valueOf(process.exitValue()));
562
        return "asinjob";
604
        return "asinjob";
563
    }
605
    }
564
    
606
 
565
    public String runFbgListingJob() throws IOException, InterruptedException {
607
    public String runFbgListingJob() throws IOException, InterruptedException {
566
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
608
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
567
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
609
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
568
            return "authfail";
610
            return "authfail";
569
        }
611
        }
Line 836... Line 878...
836
 
878
 
837
            if (!checkEmptyString(sheet.getRow(iterator).getCell(12))){
879
            if (!checkEmptyString(sheet.getRow(iterator).getCell(12))){
838
                String fbbTaxCode = sheet.getRow(iterator).getCell(12).getStringCellValue();
880
                String fbbTaxCode = sheet.getRow(iterator).getCell(12).getStringCellValue();
839
                amazonlisted.setFbbtaxCode(fbbTaxCode);
881
                amazonlisted.setFbbtaxCode(fbbTaxCode);
840
            }
882
            }
841
            
883
 
842
            if (!checkEmptyString(sheet.getRow(iterator).getCell(13))){
884
            if (!checkEmptyString(sheet.getRow(iterator).getCell(13))){
843
                double otherCost = sheet.getRow(iterator).getCell(13).getNumericCellValue();
885
                double otherCost = sheet.getRow(iterator).getCell(13).getNumericCellValue();
844
                amazonlisted.setOtherCost(otherCost);
886
                amazonlisted.setOtherCost(otherCost);
845
            }
887
            }
846
 
888
 
Line 1301... Line 1343...
1301
    }
1343
    }
1302
 
1344
 
1303
    public String getPromoItemId() {
1345
    public String getPromoItemId() {
1304
        return promoItemId;
1346
        return promoItemId;
1305
    }
1347
    }
1306
    
1348
 
1307
    public String getIsFbaPromotionActive() {
1349
    public String getIsFbaPromotionActive() {
1308
        return isFbaPromotionActive;
1350
        return isFbaPromotionActive;
1309
    }
1351
    }
1310
 
1352
 
1311
    public void setIsFbaPromotionActive(String isFbaPromotionActive) {
1353
    public void setIsFbaPromotionActive(String isFbaPromotionActive) {