Subversion Repositories SmartDukaan

Rev

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

Rev 9242 Rev 9478
Line 7... Line 7...
7
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
7
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
8
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
8
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
9
import in.shop2020.model.v1.order.SnapdealOrder;
9
import in.shop2020.model.v1.order.SnapdealOrder;
10
import in.shop2020.support.utils.ReportsUtils;
10
import in.shop2020.support.utils.ReportsUtils;
11
import in.shop2020.thrift.clients.CatalogClient;
11
import in.shop2020.thrift.clients.CatalogClient;
-
 
12
import in.shop2020.thrift.clients.InventoryClient;
12
import in.shop2020.thrift.clients.TransactionClient;
13
import in.shop2020.thrift.clients.TransactionClient;
13
 
14
 
14
import java.io.BufferedInputStream;
15
import java.io.BufferedInputStream;
15
import java.io.File;
16
import java.io.File;
16
import java.io.FileInputStream;
17
import java.io.FileInputStream;
Line 95... Line 96...
95
	private String serviceTax;
96
	private String serviceTax;
96
	private String courierCost;
97
	private String courierCost;
97
	private JSONObject itemObj;
98
	private JSONObject itemObj;
98
	private String isSuppressInventoryFeed;
99
	private String isSuppressInventoryFeed;
99
	private String isSuppressPriceFeed;
100
	private String isSuppressPriceFeed;
-
 
101
	private String maxNlc;
-
 
102
	private String sdItemCode;
100
 
103
 
101
 
104
 
102
 
105
 
-
 
106
	public String getSdItemCode() {
-
 
107
		return sdItemCode;
-
 
108
	}
-
 
109
 
-
 
110
	public void setSdItemCode(String sdItemCode) {
-
 
111
		this.sdItemCode = sdItemCode;
-
 
112
	}
-
 
113
 
103
	public String index() {
114
	public String index() {
104
		if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
115
		if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
105
			return "authfail";
116
			return "authfail";
106
		}
117
		}
107
		return "index";
118
		return "index";
Line 184... Line 195...
184
		}
195
		}
185
		if (snapdealItem.getServiceTax()!=Double.valueOf(serviceTax)){
196
		if (snapdealItem.getServiceTax()!=Double.valueOf(serviceTax)){
186
			snapdealItem.setServiceTax(Double.valueOf(serviceTax));
197
			snapdealItem.setServiceTax(Double.valueOf(serviceTax));
187
			commit = true;
198
			commit = true;
188
		}
199
		}
-
 
200
		if (snapdealItem.getMaxNlc()!=Double.valueOf(maxNlc)){
-
 
201
			snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
-
 
202
			commit = true;
-
 
203
		}
-
 
204
		if (!StringUtils.equalsIgnoreCase(snapdealItem.getSkuAtSnapdeal(), sdItemCode)){
-
 
205
			snapdealItem.setSkuAtSnapdeal(sdItemCode);
-
 
206
			commit=true;
-
 
207
		}
-
 
208
 
189
		if (commit){
209
		if (commit){
190
			catalogClient.addOrUpdateSnapdealItem(snapdealItem);
210
			catalogClient.addOrUpdateSnapdealItem(snapdealItem);
191
		}
211
		}
192
		return "index";
212
		return "index";
193
	}
213
	}
Line 203... Line 223...
203
		snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
223
		snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
204
		snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
224
		snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
205
		snapdealItem.setCourierCost(Double.valueOf(courierCost));
225
		snapdealItem.setCourierCost(Double.valueOf(courierCost));
206
		snapdealItem.setCommission(Double.valueOf(commission));
226
		snapdealItem.setCommission(Double.valueOf(commission));
207
		snapdealItem.setServiceTax(Double.valueOf(serviceTax));
227
		snapdealItem.setServiceTax(Double.valueOf(serviceTax));
-
 
228
		snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
-
 
229
		snapdealItem.setSkuAtSnapdeal(sdItemCode);
208
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
230
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
209
		catalogClient.addOrUpdateSnapdealItem(snapdealItem);
231
		catalogClient.addOrUpdateSnapdealItem(snapdealItem);
210
		return "index";
232
		return "index";
211
	}
233
	}
212
 
234
 
Line 222... Line 244...
222
		}
244
		}
223
		Item item = catalogClient.getItem(Long.valueOf(itemId));
245
		Item item = catalogClient.getItem(Long.valueOf(itemId));
224
		if (item.getId()==0){
246
		if (item.getId()==0){
225
			throw new CatalogServiceException();
247
			throw new CatalogServiceException();
226
		}
248
		}
-
 
249
		InventoryClient inventoryServiceClient = new InventoryClient();
-
 
250
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
251
		double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
227
		itemObj = new JSONObject();
252
		itemObj = new JSONObject();
228
		itemObj.put("ItemId", item.getId());
253
		itemObj.put("ItemId", item.getId());
229
		itemObj.put("Brand", item.getBrand());
254
		itemObj.put("Brand", item.getBrand());
230
		itemObj.put("ModelName", item.getModelName());
255
		itemObj.put("ModelName", item.getModelName());
231
		itemObj.put("ModelNumber", item.getModelNumber());
256
		itemObj.put("ModelNumber", item.getModelNumber());
Line 233... Line 258...
233
		itemObj.put("Weight", item.getWeight());
258
		itemObj.put("Weight", item.getWeight());
234
		itemObj.put("Risky", item.isRisky());
259
		itemObj.put("Risky", item.isRisky());
235
		itemObj.put("Status", item.getItemStatus());
260
		itemObj.put("Status", item.getItemStatus());
236
		itemObj.put("MRP", item.getMrp());
261
		itemObj.put("MRP", item.getMrp());
237
		itemObj.put("SellingPrice", item.getSellingPrice());
262
		itemObj.put("SellingPrice", item.getSellingPrice());
-
 
263
		itemObj.put("MaxNlc", maxNLC);
-
 
264
		return "item-details-json";
-
 
265
	}
-
 
266
 
-
 
267
	public String ke$ha() throws NumberFormatException, TException, JSONException{
-
 
268
		InventoryClient inventoryServiceClient = new InventoryClient();
-
 
269
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
270
		double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
-
 
271
		itemObj = new JSONObject();
-
 
272
		itemObj.put("ItemId", itemId);
-
 
273
		itemObj.put("WarehouseId", warehouseId);
-
 
274
		itemObj.put("MaxNlc", maxNLC);
238
		return "item-details-json";
275
		return "item-details-json";
239
	}
276
	}
240
 
277
 
241
	public void downloadSnapdealListings() throws IOException, TException{
278
	public void downloadSnapdealListings() throws IOException, TException{
242
		File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
279
		File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
Line 343... Line 380...
343
		try {
380
		try {
344
			catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
381
			catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
345
		} catch (TTransportException e) {
382
		} catch (TTransportException e) {
346
			e.printStackTrace();
383
			e.printStackTrace();
347
		}
384
		}
-
 
385
		InventoryClient inventoryServiceClient = new InventoryClient();
-
 
386
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
348
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
387
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
349
			SnapdealItem snapdealItem =null;
388
			SnapdealItem snapdealItem =null;
350
			Item item = null;
389
			Item item = null;
351
			Long sku;
390
			Long sku;
352
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
391
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
Line 370... Line 409...
370
					snapdealItem.setItem_id(sku); 
409
					snapdealItem.setItem_id(sku); 
371
				}
410
				}
372
			}
411
			}
373
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
412
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
374
				long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
413
				long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
-
 
414
				double maxNLC = inventoryClient.getNlcForWarehouse(warehouseId, item.getId());
375
				snapdealItem.setWarehouseId(warehouseId);
415
				snapdealItem.setWarehouseId(warehouseId);
-
 
416
				snapdealItem.setMaxNlc(maxNLC);
376
			}
417
			}
377
 
418
 
378
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
419
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
379
				double exceptionPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
420
				double exceptionPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
380
				snapdealItem.setExceptionPrice(exceptionPrice);
421
				snapdealItem.setExceptionPrice(exceptionPrice);
Line 417... Line 458...
417
				}
458
				}
418
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
459
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
419
					snapdealItem.setSuppressInventoryFeed(false);
460
					snapdealItem.setSuppressInventoryFeed(false);
420
				}
461
				}
421
			}
462
			}
-
 
463
			
-
 
464
			if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
-
 
465
				String snapdealItemCode = sheet.getRow(iterator).getCell(7).getStringCellValue();
-
 
466
				snapdealItem.setSkuAtSnapdeal(snapdealItemCode);
-
 
467
			}
422
			double weight = item.getWeight();
468
			double weight = item.getWeight();
423
 
469
 
424
			/*
470
			/*
425
			 *TODO Uncomment this for pricing feed. 
471
			 *TODO Uncomment this for pricing feed. 
426
			 * if(weight==0){
472
			 * if(weight==0){
Line 738... Line 784...
738
 
784
 
739
	public String getCourierCost() {
785
	public String getCourierCost() {
740
		return courierCost;
786
		return courierCost;
741
	}
787
	}
742
 
788
 
-
 
789
	public void setMaxNlc(String maxNlc) {
-
 
790
		this.maxNlc = maxNlc;
-
 
791
	}
-
 
792
 
-
 
793
	public String getMaxNlc() {
-
 
794
		return maxNlc;
-
 
795
	}
-
 
796
 
743
	public String getItemDetails(){
797
	public String getItemDetails(){
744
		return itemObj.toString();
798
		return itemObj.toString();
745
	}
799
	}
746
 
800
 
747
 
801