Subversion Repositories SmartDukaan

Rev

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

Rev 3599 Rev 3830
Line 69... Line 69...
69
    			UserContextService.Client userClient = (new UserClient()).getClient();
69
    			UserContextService.Client userClient = (new UserClient()).getClient();
70
    			errorMsg = userClient.validateCart(cartId, sourceId);
70
    			errorMsg = userClient.validateCart(cartId, sourceId);
71
    			log.info("Error Message rcvd from the service is:" + errorMsg);
71
    			log.info("Error Message rcvd from the service is:" + errorMsg);
72
    			
72
    			
73
    			// As per ticket #119 in trac
73
    			// As per ticket #119 in trac
-
 
74
    			Cart cart = userClient.getCart(cartId);
74
    			int totalItems = userClient.getCart(cartId).getLinesSize();
75
    			int totalItems = cart.getLinesSize();
-
 
76
    			double totalAmount = cart.getTotalPrice();
75
				userinfo.setTotalItems(totalItems);
77
				userinfo.setTotalItems(totalItems);
-
 
78
				userinfo.setTotalAmount(totalAmount);
76
    		} catch (Exception e) {
79
    		} catch (Exception e) {
77
    			// This exception can be ignored for showing the cart. Not so
80
    			// This exception can be ignored for showing the cart. Not so
78
    			// innocent when this occurs at the time of checkout or when the
81
    			// innocent when this occurs at the time of checkout or when the
79
    			// user is proceeding to pay.
82
    			// user is proceeding to pay.
80
    		    log.warn("Unable to validate the cart: ", e);
83
    		    log.warn("Unable to validate the cart: ", e);
Line 148... Line 151...
148
			if(userinfo.getCartId() == -1){
151
			if(userinfo.getCartId() == -1){
149
				log.info("Cart does not exist. Nothing to delete.");
152
				log.info("Cart does not exist. Nothing to delete.");
150
			}else{
153
			}else{
151
				if(deleteItemFromCart(userinfo.getCartId(), itemId, userinfo.getUserId(), userinfo.isSessionId()))
154
				if(deleteItemFromCart(userinfo.getCartId(), itemId, userinfo.getUserId(), userinfo.isSessionId()))
152
				{
155
				{
153
					userinfo.setTotalItems(getNumberOfItemsInCart(userinfo.getCartId()));
156
					updateUserSessionInfo(userinfo.getCartId());
154
                DataLogger.logData(EventType.DELETE_FROM_CART, getSessionId(),
157
                DataLogger.logData(EventType.DELETE_FROM_CART, getSessionId(),
155
                        userinfo.getUserId(), userinfo.getEmail(),
158
                        userinfo.getUserId(), userinfo.getEmail(),
156
                        Long.toString(userinfo.getCartId()), itemIdString);
159
                        Long.toString(userinfo.getCartId()), itemIdString);
157
					return "redirect";	
160
					return "redirect";	
158
				}
161
				}
Line 230... Line 233...
230
		}
233
		}
231
		
234
		
232
		return false;
235
		return false;
233
	}
236
	}
234
 
237
 
235
	private int getNumberOfItemsInCart(long cartId) {
238
	private void updateUserSessionInfo(long cartId) {
236
		int numberOfItems = 0;
-
 
237
		UserClient userContextServiceClient = null;
239
		UserClient userContextServiceClient = null;
238
		try {
240
		try {
239
			userContextServiceClient = new UserClient();
241
			userContextServiceClient = new UserClient();
240
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
242
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
241
 
-
 
242
			numberOfItems = userClient.getCart(cartId).getLinesSize();
243
			Cart cart = userClient.getCart(cartId);
-
 
244
			userinfo.setTotalItems(cart.getLinesSize());
-
 
245
			userinfo.setTotalAmount(cart.getTotalPrice());
243
		} catch (ShoppingCartException e) {
246
		} catch (ShoppingCartException e) {
244
		    log.error("Unable to get the cart from service: ", e);
247
		    log.error("Unable to get the cart from service: ", e);
245
		} catch (TException e) {
248
		} catch (TException e) {
246
		    log.error("Unable to get the cart from service: ", e);
249
		    log.error("Unable to get the cart from service: ", e);
247
		} catch (Exception e) {
250
		} catch (Exception e) {
248
		    log.error("Unable to get the cart from service: ", e);
251
		    log.error("Unable to get the cart from service: ", e);
249
		}
252
		}
250
		return numberOfItems;
-
 
251
	}
253
	}
252
	
254
	
253
	public List<Map<String,String>> getCartItems() {
255
	public List<Map<String,String>> getCartItems() {
254
	    List<Map<String,String>> items = null;
256
	    List<Map<String,String>> items = null;
255
 
257
 
Line 278... Line 280...
278
                    
280
                    
279
                    Item item = catalogClient.getItemForSource(line.getItemId(), sourceId);
281
                    Item item = catalogClient.getItemForSource(line.getItemId(), sourceId);
280
                    
282
                    
281
                    String itemName = ((item.getBrand() != null) ? item.getBrand() + " " : "")
283
                    String itemName = ((item.getBrand() != null) ? item.getBrand() + " " : "")
282
                                            + ((item.getModelName() != null) ? item.getModelName() + " " : "") 
284
                                            + ((item.getModelName() != null) ? item.getModelName() + " " : "") 
283
                                            + (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" )
285
                                            + (( item.getModelNumber() != null ) ? item.getModelNumber() + " " : "" );
-
 
286
                    
-
 
287
                    String itemColor = "";
284
                                            + (( (item.getColor() != null && !item.getColor().trim().equals("NA"))) ? "("+item.getColor()+")" : "" );
288
                    if(item.getColor() != null && !item.getColor().trim().equals("NA"))
-
 
289
                        itemColor = "Color - " + item.getColor();
285
                    
290
                    
286
                    itemdetail.put("ITEM_NAME", itemName);
291
                    itemdetail.put("ITEM_NAME", itemName);
-
 
292
                    itemdetail.put("ITEM_COLOR", itemColor);
287
                    itemdetail.put("ITEM_ID", line.getItemId() + "");
293
                    itemdetail.put("ITEM_ID", line.getItemId() + "");
288
                    itemdetail.put("CATALOG_ID", item.getCatalogItemId() + "");
294
                    itemdetail.put("CATALOG_ID", item.getCatalogItemId() + "");
289
                    itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity()) + "");
295
                    itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity()) + "");
290
                    itemdetail.put("MRP", formattingUtils.formatPrice(item.getMrp()));
296
                    itemdetail.put("MRP", formattingUtils.formatPrice(item.getMrp()));
291
                    itemdetail.put("SELLING_PRICE", formattingUtils.formatPrice(item.getSellingPrice()));
297
                    itemdetail.put("SELLING_PRICE", formattingUtils.formatPrice(item.getSellingPrice()));