Subversion Repositories SmartDukaan

Rev

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

Rev 11976 Rev 12280
Line 1... Line 1...
1
package in.shop2020.catalog.dashboard.server;
1
package in.shop2020.catalog.dashboard.server;
2
 
2
 
3
import in.shop2020.catalog.dashboard.client.CatalogService;
3
import in.shop2020.catalog.dashboard.client.CatalogService;
4
 
-
 
5
import in.shop2020.catalog.dashboard.shared.FreebieItem;
-
 
6
import in.shop2020.catalog.dashboard.shared.Item;
4
import in.shop2020.catalog.dashboard.shared.Item;
7
import in.shop2020.catalog.dashboard.shared.ItemInventory;
5
import in.shop2020.catalog.dashboard.shared.ItemInventory;
8
import in.shop2020.catalog.dashboard.shared.ItemStatus;
6
import in.shop2020.catalog.dashboard.shared.ItemStatus;
-
 
7
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
9
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
8
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
10
import in.shop2020.catalog.dashboard.shared.SourcePricings;
9
import in.shop2020.catalog.dashboard.shared.SourcePricings;
11
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
10
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
12
import in.shop2020.catalog.dashboard.shared.VendorPricings;
11
import in.shop2020.catalog.dashboard.shared.VendorPricings;
13
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
12
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
Line 18... Line 17...
18
import in.shop2020.model.v1.catalog.CatalogServiceException;
17
import in.shop2020.model.v1.catalog.CatalogServiceException;
19
import in.shop2020.model.v1.catalog.Insurer;
18
import in.shop2020.model.v1.catalog.Insurer;
20
import in.shop2020.model.v1.catalog.ItemType;
19
import in.shop2020.model.v1.catalog.ItemType;
21
import in.shop2020.model.v1.catalog.PrivateDeal;
20
import in.shop2020.model.v1.catalog.PrivateDeal;
22
import in.shop2020.model.v1.catalog.status;
21
import in.shop2020.model.v1.catalog.status;
-
 
22
import in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems;
23
import in.shop2020.model.v1.inventory.InventoryService;
23
import in.shop2020.model.v1.inventory.InventoryService;
24
import in.shop2020.model.v1.inventory.ItemStockPurchaseParams;
24
import in.shop2020.model.v1.inventory.ItemStockPurchaseParams;
25
import in.shop2020.model.v1.inventory.OOSStatus;
25
import in.shop2020.model.v1.inventory.OOSStatus;
-
 
26
import in.shop2020.model.v1.inventory.StateInfo;
-
 
27
import in.shop2020.model.v1.inventory.VatType;
26
import in.shop2020.model.v1.user.VoucherType;
28
import in.shop2020.model.v1.user.VoucherType;
27
import in.shop2020.thrift.clients.CatalogClient;
29
import in.shop2020.thrift.clients.CatalogClient;
28
import in.shop2020.thrift.clients.ContentClient;
30
import in.shop2020.thrift.clients.ContentClient;
29
import in.shop2020.thrift.clients.InventoryClient;
31
import in.shop2020.thrift.clients.InventoryClient;
30
import in.shop2020.thrift.clients.config.ConfigClient;
32
import in.shop2020.thrift.clients.config.ConfigClient;
31
import in.shop2020.utils.CategoryManager;
33
import in.shop2020.utils.CategoryManager;
32
import in.shop2020.utils.ConfigClientKeys;
34
import in.shop2020.utils.ConfigClientKeys;
33
import in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems;
-
 
34
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
-
 
-
 
35
 
35
import java.io.BufferedReader;
36
import java.io.BufferedReader;
36
import java.io.FileReader;
37
import java.io.FileReader;
37
import java.io.IOException;
38
import java.io.IOException;
38
import java.text.DateFormat;
39
import java.text.DateFormat;
39
import java.text.SimpleDateFormat;
40
import java.text.SimpleDateFormat;
Line 47... Line 48...
47
import java.util.List;
48
import java.util.List;
48
import java.util.Map;
49
import java.util.Map;
49
import java.util.Map.Entry;
50
import java.util.Map.Entry;
50
import java.util.Set;
51
import java.util.Set;
51
 
52
 
52
import org.apache.log4j.Logger;
-
 
53
import org.apache.thrift.TException;
53
import org.apache.thrift.TException;
54
import org.apache.thrift.transport.TTransportException;
54
import org.apache.thrift.transport.TTransportException;
55
 
55
 
-
 
56
import com.google.gwt.core.client.impl.AsyncFragmentLoader.Logger;
56
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
57
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
57
 
58
 
58
@SuppressWarnings("serial")
59
@SuppressWarnings("serial")
59
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
60
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
60
 
61
 
Line 352... Line 353...
352
						sameItemsWithDifferentColors.add(id); 
353
						sameItemsWithDifferentColors.add(id); 
353
					}
354
					}
354
				}
355
				}
355
			}
356
			}
356
			List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
357
			List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
357
			Map<Long,String> stateIdNameMap = inventoryClient.getStateMaster();
358
			Map<Long,StateInfo> stateIdNameMap = inventoryClient.getStateMaster();
358
 
359
 
359
			List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
360
			List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
360
			List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
361
			List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
361
			List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
362
			List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
362
			in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
363
			in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
Line 383... Line 384...
383
			Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
384
			Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
384
			List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
385
			List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
385
			Map<String,String> stateNameVatPercentageMap = new HashMap<String,String>();
386
			Map<String,String> stateNameVatPercentageMap = new HashMap<String,String>();
386
			catalogClient =  new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
387
			catalogClient =  new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
387
			double vatrate;
388
			double vatrate;
388
			for(Entry<Long, String> entry:stateIdNameMap.entrySet()){
389
			for(Entry<Long, StateInfo> entry:stateIdNameMap.entrySet()){
-
 
390
				vatrate = -1.0;
-
 
391
				StateInfo state = entry.getValue();
-
 
392
				double price = state.getVatType().equals(VatType.MRP)? thriftItem.getMrp() : thriftItem.getSellingPrice();
-
 
393
				if(price > 0){
389
				try{
394
					try{
390
					vatrate= catalogClient.getVatPercentageForItem(thriftItem.getId(),entry.getKey(),thriftItem.getSellingPrice());
395
						vatrate = catalogClient.getVatPercentageForItem(thriftItem.getId(),entry.getKey(),price);
-
 
396
					}
-
 
397
					catch(CatalogServiceException cex){
-
 
398
						vatrate = -1.0;
-
 
399
					}
-
 
400
				} else {
-
 
401
					vatrate = -2.0;
391
				}
402
				}
392
				catch(CatalogServiceException cex){
403
				if(vatrate != -2.0) {
-
 
404
					stateNameVatPercentageMap.put(state.getStateName(),String.valueOf(vatrate));
393
					vatrate = -1.0;
405
				} else {
-
 
406
					stateNameVatPercentageMap.put(state.getStateName(),"MRP needed");
394
				}
407
				}
395
				stateNameVatPercentageMap.put(entry.getValue(),String.valueOf(vatrate));
-
 
396
			}
408
			}
397
			Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, saleHistory, freebieItemId , stateNameVatPercentageMap,privateDeal);
409
			Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, saleHistory, freebieItemId , stateNameVatPercentageMap,privateDeal);
398
			it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
410
			it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
399
			return it;
411
			return it;
400
		}catch(Exception e){
412
		}catch(Exception e){