Subversion Repositories SmartDukaan

Rev

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

Rev 7798 Rev 7809
Line 36... Line 36...
36
	private long itemId;
36
	private long itemId;
37
	private String pincode;
37
	private String pincode;
38
	private String days = "-1";
38
	private String days = "-1";
39
	private boolean isCODAvailable;
39
	private boolean isCODAvailable;
40
	private boolean isOTGAvailable;
40
	private boolean isOTGAvailable;
-
 
41
	private String codDays = "-1";
41
	private Map<String, String> response = new HashMap<String, String>();
42
	private Map<String, String> response = new HashMap<String, String>();
42
	
43
	
43
	public EstimateController() {
44
	public EstimateController() {
44
		super();
45
		super();
45
	}
46
	}
46
    
47
    
47
    // GET /logout
48
    // GET /logout
48
    public HttpHeaders show(){
49
    public HttpHeaders show(){
-
 
50
    	Calendar cal = Calendar.getInstance();
49
    	LogisticsClient logisticsServiceClient = null;
51
    	LogisticsClient logisticsServiceClient = null;
50
    	try {
52
    	try {
51
			logisticsServiceClient = new LogisticsClient();
53
			logisticsServiceClient = new LogisticsClient();
52
			Client logisticsClient = logisticsServiceClient.getClient();
54
			Client logisticsClient = logisticsServiceClient.getClient();
53
			LogisticsInfo logistincInfo = logisticsClient.getLogisticsEstimation(itemId, pincode, DeliveryType.PREPAID);
55
			LogisticsInfo logistincInfo = logisticsClient.getLogisticsEstimation(itemId, pincode, DeliveryType.PREPAID);
54
			
56
			
55
			if(logistincInfo.getDeliveryTime()!=-1L){
57
			if(logistincInfo.getDeliveryTime()!=-1L){
56
				days = checkValidDeliveryEstimate((int)logistincInfo.getDeliveryTime());
58
				days = checkValidDeliveryEstimate((int)logistincInfo.getDeliveryTime());
-
 
59
				codDays = days;
-
 
60
				if(cal.get(Calendar.HOUR_OF_DAY) < 15){
-
 
61
					codDays = checkValidDeliveryEstimate((int)(logistincInfo.getDeliveryTime()+1));
-
 
62
				}
57
			}
63
			}
58
			
64
			
59
			isCODAvailable = logistincInfo.isCodAllowed();
65
			isCODAvailable = logistincInfo.isCodAllowed();
60
			isOTGAvailable = logistincInfo.isOtgAvailable();
66
			isOTGAvailable = logistincInfo.isOtgAvailable();
61
    	} catch (LogisticsServiceException e)	{
67
    	} catch (LogisticsServiceException e)	{
Line 67... Line 73...
67
			
73
			
68
		} catch (Exception e)	{
74
		} catch (Exception e)	{
69
    		
75
    		
70
		}
76
		}
71
		response.put("delivery_estimate", days);
77
		response.put("delivery_estimate", days);
-
 
78
		response.put("cod_delivery_estimate", codDays);
72
		response.put("is_cod_available_for_location", Boolean.toString(isCODAvailable));
79
		response.put("is_cod_available_for_location", Boolean.toString(isCODAvailable));
73
		response.put("on_time_guarantee", Boolean.toString(isOTGAvailable));
80
		response.put("on_time_guarantee", Boolean.toString(isOTGAvailable));
-
 
81
		SimpleDateFormat dateformat = new SimpleDateFormat("EEE dd-MMM-yyyy");
-
 
82
		response.put("system_date", dateformat.format(cal.getTime()));
74
		
83
		
75
		try{
84
		try{
76
			if(pincode.length() == 6 && !pincode.equals("110001")){
85
			if(pincode.length() == 6 && !pincode.equals("110001")){
77
				String requestOrigin = request.getHeader("referer").contains("cart")?"Cart":"Product";
86
				String requestOrigin = request.getHeader("referer").contains("cart")?"Cart":"Product";
78
				DataLogger.logData(EventType.DELIVERY_ESTIMATE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
87
				DataLogger.logData(EventType.DELIVERY_ESTIMATE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
Line 121... Line 130...
121
    				check = true;
130
    				check = true;
122
    				continue outer;
131
    				continue outer;
123
    			}
132
    			}
124
    		}
133
    		}
125
    		check= false;
134
    		check= false;
126
    		SimpleDateFormat dateformat = new SimpleDateFormat("dd-MMMM-yyyy");
135
    		SimpleDateFormat dateformat = new SimpleDateFormat("EEE dd-MMM-yyyy");
127
			businessDayToActualDateMap.put(days, dateformat.format(now.getTime()));
136
			businessDayToActualDateMap.put(days, dateformat.format(now.getTime()));
128
    	}
137
    	}
129
    	return businessDayToActualDateMap.get(days);
138
    	return businessDayToActualDateMap.get(days);
130
	}
139
	}
131
    
140