| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayInputStream;
|
3 |
import java.io.ByteArrayInputStream;
|
| 4 |
import java.io.ByteArrayOutputStream;
|
4 |
import java.io.ByteArrayOutputStream;
|
| 5 |
import java.io.InputStream;
|
5 |
import java.io.InputStream;
|
| 6 |
import java.time.LocalDateTime;
|
6 |
import java.time.LocalDateTime;
|
| - |
|
7 |
import java.util.ArrayList;
|
| - |
|
8 |
import java.util.Comparator;
|
| - |
|
9 |
import java.util.HashSet;
|
| 7 |
import java.util.List;
|
10 |
import java.util.List;
|
| 8 |
import java.util.Map;
|
11 |
import java.util.Map;
|
| - |
|
12 |
import java.util.Set;
|
| - |
|
13 |
import java.util.stream.Collectors;
|
| 9 |
|
14 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
15 |
import javax.servlet.http.HttpServletRequest;
|
| 11 |
import javax.servlet.http.HttpServletResponse;
|
16 |
import javax.servlet.http.HttpServletResponse;
|
| 12 |
|
17 |
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
18 |
import org.apache.logging.log4j.LogManager;
|
| 14 |
import org.apache.logging.log4j.Logger;
|
19 |
import org.apache.logging.log4j.Logger;
|
| - |
|
20 |
import org.json.JSONObject;
|
| 15 |
import org.springframework.beans.factory.annotation.Autowired;
|
21 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
22 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 17 |
import org.springframework.beans.factory.annotation.Value;
|
23 |
import org.springframework.beans.factory.annotation.Value;
|
| 18 |
import org.springframework.core.io.InputStreamResource;
|
24 |
import org.springframework.core.io.InputStreamResource;
|
| 19 |
import org.springframework.format.annotation.DateTimeFormat;
|
25 |
import org.springframework.format.annotation.DateTimeFormat;
|
| Line 29... |
Line 35... |
| 29 |
import org.springframework.web.bind.annotation.RequestMethod;
|
35 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 30 |
import org.springframework.web.bind.annotation.RequestParam;
|
36 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 31 |
|
37 |
|
| 32 |
import com.google.gson.Gson;
|
38 |
import com.google.gson.Gson;
|
| 33 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
39 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
40 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
| 34 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
41 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 35 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
42 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 36 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
43 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 37 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
44 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
| 38 |
import com.spice.profitmandi.common.model.NotificationDataModel;
|
45 |
import com.spice.profitmandi.common.model.NotificationDataModel;
|
| Line 40... |
Line 47... |
| 40 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
47 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 41 |
import com.spice.profitmandi.common.util.Utils;
|
48 |
import com.spice.profitmandi.common.util.Utils;
|
| 42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
49 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 43 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
50 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
| 44 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
51 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| - |
|
52 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| - |
|
53 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
| 45 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
54 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
| 46 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
55 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
56 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
57 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| - |
|
58 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
59 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| - |
|
60 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| - |
|
61 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
| 50 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
62 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
63 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 51 |
import com.spice.profitmandi.web.model.LoginDetails;
|
64 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 52 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
65 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 53 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
66 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 54 |
|
67 |
|
| 55 |
@Controller
|
68 |
@Controller
|
| Line 62... |
Line 75... |
| 62 |
private CookiesProcessor cookiesProcessor;
|
75 |
private CookiesProcessor cookiesProcessor;
|
| 63 |
|
76 |
|
| 64 |
@Autowired
|
77 |
@Autowired
|
| 65 |
@Qualifier("fofoInventoryService")
|
78 |
@Qualifier("fofoInventoryService")
|
| 66 |
private InventoryService inventoryService;
|
79 |
private InventoryService inventoryService;
|
| 67 |
|
80 |
|
| 68 |
@Autowired
|
81 |
@Autowired
|
| 69 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
82 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 70 |
|
83 |
|
| 71 |
@Autowired
|
84 |
@Autowired
|
| 72 |
private TagRankingRepository tagRankingRepository;
|
85 |
private TagRankingRepository tagRankingRepository;
|
| 73 |
|
86 |
|
| 74 |
@Autowired
|
87 |
@Autowired
|
| - |
|
88 |
private InventoryItemRepository inventoryItemRepository;
|
| - |
|
89 |
|
| - |
|
90 |
@Autowired
|
| - |
|
91 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
| - |
|
92 |
|
| - |
|
93 |
@Autowired
|
| 75 |
private ItemRepository itemRepository;
|
94 |
private ItemRepository itemRepository;
|
| 76 |
|
95 |
|
| 77 |
@Autowired
|
96 |
@Autowired
|
| - |
|
97 |
private RetailerService retailerService;
|
| - |
|
98 |
|
| - |
|
99 |
@Autowired
|
| 78 |
private MVCResponseSender mvcResponseSender;
|
100 |
private MVCResponseSender mvcResponseSender;
|
| 79 |
|
101 |
|
| - |
|
102 |
@Autowired
|
| - |
|
103 |
FofoStoreRepository fofoStoreRepository;
|
| - |
|
104 |
|
| 80 |
@Value("${saholic.api.host}")
|
105 |
@Value("${saholic.api.host}")
|
| 81 |
private String host;
|
106 |
private String host;
|
| 82 |
|
107 |
|
| 83 |
@Value("${saholic.api.port}")
|
108 |
@Value("${saholic.api.port}")
|
| 84 |
private int port;
|
109 |
private int port;
|
| Line 138... |
Line 163... |
| 138 |
throws ProfitMandiBusinessException {
|
163 |
throws ProfitMandiBusinessException {
|
| 139 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
164 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 140 |
if (searchTerm == null) {
|
165 |
if (searchTerm == null) {
|
| 141 |
searchTerm = "";
|
166 |
searchTerm = "";
|
| 142 |
}
|
167 |
}
|
| 143 |
|
168 |
|
| 144 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
169 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
| 145 |
model.addAllAttributes(map);
|
170 |
model.addAllAttributes(map);
|
| 146 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
171 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 147 |
return "catalog";
|
172 |
return "catalog";
|
| 148 |
}
|
173 |
}
|
| 149 |
|
- |
|
| 150 |
|
174 |
|
| 151 |
//This method is currently hardcoded to faciliate watches sold as gift.
|
175 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 152 |
private boolean hasGift(int fofoId) {
|
176 |
private boolean hasGift(int fofoId) {
|
| 153 |
try {
|
177 |
try {
|
| 154 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
178 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
| - |
|
179 |
.getAvailability() > 0;
|
| 155 |
} catch (ProfitMandiBusinessException e) {
|
180 |
} catch (ProfitMandiBusinessException e) {
|
| 156 |
return false;
|
181 |
return false;
|
| 157 |
}
|
182 |
}
|
| 158 |
}
|
183 |
}
|
| 159 |
|
184 |
|
| Line 309... |
Line 334... |
| 309 |
long size = 0;
|
334 |
long size = 0;
|
| 310 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
335 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
| 311 |
size = tagRankingRepository.selectAllCount();
|
336 |
size = tagRankingRepository.selectAllCount();
|
| 312 |
LOGGER.info("tagRanking" + tagRanking);
|
337 |
LOGGER.info("tagRanking" + tagRanking);
|
| 313 |
if (!tagRanking.isEmpty()) {
|
338 |
if (!tagRanking.isEmpty()) {
|
| 314 |
model.addAttribute("tagRanking", tagRanking);
|
339 |
model.addAttribute("tagRanking", tagRanking);
|
| 315 |
model.addAttribute("start", offset + 1);
|
340 |
model.addAttribute("start", offset + 1);
|
| 316 |
model.addAttribute("size", size);
|
341 |
model.addAttribute("size", size);
|
| 317 |
model.addAttribute("url", "/getPaginatedfeature");
|
342 |
model.addAttribute("url", "/getPaginatedfeature");
|
| 318 |
|
343 |
|
| 319 |
if (tagRanking.size() < limit) {
|
344 |
if (tagRanking.size() < limit) {
|
| Line 366... |
Line 391... |
| 366 |
tagRankingRepository.persist(tagRanking);
|
391 |
tagRankingRepository.persist(tagRanking);
|
| 367 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
392 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 368 |
return "response";
|
393 |
return "response";
|
| 369 |
}
|
394 |
}
|
| 370 |
|
395 |
|
| - |
|
396 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
| - |
|
397 |
public String DemoListbyFofoId(HttpServletRequest request,
|
| - |
|
398 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
| - |
|
399 |
|
| - |
|
400 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
| - |
|
401 |
.collect(Collectors.toList());
|
| - |
|
402 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
| - |
|
403 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| - |
|
404 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
| - |
|
405 |
LOGGER.info("serailNumberList" + serailNumberList);
|
| - |
|
406 |
List<InventoryItem> inventoryItem = null;
|
| - |
|
407 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
| - |
|
408 |
if (fofoId > 0) {
|
| - |
|
409 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
| - |
|
410 |
Set<Integer> itemIds = new HashSet<>();
|
| - |
|
411 |
for (Item Item : items) {
|
| - |
|
412 |
itemIds.add(Item.getId());
|
| - |
|
413 |
}
|
| - |
|
414 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
| - |
|
415 |
|
| - |
|
416 |
Set<String> serial = new HashSet<>();
|
| - |
|
417 |
for (InventoryItem invItem : inventoryItem) {
|
| - |
|
418 |
if(!serailNumberList.contains(invItem.getSerialNumber()))
|
| - |
|
419 |
{
|
| - |
|
420 |
inventoryItem1.add(invItem);
|
| - |
|
421 |
}
|
| - |
|
422 |
|
| - |
|
423 |
}
|
| - |
|
424 |
|
| - |
|
425 |
|
| - |
|
426 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
| - |
|
427 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
428 |
model.addAttribute("liveDemo", inventoryItem1);
|
| - |
|
429 |
|
| - |
|
430 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
| - |
|
431 |
|
| - |
|
432 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| - |
|
433 |
|
| - |
|
434 |
}
|
| - |
|
435 |
|
| - |
|
436 |
else {
|
| - |
|
437 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
438 |
model.addAttribute("liveDemo", inventoryItem1);
|
| - |
|
439 |
}
|
| - |
|
440 |
|
| - |
|
441 |
return "live_demo_billing";
|
| - |
|
442 |
|
| - |
|
443 |
}
|
| - |
|
444 |
|
| - |
|
445 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
| - |
|
446 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
| - |
|
447 |
Model model) throws Exception {
|
| - |
|
448 |
|
| - |
|
449 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
| - |
|
450 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
| - |
|
451 |
|
| - |
|
452 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
| - |
|
453 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
454 |
return "response";
|
| - |
|
455 |
}
|
| - |
|
456 |
|
| 371 |
}
|
457 |
}
|