| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import org.apache.log4j.Logger;
|
3 |
import org.apache.log4j.Logger;
|
| 4 |
import org.apache.struts2.convention.annotation.Result;
|
4 |
import org.apache.struts2.convention.annotation.Result;
|
| 5 |
import org.apache.struts2.convention.annotation.Results;
|
5 |
import org.apache.struts2.convention.annotation.Results;
|
| 6 |
|
6 |
|
| - |
|
7 |
import in.shop2020.utils.DataLogger;
|
| - |
|
8 |
import in.shop2020.datalogger.EventType;
|
| 7 |
import in.shop2020.model.v1.user.PromotionException;
|
9 |
import in.shop2020.model.v1.user.PromotionException;
|
| 8 |
import in.shop2020.model.v1.user.UserContextService;
|
10 |
import in.shop2020.model.v1.user.UserContextService;
|
| 9 |
import in.shop2020.model.v1.user.PromotionService;
|
11 |
import in.shop2020.model.v1.user.PromotionService;
|
| 10 |
import in.shop2020.serving.controllers.BaseController;
|
12 |
import in.shop2020.serving.controllers.BaseController;
|
| 11 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
13 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| Line 34... |
Line 36... |
| 34 |
|
36 |
|
| 35 |
if(action == null || action.isEmpty()) {
|
37 |
if(action == null || action.isEmpty()) {
|
| 36 |
addActionError("Invalid Request Action");
|
38 |
addActionError("Invalid Request Action");
|
| 37 |
return "redirect";
|
39 |
return "redirect";
|
| 38 |
}
|
40 |
}
|
| - |
|
41 |
String couponCode = request.getParameter("coupon_code");
|
| - |
|
42 |
|
| 39 |
if (action.equals("applycoupon")) {
|
43 |
if (action.equals("applycoupon")) {
|
| 40 |
String couponCode = request.getParameter("coupon_code");
|
- |
|
| 41 |
|
- |
|
| 42 |
if (couponCode == null || couponCode.isEmpty()) {
|
44 |
if (couponCode == null || couponCode.isEmpty()) {
|
| 43 |
addActionError("Coupon Code field cannot be left empty");
|
45 |
addActionError("Coupon Code field cannot be left empty");
|
| 44 |
return "redirect";
|
46 |
return "redirect";
|
| 45 |
}
|
47 |
}
|
| 46 |
promotionServiceClient = new PromotionServiceClient();
|
48 |
promotionServiceClient = new PromotionServiceClient();
|
| 47 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
49 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
| 48 |
promotionClient.applyCoupon(couponCode, cartId);
|
50 |
promotionClient.applyCoupon(couponCode, cartId);
|
| - |
|
51 |
DataLogger.logData(EventType.COUPON_APPLIED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
| 49 |
}
|
52 |
}
|
| 50 |
else if (action.equals("removecoupon")) {
|
53 |
else if (action.equals("removecoupon")) {
|
| 51 |
userServiceClient = new UserContextServiceClient();
|
54 |
userServiceClient = new UserContextServiceClient();
|
| 52 |
UserContextService.Client userClient = userServiceClient.getClient();
|
55 |
UserContextService.Client userClient = userServiceClient.getClient();
|
| 53 |
userClient.removeCoupon(cartId);
|
56 |
userClient.removeCoupon(cartId);
|
| - |
|
57 |
DataLogger.logData(EventType.COUPON_REMOVED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
| 54 |
}
|
58 |
}
|
| 55 |
} catch (PromotionException e) {
|
59 |
} catch (PromotionException e) {
|
| 56 |
addActionError(e.getMessage());
|
60 |
addActionError(e.getMessage());
|
| 57 |
} catch (Exception e) {
|
61 |
} catch (Exception e) {
|
| 58 |
e.printStackTrace();
|
62 |
e.printStackTrace();
|