Subversion Repositories SmartDukaan

Rev

Rev 839 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 839 Rev 894
Line 27... Line 27...
27
 
27
 
28
public class Utils {
28
public class Utils {
29
	//FIXME: Read this path from the config server
29
	//FIXME: Read this path from the config server
30
	public static final String EXPORT_ENTITIES_PATH =	"/var/lib/tomcat6/webapps/export/html/entities/";
30
	public static final String EXPORT_ENTITIES_PATH =	"/var/lib/tomcat6/webapps/export/html/entities/";
31
		
31
		
32
	public static double getPaymentAmount(long cartId){
-
 
33
		double totalAmount = 0;
-
 
34
		
-
 
35
		Cart cart;
-
 
36
		try {
-
 
37
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
-
 
38
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
39
 
-
 
40
			cart = userClient.getCart(cartId);
-
 
41
		
-
 
42
			List<Line> lineItems = cart.getLines(); 
-
 
43
		
-
 
44
			for (Line line : lineItems) {
-
 
45
				long productId = line.getItemId();
-
 
46
				totalAmount =  totalAmount + line.getQuantity() * Utils.getItemPrice(productId);
-
 
47
			}
-
 
48
 
-
 
49
		} catch (ShoppingCartException e) {
-
 
50
			e.printStackTrace();
-
 
51
		} catch (TException e) {
-
 
52
			e.printStackTrace();
-
 
53
		} catch (Exception e) {
-
 
54
			e.printStackTrace();
-
 
55
		}
-
 
56
 
-
 
57
		return totalAmount;
-
 
58
	}
-
 
59
	
32
	
60
	public static double getItemPrice(long itemId){
33
	public static double getItemPrice(long itemId){
61
		CatalogServiceClient catalogServiceClient = null;
34
		CatalogServiceClient catalogServiceClient = null;
62
		Client client = null;
35
		Client client = null;
63
		Double itemPrice = 0.0;
36
		Double itemPrice = 0.0;