Subversion Repositories SmartDukaan

Rev

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

Rev 5572 Rev 5614
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;
-
 
5
import in.shop2020.logistics.PickupStore;
-
 
6
 
-
 
7
import in.shop2020.model.v1.catalog.Item;
4
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.user.Address;
5
import in.shop2020.model.v1.user.Address;
9
import in.shop2020.model.v1.user.AddressType;
6
import in.shop2020.model.v1.user.AddressType;
10
import in.shop2020.model.v1.user.Cart;
7
import in.shop2020.model.v1.user.Cart;
11
import in.shop2020.model.v1.user.Line;
8
import in.shop2020.model.v1.user.Line;
12
import in.shop2020.model.v1.user.User;
9
import in.shop2020.model.v1.user.User;
13
import in.shop2020.model.v1.user.UserContextService;
10
import in.shop2020.model.v1.user.UserContextService;
14
import in.shop2020.serving.utils.FormattingUtils;
11
import in.shop2020.serving.utils.FormattingUtils;
15
import in.shop2020.serving.utils.Utils;
12
import in.shop2020.serving.utils.Utils;
16
import in.shop2020.thrift.clients.CatalogClient;
13
import in.shop2020.thrift.clients.CatalogClient;
17
import in.shop2020.thrift.clients.LogisticsClient;
-
 
18
import in.shop2020.thrift.clients.UserClient;
14
import in.shop2020.thrift.clients.UserClient;
19
import in.shop2020.utils.DataLogger;
15
import in.shop2020.utils.DataLogger;
20
 
16
 
21
import java.util.ArrayList;
17
import java.util.ArrayList;
22
import java.util.Collection;
18
import java.util.Collection;
Line 37... Line 33...
37
    @InterceptorRef("login")
33
    @InterceptorRef("login")
38
})
34
})
39
 
35
 
40
@Results({
36
@Results({
41
    @Result(name="redirect", type="redirectAction", 
37
    @Result(name="redirect", type="redirectAction", 
42
    		params = {"actionName" , "shipping", "st", "${selectedTab}"})
38
    		params = {"actionName" , "shipping"})
43
})
39
})
44
public class ShippingController extends BaseController{
40
public class ShippingController extends BaseController{
45
	
41
	
46
	private static Logger log = Logger.getLogger(ShippingController.class);
42
	private static Logger log = Logger.getLogger(ShippingController.class);
47
    
43
    
Line 54... Line 50...
54
	private String city;
50
	private String city;
55
	private String state = "";
51
	private String state = "";
56
	private String pincode;
52
	private String pincode;
57
	private String phone;
53
	private String phone;
58
	private String country;
54
	private String country;
59
	private String selectedTab = "myLocation";
-
 
60
	
55
	
61
	public ShippingController(){
56
	public ShippingController(){
62
		super();
57
		super();
63
	}
58
	}
64
	
59
	
Line 163... Line 158...
163
					return "redirect";				
158
					return "redirect";				
164
				}
159
				}
165
				
160
				
166
				if(action.equals("change"))	{
161
				if(action.equals("change"))	{
167
					addressId = Long.parseLong(this.request.getParameter("addressid"));
162
					addressId = Long.parseLong(this.request.getParameter("addressid"));
168
					if(request.getParameter("selectedTab").equals("HotSpot")) {
-
 
169
					    userClient.addStoreToCart(userinfo.getCartId(), addressId);
-
 
170
					} else {
-
 
171
					    userClient.addAddressToCart(userinfo.getCartId(), addressId);
163
					userClient.addAddressToCart(userinfo.getCartId(), addressId);
172
					}
-
 
173
					
164
					
174
					errorMsg = userClient.validateCart(userinfo.getCartId(), sourceId);
165
					errorMsg = userClient.validateCart(userinfo.getCartId(), sourceId);
175
                    DataLogger.logData(EventType.SHIPPINIG_ADD_CHANGE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
166
                    DataLogger.logData(EventType.SHIPPINIG_ADD_CHANGE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
176
                            Long.toString(userinfo.getCartId()), Long.toString(addressId));
167
                            Long.toString(userinfo.getCartId()), Long.toString(addressId));
177
					return "index";
168
					return "index";
Line 200... Line 191...
200
		String templateFile = "templates/shippingdetails.vm";
191
		String templateFile = "templates/shippingdetails.vm";
201
		List<Map<String,String>> items = null;
192
		List<Map<String,String>> items = null;
202
		double totalamount= 0.0;
193
		double totalamount= 0.0;
203
		List<Address> addresses = null;
194
		List<Address> addresses = null;
204
		long defaultAddressId = 0;
195
		long defaultAddressId = 0;
205
		long defaultStoreAddressId = 0;
-
 
206
		String phoneNumber = "";
196
		String phoneNumber = "";
207
		List<PickupStore> storeAddresses = null;
-
 
208
 
197
 
209
		CatalogClient catalogServiceClient  = null;
198
		CatalogClient catalogServiceClient  = null;
210
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
199
		in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = null;
211
		UserClient userContextServiceClient = null;
200
		UserClient userContextServiceClient = null;
212
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
201
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
Line 251... Line 240...
251
			}
240
			}
252
			totalamount = cart.getTotalPrice();
241
			totalamount = cart.getTotalPrice();
253
			addresses = userClient.getAllAddressesForUser(userId);
242
			addresses = userClient.getAllAddressesForUser(userId);
254
			User user = userClient.getUserById(userId);
243
			User user = userClient.getUserById(userId);
255
			phoneNumber = user.getMobileNumber();
244
			phoneNumber = user.getMobileNumber();
256
			
-
 
257
			LogisticsClient logisticsServiceClient = new LogisticsClient();
-
 
258
            Client logisticsClient = logisticsServiceClient.getClient();
-
 
259
            storeAddresses = logisticsClient.getAllPickupStores();
-
 
260
            
-
 
261
            
-
 
262
 
245
 
263
			if(cart.isSetAddressId())	{
246
			if(cart.isSetAddressId())	{
264
				defaultAddressId = cart.getAddressId();
247
				defaultAddressId = cart.getAddressId();
265
			} else	{
248
			} else	{
266
				defaultAddressId = userClient.getDefaultAddressId(userId);
249
				defaultAddressId = userClient.getDefaultAddressId(userId);
267
			}
250
			}
268
			
-
 
269
			if(cart.isSetPickupStoreId())    {
-
 
270
                defaultStoreAddressId = cart.getPickupStoreId();
-
 
271
            }
-
 
272
	        
251
	        
273
			String couponCode = cart.getCouponCode();
252
			String couponCode = cart.getCouponCode();
274
	        context.put("couponcode", couponCode == null ? "" : couponCode);
253
	        context.put("couponcode", couponCode == null ? "" : couponCode);
275
	        context.put("discountedamount", formattingUtils.formatPrice(cart.getDiscountedPrice()));
254
	        context.put("discountedamount", formattingUtils.formatPrice(cart.getDiscountedPrice()));
276
	        
255
	        
Line 281... Line 260...
281
		context.put("phonenumber", phoneNumber);
260
		context.put("phonenumber", phoneNumber);
282
		context.put("items", items);
261
		context.put("items", items);
283
		context.put("totalamount", formattingUtils.formatPrice(totalamount));
262
		context.put("totalamount", formattingUtils.formatPrice(totalamount));
284
		context.put("addresses", addresses);
263
		context.put("addresses", addresses);
285
		context.put("defaultAddressId", defaultAddressId+"");
264
		context.put("defaultAddressId", defaultAddressId+"");
286
		context.put("defaultStoreAddressId", defaultStoreAddressId+"");
-
 
287
		context.put("errorMsg", errorMsg);
265
		context.put("errorMsg", errorMsg);
288
		context.put("selectedTab", selectedTab);
-
 
289
		context.put("storeAddresses", storeAddresses);
-
 
290
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
266
		htmlString = pageLoader.getHtmlFromVelocity(templateFile, context);
291
		return htmlString;
267
		return htmlString;
292
	}
268
	}
293
	
269
	
294
	public long getAddressId(){
270
	public long getAddressId(){
Line 372... Line 348...
372
			url = "?" + url;
348
			url = "?" + url;
373
		}
349
		}
374
		url = request.getRequestURI() + url;
350
		url = request.getRequestURI() + url;
375
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), url , 0, false);
351
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), url , 0, false);
376
	}
352
	}
377
 
-
 
378
    public String getSelectedTab() {
-
 
379
        return selectedTab;
-
 
380
    }
-
 
381
 
-
 
382
    public void setSelectedTab(String selectedTab) {
-
 
383
        this.selectedTab = selectedTab;
-
 
384
    }
-
 
385
    
-
 
386
    public void setSt(String selectedTab) {
-
 
387
        this.selectedTab = selectedTab;
-
 
388
    }
-
 
389
}
353
}
390
354