| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| 3 |
import org.apache.log4j.Logger;
|
- |
|
| 4 |
import org.apache.struts2.convention.annotation.Result;
|
- |
|
| 5 |
import org.apache.struts2.convention.annotation.Results;
|
- |
|
| 6 |
|
- |
|
| 7 |
import in.shop2020.utils.DataLogger;
|
- |
|
| 8 |
import in.shop2020.datalogger.EventType;
|
3 |
import in.shop2020.datalogger.EventType;
|
| 9 |
import in.shop2020.model.v1.user.PromotionException;
|
4 |
import in.shop2020.model.v1.user.PromotionException;
|
| 10 |
import in.shop2020.model.v1.user.UserContextService;
|
- |
|
| 11 |
import in.shop2020.model.v1.user.PromotionService;
|
5 |
import in.shop2020.model.v1.user.PromotionService;
|
| 12 |
import in.shop2020.serving.controllers.BaseController;
|
- |
|
| 13 |
import in.shop2020.thrift.clients.UserClient;
|
6 |
import in.shop2020.model.v1.user.UserContextService;
|
| 14 |
import in.shop2020.thrift.clients.PromotionClient;
|
7 |
import in.shop2020.thrift.clients.PromotionClient;
|
| - |
|
8 |
import in.shop2020.thrift.clients.UserClient;
|
| - |
|
9 |
import in.shop2020.utils.DataLogger;
|
| - |
|
10 |
|
| - |
|
11 |
import org.apache.log4j.Logger;
|
| - |
|
12 |
import org.apache.struts2.convention.annotation.Result;
|
| - |
|
13 |
import org.apache.struts2.convention.annotation.Results;
|
| 15 |
|
14 |
|
| 16 |
@SuppressWarnings("serial")
|
15 |
@SuppressWarnings("serial")
|
| 17 |
@Results({
|
16 |
@Results({
|
| 18 |
@Result(name = "redirect", type = "redirectAction", params = {"actionName" , "cart"})
|
17 |
@Result(name = "redirect", type = "redirectAction", params = {"actionName" , "cart"})
|
| 19 |
})
|
18 |
})
|
| Line 46... |
Line 45... |
| 46 |
return "redirect";
|
45 |
return "redirect";
|
| 47 |
}
|
46 |
}
|
| 48 |
promotionServiceClient = new PromotionClient();
|
47 |
promotionServiceClient = new PromotionClient();
|
| 49 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
48 |
PromotionService.Client promotionClient = promotionServiceClient.getClient();
|
| 50 |
promotionClient.applyCoupon(couponCode, cartId);
|
49 |
promotionClient.applyCoupon(couponCode, cartId);
|
| 51 |
DataLogger.logData(EventType.COUPON_APPLIED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
50 |
DataLogger.logData(EventType.COUPON_APPLIED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
| 52 |
}
|
51 |
}
|
| 53 |
else if (action.equals("removecoupon")) {
|
52 |
else if (action.equals("removecoupon")) {
|
| 54 |
userServiceClient = new UserClient();
|
53 |
userServiceClient = new UserClient();
|
| 55 |
UserContextService.Client userClient = userServiceClient.getClient();
|
54 |
UserContextService.Client userClient = userServiceClient.getClient();
|
| 56 |
userClient.removeCoupon(cartId);
|
55 |
userClient.removeCoupon(cartId);
|
| 57 |
DataLogger.logData(EventType.COUPON_REMOVED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
56 |
DataLogger.logData(EventType.COUPON_REMOVED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
|
| 58 |
}
|
57 |
}
|
| 59 |
} catch (PromotionException e) {
|
58 |
} catch (PromotionException e) {
|
| 60 |
log.info("Invalid coupon: " + e.getMessage());
|
59 |
log.info("Invalid coupon: " + e.getMessage());
|
| 61 |
addActionError(e.getMessage());
|
60 |
addActionError(e.getMessage());
|
| 62 |
} catch (Exception e) {
|
61 |
} catch (Exception e) {
|