Subversion Repositories SmartDukaan

Rev

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

Rev 9046 Rev 9056
Line 277... Line 277...
277
				else{
277
				else{
278
					sb.append(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
278
					sb.append(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
279
					logger.info(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
279
					logger.info(orderId+" "+subOrderId + " Total Selling Price not set " +"\n");
280
					continue;
280
					continue;
281
				}
281
				}
282
				
282
 
283
				String shipToName,addressLine1,addressLine2,city,state,pincode,buyerName="unknown";
283
				String shipToName,addressLine1,addressLine2,city,state,pincode,buyerName="unknown";
284
				if(nextLine[17].length()>0){
284
				if(nextLine[17].length()>0){
285
					buyerName = nextLine[17];
285
					buyerName = nextLine[17];
286
				}
286
				}
287
				else{
287
				else{
Line 295... Line 295...
295
					sb.append(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
295
					sb.append(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
296
					logger.info(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
296
					logger.info(orderId+" "+subOrderId + " Ship to Name not set " +"\n");
297
					continue;
297
					continue;
298
				}
298
				}
299
				if(buyerName.contains("unknown")){
299
				if(buyerName.contains("unknown")){
300
		    		buyerName = shipToName;
300
					buyerName = shipToName;
301
		    	}
301
				}
302
				if(nextLine[19].length()>0){
302
				if(nextLine[19].length()>0){
303
					addressLine1 = nextLine[19];
303
					addressLine1 = nextLine[19];
304
				}
304
				}
305
				else{
305
				else{
306
					addressLine1 ="";
306
					addressLine1 ="";
Line 428... Line 428...
428
						logger.info("Snapdeal Item id is " + snapdealItem.getItem_id());
428
						logger.info("Snapdeal Item id is " + snapdealItem.getItem_id());
429
						if(snapdealItem.getItem_id()!=0 && snapdealItem.getWarehouseId()!=0) {
429
						if(snapdealItem.getItem_id()!=0 && snapdealItem.getWarehouseId()!=0) {
430
							logger.info("SnapdealItem Warehouse Id " + snapdealItem.getWarehouseId());
430
							logger.info("SnapdealItem Warehouse Id " + snapdealItem.getWarehouseId());
431
							fulfillmentWarehouse = inventoryClient.getWarehouse(snapdealItem.getWarehouseId());
431
							fulfillmentWarehouse = inventoryClient.getWarehouse(snapdealItem.getWarehouseId());
432
							logger.info("fulfillmentWarehouse is " + fulfillmentWarehouse.getId() + " " + fulfillmentWarehouse.getDisplayName() );
432
							logger.info("fulfillmentWarehouse is " + fulfillmentWarehouse.getId() + " " + fulfillmentWarehouse.getDisplayName() );
433
							
433
 
434
						} else {
434
						} else {
435
							List<Long> itemAvailability = inventoryClient.getItemAvailabilityAtLocation(sku, 1);
435
							List<Long> itemAvailability = inventoryClient.getItemAvailabilityAtLocation(sku, 1);
436
							fulfillmentWarehouse = inventoryClient.getWarehouse(itemAvailability.get(0));
436
							fulfillmentWarehouse = inventoryClient.getWarehouse(itemAvailability.get(0));
437
							if(fulfillmentWarehouse.getStateId()!=0){
437
							if(fulfillmentWarehouse.getStateId()!=0){
438
								fulfillmentWarehouse = inventoryClient.getWarehouse(7);
438
								fulfillmentWarehouse = inventoryClient.getWarehouse(7);
Line 444... Line 444...
444
							inventoryClient = new InventoryClient().getClient();
444
							inventoryClient = new InventoryClient().getClient();
445
							List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, fulfillmentWarehouse.getVendor().getId(), 0, 0);
445
							List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, fulfillmentWarehouse.getVendor().getId(), 0, 0);
446
							for(Warehouse warehouse : warehouses) {
446
							for(Warehouse warehouse : warehouses) {
447
								if(warehouse.getBillingWarehouseId()!=0) {
447
								if(warehouse.getBillingWarehouseId()!=0) {
448
									billingWarehouseId = warehouse.getBillingWarehouseId();
448
									billingWarehouseId = warehouse.getBillingWarehouseId();
449
					                break;
449
									break;
450
								}
450
								}
451
							}
451
							}
452
						}else {
452
						}else {
453
							billingWarehouseId = fulfillmentWarehouse.getBillingWarehouseId();
453
							billingWarehouseId = fulfillmentWarehouse.getBillingWarehouseId();
454
						}
454
						}
455
					        
455
 
456
						//logger.info("Billing warehouse id for suborderid  " + order.getSuborderId() + " is " + fulfillmentWarehouse.getBillingWarehouseId());
456
						//logger.info("Billing warehouse id for suborderid  " + order.getSuborderId() + " is " + fulfillmentWarehouse.getBillingWarehouseId());
457
						t_order.setWarehouse_id(billingWarehouseId);
457
						t_order.setWarehouse_id(billingWarehouseId);
458
						VendorItemPricing vendorItemPricing = new VendorItemPricing();
458
						VendorItemPricing vendorItemPricing = new VendorItemPricing();
459
						if(fulfillmentWarehouse.getId()==7) {
459
						if(fulfillmentWarehouse.getId()==7) {
460
							Item item = new CatalogClient().getClient().getItem(lineItem.getItem_id());
460
							Item item = new CatalogClient().getClient().getItem(lineItem.getItem_id());
461
							vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), item.getPreferredVendor());
461
							vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), item.getPreferredVendor());
462
						} else {
462
						} else {
463
							vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), fulfillmentWarehouse.getVendor().getId());
463
							vendorItemPricing = inventoryClient.getItemPricing(lineItem.getItem_id(), fulfillmentWarehouse.getVendor().getId());
464
						}
464
						}
465
						
465
 
466
						t_order.getLineitems().get(0).setTransfer_price(vendorItemPricing.getTransferPrice());
466
						t_order.getLineitems().get(0).setTransfer_price(vendorItemPricing.getTransferPrice());
467
						t_order.getLineitems().get(0).setNlc(vendorItemPricing.getNlc());
467
						t_order.getLineitems().get(0).setNlc(vendorItemPricing.getNlc());
468
					} catch (InventoryServiceException e) {
468
					} catch (InventoryServiceException e) {
469
						logger.error("Error connecting inventory service for suborderid  " + orderId + " " + subOrderId , e);
469
						logger.error("Error connecting inventory service for suborderid  " + orderId + " " + subOrderId , e);
470
						sb.append(orderId + " " + subOrderId+ " Inventory Service Exception" + " " + "\n");
470
						sb.append(orderId + " " + subOrderId+ " Inventory Service Exception" + " " + "\n");
Line 589... Line 589...
589
						continue;
589
						continue;
590
					}
590
					}
591
				}
591
				}
592
			}
592
			}
593
			response.setHeader("Content-Type", "text/javascript");
593
			response.setHeader("Content-Type", "text/javascript");
594
			
594
 
595
			if(orders_processed==1){
595
			if(orders_processed==1){
596
				order_string = "Order";
596
				order_string = "Order";
597
			}
597
			}
598
			else{
598
			else{
599
				order_string = "Orders";
599
				order_string = "Orders";
Line 604... Line 604...
604
				sos = response.getOutputStream();
604
				sos = response.getOutputStream();
605
				if(sb.toString().equalsIgnoreCase("")){
605
				if(sb.toString().equalsIgnoreCase("")){
606
					sos.write((orders_processed + " " + order_string + " Created").toString().getBytes());
606
					sos.write((orders_processed + " " + order_string + " Created").toString().getBytes());
607
				}
607
				}
608
				else{
608
				else{
609
						sos.write((orders_processed +" " + order_string + " Created \n"+ sb.toString()).getBytes());
609
					sos.write((orders_processed +" " + order_string + " Created \n"+ sb.toString()).getBytes());
610
				}
610
				}
611
				sos.flush();
611
				sos.flush();
612
			} catch (IOException e) {
612
			} catch (IOException e) {
613
				System.out.println("Unable to stream the manifest file");
613
				System.out.println("Unable to stream the manifest file");
614
			}   
614
			}   
Line 627... Line 627...
627
		String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
627
		String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
628
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
628
				"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
629
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
629
				"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
630
		try {
630
		try {
631
			logger.info("Before Sending Emails");
631
			logger.info("Before Sending Emails");
632
			
632
 
633
			if(sb.toString().equalsIgnoreCase("")){
633
			if(sb.toString().equalsIgnoreCase("")){
-
 
634
				if(orders_processed!=0){
634
				String emailSubjectTxt = orders_processed + " Flipkart " + order_string + " Created "+sdf.format(cal.getTime());
635
					String emailSubjectTxt = orders_processed + " Flipkart " + order_string + " Created "+sdf.format(cal.getTime());
635
				mailer.sendSSLMessage(sendTo, emailSubjectTxt,"Orders Created Successfully (No Alerts)", emailFromAddress, password, new ArrayList<File>());
636
					mailer.sendSSLMessage(sendTo, emailSubjectTxt,"Orders Created Successfully (No Alerts)", emailFromAddress, password, new ArrayList<File>());
636
				logger.info("Sending Email Flipkart Orders Created Successfully (No Alerts)");
637
					logger.info("Sending Email Flipkart Orders Created Successfully (No Alerts)");
-
 
638
				}
637
			}
639
			}
638
			else{
640
			else{
639
				if(orders_processed!=0){
641
				if(orders_processed!=0){
640
					String emailSubjectTxt = orders_processed + " Flipkart " + order_string + " Created (Check Alerts) "+sdf.format(cal.getTime());
642
					String emailSubjectTxt = orders_processed + " Flipkart " + order_string + " Created (Check Alerts) "+sdf.format(cal.getTime());
641
					mailer.sendSSLMessage(sendTo, emailSubjectTxt,sb.toString(), emailFromAddress, password, new ArrayList<File>());
643
					mailer.sendSSLMessage(sendTo, emailSubjectTxt,sb.toString(), emailFromAddress, password, new ArrayList<File>());
Line 646... Line 648...
646
					mailer.sendSSLMessage(sendTo, emailSubjectTxt,sb.toString(), emailFromAddress, password, new ArrayList<File>());
648
					mailer.sendSSLMessage(sendTo, emailSubjectTxt,sb.toString(), emailFromAddress, password, new ArrayList<File>());
647
					logger.info("Sending Email Flipkart Orders Created Successfully (Check Alerts)");
649
					logger.info("Sending Email Flipkart Orders Created Successfully (Check Alerts)");
648
				}
650
				}
649
			}
651
			}
650
 
652
 
651
			}
653
		}
652
			catch (Exception e) {
654
		catch (Exception e) {
653
				e.printStackTrace();
655
			e.printStackTrace();
654
				logger.error("Exception ",e);
656
			logger.error("Exception ",e);
655
			}
657
		}
656
	}
658
	}
657
 
659
 
658
	public static Logger getLogger() {
660
	public static Logger getLogger() {
659
		return logger;
661
		return logger;
660
	}
662
	}