Subversion Repositories SmartDukaan

Rev

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

Rev 6356 Rev 6390
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.EmiScheme;
-
 
5
import in.shop2020.model.v1.order.TransactionService.Client;
4
import in.shop2020.model.v1.user.Address;
6
import in.shop2020.model.v1.user.Address;
5
import in.shop2020.model.v1.user.Cart;
7
import in.shop2020.model.v1.user.Cart;
6
import in.shop2020.model.v1.user.PromotionService;
8
import in.shop2020.model.v1.user.PromotionService;
7
import in.shop2020.serving.utils.FormattingUtils;
9
import in.shop2020.serving.utils.FormattingUtils;
8
import in.shop2020.serving.utils.Utils;
10
import in.shop2020.serving.utils.Utils;
9
import in.shop2020.thrift.clients.PromotionClient;
11
import in.shop2020.thrift.clients.PromotionClient;
-
 
12
import in.shop2020.thrift.clients.TransactionClient;
10
import in.shop2020.thrift.clients.UserClient;
13
import in.shop2020.thrift.clients.UserClient;
11
import in.shop2020.utils.DataLogger;
14
import in.shop2020.utils.DataLogger;
12
 
15
 
13
import java.util.Collection;
16
import java.util.Collection;
-
 
17
import java.util.List;
14
import java.util.ResourceBundle;
18
import java.util.ResourceBundle;
15
 
19
 
16
import org.apache.commons.lang.StringUtils;
20
import org.apache.commons.lang.StringUtils;
17
import org.apache.log4j.Logger;
21
import org.apache.log4j.Logger;
18
import org.apache.struts2.convention.annotation.InterceptorRef;
22
import org.apache.struts2.convention.annotation.InterceptorRef;
19
import org.apache.struts2.convention.annotation.InterceptorRefs;
23
import org.apache.struts2.convention.annotation.InterceptorRefs;
20
import org.apache.struts2.convention.annotation.Result;
24
import org.apache.struts2.convention.annotation.Result;
21
import org.apache.struts2.convention.annotation.Results;
25
import org.apache.struts2.convention.annotation.Results;
-
 
26
import org.apache.thrift.TException;
-
 
27
import org.apache.thrift.transport.TTransportException;
22
 
28
 
23
@SuppressWarnings("serial")
29
@SuppressWarnings("serial")
24
@InterceptorRefs({
30
@InterceptorRefs({
25
    @InterceptorRef("myDefault"),
31
    @InterceptorRef("myDefault"),
26
    @InterceptorRef("login")
32
    @InterceptorRef("login")
Line 34... Line 40...
34
    
40
    
35
    private static Logger logger = Logger.getLogger(ProceedToPayController.class);
41
    private static Logger logger = Logger.getLogger(ProceedToPayController.class);
36
    private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
42
    private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
37
    private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
43
    private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
38
    
44
    
-
 
45
    private static List<EmiScheme> emiSchemes;
39
    private boolean hasGiftVoucher = false;
46
    private boolean hasGiftVoucher = false;
40
    private long addressId = -1;
47
    private long addressId = -1;
41
    private String totalAmount = "";
48
    private String totalAmount = "";
42
    private boolean showCodOption = true;
49
    private boolean showCodOption = true;
43
    private boolean showEmiOption = false;
50
    private boolean showEmiOption = false;
Line 66... Line 73...
66
        }
73
        }
67
        return processPaymentOptions();
74
        return processPaymentOptions();
68
    }
75
    }
69
 
76
 
70
    private String processPaymentOptions() {
77
    private String processPaymentOptions() {
-
 
78
    	if(emiSchemes == null){
-
 
79
    		populateEmiSchemes();
-
 
80
    	}
-
 
81
    	
71
        String showEmiOptionStr = this.request.getParameter("showEmiOption");
82
        String showEmiOptionStr = this.request.getParameter("showEmiOption");
72
        if(showEmiOptionStr!=null){
83
        if(showEmiOptionStr!=null){
73
            try{
84
            try{
74
                showEmiOption = Boolean.parseBoolean(showEmiOptionStr);
85
                showEmiOption = Boolean.parseBoolean(showEmiOptionStr);
75
            }catch(Exception e){
86
            }catch(Exception e){
Line 144... Line 155...
144
        }
155
        }
145
        
156
        
146
        return "index";
157
        return "index";
147
    }
158
    }
148
 
159
 
-
 
160
    private void populateEmiSchemes(){
-
 
161
    	try {
-
 
162
			Client tClient = new TransactionClient().getClient();
-
 
163
			emiSchemes = tClient.getAvailableEmiSchemes();
-
 
164
		} catch (TTransportException e) {
-
 
165
			logger.error("Error while getting EMI schemes: ", e);
-
 
166
		} catch (TException e) {
-
 
167
			logger.error("Error while getting EMI schemes: ", e);
-
 
168
		}
-
 
169
    }
-
 
170
    
149
    private void setTotalAmount(Cart cart) {
171
    private void setTotalAmount(Cart cart) {
150
        FormattingUtils formattingUtils = new FormattingUtils();
172
        FormattingUtils formattingUtils = new FormattingUtils();
151
        String couponCode = cart.getCouponCode();
173
        String couponCode = cart.getCouponCode();
152
        if(couponCode == null || "".equals(couponCode))
174
        if(couponCode == null || "".equals(couponCode))
153
            totalAmount = formattingUtils.formatPrice(cart.getTotalPrice());
175
            totalAmount = formattingUtils.formatPrice(cart.getTotalPrice());
Line 209... Line 231...
209
    }
231
    }
210
 
232
 
211
    public boolean shouldShowStorePickUpOption() {
233
    public boolean shouldShowStorePickUpOption() {
212
        return showStorePickUpOption;
234
        return showStorePickUpOption;
213
    }
235
    }
-
 
236
    
-
 
237
    public List<EmiScheme> getEmiSchemes(){
-
 
238
    	return emiSchemes;
-
 
239
    }
-
 
240
    
-
 
241
    public static long getGatewayId(long emiSchemeId){
-
 
242
    	for(EmiScheme scheme: emiSchemes){
-
 
243
    		if(scheme.getId() == emiSchemeId){
-
 
244
    			return scheme.getGatewayId();
-
 
245
    		}
-
 
246
    	}
-
 
247
    	return 0;
-
 
248
    }
214
}
249
}
215
250