| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.Map;
|
| - |
|
4 |
|
| 3 |
import in.shop2020.model.v1.order.RechargeOrder;
|
5 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 4 |
import in.shop2020.model.v1.order.RechargeType;
|
6 |
import in.shop2020.model.v1.order.RechargeType;
|
| 5 |
import in.shop2020.model.v1.user.Address;
|
7 |
import in.shop2020.model.v1.user.Address;
|
| - |
|
8 |
import in.shop2020.thrift.clients.PromotionClient;
|
| 6 |
import in.shop2020.thrift.clients.TransactionClient;
|
9 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 7 |
import in.shop2020.thrift.clients.UserClient;
|
10 |
import in.shop2020.thrift.clients.UserClient;
|
| 8 |
|
11 |
|
| 9 |
import org.apache.log4j.Logger;
|
12 |
import org.apache.log4j.Logger;
|
| - |
|
13 |
import org.apache.struts2.convention.annotation.Result;
|
| - |
|
14 |
import org.apache.struts2.convention.annotation.Results;
|
| - |
|
15 |
|
| - |
|
16 |
@Results({
|
| - |
|
17 |
@Result(name="recharge-redirect", type="redirectAction", params = {"actionName" , "recharge", "error", "${errorMsg}"})
|
| - |
|
18 |
})
|
| 10 |
|
19 |
|
| 11 |
public class RechargePayOptionsController extends BaseController {
|
20 |
public class RechargePayOptionsController extends BaseController {
|
| 12 |
|
21 |
|
| 13 |
/**
|
- |
|
| 14 |
*
|
- |
|
| 15 |
*/
|
- |
|
| 16 |
|
- |
|
| 17 |
//private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
|
22 |
//private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
|
| 18 |
//private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
|
23 |
//private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
|
| 19 |
private RechargeOrder rechargeOrder = null;
|
24 |
private RechargeOrder rechargeOrder = null;
|
| 20 |
private String rechargeOrderId = "";
|
25 |
private String rechargeOrderId = "";
|
| 21 |
private String errorMsg = "";
|
26 |
private String errorMsg = "";
|
| Line 32... |
Line 37... |
| 32 |
public String index() {
|
37 |
public String index() {
|
| 33 |
try {
|
38 |
try {
|
| 34 |
TransactionClient tcl = new TransactionClient();
|
39 |
TransactionClient tcl = new TransactionClient();
|
| 35 |
rechargeOrder = tcl.getClient().getRechargeOrder(Long.parseLong(rechargeOrderId));
|
40 |
rechargeOrder = tcl.getClient().getRechargeOrder(Long.parseLong(rechargeOrderId));
|
| 36 |
setAmount(rechargeOrder.getTotalAmount() - rechargeOrder.getWalletAmount() - rechargeOrder.getCouponAmount());
|
41 |
setAmount(rechargeOrder.getTotalAmount() - rechargeOrder.getWalletAmount() - rechargeOrder.getCouponAmount());
|
| - |
|
42 |
|
| - |
|
43 |
if (rechargeOrder.getCouponAmount() > 0) {
|
| - |
|
44 |
PromotionClient pc = new PromotionClient();
|
| - |
|
45 |
Map<Long, String> couponResult = null;
|
| - |
|
46 |
couponResult = pc.getClient().applyRechargeCoupon(rechargeOrder.getCouponCode(), rechargeOrder.getTotalAmount(), rechargeOrder.getUserId());
|
| 37 |
} catch (NumberFormatException e) {
|
47 |
if(couponResult != null) {
|
| 38 |
log.error("rechargeOrderId : " + rechargeOrderId + " could not be converted long");
|
48 |
if(!couponResult.containsKey(rechargeOrder.getCouponAmount())) {
|
| - |
|
49 |
errorMsg = "The coupon you applied is not valid anymore";
|
| - |
|
50 |
return "recharge-redirect";
|
| - |
|
51 |
}
|
| - |
|
52 |
} else {
|
| - |
|
53 |
errorMsg = "The coupon you applied is not valid anymore";
|
| 39 |
return "recharge-redirect";
|
54 |
return "recharge-redirect";
|
| - |
|
55 |
}
|
| - |
|
56 |
}
|
| 40 |
} catch (Exception e) {
|
57 |
} catch (Exception e) {
|
| 41 |
log.error("Unable to get recharge Order for id : " + rechargeOrderId);
|
58 |
log.error("Unable to get recharge Order for id : " + rechargeOrderId);
|
| - |
|
59 |
errorMsg = "Some error occured. Please try again. Sorry for the inconvenience.";
|
| 42 |
return "recharge-redirect";
|
60 |
return "recharge-redirect";
|
| 43 |
}
|
61 |
}
|
| 44 |
return "index";
|
62 |
return "index";
|
| 45 |
}
|
63 |
}
|
| 46 |
|
64 |
|