Subversion Repositories SmartDukaan

Rev

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

Rev 11854 Rev 11980
Line 3... Line 3...
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.Cart;
5
import in.shop2020.model.v1.user.PromotionException;
5
import in.shop2020.model.v1.user.PromotionException;
6
import in.shop2020.model.v1.user.PromotionService;
6
import in.shop2020.model.v1.user.PromotionService;
7
import in.shop2020.model.v1.user.UserContextService;
7
import in.shop2020.model.v1.user.UserContextService;
-
 
8
import in.shop2020.serving.interceptors.UserInterceptor;
8
import in.shop2020.thrift.clients.PromotionClient;
9
import in.shop2020.thrift.clients.PromotionClient;
9
import in.shop2020.thrift.clients.UserClient;
10
import in.shop2020.thrift.clients.UserClient;
10
import in.shop2020.utils.DataLogger;
11
import in.shop2020.utils.DataLogger;
11
 
12
 
-
 
13
import javax.servlet.http.Cookie;
-
 
14
 
12
import org.apache.log4j.Logger;
15
import org.apache.log4j.Logger;
13
import org.apache.struts2.convention.annotation.InterceptorRef;
16
import org.apache.struts2.convention.annotation.InterceptorRef;
14
import org.apache.struts2.convention.annotation.InterceptorRefs;
17
import org.apache.struts2.convention.annotation.InterceptorRefs;
15
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Result;
16
import org.apache.struts2.convention.annotation.Results;
19
import org.apache.struts2.convention.annotation.Results;
Line 49... Line 52...
49
            
52
            
50
            if (action.equalsIgnoreCase("applycoupon"))   {
53
            if (action.equalsIgnoreCase("applycoupon"))   {
51
                if (couponCode == null || couponCode.isEmpty()) {
54
                if (couponCode == null || couponCode.isEmpty()) {
52
                    addActionError("Coupon Code field cannot be left empty");
55
                    addActionError("Coupon Code field cannot be left empty");
53
                    return "redirect";
56
                    return "redirect";
-
 
57
                } else if (couponCode.equals("saholicdeals")) {
-
 
58
                	Cookie co = cookiesMap.get(UserInterceptor.DEAL_COUPON_REMOVED);
-
 
59
                	if (co != null) {
-
 
60
                		co.setMaxAge(0);
-
 
61
                	}
54
                }
62
                }
55
                promotionServiceClient = new PromotionClient();
63
                promotionServiceClient = new PromotionClient();
56
                PromotionService.Client promotionClient = promotionServiceClient.getClient();
64
                PromotionService.Client promotionClient = promotionServiceClient.getClient();
57
                String str = "Coupon applied";
65
                String str = "Coupon applied";
58
                Cart cart = promotionClient.applyCoupon(couponCode, cartId);
66
                Cart cart = promotionClient.applyCoupon(couponCode, cartId);
Line 61... Line 69...
61
                }
69
                }
62
                addActionMessage(str);
70
                addActionMessage(str);
63
                DataLogger.logData(EventType.COUPON_APPLIED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
71
                DataLogger.logData(EventType.COUPON_APPLIED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
64
            }
72
            }
65
            else if (action.equals("removecoupon"))    {
73
            else if (action.equals("removecoupon"))    {
-
 
74
            	if(userinfo.isPrivateDealUser()) {
-
 
75
            		if (cookiesMap.get(UserInterceptor.DEAL_COUPON_REMOVED)==null) {
-
 
76
        				Cookie co = new Cookie(UserInterceptor.DEAL_COUPON_REMOVED, "true");
-
 
77
        				cookiesMap.put(UserInterceptor.DEAL_COUPON_REMOVED, co);
-
 
78
            		}
-
 
79
            	}
66
                userServiceClient = new UserClient();
80
                userServiceClient = new UserClient();
67
                UserContextService.Client userClient = userServiceClient.getClient();
81
                UserContextService.Client userClient = userServiceClient.getClient();
68
                userClient.removeCoupon(cartId);
82
                userClient.removeCoupon(cartId);
69
                DataLogger.logData(EventType.COUPON_REMOVED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
83
                DataLogger.logData(EventType.COUPON_REMOVED, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), couponCode);
70
            }
84
            }