| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.server;
|
|
|
2 |
|
| 21864 |
ashik.ali |
3 |
import java.io.BufferedReader;
|
|
|
4 |
import java.io.FileReader;
|
|
|
5 |
import java.io.IOException;
|
|
|
6 |
import java.text.DateFormat;
|
|
|
7 |
import java.text.SimpleDateFormat;
|
|
|
8 |
import java.util.ArrayList;
|
|
|
9 |
import java.util.Arrays;
|
|
|
10 |
import java.util.Calendar;
|
|
|
11 |
import java.util.Collections;
|
|
|
12 |
import java.util.Date;
|
|
|
13 |
import java.util.HashMap;
|
|
|
14 |
import java.util.HashSet;
|
|
|
15 |
import java.util.List;
|
|
|
16 |
import java.util.Map;
|
|
|
17 |
import java.util.Map.Entry;
|
|
|
18 |
import java.util.Set;
|
|
|
19 |
import java.util.TreeMap;
|
|
|
20 |
|
|
|
21 |
import org.apache.log4j.Logger;
|
|
|
22 |
import org.apache.thrift.TException;
|
|
|
23 |
import org.apache.thrift.transport.TTransportException;
|
|
|
24 |
|
|
|
25 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
26 |
|
| 1961 |
ankur.sing |
27 |
import in.shop2020.catalog.dashboard.client.CatalogService;
|
| 18150 |
kshitij.so |
28 |
import in.shop2020.catalog.dashboard.shared.BulkItemPricing;
|
| 21864 |
ashik.ali |
29 |
import in.shop2020.catalog.dashboard.shared.CategoryHsnCode;
|
| 1961 |
ankur.sing |
30 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 4431 |
phani.kuma |
31 |
import in.shop2020.catalog.dashboard.shared.ItemInventory;
|
| 3850 |
chandransh |
32 |
import in.shop2020.catalog.dashboard.shared.ItemStatus;
|
| 12280 |
amit.gupta |
33 |
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
|
| 2068 |
ankur.sing |
34 |
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
|
| 3558 |
rajveer |
35 |
import in.shop2020.catalog.dashboard.shared.SourcePricings;
|
| 2119 |
ankur.sing |
36 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
|
|
37 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 5504 |
phani.kuma |
38 |
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
|
| 2378 |
ankur.sing |
39 |
import in.shop2020.config.ConfigException;
|
| 3907 |
chandransh |
40 |
import in.shop2020.content.ContentService;
|
|
|
41 |
import in.shop2020.content.ContentServiceException;
|
| 5946 |
rajveer |
42 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 10484 |
vikram.rag |
43 |
import in.shop2020.model.v1.catalog.CatalogServiceException;
|
| 6838 |
vikram.rag |
44 |
import in.shop2020.model.v1.catalog.Insurer;
|
| 5706 |
amit.gupta |
45 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 11671 |
vikram.rag |
46 |
import in.shop2020.model.v1.catalog.PrivateDeal;
|
| 2105 |
ankur.sing |
47 |
import in.shop2020.model.v1.catalog.status;
|
| 12280 |
amit.gupta |
48 |
import in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems;
|
| 6096 |
amit.gupta |
49 |
import in.shop2020.model.v1.inventory.InventoryService;
|
| 6813 |
amar.kumar |
50 |
import in.shop2020.model.v1.inventory.ItemStockPurchaseParams;
|
| 9687 |
rajveer |
51 |
import in.shop2020.model.v1.inventory.OOSStatus;
|
| 12280 |
amit.gupta |
52 |
import in.shop2020.model.v1.inventory.StateInfo;
|
|
|
53 |
import in.shop2020.model.v1.inventory.VatType;
|
| 5504 |
phani.kuma |
54 |
import in.shop2020.model.v1.user.VoucherType;
|
| 3129 |
rajveer |
55 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 3907 |
chandransh |
56 |
import in.shop2020.thrift.clients.ContentClient;
|
| 5946 |
rajveer |
57 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 2378 |
ankur.sing |
58 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 2119 |
ankur.sing |
59 |
import in.shop2020.utils.CategoryManager;
|
| 2359 |
ankur.sing |
60 |
import in.shop2020.utils.ConfigClientKeys;
|
| 12280 |
amit.gupta |
61 |
|
| 1961 |
ankur.sing |
62 |
@SuppressWarnings("serial")
|
|
|
63 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
|
|
64 |
|
| 11671 |
vikram.rag |
65 |
private static Logger logger = Logger.getLogger(CatalogServiceImpl.class);
|
|
|
66 |
|
|
|
67 |
private static Logger pushToProdLogger = Logger.getLogger("pushToProdLogger");
|
|
|
68 |
|
|
|
69 |
private static Date pushToProdDate;
|
|
|
70 |
|
|
|
71 |
private static String logFile;
|
|
|
72 |
|
|
|
73 |
private static int maxCount;
|
|
|
74 |
|
|
|
75 |
private static final int EBAYSOURCE = 6;
|
|
|
76 |
private static final int SNAPDEALSOURCE = 7;
|
|
|
77 |
private static final int FLIPKARTSOURCE = 8;
|
| 13748 |
manish.sha |
78 |
private static final int HOMESHOP18SOURCE = 4;
|
| 18166 |
kshitij.so |
79 |
|
|
|
80 |
private static final long DEFAULTQUANTIYSTEP = 1;
|
|
|
81 |
private static final long DEFAULTMINBUYQTY =1;
|
| 18415 |
kshitij.so |
82 |
private static final long DEFAULTMAXBUYQTY = 0;
|
| 11671 |
vikram.rag |
83 |
|
|
|
84 |
List<Item> privateDealitemList;
|
|
|
85 |
|
|
|
86 |
static {
|
|
|
87 |
try {
|
|
|
88 |
logFile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
|
|
|
89 |
maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
|
|
|
90 |
} catch(ConfigException ce) {
|
|
|
91 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
92 |
logFile = "/var/log/services/pushToProductionCount/pushToProd.log";
|
|
|
93 |
maxCount = 5;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
@Override
|
|
|
99 |
public int getItemCountByStatus(boolean useStatus, ItemStatus itemStatus){
|
|
|
100 |
int count = 0;
|
|
|
101 |
try{
|
|
|
102 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
103 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
104 |
|
|
|
105 |
status stat = status.findByValue(itemStatus.getValue());
|
|
|
106 |
count = catalogClient.getItemCountByStatus(useStatus, stat);
|
|
|
107 |
}catch(Exception e){
|
|
|
108 |
logger.error("Error while getting the count of items from the catalog service", e);
|
|
|
109 |
}
|
|
|
110 |
return count;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
@Override
|
| 6530 |
vikram.rag |
114 |
public List<Item> getInventoryOutofSyncItems(int offset, int limit){
|
| 11671 |
vikram.rag |
115 |
List<Item> itemList = new ArrayList<Item>();
|
| 6530 |
vikram.rag |
116 |
|
| 11671 |
vikram.rag |
117 |
try {
|
|
|
118 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
119 |
Client catalogClient = catalogServiceClient.getClient();
|
| 6530 |
vikram.rag |
120 |
|
| 11671 |
vikram.rag |
121 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllIgnoredInventoryUpdateItemsList(offset, limit);
|
| 6530 |
vikram.rag |
122 |
|
| 11671 |
vikram.rag |
123 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
124 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
125 |
}
|
|
|
126 |
} catch (Exception e) {
|
|
|
127 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
128 |
}
|
|
|
129 |
return itemList;
|
|
|
130 |
}
|
| 6530 |
vikram.rag |
131 |
|
| 11671 |
vikram.rag |
132 |
@Override
|
|
|
133 |
public int getInventoryOutofSyncItemsCount(){
|
|
|
134 |
int count=0;
|
|
|
135 |
try {
|
|
|
136 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
137 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 6530 |
vikram.rag |
138 |
|
| 11671 |
vikram.rag |
139 |
count = inventoryClient.getAllIgnoredInventoryupdateItemsCount();
|
| 2359 |
ankur.sing |
140 |
|
| 11671 |
vikram.rag |
141 |
} catch (Exception e) {
|
|
|
142 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
143 |
}
|
|
|
144 |
return count;
|
|
|
145 |
}
|
| 2359 |
ankur.sing |
146 |
|
| 11671 |
vikram.rag |
147 |
public List<Item> getPrivateDealItems(int offset,int limit){
|
|
|
148 |
privateDealitemList = new ArrayList<Item>();
|
|
|
149 |
try {
|
|
|
150 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
151 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
152 |
|
| 11671 |
vikram.rag |
153 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getPrivateDealItems(offset, limit);
|
| 2208 |
ankur.sing |
154 |
|
| 11671 |
vikram.rag |
155 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
156 |
privateDealitemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
157 |
}
|
|
|
158 |
} catch (Exception e) {
|
|
|
159 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
160 |
}
|
|
|
161 |
return privateDealitemList;
|
|
|
162 |
}
|
|
|
163 |
public int getPrivateDealItemsCount(){
|
|
|
164 |
if(privateDealitemList!=null)
|
|
|
165 |
return privateDealitemList.size();
|
|
|
166 |
else
|
|
|
167 |
return 0;
|
|
|
168 |
}
|
| 2359 |
ankur.sing |
169 |
|
| 11671 |
vikram.rag |
170 |
@Override
|
|
|
171 |
public List<Item> getAllItems(int start, int limit) {
|
|
|
172 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
173 |
logger.error("Inside get All Items");
|
|
|
174 |
try {
|
|
|
175 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
176 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
177 |
|
| 11671 |
vikram.rag |
178 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsInRange(start, limit);
|
|
|
179 |
logger.error("Before get item from thrift");
|
|
|
180 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
181 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
182 |
}
|
|
|
183 |
logger.error("After get item from thrift");
|
|
|
184 |
} catch (Exception e) {
|
|
|
185 |
logger.error("Error while getting all items from the catalog service", e);
|
|
|
186 |
}
|
|
|
187 |
logger.error("Item List return Size "+ itemList.size());
|
|
|
188 |
return itemList;
|
|
|
189 |
}
|
| 2359 |
ankur.sing |
190 |
|
| 11671 |
vikram.rag |
191 |
public List<Item> getAllActiveItems(int start, int limit){
|
|
|
192 |
return getItemsByStatus(status.ACTIVE, start, limit);
|
|
|
193 |
}
|
| 2359 |
ankur.sing |
194 |
|
| 11671 |
vikram.rag |
195 |
@Override
|
|
|
196 |
public List<Item> getAllPhasedOutItems(int start, int limit){
|
|
|
197 |
return getItemsByStatus(status.PHASED_OUT, start, limit);
|
|
|
198 |
}
|
| 2359 |
ankur.sing |
199 |
|
| 11671 |
vikram.rag |
200 |
@Override
|
|
|
201 |
public List<Item> getAllPausedItems(int start, int limit){
|
|
|
202 |
return getItemsByStatus(status.PAUSED, start, limit);
|
|
|
203 |
}
|
| 2359 |
ankur.sing |
204 |
|
| 11671 |
vikram.rag |
205 |
@Override
|
|
|
206 |
public List<Item> getAllInProcessItems(int start, int limit) {
|
|
|
207 |
return getItemsByStatus(status.IN_PROCESS, start, limit);
|
|
|
208 |
}
|
| 2359 |
ankur.sing |
209 |
|
| 11671 |
vikram.rag |
210 |
@Override
|
|
|
211 |
public List<Item> getAllContentCompleteItems(int start, int limit) {
|
|
|
212 |
return getItemsByStatus(status.CONTENT_COMPLETE, start, limit);
|
|
|
213 |
}
|
| 2359 |
ankur.sing |
214 |
|
| 11671 |
vikram.rag |
215 |
public List<Item> getBestDeals(){
|
|
|
216 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
217 |
try {
|
|
|
218 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
219 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
220 |
|
| 11671 |
vikram.rag |
221 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
|
|
222 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
223 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
224 |
}
|
|
|
225 |
} catch(Exception e){
|
|
|
226 |
logger.error("Error while getting the best deals from the catalog service", e);
|
|
|
227 |
}
|
|
|
228 |
//Collections.sort(itemList, new ItemsComparator());
|
|
|
229 |
return itemList;
|
|
|
230 |
}
|
| 2359 |
ankur.sing |
231 |
|
| 11671 |
vikram.rag |
232 |
@Override
|
|
|
233 |
public List<Item> getRiskyItems() {
|
|
|
234 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
235 |
try {
|
|
|
236 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
237 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
238 |
|
|
|
239 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
|
|
|
240 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
241 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
242 |
}
|
|
|
243 |
} catch(Exception e){
|
|
|
244 |
logger.error("Error while getting the risky items from the catalog service", e);
|
|
|
245 |
}
|
|
|
246 |
Collections.sort(itemList, new ItemsComparator());
|
|
|
247 |
return itemList;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
public List<Item> getBestSellers(){
|
|
|
251 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
252 |
|
|
|
253 |
try {
|
|
|
254 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
255 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
256 |
|
|
|
257 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
|
|
258 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
259 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
260 |
}
|
|
|
261 |
} catch(Exception e){
|
|
|
262 |
logger.error("Error while getting the best sellers from the catalog service", e);
|
|
|
263 |
}
|
|
|
264 |
return itemList;
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
@Override
|
|
|
268 |
public boolean addtoIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
|
|
|
269 |
try {
|
|
|
270 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
271 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
272 |
return inventoryClient.insertItemtoIgnoreInventoryUpdatelist(itemId, warehouseId);
|
| 6530 |
vikram.rag |
273 |
} catch (Exception e) {
|
| 6532 |
amit.gupta |
274 |
logger.error("Error while inserting item to ignore inventory update list", e);
|
| 11671 |
vikram.rag |
275 |
}
|
| 6530 |
vikram.rag |
276 |
return false;
|
| 11671 |
vikram.rag |
277 |
}
|
| 2359 |
ankur.sing |
278 |
|
| 11671 |
vikram.rag |
279 |
@Override
|
|
|
280 |
public boolean deleteFromIgnoredInventoryUpdateItemsIdsWarehouseIds(long itemId,long warehouseId){
|
|
|
281 |
try {
|
|
|
282 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
283 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
284 |
return inventoryClient.deleteItemFromIgnoredInventoryUpdateList(itemId,warehouseId);
|
| 6530 |
vikram.rag |
285 |
|
| 11671 |
vikram.rag |
286 |
} catch (Exception e) {
|
|
|
287 |
logger.error("Error while inserting item to ignore inventory update list", e);
|
|
|
288 |
}
|
|
|
289 |
return false;
|
|
|
290 |
}
|
| 6530 |
vikram.rag |
291 |
|
| 2359 |
ankur.sing |
292 |
|
|
|
293 |
|
| 11671 |
vikram.rag |
294 |
@Override
|
|
|
295 |
public List<Item> getLatestArrivals(){
|
|
|
296 |
List<Item> itemList = new ArrayList<Item>();
|
| 2359 |
ankur.sing |
297 |
|
| 11671 |
vikram.rag |
298 |
try {
|
|
|
299 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
300 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3872 |
chandransh |
301 |
|
| 11671 |
vikram.rag |
302 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
|
|
303 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
304 |
//List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
|
|
305 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null));
|
|
|
306 |
}
|
|
|
307 |
} catch(Exception e){
|
|
|
308 |
logger.error("Error while getting the latest arrivals from the catalog service", e);
|
|
|
309 |
}
|
|
|
310 |
return itemList;
|
|
|
311 |
}
|
| 3872 |
chandransh |
312 |
|
| 11671 |
vikram.rag |
313 |
@Override
|
|
|
314 |
public List<Item> searchItems(int start, int limit, List<String> searchTerms) {
|
|
|
315 |
List<Item> itemList = new ArrayList<Item>();
|
| 3872 |
chandransh |
316 |
|
| 11671 |
vikram.rag |
317 |
try {
|
|
|
318 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
319 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
320 |
|
| 11671 |
vikram.rag |
321 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.searchItemsInRange(searchTerms, start, limit);
|
|
|
322 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
323 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null,null));
|
|
|
324 |
}
|
|
|
325 |
} catch(Exception e){
|
|
|
326 |
logger.error("Error while getting the search results from the catalog service", e);
|
|
|
327 |
}
|
|
|
328 |
return itemList;
|
|
|
329 |
}
|
| 2359 |
ankur.sing |
330 |
|
| 11671 |
vikram.rag |
331 |
@Override
|
|
|
332 |
public int getSearchResultCount(List<String> searchTerms){
|
|
|
333 |
int count = 0;
|
|
|
334 |
try {
|
|
|
335 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
336 |
Client catalogClient = catalogServiceClient.getClient();
|
| 2359 |
ankur.sing |
337 |
|
| 11671 |
vikram.rag |
338 |
count = catalogClient.getSearchResultCount(searchTerms);
|
|
|
339 |
} catch(Exception e){
|
|
|
340 |
logger.error("Error while getting the search results from the catalog service", e);
|
|
|
341 |
}
|
| 2359 |
ankur.sing |
342 |
|
| 11671 |
vikram.rag |
343 |
return count;
|
|
|
344 |
}
|
| 2359 |
ankur.sing |
345 |
|
| 11671 |
vikram.rag |
346 |
public Item getItem(long itemId){
|
|
|
347 |
try{
|
|
|
348 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
349 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
350 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
351 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
352 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
|
|
353 |
PrivateDeal privateDeal = catalogClient.getPrivateDealDetails(itemId);
|
|
|
354 |
Long catalogItemId = thriftItem.getCatalogItemId();
|
|
|
355 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByCatalogId(catalogItemId);
|
|
|
356 |
List <Long> sameItemsWithDifferentColors = new ArrayList<Long>();
|
|
|
357 |
if(thriftItems.size()>1){
|
|
|
358 |
for(in.shop2020.model.v1.catalog.Item tItem : thriftItems ){
|
|
|
359 |
Long id = tItem.getId();
|
|
|
360 |
if(!id.equals(itemId)){
|
|
|
361 |
sameItemsWithDifferentColors.add(id);
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
}
|
|
|
365 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
| 12280 |
amit.gupta |
366 |
Map<Long,StateInfo> stateIdNameMap = inventoryClient.getStateMaster();
|
| 2359 |
ankur.sing |
367 |
|
| 11671 |
vikram.rag |
368 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
|
|
369 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
|
|
|
370 |
List<in.shop2020.model.v1.catalog.Item> sit = catalogClient.getAllSimilarItems(thriftItem.getId());
|
|
|
371 |
in.shop2020.model.v1.inventory.ItemInventory itemInventory = inventoryClient.getItemInventoryByItemId(thriftItem.getId());
|
|
|
372 |
ItemStockPurchaseParams stockPurchaseParams = inventoryClient.getItemStockPurchaseParams(thriftItem.getId());
|
|
|
373 |
Map<Long, String> saleHistory = new HashMap<Long, String>();
|
|
|
374 |
List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 0, 5);
|
|
|
375 |
String lastNdaySale = getOosString(oosStatuses);
|
|
|
376 |
saleHistory.put(0L,lastNdaySale);
|
|
|
377 |
List<OOSStatus> webOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 1, 5);
|
|
|
378 |
String webLastNdaySale = getOosString(webOosStatuses);
|
|
|
379 |
saleHistory.put(1L,webLastNdaySale);
|
|
|
380 |
List<OOSStatus> amzOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 3, 5);
|
|
|
381 |
String amzLastNdaySale = getOosString(amzOosStatuses);
|
|
|
382 |
saleHistory.put(3L,amzLastNdaySale);
|
|
|
383 |
List<OOSStatus> ebayOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 6, 5);
|
|
|
384 |
String ebayLastNdaySale = getOosString(ebayOosStatuses);
|
|
|
385 |
saleHistory.put(6L,ebayLastNdaySale);
|
|
|
386 |
List<OOSStatus> spdOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 7, 5);
|
|
|
387 |
String spdLastNdaySale = getOosString(spdOosStatuses);
|
|
|
388 |
saleHistory.put(7L,spdLastNdaySale);
|
|
|
389 |
List<OOSStatus> fktOosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 8, 5);
|
|
|
390 |
String fktLastNdaySale = getOosString(fktOosStatuses);
|
|
|
391 |
saleHistory.put(8L,fktLastNdaySale);
|
| 13727 |
manish.sha |
392 |
List<OOSStatus> hs18OosStatuses = inventoryClient.getOosStatusesForXDaysForItem(thriftItem.getId(), 4, 5);
|
|
|
393 |
String hs18LastNdaySale = getOosString(hs18OosStatuses);
|
|
|
394 |
saleHistory.put(4L,hs18LastNdaySale);
|
| 11671 |
vikram.rag |
395 |
Long freebieItemId = catalogClient.getFreebieForItem(thriftItem.getId());
|
|
|
396 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tvouchers = catalogClient.getAllItemVouchers(thriftItem.getId());
|
|
|
397 |
Map<String,String> stateNameVatPercentageMap = new HashMap<String,String>();
|
|
|
398 |
catalogClient = new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
|
|
|
399 |
double vatrate;
|
| 12280 |
amit.gupta |
400 |
for(Entry<Long, StateInfo> entry:stateIdNameMap.entrySet()){
|
|
|
401 |
vatrate = -1.0;
|
|
|
402 |
StateInfo state = entry.getValue();
|
|
|
403 |
double price = state.getVatType().equals(VatType.MRP)? thriftItem.getMrp() : thriftItem.getSellingPrice();
|
|
|
404 |
if(price > 0){
|
|
|
405 |
try{
|
|
|
406 |
vatrate = catalogClient.getVatPercentageForItem(thriftItem.getId(),entry.getKey(),price);
|
|
|
407 |
}
|
|
|
408 |
catch(CatalogServiceException cex){
|
|
|
409 |
vatrate = -1.0;
|
|
|
410 |
}
|
|
|
411 |
} else {
|
|
|
412 |
vatrate = -2.0;
|
| 11671 |
vikram.rag |
413 |
}
|
| 12280 |
amit.gupta |
414 |
if(vatrate != -2.0) {
|
|
|
415 |
stateNameVatPercentageMap.put(state.getStateName(),String.valueOf(vatrate));
|
|
|
416 |
} else {
|
|
|
417 |
stateNameVatPercentageMap.put(state.getStateName(),"MRP needed");
|
| 11671 |
vikram.rag |
418 |
}
|
|
|
419 |
}
|
|
|
420 |
Item it = getItemFromThriftItem(thriftItem, vip, vim, sip, sit, itemInventory, tvouchers, stockPurchaseParams, saleHistory, freebieItemId , stateNameVatPercentageMap,privateDeal);
|
|
|
421 |
it.setSameItemsWithDifferentColors(sameItemsWithDifferentColors);
|
|
|
422 |
return it;
|
|
|
423 |
}catch(Exception e){
|
|
|
424 |
logger.error("Error while getting the item from the catalog service", e);
|
|
|
425 |
}
|
|
|
426 |
return null;
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
private String getOosString(List<OOSStatus> oosStatuses){
|
|
|
430 |
String lastNdaySale = "";
|
|
|
431 |
for(OOSStatus oosStatus : oosStatuses){
|
|
|
432 |
if(oosStatus.isIs_oos()){
|
|
|
433 |
lastNdaySale += "X-";
|
|
|
434 |
}else{
|
|
|
435 |
lastNdaySale += oosStatus.getNum_orders() + "-";
|
|
|
436 |
}
|
|
|
437 |
}
|
|
|
438 |
if(lastNdaySale!=""){
|
|
|
439 |
lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
|
|
|
440 |
}
|
|
|
441 |
return lastNdaySale;
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
@Override
|
|
|
445 |
public boolean updateItem(Item item) {
|
|
|
446 |
logger.info("Updating item with Id: " + item.getId());
|
|
|
447 |
try{
|
|
|
448 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
449 |
Client catalogClient = catalogServiceClient.getClient();
|
| 6530 |
vikram.rag |
450 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 11671 |
vikram.rag |
451 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
452 |
|
|
|
453 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
|
|
454 |
in.shop2020.model.v1.catalog.PrivateDeal privateDeal = new in.shop2020.model.v1.catalog.PrivateDeal();
|
|
|
455 |
privateDeal.setItem_id(item.getId());
|
|
|
456 |
privateDeal.setDealFreebieItemId(item.getPrivateDeal().getDealFreebieItemId());
|
|
|
457 |
privateDeal.setDealPrice(item.getPrivateDeal().getDealPrice());
|
|
|
458 |
privateDeal.setDealText(item.getPrivateDeal().getDealText());
|
|
|
459 |
privateDeal.setDealFreebieOption(item.getPrivateDeal().getDealFreebieOption());
|
|
|
460 |
privateDeal.setDealTextOption(item.getPrivateDeal().getDealTextOption());
|
|
|
461 |
if(item.getPrivateDeal().getEndDate()!=null){
|
|
|
462 |
privateDeal.setEndDate(item.getPrivateDeal().getEndDate());
|
|
|
463 |
}
|
|
|
464 |
if(item.getPrivateDeal().getStartDate()!=null){
|
|
|
465 |
privateDeal.setStartDate(item.getPrivateDeal().getStartDate());
|
|
|
466 |
}
|
|
|
467 |
privateDeal.setIsCod(item.getPrivateDeal().isCod());
|
|
|
468 |
privateDeal.setRank(item.getPrivateDeal().getRank());
|
|
|
469 |
privateDeal.setIsActive(item.getPrivateDeal().isActive());
|
|
|
470 |
if(privateDeal.getDealPrice() > 0 && privateDeal.getEndDate()!=0 && privateDeal.getStartDate()!=0){
|
|
|
471 |
logger.info("Updating Private deal: " + item.getId());
|
|
|
472 |
logger.info("Deal Price "+privateDeal.getDealPrice());
|
|
|
473 |
logger.info("Deal Start Date "+privateDeal.getStartDate());
|
|
|
474 |
logger.info("Deal End Date "+privateDeal.getEndDate());
|
|
|
475 |
logger.info("Has COD on deal: " + privateDeal.isIsCod());
|
|
|
476 |
logger.info("Response" + catalogClient.addOrUpdatePrivateDeal(privateDeal));
|
|
|
477 |
logger.info("Updated Private deal: " + item.getId());
|
|
|
478 |
}
|
|
|
479 |
else{
|
|
|
480 |
logger.info("Skipping Private deal: " + item.getId());
|
|
|
481 |
logger.info("Deal Price "+privateDeal.getDealPrice());
|
|
|
482 |
logger.info("Deal Start Date "+privateDeal.getStartDate());
|
|
|
483 |
logger.info("Deal End Date "+privateDeal.getEndDate());
|
|
|
484 |
}
|
|
|
485 |
setThriftItemParams(tItem, item);
|
|
|
486 |
long rItemId;
|
|
|
487 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
|
|
488 |
logger.error("Error updating item, returned Item Id: " + rItemId);
|
|
|
489 |
return false;
|
|
|
490 |
}
|
|
|
491 |
logger.info("Successfully updated item with id: " + item.getId());
|
|
|
492 |
|
|
|
493 |
Map<String, VendorItemMapping> vendorMappings = item.getVendorKeysMap();
|
|
|
494 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
|
|
495 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
|
|
496 |
|
|
|
497 |
for(Entry<String, VendorItemMapping> e : vendorMappings.entrySet()) {
|
|
|
498 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
|
|
499 |
VendorItemMapping v = e.getValue();
|
|
|
500 |
tVendorMapping.setVendorId(v.getVendorId());
|
|
|
501 |
tVendorMapping.setItemKey(v.getItemKey());
|
|
|
502 |
tVendorMapping.setItemId(item.getId());
|
|
|
503 |
inventoryClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
|
|
504 |
logger.info("Updates VendorItemMapping: " + tVendorMapping.toString());
|
|
|
505 |
}
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
if(item.getMinStockLevel()!=0 || item.getNumOfDaysStock()!=0) {
|
|
|
509 |
inventoryClient.updateItemStockPurchaseParams(item.getId(), item.getNumOfDaysStock(),
|
|
|
510 |
item.getMinStockLevel());
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
if(item.getFreebieItemId()!=null) {
|
|
|
514 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem = new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
515 |
freebieItem.setItemId(item.getId());
|
|
|
516 |
freebieItem.setFreebieItemId(item.getFreebieItemId());
|
|
|
517 |
catalogClient.addOrUpdateFreebieForItem(freebieItem);
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
|
|
521 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
|
|
522 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
|
|
523 |
for(VendorPricings v : vendorPricings.values()) {
|
|
|
524 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
|
|
525 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
526 |
tVendorPricing.setItemId(item.getId());
|
|
|
527 |
tVendorPricing.setMop(v.getMop());
|
|
|
528 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
|
|
529 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
|
|
530 |
tVendorPricing.setNlc(v.getNlc());
|
|
|
531 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
|
|
532 |
logger.info("Updated VendorItemPricing: " + tVendorPricing.toString());
|
|
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
Map<Long, SourcePricings> sourcePricings = item.getSourcePricesMap();
|
|
|
537 |
if(sourcePricings != null && !sourcePricings.isEmpty()) {
|
|
|
538 |
in.shop2020.model.v1.catalog.SourceItemPricing tSourcePricings;
|
|
|
539 |
for(SourcePricings s : sourcePricings.values()) {
|
|
|
540 |
tSourcePricings = new in.shop2020.model.v1.catalog.SourceItemPricing();
|
|
|
541 |
tSourcePricings.setSourceId(s.getSourceId());
|
|
|
542 |
tSourcePricings.setItemId(item.getId());
|
|
|
543 |
tSourcePricings.setMrp(s.getMrp());
|
|
|
544 |
tSourcePricings.setSellingPrice(s.getSellingPrice());
|
|
|
545 |
catalogClient.addSourceItemPricing(tSourcePricings);
|
|
|
546 |
logger.info("Updated SourceItemPricing: " + tSourcePricings.toString());
|
|
|
547 |
}
|
|
|
548 |
}
|
|
|
549 |
|
|
|
550 |
}catch(Exception e){
|
|
|
551 |
logger.error("Error while updating item: ", e);
|
|
|
552 |
return false;
|
|
|
553 |
}
|
|
|
554 |
return true;
|
|
|
555 |
}
|
|
|
556 |
|
|
|
557 |
@Override
|
|
|
558 |
public List<Long> getMonitoredWarehouseIdsForVendors(List<Long> vendorIds){
|
|
|
559 |
List<Long> monitoredWarehouseids=null;
|
|
|
560 |
try {
|
|
|
561 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
562 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
563 |
monitoredWarehouseids = inventoryClient.getMonitoredWarehouseForVendors(vendorIds);
|
| 6530 |
vikram.rag |
564 |
} catch (Exception e) {
|
|
|
565 |
logger.error("Error while getting Monitored warehouse for vendor: ", e);
|
|
|
566 |
}
|
|
|
567 |
return monitoredWarehouseids;
|
| 11671 |
vikram.rag |
568 |
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
@Override
|
|
|
572 |
public List<ItemWarehouse> getignoredInventoryUpdateItemsIdsWarehouseIds(){
|
| 6530 |
vikram.rag |
573 |
List<ItemWarehouse> ignoredItemIdwarehouseIdList = new ArrayList<ItemWarehouse>();
|
| 11671 |
vikram.rag |
574 |
try {
|
| 2359 |
ankur.sing |
575 |
|
| 6530 |
vikram.rag |
576 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
577 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
578 |
List<IgnoredInventoryUpdateItems> ignoredInventoryUpdateItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
|
|
|
579 |
for(IgnoredInventoryUpdateItems ignoredInventoryUpdateItem:ignoredInventoryUpdateItems){
|
|
|
580 |
ignoredItemIdwarehouseIdList.add(new ItemWarehouse(ignoredInventoryUpdateItem.getItemId(),ignoredInventoryUpdateItem.getWarehouseId()));
|
|
|
581 |
}
|
| 11671 |
vikram.rag |
582 |
|
|
|
583 |
|
| 6530 |
vikram.rag |
584 |
} catch (Exception e) {
|
|
|
585 |
logger.error("Error while getting Monitored warehouseid and itemid : ", e);
|
|
|
586 |
}
|
|
|
587 |
return ignoredItemIdwarehouseIdList;
|
| 2359 |
ankur.sing |
588 |
|
| 11671 |
vikram.rag |
589 |
}
|
|
|
590 |
@Override
|
|
|
591 |
public Map<Long, String> getAllVendors() {
|
|
|
592 |
Map<Long, String> vendorMap = new HashMap<Long, String>();
|
|
|
593 |
try {
|
|
|
594 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
595 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2066 |
ankur.sing |
596 |
|
| 11671 |
vikram.rag |
597 |
List<in.shop2020.model.v1.inventory.Vendor> vendors = inventoryClient.getAllVendors();
|
| 3558 |
rajveer |
598 |
|
| 11671 |
vikram.rag |
599 |
for(in.shop2020.model.v1.inventory.Vendor v : vendors) {
|
|
|
600 |
vendorMap.put(v.getId(), v.getName());
|
|
|
601 |
}
|
|
|
602 |
} catch (Exception e) {
|
|
|
603 |
logger.error("Error while getting all the vendors: ", e);
|
|
|
604 |
}
|
|
|
605 |
return vendorMap;
|
|
|
606 |
}
|
| 3558 |
rajveer |
607 |
|
| 11671 |
vikram.rag |
608 |
@Override
|
|
|
609 |
public Map<Long, String> getAllSources() {
|
|
|
610 |
Map<Long, String> sourceMap = new HashMap<Long, String>();
|
|
|
611 |
try {
|
|
|
612 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
613 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3558 |
rajveer |
614 |
|
| 11671 |
vikram.rag |
615 |
List<in.shop2020.model.v1.catalog.Source> sources = catalogClient.getAllSources();
|
| 5118 |
mandeep.dh |
616 |
|
| 11671 |
vikram.rag |
617 |
for(in.shop2020.model.v1.catalog.Source s : sources) {
|
|
|
618 |
sourceMap.put(s.getId(), s.getName());
|
|
|
619 |
}
|
|
|
620 |
} catch (Exception e) {
|
|
|
621 |
logger.error("Error while getting all the vendors: ", e);
|
|
|
622 |
}
|
|
|
623 |
return sourceMap;
|
|
|
624 |
}
|
| 5118 |
mandeep.dh |
625 |
|
| 11671 |
vikram.rag |
626 |
@Override
|
|
|
627 |
public Map<Long, String> getShippingWarehouses() {
|
|
|
628 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
|
|
629 |
Set<Long> shippingLocations = new HashSet<Long>();
|
|
|
630 |
try {
|
|
|
631 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
632 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2359 |
ankur.sing |
633 |
|
| 11671 |
vikram.rag |
634 |
List<in.shop2020.model.v1.inventory.Warehouse> warehouses = inventoryClient.getAllWarehouses(true);
|
| 2359 |
ankur.sing |
635 |
|
| 11671 |
vikram.rag |
636 |
for(in.shop2020.model.v1.inventory.Warehouse warehouse : warehouses) {
|
|
|
637 |
shippingLocations.add(warehouse.getShippingWarehouseId());
|
|
|
638 |
}
|
| 2105 |
ankur.sing |
639 |
|
| 11671 |
vikram.rag |
640 |
for(in.shop2020.model.v1.inventory.Warehouse warehouse : warehouses) {
|
|
|
641 |
if (shippingLocations.contains(warehouse.getId())) {
|
|
|
642 |
warehouseMap.put(warehouse.getId(), warehouse.getDisplayName());
|
|
|
643 |
}
|
|
|
644 |
}
|
|
|
645 |
} catch (Exception e) {
|
|
|
646 |
logger.error("Error while getting all the warehouses:", e );
|
|
|
647 |
}
|
|
|
648 |
return warehouseMap;
|
|
|
649 |
}
|
| 2126 |
ankur.sing |
650 |
|
| 11671 |
vikram.rag |
651 |
@Override
|
|
|
652 |
public Map<Long, String> getAllWarehouses() {
|
|
|
653 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
|
|
654 |
try {
|
|
|
655 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
656 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 2105 |
ankur.sing |
657 |
|
| 11671 |
vikram.rag |
658 |
List<in.shop2020.model.v1.inventory.Warehouse> warehouses = inventoryClient.getAllWarehouses(true);
|
| 2359 |
ankur.sing |
659 |
|
| 11671 |
vikram.rag |
660 |
for(in.shop2020.model.v1.inventory.Warehouse w : warehouses) {
|
|
|
661 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
|
|
662 |
}
|
|
|
663 |
} catch (Exception e) {
|
|
|
664 |
logger.error("Error while getting all the warehouses:", e );
|
|
|
665 |
}
|
|
|
666 |
return warehouseMap;
|
|
|
667 |
}
|
| 2119 |
ankur.sing |
668 |
|
| 11671 |
vikram.rag |
669 |
@Override
|
|
|
670 |
public long addItem(Item item) {
|
|
|
671 |
long itemId = 0;
|
|
|
672 |
try {
|
|
|
673 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
674 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
675 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
676 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
677 |
in.shop2020.model.v1.catalog.Item tItem = new in.shop2020.model.v1.catalog.Item();
|
| 21864 |
ashik.ali |
678 |
tItem.setHsnCode(item.getHsnCode());
|
| 18166 |
kshitij.so |
679 |
item.setQuantityStep(DEFAULTQUANTIYSTEP);
|
|
|
680 |
item.setMinimumBuyQuantity(DEFAULTMINBUYQTY);
|
| 18415 |
kshitij.so |
681 |
item.setMaximumBuyQuantity(DEFAULTMAXBUYQTY);
|
| 11671 |
vikram.rag |
682 |
setThriftItemParams(tItem, item);
|
|
|
683 |
itemId = catalogClient.addItem(tItem);
|
| 12523 |
amit.gupta |
684 |
tItem.setId(itemId);
|
|
|
685 |
Client catalogClientProd = new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
|
|
|
686 |
catalogClientProd.addItem(tItem);
|
| 11671 |
vikram.rag |
687 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
|
|
688 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
|
|
689 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
|
|
690 |
for(VendorPricings v : vendorPricings.values()) {
|
|
|
691 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
|
|
692 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
693 |
tVendorPricing.setItemId(itemId);
|
|
|
694 |
tVendorPricing.setMop(v.getMop());
|
|
|
695 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
|
|
696 |
tVendorPricing.setNlc(v.getNlc());
|
|
|
697 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
|
|
698 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
|
|
699 |
}
|
|
|
700 |
}
|
| 2359 |
ankur.sing |
701 |
|
| 11671 |
vikram.rag |
702 |
Map<String, VendorItemMapping> vendorKeysMap = item.getVendorKeysMap();
|
|
|
703 |
if(vendorKeysMap != null && !vendorKeysMap.isEmpty()) {
|
|
|
704 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
|
|
705 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()) {
|
|
|
706 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
|
|
707 |
VendorItemMapping v = e.getValue();
|
|
|
708 |
tVendorMapping.setVendorId(v.getVendorId());
|
|
|
709 |
tVendorMapping.setItemKey(v.getItemKey());
|
|
|
710 |
tVendorMapping.setItemId(itemId);
|
|
|
711 |
inventoryClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
|
|
712 |
}
|
|
|
713 |
}
|
| 2359 |
ankur.sing |
714 |
|
| 11671 |
vikram.rag |
715 |
inventoryClient.updateItemStockPurchaseParams(itemId, item.getNumOfDaysStock(),
|
|
|
716 |
item.getMinStockLevel());
|
| 7291 |
vikram.rag |
717 |
|
| 11671 |
vikram.rag |
718 |
if(item.getFreebieItemId()!=null && item.getFreebieItemId()!=0) {
|
|
|
719 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem =
|
|
|
720 |
new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
721 |
freebieItem.setItemId(itemId);
|
|
|
722 |
freebieItem.setFreebieItemId(item.getFreebieItemId());
|
|
|
723 |
catalogClient.addOrUpdateFreebieForItem(freebieItem);
|
|
|
724 |
}
|
| 5217 |
amit.gupta |
725 |
|
| 11671 |
vikram.rag |
726 |
} catch (Exception e) {
|
|
|
727 |
logger.error("Error while adding an item: ", e);
|
|
|
728 |
}
|
|
|
729 |
return itemId;
|
|
|
730 |
}
|
| 2126 |
ankur.sing |
731 |
|
| 11671 |
vikram.rag |
732 |
@Override
|
|
|
733 |
public long checkSimilarItem(String brand, String modelNumber, String modelName, String color) {
|
| 2359 |
ankur.sing |
734 |
|
| 11671 |
vikram.rag |
735 |
try {
|
|
|
736 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
737 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
738 |
return catalogClient.checkSimilarItem(brand, modelNumber, modelName, color);
|
|
|
739 |
} catch (Exception e) {
|
|
|
740 |
logger.error("Error while checking for a similar item: ", e);
|
|
|
741 |
}
|
|
|
742 |
return 0;
|
|
|
743 |
}
|
| 2359 |
ankur.sing |
744 |
|
| 11671 |
vikram.rag |
745 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
|
|
746 |
tItem.setId(tItem.getId());
|
|
|
747 |
tItem.setProductGroup(item.getProductGroup());
|
|
|
748 |
tItem.setBrand(item.getBrand());
|
|
|
749 |
tItem.setModelName(item.getModelName());
|
|
|
750 |
tItem.setModelNumber(item.getModelNumber());
|
|
|
751 |
tItem.setColor(item.getColor());
|
|
|
752 |
tItem.setShowSellingPrice(item.isShowSellingPrice());
|
|
|
753 |
tItem.setHoldOverride(item.isHoldOverride());
|
|
|
754 |
tItem.setStatus_description(item.getItemStatusDesc());
|
|
|
755 |
tItem.setComments(item.getComments());
|
| 2126 |
ankur.sing |
756 |
|
| 11671 |
vikram.rag |
757 |
if(item.getMrp() != null) {
|
|
|
758 |
tItem.setMrp(item.getMrp());
|
|
|
759 |
}
|
| 2359 |
ankur.sing |
760 |
|
| 11671 |
vikram.rag |
761 |
if(item.getCatalogItemId() != null) {
|
|
|
762 |
tItem.setCatalogItemId(item.getCatalogItemId());
|
|
|
763 |
}
|
| 2359 |
ankur.sing |
764 |
|
| 11671 |
vikram.rag |
765 |
if(item.getSellingPrice() != null) {
|
|
|
766 |
tItem.setSellingPrice(item.getSellingPrice());
|
|
|
767 |
}
|
| 2359 |
ankur.sing |
768 |
|
| 11671 |
vikram.rag |
769 |
if(item.getWeight() != null) {
|
|
|
770 |
tItem.setWeight(item.getWeight());
|
|
|
771 |
}
|
| 2359 |
ankur.sing |
772 |
|
| 11671 |
vikram.rag |
773 |
if(item.getExpectedDelay() != null) {
|
|
|
774 |
tItem.setExpectedDelay(item.getExpectedDelay());
|
|
|
775 |
}
|
| 2359 |
ankur.sing |
776 |
|
| 11671 |
vikram.rag |
777 |
tItem.setIsWarehousePreferenceSticky(item.isWarehouseStickiness());
|
| 2359 |
ankur.sing |
778 |
|
| 11671 |
vikram.rag |
779 |
if(item.getPreferredVendor() != null) {
|
|
|
780 |
tItem.setPreferredVendor(item.getPreferredVendor());
|
|
|
781 |
}
|
|
|
782 |
tItem.setPreferredInsurer(item.getPreferredInsurer());
|
| 2359 |
ankur.sing |
783 |
|
| 11671 |
vikram.rag |
784 |
if(item.getAsin() != null) {
|
|
|
785 |
tItem.setAsin(item.getAsin());
|
|
|
786 |
}
|
|
|
787 |
if(item.getHoldInventory()!= null) {
|
|
|
788 |
tItem.setHoldInventory(item.getHoldInventory());
|
|
|
789 |
}
|
|
|
790 |
else{
|
|
|
791 |
tItem.setHoldInventory(0);
|
|
|
792 |
}
|
|
|
793 |
if(item.getDefaultInventory()!=null){
|
|
|
794 |
tItem.setDefaultInventory(item.getDefaultInventory());
|
|
|
795 |
}
|
|
|
796 |
else{
|
|
|
797 |
tItem.setDefaultInventory(0);
|
|
|
798 |
}
|
|
|
799 |
tItem.setBestDealText(item.getBestDealsText());
|
|
|
800 |
tItem.setBestDealsDetailsText(item.getBestDealsDetailsText());
|
|
|
801 |
tItem.setBestDealsDetailsLink(item.getBestDealsDetailsLink());
|
|
|
802 |
if(item.getBestDealsValue() != null) {
|
|
|
803 |
tItem.setBestDealValue(item.getBestDealsValue());
|
|
|
804 |
}
|
| 2359 |
ankur.sing |
805 |
|
| 11671 |
vikram.rag |
806 |
if(item.getBestSellingRank() != null) {
|
|
|
807 |
tItem.setBestSellingRank(item.getBestSellingRank());
|
|
|
808 |
}
|
| 2359 |
ankur.sing |
809 |
|
| 11671 |
vikram.rag |
810 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
|
|
811 |
tItem.setRisky(item.isRisky());
|
|
|
812 |
tItem.setHasItemNo(item.isHasItemNo());
|
| 2359 |
ankur.sing |
813 |
|
| 11671 |
vikram.rag |
814 |
if(item.isItemType()) {
|
|
|
815 |
tItem.setType(ItemType.SERIALIZED);
|
|
|
816 |
}
|
|
|
817 |
else {
|
|
|
818 |
tItem.setType(ItemType.NON_SERIALIZED);
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
if(item.getStartDate() != null) {
|
|
|
822 |
tItem.setStartDate(item.getStartDate());
|
|
|
823 |
}
|
|
|
824 |
|
|
|
825 |
if(item.getExpectedArrivalDate() != null) {
|
|
|
826 |
tItem.setExpectedArrivalDate(item.getExpectedArrivalDate());
|
|
|
827 |
} else {
|
|
|
828 |
tItem.unsetComingSoonStartDate();
|
|
|
829 |
tItem.unsetExpectedArrivalDate();
|
|
|
830 |
if(status.COMING_SOON.equals(tItem.getItemStatus())){
|
|
|
831 |
tItem.setItemStatus(status.CONTENT_COMPLETE);
|
|
|
832 |
tItem.setStatus_description("Content generation completed");
|
|
|
833 |
}
|
|
|
834 |
}
|
|
|
835 |
|
|
|
836 |
if(item.getComingSoonStartDate() != null) {
|
|
|
837 |
tItem.setComingSoonStartDate(item.getComingSoonStartDate());
|
|
|
838 |
} else {
|
|
|
839 |
tItem.unsetComingSoonStartDate();
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
if(item.getRetireDate() != null) {
|
|
|
843 |
tItem.setRetireDate(item.getRetireDate());
|
|
|
844 |
}
|
|
|
845 |
|
|
|
846 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
| 18048 |
kshitij.so |
847 |
tItem.setPackQuantity(item.getPackQuantity());
|
| 18150 |
kshitij.so |
848 |
tItem.setQuantityStep(item.getQuantityStep());
|
|
|
849 |
tItem.setMinimumBuyQuantity(item.getMinimumBuyQuantity());
|
| 18415 |
kshitij.so |
850 |
tItem.setMaximumBuyQuantity(item.getMaximumBuyQuantity());
|
| 11671 |
vikram.rag |
851 |
}
|
|
|
852 |
|
|
|
853 |
@Override
|
|
|
854 |
public void pauseItem(long itemId) {
|
|
|
855 |
try {
|
|
|
856 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
857 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
858 |
|
|
|
859 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
|
|
860 |
} catch (Exception e) {
|
|
|
861 |
logger.error("Error while pausing the item: " + itemId, e);
|
|
|
862 |
}
|
|
|
863 |
|
|
|
864 |
}
|
|
|
865 |
|
|
|
866 |
@Override
|
|
|
867 |
public void markInProcess(long itemId) {
|
|
|
868 |
try {
|
|
|
869 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
870 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
871 |
|
|
|
872 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
|
|
873 |
} catch (Exception e) {
|
|
|
874 |
logger.error("Error while marking in-process the item: " + itemId, e);
|
|
|
875 |
}
|
|
|
876 |
}
|
|
|
877 |
|
|
|
878 |
@Override
|
|
|
879 |
public void phaseoutItem(long itemId) {
|
|
|
880 |
try {
|
|
|
881 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
882 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
883 |
|
|
|
884 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
|
|
885 |
} catch (Exception e) {
|
|
|
886 |
logger.error("Error while phasing out the item: " + itemId, e);
|
|
|
887 |
}
|
|
|
888 |
}
|
|
|
889 |
|
|
|
890 |
@Override
|
|
|
891 |
public void activateItem(long itemId) {
|
|
|
892 |
try {
|
|
|
893 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
894 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
895 |
|
|
|
896 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
|
|
897 |
} catch (Exception e) {
|
|
|
898 |
logger.error("Error while activating the item: " + itemId, e);
|
|
|
899 |
}
|
|
|
900 |
}
|
|
|
901 |
|
|
|
902 |
@Override
|
|
|
903 |
public boolean changeItemRiskyFlag(long itemId, boolean risky) {
|
|
|
904 |
try {
|
|
|
905 |
logger.info("Updating risky flag for item id: " + itemId + " to " + risky);
|
|
|
906 |
// Initialize client for staging server
|
|
|
907 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
908 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
909 |
|
|
|
910 |
// Initialize client for production server
|
|
|
911 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
912 |
ConfigClientKeys.catalog_service_server_port.toString());
|
|
|
913 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
|
|
914 |
catalogClient.changeItemRiskyFlag(itemId, risky);
|
|
|
915 |
|
|
|
916 |
try{
|
|
|
917 |
catalogClient_Prod.changeItemRiskyFlag(itemId, risky);
|
|
|
918 |
}catch(Exception e){
|
|
|
919 |
logger.error("Error while updating item's risky flag on production", e);
|
|
|
920 |
// If not able to change risky flag on production, revert on staging and return false (to show error to user).
|
|
|
921 |
catalogClient.changeItemRiskyFlag(itemId, !risky);
|
|
|
922 |
return false;
|
|
|
923 |
}
|
|
|
924 |
} catch (Exception e) {
|
|
|
925 |
logger.error("Error while updating item's risky flag on staging", e);
|
|
|
926 |
return false;
|
|
|
927 |
}
|
|
|
928 |
return true;
|
|
|
929 |
}
|
|
|
930 |
|
|
|
931 |
|
|
|
932 |
/**
|
|
|
933 |
* Retuns list of Items filtered by category (column is product_group in catalog.item table)
|
|
|
934 |
* This list is used to generate master sheet (excel sheet)
|
|
|
935 |
* @param category
|
|
|
936 |
* @param brand
|
|
|
937 |
* @return
|
|
|
938 |
*/
|
|
|
939 |
public List<Item> getItemsForMasterSheet(String category, String brand) {
|
|
|
940 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
941 |
try {
|
|
|
942 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
943 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
944 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
945 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
946 |
|
|
|
947 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsForMasterSheet(category, brand);
|
|
|
948 |
|
|
|
949 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 5946 |
rajveer |
950 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
| 22610 |
amit.gupta |
951 |
/*List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
|
|
952 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());*/
|
|
|
953 |
Item item = getItemFromThriftItem(thriftItem, vip, null, null, null, null, null, null, null, null);
|
| 19754 |
amit.gupta |
954 |
item.setDealPrice(thriftItem.getDealPrice());
|
|
|
955 |
itemList.add(item);
|
| 11671 |
vikram.rag |
956 |
}
|
|
|
957 |
} catch (Exception e) {
|
|
|
958 |
logger.error("Error while getting items by category: " + category, e);
|
|
|
959 |
}
|
|
|
960 |
Collections.sort(itemList, new ItemsComparator());
|
|
|
961 |
return itemList;
|
|
|
962 |
}
|
|
|
963 |
|
|
|
964 |
@Override
|
|
|
965 |
public String updateItemOnProduction(Item item) {
|
|
|
966 |
if(!canPushToProduction()) {
|
|
|
967 |
// If we can't push to production, then return that message to user
|
|
|
968 |
// else move forward with update.
|
|
|
969 |
return "Maximum push to production count reached for today";
|
|
|
970 |
}
|
|
|
971 |
List<Long> itemIds = item.getSameItemsWithDifferentColors();
|
|
|
972 |
List<Item> items = new ArrayList<Item>();
|
|
|
973 |
items.add(item);
|
|
|
974 |
for(Long itemId : itemIds) {
|
|
|
975 |
try {
|
|
|
976 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
977 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
978 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
979 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
980 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
| 11976 |
vikram.rag |
981 |
in.shop2020.model.v1.catalog.PrivateDeal tPrivateDeal = catalogClient.getPrivateDealDetails(itemId);
|
| 11671 |
vikram.rag |
982 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> vip = inventoryClient.getAllItemPricing(thriftItem.getId());
|
|
|
983 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> vim = inventoryClient.getVendorItemMappings(thriftItem.getId());
|
|
|
984 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> sip = catalogClient.getAllSourcePricing(thriftItem.getId());
|
| 11976 |
vikram.rag |
985 |
items.add(getItemFromThriftItem(thriftItem, vip, vim, sip, null, null, null, null, null, null,null,tPrivateDeal));
|
| 11671 |
vikram.rag |
986 |
} catch (Exception e) {
|
|
|
987 |
logger.error("Could not fetch item for : " + itemId, e);
|
|
|
988 |
return "Could not push to production. No item got pushed.";
|
|
|
989 |
}
|
|
|
990 |
}
|
| 18451 |
kshitij.so |
991 |
|
|
|
992 |
|
| 11671 |
vikram.rag |
993 |
for (Item it : items) {
|
|
|
994 |
logger.info("Update item on production call, Item Id: " + it.getId());
|
| 3354 |
chandransh |
995 |
|
| 11671 |
vikram.rag |
996 |
try{
|
|
|
997 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(
|
|
|
998 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
999 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| 3354 |
chandransh |
1000 |
|
| 11671 |
vikram.rag |
1001 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| 18607 |
kshitij.so |
1002 |
|
|
|
1003 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1004 |
Client catalogClient = catalogServiceClient.getClient();
|
| 3354 |
chandransh |
1005 |
|
| 11671 |
vikram.rag |
1006 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(it.getId());
|
| 3354 |
chandransh |
1007 |
|
| 11671 |
vikram.rag |
1008 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
1009 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 3354 |
chandransh |
1010 |
|
| 11671 |
vikram.rag |
1011 |
if(it.getMrp() != null) {
|
|
|
1012 |
tItem.setMrp(it.getMrp());
|
|
|
1013 |
}
|
| 3558 |
rajveer |
1014 |
|
| 11671 |
vikram.rag |
1015 |
if(it.getSellingPrice() != null) {
|
|
|
1016 |
tItem.setSellingPrice(it.getSellingPrice());
|
|
|
1017 |
}
|
| 18415 |
kshitij.so |
1018 |
|
| 18049 |
kshitij.so |
1019 |
tItem.setPackQuantity(it.getPackQuantity());
|
| 18415 |
kshitij.so |
1020 |
tItem.setQuantityStep(it.getQuantityStep());
|
|
|
1021 |
tItem.setMinimumBuyQuantity(it.getMinimumBuyQuantity());
|
|
|
1022 |
tItem.setMaximumBuyQuantity(it.getMaximumBuyQuantity());
|
| 4423 |
phani.kuma |
1023 |
|
| 11671 |
vikram.rag |
1024 |
tItem.setBestDealText(it.getBestDealsText());
|
|
|
1025 |
|
|
|
1026 |
if (it.getItemStatusValue() == ItemStatus.ACTIVE.getValue() || it.getItemStatusValue() == ItemStatus.PAUSED.getValue()) {
|
|
|
1027 |
tItem.setItemStatus(status.findByValue(it.getItemStatusValue()));
|
|
|
1028 |
tItem.setStartDate(it.getStartDate());
|
|
|
1029 |
}
|
|
|
1030 |
long rItemId;
|
|
|
1031 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != it.getId()) {
|
|
|
1032 |
logger.error("Error updating item on production, returned Item Id: " + rItemId);
|
|
|
1033 |
return "Error updating item prices on production";
|
|
|
1034 |
}
|
| 18451 |
kshitij.so |
1035 |
|
|
|
1036 |
|
| 18596 |
kshitij.so |
1037 |
List<in.shop2020.model.v1.catalog.BulkItemPricing> t_bulkItemsPricing = catalogClient.getBulkPricingByItemId(it.getId());
|
|
|
1038 |
if (!catalogClient_Prod.updateBulkPricesOnProduction(it.getId(), t_bulkItemsPricing)){
|
|
|
1039 |
return "Bulk prices updation error";
|
|
|
1040 |
}
|
| 18451 |
kshitij.so |
1041 |
|
| 11671 |
vikram.rag |
1042 |
if(it.getFreebieItemId() !=null && it.getFreebieItemId()!=0) {
|
|
|
1043 |
in.shop2020.model.v1.catalog.FreebieItem freebieItem = new in.shop2020.model.v1.catalog.FreebieItem();
|
|
|
1044 |
freebieItem.setItemId(it.getId());
|
|
|
1045 |
freebieItem.setFreebieItemId(it.getFreebieItemId());
|
|
|
1046 |
catalogClient_Prod.addOrUpdateFreebieForItem(freebieItem);
|
|
|
1047 |
}
|
|
|
1048 |
logger.info("Successfully updated item: " + it.getId());
|
|
|
1049 |
|
|
|
1050 |
StringBuilder sb = new StringBuilder();
|
|
|
1051 |
|
|
|
1052 |
Map<Long, VendorPricings> vendorPricings = it.getVendorPricesMap();
|
|
|
1053 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
|
|
1054 |
in.shop2020.model.v1.inventory.VendorItemPricing tVendorPricing;
|
|
|
1055 |
for(VendorPricings v : vendorPricings.values()) {
|
|
|
1056 |
tVendorPricing = new in.shop2020.model.v1.inventory.VendorItemPricing();
|
|
|
1057 |
tVendorPricing.setVendorId(v.getVendorId());
|
|
|
1058 |
tVendorPricing.setItemId(it.getId());
|
|
|
1059 |
tVendorPricing.setMop(v.getMop());
|
|
|
1060 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
|
|
1061 |
tVendorPricing.setNlc(v.getNlc());
|
|
|
1062 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
|
|
1063 |
inventoryClient.addVendorItemPricing(tVendorPricing);
|
|
|
1064 |
logger.info("VendorItemPricing updated. " + tVendorPricing.toString());
|
|
|
1065 |
sb.append("[VId:" + v.getVendorId() + ",MOP=" + v.getMop() + ",TP=" + v.getTransferPrice() + ",NLC= " +v.getNlc() + ",DP=" + v.getDealerPrice() + "], ");
|
|
|
1066 |
}
|
|
|
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
Map<String, VendorItemMapping> vendorMappings = it.getVendorKeysMap();
|
|
|
1070 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
|
|
1071 |
in.shop2020.model.v1.inventory.VendorItemMapping tVendorMapping;
|
|
|
1072 |
for(VendorItemMapping vendorItemMapping : vendorMappings.values()) {
|
|
|
1073 |
tVendorMapping = new in.shop2020.model.v1.inventory.VendorItemMapping();
|
|
|
1074 |
tVendorMapping.setVendorId(vendorItemMapping.getVendorId());
|
|
|
1075 |
tVendorMapping.setItemId(it.getId());
|
|
|
1076 |
tVendorMapping.setItemKey(vendorItemMapping.getItemKey());
|
|
|
1077 |
inventoryClient.addVendorItemMapping(vendorItemMapping.getItemKey(), tVendorMapping);
|
|
|
1078 |
logger.info("VendorItemMapping updated. " + tVendorMapping.toString());
|
|
|
1079 |
sb.append("[VId:" + vendorItemMapping.getVendorId() + ",ItemKey=" + vendorItemMapping.getItemKey() + "], ");
|
|
|
1080 |
}
|
|
|
1081 |
}
|
|
|
1082 |
|
|
|
1083 |
Map<Long, SourcePricings> sourcePricings = it.getSourcePricesMap();
|
|
|
1084 |
if(sourcePricings != null && !sourcePricings.isEmpty()){
|
|
|
1085 |
in.shop2020.model.v1.catalog.SourceItemPricing tSourcePricing;
|
|
|
1086 |
for(SourcePricings s : sourcePricings.values()){
|
|
|
1087 |
tSourcePricing = new in.shop2020.model.v1.catalog.SourceItemPricing();
|
|
|
1088 |
tSourcePricing.setSourceId(s.getSourceId());
|
|
|
1089 |
tSourcePricing.setItemId(it.getId());
|
|
|
1090 |
tSourcePricing.setMrp(s.getMrp());
|
|
|
1091 |
tSourcePricing.setSellingPrice(s.getSellingPrice());
|
|
|
1092 |
catalogClient_Prod.addSourceItemPricing(tSourcePricing);
|
|
|
1093 |
logger.info("SourceItemPricing updated. " + tSourcePricing.toString());
|
|
|
1094 |
sb.append("[SId:" + s.getSourceId() + ",MRP=" + s.getMrp() + ",SP=" + s.getSellingPrice() + "], ");
|
|
|
1095 |
}
|
|
|
1096 |
}
|
|
|
1097 |
pushToProdLogger.info("Id=" + it.getId() + ",MRP=" + it.getMrp() + ",SP=" + " " + it.getSellingPrice() + sb.toString());
|
| 11976 |
vikram.rag |
1098 |
in.shop2020.model.v1.catalog.PrivateDeal privateDeal = new in.shop2020.model.v1.catalog.PrivateDeal();
|
|
|
1099 |
privateDeal.setItem_id(item.getId());
|
|
|
1100 |
privateDeal.setDealFreebieItemId(item.getPrivateDeal().getDealFreebieItemId());
|
|
|
1101 |
privateDeal.setDealPrice(item.getPrivateDeal().getDealPrice());
|
|
|
1102 |
privateDeal.setDealText(item.getPrivateDeal().getDealText());
|
|
|
1103 |
privateDeal.setDealFreebieOption(item.getPrivateDeal().getDealFreebieOption());
|
|
|
1104 |
privateDeal.setDealTextOption(item.getPrivateDeal().getDealTextOption());
|
| 12331 |
amit.gupta |
1105 |
privateDeal.setEndDate(item.getPrivateDeal().getEndDate() == null ? 0 : item.getPrivateDeal().getEndDate());
|
| 12332 |
amit.gupta |
1106 |
privateDeal.setStartDate(item.getPrivateDeal().getStartDate() == null ? 0 : item.getPrivateDeal().getStartDate());
|
| 11976 |
vikram.rag |
1107 |
privateDeal.setIsCod(item.getPrivateDeal().isCod());
|
|
|
1108 |
privateDeal.setRank(item.getPrivateDeal().getRank());
|
|
|
1109 |
privateDeal.setIsActive(item.getPrivateDeal().isActive());
|
|
|
1110 |
if(privateDeal.getDealPrice() > 0 && privateDeal.getEndDate()!=0 && privateDeal.getStartDate()!=0){
|
|
|
1111 |
logger.info("Updating Private deal: " + item.getId());
|
|
|
1112 |
logger.info("Deal Price "+privateDeal.getDealPrice());
|
|
|
1113 |
logger.info("Deal Start Date "+privateDeal.getStartDate());
|
|
|
1114 |
logger.info("Deal End Date "+privateDeal.getEndDate());
|
|
|
1115 |
logger.info("Has COD on deal: " + privateDeal.isIsCod());
|
|
|
1116 |
logger.info("Response" + catalogClient_Prod.addOrUpdatePrivateDeal(privateDeal));
|
|
|
1117 |
logger.info("Updated Private deal: " + item.getId());
|
|
|
1118 |
}
|
|
|
1119 |
else{
|
|
|
1120 |
logger.info("Skipping Private deal: " + item.getId());
|
|
|
1121 |
logger.info("Deal Price "+privateDeal.getDealPrice());
|
|
|
1122 |
logger.info("Deal Start Date "+privateDeal.getStartDate());
|
|
|
1123 |
logger.info("Deal End Date "+privateDeal.getEndDate());
|
|
|
1124 |
}
|
| 18150 |
kshitij.so |
1125 |
|
| 11671 |
vikram.rag |
1126 |
} catch (Exception e) {
|
|
|
1127 |
logger.error("Error while updating prices on production", e);
|
|
|
1128 |
return "Error while updating all prices on production. Some of the prices may not have been updated";
|
|
|
1129 |
}
|
|
|
1130 |
}
|
|
|
1131 |
|
|
|
1132 |
try {
|
|
|
1133 |
ContentClient contentServiceClient = new ContentClient();
|
|
|
1134 |
ContentService.Client contentClient = contentServiceClient.getClient();
|
|
|
1135 |
|
|
|
1136 |
contentClient.pushContentToProduction(items.get(0).getCatalogItemId());
|
|
|
1137 |
} catch (TTransportException e) {
|
|
|
1138 |
logger.error("Error while establishing connection to the content server", e);
|
|
|
1139 |
return "Error generating content. Prices updated successfully.";
|
|
|
1140 |
} catch (TException e) {
|
|
|
1141 |
logger.error("Error while pushing content to production", e);
|
|
|
1142 |
return "Error generating content. Prices updated successfully.";
|
|
|
1143 |
} catch (ContentServiceException e) {
|
|
|
1144 |
logger.error("Error while pushing content to production", e);
|
|
|
1145 |
return "Error generating content. Prices updated successfully.";
|
|
|
1146 |
}
|
|
|
1147 |
|
|
|
1148 |
return "Prices updated and content generated successfully";
|
|
|
1149 |
}
|
|
|
1150 |
|
|
|
1151 |
/**
|
|
|
1152 |
* Returns list of items with a particular status.
|
|
|
1153 |
* @param st
|
|
|
1154 |
* @return
|
|
|
1155 |
*/
|
|
|
1156 |
private List<Item> getItemsByStatus(status st, int start, int limit) {
|
|
|
1157 |
List<Item> itemList = new ArrayList<Item>();
|
|
|
1158 |
try {
|
|
|
1159 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1160 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
1161 |
|
|
|
1162 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatusInRange(st, start, limit);
|
|
|
1163 |
|
|
|
1164 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
|
|
1165 |
itemList.add(getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null, null, null));
|
|
|
1166 |
}
|
|
|
1167 |
} catch (Exception e) {
|
|
|
1168 |
logger.error("Error while getting items by status: " + st, e);
|
|
|
1169 |
}
|
|
|
1170 |
return itemList;
|
|
|
1171 |
}
|
|
|
1172 |
|
|
|
1173 |
/**
|
|
|
1174 |
* Creates a new Item object and populates its attributes from thrift item passed as parameter.
|
|
|
1175 |
* Also creates a Map each for VendorItemPricing, VendorItemMapping, SourceItemPricing and SimilarItems and adds these maps to the
|
|
|
1176 |
* new Item object.
|
|
|
1177 |
* @param thriftItem
|
|
|
1178 |
* @param tVendorPricings
|
|
|
1179 |
* @param tVendorMappings
|
|
|
1180 |
* @param tSourceMappings
|
|
|
1181 |
* @param tSimilarItems
|
|
|
1182 |
* @param tVoucherMappings
|
|
|
1183 |
* @param stockPurchaseParams
|
|
|
1184 |
* @return item object with attributes copied from thrift item object.
|
|
|
1185 |
*/
|
|
|
1186 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
|
|
1187 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> tVendorPricings,
|
|
|
1188 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
|
|
|
1189 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
|
|
|
1190 |
List<in.shop2020.model.v1.catalog.Item> tSimilarItems,
|
|
|
1191 |
in.shop2020.model.v1.inventory.ItemInventory tItemInventory,
|
|
|
1192 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings,
|
|
|
1193 |
ItemStockPurchaseParams tStockPurchaseParams, Map<Long,String> saleHistory, Long freebieItemId){
|
|
|
1194 |
|
|
|
1195 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
|
|
1196 |
VendorItemMapping vItemMapping;
|
|
|
1197 |
if(tVendorMappings != null) {
|
|
|
1198 |
for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
|
|
|
1199 |
vItemMapping = new VendorItemMapping();
|
|
|
1200 |
vItemMapping.setVendorId(vim.getVendorId());
|
|
|
1201 |
vItemMapping.setItemKey(vim.getItemKey());
|
|
|
1202 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
|
|
1203 |
}
|
|
|
1204 |
}
|
|
|
1205 |
|
|
|
1206 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
|
|
1207 |
VendorPricings vPricings;
|
|
|
1208 |
if(tVendorPricings != null) {
|
|
|
1209 |
for(in.shop2020.model.v1.inventory.VendorItemPricing vip : tVendorPricings) {
|
|
|
1210 |
vPricings = new VendorPricings();
|
|
|
1211 |
vPricings.setVendorId(vip.getVendorId());
|
|
|
1212 |
vPricings.setMop(vip.getMop());
|
|
|
1213 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
|
|
1214 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
|
|
1215 |
vPricings.setNlc(vip.getNlc());
|
|
|
1216 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
|
|
1217 |
}
|
|
|
1218 |
}
|
|
|
1219 |
|
|
|
1220 |
Map<Long, SourcePricings> sourcePricingMap = new HashMap<Long, SourcePricings>();
|
|
|
1221 |
SourcePricings sPricings;
|
|
|
1222 |
if(tSourceMappings != null) {
|
|
|
1223 |
for(in.shop2020.model.v1.catalog.SourceItemPricing sip : tSourceMappings) {
|
|
|
1224 |
sPricings = new SourcePricings();
|
|
|
1225 |
sPricings.setSourceId(sip.getSourceId());
|
|
|
1226 |
sPricings.setMrp(sip.getMrp());
|
|
|
1227 |
sPricings.setSellingPrice(sip.getSellingPrice());
|
|
|
1228 |
sourcePricingMap.put(sPricings.getSourceId(), sPricings);
|
|
|
1229 |
}
|
|
|
1230 |
}
|
|
|
1231 |
|
|
|
1232 |
Map<Long, Item> SimilarItemslist = new HashMap<Long, Item>();
|
|
|
1233 |
Item sItems;
|
|
|
1234 |
if(tSimilarItems != null) {
|
|
|
1235 |
for(in.shop2020.model.v1.catalog.Item sit : tSimilarItems) {
|
|
|
1236 |
sItems = new Item();
|
|
|
1237 |
sItems.setCatalogItemId(sit.getCatalogItemId());
|
|
|
1238 |
sItems.setProductGroup(sit.getProductGroup());
|
|
|
1239 |
sItems.setBrand(sit.getBrand());
|
|
|
1240 |
sItems.setModelNumber(sit.getModelNumber());
|
|
|
1241 |
sItems.setModelName(sit.getModelName());
|
|
|
1242 |
sItems.setContentCategory(CategoryManager.getCategoryManager().getCategoryLabel(sit.getCategory()));
|
|
|
1243 |
SimilarItemslist.put(sit.getCatalogItemId(), sItems);
|
|
|
1244 |
}
|
|
|
1245 |
}
|
|
|
1246 |
|
|
|
1247 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1248 |
ItemInventory warehousedata;
|
|
|
1249 |
if(tItemInventory != null) {
|
|
|
1250 |
Map<Long, Long> availabilityMap = tItemInventory.getAvailability();
|
|
|
1251 |
Map<Long, Long> reservedMap = tItemInventory.getReserved();
|
|
|
1252 |
Map<Long, Long> heldMap = tItemInventory.getHeld();
|
|
|
1253 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
|
|
1254 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
|
|
1255 |
warehousedata = new ItemInventory();
|
|
|
1256 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1257 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1258 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
|
|
1259 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
|
|
1260 |
try {
|
|
|
1261 |
if(warehousedata.getHeld()>0) {
|
|
|
1262 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
1263 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(thriftItem.getId(), availability.getKey());
|
|
|
1264 |
}
|
|
|
1265 |
if(heldInventoryMap.size()>0) {
|
|
|
1266 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1267 |
switch(source) {
|
| 13748 |
manish.sha |
1268 |
case HOMESHOP18SOURCE: warehousedata.setHomeshop18Held(heldInventoryMap.get(source));
|
|
|
1269 |
break;
|
| 11671 |
vikram.rag |
1270 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
|
|
1271 |
break;
|
|
|
1272 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
|
|
1273 |
break;
|
|
|
1274 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1275 |
}
|
|
|
1276 |
}
|
|
|
1277 |
}
|
|
|
1278 |
} catch (Exception e) {
|
|
|
1279 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + thriftItem.getId() +
|
|
|
1280 |
" and warehouse " +availability.getKey());
|
|
|
1281 |
}
|
|
|
1282 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1283 |
}
|
|
|
1284 |
}
|
|
|
1285 |
else {
|
|
|
1286 |
itemInventoryMap = null;
|
|
|
1287 |
}
|
|
|
1288 |
|
|
|
1289 |
Map<String, VoucherItemMapping> voucherMap = new HashMap<String, VoucherItemMapping>();
|
|
|
1290 |
VoucherItemMapping voucher;
|
|
|
1291 |
if(tVoucherMappings != null) {
|
|
|
1292 |
for(in.shop2020.model.v1.catalog.VoucherItemMapping tvoucher : tVoucherMappings) {
|
|
|
1293 |
voucher = new VoucherItemMapping(tvoucher.getAmount(), VoucherType.findByValue((int) tvoucher.getVoucherType()).name());
|
|
|
1294 |
voucherMap.put(VoucherType.findByValue((int) tvoucher.getVoucherType()).name(), voucher);
|
|
|
1295 |
}
|
|
|
1296 |
}
|
|
|
1297 |
|
|
|
1298 |
in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams stockPurchaseParams =
|
|
|
1299 |
new in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams();
|
|
|
1300 |
if(tStockPurchaseParams != null) {
|
|
|
1301 |
stockPurchaseParams.setItem_id(tStockPurchaseParams.getItem_id());
|
|
|
1302 |
stockPurchaseParams.setMinStockLevel(tStockPurchaseParams.getMinStockLevel());
|
|
|
1303 |
stockPurchaseParams.setNumOfDaysStock(tStockPurchaseParams.getNumOfDaysStock());
|
|
|
1304 |
}
|
|
|
1305 |
|
|
|
1306 |
Item item = new Item(thriftItem.getId(),
|
|
|
1307 |
thriftItem.getProductGroup(),
|
|
|
1308 |
thriftItem.getBrand(),
|
|
|
1309 |
thriftItem.getModelNumber(),
|
|
|
1310 |
thriftItem.getModelName(),
|
|
|
1311 |
thriftItem.getColor(),
|
|
|
1312 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
|
|
1313 |
thriftItem.getCategory(),
|
|
|
1314 |
thriftItem.getComments(),
|
|
|
1315 |
thriftItem.getCatalogItemId(),
|
|
|
1316 |
thriftItem.getFeatureId(),
|
|
|
1317 |
thriftItem.getFeatureDescription(),
|
|
|
1318 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
|
|
1319 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
|
|
1320 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
|
|
1321 |
thriftItem.getAddedOn(),
|
|
|
1322 |
thriftItem.getStartDate(),
|
|
|
1323 |
thriftItem.isSetComingSoonStartDate() ? thriftItem.getComingSoonStartDate() : null ,
|
|
|
1324 |
thriftItem.isSetExpectedArrivalDate() ? thriftItem.getExpectedArrivalDate() : null ,
|
|
|
1325 |
thriftItem.getRetireDate(),
|
|
|
1326 |
thriftItem.getUpdatedOn(),
|
|
|
1327 |
thriftItem.getItemStatus().name(),
|
|
|
1328 |
thriftItem.getItemStatus().getValue(),
|
|
|
1329 |
thriftItem.getStatus_description(),
|
|
|
1330 |
thriftItem.getBestDealText(),
|
|
|
1331 |
thriftItem.getBestDealsDetailsText(),
|
|
|
1332 |
thriftItem.getBestDealsDetailsLink(),
|
|
|
1333 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
|
|
1334 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
|
|
1335 |
thriftItem.isDefaultForEntity(),
|
|
|
1336 |
thriftItem.isRisky(),
|
|
|
1337 |
thriftItem.isSetExpectedDelay() ? thriftItem.getExpectedDelay() : null,
|
|
|
1338 |
thriftItem.isIsWarehousePreferenceSticky(),
|
|
|
1339 |
thriftItem.isHasItemNo(),
|
|
|
1340 |
ItemType.SERIALIZED.equals(thriftItem.getType()),
|
|
|
1341 |
thriftItem.isSetShowSellingPrice() ? thriftItem.isShowSellingPrice() : false,
|
|
|
1342 |
thriftItem.isHoldOverride(),
|
|
|
1343 |
thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
|
|
|
1344 |
thriftItem.isSetPreferredInsurer() ? thriftItem.getPreferredInsurer() : null,
|
|
|
1345 |
itemInventoryMap,
|
|
|
1346 |
vendorPricingMap,
|
|
|
1347 |
vItemMap,
|
|
|
1348 |
sourcePricingMap,
|
|
|
1349 |
SimilarItemslist,
|
|
|
1350 |
voucherMap,
|
|
|
1351 |
stockPurchaseParams.getNumOfDaysStock(),
|
|
|
1352 |
stockPurchaseParams.getMinStockLevel(),
|
|
|
1353 |
saleHistory,
|
|
|
1354 |
freebieItemId,
|
|
|
1355 |
thriftItem.getAsin(),
|
|
|
1356 |
thriftItem.getHoldInventory(),
|
|
|
1357 |
thriftItem.getDefaultInventory());
|
|
|
1358 |
return item;
|
|
|
1359 |
}
|
|
|
1360 |
|
|
|
1361 |
/**
|
|
|
1362 |
*
|
|
|
1363 |
* @return True if push to production count is less than maximum allowed.
|
|
|
1364 |
*/
|
|
|
1365 |
private boolean canPushToProduction() {
|
|
|
1366 |
int count = getPushToProdCount(logFile);
|
|
|
1367 |
return count < maxCount;
|
|
|
1368 |
}
|
|
|
1369 |
|
|
|
1370 |
/**
|
|
|
1371 |
* If this is the first attempt to push to production for current date, returns 0
|
|
|
1372 |
* else reads number of lines from daily rolling log file to get the count.
|
|
|
1373 |
* @return push to production count for current date
|
|
|
1374 |
*/
|
|
|
1375 |
private int getPushToProdCount(String logfile) {
|
|
|
1376 |
// logfile is "/var/log/services/pushToProductionCount/pushToProd.log"
|
|
|
1377 |
// this should also be set in log4j.properties
|
|
|
1378 |
int lineCount = 0;
|
|
|
1379 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
1380 |
Date currentDate = Calendar.getInstance().getTime();
|
|
|
1381 |
if(pushToProdDate == null || !dateFormat.format(pushToProdDate).equals(dateFormat.format(currentDate))) {
|
|
|
1382 |
pushToProdDate = currentDate;
|
|
|
1383 |
return lineCount;
|
|
|
1384 |
}
|
|
|
1385 |
try {
|
|
|
1386 |
BufferedReader br = new BufferedReader(new FileReader(logfile));
|
|
|
1387 |
while (br.readLine() != null) {
|
|
|
1388 |
lineCount++;
|
|
|
1389 |
}
|
|
|
1390 |
} catch (IOException e) {
|
|
|
1391 |
logger.error("Error while reading the log file", e);
|
|
|
1392 |
}
|
|
|
1393 |
return lineCount;
|
|
|
1394 |
}
|
|
|
1395 |
|
| 4423 |
phani.kuma |
1396 |
@Override
|
|
|
1397 |
public boolean deleteSimilarItem(long itemId, long catalogItemId) {
|
|
|
1398 |
try{
|
| 11671 |
vikram.rag |
1399 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1400 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4423 |
phani.kuma |
1401 |
|
| 11671 |
vikram.rag |
1402 |
return catalogClient.deleteSimilarItem(itemId, catalogItemId);
|
| 4423 |
phani.kuma |
1403 |
|
| 11671 |
vikram.rag |
1404 |
}catch(Exception e){
|
|
|
1405 |
logger.error("Error while deleting the SimilarItems for: " + itemId, e);
|
|
|
1406 |
}
|
|
|
1407 |
return false;
|
| 4423 |
phani.kuma |
1408 |
}
|
|
|
1409 |
|
|
|
1410 |
@Override
|
|
|
1411 |
public Item addSimilarItem(long itemId, long catalogItemId) {
|
|
|
1412 |
try{
|
| 11671 |
vikram.rag |
1413 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1414 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
1415 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.addSimilarItem(itemId, catalogItemId);;
|
| 4423 |
phani.kuma |
1416 |
|
| 11671 |
vikram.rag |
1417 |
return getItemFromThriftItem(thriftItem, null, null, null, null, null, null, null, null, null,null,null);
|
|
|
1418 |
}catch(Exception e){
|
|
|
1419 |
logger.error("Error while adding the SimilarItems for: " + itemId, e);
|
|
|
1420 |
}
|
|
|
1421 |
return null;
|
| 4423 |
phani.kuma |
1422 |
}
|
| 4431 |
phani.kuma |
1423 |
|
|
|
1424 |
@Override
|
|
|
1425 |
public Map<Long, ItemInventory> getProdItemInventory(long itemId) {
|
|
|
1426 |
try {
|
| 11671 |
vikram.rag |
1427 |
// Initialize client for production server
|
|
|
1428 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
1429 |
ConfigClientKeys.catalog_service_server_port.toString());
|
|
|
1430 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
|
|
1431 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
1432 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
1433 |
in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(itemId);
|
|
|
1434 |
|
|
|
1435 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1436 |
ItemInventory warehousedata;
|
|
|
1437 |
if(thriftItemInventory != null) {
|
|
|
1438 |
Map<Long, Long> availabilityMap = thriftItemInventory.getAvailability();
|
|
|
1439 |
Map<Long, Long> reservedMap = thriftItemInventory.getReserved();
|
|
|
1440 |
Map<Long, Long> heldMap = thriftItemInventory.getHeld();
|
|
|
1441 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
|
|
1442 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
|
|
1443 |
warehousedata = new ItemInventory();
|
|
|
1444 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1445 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1446 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
|
|
1447 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
|
|
1448 |
try {
|
|
|
1449 |
if(warehousedata.getHeld()>0) {
|
|
|
1450 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(itemId, availability.getKey());
|
|
|
1451 |
}
|
|
|
1452 |
if(heldInventoryMap.size()>0) {
|
|
|
1453 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1454 |
switch(source) {
|
| 13748 |
manish.sha |
1455 |
case HOMESHOP18SOURCE: warehousedata.setHomeshop18Held(heldInventoryMap.get(source));
|
|
|
1456 |
break;
|
| 11671 |
vikram.rag |
1457 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
|
|
1458 |
break;
|
|
|
1459 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
|
|
1460 |
break;
|
|
|
1461 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1462 |
}
|
|
|
1463 |
}
|
|
|
1464 |
}
|
|
|
1465 |
}catch (Exception e) {
|
|
|
1466 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + itemId +
|
|
|
1467 |
" and warehouse " +availability.getKey());
|
|
|
1468 |
}
|
|
|
1469 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1470 |
}
|
|
|
1471 |
}
|
|
|
1472 |
else {
|
|
|
1473 |
itemInventoryMap = null;
|
|
|
1474 |
}
|
|
|
1475 |
return itemInventoryMap;
|
|
|
1476 |
} catch (Exception e) {
|
|
|
1477 |
logger.error("Error while updating item's risky flag on staging", e);
|
|
|
1478 |
}
|
| 4431 |
phani.kuma |
1479 |
return null;
|
|
|
1480 |
}
|
| 4649 |
phani.kuma |
1481 |
|
|
|
1482 |
@Override
|
|
|
1483 |
public boolean addAuthorizationLog(long itemId, String username, String message) {
|
|
|
1484 |
try{
|
| 11671 |
vikram.rag |
1485 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1486 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4649 |
phani.kuma |
1487 |
|
| 11671 |
vikram.rag |
1488 |
return catalogClient.addAuthorizationLog(itemId, username, message);
|
| 4649 |
phani.kuma |
1489 |
|
| 11671 |
vikram.rag |
1490 |
}catch(Exception e){
|
|
|
1491 |
logger.error("Error while adding the event for: " + itemId, e);
|
|
|
1492 |
}
|
| 4649 |
phani.kuma |
1493 |
return false;
|
|
|
1494 |
}
|
|
|
1495 |
|
|
|
1496 |
@Override
|
|
|
1497 |
public Map<String, String> getConfigdataforPriceCompare() {
|
|
|
1498 |
Map<String, String> ConfigMap = new HashMap<String, String>();
|
|
|
1499 |
try {
|
|
|
1500 |
ConfigMap.put("courier_cost_factor", ConfigClient.getClient().get(ConfigClientKeys.courier_cost_factor.toString()));
|
| 11671 |
vikram.rag |
1501 |
ConfigMap.put("courier_weight_factor", ConfigClient.getClient().get(ConfigClientKeys.courier_weight_factor.toString()));
|
|
|
1502 |
ConfigMap.put("breakeven_divisor", ConfigClient.getClient().get(ConfigClientKeys.breakeven_divisor.toString()));
|
|
|
1503 |
ConfigMap.put("breakeven_additon_factor", ConfigClient.getClient().get(ConfigClientKeys.breakeven_additon_factor.toString()));
|
|
|
1504 |
ConfigMap.put("transfer_price_percentage", ConfigClient.getClient().get(ConfigClientKeys.transfer_price_percentage.toString()));
|
|
|
1505 |
ConfigMap.put("transfer_price_factor", ConfigClient.getClient().get(ConfigClientKeys.transfer_price_factor.toString()));
|
|
|
1506 |
} catch(ConfigException ce) {
|
|
|
1507 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
1508 |
ConfigMap.put("courier_cost_factor", "60");
|
|
|
1509 |
ConfigMap.put("courier_weight_factor", "500");
|
|
|
1510 |
ConfigMap.put("breakeven_divisor", "0.98");
|
|
|
1511 |
ConfigMap.put("breakeven_additon_factor", "50");
|
|
|
1512 |
ConfigMap.put("transfer_price_percentage", "2");
|
|
|
1513 |
ConfigMap.put("transfer_price_factor", "50");
|
|
|
1514 |
}
|
| 4649 |
phani.kuma |
1515 |
return ConfigMap;
|
|
|
1516 |
}
|
| 4957 |
phani.kuma |
1517 |
|
|
|
1518 |
@Override
|
|
|
1519 |
public List<String> getAllCategories() {
|
|
|
1520 |
List<String> categoryList = new ArrayList<String>();
|
|
|
1521 |
List<Long> parentCategoryIDs = Arrays.asList(new Long[] {(long) 0,(long) 10001,(long) 10009,(long) 10049});
|
| 11671 |
vikram.rag |
1522 |
try {
|
|
|
1523 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1524 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4957 |
phani.kuma |
1525 |
|
| 11671 |
vikram.rag |
1526 |
List<in.shop2020.model.v1.catalog.Category> categories = catalogClient.getAllCategories();
|
| 4957 |
phani.kuma |
1527 |
|
| 11671 |
vikram.rag |
1528 |
for(in.shop2020.model.v1.catalog.Category category : categories) {
|
|
|
1529 |
if(!parentCategoryIDs.contains(category.getParent_category_id())){
|
|
|
1530 |
categoryList.add(category.getDisplay_name());
|
|
|
1531 |
}
|
|
|
1532 |
else{
|
|
|
1533 |
continue;
|
|
|
1534 |
}
|
|
|
1535 |
}
|
|
|
1536 |
} catch (Exception e) {
|
|
|
1537 |
logger.error("Error while getting all the categories: ", e);
|
|
|
1538 |
}
|
|
|
1539 |
return categoryList;
|
| 4957 |
phani.kuma |
1540 |
}
|
| 18150 |
kshitij.so |
1541 |
|
| 12523 |
amit.gupta |
1542 |
@Override
|
|
|
1543 |
public Map<Long, String> getAllCategoriesMap() {
|
|
|
1544 |
Map<Long, String> categoryList = new TreeMap<Long, String>();
|
|
|
1545 |
try {
|
|
|
1546 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1547 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4957 |
phani.kuma |
1548 |
|
| 12523 |
amit.gupta |
1549 |
List<in.shop2020.model.v1.catalog.Category> categories = catalogClient.getAllCategories();
|
|
|
1550 |
|
|
|
1551 |
for(in.shop2020.model.v1.catalog.Category category : categories) {
|
|
|
1552 |
if(category.getParent_category_id() != 10000l && category.getParent_category_id() != 0l){
|
|
|
1553 |
categoryList.put(category.getId(), category.getLabel());
|
|
|
1554 |
}
|
|
|
1555 |
else{
|
|
|
1556 |
continue;
|
|
|
1557 |
}
|
|
|
1558 |
}
|
|
|
1559 |
} catch (Exception e) {
|
|
|
1560 |
logger.error("Error while getting all the categories: ", e);
|
|
|
1561 |
}
|
|
|
1562 |
return categoryList;
|
|
|
1563 |
}
|
|
|
1564 |
|
|
|
1565 |
|
| 4957 |
phani.kuma |
1566 |
@Override
|
|
|
1567 |
public List<String> getAllBrands() {
|
|
|
1568 |
List<String> brandsList = new ArrayList<String>();
|
| 11671 |
vikram.rag |
1569 |
try {
|
|
|
1570 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1571 |
Client catalogClient = catalogServiceClient.getClient();
|
| 4957 |
phani.kuma |
1572 |
|
| 11671 |
vikram.rag |
1573 |
brandsList = catalogClient.getAllBrands();
|
|
|
1574 |
} catch (Exception e) {
|
|
|
1575 |
logger.error("Error while getting all the categories: ", e);
|
|
|
1576 |
}
|
|
|
1577 |
return brandsList;
|
| 4957 |
phani.kuma |
1578 |
}
|
| 5427 |
amit.gupta |
1579 |
|
| 5504 |
phani.kuma |
1580 |
@Override
|
| 5516 |
phani.kuma |
1581 |
public boolean deleteVoucher(Long catalogItemId, Long voucherType) {
|
| 5504 |
phani.kuma |
1582 |
try{
|
| 11671 |
vikram.rag |
1583 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1584 |
Client catalogClient = catalogServiceClient.getClient();
|
| 5504 |
phani.kuma |
1585 |
|
| 11671 |
vikram.rag |
1586 |
return catalogClient.deleteVoucherForItem(catalogItemId, voucherType);
|
| 5504 |
phani.kuma |
1587 |
|
| 11671 |
vikram.rag |
1588 |
}catch(Exception e){
|
|
|
1589 |
logger.error("Error while deleting the Voucher for: " + catalogItemId, e);
|
|
|
1590 |
}
|
|
|
1591 |
return false;
|
| 5504 |
phani.kuma |
1592 |
}
|
|
|
1593 |
|
|
|
1594 |
@Override
|
| 5516 |
phani.kuma |
1595 |
public boolean addVoucher(Long catalogItemId, Long voucherType, long voucherAmount) {
|
| 5504 |
phani.kuma |
1596 |
try{
|
| 11671 |
vikram.rag |
1597 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1598 |
Client catalogClient = catalogServiceClient.getClient();
|
| 5504 |
phani.kuma |
1599 |
|
| 11671 |
vikram.rag |
1600 |
return catalogClient.addupdateVoucherForItem(catalogItemId, voucherType, voucherAmount);
|
| 5504 |
phani.kuma |
1601 |
|
| 11671 |
vikram.rag |
1602 |
}catch(Exception e){
|
|
|
1603 |
logger.error("Error while adding the Voucher for: " + catalogItemId, e);
|
|
|
1604 |
}
|
| 5504 |
phani.kuma |
1605 |
return false;
|
|
|
1606 |
}
|
|
|
1607 |
@Override
|
| 5516 |
phani.kuma |
1608 |
public Map<Long, String> getvoucherTypes() {
|
|
|
1609 |
Map<Long, String> voucherType = new HashMap<Long, String>();
|
| 5504 |
phani.kuma |
1610 |
for(VoucherType voucher : VoucherType.values())
|
|
|
1611 |
{
|
| 5516 |
phani.kuma |
1612 |
voucherType.put((long) voucher.getValue(), voucher.name());
|
| 5504 |
phani.kuma |
1613 |
}
|
|
|
1614 |
return voucherType;
|
|
|
1615 |
}
|
|
|
1616 |
|
| 5586 |
phani.kuma |
1617 |
@Override
|
|
|
1618 |
public boolean getConfigforentityIdMandatory() {
|
|
|
1619 |
try {
|
|
|
1620 |
String entityId_mandatory = ConfigClient.getClient().get(ConfigClientKeys.entityId_mandatory.toString());
|
|
|
1621 |
if (entityId_mandatory.equals("TRUE")) {
|
|
|
1622 |
return true;
|
|
|
1623 |
}
|
| 11671 |
vikram.rag |
1624 |
} catch(ConfigException ce) {
|
|
|
1625 |
logger.error("Unable to connect to the config server. Setting sensible defaults.", ce);
|
|
|
1626 |
}
|
| 5586 |
phani.kuma |
1627 |
return false;
|
|
|
1628 |
}
|
|
|
1629 |
|
|
|
1630 |
@Override
|
|
|
1631 |
public boolean checkEntityId(long entityId) {
|
|
|
1632 |
try {
|
| 11671 |
vikram.rag |
1633 |
CatalogClient catalogServiceClient = new CatalogClient(ConfigClientKeys.catalog_service_server_host_master.toString(), ConfigClientKeys.catalog_service_server_port.toString());
|
|
|
1634 |
Client catalogClient = catalogServiceClient.getClient();
|
|
|
1635 |
return catalogClient.isValidCatalogItemId(entityId);
|
|
|
1636 |
} catch (Exception e) {
|
|
|
1637 |
logger.error("Error while checking for a Catalog Item Id: ", e);
|
|
|
1638 |
}
|
| 5586 |
phani.kuma |
1639 |
return false;
|
|
|
1640 |
}
|
|
|
1641 |
|
| 6096 |
amit.gupta |
1642 |
@Override
|
|
|
1643 |
public String updateExpectedDelayOnProd(Item item) {
|
|
|
1644 |
try{
|
| 11671 |
vikram.rag |
1645 |
CatalogClient catalogServiceClient_Prod = new CatalogClient(
|
|
|
1646 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
|
|
1647 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| 6096 |
amit.gupta |
1648 |
|
| 11671 |
vikram.rag |
1649 |
Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| 6096 |
amit.gupta |
1650 |
|
| 11671 |
vikram.rag |
1651 |
|
|
|
1652 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
|
|
|
1653 |
if(item.getExpectedDelay() != null) {
|
|
|
1654 |
tItem.setExpectedDelay(item.getExpectedDelay());
|
|
|
1655 |
if(item.isItemType()) {
|
|
|
1656 |
tItem.setType(ItemType.SERIALIZED);
|
|
|
1657 |
}
|
|
|
1658 |
else {
|
|
|
1659 |
tItem.setType(ItemType.NON_SERIALIZED);
|
|
|
1660 |
}
|
|
|
1661 |
long rItemId;
|
|
|
1662 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != item.getId()) {
|
|
|
1663 |
logger.error("Error updating item on production, returned Item Id: " + rItemId);
|
|
|
1664 |
return "Error updating expected delay on production";
|
|
|
1665 |
}
|
|
|
1666 |
InventoryClient inventoryServiceClient= new InventoryClient();
|
|
|
1667 |
InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
1668 |
inventoryClient.clearItemAvailabilityCacheForItem(rItemId);
|
|
|
1669 |
logger.info("Successfully updated item: " + item.getId());
|
|
|
1670 |
return "Expected delay successfully updated on prod";
|
|
|
1671 |
} else {
|
|
|
1672 |
return "Error:expected delay should not be null";
|
|
|
1673 |
}
|
|
|
1674 |
} catch (Exception e) {
|
|
|
1675 |
logger.error("Error while updating expected delay on production", e);
|
|
|
1676 |
return "Error while updating expected delay on production";
|
|
|
1677 |
}
|
| 6096 |
amit.gupta |
1678 |
}
|
|
|
1679 |
|
| 6838 |
vikram.rag |
1680 |
@Override
|
|
|
1681 |
public Map<Long, String> getAllInsurers() {
|
| 11671 |
vikram.rag |
1682 |
Map<Long, String> insurersMap = new HashMap<Long, String>();
|
|
|
1683 |
try {
|
|
|
1684 |
CatalogClient catalogServiceClient = new CatalogClient();
|
|
|
1685 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
| 6096 |
amit.gupta |
1686 |
|
| 11671 |
vikram.rag |
1687 |
List<Insurer> insurers = catalogClient.getAllInsurers();
|
|
|
1688 |
|
|
|
1689 |
for(in.shop2020.model.v1.catalog.Insurer i : insurers) {
|
|
|
1690 |
insurersMap.put(i.getId(), i.getName());
|
|
|
1691 |
}
|
|
|
1692 |
} catch (Exception e) {
|
|
|
1693 |
logger.error("Error while getting all the vendors: ", e);
|
|
|
1694 |
}
|
|
|
1695 |
return insurersMap;
|
| 6838 |
vikram.rag |
1696 |
}
|
| 11671 |
vikram.rag |
1697 |
|
| 10484 |
vikram.rag |
1698 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
| 11671 |
vikram.rag |
1699 |
List<in.shop2020.model.v1.inventory.VendorItemPricing> tVendorPricings,
|
|
|
1700 |
List<in.shop2020.model.v1.inventory.VendorItemMapping> tVendorMappings,
|
|
|
1701 |
List<in.shop2020.model.v1.catalog.SourceItemPricing> tSourceMappings,
|
|
|
1702 |
List<in.shop2020.model.v1.catalog.Item> tSimilarItems,
|
|
|
1703 |
in.shop2020.model.v1.inventory.ItemInventory tItemInventory,
|
|
|
1704 |
List<in.shop2020.model.v1.catalog.VoucherItemMapping> tVoucherMappings,
|
|
|
1705 |
ItemStockPurchaseParams tStockPurchaseParams, Map<Long,String> saleHistory, Long freebieItemId,Map<String,String> stateNameVatPercentageMap,in.shop2020.model.v1.catalog.PrivateDeal tPrivateDeal){
|
| 6838 |
vikram.rag |
1706 |
|
| 11671 |
vikram.rag |
1707 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
|
|
1708 |
VendorItemMapping vItemMapping;
|
|
|
1709 |
if(tVendorMappings != null) {
|
|
|
1710 |
for(in.shop2020.model.v1.inventory.VendorItemMapping vim : tVendorMappings) {
|
|
|
1711 |
vItemMapping = new VendorItemMapping();
|
|
|
1712 |
vItemMapping.setVendorId(vim.getVendorId());
|
|
|
1713 |
vItemMapping.setItemKey(vim.getItemKey());
|
|
|
1714 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
|
|
1715 |
}
|
|
|
1716 |
}
|
| 6838 |
vikram.rag |
1717 |
|
| 11671 |
vikram.rag |
1718 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
|
|
1719 |
VendorPricings vPricings;
|
|
|
1720 |
if(tVendorPricings != null) {
|
|
|
1721 |
for(in.shop2020.model.v1.inventory.VendorItemPricing vip : tVendorPricings) {
|
|
|
1722 |
vPricings = new VendorPricings();
|
|
|
1723 |
vPricings.setVendorId(vip.getVendorId());
|
|
|
1724 |
vPricings.setMop(vip.getMop());
|
|
|
1725 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
|
|
1726 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
|
|
1727 |
vPricings.setNlc(vip.getNlc());
|
|
|
1728 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
|
|
1729 |
}
|
|
|
1730 |
}
|
| 6096 |
amit.gupta |
1731 |
|
| 11671 |
vikram.rag |
1732 |
Map<Long, SourcePricings> sourcePricingMap = new HashMap<Long, SourcePricings>();
|
|
|
1733 |
SourcePricings sPricings;
|
|
|
1734 |
if(tSourceMappings != null) {
|
|
|
1735 |
for(in.shop2020.model.v1.catalog.SourceItemPricing sip : tSourceMappings) {
|
|
|
1736 |
sPricings = new SourcePricings();
|
|
|
1737 |
sPricings.setSourceId(sip.getSourceId());
|
|
|
1738 |
sPricings.setMrp(sip.getMrp());
|
|
|
1739 |
sPricings.setSellingPrice(sip.getSellingPrice());
|
|
|
1740 |
sourcePricingMap.put(sPricings.getSourceId(), sPricings);
|
|
|
1741 |
}
|
|
|
1742 |
}
|
| 10484 |
vikram.rag |
1743 |
|
| 11671 |
vikram.rag |
1744 |
Map<Long, Item> SimilarItemslist = new HashMap<Long, Item>();
|
|
|
1745 |
Item sItems;
|
|
|
1746 |
if(tSimilarItems != null) {
|
|
|
1747 |
for(in.shop2020.model.v1.catalog.Item sit : tSimilarItems) {
|
|
|
1748 |
sItems = new Item();
|
|
|
1749 |
sItems.setCatalogItemId(sit.getCatalogItemId());
|
|
|
1750 |
sItems.setProductGroup(sit.getProductGroup());
|
|
|
1751 |
sItems.setBrand(sit.getBrand());
|
|
|
1752 |
sItems.setModelNumber(sit.getModelNumber());
|
|
|
1753 |
sItems.setModelName(sit.getModelName());
|
|
|
1754 |
sItems.setContentCategory(CategoryManager.getCategoryManager().getCategoryLabel(sit.getCategory()));
|
|
|
1755 |
SimilarItemslist.put(sit.getCatalogItemId(), sItems);
|
|
|
1756 |
}
|
|
|
1757 |
}
|
|
|
1758 |
|
|
|
1759 |
Map<Long, ItemInventory> itemInventoryMap = new HashMap<Long, ItemInventory>();
|
|
|
1760 |
ItemInventory warehousedata;
|
|
|
1761 |
if(tItemInventory != null) {
|
|
|
1762 |
Map<Long, Long> availabilityMap = tItemInventory.getAvailability();
|
|
|
1763 |
Map<Long, Long> reservedMap = tItemInventory.getReserved();
|
|
|
1764 |
Map<Long, Long> heldMap = tItemInventory.getHeld();
|
|
|
1765 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()) {
|
|
|
1766 |
Map<Integer, Long> heldInventoryMap = new HashMap<Integer, Long>();
|
|
|
1767 |
warehousedata = new ItemInventory();
|
|
|
1768 |
warehousedata.setWarehouseId(availability.getKey());
|
|
|
1769 |
warehousedata.setAvailability(availability.getValue());
|
|
|
1770 |
warehousedata.setReserved(reservedMap.get(availability.getKey()));
|
|
|
1771 |
warehousedata.setHeld(heldMap.get(availability.getKey()));
|
|
|
1772 |
try {
|
|
|
1773 |
if(warehousedata.getHeld()>0) {
|
|
|
1774 |
InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
1775 |
heldInventoryMap = inventoryClient.getHeldInventoryMapForItem(thriftItem.getId(), availability.getKey());
|
|
|
1776 |
}
|
|
|
1777 |
if(heldInventoryMap.size()>0) {
|
|
|
1778 |
for(Integer source : heldInventoryMap.keySet()) {
|
|
|
1779 |
switch(source) {
|
| 13749 |
manish.sha |
1780 |
case HOMESHOP18SOURCE: warehousedata.setHomeshop18Held(heldInventoryMap.get(source));
|
| 13748 |
manish.sha |
1781 |
break;
|
| 11671 |
vikram.rag |
1782 |
case EBAYSOURCE: warehousedata.setEbayHeld(heldInventoryMap.get(source));
|
|
|
1783 |
break;
|
|
|
1784 |
case SNAPDEALSOURCE: warehousedata.setSnapdealHeld(heldInventoryMap.get(source));
|
|
|
1785 |
break;
|
|
|
1786 |
case FLIPKARTSOURCE: warehousedata.setFlipkartHeld(heldInventoryMap.get(source));
|
|
|
1787 |
}
|
|
|
1788 |
}
|
|
|
1789 |
}
|
|
|
1790 |
} catch (Exception e) {
|
|
|
1791 |
logger.error("Error in getting data from holdInventoryDetail for itemId " + thriftItem.getId() +
|
|
|
1792 |
" and warehouse " +availability.getKey());
|
|
|
1793 |
}
|
|
|
1794 |
itemInventoryMap.put(warehousedata.getWarehouseId(), warehousedata);
|
|
|
1795 |
}
|
|
|
1796 |
}
|
|
|
1797 |
else {
|
|
|
1798 |
itemInventoryMap = null;
|
|
|
1799 |
}
|
|
|
1800 |
|
|
|
1801 |
Map<String, VoucherItemMapping> voucherMap = new HashMap<String, VoucherItemMapping>();
|
|
|
1802 |
VoucherItemMapping voucher;
|
|
|
1803 |
if(tVoucherMappings != null) {
|
|
|
1804 |
for(in.shop2020.model.v1.catalog.VoucherItemMapping tvoucher : tVoucherMappings) {
|
|
|
1805 |
voucher = new VoucherItemMapping(tvoucher.getAmount(), VoucherType.findByValue((int) tvoucher.getVoucherType()).name());
|
|
|
1806 |
voucherMap.put(VoucherType.findByValue((int) tvoucher.getVoucherType()).name(), voucher);
|
|
|
1807 |
}
|
|
|
1808 |
}
|
|
|
1809 |
|
|
|
1810 |
in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams stockPurchaseParams =
|
|
|
1811 |
new in.shop2020.catalog.dashboard.shared.ItemStockPurchaseParams();
|
|
|
1812 |
if(tStockPurchaseParams != null) {
|
|
|
1813 |
stockPurchaseParams.setItem_id(tStockPurchaseParams.getItem_id());
|
|
|
1814 |
stockPurchaseParams.setMinStockLevel(tStockPurchaseParams.getMinStockLevel());
|
|
|
1815 |
stockPurchaseParams.setNumOfDaysStock(tStockPurchaseParams.getNumOfDaysStock());
|
|
|
1816 |
}
|
|
|
1817 |
in.shop2020.catalog.dashboard.shared.PrivateDeal privateDeal=null;
|
|
|
1818 |
if(tPrivateDeal!=null){
|
|
|
1819 |
privateDeal= new in.shop2020.catalog.dashboard.shared.PrivateDeal();
|
| 11976 |
vikram.rag |
1820 |
if(tPrivateDeal.isSetDealFreebieItemId()){
|
|
|
1821 |
privateDeal.setDealFreebieItemId(tPrivateDeal.getDealFreebieItemId());
|
|
|
1822 |
}
|
| 11671 |
vikram.rag |
1823 |
privateDeal.setItem_id(tPrivateDeal.getItem_id());
|
|
|
1824 |
privateDeal.setDealPrice(tPrivateDeal.getDealPrice());
|
|
|
1825 |
if(tPrivateDeal.isSetStartDate()){
|
|
|
1826 |
privateDeal.setStartDate(tPrivateDeal.getStartDate());
|
|
|
1827 |
}
|
|
|
1828 |
else{
|
|
|
1829 |
privateDeal.setStartDate(null);
|
|
|
1830 |
}
|
|
|
1831 |
if(tPrivateDeal.isSetEndDate()){
|
|
|
1832 |
privateDeal.setEndDate(tPrivateDeal.getEndDate());
|
|
|
1833 |
}
|
|
|
1834 |
else{
|
|
|
1835 |
privateDeal.setEndDate(null);
|
|
|
1836 |
}
|
|
|
1837 |
privateDeal.setRank(tPrivateDeal.getRank());
|
| 11976 |
vikram.rag |
1838 |
if(tPrivateDeal.isSetIsCod()){
|
|
|
1839 |
privateDeal.setCod(tPrivateDeal.isIsCod());
|
|
|
1840 |
}
|
|
|
1841 |
else{
|
|
|
1842 |
privateDeal.setCod(true);
|
|
|
1843 |
}
|
|
|
1844 |
if(tPrivateDeal.isSetDealFreebieOption()){
|
|
|
1845 |
privateDeal.setDealFreebieOption(tPrivateDeal.getDealFreebieOption());
|
|
|
1846 |
}
|
|
|
1847 |
else{
|
|
|
1848 |
privateDeal.setDealFreebieOption(1L);
|
|
|
1849 |
}
|
|
|
1850 |
if(tPrivateDeal.isSetDealText()){
|
| 11671 |
vikram.rag |
1851 |
privateDeal.setDealText(tPrivateDeal.getDealText());
|
|
|
1852 |
}
|
|
|
1853 |
else{
|
| 11976 |
vikram.rag |
1854 |
if(thriftItem.isSetBestDealText()){
|
|
|
1855 |
privateDeal.setDealText(thriftItem.getBestDealText());
|
|
|
1856 |
}
|
|
|
1857 |
else{
|
|
|
1858 |
privateDeal.setDealText("");
|
|
|
1859 |
}
|
| 11671 |
vikram.rag |
1860 |
}
|
| 11976 |
vikram.rag |
1861 |
if(tPrivateDeal.isSetDealTextOption()){
|
|
|
1862 |
privateDeal.setDealTextOption(tPrivateDeal.getDealTextOption());
|
|
|
1863 |
}
|
|
|
1864 |
else{
|
|
|
1865 |
privateDeal.setDealTextOption(1L);
|
|
|
1866 |
}
|
|
|
1867 |
if(tPrivateDeal.isSetIsActive()){
|
|
|
1868 |
privateDeal.setActive(tPrivateDeal.isIsActive());
|
|
|
1869 |
}
|
|
|
1870 |
else{
|
|
|
1871 |
privateDeal.setActive(false);
|
|
|
1872 |
}
|
| 11671 |
vikram.rag |
1873 |
}
|
|
|
1874 |
Item item = new Item(thriftItem.getId(),
|
|
|
1875 |
thriftItem.getProductGroup(),
|
|
|
1876 |
thriftItem.getBrand(),
|
|
|
1877 |
thriftItem.getModelNumber(),
|
|
|
1878 |
thriftItem.getModelName(),
|
|
|
1879 |
thriftItem.getColor(),
|
|
|
1880 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
|
|
1881 |
thriftItem.getCategory(),
|
|
|
1882 |
thriftItem.getComments(),
|
|
|
1883 |
thriftItem.getCatalogItemId(),
|
|
|
1884 |
thriftItem.getFeatureId(),
|
|
|
1885 |
thriftItem.getFeatureDescription(),
|
|
|
1886 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
|
|
1887 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
|
|
1888 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
|
|
1889 |
thriftItem.getAddedOn(),
|
|
|
1890 |
thriftItem.getStartDate(),
|
|
|
1891 |
thriftItem.isSetComingSoonStartDate() ? thriftItem.getComingSoonStartDate() : null ,
|
|
|
1892 |
thriftItem.isSetExpectedArrivalDate() ? thriftItem.getExpectedArrivalDate() : null ,
|
|
|
1893 |
thriftItem.getRetireDate(),
|
|
|
1894 |
thriftItem.getUpdatedOn(),
|
|
|
1895 |
thriftItem.getItemStatus().name(),
|
|
|
1896 |
thriftItem.getItemStatus().getValue(),
|
|
|
1897 |
thriftItem.getStatus_description(),
|
|
|
1898 |
thriftItem.getBestDealText(),
|
|
|
1899 |
thriftItem.getBestDealsDetailsText(),
|
|
|
1900 |
thriftItem.getBestDealsDetailsLink(),
|
|
|
1901 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
|
|
1902 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
|
|
1903 |
thriftItem.isDefaultForEntity(),
|
|
|
1904 |
thriftItem.isRisky(),
|
|
|
1905 |
thriftItem.isSetExpectedDelay() ? thriftItem.getExpectedDelay() : null,
|
|
|
1906 |
thriftItem.isIsWarehousePreferenceSticky(),
|
|
|
1907 |
thriftItem.isHasItemNo(),
|
|
|
1908 |
ItemType.SERIALIZED.equals(thriftItem.getType()),
|
|
|
1909 |
thriftItem.isSetShowSellingPrice() ? thriftItem.isShowSellingPrice() : false,
|
|
|
1910 |
thriftItem.isHoldOverride(),
|
|
|
1911 |
thriftItem.isSetPreferredVendor() ? thriftItem.getPreferredVendor() : null,
|
|
|
1912 |
thriftItem.isSetPreferredInsurer() ? thriftItem.getPreferredInsurer() : null,
|
|
|
1913 |
itemInventoryMap,
|
|
|
1914 |
vendorPricingMap,
|
|
|
1915 |
vItemMap,
|
|
|
1916 |
sourcePricingMap,
|
|
|
1917 |
SimilarItemslist,
|
|
|
1918 |
voucherMap,
|
|
|
1919 |
stockPurchaseParams.getNumOfDaysStock(),
|
|
|
1920 |
stockPurchaseParams.getMinStockLevel(),
|
|
|
1921 |
saleHistory,
|
|
|
1922 |
freebieItemId,
|
|
|
1923 |
thriftItem.getAsin(),
|
|
|
1924 |
thriftItem.getHoldInventory(),
|
| 18150 |
kshitij.so |
1925 |
thriftItem.getDefaultInventory(),stateNameVatPercentageMap,privateDeal, thriftItem.getPackQuantity(),
|
| 18415 |
kshitij.so |
1926 |
thriftItem.getQuantityStep(),thriftItem.getMinimumBuyQuantity(),thriftItem.getMaximumBuyQuantity());
|
| 11671 |
vikram.rag |
1927 |
return item;
|
|
|
1928 |
}
|
| 12523 |
amit.gupta |
1929 |
|
|
|
1930 |
@Override
|
|
|
1931 |
public Map<Long, Double> getVatRates(long itemId, long categoryId) {
|
|
|
1932 |
try {
|
|
|
1933 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
1934 |
return catalogClient.getVatRates(itemId, categoryId);
|
|
|
1935 |
} catch (Exception e){
|
|
|
1936 |
e.printStackTrace();
|
|
|
1937 |
logger.info("Could not fetch vat rates");
|
|
|
1938 |
}
|
|
|
1939 |
return new HashMap<Long, Double>();
|
|
|
1940 |
}
|
|
|
1941 |
|
|
|
1942 |
@Override
|
|
|
1943 |
public Map<Long, String> getAllStatesMap() {
|
|
|
1944 |
Map<Long, String> allStatesMap = new TreeMap<Long, String>();
|
|
|
1945 |
try {
|
|
|
1946 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
1947 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
1948 |
Map<Long, StateInfo> stateMasterInfo = inventoryClient.getStateMaster();
|
|
|
1949 |
for( Map.Entry<Long, StateInfo> si : stateMasterInfo.entrySet()){
|
|
|
1950 |
allStatesMap.put(si.getKey(), si.getValue().getStateName());
|
|
|
1951 |
}
|
|
|
1952 |
} catch (Exception e){
|
|
|
1953 |
logger.info("Could not fetch States");
|
|
|
1954 |
e.printStackTrace();
|
|
|
1955 |
}
|
|
|
1956 |
return allStatesMap;
|
|
|
1957 |
}
|
|
|
1958 |
|
|
|
1959 |
@Override
|
|
|
1960 |
public boolean markPartiallyActive(long itemId, Long categoryId) {
|
|
|
1961 |
try {
|
|
|
1962 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
1963 |
catalogClient.markPartiallyActive(itemId, categoryId);
|
|
|
1964 |
Client catalogClientProd = new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
|
|
|
1965 |
catalogClientProd.markPartiallyActive(itemId, categoryId);
|
|
|
1966 |
return true;
|
|
|
1967 |
} catch (Exception e){
|
|
|
1968 |
e.printStackTrace();
|
|
|
1969 |
logger.info("Could not update");
|
|
|
1970 |
}
|
|
|
1971 |
return false;
|
|
|
1972 |
}
|
|
|
1973 |
|
|
|
1974 |
@Override
|
|
|
1975 |
public boolean updateItemStateVat(long itemId, List<in.shop2020.catalog.dashboard.shared.StateVat> svs) {
|
|
|
1976 |
logger.info("In update itemStateVat");
|
|
|
1977 |
try {
|
|
|
1978 |
Map<Long, Double> stateVatMap = new HashMap<Long, Double>();
|
|
|
1979 |
for(in.shop2020.catalog.dashboard.shared.StateVat sv : svs){
|
|
|
1980 |
stateVatMap.put(sv.stateId, sv.vatRate);
|
|
|
1981 |
}
|
|
|
1982 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
1983 |
catalogClient.updateItemStateVat(itemId, stateVatMap);
|
|
|
1984 |
Client catalogClientProd = new CatalogClient("catalog_service_server_host_prod","catalog_service_server_port").getClient();
|
|
|
1985 |
catalogClientProd.updateItemStateVat(itemId, stateVatMap);
|
|
|
1986 |
return true;
|
|
|
1987 |
} catch (Exception e){
|
|
|
1988 |
e.printStackTrace();
|
|
|
1989 |
logger.info("Could not update");
|
|
|
1990 |
return false;
|
|
|
1991 |
}
|
|
|
1992 |
}
|
| 18150 |
kshitij.so |
1993 |
|
|
|
1994 |
public in.shop2020.catalog.dashboard.shared.BulkItemPricing addBulkPricingForItem(BulkItemPricing bulkItemPricing){
|
|
|
1995 |
try{
|
|
|
1996 |
in.shop2020.model.v1.catalog.BulkItemPricing t_bulkItemPricing = new in.shop2020.model.v1.catalog.BulkItemPricing();
|
|
|
1997 |
t_bulkItemPricing.setItem_id(bulkItemPricing.getItem_id());
|
|
|
1998 |
t_bulkItemPricing.setPrice(bulkItemPricing.getPrice());
|
|
|
1999 |
t_bulkItemPricing.setQuantity(bulkItemPricing.getQuantity());
|
|
|
2000 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
2001 |
in.shop2020.model.v1.catalog.BulkItemPricing result = catalogClient.addBulkPricingForItem(t_bulkItemPricing);
|
|
|
2002 |
in.shop2020.catalog.dashboard.shared.BulkItemPricing bulkItemPricingObj = new in.shop2020.catalog.dashboard.shared.BulkItemPricing(result.getId(), result.getItem_id(), result.getQuantity(), result.getPrice());
|
|
|
2003 |
return bulkItemPricingObj;
|
|
|
2004 |
}
|
|
|
2005 |
catch (Exception e){
|
|
|
2006 |
e.printStackTrace();
|
|
|
2007 |
logger.info("Could not add bulk pricing");
|
|
|
2008 |
return null;
|
|
|
2009 |
}
|
|
|
2010 |
}
|
|
|
2011 |
|
|
|
2012 |
public List<in.shop2020.catalog.dashboard.shared.BulkItemPricing> getBulkPricingByItemId(long itemId){
|
|
|
2013 |
try{
|
|
|
2014 |
List<in.shop2020.catalog.dashboard.shared.BulkItemPricing> listBulkItemPricingObj = new ArrayList<in.shop2020.catalog.dashboard.shared.BulkItemPricing>();
|
|
|
2015 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
2016 |
List<in.shop2020.model.v1.catalog.BulkItemPricing> t_bulkItemsPricing = catalogClient.getBulkPricingByItemId(itemId);
|
|
|
2017 |
for (in.shop2020.model.v1.catalog.BulkItemPricing result : t_bulkItemsPricing){
|
|
|
2018 |
in.shop2020.catalog.dashboard.shared.BulkItemPricing bulkItemPricingObj = new in.shop2020.catalog.dashboard.shared.BulkItemPricing(result.getId(), result.getItem_id(), result.getQuantity(), result.getPrice());
|
|
|
2019 |
listBulkItemPricingObj.add(bulkItemPricingObj);
|
|
|
2020 |
}
|
|
|
2021 |
return listBulkItemPricingObj;
|
|
|
2022 |
}
|
|
|
2023 |
catch (Exception e){
|
|
|
2024 |
e.printStackTrace();
|
|
|
2025 |
logger.info("Could not get bulk pricing");
|
|
|
2026 |
return null;
|
|
|
2027 |
}
|
|
|
2028 |
}
|
|
|
2029 |
|
|
|
2030 |
public boolean deleteBulkPricingForItemById(long id){
|
|
|
2031 |
try{
|
|
|
2032 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
2033 |
boolean result = catalogClient.deleteBulkPricingForItemById(id);
|
|
|
2034 |
return result;
|
|
|
2035 |
}
|
|
|
2036 |
catch (Exception e){
|
|
|
2037 |
e.printStackTrace();
|
|
|
2038 |
logger.info("Could not delete bulk pricing");
|
|
|
2039 |
return false;
|
|
|
2040 |
}
|
|
|
2041 |
}
|
|
|
2042 |
|
|
|
2043 |
public boolean deleteBulkPricingForItem(long itemId){
|
|
|
2044 |
try{
|
|
|
2045 |
Client catalogClient = new CatalogClient().getClient();
|
|
|
2046 |
boolean result = catalogClient.deleteBulkPricingForItem(itemId);
|
|
|
2047 |
return result;
|
|
|
2048 |
}
|
|
|
2049 |
catch (Exception e){
|
|
|
2050 |
e.printStackTrace();
|
|
|
2051 |
logger.info("Could not delete all bulk pricing");
|
|
|
2052 |
return false;
|
|
|
2053 |
}
|
|
|
2054 |
}
|
| 21864 |
ashik.ali |
2055 |
|
|
|
2056 |
public List<CategoryHsnCode> getHsnCodesByCategoryId(int categoryId) {
|
|
|
2057 |
List<CategoryHsnCode> categoryHsnCodes = new ArrayList<CategoryHsnCode>();
|
|
|
2058 |
try{
|
|
|
2059 |
Client client2 = new CatalogClient().getClient();
|
|
|
2060 |
for(in.shop2020.model.v1.catalog.CategoryHsnCode e : client2.getHsnCodesByCategory(categoryId)){
|
|
|
2061 |
CategoryHsnCode categoryHsnCode = new CategoryHsnCode();
|
|
|
2062 |
categoryHsnCode.setCategoryId(Long.valueOf(e.getCategoryId()).intValue());
|
|
|
2063 |
categoryHsnCode.setHsnCode(e.getHsnCode());
|
|
|
2064 |
categoryHsnCode.setDescription(e.getDescription());
|
|
|
2065 |
categoryHsnCodes.add(categoryHsnCode);
|
|
|
2066 |
}
|
|
|
2067 |
}catch(Exception e){
|
|
|
2068 |
e.printStackTrace();
|
|
|
2069 |
logger.info("Could not get Hsn Codes By Category Id");
|
|
|
2070 |
}
|
|
|
2071 |
return categoryHsnCodes;
|
|
|
2072 |
}
|
|
|
2073 |
|
| 6530 |
vikram.rag |
2074 |
}
|