Subversion Repositories SmartDukaan

Rev

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

Rev 3903 Rev 3970
Line 40... Line 40...
40
	
40
	
41
	private static final long serialVersionUID = 1L;
41
	private static final long serialVersionUID = 1L;
42
	private static Logger log = Logger.getLogger(Class.class);
42
	private static Logger log = Logger.getLogger(Class.class);
43
	Map<String, String[]> reqparams = null;
43
	Map<String, String[]> reqparams = null;
44
 
44
 
-
 
45
	private String id = "0";
45
    private String totalamount;
46
    private String totalamount;
46
	
47
	
47
	private String errorMsg = "";
48
	private String errorMsg = "";
48
	private String cartMsg = ""; 
49
	private String cartMsg = "";
49
	
50
	
50
	private String pincode = "110001";
51
	private String pincode = "110001";
51
	
52
	
52
	private String couponCode = null;
53
	private String couponCode = null;
53
	
54
	
Line 61... Line 62...
61
	
62
	
62
	 // GET /cart
63
	 // GET /cart
63
 
64
 
64
	@Action(value="cart",interceptorRefs={@InterceptorRef("myDefault")})
65
	@Action(value="cart",interceptorRefs={@InterceptorRef("myDefault")})
65
	 public String index() {
66
	 public String index() {
66
	    long cartId = userinfo.getCartId();
-
 
67
	    if(cartId != -1){
67
	    populateCartData();
68
        	try {
-
 
69
    			UserContextService.Client userClient = (new UserClient()).getClient();
-
 
70
    			errorMsg = userClient.validateCart(cartId, sourceId);
-
 
71
    			log.info("Error Message rcvd from the service is:" + errorMsg);
-
 
72
    			
-
 
73
    			// As per ticket #119 in trac
-
 
74
    			Cart cart = userClient.getCart(cartId);
-
 
75
    			int totalItems = cart.getLinesSize();
-
 
76
    			double totalAmount = cart.getTotalPrice();
-
 
77
				userinfo.setTotalItems(totalItems);
-
 
78
				userinfo.setTotalAmount(totalAmount);
-
 
79
    		} catch (Exception e) {
-
 
80
    			// This exception can be ignored for showing the cart. Not so
-
 
81
    			// innocent when this occurs at the time of checkout or when the
-
 
82
    			// user is proceeding to pay.
-
 
83
    		    log.warn("Unable to validate the cart: ", e);
-
 
84
    		}
-
 
85
	    }
-
 
86
    	return "index";
68
    	return "index";
87
	 }
69
	 }
-
 
70
	
-
 
71
	//GET /cart/param
-
 
72
 
-
 
73
	@Action(value="cart",interceptorRefs={@InterceptorRef("myDefault")})
-
 
74
	public String show()	{
-
 
75
	    populateCartData();
-
 
76
		return "index";
-
 
77
	}
-
 
78
	
88
	// POST /entity
79
	// POST /entity
89
 
80
 
90
	@Action(value="addtocart",interceptorRefs={@InterceptorRef("createuser"),@InterceptorRef("myDefault")})
81
	@Action(value="addtocart",interceptorRefs={@InterceptorRef("createuser"),@InterceptorRef("myDefault")})
91
	public String create() {
82
	public String create() {
92
		log.info("CartController.create");
83
		log.info("CartController.create");
Line 189... Line 180...
189
                    Long.toString(userinfo.getCartId()), Long.toString(itemId), Long.toString(quantity));
180
                    Long.toString(userinfo.getCartId()), Long.toString(itemId), Long.toString(quantity));
190
			addActionError("Unable to update the quantity");
181
			addActionError("Unable to update the quantity");
191
			return "redirect";
182
			return "redirect";
192
		}
183
		}
193
		
184
		
-
 
185
 
-
 
186
	private void populateCartData()	{
-
 
187
		long cartId = userinfo.getCartId();
-
 
188
	    if(cartId != -1){
-
 
189
        	try {
-
 
190
    			UserContextService.Client userClient = (new UserClient()).getClient();
-
 
191
    			errorMsg = userClient.validateCart(cartId, sourceId);
-
 
192
    			log.info("Error Message rcvd from the service is:" + errorMsg);
-
 
193
    			
-
 
194
    			// As per ticket #119 in trac
-
 
195
    			Cart cart = userClient.getCart(cartId);
-
 
196
    			int totalItems = cart.getLinesSize();
-
 
197
    			double totalAmount = cart.getTotalPrice();
-
 
198
				userinfo.setTotalItems(totalItems);
-
 
199
				userinfo.setTotalAmount(totalAmount);
-
 
200
    		} catch (Exception e) {
-
 
201
    			// This exception can be ignored for showing the cart. Not so
-
 
202
    			// innocent when this occurs at the time of checkout or when the
-
 
203
    			// user is proceeding to pay.
-
 
204
    		    log.warn("Unable to validate the cart: ", e);
-
 
205
    		}
-
 
206
	    }
194
		
207
	}
-
 
208
	
195
    public void printParams(){
209
    public void printParams(){
196
    	for(String param : reqparams.keySet()) {
210
    	for(String param : reqparams.keySet()) {
197
    		log.info("param name is " + param);
211
    		log.info("param name is " + param);
198
    		log.info("param first is " + reqparams.get(param)[0]);
212
    		log.info("param first is " + reqparams.get(param)[0]);
199
    	}
213
    	}
Line 376... Line 390...
376
			url = "?" + url;
390
			url = "?" + url;
377
		}
391
		}
378
		url = request.getRequestURI() + url;
392
		url = request.getRequestURI() + url;
379
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getNameOfUser(), url , 0, false);
393
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getNameOfUser(), url , 0, false);
380
	}
394
	}
-
 
395
	
-
 
396
	public void setId(String id)	{
-
 
397
		this.id = id;
-
 
398
	}
-
 
399
	
-
 
400
	public String getId()	{
-
 
401
		return this.id;
-
 
402
	}
381
}
403
}
382
404