| Line 25... |
Line 25... |
| 25 |
import com.spice.profitmandi.dao.entity.dtr.UserAccounts;
|
25 |
import com.spice.profitmandi.dao.entity.dtr.UserAccounts;
|
| 26 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
26 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 27 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
27 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
28 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
29 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| - |
|
30 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.transaction.WalletRepository;
|
31 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 31 |
import com.spice.profitmandi.web.res.UserWalletHistoryResponse;
|
32 |
import com.spice.profitmandi.web.res.UserWalletHistoryResponse;
|
| 32 |
import com.spice.profitmandi.web.res.UserWalletResponse;
|
33 |
import com.spice.profitmandi.web.res.UserWalletResponse;
|
| 33 |
|
34 |
|
| 34 |
import io.swagger.annotations.ApiImplicitParam;
|
35 |
import io.swagger.annotations.ApiImplicitParam;
|
| 35 |
import io.swagger.annotations.ApiImplicitParams;
|
36 |
import io.swagger.annotations.ApiImplicitParams;
|
| Line 40... |
Line 41... |
| 40 |
public class WalletController {
|
41 |
public class WalletController {
|
| 41 |
|
42 |
|
| 42 |
private static final Logger log=LoggerFactory.getLogger(WalletController.class);
|
43 |
private static final Logger log=LoggerFactory.getLogger(WalletController.class);
|
| 43 |
|
44 |
|
| 44 |
@Autowired
|
45 |
@Autowired
|
| 45 |
WalletRepository walletRepository;
|
46 |
UserWalletRepository userWalletRepository;
|
| 46 |
|
47 |
|
| 47 |
@Autowired
|
48 |
@Autowired
|
| - |
|
49 |
UserWalletHistoryRepository userWalletHistoryRepository;
|
| - |
|
50 |
|
| - |
|
51 |
@Autowired
|
| 48 |
UserAccountRepository userAccountRepository;
|
52 |
UserAccountRepository userAccountRepository;
|
| 49 |
|
53 |
|
| 50 |
@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
54 |
@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 51 |
@ApiImplicitParams({
|
55 |
@ApiImplicitParams({
|
| 52 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
56 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| Line 64... |
Line 68... |
| 64 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
68 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
| 65 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
69 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 66 |
}
|
70 |
}
|
| 67 |
|
71 |
|
| 68 |
try {
|
72 |
try {
|
| 69 |
wallet = walletRepository.getWalletForUser(Integer.valueOf(userAccount.getAccount_key()));
|
73 |
wallet = userWalletRepository.selectByRetailerId(Integer.valueOf(userAccount.getAccount_key()));
|
| 70 |
log.info("wallet "+wallet);
|
74 |
log.info("wallet "+wallet);
|
| 71 |
} catch (NumberFormatException | ProfitMandiBusinessException e) {
|
75 |
} catch (NumberFormatException | ProfitMandiBusinessException e) {
|
| 72 |
log.error("Unable to get userwallet ",e);
|
76 |
log.error("Unable to get userwallet ",e);
|
| 73 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
77 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
| 74 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
78 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| Line 78... |
Line 82... |
| 78 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
82 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 79 |
}
|
83 |
}
|
| 80 |
|
84 |
|
| 81 |
UserWalletResponse uwr = new UserWalletResponse();
|
85 |
UserWalletResponse uwr = new UserWalletResponse();
|
| 82 |
uwr.setAmount(wallet.getAmount());
|
86 |
uwr.setAmount(wallet.getAmount());
|
| 83 |
uwr.setRefundableAmount(wallet.getRefundable_amount());
|
87 |
uwr.setRefundableAmount(wallet.getRefundableAmount());
|
| 84 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, uwr);
|
88 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, uwr);
|
| 85 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
89 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 86 |
|
90 |
|
| 87 |
}
|
91 |
}
|
| 88 |
|
92 |
|
| Line 102... |
Line 106... |
| 102 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
106 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
| 103 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
107 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 104 |
}
|
108 |
}
|
| 105 |
|
109 |
|
| 106 |
try {
|
110 |
try {
|
| 107 |
walletHistory = walletRepository.getWalletHistoryForUser(Integer.valueOf(userAccount.getAccount_key()));
|
111 |
UserWallet uw = userWalletRepository.selectByRetailerId(Integer.valueOf(userAccount.getAccount_key()));
|
| - |
|
112 |
walletHistory = userWalletHistoryRepository.selectByWalletId(uw.getId());
|
| 108 |
} catch (NumberFormatException | ProfitMandiBusinessException e) {
|
113 |
} catch (NumberFormatException | ProfitMandiBusinessException e) {
|
| 109 |
log.error("Unable to get wallet history ",e);
|
114 |
log.error("Unable to get wallet history ",e);
|
| 110 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, new ArrayList<UserWalletHistoryResponse>());
|
115 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, new ArrayList<UserWalletHistoryResponse>());
|
| 111 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
116 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 112 |
}
|
117 |
}
|
| Line 116... |
Line 121... |
| 116 |
for (UserWalletHistory uwh : walletHistory){
|
121 |
for (UserWalletHistory uwh : walletHistory){
|
| 117 |
UserWalletHistoryResponse uwhr = new UserWalletHistoryResponse();
|
122 |
UserWalletHistoryResponse uwhr = new UserWalletHistoryResponse();
|
| 118 |
uwhr.setAmount(uwh.getAmount());
|
123 |
uwhr.setAmount(uwh.getAmount());
|
| 119 |
uwhr.setReference(uwh.getReference());
|
124 |
uwhr.setReference(uwh.getReference());
|
| 120 |
try{
|
125 |
try{
|
| 121 |
uwhr.setReference_type(uwh.getReference_type().toString());
|
126 |
uwhr.setReference_type(uwh.getReferenceType().toString());
|
| 122 |
}
|
127 |
}
|
| 123 |
catch(Exception e){
|
128 |
catch(Exception e){
|
| 124 |
uwhr.setReference_type("");
|
129 |
uwhr.setReference_type("");
|
| 125 |
}
|
130 |
}
|
| 126 |
uwhr.setTimestamp(uwh.getTimestamp().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
131 |
uwhr.setTimestamp(uwh.getTimestamp().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|