Subversion Repositories SmartDukaan

Rev

Rev 2949 | Rev 3171 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2949 Rev 3126
Line 8... Line 8...
8
import in.shop2020.datalogger.EventType;
8
import in.shop2020.datalogger.EventType;
9
import in.shop2020.model.v1.user.PromotionException;
9
import in.shop2020.model.v1.user.PromotionException;
10
import in.shop2020.model.v1.user.UserContextService;
10
import in.shop2020.model.v1.user.UserContextService;
11
import in.shop2020.model.v1.user.PromotionService;
11
import in.shop2020.model.v1.user.PromotionService;
12
import in.shop2020.serving.controllers.BaseController;
12
import in.shop2020.serving.controllers.BaseController;
13
import in.shop2020.thrift.clients.UserContextServiceClient;
13
import in.shop2020.thrift.clients.UserClient;
14
import in.shop2020.thrift.clients.PromotionServiceClient;
14
import in.shop2020.thrift.clients.PromotionClient;
15
 
15
 
16
@SuppressWarnings("serial")
16
@SuppressWarnings("serial")
17
@Results({
17
@Results({
18
    @Result(name = "redirect", type = "redirectAction", params = {"actionName" , "cart"})
18
    @Result(name = "redirect", type = "redirectAction", params = {"actionName" , "cart"})
19
})
19
})
Line 26... Line 26...
26
    
26
    
27
    public String create()  {
27
    public String create()  {
28
        String action = request.getParameter("action");
28
        String action = request.getParameter("action");
29
        log.info("Action is: " + action);
29
        log.info("Action is: " + action);
30
        
30
        
31
        UserContextServiceClient userServiceClient = null;
31
        UserClient userServiceClient = null;
32
        PromotionServiceClient promotionServiceClient = null;
32
        PromotionClient promotionServiceClient = null;
33
        
33
        
34
        try {
34
        try {
35
            long cartId = userinfo.getCartId();
35
            long cartId = userinfo.getCartId();
36
 
36
 
37
            if(action == null || action.isEmpty())  {
37
            if(action == null || action.isEmpty())  {
Line 43... Line 43...
43
            if (action.equals("applycoupon"))   {
43
            if (action.equals("applycoupon"))   {
44
                if (couponCode == null || couponCode.isEmpty()) {
44
                if (couponCode == null || couponCode.isEmpty()) {
45
                    addActionError("Coupon Code field cannot be left empty");
45
                    addActionError("Coupon Code field cannot be left empty");
46
                    return "redirect";
46
                    return "redirect";
47
                }
47
                }
48
                promotionServiceClient = new PromotionServiceClient();
48
                promotionServiceClient = new PromotionClient();
49
                PromotionService.Client promotionClient = promotionServiceClient.getClient();
49
                PromotionService.Client promotionClient = promotionServiceClient.getClient();
50
                promotionClient.applyCoupon(couponCode, cartId);
50
                promotionClient.applyCoupon(couponCode, cartId);
51
                DataLogger.logData(EventType.COUPON_APPLIED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
51
                DataLogger.logData(EventType.COUPON_APPLIED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
52
            }
52
            }
53
            else if (action.equals("removecoupon"))    {
53
            else if (action.equals("removecoupon"))    {
54
                userServiceClient = new UserContextServiceClient();
54
                userServiceClient = new UserClient();
55
                UserContextService.Client userClient = userServiceClient.getClient();
55
                UserContextService.Client userClient = userServiceClient.getClient();
56
                userClient.removeCoupon(cartId);
56
                userClient.removeCoupon(cartId);
57
                DataLogger.logData(EventType.COUPON_REMOVED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
57
                DataLogger.logData(EventType.COUPON_REMOVED, session.getId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
58
            }
58
            }
59
        } catch (PromotionException e) {
59
        } catch (PromotionException e) {