| Line 26... |
Line 26... |
| 26 |
|
26 |
|
| 27 |
import com.google.gson.Gson;
|
27 |
import com.google.gson.Gson;
|
| 28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
28 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 29 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
29 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 30 |
import com.spice.profitmandi.common.services.ContentPojoPopulator;
|
30 |
import com.spice.profitmandi.common.services.ContentPojoPopulator;
|
| 31 |
import com.spice.profitmandi.common.services.ContentServingService;
|
- |
|
| 32 |
import com.spice.profitmandi.common.services.LogisticsService;
|
31 |
import com.spice.profitmandi.common.services.LogisticsService;
|
| 33 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 34 |
import com.spice.profitmandi.dao.entity.UserAccounts;
|
32 |
import com.spice.profitmandi.dao.entity.UserAccounts;
|
| 35 |
import com.spice.profitmandi.dao.enumuration.AccountType;
|
33 |
import com.spice.profitmandi.dao.enumuration.AccountType;
|
| 36 |
import com.spice.profitmandi.dao.model.ProductPojo;
|
34 |
import com.spice.profitmandi.dao.model.ProductPojo;
|
| 37 |
import com.spice.profitmandi.dao.repository.UserAccountRepository;
|
35 |
import com.spice.profitmandi.dao.repository.UserAccountRepository;
|
| 38 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
36 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
| Line 67... |
Line 65... |
| 67 |
@ApiImplicitParams({
|
65 |
@ApiImplicitParams({
|
| 68 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
66 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 69 |
required = true, dataType = "string", paramType = "header")
|
67 |
required = true, dataType = "string", paramType = "header")
|
| 70 |
})
|
68 |
})
|
| 71 |
@ApiOperation(value = "Add items to cart")
|
69 |
@ApiOperation(value = "Add items to cart")
|
| 72 |
public ResponseEntity<?> validateCart(HttpServletRequest request,@RequestBody AddCartRequest cartRequest){
|
70 |
public ResponseEntity<?> validateCart(HttpServletRequest request,@RequestBody AddCartRequest cartRequest, @RequestParam(value="pincode", defaultValue="110001") String pincode){
|
| 73 |
UserAccounts userAccount = null;
|
71 |
UserAccounts userAccount = null;
|
| 74 |
ValidateCartResponse vc = null;
|
72 |
ValidateCartResponse vc = null;
|
| - |
|
73 |
int userId = (int)request.getAttribute("userId");
|
| 75 |
try {
|
74 |
try {
|
| 76 |
userAccount = userAccountRepository.getUserAccountByType(14, AccountType.cartId);
|
75 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.cartId);
|
| 77 |
logger.info("UserAccount "+userAccount);
|
76 |
logger.info("UserAccount "+userAccount);
|
| 78 |
} catch (ProfitMandiBusinessException e1) {
|
77 |
} catch (ProfitMandiBusinessException e1) {
|
| 79 |
vc = new ValidateCartResponse(null, "Error","Error while getting cart information");
|
78 |
vc = new ValidateCartResponse(null, "Error","Error while getting cart information");
|
| 80 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
79 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
| 81 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
80 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| Line 98... |
Line 97... |
| 98 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
97 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
| 99 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
98 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 100 |
}
|
99 |
}
|
| 101 |
String cartString=null;
|
100 |
String cartString=null;
|
| 102 |
try {
|
101 |
try {
|
| 103 |
cartString = userClient.validateCartNew(Integer.valueOf(userAccount.getAccount_key()), "110002", -1);
|
102 |
cartString = userClient.validateCartNew(Integer.valueOf(userAccount.getAccount_key()), pincode, -1);
|
| 104 |
} catch (Exception e) {
|
103 |
} catch (Exception e) {
|
| 105 |
// TODO Auto-generated catch block
|
104 |
// TODO Auto-generated catch block
|
| 106 |
e.printStackTrace();
|
105 |
e.printStackTrace();
|
| 107 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while validating cart");
|
106 |
vc = new ValidateCartResponse(null, "Error","Problem occurred while validating cart");
|
| 108 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|
107 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, vc);
|