Subversion Repositories SmartDukaan

Rev

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

Rev 2810 Rev 2944
Line 71... Line 71...
71
			errorMsg = userClient.validateCart(userinfo.getCartId());
71
			errorMsg = userClient.validateCart(userinfo.getCartId());
72
		} catch (Exception e) {
72
		} catch (Exception e) {
73
			// This exception can be ignored for showing the cart. Not so
73
			// This exception can be ignored for showing the cart. Not so
74
			// innocent when this occurs at the time of checkout or when the
74
			// innocent when this occurs at the time of checkout or when the
75
			// user is proceeding to pay.
75
			// user is proceeding to pay.
76
			e.printStackTrace();
76
		    log.warn("Unable to validate the cart: ", e);
77
		}
77
		}
78
    	return "index";
78
    	return "index";
79
	 }
79
	 }
80
	// POST /entity
80
	// POST /entity
81
 
81
 
Line 117... Line 117...
117
			    }
117
			    }
118
				userinfo.setCartId(cartId);
118
				userinfo.setCartId(cartId);
119
				int totalItems = userClient.getCart(cartId).getLinesSize();
119
				int totalItems = userClient.getCart(cartId).getLinesSize();
120
				userinfo.setTotalItems(totalItems);
120
				userinfo.setTotalItems(totalItems);
121
			} catch (TException e) {
121
			} catch (TException e) {
122
				e.printStackTrace();
122
			    log.error("Unable to create or add to cart because of: ", e);
123
			} catch (Exception e) {
123
			} catch (Exception e) {
124
				e.printStackTrace();
124
			    log.error("Unable to create or add to cart because of: ", e);
125
			}
125
			}
126
 
126
 
127
		}
127
		}
128
        DataLogger.logData(EventType.ADD_TO_CART, session.getId(), userinfo.getUserId(), userinfo.getEmail(),
128
        DataLogger.logData(EventType.ADD_TO_CART, session.getId(), userinfo.getUserId(), userinfo.getEmail(),
129
                Long.toString(cartId), itemIds);
129
                Long.toString(cartId), itemIds);
Line 196... Line 196...
196
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
196
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
197
 
197
 
198
			userClient.changeQuantity(cartId, itemId, quantity);
198
			userClient.changeQuantity(cartId, itemId, quantity);
199
			return true;
199
			return true;
200
		} catch (ShoppingCartException e) {
200
		} catch (ShoppingCartException e) {
201
			e.printStackTrace();
201
		    log.error("Unable to update the item quantity in the cart: ", e);
202
		} catch (TException e) {
202
		} catch (TException e) {
203
			e.printStackTrace();
203
		    log.error("Unable to update the item quantity in the cart: ", e);
204
		} catch (Exception e) {
204
		} catch (Exception e) {
205
			e.printStackTrace();
205
		    log.error("Unable to update the item quantity in the cart: ", e);
206
		}
206
		}
207
		return false;
207
		return false;
208
	}
208
	}
209
	
209
	
210
	private boolean deleteItemFromCart(long cartId, long catalogItemId, long userId, boolean isSessionId){
210
	private boolean deleteItemFromCart(long cartId, long catalogItemId, long userId, boolean isSessionId){
Line 213... Line 213...
213
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
213
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
214
 
214
 
215
			userClient.deleteItemFromCart(cartId, catalogItemId);
215
			userClient.deleteItemFromCart(cartId, catalogItemId);
216
			return true;	
216
			return true;	
217
		} catch (ShoppingCartException e) {
217
		} catch (ShoppingCartException e) {
218
			e.printStackTrace();
218
		    log.error("Unable to delete item from cart: ", e);
219
		} catch (TException e) {
219
		} catch (TException e) {
220
			e.printStackTrace();
220
		    log.error("Unable to delete item from cart: ", e);
221
		} catch (Exception e) {
221
		} catch (Exception e) {
222
			e.printStackTrace();
222
		    log.error("Unable to delete item from cart: ", e);
223
		}
223
		}
224
		
224
		
225
		return false;
225
		return false;
226
	}
226
	}
227
 
227
 
Line 232... Line 232...
232
			userContextServiceClient = new UserContextServiceClient();
232
			userContextServiceClient = new UserContextServiceClient();
233
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
233
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
234
 
234
 
235
			numberOfItems = userClient.getCart(cartId).getLinesSize();
235
			numberOfItems = userClient.getCart(cartId).getLinesSize();
236
		} catch (ShoppingCartException e) {
236
		} catch (ShoppingCartException e) {
237
			e.printStackTrace();
237
		    log.error("Unable to get the cart from service: ", e);
238
		} catch (TException e) {
238
		} catch (TException e) {
239
			e.printStackTrace();
239
		    log.error("Unable to get the cart from service: ", e);
240
		} catch (Exception e) {
240
		} catch (Exception e) {
241
			e.printStackTrace();
241
		    log.error("Unable to get the cart from service: ", e);
242
		}
242
		}
243
		return numberOfItems;
243
		return numberOfItems;
244
	}
244
	}
245
	
245
	
246
	public List<Map<String,String>> getCartItems() {
246
	public List<Map<String,String>> getCartItems() {
Line 290... Line 290...
290
            
290
            
291
            totalamount = formattingUtils.formatPrice(cart.getTotalPrice());
291
            totalamount = formattingUtils.formatPrice(cart.getTotalPrice());
292
            couponCode = cart.getCouponCode() == null ? "" : cart.getCouponCode();
292
            couponCode = cart.getCouponCode() == null ? "" : cart.getCouponCode();
293
            discountedAmount = formattingUtils.formatPrice(cart.getDiscountedPrice());
293
            discountedAmount = formattingUtils.formatPrice(cart.getDiscountedPrice());
294
        } catch (Exception e)  {
294
        } catch (Exception e)  {
295
            e.printStackTrace();
295
            log.error("Unable to get the cart details becasue of: ", e);
296
        }
296
        }
297
        return items;
297
        return items;
298
	}
298
	}
299
 
299
 
300
	public String getTotalAmount() {
300
	public String getTotalAmount() {