Subversion Repositories SmartDukaan

Rev

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

Rev 7283 Rev 7365
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
-
 
3
import java.util.HashMap;
3
import java.util.List;
4
import java.util.List;
4
import java.util.Map;
5
import java.util.Map;
5
 
6
 
6
import javax.servlet.ServletRequest;
7
import javax.servlet.ServletRequest;
7
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletRequest;
Line 12... Line 13...
12
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
13
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
13
import in.shop2020.model.v1.catalog.CatalogService.Client;
14
import in.shop2020.model.v1.catalog.CatalogService.Client;
14
import in.shop2020.model.v1.inventory.InventoryServiceException;
15
import in.shop2020.model.v1.inventory.InventoryServiceException;
15
import in.shop2020.thrift.clients.CatalogClient;
16
import in.shop2020.thrift.clients.CatalogClient;
16
import in.shop2020.thrift.clients.InventoryClient;
17
import in.shop2020.thrift.clients.InventoryClient;
-
 
18
import in.shop2020.thrift.clients.LogisticsClient;
-
 
19
import in.shop2020.logistics.DeliveryType;
-
 
20
import in.shop2020.logistics.LogisticsInfo;
-
 
21
import in.shop2020.logistics.LogisticsServiceException;
-
 
22
import in.shop2020.logistics.PickUpType;
17
 
23
 
-
 
24
import org.apache.commons.lang.xwork.StringUtils;
18
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Result;
19
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.struts2.convention.annotation.Results;
20
import org.apache.struts2.interceptor.ServletRequestAware;
27
import org.apache.struts2.interceptor.ServletRequestAware;
21
import org.apache.thrift.TException;
28
import org.apache.thrift.TException;
22
import org.apache.thrift.transport.TTransportException;
29
import org.apache.thrift.transport.TTransportException;
Line 40... Line 47...
40
	private String isNonFba;
47
	private String isNonFba;
41
	private String isInventoryOverride;
48
	private String isInventoryOverride;
42
	private String fbaPrice;
49
	private String fbaPrice;
43
	private String sellingPrice;
50
	private String sellingPrice;
44
	private String saholicPrice;
51
	private String saholicPrice;
-
 
52
	private String isTime;
-
 
53
	private String handlingTime;
-
 
54
	private String customHandlingTime;
45
 
55
 
46
	public String index() {
56
	public String index() {
47
		return "index";
57
		return "index";
48
	}
58
	}
49
 
59
 
50
 
60
 
51
	public List<Amazonlisted> fetchItems() throws TException {
61
	public List<Amazonlisted> fetchItems() throws TException {
52
		Client CatalogClient = new CatalogClient().getClient();
62
		Client CatalogClient = new CatalogClient().getClient();
53
		return CatalogClient.getAllAmazonListedItems();
63
		return CatalogClient.getAllAmazonListedItems();
54
 
-
 
55
	}
64
	}
56
 
65
 
57
	public Amazonlisted fetchItemDetail() throws NumberFormatException, TException { 
66
	public Amazonlisted fetchItemDetail() throws NumberFormatException, TException { 
58
		Client CatalogClient = new CatalogClient().getClient();
67
		Client CatalogClient = new CatalogClient().getClient();
59
		return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
68
		return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
60
 
-
 
61
	}
69
	}
62
 
70
 
63
	public Item getSaholicItem() throws NumberFormatException, CatalogServiceException, TException { 
71
	public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException { 
64
		Client CatalogClient = new CatalogClient().getClient();
72
		Client CatalogClient = new CatalogClient().getClient();
65
		return CatalogClient.getItem(Long.valueOf(id));
73
		return CatalogClient.getItem(Long.valueOf(id));
66
	}
74
	}
-
 
75
 
67
	
76
 
68
	
77
 
69
	public String update() throws NumberFormatException, TException{
78
	public String update() throws NumberFormatException, TException{
70
		Client CatalogClient = new CatalogClient().getClient();
79
		Client CatalogClient = new CatalogClient().getClient();
71
		if ( Double.valueOf(fbaPrice) > Double.valueOf(saholicPrice) || Double.valueOf(sellingPrice) > Double.valueOf(saholicPrice) ) {
80
		if ( Double.valueOf(fbaPrice) > Double.valueOf(saholicPrice) || Double.valueOf(sellingPrice) > Double.valueOf(saholicPrice) ) {
72
		addActionError("Failed To Do Changes");
81
			addActionError("Failed To Do Changes");
73
		}
82
		}
74
		else {
83
		else {
-
 
84
			boolean flag=false;
-
 
85
			long delay = Long.valueOf(handlingTime);
-
 
86
			if ( Boolean.valueOf(isTime)) {
-
 
87
				flag = true;
-
 
88
				delay = Long.valueOf(customHandlingTime);
-
 
89
			}
-
 
90
 
75
		CatalogClient.updateAmazonItemDetails(Long.valueOf(itemId),Double.valueOf(fbaPrice),Double.valueOf(sellingPrice),Boolean.valueOf(isFba),Boolean.valueOf(isNonFba),Boolean.valueOf(isInventoryOverride));
91
			CatalogClient.updateAmazonItemDetails(Long.valueOf(itemId),Double.valueOf(fbaPrice),Double.valueOf(sellingPrice),Boolean.valueOf(isFba),Boolean.valueOf(isNonFba),Boolean.valueOf(isInventoryOverride),delay,flag);
76
		}
92
		}
77
		setUrl("/amazon-list/");
93
		setUrl("/amazon-list/");
78
		return "redirect";
94
		return "redirect";
79
 
95
 
80
	}
96
	}
Line 100... Line 116...
100
		return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
116
		return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
101
	}
117
	}
102
 
118
 
103
	public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
119
	public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
104
		InventoryClient inventoryServiceClient = new InventoryClient();
120
		InventoryClient inventoryServiceClient = new InventoryClient();
-
 
121
		try { 
105
		return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
122
			return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
-
 
123
		}
-
 
124
		catch (Exception e){
-
 
125
			return null;
-
 
126
		}
-
 
127
	}
-
 
128
 
-
 
129
	public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
-
 
130
		LogisticsClient logisticsClient = new LogisticsClient();
-
 
131
		return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
-
 
132
 
-
 
133
	}
-
 
134
 
-
 
135
	public  Map<Long, String> getAliveItemMap() throws TException{
-
 
136
		Client CatalogClient = new CatalogClient().getClient();
-
 
137
		List<Item> itemList = CatalogClient.getAllAliveItems();
-
 
138
		Map<Long, String> itemMap = new HashMap<Long, String>();
-
 
139
		for (Item o : itemList) {
-
 
140
			itemMap.put((Long) o.getId(), (String) o.getBrand()+" "+o.getModelName()+" "+o.getModelNumber()+" "+o.getColor());
-
 
141
		}
-
 
142
		return itemMap;
106
	}
143
	}
107
 
144
 
108
	public String edit() {
145
	public String edit() {
109
		return "edit";
146
		return "edit";
110
	}
147
	}
Line 180... Line 217...
180
	}
217
	}
181
 
218
 
182
	public String getFbaPrice() {
219
	public String getFbaPrice() {
183
		return fbaPrice;
220
		return fbaPrice;
184
	}
221
	}
185
	
222
 
186
	public void setSaholicPrice(String saholicPrice) {
223
	public void setSaholicPrice(String saholicPrice) {
187
		this.saholicPrice = saholicPrice;
224
		this.saholicPrice = saholicPrice;
188
	}
225
	}
189
 
226
 
190
	public String getSaholicPrice() {
227
	public String getSaholicPrice() {
191
		return saholicPrice;
228
		return saholicPrice;
192
	}
229
	}
193
 
230
 
-
 
231
	public void setIsTime(String isTime){
-
 
232
		this.isTime = isTime;
-
 
233
	}
-
 
234
 
-
 
235
	String getIsTime(){
-
 
236
		return isTime;
-
 
237
	}
-
 
238
 
-
 
239
	public void setHandlingTime(String handlingTime){
-
 
240
		this.handlingTime = handlingTime;
-
 
241
	}
-
 
242
 
-
 
243
	String getHandlingTime(){
-
 
244
		return handlingTime;
-
 
245
	}
-
 
246
 
-
 
247
	public void setCustomHandlingTime(String customHandlingTime){
-
 
248
		this.customHandlingTime = customHandlingTime;
-
 
249
	}
-
 
250
 
-
 
251
	String getCustomHandlingTime(){
-
 
252
		return customHandlingTime;
-
 
253
	}
-
 
254
 
194
	@Override
255
	@Override
195
	public void setServletRequest(HttpServletRequest request) {
256
	public void setServletRequest(HttpServletRequest request) {
196
		this.request = request;
257
		this.request = request;
197
 
258
 
198
	}
259
	}
199
 
260
 
200
	public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException {
261
	public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException {
201
		AmazonListController call = new AmazonListController();
262
		AmazonListController call = new AmazonListController();
202
		//System.out.println(call.getItemReservedInventory("5"));
263
		System.out.println(call.getInventoryForAmazonItem("5"));
203
	}
264
	}
204
}
265
}