Subversion Repositories SmartDukaan

Rev

Rev 507 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 507 Rev 517
Line 1... Line 1...
1
package in.shop2020.serving.utils;
1
package in.shop2020.serving.utils;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
-
 
4
import java.util.Calendar;
4
import java.util.Date;
5
import java.util.Date;
5
import java.util.HashMap;
6
import java.util.HashMap;
6
import java.util.Iterator;
7
import java.util.Iterator;
7
import java.util.List;
8
import java.util.List;
8
import java.util.Map;
9
import java.util.Map;
Line 138... Line 139...
138
		return cartId;
139
		return cartId;
139
		//if user is logged in create  new cart
140
		//if user is logged in create  new cart
140
		//if( userClient.getState(userId, false).isIsLoggedIn()){
141
		//if( userClient.getState(userId, false).isIsLoggedIn()){
141
	}
142
	}
142
 
143
 
143
	public static boolean deleteItemFromCart(long catalogItemId, long userId, boolean isSessionId){
144
	public static boolean deleteItemFromCart(long cartId, long catalogItemId, long userId, boolean isSessionId){
144
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = shoppingCartClient.getClient();
145
		in.shop2020.model.v1.shoppingcart.ShoppingCartService.Client cartClient = shoppingCartClient.getClient();
145
		long cartId = -1;
-
 
146
		
-
 
147
		try {
146
		try {
148
			
-
 
149
			cartId = cartClient.createCart(userId, isSessionId);
-
 
150
			cartClient.deleteItemFromCart(cartId, catalogItemId);
147
			cartClient.deleteItemFromCart(cartId, catalogItemId);
151
			//cartClient.changeItemStatus(cartId, catalogItemId, LineStatus.LINE_DELETED);
-
 
152
			return true;	
148
			return true;	
153
		} catch (ShoppingCartException e) {
149
		} catch (ShoppingCartException e) {
154
			// TODO Auto-generated catch block
150
			// TODO Auto-generated catch block
155
			e.printStackTrace();
151
			e.printStackTrace();
156
		} catch (TException e) {
152
		} catch (TException e) {
Line 260... Line 256...
260
			List<Line> lineItems = cart.getLines(); 
256
			List<Line> lineItems = cart.getLines(); 
261
		
257
		
262
			for (Line line : lineItems) {
258
			for (Line line : lineItems) {
263
				long productId = line.getItemId();
259
				long productId = line.getItemId();
264
				totalAmount =  totalAmount + line.getQuantity() * Utils.getItemPriceByCatalogId(productId);
260
				totalAmount =  totalAmount + line.getQuantity() * Utils.getItemPriceByCatalogId(productId);
-
 
261
				
265
			}
262
			}
266
 
263
 
267
		} catch (ShoppingCartException e) {
264
		} catch (ShoppingCartException e) {
268
			// TODO Auto-generated catch block
265
			// TODO Auto-generated catch block
269
			e.printStackTrace();
266
			e.printStackTrace();
Line 281... Line 278...
281
		Double itemPrice = 0.0;
278
		Double itemPrice = 0.0;
282
		try {
279
		try {
283
			catalogServiceClient = new CatalogServiceClient();
280
			catalogServiceClient = new CatalogServiceClient();
284
			client = catalogServiceClient.getClient();
281
			client = catalogServiceClient.getClient();
285
			Item item = client.getItemByCatalogId(productId);
282
			Item item = client.getItemByCatalogId(productId);
-
 
283
			itemPrice = item.getSellingPrice();
286
			/*
284
			/*
287
			Map<Long,Double> priceMap = item.getPrice();
285
			Map<Long,Double> priceMap = item.getPrice();
288
			if(priceMap == null || priceMap.isEmpty()){
286
			if(priceMap == null || priceMap.isEmpty()){
289
				System.out.println("Price Not Found");
287
				System.out.println("Price Not Found");
290
			}else{
288
			}else{
Line 341... Line 339...
341
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
339
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
342
		
340
		
343
		try {
341
		try {
344
			UserContext context = userClient.getContextFromId(userId, false);
342
			UserContext context = userClient.getContextFromId(userId, false);
345
			UserPrimaryInfo primaryInfo = context.getPrimaryInfo();
343
			UserPrimaryInfo primaryInfo = context.getPrimaryInfo();
-
 
344
			Calendar calendar = Calendar.getInstance();
-
 
345
			calendar.set(year + 1900, month, day);
346
			long dateOfBirth = (new Date(year, month, day)).getTime();
346
			long dateOfBirth = calendar.getTimeInMillis();
347
			
347
			
348
			primaryInfo.setDateOfBirth(dateOfBirth);
348
			primaryInfo.setDateOfBirth(dateOfBirth);
349
			primaryInfo.setFirstName(name);
349
			primaryInfo.setFirstName(name);
-
 
350
			primaryInfo.setCommunicationEmail(communicationEmail);
350
			context.setPrimaryInfo(primaryInfo);
351
			context.setPrimaryInfo(primaryInfo);
351
			userClient.createContext(context, true);
352
			userClient.createContext(context, true);
352
			return true;
353
			return true;
353
		} catch (UserContextException e) {
354
		} catch (UserContextException e) {
354
			// TODO Auto-generated catch block
355
			// TODO Auto-generated catch block