Subversion Repositories SmartDukaan

Rev

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

Rev 17902 Rev 17940
Line 460... Line 460...
460
				userClient = getClient();
460
				userClient = getClient();
461
				if (itemsList.size()==0 || userClient.addItemsToCart(id, itemQuantities, jsonObj.has("couponCode")? jsonObj.getString("couponCode"):null)){
461
				if (itemsList.size()==0 || userClient.addItemsToCart(id, itemQuantities, jsonObj.has("couponCode")? jsonObj.getString("couponCode"):null)){
462
					log.info("Items added to cart Successfully");
462
					log.info("Items added to cart Successfully");
463
					//Now validate cart and provide appropriate response.
463
					//Now validate cart and provide appropriate response.
464
					String cartString = userClient.validateCartNew(id, userinfo.getPincode(), -1);
464
					String cartString = userClient.validateCartNew(id, userinfo.getPincode(), -1);
-
 
465
					//System.out.println("cartString  "  + cartString);
465
					JSONObject cartObj = new JSONObject(cartString);
466
					JSONObject cartObj = new JSONObject(cartString);
466
					JSONArray arr = cartObj.getJSONArray("cartItems");
467
					JSONArray arr = cartObj.getJSONArray("cartItems");
467
					int maxEstimate=-1;
468
					int maxEstimate=-2;
468
					boolean allSame=true;
469
					boolean allSame=true;
469
					int removedCount = 0;
470
					int removedCount = 0;
470
					cartObj.put("cartMessagesMerged", 0);
471
					cartObj.put("cartMessagesMerged", 0);
471
					for (int j=0; j<arr.length(); j++){
472
					for (int j=0; j<arr.length(); j++){
472
						JSONObject itemObj = arr.getJSONObject(j-removedCount);
473
						JSONObject itemObj = arr.getJSONObject(j-removedCount);
Line 491... Line 492...
491
									cartObj.put("cartMessagesMerged", cartObj.getInt("cartMessagesMerged") + 1);
492
									cartObj.put("cartMessagesMerged", cartObj.getInt("cartMessagesMerged") + 1);
492
								}
493
								}
493
							 }
494
							 }
494
						}
495
						}
495
						ProductPojo pp = PojoPopulator.getShortContent(itemObj.getLong("catalogItemId"));
496
						ProductPojo pp = PojoPopulator.getShortContent(itemObj.getLong("catalogItemId"));
-
 
497
						if(itemObj.has("estimate")){
496
						if(allSame){
498
							if(allSame){
497
							allSame = maxEstimate==-1 || maxEstimate==itemObj.getInt("estimate");
499
								allSame = maxEstimate==-2 || maxEstimate==itemObj.getInt("estimate");
498
						}
500
							}
499
						if(itemObj.has("estimate") && itemObj.getInt("estimate") > maxEstimate){
501
							if(itemObj.getInt("estimate") > maxEstimate){
500
							maxEstimate = itemObj.getInt("estimate");
502
								maxEstimate = itemObj.getInt("estimate");
-
 
503
							}
501
						}
504
						}
502
						itemObj.put("imageUrl", pp.getImageUrl());
505
						itemObj.put("imageUrl", pp.getImageUrl());
503
						itemObj.put("title", pp.getTitle());
506
						itemObj.put("title", pp.getTitle());
504
					}
507
					}
505
					
508