Subversion Repositories SmartDukaan

Rev

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

Rev 1386 Rev 1429
Line 732... Line 732...
732
		String templateFile = "templates/myaccountheader.vm";
732
		String templateFile = "templates/myaccountheader.vm";
733
		htmlString = getHtmlFromVelocity(templateFile, context);
733
		htmlString = getHtmlFromVelocity(templateFile, context);
734
		return htmlString;
734
		return htmlString;
735
	}
735
	}
736
 
736
 
737
	public String getShippingHeaderHtml() {
-
 
738
		String htmlString = "";
-
 
739
		VelocityContext context = new VelocityContext();
-
 
740
		String templateFile = "templates/shippingheader.vm";
-
 
741
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
742
		return htmlString;
-
 
743
	}
-
 
744
 
737
 
745
	public String getShippingAddressDetailsHtml(long userId, String errorMsg){
738
	public String getShippingAddressDetailsHtml(long userId, String errorMsg){
746
		String htmlString = "";
739
		String htmlString = "";
747
		VelocityContext context = new VelocityContext();
740
		VelocityContext context = new VelocityContext();
748
		String templateFile = "templates/shippingaddressdetails.vm";
741
		String templateFile = "templates/shippingaddressdetails.vm";
Line 765... Line 758...
765
		context.put("errorMsg", errorMsg);
758
		context.put("errorMsg", errorMsg);
766
		
759
		
767
		htmlString = getHtmlFromVelocity(templateFile, context);
760
		htmlString = getHtmlFromVelocity(templateFile, context);
768
		return htmlString;
761
		return htmlString;
769
	}
762
	}
770
 
-
 
771
	public String getShippingDetailsHtml(long cartId, String errorMsg) {
-
 
772
		String htmlString = "";
-
 
773
		VelocityContext context = new VelocityContext();
-
 
774
		String templateFile = "templates/shippingdetails.vm";
-
 
775
		List<Map<String,String>> items = null;
-
 
776
		double totalamount= 0.0;
-
 
777
		List<Address> addresses = null;
-
 
778
		long defaultAddressId = 0;
-
 
779
 
-
 
780
		CatalogServiceClient catalogServiceClient  = null;
-
 
781
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
-
 
782
		UserContextServiceClient userContextServiceClient = null;
-
 
783
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
-
 
784
		
-
 
785
		try {
-
 
786
			catalogServiceClient = new CatalogServiceClient();
-
 
787
			catalogClient = catalogServiceClient.getClient();
-
 
788
			userContextServiceClient = new UserContextServiceClient();
-
 
789
			userClient = userContextServiceClient.getClient();
-
 
790
			
-
 
791
			
-
 
792
			Cart cart = userClient.getCart(cartId);
-
 
793
			List<Line> lineItems = cart.getLines();
-
 
794
			
-
 
795
			if( ! lineItems.isEmpty())
-
 
796
			{
-
 
797
				items = new ArrayList<Map<String,String>>();
-
 
798
				
-
 
799
				for (Line line : lineItems) {
-
 
800
					Map<String, String> itemdetail = new HashMap<String, String>();
-
 
801
					Item item = catalogClient.getItem(line.getItemId());
-
 
802
					String itemName = ((item.getBrand() != null) ? item.getBrand() + " " : "")
-
 
803
										+ ((item.getModelName() != null) ? item.getModelName() + " " : "") 
-
 
804
										+ (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" )
-
 
805
										+ (( (item.getColor() != null && !item.getColor().trim().equals("NA"))) ? "("+item.getColor()+")" : "" );
-
 
806
					
-
 
807
					itemdetail.put("ITEM_NAME", itemName);
-
 
808
					itemdetail.put("ITEM_ID", line.getItemId()+"");
-
 
809
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
-
 
810
					itemdetail.put("MRP", ((int)item.getMrp())+"");
-
 
811
					itemdetail.put("SELLING_PRICE", (int)item.getSellingPrice()+"");
-
 
812
					itemdetail.put("TOTAL_PRICE", (int)(item.getSellingPrice()*line.getQuantity())+"");
-
 
813
					itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
-
 
814
					totalamount = totalamount + line.getQuantity()*item.getSellingPrice();
-
 
815
					items.add(itemdetail);				
-
 
816
				}
-
 
817
			}
-
 
818
			
-
 
819
			addresses = userClient.getAllAddressesForUser(cart.getUserId());
-
 
820
			if(cart.isSetAddressId()){
-
 
821
				defaultAddressId = cart.getAddressId();
-
 
822
			}else{
-
 
823
				defaultAddressId = userClient.getDefaultAddressId(cart.getUserId());
-
 
824
			}
-
 
825
			
-
 
826
		}catch (Exception e){
-
 
827
			e.printStackTrace();
-
 
828
		}
-
 
829
		
-
 
830
		context.put("items", items);
-
 
831
		context.put("totalamount", (int)totalamount+"");
-
 
832
		context.put("addresses", addresses);
-
 
833
		context.put("defaultAddressId", defaultAddressId+"");
-
 
834
		context.put("errorMsg", errorMsg);
-
 
835
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
836
		return htmlString;
-
 
837
	}
-
 
838
 
-
 
839
	
763
	
840
	public String getCartHeaderHtml() {
764
	public String getCartHeaderHtml() {
841
		String htmlString = "";
765
		String htmlString = "";
842
		VelocityContext context = new VelocityContext();
766
		VelocityContext context = new VelocityContext();
843
		String templateFile = "templates/cartheader.vm";
767
		String templateFile = "templates/cartheader.vm";
Line 941... Line 865...
941
				e.printStackTrace();
865
				e.printStackTrace();
942
			}
866
			}
943
	
867
	
944
		return null;
868
		return null;
945
	}
869
	}
946
}
870
}
947
 
-
 
948
871