Subversion Repositories SmartDukaan

Rev

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

Rev 2949 Rev 3063
Line 9... Line 9...
9
import in.shop2020.model.v1.user.User;
9
import in.shop2020.model.v1.user.User;
10
import in.shop2020.model.v1.user.UserContextService;
10
import in.shop2020.model.v1.user.UserContextService;
11
import in.shop2020.serving.utils.FormattingUtils;
11
import in.shop2020.serving.utils.FormattingUtils;
12
import in.shop2020.serving.utils.Utils;
12
import in.shop2020.serving.utils.Utils;
13
import in.shop2020.thrift.clients.CatalogServiceClient;
13
import in.shop2020.thrift.clients.CatalogServiceClient;
-
 
14
import in.shop2020.thrift.clients.LogisticsServiceClient;
14
import in.shop2020.thrift.clients.UserContextServiceClient;
15
import in.shop2020.thrift.clients.UserContextServiceClient;
15
import in.shop2020.utils.DataLogger;
16
import in.shop2020.utils.DataLogger;
16
 
17
 
17
import java.util.ArrayList;
18
import java.util.ArrayList;
18
import java.util.Collection;
19
import java.util.Collection;
-
 
20
import java.util.Enumeration;
19
import java.util.HashMap;
21
import java.util.HashMap;
20
import java.util.List;
22
import java.util.List;
21
import java.util.Map;
23
import java.util.Map;
-
 
24
import java.util.Properties;
-
 
25
import java.util.ResourceBundle;
-
 
26
 
-
 
27
import net.tanesha.recaptcha.ReCaptcha;
-
 
28
import net.tanesha.recaptcha.ReCaptchaFactory;
22
 
29
 
23
import org.apache.log4j.Logger;
30
import org.apache.log4j.Logger;
24
import org.apache.struts2.convention.annotation.InterceptorRef;
31
import org.apache.struts2.convention.annotation.InterceptorRef;
25
import org.apache.struts2.convention.annotation.InterceptorRefs;
32
import org.apache.struts2.convention.annotation.InterceptorRefs;
26
import org.apache.struts2.convention.annotation.Result;
33
import org.apache.struts2.convention.annotation.Result;
Line 39... Line 46...
39
public class ShippingController extends BaseController{
46
public class ShippingController extends BaseController{
40
	
47
	
41
	private static final long serialVersionUID = 1L;
48
	private static final long serialVersionUID = 1L;
42
	private static Logger log = Logger.getLogger(Class.class);
49
	private static Logger log = Logger.getLogger(Class.class);
43
	
50
	
-
 
51
	private static final ResourceBundle resource = ResourceBundle.getBundle(ShippingController.class.getName());
-
 
52
	private static final double COD_CUTOFF_AMOUNT = Double.parseDouble(resource.getString("cod_cutoff_amount")); 
-
 
53
	private static final String RECAPTCHA_PUBLIC_KEY = resource.getString("recaptcha_public_key");
-
 
54
    
44
	private long addressId = 0;
55
	private long addressId = 0;
45
	private String errorMsg = "";
56
	private String errorMsg = "";
46
	
57
	
47
	private String name;
58
	private String name;
48
	private String line1;
59
	private String line1;
Line 51... Line 62...
51
	private String state = "";
62
	private String state = "";
52
	private String pincode;
63
	private String pincode;
53
	private String phone;
64
	private String phone;
54
	private String country;
65
	private String country;
55
	
66
	
-
 
67
	private boolean showCodOption = true;
-
 
68
	
56
	public ShippingController(){
69
	public ShippingController(){
57
		super();
70
		super();
58
	}
71
	}
59
	
72
	
60
	 // GET /shipping
73
	 // GET /shipping
Line 219... Line 232...
219
					itemdetail.put("ITEM_NAME", itemName);
232
					itemdetail.put("ITEM_NAME", itemName);
220
					itemdetail.put("ITEM_ID", line.getItemId()+"");
233
					itemdetail.put("ITEM_ID", line.getItemId()+"");
221
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
234
					itemdetail.put("ITEM_QUANTITY", ((int)line.getQuantity())+"");
222
					itemdetail.put("MRP", formattingUtils.formatPrice(item.getMrp()));
235
					itemdetail.put("MRP", formattingUtils.formatPrice(item.getMrp()));
223
					itemdetail.put("SELLING_PRICE", formattingUtils.formatPrice(item.getSellingPrice()));
236
					itemdetail.put("SELLING_PRICE", formattingUtils.formatPrice(item.getSellingPrice()));
-
 
237
					if(item.getSellingPrice() > COD_CUTOFF_AMOUNT)
-
 
238
					    showCodOption = false;
224
					itemdetail.put("TOTAL_PRICE", formattingUtils.formatPrice((item.getSellingPrice()*line.getQuantity())));
239
					itemdetail.put("TOTAL_PRICE", formattingUtils.formatPrice((item.getSellingPrice()*line.getQuantity())));
225
					itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
240
					itemdetail.put("SHIPPING_TIME", line.getEstimate()+"");
226
					items.add(itemdetail);
241
					items.add(itemdetail);
227
				}
242
				}
228
			}
243
			}
Line 236... Line 251...
236
			if(cart.isSetAddressId())	{
251
			if(cart.isSetAddressId())	{
237
				defaultAddressId = cart.getAddressId();
252
				defaultAddressId = cart.getAddressId();
238
			} else	{
253
			} else	{
239
				defaultAddressId = userClient.getDefaultAddressId(cart.getUserId());
254
				defaultAddressId = userClient.getDefaultAddressId(cart.getUserId());
240
			}
255
			}
-
 
256
			
-
 
257
	        for(Address address : addresses){
-
 
258
	            if(address.getId() == defaultAddressId){
-
 
259
	                try {
-
 
260
	                    LogisticsServiceClient lClient = new LogisticsServiceClient();
-
 
261
	                    showCodOption = showCodOption && lClient.getClient().isCodAllowed(address.getPin());
-
 
262
	                } catch(Exception e) {
-
 
263
	                    log.error("Error while checking if COD is available for: " + showCodOption);
-
 
264
	                    showCodOption = false; //Defaulting to defensive behaviour
-
 
265
	                }
-
 
266
	            }
-
 
267
	        }
241
	        
268
	        
242
			String couponCode = cart.getCouponCode();
269
			String couponCode = cart.getCouponCode();
243
	        context.put("couponcode", couponCode == null ? "" : couponCode);
270
	        context.put("couponcode", couponCode == null ? "" : couponCode);
244
	        context.put("discountedamount", formattingUtils.formatPrice(cart.getDiscountedPrice()));
271
	        context.put("discountedamount", formattingUtils.formatPrice(cart.getDiscountedPrice()));
245
	        
272
	        
Line 329... Line 356...
329
	}
356
	}
330
 
357
 
331
	public void setPhone(String phone) {
358
	public void setPhone(String phone) {
332
		this.phone = phone;
359
		this.phone = phone;
333
	}
360
	}
-
 
361
 
-
 
362
    public boolean shouldShowCodOption() {
-
 
363
        return showCodOption;
-
 
364
    }
-
 
365
    
-
 
366
    public String getPublicKey(){
-
 
367
        return RECAPTCHA_PUBLIC_KEY;
-
 
368
    }
334
}
369
}
335
370