Subversion Repositories SmartDukaan

Rev

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

Rev 1934 Rev 1981
Line 740... Line 740...
740
		context.put("errorMsg", errorMsg);
740
		context.put("errorMsg", errorMsg);
741
		
741
		
742
		htmlString = getHtmlFromVelocity(templateFile, context);
742
		htmlString = getHtmlFromVelocity(templateFile, context);
743
		return htmlString;
743
		return htmlString;
744
	}
744
	}
745
	
-
 
746
	public String getCartHeaderHtml() {
-
 
747
		String htmlString = "";
-
 
748
		VelocityContext context = new VelocityContext();
-
 
749
		String templateFile = "templates/cartheader.vm";
-
 
750
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
751
		return htmlString;
-
 
752
	}
-
 
753
 
-
 
754
 
-
 
755
	public String getCartDetailsHtml(long userId, long cartId, String errorMsg) {
-
 
756
		String htmlString = "";
-
 
757
		VelocityContext context = new VelocityContext();
-
 
758
		String templateFile = "templates/cartdetails.vm";
-
 
759
		List<Map<String,String>> items = null;
-
 
760
		double totalamount= 0.0;
-
 
761
		
-
 
762
		UserContextServiceClient userServiceClient = null;
-
 
763
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
-
 
764
		CatalogServiceClient catalogServiceClient  = null;
-
 
765
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
-
 
766
		String pincode = "110001";
-
 
767
		try {
-
 
768
			catalogServiceClient = new CatalogServiceClient();
-
 
769
			catalogClient = catalogServiceClient.getClient();
-
 
770
			userServiceClient = new UserContextServiceClient();
-
 
771
			userClient = userServiceClient.getClient();
-
 
772
			
-
 
773
			pincode = userClient.getDefaultPincode(userId);
-
 
774
			Cart cart = userClient.getCart(cartId);
-
 
775
			List<Line> lineItems = cart.getLines();
-
 
776
			if(lineItems.size() != 0){
-
 
777
				items = new ArrayList<Map<String,String>>();
-
 
778
				for (Line line : lineItems) {
-
 
779
	
-
 
780
					Map<String, String> itemdetail = new HashMap<String, String>();
-
 
781
					Item item = catalogClient.getItem(line.getItemId());
-
 
782
					
-
 
783
					String itemName = ((item.getBrand() != null) ? item.getBrand() + " " : "")
-
 
784
										+ ((item.getModelName() != null) ? item.getModelName() + " " : "") 
-
 
785
										+ (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" )
-
 
786
										+ (( (item.getColor() != null && !item.getColor().trim().equals("NA"))) ? "("+item.getColor()+")" : "" );
-
 
787
					
-
 
788
					itemdetail.put("ITEM_NAME", itemName);
-
 
789
					System.out.println(itemdetail.get("ITEM_NAME"));
-
 
790
					itemdetail.put("ITEM_ID", line.getItemId()+"");
-
 
791
					itemdetail.put("CATALOG_ID", item.getCatalogItemId()+"");
-
 
792
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
-
 
793
					itemdetail.put("MRP", ((int)item.getMrp())+"");
-
 
794
					itemdetail.put("SELLING_PRICE", ((int)item.getSellingPrice())+"");
-
 
795
					itemdetail.put("TOTAL_PRICE", ((int)((item.getSellingPrice()*line.getQuantity())))+"");
-
 
796
					itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
-
 
797
					totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
-
 
798
					items.add(itemdetail);				
-
 
799
				}
-
 
800
			}
-
 
801
			
-
 
802
		}catch (Exception e){
-
 
803
			e.printStackTrace();
-
 
804
		}
-
 
805
			
-
 
806
		context.put("items", items);
-
 
807
		context.put("totalamount", ((int)totalamount)+"");
-
 
808
		context.put("errorMsg", errorMsg);
-
 
809
		context.put("pincode", pincode);
-
 
810
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
811
		return htmlString;
-
 
812
	}
-
 
813
 
745
 
814
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
746
	public String getHtmlFromVelocity(String templateFile, VelocityContext context){
815
		Properties p = new Properties();
747
		Properties p = new Properties();
816
		p.setProperty("resource.loader", "class");
748
		p.setProperty("resource.loader", "class");
817
		p.setProperty("class.resource.loader.class",
749
		p.setProperty("class.resource.loader.class",