| 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.Cart;
|
| 4 |
import in.shop2020.model.v1.user.PromotionException;
|
5 |
import in.shop2020.model.v1.user.PromotionException;
|
| 5 |
import in.shop2020.model.v1.user.PromotionService;
|
6 |
import in.shop2020.model.v1.user.PromotionService;
|
| 6 |
import in.shop2020.model.v1.user.UserContextService;
|
7 |
import in.shop2020.model.v1.user.UserContextService;
|
| 7 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
- |
|
| 8 |
import in.shop2020.thrift.clients.PromotionClient;
|
8 |
import in.shop2020.thrift.clients.PromotionClient;
|
| 9 |
import in.shop2020.thrift.clients.UserClient;
|
9 |
import in.shop2020.thrift.clients.UserClient;
|
| 10 |
import in.shop2020.utils.DataLogger;
|
10 |
import in.shop2020.utils.DataLogger;
|
| 11 |
|
11 |
|
| 12 |
import org.apache.log4j.Logger;
|
12 |
import org.apache.log4j.Logger;
|
| Line 50... |
Line 50... |
| 50 |
if (action.equalsIgnoreCase("applycoupon")) {
|
50 |
if (action.equalsIgnoreCase("applycoupon")) {
|
| 51 |
if (couponCode == null || couponCode.isEmpty()) {
|
51 |
if (couponCode == null || couponCode.isEmpty()) {
|
| 52 |
addActionError("Coupon Code field cannot be left empty");
|
52 |
addActionError("Coupon Code field cannot be left empty");
|
| 53 |
return "redirect";
|
53 |
return "redirect";
|
| 54 |
}
|
54 |
}
|
| 55 |
|
- |
|
| 56 |
boolean qualifiesForCoupon = true;
|
- |
|
| 57 |
|
- |
|
| 58 |
if(couponCode.equalsIgnoreCase("SGalaxy")) {
|
- |
|
| 59 |
if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
|
- |
|
| 60 |
long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
|
- |
|
| 61 |
|
- |
|
| 62 |
//TODO: Affiliate based qualification should be inside service
|
- |
|
| 63 |
if (affId != 5) { //For MySmartPrice
|
- |
|
| 64 |
qualifiesForCoupon = false;
|
- |
|
| 65 |
}
|
- |
|
| 66 |
} else {
|
- |
|
| 67 |
qualifiesForCoupon = false;
|
- |
|
| 68 |
}
|
- |
|
| 69 |
}
|
- |
|
| 70 |
if(qualifiesForCoupon) {
|
- |
|
| 71 |
promotionServiceClient = new PromotionClient();
|
55 |
promotionServiceClient = new PromotionClient();
|
| 72 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
56 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
| 73 |
|
57 |
String str = "Coupon applied";
|
| 74 |
promotionClient.applyCoupon(couponCode, cartId);
|
58 |
Cart cart = promotionClient.applyCoupon(couponCode, cartId);
|
| 75 |
DataLogger.logData(EventType.COUPON_APPLIED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
59 |
if(cart.getMessage() != null && cart.getMessage().equals("")){
|
| 76 |
} else {
|
- |
|
| 77 |
addActionError("You are not eligible for this coupon");
|
60 |
str = str + ", " + cart.getMessage();
|
| 78 |
}
|
61 |
}
|
| - |
|
62 |
addActionError(str);
|
| - |
|
63 |
DataLogger.logData(EventType.COUPON_APPLIED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
| 79 |
}
|
64 |
}
|
| 80 |
else if (action.equals("removecoupon")) {
|
65 |
else if (action.equals("removecoupon")) {
|
| 81 |
userServiceClient = new UserClient();
|
66 |
userServiceClient = new UserClient();
|
| 82 |
UserContextService.Client userClient = userServiceClient.getClient();
|
67 |
UserContextService.Client userClient = userServiceClient.getClient();
|
| 83 |
userClient.removeCoupon(cartId);
|
68 |
userClient.removeCoupon(cartId);
|