Subversion Repositories SmartDukaan

Rev

Rev 9729 | Rev 9780 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8739 vikram.rag 1
package in.shop2020.support.controllers;
2
 
3
import in.shop2020.model.v1.catalog.CatalogService.Client;
9242 kshitij.so 4
import in.shop2020.model.v1.catalog.CatalogServiceException;
5
import in.shop2020.model.v1.catalog.Item;
9725 kshitij.so 6
import in.shop2020.model.v1.catalog.MarketplaceItems;
8739 vikram.rag 7
import in.shop2020.model.v1.catalog.SnapdealItem;
9242 kshitij.so 8
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
9725 kshitij.so 9
import in.shop2020.model.v1.inventory.InventoryServiceException;
10
import in.shop2020.model.v1.inventory.InventoryType;
11
import in.shop2020.model.v1.inventory.ItemInventory;
12
import in.shop2020.model.v1.inventory.Warehouse;
13
import in.shop2020.model.v1.inventory.WarehouseType;
8739 vikram.rag 14
import in.shop2020.model.v1.order.AmazonFbaSalesSnapshot;
8886 vikram.rag 15
import in.shop2020.model.v1.order.SnapdealOrder;
8739 vikram.rag 16
import in.shop2020.support.utils.ReportsUtils;
17
import in.shop2020.thrift.clients.CatalogClient;
9478 kshitij.so 18
import in.shop2020.thrift.clients.InventoryClient;
8739 vikram.rag 19
import in.shop2020.thrift.clients.TransactionClient;
9725 kshitij.so 20
import in.shop2020.utils.GmailUtils;
21
import javax.mail.MessagingException;
8739 vikram.rag 22
 
23
import java.io.BufferedInputStream;
24
import java.io.File;
25
import java.io.FileInputStream;
26
import java.io.FileNotFoundException;
27
import java.io.FileOutputStream;
28
import java.io.FileWriter;
29
import java.io.IOException;
30
import java.io.InputStream;
9242 kshitij.so 31
import java.text.DecimalFormat;
8739 vikram.rag 32
import java.util.ArrayList;
9242 kshitij.so 33
import java.util.Arrays;
8739 vikram.rag 34
import java.util.HashMap;
35
import java.util.List;
36
import java.util.Map;
37
 
38
import javax.servlet.ServletContext;
39
import javax.servlet.ServletOutputStream;
40
import javax.servlet.http.HttpServletRequest;
41
import javax.servlet.http.HttpServletResponse;
42
import javax.servlet.http.HttpSession;
43
 
44
import org.apache.commons.io.FileUtils;
45
import org.apache.commons.lang.xwork.StringUtils;
46
import org.apache.poi.hssf.usermodel.HSSFRow;
47
import org.apache.poi.hssf.usermodel.HSSFSheet;
48
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
49
import org.apache.poi.ss.usermodel.Cell;
50
import org.apache.struts2.convention.annotation.InterceptorRef;
51
import org.apache.struts2.convention.annotation.InterceptorRefs;
52
import org.apache.struts2.interceptor.ServletRequestAware;
53
import org.apache.struts2.interceptor.ServletResponseAware;
54
import org.apache.struts2.util.ServletContextAware;
55
import org.apache.thrift.TException;
56
import org.apache.thrift.transport.TTransportException;
9242 kshitij.so 57
import org.json.JSONException;
58
import org.json.JSONObject;
8739 vikram.rag 59
import org.slf4j.Logger;
60
import org.slf4j.LoggerFactory;
61
 
62
import com.opensymphony.xwork2.ValidationAwareSupport;
63
 
9242 kshitij.so 64
@SuppressWarnings("unused")
65
 
66
@InterceptorRefs({
67
	@InterceptorRef("defaultStack"),
68
	@InterceptorRef("login")
69
})
70
 
8739 vikram.rag 71
public class SnapdealListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
9242 kshitij.so 72
	/**
73
	 * 
74
	 */
75
	private static final long serialVersionUID = 1L;
76
 
77
 
8739 vikram.rag 78
	private static Logger logger = LoggerFactory.getLogger(SnapdealListController.class);
79
 
80
 
81
	private HttpServletRequest request;
82
	private HttpServletResponse response;
83
	private HttpSession session;
84
	private ServletContext context;
85
	private String url;
86
	private String itemId;
87
	private String isSnapdealListed;
88
	private String exceptionPrice;
89
	private String warehouseId;
90
	private File file;
91
	private String errMsg;
92
	private String next;
93
	private String id;
9242 kshitij.so 94
	private String searchText;
95
	private List<SnapdealItemDetails> snapdealItems;
96
	private long searchCount;
97
	private long totalCount;
98
	private String sellingPrice;
99
	private String transferPrice;
100
	private String webisteMrp;
101
	private String webisteSellingPrice;
102
	private String isListedOnSnapdeal;
103
	private String commission;
104
	private String serviceTax;
105
	private String courierCost;
106
	private JSONObject itemObj;
107
	private String isSuppressInventoryFeed;
108
	private String isSuppressPriceFeed;
9478 kshitij.so 109
	private String maxNlc;
110
	private String sdItemCode;
9568 kshitij.so 111
	private String supc;
9725 kshitij.so 112
	private String held;
113
	private String lastUpdatedInventoryTimestamp;
114
	private String lastCheckedTimestamp;
115
	private String otherCost;
116
	private String isAutoIncrement;
117
	private String isAutoDecrement;
118
	private String isManualFavourite;
119
	private String isAutoFavourite;
120
	private String currentSp;
121
	private String currentTp;
122
	private String minPosSp;
123
	private String minPosTp;
124
	private String vat;
9734 kshitij.so 125
	private String comparsionResult;
126
	public String getComparsionResult() {
127
		return comparsionResult;
128
	}
8739 vikram.rag 129
 
9734 kshitij.so 130
	public void setComparsionResult(String comparsionResult) {
131
		this.comparsionResult = comparsionResult;
132
	}
133
 
134
	private Map<Integer, Long> holdInventoryMap;
135
 
9725 kshitij.so 136
	public String getVat() {
137
		return vat;
138
	}
9242 kshitij.so 139
 
9725 kshitij.so 140
	public void setVat(String vat) {
141
		this.vat = vat;
142
	}
9242 kshitij.so 143
 
9725 kshitij.so 144
	public String getOtherCost() {
145
		return otherCost;
146
	}
147
 
148
	public void setOtherCost(String otherCost) {
149
		this.otherCost = otherCost;
150
	}
151
 
152
 
153
	public String getCurrentSp() {
154
		return currentSp;
155
	}
156
 
157
	public void setCurrentSp(String currentSp) {
158
		this.currentSp = currentSp;
159
	}
160
 
161
	public String getCurrentTp() {
162
		return currentTp;
163
	}
164
 
165
	public void setCurrentTp(String currentTp) {
166
		this.currentTp = currentTp;
167
	}
168
 
169
 
170
	public String getLastCheckedTimestamp() {
171
		return lastCheckedTimestamp;
172
	}
173
 
174
	public String getLastUpdatedInventoryTimestamp() {
175
		return lastUpdatedInventoryTimestamp;
176
	}
177
 
178
	public void setLastUpdatedInventoryTimestamp(
179
			String lastUpdatedInventoryTimestamp) {
180
		this.lastUpdatedInventoryTimestamp = lastUpdatedInventoryTimestamp;
181
	}
182
 
183
	public void setLastCheckedTimestamp(
184
			String lastCheckedTimestamp) {
185
		this.lastCheckedTimestamp = lastCheckedTimestamp;
186
	}
187
 
188
	public String getIsAutoIncrement() {
189
		return isAutoIncrement;
190
	}
191
 
192
	public void setIsAutoIncrement(String isAutoIncrement) {
193
		this.isAutoIncrement = isAutoIncrement;
194
	}
195
 
196
	public String getIsAutoDecrement() {
197
		return isAutoDecrement;
198
	}
199
 
200
	public void setIsAutoDecrement(String isAutoDecrement) {
201
		this.isAutoDecrement = isAutoDecrement;
202
	}
203
 
204
	public String getIsManualFavourite() {
205
		return isManualFavourite;
206
	}
207
 
208
	public void setIsManualFavourite(String isManualFavourite) {
209
		this.isManualFavourite = isManualFavourite;
210
	}
211
 
212
	public String getIsAutoFavourite() {
213
		return isAutoFavourite;
214
	}
215
 
216
	public void setIsAutoFavourite(String isAutoFavourite) {
217
		this.isAutoFavourite = isAutoFavourite;
218
	}
219
 
220
	public String getMinPosSp() {
221
		return minPosSp;
222
	}
223
 
224
	public void setMinPosSp(String minPosSp) {
225
		this.minPosSp = minPosSp;
226
	}
227
 
228
	public String getMinPosTp() {
229
		return minPosTp;
230
	}
231
 
232
	public void setMinPosTp(String minPosTp) {
233
		this.minPosTp = minPosTp;
234
	}
235
 
236
	public String getHeld() {
237
		return held;
238
	}
239
 
240
	public void setHeld(String held) {
241
		this.held = held;
242
	}
243
 
9568 kshitij.so 244
	public String getSupc() {
245
		return supc;
246
	}
247
 
248
	public void setSupc(String supc) {
249
		this.supc = supc;
250
	}
251
 
9478 kshitij.so 252
	public String getSdItemCode() {
253
		return sdItemCode;
254
	}
255
 
256
	public void setSdItemCode(String sdItemCode) {
257
		this.sdItemCode = sdItemCode;
258
	}
259
 
8739 vikram.rag 260
	public String index() {
261
		if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
262
			return "authfail";
263
		}
264
		return "index";
265
	}
266
 
9242 kshitij.so 267
	public String edit() {
268
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
269
			return "authfail";
270
		}
271
		return "edit";
272
	}
273
 
274
	public String fetchItems() throws TException {
275
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
276
		if (searchText.length() == 0) {
277
			snapdealItems = CatalogClient.getSnapdealItems(Long.valueOf(next), 10);
278
			totalCount = CatalogClient.getCountForSnapdealItems();
279
			setSearchCount(totalCount);
280
		} else {
281
			List<String> subString = Arrays.asList(searchText.split(" "));
282
			snapdealItems = CatalogClient.searchSnapdealItems(subString,Long.valueOf(next), 10);
283
			totalCount = CatalogClient.getCountForSnapdealItems();
284
			searchCount = CatalogClient.getSnapdealSearchResultCount(subString);
285
		}
286
		return "snapdeal-item-table";
287
	}
288
 
289
	public SnapdealItemDetails fetchItemDetail() throws NumberFormatException, TException {
290
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
9725 kshitij.so 291
		SnapdealItemDetails sdItemDetails = CatalogClient.getSnapdealItemDetails(Long.valueOf(id));
292
		lastUpdatedInventoryTimeStampForItem(sdItemDetails.getLastUpdatedInventoryTimestamp());
293
		return sdItemDetails;
9242 kshitij.so 294
	}
295
 
9725 kshitij.so 296
	public MarketplaceItems fetchMarketplaceDetail() throws NumberFormatException, TException {
297
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
298
		MarketplaceItems mpItemDetails = CatalogClient.getMarketplacedetailsForItem(Long.valueOf(id), 7);
299
		lastCheckedTimeStampForItem(mpItemDetails.getLastCheckedTimestamp());
300
		return mpItemDetails;
301
	}
302
 
303
	public void lastUpdatedInventoryTimeStampForItem(long timestamp){
304
		setLastUpdatedInventoryTimestamp(new java.util.Date(timestamp).toLocaleString());
305
	}
306
 
307
	public void lastCheckedTimeStampForItem(long timestamp){
308
		setLastCheckedTimestamp(new java.util.Date(timestamp).toLocaleString());
309
	}
310
 
8739 vikram.rag 311
	public String uploadBulkSheet(){
312
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
313
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
314
			return "authfail";
315
		}
316
		return "snapdeal-bulk-upload";
317
	}
9242 kshitij.so 318
 
9734 kshitij.so 319
	public String update() throws NumberFormatException, TException, InventoryServiceException, CatalogServiceException, JSONException{
9242 kshitij.so 320
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
321
		SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
9725 kshitij.so 322
		MarketplaceItems mpItem = catalogClient.getMarketplacedetailsForItem(Long.valueOf(itemId),7);
323
		InventoryClient inventoryServiceClient = new InventoryClient();
324
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
325
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
326
		if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
327
			throw new InventoryServiceException();
328
		}
9242 kshitij.so 329
		boolean commit = false; 
330
		if (snapdealItem.getWarehouseId()!=Long.valueOf(warehouseId)){
331
			snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
332
			commit = true;
333
		}
334
		if (snapdealItem.isIsListedOnSnapdeal()!=Boolean.valueOf(isListedOnSnapdeal)){
335
			snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
336
			commit = true;
337
		}
338
		if (snapdealItem.isSuppressInventoryFeed()!=Boolean.valueOf(isSuppressInventoryFeed)){
339
			snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
340
			commit = true;
341
		}
342
		if (snapdealItem.isSuppressPriceFeed()!=Boolean.valueOf(isSuppressPriceFeed)){
343
			snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
344
			commit = true;
345
		}
346
		if (snapdealItem.getTransferPrice()!=Double.valueOf(transferPrice)){
347
			snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
348
			commit = true;
349
		}
350
		if (snapdealItem.getExceptionPrice()!=Double.valueOf(exceptionPrice)){
351
			snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
352
			commit = true;
353
		}
354
		if (snapdealItem.getSellingPrice()!=Double.valueOf(sellingPrice)){
355
			snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
356
			commit = true;
357
		}
358
		if (snapdealItem.getCourierCost()!=Double.valueOf(courierCost)){
359
			snapdealItem.setCourierCost(Double.valueOf(courierCost));
360
			commit = true;
361
		}
362
		if (snapdealItem.getCommission()!=Double.valueOf(commission)){
363
			snapdealItem.setCommission(Double.valueOf(commission));
364
			commit = true;
365
		}
366
		if (snapdealItem.getServiceTax()!=Double.valueOf(serviceTax)){
367
			snapdealItem.setServiceTax(Double.valueOf(serviceTax));
368
			commit = true;
369
		}
9478 kshitij.so 370
		if (snapdealItem.getMaxNlc()!=Double.valueOf(maxNlc)){
371
			snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
372
			commit = true;
373
		}
374
		if (!StringUtils.equalsIgnoreCase(snapdealItem.getSkuAtSnapdeal(), sdItemCode)){
375
			snapdealItem.setSkuAtSnapdeal(sdItemCode);
376
			commit=true;
377
		}
9568 kshitij.so 378
		if (!StringUtils.equalsIgnoreCase(snapdealItem.getSupc(), supc)){
379
			snapdealItem.setSupc(supc);
380
			commit=true;
381
		}
9734 kshitij.so 382
		MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
383
 
384
		if(!compareParameters(t_mpItem,snapdealItem)){
385
			setComparsionResult("0");
386
			return "snapdeal-update-result";
387
		}
388
		else{
389
			setComparsionResult("1");
390
		}
9478 kshitij.so 391
 
9242 kshitij.so 392
		if (commit){
9734 kshitij.so 393
			if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
394
				throw new CatalogServiceException();
395
			}
9242 kshitij.so 396
		}
9734 kshitij.so 397
		boolean result = catalogClient.updateMarketplaceAttributesForItem(t_mpItem);
9725 kshitij.so 398
		if(!result){
399
			throw new CatalogServiceException();
400
		}
401
		if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
402
			sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
403
		}
9734 kshitij.so 404
		return "snapdeal-update-result";
9242 kshitij.so 405
	}
406
 
9734 kshitij.so 407
 
408
	public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem) throws TException, JSONException{
409
		double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
410
		double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
411
		double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
412
	    double lowest_possible_tp = nlc+inHouseCost;
413
	    double our_tp =  snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*(mpItem.getCommission()/100)*(1+(mpItem.getServiceTax()/100))-snapdealItem.getCourierCost()*(1+(mpItem.getServiceTax()/100));
414
	    double commission =  ((mpItem.getCommission()/100)*snapdealItem.getSellingPrice());
415
	    double service_tax = (mpItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost());
416
	    double lowest_possible_sp = (nlc+(snapdealItem.getCourierCost()+0)*1.1236*(1+(mpItem.getVat()/100))+(15+mpItem.getOtherCost())*(1+(mpItem.getVat())/100))/(1-(mpItem.getCommission()/100+0)*1.1236*(1+(mpItem.getVat())/100)-.005*(1+(mpItem.getVat())/100));
417
	    JSONObject x = new JSONObject();
418
	    x.put("NLC", nlc);
419
	    x.put("VAT", vat);
420
	    x.put("LOWEST POS TP", lowest_possible_tp);
421
	    x.put("TP", our_tp);
422
	    x.put("COMMISSION", commission);
423
	    x.put("SERVICE TAX", service_tax);
424
	    x.put("LOWEST POS SP", lowest_possible_sp);
425
	    logger.info("Snapdeal Backend validation "+x.toString());
426
	    boolean compare_result=true;
427
	    if(!(nlc==snapdealItem.getMaxNlc())){
428
	    	compare_result=false;
429
	    }
430
	    if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
431
	    	compare_result=false;
432
	    }
433
	    if(!(our_tp-snapdealItem.getTransferPrice()>-1 && our_tp-snapdealItem.getTransferPrice()<1)){
434
	    	compare_result=false;
435
	    }
436
	    if(!(commission-snapdealItem.getCommission()>-1 && commission-snapdealItem.getCommission()<1)){
437
	    	compare_result=false;
438
	    }
439
	    if(!(service_tax-snapdealItem.getServiceTax()>-1 && service_tax-snapdealItem.getServiceTax()<1)){
440
	    	compare_result=false;
441
	    }
442
	    if(!(lowest_possible_sp-mpItem.getMinimumPossibleSp()>-1 && lowest_possible_sp-mpItem.getMinimumPossibleSp()<1)){
443
	    	compare_result=false;
444
	    }
445
	    return compare_result;
446
 
447
	}
448
 
449
	public double getNlcForWarehouse(long warehouseId,long item_id) throws TException{
450
		InventoryClient inventoryServiceClient = new InventoryClient();
451
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
452
		return inventoryClient.getNlcForWarehouse(warehouseId, item_id);
453
	}
454
 
455
	public double getCourierCost(double weight){
456
		double cCost = 45;
457
		int slabs = (int) ((weight - .001)/(.5));
458
		for(int i=0;i<slabs;i++){
459
			cCost = cCost + 35;
460
		}
461
		return cCost;
462
	}
463
 
464
 
9725 kshitij.so 465
	private MarketplaceItems updateMarketplaceItemDetails(MarketplaceItems mpItem){
466
		mpItem.setItemId(Long.valueOf(itemId));
467
		mpItem.setSource(7);
468
		mpItem.setVat(Double.valueOf(vat));
469
		mpItem.setCourierCost(Double.valueOf(courierCost));
470
		mpItem.setOtherCost(Double.valueOf(otherCost));
471
		mpItem.setCurrentSp(Double.valueOf(sellingPrice));
472
		mpItem.setCurrentTp(Double.valueOf(transferPrice));
473
		mpItem.setAutoDecrement(Boolean.valueOf(isAutoDecrement));
474
		mpItem.setAutoIncrement(Boolean.valueOf(isAutoIncrement));
475
		mpItem.setManualFavourite(Boolean.valueOf(isManualFavourite));
476
		mpItem.setMinimumPossibleSp(Double.valueOf(minPosSp));
477
		mpItem.setMinimumPossibleTp(Double.valueOf(minPosTp));
478
		return mpItem;
479
	}
480
 
481
	private void sendAlert(long itemId,double sp,double minSp){
482
		Item item;
483
		try{
484
			Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
485
			item= catalogClient.getItem(itemId);
486
		}
487
		catch(Exception e){
488
			e.printStackTrace();
489
			return;
490
		}
491
		String emailSubjectTxt="Snapdeal SP is set below Min Possible SP";
9729 kshitij.so 492
		String[] sendTo=new String[]{ "kshitij.sood@saholic.com","rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com"};
9725 kshitij.so 493
		String text = "Item Details\nItem Id: "+itemId+"\nProduct Name: "+item.getBrand()+" "+item.getModelName()+" "+item.getModelNumber()+" "+item.getColor()+"\nSellingPrice: "+sp+"\nMinPossibleSp: "+minSp+"\nUpdated By: "+session.getAttribute(ReportsUtils.USER_NAME).toString();
494
		logger.info(text);
495
		String emailFromAddress = "build@shop2020.in";
496
		String password = "cafe@nes";
497
		GmailUtils mailer = new GmailUtils();
498
		try {
9734 kshitij.so 499
			//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
9725 kshitij.so 500
		}
501
		catch (Exception e) {
9729 kshitij.so 502
			logger.info(e.toString());
9725 kshitij.so 503
		}
504
	}
505
 
506
	public void addNewItem() throws TException, NumberFormatException, InventoryServiceException, CatalogServiceException{
507
		InventoryClient inventoryServiceClient = new InventoryClient();
508
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
509
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
510
		if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
511
			throw new InventoryServiceException();
512
		}
9242 kshitij.so 513
		SnapdealItem snapdealItem = new SnapdealItem();
514
		snapdealItem.setItem_id(Long.valueOf(itemId));
515
		snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
516
		snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
517
		snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
518
		snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
519
		snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
520
		snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
521
		snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
522
		snapdealItem.setCourierCost(Double.valueOf(courierCost));
523
		snapdealItem.setCommission(Double.valueOf(commission));
524
		snapdealItem.setServiceTax(Double.valueOf(serviceTax));
9478 kshitij.so 525
		snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
526
		snapdealItem.setSkuAtSnapdeal(sdItemCode);
9568 kshitij.so 527
		snapdealItem.setSupc(supc);
9734 kshitij.so 528
 
9725 kshitij.so 529
		MarketplaceItems mpItem = new MarketplaceItems();
530
		MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
9242 kshitij.so 531
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
532
		catalogClient.addOrUpdateSnapdealItem(snapdealItem);
9725 kshitij.so 533
		boolean result =catalogClient.updateMarketplaceAttributesForItem(t_mpItem);
534
		if(!result){
535
			throw new CatalogServiceException();
536
		}
537
		if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
538
			sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
539
		}
9242 kshitij.so 540
	}
541
 
542
	public String getAddNewItemForm(){
543
		return "snapdeal-add-item";
544
	}
545
 
9725 kshitij.so 546
	public String getItemDetailsInJson() throws NumberFormatException, CatalogServiceException, TException, JSONException, InventoryServiceException{
9242 kshitij.so 547
		Client catalogClient =new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
548
		SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
549
		if (snapdealItem.getItem_id()!=0){
550
			throw new CatalogServiceException();
551
		}
552
		Item item = catalogClient.getItem(Long.valueOf(itemId));
553
		if (item.getId()==0){
554
			throw new CatalogServiceException();
555
		}
9478 kshitij.so 556
		InventoryClient inventoryServiceClient = new InventoryClient();
557
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9725 kshitij.so 558
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
559
		if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
560
			throw new InventoryServiceException();
561
		}
9478 kshitij.so 562
		double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
9242 kshitij.so 563
		itemObj = new JSONObject();
564
		itemObj.put("ItemId", item.getId());
565
		itemObj.put("Brand", item.getBrand());
566
		itemObj.put("ModelName", item.getModelName());
567
		itemObj.put("ModelNumber", item.getModelNumber());
568
		itemObj.put("Color", item.getColor());
569
		itemObj.put("Weight", item.getWeight());
570
		itemObj.put("Risky", item.isRisky());
571
		itemObj.put("Status", item.getItemStatus());
572
		itemObj.put("MRP", item.getMrp());
573
		itemObj.put("SellingPrice", item.getSellingPrice());
9478 kshitij.so 574
		itemObj.put("MaxNlc", maxNLC);
9242 kshitij.so 575
		return "item-details-json";
576
	}
577
 
9725 kshitij.so 578
	public String ke$ha() throws NumberFormatException, TException, JSONException, InventoryServiceException{
9478 kshitij.so 579
		InventoryClient inventoryServiceClient = new InventoryClient();
580
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9725 kshitij.so 581
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
582
		if (warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD){
583
			double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
584
			itemObj = new JSONObject();
585
			itemObj.put("ItemId", itemId);
586
			itemObj.put("WarehouseId", warehouseId);
587
			itemObj.put("MaxNlc", maxNLC);
588
		}
589
		else{
590
			itemObj = new JSONObject();
591
			throw new InventoryServiceException();
592
		}
9478 kshitij.so 593
		return "item-details-json";
594
	}
595
 
9725 kshitij.so 596
	public ItemInventory getItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
597
		try{
598
			InventoryClient inventoryServiceClient = new InventoryClient();
599
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
600
			in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
601
			return thriftItemInventory;
602
		}
603
		catch(Exception e){
604
			logger.error("Unable to get inventory info for item",e);
605
			return null;
606
		}
607
	}
608
 
9734 kshitij.so 609
 
610
 
611
	public Warehouse getWarehouse(String warehouseId,String itemId) throws NumberFormatException, TException, InventoryServiceException { 
9725 kshitij.so 612
		InventoryClient inventoryServiceClient = new InventoryClient();
9734 kshitij.so 613
		holdInventoryMap =inventoryServiceClient.getClient().getHeldInventoryMapForItem(Long.valueOf(itemId), Long.valueOf(warehouseId));
9725 kshitij.so 614
		return inventoryServiceClient.getClient().getWarehouse(Long.valueOf(warehouseId));
615
	}
616
 
9734 kshitij.so 617
	public Map<Integer, Long> getHoldInventoryMapForItem(){
618
		return holdInventoryMap;
619
	}
620
 
9725 kshitij.so 621
	public void changeHeldForSource() throws NumberFormatException, TException, InventoryServiceException{
622
		InventoryClient inventoryServiceClient = new InventoryClient();
623
		Warehouse warehouse = inventoryServiceClient.getClient().getWarehouse(Long.valueOf(warehouseId));
624
		if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
625
			throw new InventoryServiceException();
626
		}
627
		inventoryServiceClient.getClient().addUpdateHoldInventory(Long.valueOf(itemId),Long.valueOf(warehouseId),Long.valueOf(held),7);
628
	}
629
 
8739 vikram.rag 630
	public void downloadSnapdealListings() throws IOException, TException{
631
		File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
632
		HSSFWorkbook hwb=new HSSFWorkbook();
633
		HSSFSheet sheet =  hwb.createSheet("Snapdeal-Listings");
634
		HSSFRow rowhead=   sheet.createRow((short)0);
635
		rowhead.createCell((short) 0).setCellValue("ITEM-ID");
636
		rowhead.createCell((short) 1).setCellValue("WAREHOUSE-ID");
637
		rowhead.createCell((short) 2).setCellValue("EXCEPTIONAL-PRICE");
638
		rowhead.createCell((short) 3).setCellValue("SNAPDEAL-LISTED");
9242 kshitij.so 639
		rowhead.createCell((short) 4).setCellValue("TRANSFER-PRICE");
640
		rowhead.createCell((short) 5).setCellValue("SELLING-PRICE");
641
		rowhead.createCell((short) 6).setCellValue("COURIER-COST");
642
		rowhead.createCell((short) 7).setCellValue("COMMISION");
643
		rowhead.createCell((short) 8).setCellValue("SERVICE-TAX");
9568 kshitij.so 644
		rowhead.createCell((short) 9).setCellValue("Suppress Inventory Feed");
645
		rowhead.createCell((short) 10).setCellValue("Suppress Price Feed");
646
		rowhead.createCell((short) 11).setCellValue("Max NLC");
647
		rowhead.createCell((short) 12).setCellValue("SKU @ Snapdeal");
648
		rowhead.createCell((short) 13).setCellValue("SUPC");
8739 vikram.rag 649
		CatalogClient catalogServiceClient = null;
9242 kshitij.so 650
		List<SnapdealItemDetails> snapdealItems = null;
8739 vikram.rag 651
		try {
9242 kshitij.so 652
			catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port");
8739 vikram.rag 653
			in.shop2020.model.v1.catalog.CatalogService.Client catalogClient= catalogServiceClient.getClient();
654
			snapdealItems = catalogClient.getAllSnapdealItems();
655
		} catch (Exception e) {
656
			e.printStackTrace();
657
		}
658
		int iterator=1;
9242 kshitij.so 659
		for(SnapdealItemDetails snapdealItem:snapdealItems){
8739 vikram.rag 660
			HSSFRow row = sheet.createRow((short)iterator);
661
			row.createCell((short) 0).setCellValue(snapdealItem.getItem_id());
662
			row.createCell((short) 1).setCellValue(snapdealItem.getWarehouseId());
663
			row.createCell((short) 2).setCellValue(snapdealItem.getExceptionPrice());
664
			if(snapdealItem.isIsListedOnSnapdeal()){
665
				row.createCell((short) 3).setCellValue(1);
666
			}
667
			else{
668
				row.createCell((short) 3).setCellValue(0);
669
			}
9242 kshitij.so 670
			row.createCell((short) 4).setCellValue(snapdealItem.getTransferPrice());
671
			row.createCell((short) 5).setCellValue(snapdealItem.getSellingPrice());
9579 kshitij.so 672
			row.createCell((short) 6).setCellValue(snapdealItem.getCourierCost());
673
			row.createCell((short) 7).setCellValue(snapdealItem.getCommission());
674
			row.createCell((short) 8).setCellValue(snapdealItem.getServiceTax());
675
			row.createCell((short) 9).setCellValue(snapdealItem.isSuppressInventoryFeed());
676
			row.createCell((short) 10).setCellValue(snapdealItem.isSuppressPriceFeed());
677
			row.createCell((short) 11).setCellValue(snapdealItem.getMaxNlc());
678
			row.createCell((short) 12).setCellValue(snapdealItem.getSkuAtSnapdeal());
679
			row.createCell((short) 13).setCellValue(snapdealItem.getSupc());
8739 vikram.rag 680
			iterator++;
681
		}
9242 kshitij.so 682
 
8739 vikram.rag 683
		FileOutputStream fileOut = null;
684
		try {
685
			fileOut = new FileOutputStream(file);
686
		} catch (FileNotFoundException e) {
687
			// TODO Auto-generated catch block
688
			e.printStackTrace();
689
		}
690
		try {
691
			hwb.write(fileOut);
692
		} catch (IOException e) {
693
			// TODO Auto-generated catch block
694
			e.printStackTrace();
695
		}
696
		try {
697
			fileOut.close();
698
		} catch (IOException e) {
699
			// TODO Auto-generated catch block
700
			e.printStackTrace();
701
		}
702
		byte[] buffer = new byte[(int)file.length()];
703
		InputStream input = null;
704
		try {
705
			int totalBytesRead = 0;
706
			input = new BufferedInputStream(new FileInputStream(file));
707
			while(totalBytesRead < buffer.length){
708
				int bytesRemaining = buffer.length - totalBytesRead;
709
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
710
				if (bytesRead > 0){
711
					totalBytesRead = totalBytesRead + bytesRead;
712
				}
713
			}
714
		}
715
		finally {
716
			input.close();
717
			file.delete();
718
		}
719
 
720
		response.setHeader("Content-Disposition", "attachment; filename=\"Snapdeal-Bulk-Listings.xls\"");
721
		response.setContentType("application/octet-stream");
722
		ServletOutputStream sos;
723
		try {
724
			sos = response.getOutputStream();
725
			sos.write(buffer);
726
			sos.flush();
727
		} catch (IOException e) {
728
			System.out.println("Unable to stream the manifest file");
729
		}   
730
 
9242 kshitij.so 731
 
8739 vikram.rag 732
	}
733
 
9725 kshitij.so 734
	public void uploadsnapdealBulkSheet() throws IOException, TException, NumberFormatException, InventoryServiceException{
8739 vikram.rag 735
		File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
736
		FileUtils.copyFile(this.file, fileToCreate);
737
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
738
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
739
		HSSFSheet sheet = workbook.getSheetAt(0);
8887 vikram.rag 740
		Client catalogClient=null;
8739 vikram.rag 741
		StringBuilder sb = new StringBuilder();
742
		try {
9242 kshitij.so 743
			catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
8739 vikram.rag 744
		} catch (TTransportException e) {
745
			e.printStackTrace();
746
		}
9478 kshitij.so 747
		InventoryClient inventoryServiceClient = new InventoryClient();
748
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
8739 vikram.rag 749
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
750
			SnapdealItem snapdealItem =null;
9242 kshitij.so 751
			Item item = null;
8739 vikram.rag 752
			Long sku;
9595 kshitij.so 753
			boolean new_item = false;
8739 vikram.rag 754
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
755
				continue;
756
			}
757
			else {
8791 kshitij.so 758
				sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
8887 vikram.rag 759
				snapdealItem = catalogClient.getSnapdealItem(sku);
9242 kshitij.so 760
				try {
761
					item = catalogClient.getItem(sku);
762
					if (item.getId()==0){
763
						sb.append(sku + " Item not Present"+"\n");
764
						continue;
765
					}
766
				} catch (CatalogServiceException e) {
767
					sb.append(sku + " Item not Present"+"\n");
768
					continue;
769
				}
8886 vikram.rag 770
				if(snapdealItem.getItem_id()==0){
9595 kshitij.so 771
					new_item = true;
8886 vikram.rag 772
					snapdealItem = new SnapdealItem();
773
					snapdealItem.setItem_id(sku); 
774
				}
8739 vikram.rag 775
			}
9725 kshitij.so 776
 
9595 kshitij.so 777
			if (checkEmptyString(sheet.getRow(iterator).getCell(1)) && new_item){
778
				sb.append(sku + " New Listing - Warehouse Id not Present"+"\n");
779
				continue;
780
			}
9725 kshitij.so 781
 
8739 vikram.rag 782
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
9725 kshitij.so 783
				Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
784
				if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
785
					sb.append(sku + "Not acceptable warehouse"+"\n");
786
					continue;
787
				}
8739 vikram.rag 788
				long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
9478 kshitij.so 789
				double maxNLC = inventoryClient.getNlcForWarehouse(warehouseId, item.getId());
9595 kshitij.so 790
				if (maxNLC==0){
791
					sb.append(sku + "Max Nlc can't be 0"+"\n");
792
					continue;
793
				}
8739 vikram.rag 794
				snapdealItem.setWarehouseId(warehouseId);
9478 kshitij.so 795
				snapdealItem.setMaxNlc(maxNLC);
8739 vikram.rag 796
			}
797
 
798
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
799
				double exceptionPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
800
				snapdealItem.setExceptionPrice(exceptionPrice);
801
			}
802
 
803
			if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
804
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==1){
805
					snapdealItem.setIsListedOnSnapdeal(true);
806
				}
807
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
808
					snapdealItem.setIsListedOnSnapdeal(false);
809
				}
810
			}
9242 kshitij.so 811
			double transferPrice = 0,sellingPrice,commission,courierCost =45,serviceTax;
812
			if (checkEmptyString(sheet.getRow(iterator).getCell(4))){
813
				sb.append(sku + " Transfer Price cannot be empty"+"\n");
814
				continue;
815
			}
816
			if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
817
				transferPrice = sheet.getRow(iterator).getCell(4).getNumericCellValue();
818
				if(transferPrice==0){
819
					sb.append(sku + " Transfer Price cannot be zero"+"\n");
820
					continue;
821
				}
822
				snapdealItem.setTransferPrice(transferPrice);
823
			}
824
 
825
			if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
826
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
827
					snapdealItem.setSuppressPriceFeed(true);
828
				}
829
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
830
					snapdealItem.setSuppressPriceFeed(false);
831
				}
832
			}
833
 
834
			if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
835
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
836
					snapdealItem.setSuppressInventoryFeed(true);
837
				}
838
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
839
					snapdealItem.setSuppressInventoryFeed(false);
840
				}
841
			}
9725 kshitij.so 842
 
9478 kshitij.so 843
			if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
9597 kshitij.so 844
				sheet.getRow(iterator).getCell(7).setCellType(Cell.CELL_TYPE_STRING);
9478 kshitij.so 845
				String snapdealItemCode = sheet.getRow(iterator).getCell(7).getStringCellValue();
846
				snapdealItem.setSkuAtSnapdeal(snapdealItemCode);
847
			}
9725 kshitij.so 848
 
9568 kshitij.so 849
			if (!checkEmptyString(sheet.getRow(iterator).getCell(8))){
9597 kshitij.so 850
				sheet.getRow(iterator).getCell(8).setCellType(Cell.CELL_TYPE_STRING);
9568 kshitij.so 851
				String supc = sheet.getRow(iterator).getCell(8).getStringCellValue();
852
				snapdealItem.setSupc(supc);
853
			}
9242 kshitij.so 854
			double weight = item.getWeight();
855
 
856
			/*
857
			 *TODO Uncomment this for pricing feed. 
858
			 * if(weight==0){
859
				sb.append(sku + " Please add weight"+"\n");
860
				continue;
861
			}*/
862
			if (weight!=0){
863
				int slabs = (int) ((weight - .001)/(.5));
864
 
865
				for(int i=0;i<slabs;i++){
866
					courierCost = courierCost + 35;
867
				}
868
			}
869
 
870
			snapdealItem.setCourierCost(courierCost);
871
			sellingPrice = roundTwoDecimals(((transferPrice + courierCost*1.1236)/(100 - 3.59*1.1236))*100);
872
			snapdealItem.setSellingPrice(sellingPrice);
873
			double commision_value = roundTwoDecimals(.0359*sellingPrice + courierCost);
874
			commission = roundTwoDecimals(((.0359*sellingPrice + courierCost)/sellingPrice)*100);
875
			snapdealItem.setCommission(commission);
876
			serviceTax = roundTwoDecimals((commision_value * .1236)); 
877
			snapdealItem.setServiceTax(serviceTax);
8888 vikram.rag 878
			if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
8739 vikram.rag 879
				sb.append(sku + "\n");
880
			}	
881
		}
882
		//logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
883
		File file = new File("/tmp/amazonbulk");
884
		FileWriter writer = new FileWriter(file);
885
		writer.append(sb.toString());
886
		writer.close();
887
		byte[] buffer = new byte[(int)file.length()];
888
		InputStream input = null;
889
		try {
890
			int totalBytesRead = 0;
891
			input = new BufferedInputStream(new FileInputStream(file));
892
			while(totalBytesRead < buffer.length){
893
				int bytesRemaining = buffer.length - totalBytesRead;
894
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
895
				if (bytesRead > 0){
896
					totalBytesRead = totalBytesRead + bytesRead;
897
				}
898
			}
899
		}
900
		finally {
901
			input.close();
902
			file.delete();
903
		}
904
 
905
		response.setHeader("Content-Type", "text/javascript");
906
 
907
		ServletOutputStream sos;
908
		try {
909
			sos = response.getOutputStream();
910
			sos.write(buffer);
911
			sos.flush();
912
		} catch (IOException e) {
913
			System.out.println("Unable to stream the manifest file");
914
		}   
915
	}
916
 
917
	public boolean checkEmptyString(Cell cell){
918
		if (cell==null){
919
			return true;
920
		}
921
		return false;
922
	}
923
 
9242 kshitij.so 924
	double roundTwoDecimals(double d) {
925
		DecimalFormat twoPlaces = new DecimalFormat("#.##");
926
		return Double.valueOf(twoPlaces.format(d));
927
	}
928
 
929
 
8739 vikram.rag 930
	public String show() {
931
		logger.info("Before fetching role");
932
		logger.info(request.getSession().toString());
933
		logger.info(ReportsUtils.ROLE);
9725 kshitij.so 934
		logger.info(session.getAttribute(ReportsUtils.USER_NAME).toString());
8739 vikram.rag 935
		logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
936
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
937
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
938
			return "authfail";
939
		}
940
 
941
		if (StringUtils.equals(id, "snapdeal-options")){
942
			return "snapdeal-options";
943
		}
9242 kshitij.so 944
		if (StringUtils.equals(id, "item-table")){
945
			return "snapdeal-item-table";
946
		}
8739 vikram.rag 947
 
948
		return "id";
949
	}
950
 
951
	public void setId(String id) {
952
		this.id = id;
953
	}
954
 
955
	public HttpServletRequest getRequest() {
956
		logger.info("set request"+request.toString());
957
		return request;
958
	}
959
 
960
	public void setRequest(HttpServletRequest request) {
961
		this.request = request;
962
	}
963
 
964
	public HttpServletResponse getResponse() {
965
		return response;
966
	}
967
 
968
	public void setResponse(HttpServletResponse response) {
969
		this.response = response;
970
	}
971
 
972
	public HttpSession getSession() {
973
		return session;
974
	}
975
 
976
	public void setSession(HttpSession session) {
977
		logger.info("set session"+session.toString());
978
		this.session = session;
979
	}
980
 
981
	public ServletContext getContext() {
982
		return context;
983
	}
984
 
985
	public void setContext(ServletContext context) {
986
		this.context = context;
987
	}
988
 
989
	public String getUrl() {
990
		return url;
991
	}
992
 
993
	public void setUrl(String url) {
994
		this.url = url;
995
	}
996
 
997
	public String getItemId() {
998
		return itemId;
999
	}
1000
 
1001
	public void setItemId(String itemId) {
1002
		this.itemId = itemId;
1003
	}
1004
 
1005
	public String getIsSnapdealListed() {
1006
		return isSnapdealListed;
1007
	}
1008
 
1009
	public void setIsSnapdealListed(String isSnapdealListed) {
1010
		this.isSnapdealListed = isSnapdealListed;
1011
	}
1012
 
1013
	public String getExceptionPrice() {
1014
		return exceptionPrice;
1015
	}
1016
 
1017
	public void setExceptionPrice(String exceptionPrice) {
1018
		this.exceptionPrice = exceptionPrice;
1019
	}
1020
 
1021
	public String getWarehouseId() {
1022
		return warehouseId;
1023
	}
1024
 
1025
	public void setWarehouseId(String warehouseId) {
1026
		this.warehouseId = warehouseId;
1027
	}
1028
 
1029
	public File getFile() {
1030
		return file;
1031
	}
1032
 
1033
	public void setFile(File file) {
1034
		this.file = file;
1035
	}
1036
 
1037
	public String getErrMsg() {
1038
		return errMsg;
1039
	}
1040
 
1041
	public void setErrMsg(String errMsg) {
1042
		this.errMsg = errMsg;
1043
	}
1044
 
1045
	public String getNext() {
1046
		return next;
1047
	}
1048
 
1049
	public void setNext(String next) {
1050
		this.next = next;
1051
	}
1052
 
1053
	public String getId() {
1054
		return id;
1055
	}
1056
 
1057
	public void setServletRequest(HttpServletRequest req) {
1058
		this.request = req;
1059
		this.session = req.getSession();        
1060
	}
1061
 
1062
	public void setServletContext(ServletContext arg0) {
1063
		// TODO Auto-generated method stub
1064
 
1065
	}
1066
 
1067
	public void setServletResponse(HttpServletResponse response) {
1068
		this.response = response;
1069
	}
1070
 
9242 kshitij.so 1071
	public void setSearchText(String searchText) {
1072
		this.searchText = searchText;
1073
	}
1074
 
1075
	public String getSearchText() {
1076
		return searchText;
1077
	}
1078
 
1079
	public long getSearchCount() {
1080
		return searchCount;
1081
	}
1082
 
1083
	public long getTotalCount() {
1084
		return totalCount;
1085
	}
1086
 
1087
	public void setSearchCount(long count) {
1088
		this.searchCount = count;
1089
	}
1090
 
1091
	public List<SnapdealItemDetails> getSnapdealItems(){
1092
		return snapdealItems;
1093
	}
1094
 
1095
	public void setSellingPrice(String sellingPrice) {
1096
		this.sellingPrice = sellingPrice;
1097
	}
1098
 
1099
	public String getSellingPrice() {
1100
		return sellingPrice;
1101
	}
1102
 
1103
	public void setTransferPrice(String transferPrice) {
1104
		this.transferPrice = transferPrice;
1105
	}
1106
 
1107
	public String getTransferPrice() {
1108
		return transferPrice;
1109
	}
1110
 
1111
	public void setWebisteMrp(String webisteMrp) {
1112
		this.webisteMrp = webisteMrp;
1113
	}
1114
 
1115
	public String getWebisteMrp() {
1116
		return webisteMrp;
1117
	}
1118
 
1119
	public void setWebisteSellingPrice(String webisteSellingPrice) {
1120
		this.webisteSellingPrice = webisteSellingPrice;
1121
	}
1122
 
1123
	public String getWebisteSellingPrice() {
1124
		return webisteSellingPrice;
1125
	}
1126
 
1127
	public void setIsListedOnSnapdeal(String isListedOnSnapdeal) {
1128
		this.isListedOnSnapdeal = isListedOnSnapdeal;
1129
	}
1130
 
1131
	public String getIsSuppressInventoryFeed() {
1132
		return isSuppressInventoryFeed;
1133
	}
1134
 
1135
	public void setIsSuppressInventoryFeed(String isSuppressInventoryFeed) {
1136
		this.isSuppressInventoryFeed = isSuppressInventoryFeed;
1137
	}
1138
 
1139
	public String getIsSuppressPriceFeed() {
1140
		return isSuppressPriceFeed;
1141
	}
1142
 
1143
	public void setIsSuppressPriceFeed(String isSuppressPriceFeed) {
1144
		this.isSuppressPriceFeed = isSuppressPriceFeed;
1145
	}
1146
 
1147
	public String getIsListedOnSnapdeal() {
1148
		return isListedOnSnapdeal;
1149
	}
1150
 
1151
	public void setCommission(String commission) {
1152
		this.commission = commission;
1153
	}
1154
 
1155
	public String getCommission() {
1156
		return commission;
1157
	}
1158
 
1159
	public void setServiceTax(String serviceTax) {
1160
		this.serviceTax = serviceTax;
1161
	}
1162
 
1163
	public String getServiceTax() {
1164
		return serviceTax;
1165
	}
1166
 
1167
	public void setCourierCost(String courierCost) {
1168
		this.courierCost = courierCost;
1169
	}
1170
 
1171
	public String getCourierCost() {
1172
		return courierCost;
1173
	}
1174
 
9478 kshitij.so 1175
	public void setMaxNlc(String maxNlc) {
1176
		this.maxNlc = maxNlc;
1177
	}
1178
 
1179
	public String getMaxNlc() {
1180
		return maxNlc;
1181
	}
1182
 
9242 kshitij.so 1183
	public String getItemDetails(){
1184
		return itemObj.toString();
1185
	}
1186
 
9725 kshitij.so 1187
	public double getRoundOfValue(String val){
1188
		return roundTwoDecimals(Double.valueOf(val));
1189
	}
9242 kshitij.so 1190
 
1191
 
9725 kshitij.so 1192
 
9242 kshitij.so 1193
}