| 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.RechargeResultPojo;
|
| 39 |
|
40 |
|
| 40 |
import in.shop2020.model.v1.order.DenominationType;
|
41 |
import in.shop2020.model.v1.order.DenominationType;
|
| 41 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
42 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
| 42 |
import in.shop2020.model.v1.order.OrderType;
|
43 |
import in.shop2020.model.v1.order.OrderType;
|
| 43 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
44 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
| Line 299... |
Line 300... |
| 299 |
}
|
300 |
}
|
| 300 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, crr);
|
301 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, crr);
|
| 301 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
302 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 302 |
}
|
303 |
}
|
| 303 |
|
304 |
|
| - |
|
305 |
@RequestMapping(value = ProfitMandiConstants.URL_RECHARGE_RESULT , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
306 |
@ApiImplicitParams({
|
| - |
|
307 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
308 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
309 |
})
|
| - |
|
310 |
public ResponseEntity<?> rechargeResult(HttpServletRequest request, @RequestParam(value="rechargeOrderId") long rechargeOrderId){
|
| - |
|
311 |
TransactionClient tc=null;
|
| - |
|
312 |
RechargeOrder rechargeOrder = null;
|
| - |
|
313 |
RechargeResultPojo rrp = null;
|
| - |
|
314 |
try {
|
| - |
|
315 |
tc = new TransactionClient();
|
| - |
|
316 |
rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrderId);
|
| - |
|
317 |
} catch (TransactionServiceException | TException e) {
|
| - |
|
318 |
// return with internal server error
|
| - |
|
319 |
e.printStackTrace();
|
| - |
|
320 |
rrp = new RechargeResultPojo();
|
| - |
|
321 |
rrp.setIsError(true);
|
| - |
|
322 |
rrp.setDetailDisplayMessage("We are experiencing some problem right now.");
|
| - |
|
323 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, rrp);
|
| - |
|
324 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
325 |
}
|
| - |
|
326 |
if (rechargeOrder == null){
|
| - |
|
327 |
rrp = new RechargeResultPojo();
|
| - |
|
328 |
rrp.setIsError(true);
|
| - |
|
329 |
rrp.setDetailDisplayMessage("Recharge order doesnot exist in our system.");
|
| - |
|
330 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, rrp);
|
| - |
|
331 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
332 |
}
|
| - |
|
333 |
String[] os = Utils.getOrderStatus(rechargeOrder.getStatus());
|
| - |
|
334 |
rrp = new RechargeResultPojo();
|
| - |
|
335 |
rrp.setRechargeDeviceNumber(rechargeOrder.getDeviceNumber());
|
| - |
|
336 |
rrp.setRechargeDisplayId(rechargeOrder.getDisplayId());
|
| - |
|
337 |
rrp.setTotalAmount(rechargeOrder.getTotalAmount() + "");
|
| - |
|
338 |
rrp.setRechargeProvider(Utils.getProvider(rechargeOrder.getOperatorId()));
|
| - |
|
339 |
rrp.setIsError(Boolean.parseBoolean(os[0]));
|
| - |
|
340 |
rrp.setRechargeStatus(os[1]);
|
| - |
|
341 |
rrp.setDetailDisplayMessage(os[2]);
|
| - |
|
342 |
if (rechargeOrder.getStatus() == RechargeOrderStatus.RECHARGE_IN_PROCESS){
|
| - |
|
343 |
rrp.setPoll(true);
|
| - |
|
344 |
}
|
| - |
|
345 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, rrp);
|
| - |
|
346 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
347 |
}
|
| - |
|
348 |
|
| - |
|
349 |
@RequestMapping(value = ProfitMandiConstants.URL_POLL_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
350 |
@ApiImplicitParams({
|
| - |
|
351 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| - |
|
352 |
required = true, dataType = "string", paramType = "header")
|
| - |
|
353 |
})
|
| - |
|
354 |
public ResponseEntity<?> getRechargeResulr(HttpServletRequest request, @RequestParam(value="rechargeOrderId") long rechargeOrderId, @RequestParam(value="finalCall") boolean finalCall){
|
| - |
|
355 |
TransactionClient transactionServiceClient = null;
|
| - |
|
356 |
RechargeOrder t_rechargeOrder = null;
|
| - |
|
357 |
RechargeResultPojo rrp = null;
|
| - |
|
358 |
try{
|
| - |
|
359 |
transactionServiceClient = new TransactionClient();
|
| - |
|
360 |
t_rechargeOrder = transactionServiceClient.getClient().getRcgOrderStatus(rechargeOrderId, finalCall);
|
| - |
|
361 |
}
|
| - |
|
362 |
catch(Exception e){
|
| - |
|
363 |
rrp = new RechargeResultPojo();
|
| - |
|
364 |
rrp.setRechargeStatus("");
|
| - |
|
365 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, rrp);
|
| - |
|
366 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
367 |
}
|
| - |
|
368 |
if (t_rechargeOrder == null){
|
| - |
|
369 |
rrp = new RechargeResultPojo();
|
| - |
|
370 |
rrp.setRechargeStatus("");
|
| - |
|
371 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, new RechargeResultPojo());
|
| - |
|
372 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
373 |
}
|
| - |
|
374 |
rrp = new RechargeResultPojo();
|
| - |
|
375 |
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 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
378 |
}
|
| - |
|
379 |
|
| - |
|
380 |
|
| 304 |
|
381 |
|
| 305 |
private String remoteAddr(HttpServletRequest request) {
|
382 |
private String remoteAddr(HttpServletRequest request) {
|
| 306 |
String remoteAddr = "";
|
383 |
String remoteAddr = "";
|
| 307 |
String x;
|
384 |
String x;
|
| 308 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|
385 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|