Subversion Repositories SmartDukaan

Rev

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

Rev 5716 Rev 5746
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.logistics.LogisticsService.Client;
4
import in.shop2020.logistics.LogisticsService;
5
import in.shop2020.logistics.PickupStore;
5
import in.shop2020.logistics.PickupStore;
6
 
6
 
7
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.user.Address;
8
import in.shop2020.model.v1.user.Address;
9
import in.shop2020.model.v1.user.AddressType;
9
import in.shop2020.model.v1.user.AddressType;
Line 27... Line 27...
27
import org.apache.log4j.Logger;
27
import org.apache.log4j.Logger;
28
import org.apache.struts2.convention.annotation.InterceptorRef;
28
import org.apache.struts2.convention.annotation.InterceptorRef;
29
import org.apache.struts2.convention.annotation.InterceptorRefs;
29
import org.apache.struts2.convention.annotation.InterceptorRefs;
30
import org.apache.struts2.convention.annotation.Result;
30
import org.apache.struts2.convention.annotation.Result;
31
import org.apache.struts2.convention.annotation.Results;
31
import org.apache.struts2.convention.annotation.Results;
-
 
32
import org.apache.thrift.TException;
32
import org.apache.velocity.VelocityContext;
33
import org.apache.velocity.VelocityContext;
33
 
34
 
34
@SuppressWarnings("serial")
35
@SuppressWarnings("serial")
35
@InterceptorRefs({
36
@InterceptorRefs({
36
    @InterceptorRef("myDefault"),
37
    @InterceptorRef("myDefault"),
Line 56... Line 57...
56
	private String pincode;
57
	private String pincode;
57
	private String phone;
58
	private String phone;
58
	private String country;
59
	private String country;
59
	private String selectedTab = "myLocation";
60
	private String selectedTab = "myLocation";
60
	
61
	
-
 
62
	private static List<PickupStore> storeAddresses = new ArrayList<PickupStore>();
-
 
63
	private static final List<String> allZones = new ArrayList<String>();
-
 
64
	    
-
 
65
    static {
-
 
66
        try {
-
 
67
            allZones.add("All");
-
 
68
            LogisticsService.Client logisticsClient = (new LogisticsClient()).getClient();
-
 
69
            storeAddresses = logisticsClient.getAllPickupStores();
-
 
70
            for (PickupStore store : storeAddresses) {
-
 
71
                if(!allZones.contains(store.getZone())) {
-
 
72
                    allZones.add(store.getZone());
-
 
73
                }
-
 
74
            }
-
 
75
        } catch (TException e) {
-
 
76
            e.printStackTrace();
-
 
77
        }
-
 
78
    }
-
 
79
	
61
	public ShippingController(){
80
	public ShippingController(){
62
		super();
81
		super();
63
	}
82
	}
64
	
83
	
65
	 // GET /shipping
84
	 // GET /shipping
Line 202... Line 221...
202
		double totalamount= 0.0;
221
		double totalamount= 0.0;
203
		List<Address> addresses = null;
222
		List<Address> addresses = null;
204
		long defaultAddressId = 0;
223
		long defaultAddressId = 0;
205
		long defaultStoreAddressId = 0;
224
		long defaultStoreAddressId = 0;
206
		String phoneNumber = "";
225
		String phoneNumber = "";
207
		List<PickupStore> storeAddresses = null;
-
 
208
 
226
 
209
		CatalogClient catalogServiceClient  = null;
227
		CatalogClient catalogServiceClient  = null;
210
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
228
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
211
		UserClient userContextServiceClient = null;
229
		UserClient userContextServiceClient = null;
212
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
230
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
Line 252... Line 270...
252
			totalamount = cart.getTotalPrice();
270
			totalamount = cart.getTotalPrice();
253
			addresses = userClient.getAllAddressesForUser(userId);
271
			addresses = userClient.getAllAddressesForUser(userId);
254
			User user = userClient.getUserById(userId);
272
			User user = userClient.getUserById(userId);
255
			phoneNumber = user.getMobileNumber();
273
			phoneNumber = user.getMobileNumber();
256
			
274
			
257
			LogisticsClient logisticsServiceClient = new LogisticsClient();
-
 
258
            Client logisticsClient = logisticsServiceClient.getClient();
-
 
259
            storeAddresses = logisticsClient.getAllPickupStores();
-
 
260
            
-
 
261
            
-
 
262
 
-
 
263
			if(cart.isSetAddressId())	{
275
			if(cart.isSetAddressId())	{
264
				defaultAddressId = cart.getAddressId();
276
				defaultAddressId = cart.getAddressId();
265
			} else	{
277
			} else	{
266
				defaultAddressId = userClient.getDefaultAddressId(userId);
278
				defaultAddressId = userClient.getDefaultAddressId(userId);
267
			}
279
			}
Line 285... Line 297...
285
		context.put("defaultAddressId", defaultAddressId+"");
297
		context.put("defaultAddressId", defaultAddressId+"");
286
		context.put("defaultStoreAddressId", defaultStoreAddressId+"");
298
		context.put("defaultStoreAddressId", defaultStoreAddressId+"");
287
		context.put("errorMsg", errorMsg);
299
		context.put("errorMsg", errorMsg);
288
		context.put("selectedTab", selectedTab);
300
		context.put("selectedTab", selectedTab);
289
		context.put("storeAddresses", storeAddresses);
301
		context.put("storeAddresses", storeAddresses);
-
 
302
		context.put("allZones", allZones);
290
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
303
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
291
		return htmlString;
304
		return htmlString;
292
	}
305
	}
293
	
306
	
294
	public long getAddressId(){
307
	public long getAddressId(){
Line 384... Line 397...
384
    }
397
    }
385
    
398
    
386
    public void setSt(String selectedTab) {
399
    public void setSt(String selectedTab) {
387
        this.selectedTab = selectedTab;
400
        this.selectedTab = selectedTab;
388
    }
401
    }
-
 
402
 
-
 
403
    public static List<String> getAllZones() {
-
 
404
        return allZones;
-
 
405
    }
389
}
406
}
390
407