| Line 34... |
Line 34... |
| 34 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
34 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 35 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
35 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 36 |
import com.spice.profitmandi.web.req.CreateRechargeRequest;
|
36 |
import com.spice.profitmandi.web.req.CreateRechargeRequest;
|
| 37 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
37 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
| 38 |
import com.spice.profitmandi.web.res.CreateRechargeResponse;
|
38 |
import com.spice.profitmandi.web.res.CreateRechargeResponse;
|
| - |
|
39 |
import com.spice.profitmandi.web.res.MyRechargesResponse;
|
| 39 |
import com.spice.profitmandi.web.res.RechargeResultPojo;
|
40 |
import com.spice.profitmandi.web.res.RechargeResultPojo;
|
| 40 |
|
41 |
|
| 41 |
import in.shop2020.model.v1.order.DenominationType;
|
42 |
import in.shop2020.model.v1.order.DenominationType;
|
| 42 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
43 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
| 43 |
import in.shop2020.model.v1.order.OrderType;
|
44 |
import in.shop2020.model.v1.order.OrderType;
|
| Line 374... |
Line 375... |
| 374 |
rrp = new RechargeResultPojo();
|
375 |
rrp = new RechargeResultPojo();
|
| 375 |
rrp.setRechargeStatus(t_rechargeOrder.getStatus().name());
|
376 |
rrp.setRechargeStatus(t_rechargeOrder.getStatus().name());
|
| 376 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, rrp);
|
377 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, rrp);
|
| 377 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
378 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 378 |
}
|
379 |
}
|
| - |
|
380 |
|
| - |
|
381 |
@RequestMapping(value = ProfitMandiConstants.URL_MY_RECHARGES , method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
382 |
@ApiImplicitParams({
|
| - |
|
383 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
384 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
385 |
})
|
| - |
|
386 |
public ResponseEntity<?> myRecharges(HttpServletRequest request, @RequestParam(value="offset") int offset, @RequestParam(value="limit") int limit){
|
| - |
|
387 |
TransactionClient tc=null;
|
| - |
|
388 |
int userId = (int)request.getAttribute("userId");
|
| - |
|
389 |
UserAccounts userAccount;
|
| - |
|
390 |
List<RechargeOrder> rechargeOrders = null;
|
| - |
|
391 |
try {
|
| - |
|
392 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.saholic);
|
| - |
|
393 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
394 |
log.error("Unable to get user account ",e);
|
| - |
|
395 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, new ArrayList<MyRechargesResponse>());
|
| - |
|
396 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
397 |
}
|
| - |
|
398 |
try {
|
| - |
|
399 |
tc = new TransactionClient();
|
| - |
|
400 |
rechargeOrders = tc.getClient().getPaginatedRechargeOrders(Long.valueOf(userAccount.getAccount_key()), offset, limit);
|
| - |
|
401 |
} catch (Exception e) {
|
| - |
|
402 |
log.error("Unable to get recharge order list",e);
|
| - |
|
403 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, new ArrayList<MyRechargesResponse>());
|
| - |
|
404 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
405 |
}
|
| - |
|
406 |
List<MyRechargesResponse> myRechargesList = new ArrayList<MyRechargesResponse>();
|
| - |
|
407 |
for (RechargeOrder rechargeOrder : rechargeOrders){
|
| - |
|
408 |
MyRechargesResponse rp = new MyRechargesResponse();
|
| - |
|
409 |
if(rechargeOrder.getRechargeType() == RechargeType.MOBILE){
|
| - |
|
410 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
| - |
|
411 |
rp.setOperatorType("MOBILE");
|
| - |
|
412 |
}
|
| - |
|
413 |
if(rechargeOrder.getRechargeType() == RechargeType.DTH){
|
| - |
|
414 |
rp.setOperator(Utils.getProvider(rechargeOrder.getOperatorId()));
|
| - |
|
415 |
rp.setOperatorType("DTH");
|
| - |
|
416 |
}
|
| - |
|
417 |
rp.setOrderId(rechargeOrder.getId());
|
| - |
|
418 |
rp.setOperatorId(rechargeOrder.getOperatorId());
|
| - |
|
419 |
rp.setDate(rechargeOrder.getCreationTimestamp());
|
| - |
|
420 |
rp.setNumber(rechargeOrder.getDeviceNumber());
|
| - |
|
421 |
rp.setAmount(rechargeOrder.getTotalAmount());
|
| - |
|
422 |
rp.setStatus(Utils.getRechargeDisplayStatus(rechargeOrder.getStatus()));
|
| - |
|
423 |
rp.setDisplayOrderId(rechargeOrder.getDisplayId());
|
| - |
|
424 |
myRechargesList.add(rp);
|
| - |
|
425 |
}
|
| - |
|
426 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, myRechargesList);
|
| - |
|
427 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
428 |
}
|
| 379 |
|
429 |
|
| 380 |
|
- |
|
| 381 |
|
430 |
|
| 382 |
private String remoteAddr(HttpServletRequest request) {
|
431 |
private String remoteAddr(HttpServletRequest request) {
|
| 383 |
String remoteAddr = "";
|
432 |
String remoteAddr = "";
|
| 384 |
String x;
|
433 |
String x;
|
| 385 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|
434 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|
| 386 |
if (x != null && !x.isEmpty()) {
|
435 |
if (x != null && !x.isEmpty()) {
|