| Line 41... |
Line 41... |
| 41 |
import com.spice.profitmandi.common.model.UserInfo;
|
41 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 42 |
import com.spice.profitmandi.common.web.client.RestClient;
|
42 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 43 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
43 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 44 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
44 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 45 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
45 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
46 |
import com.spice.profitmandi.dao.entity.inventory.ItemAvailabilityCache;
|
| 46 |
import com.spice.profitmandi.dao.model.UserCart;
|
47 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
48 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
49 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
50 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 50 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
52 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| 52 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
53 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 53 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
- |
|
| 54 |
import com.spice.profitmandi.service.pricing.PricingService;
|
54 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 55 |
import com.spice.profitmandi.web.res.AvailabilityInfo;
|
55 |
import com.spice.profitmandi.web.res.AvailabilityInfo;
|
| 56 |
import com.spice.profitmandi.web.res.DealBrands;
|
56 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 57 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
57 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 58 |
import com.spice.profitmandi.web.res.DealsResponse;
|
58 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| Line 96... |
Line 96... |
| 96 |
|
96 |
|
| 97 |
@Autowired
|
97 |
@Autowired
|
| 98 |
private ItemRepository itemRepository;
|
98 |
private ItemRepository itemRepository;
|
| 99 |
|
99 |
|
| 100 |
@Autowired
|
100 |
@Autowired
|
| - |
|
101 |
private ItemAvailabilityCacheRepository itemAvailabilityCacheRepository;
|
| - |
|
102 |
|
| - |
|
103 |
@Autowired
|
| 101 |
private RoleManager roleManagerService;
|
104 |
private RoleManager roleManagerService;
|
| 102 |
|
105 |
|
| 103 |
List<String> filterableParams = Arrays.asList("brand");
|
106 |
List<String> filterableParams = Arrays.asList("brand");
|
| 104 |
|
107 |
|
| 105 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
108 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 234... |
Line 237... |
| 234 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
237 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
| 235 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
238 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
| 236 |
int itemId = childItem.getInt("itemId_i");
|
239 |
int itemId = childItem.getInt("itemId_i");
|
| 237 |
if (hotDeal) {
|
240 |
if (hotDeal) {
|
| 238 |
TagListing tl = itemTagListingMap.get(itemId);
|
241 |
TagListing tl = itemTagListingMap.get(itemId);
|
| 239 |
if(!tl.isHotDeals()) {
|
242 |
if (!tl.isHotDeals()) {
|
| 240 |
continue;
|
243 |
continue;
|
| 241 |
}
|
244 |
}
|
| 242 |
}
|
245 |
}
|
| 243 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
246 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
| 244 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
247 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
| Line 251... |
Line 254... |
| 251 |
fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
|
254 |
fdi.setSellingPrice((float) childItem.getDouble("sellingPrice_f"));
|
| 252 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
255 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
| 253 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
256 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
| 254 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
257 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
| 255 |
fdi.setItem_id(itemId);
|
258 |
fdi.setItem_id(itemId);
|
| 256 |
/*
|
- |
|
| 257 |
* int totalAvailability = 0; //Using item availability cache for now but can be
|
- |
|
| 258 |
* changed to use caching later. try { ItemAvailabilityCache iac =
|
- |
|
| 259 |
* itemAvailabilityCacheRepository.selectByItemId(itemId); totalAvailability =
|
- |
|
| 260 |
* iac.getTotalAvailability(); } catch (Exception e) {} if(totalAvailability <=
|
- |
|
| 261 |
* 0){ continue; }
|
- |
|
| 262 |
*/
|
- |
|
| 263 |
Item item = itemRepository.selectById(itemId);
|
259 |
Item item = itemRepository.selectById(itemId);
|
| 264 |
// In case its tampered glass moq should be 5
|
260 |
// In case its tampered glass moq should be 5
|
| 265 |
if (item.getCategoryId() == 10020) {
|
261 |
if (item.getCategoryId() == 10020) {
|
| 266 |
fdi.setMinBuyQuantity(5);
|
262 |
fdi.setMinBuyQuantity(5);
|
| 267 |
} else {
|
263 |
} else {
|
| 268 |
fdi.setMinBuyQuantity(1);
|
264 |
fdi.setMinBuyQuantity(1);
|
| 269 |
}
|
265 |
}
|
| - |
|
266 |
if (hotDeal) {
|
| - |
|
267 |
|
| - |
|
268 |
int totalAvailability = 0; // Using item availability cache for now but can be changed to
|
| - |
|
269 |
// use caching later.
|
| - |
|
270 |
try {
|
| - |
|
271 |
ItemAvailabilityCache iac = itemAvailabilityCacheRepository.selectByItemId(itemId);
|
| - |
|
272 |
totalAvailability = iac.getTotalAvailability();
|
| - |
|
273 |
fdi.setAvailability(totalAvailability);
|
| - |
|
274 |
} catch (Exception e) {
|
| - |
|
275 |
continue;
|
| - |
|
276 |
}
|
| - |
|
277 |
if (totalAvailability <= 0) {
|
| - |
|
278 |
continue;
|
| - |
|
279 |
}
|
| - |
|
280 |
} else {
|
| 270 |
fdi.setAvailability(10);
|
281 |
fdi.setAvailability(10);
|
| - |
|
282 |
}
|
| 271 |
fdi.setQuantityStep(1);
|
283 |
fdi.setQuantityStep(1);
|
| 272 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
284 |
fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
|
| 273 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
285 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
| 274 |
}
|
286 |
}
|
| 275 |
}
|
287 |
}
|