| Line 65... |
Line 65... |
| 65 |
@ApiImplicitParams({
|
65 |
@ApiImplicitParams({
|
| 66 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
66 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 67 |
required = true, dataType = "string", paramType = "header")
|
67 |
required = true, dataType = "string", paramType = "header")
|
| 68 |
})
|
68 |
})
|
| 69 |
@ApiOperation(value = "Add items to cart")
|
69 |
@ApiOperation(value = "Add items to cart")
|
| 70 |
public ResponseEntity<?> validateCart(HttpServletRequest request,@RequestBody AddCartRequest cartRequest, @RequestParam(value="pincode", defaultValue="110001") String pincode){
|
70 |
public ResponseEntity<?> validateCart(HttpServletRequest request,@RequestBody AddCartRequest cartRequest, @RequestParam(value="pincode", defaultValue="110001") String pincode) throws Throwable{
|
| 71 |
UserAccounts userAccount = null;
|
71 |
UserAccounts userAccount = null;
|
| 72 |
ValidateCartResponse vc = null;
|
72 |
ValidateCartResponse vc = null;
|
| 73 |
int userId = (int)request.getAttribute("userId");
|
73 |
int userId = (int)request.getAttribute("userId");
|
| 74 |
try {
|
74 |
|
| 75 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.cartId);
|
75 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.cartId);
|
| 76 |
logger.info("UserAccount "+userAccount);
|
76 |
logger.info("UserAccount "+userAccount);
|
| 77 |
} catch (ProfitMandiBusinessException e1) {
|
- |
|
| 78 |
vc = new ValidateCartResponse(null, "Error","Error while getting cart information");
|
- |
|
| 79 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
- |
|
| 80 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 81 |
}
|
- |
|
| 82 |
|
77 |
|
| 83 |
List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
|
78 |
List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
|
| 84 |
CartItems[] cartItems = cartRequest.getCartItems();
|
79 |
CartItems[] cartItems = cartRequest.getCartItems();
|
| 85 |
List<Integer> itemsList = new ArrayList<Integer>();
|
80 |
List<Integer> itemsList = new ArrayList<Integer>();
|
| 86 |
for (CartItems ci: cartItems){
|
81 |
for (CartItems ci: cartItems){
|
| Line 96... |
Line 91... |
| 96 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while updating cart");
|
91 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while updating cart");
|
| 97 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
92 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
| 98 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
93 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 99 |
}
|
94 |
}
|
| 100 |
String cartString=null;
|
95 |
String cartString=null;
|
| 101 |
try {
|
- |
|
| 102 |
cartString = userClient.validateCartNew(Integer.valueOf(userAccount.getAccount_key()), pincode, -1);
|
96 |
cartString = userClient.validateCartNew(Integer.valueOf(userAccount.getAccount_key()), pincode, -1);
|
| 103 |
} catch (Exception e) {
|
- |
|
| 104 |
// TODO Auto-generated catch block
|
- |
|
| 105 |
e.printStackTrace();
|
- |
|
| 106 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while validating cart");
|
- |
|
| 107 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
- |
|
| 108 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 109 |
}
|
- |
|
| 110 |
JSONObject cartObj = new JSONObject(cartString);
|
97 |
JSONObject cartObj = new JSONObject(cartString);
|
| 111 |
JSONArray arr = cartObj.getJSONArray("cartItems");
|
98 |
JSONArray arr = cartObj.getJSONArray("cartItems");
|
| 112 |
int maxEstimate=-2;
|
99 |
int maxEstimate=-2;
|
| 113 |
boolean allSame=true;
|
100 |
boolean allSame=true;
|
| 114 |
int removedCount = 0;
|
101 |
int removedCount = 0;
|