Subversion Repositories SmartDukaan

Rev

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

Rev 6390 Rev 6407
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.EmiChargeType;
4
import in.shop2020.model.v1.order.EmiScheme;
5
import in.shop2020.model.v1.order.EmiScheme;
5
import in.shop2020.model.v1.order.TransactionService.Client;
6
import in.shop2020.model.v1.order.TransactionService.Client;
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.Cart;
8
import in.shop2020.model.v1.user.Cart;
8
import in.shop2020.model.v1.user.PromotionService;
9
import in.shop2020.model.v1.user.PromotionService;
Line 11... Line 12...
11
import in.shop2020.thrift.clients.PromotionClient;
12
import in.shop2020.thrift.clients.PromotionClient;
12
import in.shop2020.thrift.clients.TransactionClient;
13
import in.shop2020.thrift.clients.TransactionClient;
13
import in.shop2020.thrift.clients.UserClient;
14
import in.shop2020.thrift.clients.UserClient;
14
import in.shop2020.utils.DataLogger;
15
import in.shop2020.utils.DataLogger;
15
 
16
 
-
 
17
import java.util.ArrayList;
16
import java.util.Collection;
18
import java.util.Collection;
17
import java.util.List;
19
import java.util.List;
18
import java.util.ResourceBundle;
20
import java.util.ResourceBundle;
19
 
21
 
20
import org.apache.commons.lang.StringUtils;
22
import org.apache.commons.lang.StringUtils;
Line 24... Line 26...
24
import org.apache.struts2.convention.annotation.Result;
26
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Results;
27
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.thrift.TException;
28
import org.apache.thrift.TException;
27
import org.apache.thrift.transport.TTransportException;
29
import org.apache.thrift.transport.TTransportException;
28
 
30
 
-
 
31
import com.google.gson.Gson;
-
 
32
 
29
@SuppressWarnings("serial")
33
@SuppressWarnings("serial")
30
@InterceptorRefs({
34
@InterceptorRefs({
31
    @InterceptorRef("myDefault"),
35
    @InterceptorRef("myDefault"),
32
    @InterceptorRef("login")
36
    @InterceptorRef("login")
33
})
37
})
Line 44... Line 48...
44
    
48
    
45
    private static List<EmiScheme> emiSchemes;
49
    private static List<EmiScheme> emiSchemes;
46
    private boolean hasGiftVoucher = false;
50
    private boolean hasGiftVoucher = false;
47
    private long addressId = -1;
51
    private long addressId = -1;
48
    private String totalAmount = "";
52
    private String totalAmount = "";
-
 
53
    private double totalAmountD = 0l;
49
    private boolean showCodOption = true;
54
    private boolean showCodOption = true;
50
    private boolean showEmiOption = false;
55
    private boolean showEmiOption = false;
51
    private String errorMsg = "";
56
    private String errorMsg = "";
52
    private String deliveryLocation = ""; //This could be set as myLocation or HotSpot
57
    private String deliveryLocation = ""; //This could be set as myLocation or HotSpot
53
    private boolean showStorePickUpOption = false;
58
    private boolean showStorePickUpOption = false;
54
    private long hotSpotAddressId = 1;
59
    private long hotSpotAddressId = 1;
55
    
60
    
-
 
61
    
56
    public String index(){
62
    public String index(){
57
        return processPaymentOptions();
63
        return processPaymentOptions();
58
    }
64
    }
59
    
65
    
60
    public String create(){
66
    public String create(){
Line 116... Line 122...
116
            
122
            
117
            if (!hasGiftVoucher && deliveryLocation.equals("HotSpot")) {
123
            if (!hasGiftVoucher && deliveryLocation.equals("HotSpot")) {
118
            	userClient.addStoreToCart(cartId, hotSpotAddressId);
124
            	userClient.addStoreToCart(cartId, hotSpotAddressId);
119
            	showStorePickUpOption = true;
125
            	showStorePickUpOption = true;
120
            }
126
            }
121
            
-
 
122
            setTotalAmount(cart);
127
            setTotalAmount(cart);
123
            itemIdString = Utils.getItemIdStringInCart(cart);
128
            itemIdString = Utils.getItemIdStringInCart(cart);
124
            
129
            
125
            
130
            
126
            // Get the address to check if COD option is available for this
131
            // Get the address to check if COD option is available for this
Line 167... Line 172...
167
			logger.error("Error while getting EMI schemes: ", e);
172
			logger.error("Error while getting EMI schemes: ", e);
168
		}
173
		}
169
    }
174
    }
170
    
175
    
171
    private void setTotalAmount(Cart cart) {
176
    private void setTotalAmount(Cart cart) {
172
        FormattingUtils formattingUtils = new FormattingUtils();
-
 
173
        String couponCode = cart.getCouponCode();
177
    	String couponCode = cart.getCouponCode();
174
        if(couponCode == null || "".equals(couponCode))
178
        if(couponCode == null || "".equals(couponCode))
175
            totalAmount = formattingUtils.formatPrice(cart.getTotalPrice());
179
        	totalAmountD = cart.getTotalPrice();
176
        else
180
        else
-
 
181
            totalAmountD = cart.getDiscountedPrice();
-
 
182
        
-
 
183
        FormattingUtils formattingUtils = new FormattingUtils();
177
            totalAmount = formattingUtils.formatPrice(cart.getDiscountedPrice());
184
        totalAmount = formattingUtils.formatPrice(totalAmountD);
178
    }
185
    }
179
 
186
 
180
    public long getAddressId(){
187
    public long getAddressId(){
181
        return this.addressId;
188
        return this.addressId;
182
    }
189
    }
Line 196... Line 203...
196
 
203
 
197
    public String getTotalAmount(){
204
    public String getTotalAmount(){
198
        return totalAmount;
205
        return totalAmount;
199
    }
206
    }
200
    
207
    
-
 
208
    public double getTotalAmountL(){
-
 
209
    	return totalAmountD;
-
 
210
    }
-
 
211
    
201
    public boolean shouldShowEbsTestGateway() {
212
    public boolean shouldShowEbsTestGateway() {
202
        return SHOW_EBS_TEST_GATEWAY;
213
        return SHOW_EBS_TEST_GATEWAY;
203
    }
214
    }
204
    
215
    
205
	@Override
216
	@Override
Line 232... Line 243...
232
 
243
 
233
    public boolean shouldShowStorePickUpOption() {
244
    public boolean shouldShowStorePickUpOption() {
234
        return showStorePickUpOption;
245
        return showStorePickUpOption;
235
    }
246
    }
236
    
247
    
-
 
248
    public String getJSONEmiSchemes(){
-
 
249
    	getEmiSchemes();
-
 
250
    	Double totalAmount = getTotalAmountL();
-
 
251
    	List<EmiScheme> schemes = new ArrayList<EmiScheme>();
-
 
252
    	for(EmiScheme emiScheme : emiSchemes) {
-
 
253
    		if(emiScheme.getMinAmount() <= totalAmount ) {
-
 
254
    			schemes.add(emiScheme);
-
 
255
    		}
-
 
256
    	}
-
 
257
    	Gson gson  = new Gson();
-
 
258
    	return gson.toJson(schemes);
-
 
259
    }
-
 
260
    
237
    public List<EmiScheme> getEmiSchemes(){
261
    public List<EmiScheme> getEmiSchemes(){
-
 
262
    	/*List<EmiScheme> schemes = new ArrayList<EmiScheme>();
-
 
263
    	schemes.add(new EmiScheme(1,1,1,3,"HDFC Bank", 2000, "3 Months", EmiChargeType.FIXED, 500));
-
 
264
    	schemes.add(new EmiScheme(2,1,1,6,"HDFC Bank", 4000, "6 Months", EmiChargeType.FIXED, 1000));
-
 
265
    	schemes.add(new EmiScheme(3,1,1,9,"HDFC Bank", 6000, "9 Months", EmiChargeType.FIXED, 1500));
-
 
266
    	schemes.add(new EmiScheme(4,1,1,12,"HDFC Bank", 6000, "12 Months", EmiChargeType.FIXED, 2000));
-
 
267
    	schemes.add(new EmiScheme(5,1,2,6,"ICICI Bank", 7000, "6 Months", EmiChargeType.FIXED, 1000));
-
 
268
    	schemes.add(new EmiScheme(6,1,2,9,"ICICI Bank", 7000,"9 Months", EmiChargeType.FIXED, 1500));
-
 
269
    	schemes.add(new EmiScheme(7,1,2,12,"ICICI Bank", 7000, "12 Months", EmiChargeType.FIXED, 2000));
-
 
270
    	schemes.add(new EmiScheme(8,1,2,12,"ICICI Bank", 7000, "12 Months", EmiChargeType.PERCENTAGE, 3));
-
 
271
    	emiSchemes = schemes;*/ 
238
    	return emiSchemes;
272
    	return emiSchemes;
239
    }
273
    }
240
    
274
    
241
    public static long getGatewayId(long emiSchemeId){
275
    public static long getGatewayId(long emiSchemeId){
242
    	for(EmiScheme scheme: emiSchemes){
276
    	for(EmiScheme scheme: emiSchemes){