| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.datalogger.EventType;
|
3 |
import in.shop2020.datalogger.EventType;
|
| 4 |
import in.shop2020.model.v1.user.Address;
|
4 |
import in.shop2020.model.v1.user.Address;
|
| 5 |
import in.shop2020.model.v1.user.Cart;
|
5 |
import in.shop2020.model.v1.user.Cart;
|
| - |
|
6 |
import in.shop2020.model.v1.user.PromotionService;
|
| 6 |
import in.shop2020.serving.utils.FormattingUtils;
|
7 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 7 |
import in.shop2020.serving.utils.Utils;
|
8 |
import in.shop2020.serving.utils.Utils;
|
| - |
|
9 |
import in.shop2020.thrift.clients.PromotionClient;
|
| 8 |
import in.shop2020.thrift.clients.UserClient;
|
10 |
import in.shop2020.thrift.clients.UserClient;
|
| 9 |
import in.shop2020.utils.DataLogger;
|
11 |
import in.shop2020.utils.DataLogger;
|
| 10 |
|
12 |
|
| 11 |
import java.util.Collection;
|
13 |
import java.util.Collection;
|
| 12 |
import java.util.ResourceBundle;
|
14 |
import java.util.ResourceBundle;
|
| Line 28... |
Line 30... |
| 28 |
})
|
30 |
})
|
| 29 |
|
31 |
|
| 30 |
public class ProceedToPayController extends BaseController {
|
32 |
public class ProceedToPayController extends BaseController {
|
| 31 |
|
33 |
|
| 32 |
private static Logger logger = Logger.getLogger(ProceedToPayController.class);
|
34 |
private static Logger logger = Logger.getLogger(ProceedToPayController.class);
|
| 33 |
|
- |
|
| 34 |
private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
|
35 |
private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
|
| 35 |
private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
|
36 |
private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
|
| 36 |
|
37 |
|
| - |
|
38 |
private boolean hasGiftVoucher = false;
|
| 37 |
private long addressId = -1;
|
39 |
private long addressId = -1;
|
| 38 |
private String totalAmount = "";
|
40 |
private String totalAmount = "";
|
| 39 |
private boolean showCodOption = true;
|
41 |
private boolean showCodOption = true;
|
| 40 |
private boolean showEmiOption = false;
|
42 |
private boolean showEmiOption = false;
|
| 41 |
private String errorMsg = "";
|
43 |
private String errorMsg = "";
|
| Line 81... |
Line 83... |
| 81 |
String itemIdString = "";
|
83 |
String itemIdString = "";
|
| 82 |
try {
|
84 |
try {
|
| 83 |
userContextServiceClient = new UserClient();
|
85 |
userContextServiceClient = new UserClient();
|
| 84 |
userClient = userContextServiceClient.getClient();
|
86 |
userClient = userContextServiceClient.getClient();
|
| 85 |
|
87 |
|
| 86 |
|
- |
|
| 87 |
long cartId = userinfo.getCartId();
|
88 |
long cartId = userinfo.getCartId();
|
| 88 |
if(deliveryLocation.equals("myLocation")) {
|
89 |
if(deliveryLocation.equals("myLocation")) {
|
| 89 |
userClient.addStoreToCart(cartId, 0);
|
90 |
userClient.addStoreToCart(cartId, 0);
|
| 90 |
}
|
91 |
}
|
| 91 |
|
- |
|
| 92 |
if (deliveryLocation.equals("HotSpot")) {
|
- |
|
| 93 |
userClient.addStoreToCart(cartId, hotSpotAddressId);
|
- |
|
| 94 |
showStorePickUpOption = true;
|
- |
|
| 95 |
}
|
- |
|
| 96 |
// Validate the cart to ensure that we are not accepting payment for
|
92 |
// Validate the cart to ensure that we are not accepting payment for
|
| 97 |
// an invalid order.
|
93 |
// an invalid order.
|
| 98 |
errorMsg = userClient.validateCart(cartId, sourceId);
|
94 |
errorMsg = userClient.validateCart(cartId, sourceId);
|
| 99 |
|
95 |
|
| 100 |
Cart cart = userClient.getCart(cartId);
|
96 |
Cart cart = userClient.getCart(cartId);
|
| 101 |
|
- |
|
| 102 |
String couponCode = cart.getCouponCode();
|
97 |
String couponCode = cart.getCouponCode();
|
| 103 |
logger.info("Coupon: " + couponCode);
|
98 |
logger.info("Coupon: " + couponCode);
|
| 104 |
|
99 |
|
| - |
|
100 |
PromotionService.Client pc = new PromotionClient().getClient();
|
| - |
|
101 |
if(pc.isGiftVoucher(couponCode)){
|
| - |
|
102 |
hasGiftVoucher = true;
|
| - |
|
103 |
}
|
| - |
|
104 |
|
| - |
|
105 |
if (!hasGiftVoucher && deliveryLocation.equals("HotSpot")) {
|
| - |
|
106 |
userClient.addStoreToCart(cartId, hotSpotAddressId);
|
| - |
|
107 |
showStorePickUpOption = true;
|
| - |
|
108 |
}
|
| - |
|
109 |
|
| 105 |
setTotalAmount(cart);
|
110 |
setTotalAmount(cart);
|
| 106 |
itemIdString = Utils.getItemIdStringInCart(cart);
|
111 |
itemIdString = Utils.getItemIdStringInCart(cart);
|
| 107 |
|
112 |
|
| 108 |
|
113 |
|
| 109 |
// Get the address to check if COD option is available for this
|
114 |
// Get the address to check if COD option is available for this
|
| Line 112... |
Line 117... |
| 112 |
addressId = cart.getAddressId();
|
117 |
addressId = cart.getAddressId();
|
| 113 |
}
|
118 |
}
|
| 114 |
address = userClient.getAddressById(addressId);
|
119 |
address = userClient.getAddressById(addressId);
|
| 115 |
|
120 |
|
| 116 |
try {
|
121 |
try {
|
| 117 |
showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
|
122 |
showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin()) && !hasGiftVoucher;
|
| 118 |
} catch(Exception e) {
|
123 |
} catch(Exception e) {
|
| 119 |
logger.error("Error while checking if COD is available for: " + showCodOption, e);
|
124 |
logger.error("Error while checking if COD is available for: " + showCodOption, e);
|
| 120 |
showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
|
125 |
showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
|
| 121 |
}
|
126 |
}
|
| 122 |
|
127 |
|