Subversion Repositories SmartDukaan

Rev

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

Rev 12586 Rev 12661
Line 125... Line 125...
125
    private String autoDecrement;
125
    private String autoDecrement;
126
    private String autoIncrement;
126
    private String autoIncrement;
127
    private String autoFavourite;
127
    private String autoFavourite;
128
    private String manualFavourite;
128
    private String manualFavourite;
129
    private String otherCost;
129
    private String otherCost;
-
 
130
    private boolean isFbaPromotionActive;
-
 
131
    private boolean isFbbPromotionActive;
-
 
132
    private String fbaPromoPrice;
-
 
133
    private String fbbPromoPrice;
-
 
134
    private String promoItemId;
130
    
135
    
131
    public String getOtherCost() {
136
    public String getOtherCost() {
132
        return otherCost;
137
        return otherCost;
133
    }
138
    }
134
 
139
 
Line 192... Line 197...
192
    }
197
    }
193
 
198
 
194
 
199
 
195
    public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
200
    public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
196
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
201
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
-
 
202
        long now = getTimeInMilliseconds();
197
        return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
203
        Amazonlisted amazonItemDetails = CatalogClient.getAmazonItemDetails(Long.valueOf(id));
-
 
204
        return amazonItemDetails;
198
    }
205
    }
199
 
206
 
200
    public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
207
    public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
201
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
208
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
202
        return CatalogClient.getItem(Long.valueOf(id));
209
        return CatalogClient.getItem(Long.valueOf(id));
Line 314... Line 321...
314
            logger.info("Nothing new to commit");
321
            logger.info("Nothing new to commit");
315
        }
322
        }
316
        return "index";
323
        return "index";
317
 
324
 
318
    }
325
    }
-
 
326
    
-
 
327
    public String updatePromo() throws NumberFormatException, TException{
-
 
328
        
-
 
329
        Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
-
 
330
        Amazonlisted amazonlisted = catalogClient.getAmazonItemDetails(Long.valueOf(promoItemId));
-
 
331
        
-
 
332
        if(Boolean.valueOf(isFbaPromotionActive)){
-
 
333
            amazonlisted.setFbaPromoPrice(Double.valueOf(fbaPromoPrice));
-
 
334
        }
-
 
335
        
-
 
336
        if(Boolean.valueOf(isFbbPromotionActive)){
-
 
337
            amazonlisted.setFbbPromoPrice(Double.valueOf(fbbPromoPrice));
-
 
338
        }
-
 
339
        
-
 
340
        catalogClient.updateAmazonItemDetails(amazonlisted);
-
 
341
        return "index";
-
 
342
    }
319
 
343
 
320
    public void upload() throws IOException, TException {
344
    public void upload() throws IOException, TException {
321
        File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
345
        File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
322
        FileUtils.copyFile(this.file, fileToCreate);
346
        FileUtils.copyFile(this.file, fileToCreate);
323
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
347
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
Line 337... Line 361...
337
        }
361
        }
338
        TransactionClient tcl = new TransactionClient();
362
        TransactionClient tcl = new TransactionClient();
339
        tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
363
        tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
340
    }
364
    }
341
 
365
 
342
    public void uploadPromotionSheet() throws IOException, ParseException, TException, CatalogServiceException{
366
    public void uploadPromotionSheet() throws IOException, ParseException, TException, CatalogServiceException, InterruptedException{
343
        Map<String,AmazonPromotion> amazonPromoMap = new HashMap<String,AmazonPromotion>();
367
        Map<String,AmazonPromotion> amazonPromoMap = new HashMap<String,AmazonPromotion>();
344
        SimpleDateFormat dateFormatter;
368
        SimpleDateFormat dateFormatter;
-
 
369
        long timeNow = Long.valueOf(getTimeInMilliseconds());
345
        if (promotionType.equalsIgnoreCase("SHORTTERM")){
370
        if (promotionType.equalsIgnoreCase("SHORTTERM")){
346
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
371
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
347
        }
372
        }
348
        else{
373
        else{
349
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
374
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
350
        }
375
        }
351
        File fileToCreate = new File("/tmp/", "Amazon-Promotion-"+String.valueOf(getTimeInMilliseconds())+".xls");
376
        File fileToCreate = new File("/tmp/", "Amazon-Promotion-"+String.valueOf(getTimeInMilliseconds()));
352
        FileUtils.copyFile(this.file, fileToCreate);
377
        FileUtils.copyFile(this.file, fileToCreate);
353
        BufferedReader reader = null;
378
        BufferedReader reader = null;
354
        try {
379
        try {
355
            reader = new BufferedReader(new FileReader(file.getAbsolutePath()));
380
            reader = new BufferedReader(new FileReader(file.getAbsolutePath()));
356
        } catch (FileNotFoundException e1) {
381
        } catch (FileNotFoundException e1) {
Line 362... Line 387...
362
        while ((str = reader.readLine()) != null) {
387
        while ((str = reader.readLine()) != null) {
363
            lineNumber++;
388
            lineNumber++;
364
            if (str.trim().length() == 0 || lineNumber<2) {
389
            if (str.trim().length() == 0 || lineNumber<2) {
365
                continue;
390
                continue;
366
            }
391
            }
367
 
-
 
-
 
392
            timeNow +=1500;
368
            String[] values = str.split("\t");
393
            String[] values = str.split("\t");
369
            AmazonPromotion amazonPromotion = new AmazonPromotion();
394
            AmazonPromotion amazonPromotion = new AmazonPromotion();
370
            amazonPromotion.setSku(values[0]);
395
            amazonPromotion.setSku(values[0]);
371
            amazonPromotion.setStandardPrice(Double.valueOf(values[1]));
396
            amazonPromotion.setStandardPrice(Double.valueOf(values[1]));
372
            amazonPromotion.setSalePrice(Double.valueOf(values[2]));
397
            amazonPromotion.setSalePrice(Double.valueOf(values[2]));
373
            amazonPromotion.setSubsidyAmount(Double.valueOf(values[3]));
398
            amazonPromotion.setSubsidyAmount(Double.valueOf(values[3]));
374
            Date startDate = dateFormatter.parse(values[4]);
399
            Date startDate = dateFormatter.parse(values[4]);
375
            Date endDate = dateFormatter.parse(values[5]);
400
            Date endDate = dateFormatter.parse(values[5]);
376
            amazonPromotion.setStartDate(startDate.getTime());
401
            amazonPromotion.setStartDate(startDate.getTime());
377
            amazonPromotion.setEndDate(endDate.getTime());
402
            amazonPromotion.setEndDate(endDate.getTime());
378
            amazonPromotion.setPromotionActive(true);
403
            amazonPromotion.setAddedOn(timeNow);
379
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
404
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
380
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
405
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
381
        }
406
        }
382
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
407
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
383
        if (!cc.addAmazonPromotion(amazonPromoMap)){
408
        if (!cc.addAmazonPromotion(amazonPromoMap)){
384
            throw new CatalogServiceException();
409
            throw new CatalogServiceException();
385
        }
410
        }
386
//        if (promotionType.equalsIgnoreCase("LONGTERM")){
-
 
387
//            PromotionFeed pm = new PromotionFeed();
-
 
388
//            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
-
 
389
//            String fPath = pm.CreatePromotionFeed(list);
-
 
390
//            try {
-
 
391
//                logger.info(fPath);
-
 
392
//                pm.SubmitPromotionFeed(fPath);
-
 
393
//            } catch (InterruptedException e) {
-
 
394
//                // TODO Auto-generated catch block
-
 
395
//                e.printStackTrace();
-
 
396
//            } catch (MarketplaceWebServiceException e) {
-
 
397
//                // TODO Auto-generated catch block
-
 
398
//                e.printStackTrace();
-
 
399
//            }
-
 
400
//        }
-
 
401
    }
-
 
402
 
-
 
403
 
411
 
-
 
412
        if (promotionType.equalsIgnoreCase("LONGTERM")){
-
 
413
            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
-
 
414
            PromotionFeed pm = new PromotionFeed(list);
-
 
415
            pm.start();
-
 
416
        }
-
 
417
    }
404
 
418
 
405
    private void changeItemInventory() throws NumberFormatException, TException {
419
    private void changeItemInventory() throws NumberFormatException, TException {
406
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
420
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
407
 
421
 
408
        if (StringUtils.isEmpty(holdInventory)) {
422
        if (StringUtils.isEmpty(holdInventory)) {
Line 459... Line 473...
459
    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
473
    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
460
        LogisticsClient logisticsClient = new LogisticsClient();
474
        LogisticsClient logisticsClient = new LogisticsClient();
461
        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
475
        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
462
    }
476
    }
463
    
477
    
464
//      public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
478
      public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
465
//          return 0l;
479
          return 0l;
466
//    }
480
    }
467
    
481
    
468
    
482
    
469
    public double getWanlcForItem(String itemId){
483
    public double getWanlcForItem(String itemId){
470
        InventoryClient inventoryServiceClient;
484
        InventoryClient inventoryServiceClient;
471
        try {
485
        try {
Line 826... Line 840...
826
        } catch (IOException e) {
840
        } catch (IOException e) {
827
            System.out.println("Unable to stream the manifest file");
841
            System.out.println("Unable to stream the manifest file");
828
        }   
842
        }   
829
    }
843
    }
830
 
844
 
831
 
-
 
832
 
-
 
833
 
-
 
834
    public boolean checkEmptyString(Cell cell){
845
    public boolean checkEmptyString(Cell cell){
835
        if (cell==null){
846
        if (cell==null){
836
            return true;
847
            return true;
837
        }
848
        }
838
        return false;
849
        return false;
Line 1222... Line 1233...
1222
 
1233
 
1223
    public void setExceptionalWanlc(String exceptionalWanlc) {
1234
    public void setExceptionalWanlc(String exceptionalWanlc) {
1224
        this.exceptionalWanlc = exceptionalWanlc;
1235
        this.exceptionalWanlc = exceptionalWanlc;
1225
    }
1236
    }
1226
 
1237
 
-
 
1238
    public void setFbaPromotionActive(boolean isFbaPromotionActive) {
-
 
1239
        this.isFbaPromotionActive = isFbaPromotionActive;
-
 
1240
    }
-
 
1241
 
-
 
1242
    public boolean isFbaPromotionActive() {
-
 
1243
        return isFbaPromotionActive;
-
 
1244
    }
-
 
1245
 
-
 
1246
    public void setFbbPromotionActive(boolean isFbbPromotionActive) {
-
 
1247
        this.isFbbPromotionActive = isFbbPromotionActive;
-
 
1248
    }
-
 
1249
 
-
 
1250
    public boolean isFbbPromotionActive() {
-
 
1251
        return isFbbPromotionActive;
-
 
1252
    }
-
 
1253
 
-
 
1254
    public void setFbaPromoPrice(String fbaPromoPrice) {
-
 
1255
        this.fbaPromoPrice = fbaPromoPrice;
-
 
1256
    }
-
 
1257
 
-
 
1258
    public String getFbaPromoPrice() {
-
 
1259
        return fbaPromoPrice;
-
 
1260
    }
-
 
1261
 
-
 
1262
    public void setFbbPromoPrice(String fbbPromoPrice) {
-
 
1263
        this.fbbPromoPrice = fbbPromoPrice;
-
 
1264
    }
-
 
1265
 
-
 
1266
    public String getFbbPromoPrice() {
-
 
1267
        return fbbPromoPrice;
-
 
1268
    }
-
 
1269
 
-
 
1270
    public void setPromoItemId(String promoItemId) {
-
 
1271
        this.promoItemId = promoItemId;
-
 
1272
    }
-
 
1273
 
-
 
1274
    public String getPromoItemId() {
-
 
1275
        return promoItemId;
-
 
1276
    }
-
 
1277
 
1227
}
1278
}