Subversion Repositories SmartDukaan

Rev

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

Rev 3967 Rev 4061
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.order.Order;
4
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.TransactionServiceException;
5
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
6
import in.shop2020.model.v1.user.Affiliate;
6
import in.shop2020.model.v1.user.Cart;
7
import in.shop2020.model.v1.user.Cart;
7
import in.shop2020.model.v1.user.ShoppingCartException;
8
import in.shop2020.model.v1.user.ShoppingCartException;
8
import in.shop2020.model.v1.user.TrackLogType;
9
import in.shop2020.model.v1.user.TrackLogType;
9
import in.shop2020.model.v1.user.UserAffiliateException;
10
import in.shop2020.model.v1.user.UserAffiliateException;
10
import in.shop2020.payments.PaymentException;
11
import in.shop2020.payments.PaymentException;
Line 34... Line 35...
34
	private static final long serialVersionUID = 1L;
35
	private static final long serialVersionUID = 1L;
35
	
36
	
36
	private static final String ITEM = "ITEM";
37
	private static final String ITEM = "ITEM";
37
	private static final String ITEMS = "ITEMS";
38
	private static final String ITEMS = "ITEMS";
38
	
39
	
-
 
40
	private static final String SHOOGLOO_AFF_NAME = "shoogloo";
-
 
41
	
39
	private static Logger log = Logger.getLogger(Class.class);
42
	private static Logger log = Logger.getLogger(Class.class);
40
	private FormattingUtils formattingUtils = new FormattingUtils();
43
	private FormattingUtils formattingUtils = new FormattingUtils();
41
    
44
    
-
 
45
	private boolean isShooglooAff  = false;
42
	
46
	
43
	long merchantPaymentId;
47
	long merchantPaymentId;
44
	List<Order> orders = null;
48
	List<Order> orders = null;
45
	String message = null;
49
	String message = null;
46
	
50
	
Line 77... Line 81...
77
			}else{
81
			}else{
78
				userinfo.setTotalItems(0);
82
				userinfo.setTotalItems(0);
79
				userinfo.setTotalAmount(0);
83
				userinfo.setTotalAmount(0);
80
			}
84
			}
81
			
85
			
82
			if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
-
 
83
	            long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
-
 
84
	            userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
-
 
85
                        Long.toString(merchantPaymentId), (new Date()).getTime());
-
 
86
	        }
-
 
87
			
-
 
88
			String suffix = ITEM;
86
			String suffix = ITEM;
89
			if(orders.size() > 1)
87
			if(orders.size() > 1)
90
			    suffix = ITEMS;
88
			    suffix = ITEMS;
91
			
89
			
92
			this.message = "You have successfully ordered <span class=\"orange\">" + orders.size() + " " + suffix + ".</span>";
90
			this.message = "You have successfully ordered <span class=\"orange\">" + orders.size() + " " + suffix + ".</span>";
93
			
91
			
-
 
92
			if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
-
 
93
                long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
-
 
94
                userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
-
 
95
                        Long.toString(merchantPaymentId), (new Date()).getTime());
-
 
96
                Affiliate aff = userServiceClient.getClient().getAffiliateById(affId);
-
 
97
                if (aff.getName().equals(SHOOGLOO_AFF_NAME)) {
-
 
98
                    isShooglooAff = true;
-
 
99
                }
-
 
100
            }
-
 
101
            
94
		} catch (PaymentException e) {
102
		} catch (PaymentException e) {
95
			log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
103
			log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
96
		} catch (TException e) {
104
		} catch (TException e) {
97
			log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
105
			log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
98
		} catch (TransactionServiceException e) {
106
		} catch (TransactionServiceException e) {
Line 119... Line 127...
119
	
127
	
120
	public String getMessage(){
128
	public String getMessage(){
121
		return this.message;
129
		return this.message;
122
	}
130
	}
123
	
131
	
-
 
132
	public boolean getIsShooglooAff() {
-
 
133
        return this.isShooglooAff;
-
 
134
    }
-
 
135
	
-
 
136
	public long getMerchantPaymentId() {
-
 
137
	    return merchantPaymentId;
-
 
138
	}
-
 
139
	
124
	@Override
140
	@Override
125
	public String getHeaderSnippet() {
141
	public String getHeaderSnippet() {
126
		String url = request.getQueryString();
142
		String url = request.getQueryString();
127
		if (url == null) {
143
		if (url == null) {
128
			url = "";
144
			url = "";