| Line 1... |
Line 1... |
| 1 |
package in.shop2020.catalog.dashboard.server;
|
1 |
package in.shop2020.catalog.dashboard.server;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.catalog.dashboard.client.CatalogService;
|
3 |
import in.shop2020.catalog.dashboard.client.CatalogService;
|
| 4 |
import in.shop2020.catalog.dashboard.shared.Item;
|
4 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 5 |
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
|
5 |
import in.shop2020.catalog.dashboard.shared.ItemsComparator;
|
| - |
|
6 |
import in.shop2020.catalog.dashboard.shared.VendorDetails;
|
| 6 |
import in.shop2020.model.v1.catalog.InventoryService;
|
7 |
import in.shop2020.model.v1.catalog.InventoryService;
|
| - |
|
8 |
import in.shop2020.model.v1.catalog.VendorItemMapping;
|
| 7 |
import in.shop2020.model.v1.catalog.VendorItemPricing;
|
9 |
import in.shop2020.model.v1.catalog.VendorItemPricing;
|
| - |
|
10 |
import in.shop2020.model.v1.catalog.status;
|
| 8 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
11 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
| 9 |
|
12 |
|
| 10 |
import java.util.ArrayList;
|
13 |
import java.util.ArrayList;
|
| - |
|
14 |
import java.util.Calendar;
|
| 11 |
import java.util.Collections;
|
15 |
import java.util.Collections;
|
| 12 |
import java.util.Comparator;
|
- |
|
| 13 |
import java.util.HashMap;
|
16 |
import java.util.HashMap;
|
| 14 |
import java.util.List;
|
17 |
import java.util.List;
|
| 15 |
import java.util.Map;
|
18 |
import java.util.Map;
|
| 16 |
import java.util.Map.Entry;
|
19 |
import java.util.Map.Entry;
|
| 17 |
|
20 |
|
| Line 29... |
Line 32... |
| 29 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
32 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 30 |
|
33 |
|
| 31 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(true);
|
34 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(true);
|
| 32 |
|
35 |
|
| 33 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
36 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 34 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
37 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 35 |
itemList.add(getItemFromThriftItem(thriftItem, vip));
|
38 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 36 |
}
|
39 |
}
|
| 37 |
} catch (Exception e) {
|
40 |
} catch (Exception e) {
|
| 38 |
e.printStackTrace();
|
41 |
e.printStackTrace();
|
| 39 |
}
|
42 |
}
|
| 40 |
Collections.sort(itemList, new ItemsComparator());
|
43 |
Collections.sort(itemList, new ItemsComparator());
|
| Line 48... |
Line 51... |
| 48 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
51 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 49 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
52 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 50 |
|
53 |
|
| 51 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
54 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
| 52 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
55 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 53 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
56 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 54 |
itemList.add(getItemFromThriftItem(thriftItem, vip));
|
57 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 55 |
}
|
58 |
}
|
| 56 |
} catch(Exception e){
|
59 |
} catch(Exception e){
|
| 57 |
e.printStackTrace();
|
60 |
e.printStackTrace();
|
| 58 |
}
|
61 |
}
|
| 59 |
Collections.sort(itemList, new ItemsComparator());
|
62 |
Collections.sort(itemList, new ItemsComparator());
|
| Line 67... |
Line 70... |
| 67 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
70 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 68 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
71 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 69 |
|
72 |
|
| 70 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
73 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
| 71 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
74 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 72 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
75 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 73 |
itemList.add(getItemFromThriftItem(thriftItem, vip));
|
76 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 74 |
}
|
77 |
}
|
| 75 |
} catch(Exception e){
|
78 |
} catch(Exception e){
|
| 76 |
e.printStackTrace();
|
79 |
e.printStackTrace();
|
| 77 |
}
|
80 |
}
|
| 78 |
Collections.sort(itemList, new ItemsComparator());
|
81 |
Collections.sort(itemList, new ItemsComparator());
|
| Line 86... |
Line 89... |
| 86 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
89 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 87 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
90 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 88 |
|
91 |
|
| 89 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
92 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
| 90 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
93 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 91 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
94 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 92 |
itemList.add(getItemFromThriftItem(thriftItem, vip));
|
95 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 93 |
}
|
96 |
}
|
| 94 |
} catch(Exception e){
|
97 |
} catch(Exception e){
|
| 95 |
e.printStackTrace();
|
98 |
e.printStackTrace();
|
| 96 |
}
|
99 |
}
|
| 97 |
Collections.sort(itemList, new ItemsComparator());
|
100 |
Collections.sort(itemList, new ItemsComparator());
|
| Line 103... |
Line 106... |
| 103 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
106 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 104 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
107 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 105 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
108 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
| 106 |
|
109 |
|
| 107 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
110 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| - |
|
111 |
//List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| 108 |
return getItemFromThriftItem(thriftItem, vip);
|
112 |
return getItemFromThriftItem(thriftItem, vip, null);
|
| 109 |
}catch(Exception e){
|
113 |
}catch(Exception e){
|
| 110 |
// Oops! We didn't receive the details. We should let the user know
|
114 |
// Oops! We didn't receive the details. We should let the user know
|
| 111 |
// that the catalog service is currently unavailable.
|
115 |
// that the catalog service is currently unavailable.
|
| 112 |
e.printStackTrace();
|
116 |
e.printStackTrace();
|
| 113 |
}
|
117 |
}
|
| Line 126... |
Line 130... |
| 126 |
// periodically.
|
130 |
// periodically.
|
| 127 |
e.printStackTrace();
|
131 |
e.printStackTrace();
|
| 128 |
}
|
132 |
}
|
| 129 |
}
|
133 |
}
|
| 130 |
|
134 |
|
| 131 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem, List<in.shop2020.model.v1.catalog.VendorItemPricing> thriftItemPricings){
|
135 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
| - |
|
136 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings,
|
| - |
|
137 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings){
|
| 132 |
|
138 |
|
| 133 |
Map<Long, double[]> vendorPricings = new HashMap<Long, double[]>();
|
139 |
Map<Long, VendorDetails> vendorDetailsMap = new HashMap<Long, VendorDetails>();
|
| 134 |
double[] prices;
|
140 |
VendorDetails vDetails;
|
| - |
|
141 |
if(tVendorMappings != null) {
|
| - |
|
142 |
for(VendorItemMapping vim : tVendorMappings) {
|
| - |
|
143 |
vDetails = vendorDetailsMap.get(vim.getVendorId());
|
| - |
|
144 |
if(vDetails == null) {
|
| - |
|
145 |
vDetails = new VendorDetails();
|
| - |
|
146 |
vDetails.setVendorId(vim.getVendorId());
|
| - |
|
147 |
}
|
| - |
|
148 |
vDetails.setVendorId(vim.getVendorId());
|
| - |
|
149 |
vDetails.setItemKey(vim.getItemKey());
|
| - |
|
150 |
vendorDetailsMap.put(vDetails.getVendorId(), vDetails);
|
| - |
|
151 |
}
|
| - |
|
152 |
}
|
| 135 |
if(thriftItemPricings != null) {
|
153 |
if(tVendorPricings != null) {
|
| 136 |
for(VendorItemPricing v : thriftItemPricings) {
|
154 |
for(VendorItemPricing vip : tVendorPricings) {
|
| - |
|
155 |
vDetails = vendorDetailsMap.get(vip.getVendorId());
|
| - |
|
156 |
if(vDetails == null) {
|
| 137 |
prices = new double[3];
|
157 |
vDetails = new VendorDetails();
|
| - |
|
158 |
vDetails.setVendorId(vip.getVendorId());
|
| - |
|
159 |
}
|
| 138 |
prices[0] = v.getMop();
|
160 |
vDetails.setMop(vip.getMop());
|
| 139 |
prices[1] = v.getDealerPrice();
|
161 |
vDetails.setDealerPrice(vip.getDealerPrice());
|
| 140 |
prices[2] = v.getTransferPrice();
|
162 |
vDetails.setTransferPrice(vip.getTransferPrice());
|
| 141 |
vendorPricings.put(v.getVendorId(), prices);
|
163 |
vendorDetailsMap.put(vDetails.getVendorId(), vDetails);
|
| 142 |
}
|
164 |
}
|
| 143 |
}
|
165 |
}
|
| - |
|
166 |
|
| 144 |
Item item = new Item(thriftItem.getId(),
|
167 |
Item item = new Item(thriftItem.getId(),
|
| 145 |
thriftItem.getProductGroup(),
|
168 |
thriftItem.getProductGroup(),
|
| 146 |
thriftItem.getBrand(),
|
169 |
thriftItem.getBrand(),
|
| 147 |
thriftItem.getModelNumber(),
|
170 |
thriftItem.getModelNumber(),
|
| 148 |
thriftItem.getModelName(),
|
171 |
thriftItem.getModelName(),
|
| Line 167... |
Line 190... |
| 167 |
thriftItem.getBestDealText(),
|
190 |
thriftItem.getBestDealText(),
|
| 168 |
thriftItem.getBestDealValue(),
|
191 |
thriftItem.getBestDealValue(),
|
| 169 |
thriftItem.getBestSellingRank(),
|
192 |
thriftItem.getBestSellingRank(),
|
| 170 |
thriftItem.isDefaultForEntity(),
|
193 |
thriftItem.isDefaultForEntity(),
|
| 171 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
194 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
| 172 |
vendorPricings
|
195 |
vendorDetailsMap
|
| 173 |
);
|
196 |
);
|
| 174 |
return item;
|
197 |
return item;
|
| 175 |
}
|
198 |
}
|
| 176 |
|
199 |
|
| 177 |
@Override
|
200 |
@Override
|
| Line 210... |
Line 233... |
| 210 |
// tItem.setCategory(item.getCategory());
|
233 |
// tItem.setCategory(item.getCategory());
|
| 211 |
|
234 |
|
| 212 |
// tItem.setFeatureId(item.getFeatureId());
|
235 |
// tItem.setFeatureId(item.getFeatureId());
|
| 213 |
// tItem.setFeatureDescription(item.getFeatureDescription());
|
236 |
// tItem.setFeatureDescription(item.getFeatureDescription());
|
| 214 |
|
237 |
|
| - |
|
238 |
long rItemId;
|
| - |
|
239 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
| - |
|
240 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
| - |
|
241 |
return false;
|
| - |
|
242 |
}
|
| - |
|
243 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
| - |
|
244 |
|
| - |
|
245 |
Map<Long, VendorDetails> vendorDetails = item.getVendorDetails();
|
| - |
|
246 |
if(vendorDetails != null && !vendorDetails.isEmpty()) {
|
| - |
|
247 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
| - |
|
248 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
| - |
|
249 |
for(VendorDetails v : vendorDetails.values()) {
|
| - |
|
250 |
tVendorPricing = new VendorItemPricing();
|
| - |
|
251 |
tVendorPricing.setVendorId(v.getVendorId());
|
| - |
|
252 |
tVendorPricing.setItemId(item.getId());
|
| - |
|
253 |
tVendorPricing.setMop(v.getMop());
|
| - |
|
254 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| - |
|
255 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| - |
|
256 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
| - |
|
257 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
| - |
|
258 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
| - |
|
259 |
|
| - |
|
260 |
/*tVendorMapping = new VendorItemMapping();
|
| - |
|
261 |
tVendorMapping.setVendorId(v.getVendorId());
|
| - |
|
262 |
tVendorMapping.setItemKey(v.getItemKey());
|
| - |
|
263 |
tVendorMapping.setItemId(item.getId());
|
| - |
|
264 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| - |
|
265 |
catalogClient.addVendorItemMapping(tVendorMapping);
|
| - |
|
266 |
GWT.log("VendorItemMapping updated. " + tVendorMapping.getVendorId() + ", " + tVendorMapping.getItemId() + ", " +
|
| - |
|
267 |
tVendorMapping.getItemKey() + ", " + tVendorMapping.getVendorCategory());*/
|
| - |
|
268 |
}
|
| - |
|
269 |
}
|
| - |
|
270 |
|
| - |
|
271 |
}catch(Exception e){
|
| - |
|
272 |
e.printStackTrace();
|
| - |
|
273 |
}
|
| - |
|
274 |
return true;
|
| - |
|
275 |
|
| - |
|
276 |
|
| 215 |
/*List<VendorItemPricing> tVendorPrices = tItem.getVendorPrices();
|
277 |
/*List<VendorItemPricing> tVendorPrices = tItem.getVendorPrices();
|
| 216 |
if(tVendorPrices == null) {
|
278 |
if(tVendorPrices == null) {
|
| 217 |
tVendorPrices = new ArrayList<VendorItemPricing>();
|
279 |
tVendorPrices = new ArrayList<VendorItemPricing>();
|
| 218 |
}
|
280 |
}
|
| 219 |
for(Entry<Long, double[]> vendorItemPricing : item.getVendorPricings().entrySet()) {
|
281 |
for(Entry<Long, double[]> vendorItemPricing : item.getVendorPricings().entrySet()) {
|
| Line 233... |
Line 295... |
| 233 |
vip.setMop(vendorItemPricing.getValue()[Item.INDEX_MOP]);
|
295 |
vip.setMop(vendorItemPricing.getValue()[Item.INDEX_MOP]);
|
| 234 |
vip.setDealerPrice(vendorItemPricing.getValue()[Item.INDEX_DP]);
|
296 |
vip.setDealerPrice(vendorItemPricing.getValue()[Item.INDEX_DP]);
|
| 235 |
vip.setTransferPrice(vendorItemPricing.getValue()[Item.INDEX_TP]);
|
297 |
vip.setTransferPrice(vendorItemPricing.getValue()[Item.INDEX_TP]);
|
| 236 |
//catalogClient.updateVendorItemPricing(vip);
|
298 |
//catalogClient.updateVendorItemPricing(vip);
|
| 237 |
}*/
|
299 |
}*/
|
| 238 |
|
- |
|
| 239 |
VendorItemPricing vip = new VendorItemPricing();
|
- |
|
| 240 |
for(Entry<Long, double[]> vendorItemPricing : item.getVendorPricings().entrySet()) {
|
- |
|
| 241 |
vip.setItemId(item.getId());
|
- |
|
| 242 |
vip.setVendorId(vendorItemPricing.getKey());
|
- |
|
| 243 |
vip.setMop(vendorItemPricing.getValue()[Item.INDEX_MOP]);
|
- |
|
| 244 |
vip.setDealerPrice(vendorItemPricing.getValue()[Item.INDEX_DP]);
|
- |
|
| 245 |
vip.setTransferPrice(vendorItemPricing.getValue()[Item.INDEX_TP]);
|
- |
|
| 246 |
catalogClient.updateVendorItemPricing(vip);
|
- |
|
| 247 |
}
|
- |
|
| 248 |
|
- |
|
| 249 |
if(catalogClient.updateItem(tItem) == item.getId());
|
- |
|
| 250 |
return true;
|
- |
|
| 251 |
|
- |
|
| 252 |
}catch(Exception e){
|
- |
|
| 253 |
e.printStackTrace();
|
- |
|
| 254 |
}
|
- |
|
| 255 |
return false;
|
- |
|
| 256 |
}
|
300 |
}
|
| 257 |
|
301 |
|
| 258 |
|
302 |
|
| 259 |
@Override
|
303 |
@Override
|
| 260 |
public Map<Long, String> getAllVendors() {
|
304 |
public Map<Long, String> getAllVendors() {
|
| Line 289... |
Line 333... |
| 289 |
} catch (Exception e) {
|
333 |
} catch (Exception e) {
|
| 290 |
e.printStackTrace();
|
334 |
e.printStackTrace();
|
| 291 |
}
|
335 |
}
|
| 292 |
return warehouseMap;
|
336 |
return warehouseMap;
|
| 293 |
}
|
337 |
}
|
| - |
|
338 |
|
| - |
|
339 |
@Override
|
| - |
|
340 |
public void phaseoutItem(long itemId) {
|
| - |
|
341 |
try {
|
| - |
|
342 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
343 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
344 |
|
| - |
|
345 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
| - |
|
346 |
} catch (Exception e) {
|
| - |
|
347 |
e.printStackTrace();
|
| - |
|
348 |
}
|
| - |
|
349 |
}
|
| - |
|
350 |
|
| - |
|
351 |
@Override
|
| - |
|
352 |
public void activateItem(long itemId) {
|
| - |
|
353 |
try {
|
| - |
|
354 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
355 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
356 |
|
| - |
|
357 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
| - |
|
358 |
} catch (Exception e) {
|
| - |
|
359 |
e.printStackTrace();
|
| - |
|
360 |
}
|
| - |
|
361 |
}
|
| - |
|
362 |
|
| - |
|
363 |
|
| - |
|
364 |
|
| - |
|
365 |
@Override
|
| - |
|
366 |
public long addItem(Item item) {
|
| - |
|
367 |
long itemId = 0;
|
| - |
|
368 |
try {
|
| - |
|
369 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
370 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
371 |
|
| - |
|
372 |
in.shop2020.model.v1.catalog.Item tItem = new in.shop2020.model.v1.catalog.Item();
|
| - |
|
373 |
|
| - |
|
374 |
tItem.setProductGroup(item.getProductGroup());
|
| - |
|
375 |
tItem.setBrand(item.getBrand());
|
| - |
|
376 |
tItem.setModelNumber(item.getModelNumber());
|
| - |
|
377 |
tItem.setModelName(item.getModelName());
|
| - |
|
378 |
tItem.setColor(item.getColor());
|
| - |
|
379 |
tItem.setComments(item.getComments());
|
| - |
|
380 |
tItem.setMrp(item.getMrp());
|
| - |
|
381 |
tItem.setSellingPrice(item.getSellingPrice());
|
| - |
|
382 |
tItem.setWeight(item.getWeight());
|
| - |
|
383 |
tItem.setAddedOn(Calendar.getInstance().getTimeInMillis());
|
| - |
|
384 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
| - |
|
385 |
tItem.setRetireDate(item.getRetireDate());
|
| - |
|
386 |
tItem.setStartDate(item.getStartDate());
|
| - |
|
387 |
tItem.setBestDealText(item.getBestDealsText());
|
| - |
|
388 |
tItem.setBestDealValue(item.getBestDealsValue());
|
| - |
|
389 |
tItem.setBestSellingRank(item.getBestSellingRank());
|
| - |
|
390 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
| - |
|
391 |
tItem.setHotspotCategory(item.getVendorCategory());
|
| - |
|
392 |
|
| - |
|
393 |
itemId = catalogClient.addItem(tItem);
|
| - |
|
394 |
|
| - |
|
395 |
Map<Long, VendorDetails> vendorDetails = item.getVendorDetails();
|
| - |
|
396 |
if(vendorDetails != null && !vendorDetails.isEmpty()) {
|
| - |
|
397 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
| - |
|
398 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
| - |
|
399 |
for(VendorDetails v : vendorDetails.values()) {
|
| - |
|
400 |
tVendorMapping = new VendorItemMapping();
|
| - |
|
401 |
tVendorMapping.setVendorId(v.getVendorId());
|
| - |
|
402 |
tVendorMapping.setItemKey(v.getItemKey());
|
| - |
|
403 |
tVendorMapping.setItemId(itemId);
|
| - |
|
404 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| - |
|
405 |
catalogClient.addVendorItemMapping(tVendorMapping);
|
| - |
|
406 |
|
| - |
|
407 |
/*tVendorPricing = new VendorItemPricing();
|
| - |
|
408 |
tVendorPricing.setVendorId(v.getVendorId());
|
| - |
|
409 |
tVendorPricing.setItemId(itemId);
|
| - |
|
410 |
tVendorPricing.setMop(v.getMop());
|
| - |
|
411 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| - |
|
412 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| - |
|
413 |
catalogClient.addVendorItemPricing(tVendorPricing);*/
|
| - |
|
414 |
}
|
| - |
|
415 |
|
| - |
|
416 |
}
|
| - |
|
417 |
/*Map<Long, double[]> vendors = item.getVendorPricings();
|
| - |
|
418 |
List<VendorItemPricing> vPricesList;
|
| - |
|
419 |
if(vendors != null && !vendors.isEmpty()) {
|
| - |
|
420 |
vPricesList = new ArrayList<VendorItemPricing>();
|
| - |
|
421 |
VendorItemPricing vendorPrices = null;
|
| - |
|
422 |
for(Entry<Long, double[]> v : vendors.entrySet()) {
|
| - |
|
423 |
vendorPrices = new VendorItemPricing(v.getKey(), item.getId(),
|
| - |
|
424 |
v.getValue()[Item.INDEX_TP], v.getValue()[Item.INDEX_MOP], v.getValue()[Item.INDEX_DP]);
|
| - |
|
425 |
vPricesList.add(vendorPrices);
|
| - |
|
426 |
}
|
| - |
|
427 |
boolean itemExists = catalogClient.itemExists(item.getProductGroup(), item.getHbrand(), item.getHmodelNumber(),
|
| - |
|
428 |
item.getHcolor(), vendorPrices.getVendorId(), item.getVendorCategory());
|
| - |
|
429 |
if(itemExists) {
|
| - |
|
430 |
return itemId;
|
| - |
|
431 |
}
|
| - |
|
432 |
} else {
|
| - |
|
433 |
return 0;
|
| - |
|
434 |
}
|
| - |
|
435 |
catalogClient.addVendorItemPricing(vendorItemPricing)
|
| - |
|
436 |
*/
|
| - |
|
437 |
|
| - |
|
438 |
} catch (Exception e) {
|
| - |
|
439 |
e.printStackTrace();
|
| - |
|
440 |
}
|
| - |
|
441 |
return itemId;
|
| - |
|
442 |
}
|
| 294 |
}
|
443 |
}
|