| Line 72... |
Line 72... |
| 72 |
if(cartId != -1){
|
72 |
if(cartId != -1){
|
| 73 |
try {
|
73 |
try {
|
| 74 |
UserContextService.Client userClient = (new UserClient()).getClient();
|
74 |
UserContextService.Client userClient = (new UserClient()).getClient();
|
| 75 |
Cart cart = userClient.getCurrentCart(userinfo.getUserId());
|
75 |
Cart cart = userClient.getCurrentCart(userinfo.getUserId());
|
| 76 |
cartId = cart.getId();
|
76 |
cartId = cart.getId();
|
| 77 |
List<String> cartResponse = userClient.validateCart(cartId, sourceId);
|
77 |
List<String> cartResponse = userClient.validateCart(cartId, -1);
|
| 78 |
errorMsg = cartResponse.get(0);
|
78 |
errorMsg = cartResponse.get(0);
|
| 79 |
if(StringUtils.isNotEmpty(cartResponse.get(1))) {
|
79 |
if(StringUtils.isNotEmpty(cartResponse.get(1))) {
|
| 80 |
addActionMessage(cartResponse.get(1));
|
80 |
addActionMessage(cartResponse.get(1));
|
| 81 |
}
|
81 |
}
|
| 82 |
log.info("Cart Change/EMI Message rcvd from the service is:" + errorMsg);
|
82 |
log.info("Cart Change/EMI Message rcvd from the service is:" + errorMsg);
|
| Line 123... |
Line 123... |
| 123 |
cartId = userClient.getUserById(userId).getActiveCartId();
|
123 |
cartId = userClient.getUserById(userId).getActiveCartId();
|
| 124 |
}
|
124 |
}
|
| 125 |
// If we add multiple items to cart and get some message from service,
|
125 |
// If we add multiple items to cart and get some message from service,
|
| 126 |
// first message to be preserved and presented to the user.
|
126 |
// first message to be preserved and presented to the user.
|
| 127 |
if(cartMsg.equals("")){
|
127 |
if(cartMsg.equals("")){
|
| 128 |
cartMsg = userClient.addItemToCart(cartId, itemId, 1, sourceId);
|
128 |
cartMsg = userClient.addItemToCart(cartId, itemId, 1, -1);
|
| 129 |
}else{
|
129 |
}else{
|
| 130 |
userClient.addItemToCart(cartId, itemId, 1, sourceId);
|
130 |
userClient.addItemToCart(cartId, itemId, 1, -1);
|
| 131 |
}
|
131 |
}
|
| 132 |
int totalItems = userClient.getCart(cartId).getLinesSize();
|
132 |
int totalItems = userClient.getCart(cartId).getLinesSize();
|
| 133 |
} catch (TException e) {
|
133 |
} catch (TException e) {
|
| 134 |
log.error("Unable to create or add to cart because of: ", e);
|
134 |
log.error("Unable to create or add to cart because of: ", e);
|
| 135 |
} catch (Exception e) {
|
135 |
} catch (Exception e) {
|
| Line 202... |
Line 202... |
| 202 |
private boolean updateItemQuantityInCart(long cartId, long itemId, long quantity){
|
202 |
private boolean updateItemQuantityInCart(long cartId, long itemId, long quantity){
|
| 203 |
try {
|
203 |
try {
|
| 204 |
UserClient userContextServiceClient = new UserClient();
|
204 |
UserClient userContextServiceClient = new UserClient();
|
| 205 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
205 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
| 206 |
|
206 |
|
| 207 |
userClient.addItemToCart(cartId, itemId, quantity, sourceId);
|
207 |
userClient.addItemToCart(cartId, itemId, quantity, -1);
|
| 208 |
return true;
|
208 |
return true;
|
| 209 |
} catch (ShoppingCartException e) {
|
209 |
} catch (ShoppingCartException e) {
|
| 210 |
log.error("Unable to update the item quantity in the cart: ", e);
|
210 |
log.error("Unable to update the item quantity in the cart: ", e);
|
| 211 |
} catch (TException e) {
|
211 |
} catch (TException e) {
|
| 212 |
log.error("Unable to update the item quantity in the cart: ", e);
|
212 |
log.error("Unable to update the item quantity in the cart: ", e);
|
| Line 277... |
Line 277... |
| 277 |
//
|
277 |
//
|
| 278 |
// for (Line line : lineItems) {
|
278 |
// for (Line line : lineItems) {
|
| 279 |
// Map<String, String> itemdetail = new HashMap<String, String>();
|
279 |
// Map<String, String> itemdetail = new HashMap<String, String>();
|
| 280 |
//
|
280 |
//
|
| 281 |
// double insuranceAmount = 0;
|
281 |
// double insuranceAmount = 0;
|
| 282 |
// Item item = catalogClient.getItemForSource(line.getItemId(), sourceId);
|
282 |
// Item item = catalogClient.getItemForSource(line.getItemId(), -1);
|
| 283 |
// Insurer insurer = null;
|
283 |
// Insurer insurer = null;
|
| 284 |
//
|
284 |
//
|
| 285 |
// if(line.getInsurer() != 0) {
|
285 |
// if(line.getInsurer() != 0) {
|
| 286 |
// insuranceAmount = catalogClient.getInsuranceAmount(item.getId(),
|
286 |
// insuranceAmount = catalogClient.getInsuranceAmount(item.getId(),
|
| 287 |
// (line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
|
287 |
// (line.getDiscountedPrice() == 0 ? line.getActualPrice() : line.getDiscountedPrice()),
|
| Line 398... |
Line 398... |
| 398 |
CatalogClient csc;
|
398 |
CatalogClient csc;
|
| 399 |
try {
|
399 |
try {
|
| 400 |
csc = new CatalogClient();
|
400 |
csc = new CatalogClient();
|
| 401 |
List<Long> similarItems = csc.getClient().getSimilarItemsCatalogIds(0, 4, itemId);
|
401 |
List<Long> similarItems = csc.getClient().getSimilarItemsCatalogIds(0, 4, itemId);
|
| 402 |
for(Long catalogId: similarItems){
|
402 |
for(Long catalogId: similarItems){
|
| 403 |
snippets = snippets + ContentServingService.getSnippet(SnippetType.WIDGET_SNIPPET, catalogId+"", sourceId);
|
403 |
snippets = snippets + ContentServingService.getSnippet(SnippetType.WIDGET_SNIPPET, catalogId+"", -1);
|
| 404 |
}
|
404 |
}
|
| 405 |
} catch (Exception e) {
|
405 |
} catch (Exception e) {
|
| 406 |
log.error("Unable to initialise Catalogservice Client");
|
406 |
log.error("Unable to initialise Catalogservice Client");
|
| 407 |
}
|
407 |
}
|
| 408 |
return snippets;
|
408 |
return snippets;
|