| Line 26... |
Line 26... |
| 26 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
26 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
27 |
import com.spice.profitmandi.dao.repository.catalog.CategoryRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
|
| 31 |
import com.spice.profitmandi.dao.repository.cs.*;
|
32 |
import com.spice.profitmandi.dao.repository.cs.*;
|
| 32 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
33 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
35 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 35 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
36 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| Line 155... |
Line 156... |
| 155 |
|
156 |
|
| 156 |
@Autowired
|
157 |
@Autowired
|
| 157 |
private TagListingRepository tagListingRepository;
|
158 |
private TagListingRepository tagListingRepository;
|
| 158 |
|
159 |
|
| 159 |
@Autowired
|
160 |
@Autowired
|
| - |
|
161 |
private TagListingEventPublisher tagListingEventPublisher;
|
| - |
|
162 |
|
| - |
|
163 |
@Autowired
|
| 160 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
164 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 161 |
|
165 |
|
| 162 |
@Autowired
|
166 |
@Autowired
|
| 163 |
private PurchaseRepository purchaseRepository;
|
167 |
private PurchaseRepository purchaseRepository;
|
| 164 |
|
168 |
|
| Line 574... |
Line 578... |
| 574 |
// Clean up the saholic cis table
|
578 |
// Clean up the saholic cis table
|
| 575 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
579 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
| 576 |
public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
580 |
public String updateTagListing(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| 577 |
throws Exception {
|
581 |
throws Exception {
|
| 578 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
582 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| - |
|
583 |
Set<Integer> updatedCatalogIds = new HashSet<>();
|
| - |
|
584 |
|
| 579 |
for (int i = 0; i < jsonArray.length(); i++) {
|
585 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| 580 |
JSONObject obj = jsonArray.getJSONObject(i);
|
586 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| 581 |
|
- |
|
| - |
|
587 |
int itemId = obj.getInt("id");
|
| 582 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
588 |
TagListing tl = tagListingRepository.selectByItemId(itemId);
|
| 583 |
if (tl == null) {
|
589 |
if (tl == null) {
|
| 584 |
continue;
|
590 |
continue;
|
| 585 |
} else {
|
591 |
} else {
|
| 586 |
tl.setActive(obj.getBoolean("active"));
|
592 |
tl.setActive(obj.getBoolean("active"));
|
| 587 |
if (!tl.isActive()) {
|
593 |
if (!tl.isActive()) {
|
| 588 |
saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream()
|
594 |
saholicCISTableRepository.selectAllByItemId(tl.getItemId()).stream()
|
| 589 |
.forEach(x -> saholicCISTableRepository.delete(x));
|
595 |
.forEach(x -> saholicCISTableRepository.delete(x));
|
| 590 |
}
|
596 |
}
|
| - |
|
597 |
// Collect catalogIds for Solr updates
|
| - |
|
598 |
try {
|
| - |
|
599 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
600 |
updatedCatalogIds.add(item.getCatalogItemId());
|
| - |
|
601 |
} catch (Exception e) {
|
| - |
|
602 |
LOGGER.error("Failed to get catalogId for itemId: {}", itemId, e);
|
| - |
|
603 |
}
|
| - |
|
604 |
}
|
| - |
|
605 |
}
|
| - |
|
606 |
|
| - |
|
607 |
// Publish events for all updated catalogs
|
| - |
|
608 |
for (Integer catalogId : updatedCatalogIds) {
|
| - |
|
609 |
try {
|
| - |
|
610 |
tagListingEventPublisher.publishStatusChange(0, catalogId);
|
| - |
|
611 |
} catch (Exception e) {
|
| - |
|
612 |
LOGGER.error("Failed to publish status change event for catalogId: {}", catalogId, e);
|
| 591 |
}
|
613 |
}
|
| 592 |
}
|
614 |
}
|
| - |
|
615 |
|
| 593 |
model.addAttribute("response1", true);
|
616 |
model.addAttribute("response1", true);
|
| 594 |
return "response";
|
617 |
return "response";
|
| 595 |
}
|
618 |
}
|
| 596 |
|
619 |
|
| 597 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
620 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
| 598 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
621 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| 599 |
throws Exception {
|
622 |
throws Exception {
|
| 600 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
623 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| - |
|
624 |
Set<Integer> updatedCatalogIds = new HashSet<>();
|
| - |
|
625 |
|
| 601 |
for (int i = 0; i < jsonArray.length(); i++) {
|
626 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| 602 |
JSONObject obj = jsonArray.getJSONObject(i);
|
627 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| 603 |
|
- |
|
| - |
|
628 |
int itemId = obj.getInt("id");
|
| 604 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
629 |
TagListing tl = tagListingRepository.selectByItemId(itemId);
|
| 605 |
if (tl == null) {
|
630 |
if (tl == null) {
|
| 606 |
continue;
|
631 |
continue;
|
| 607 |
} else {
|
632 |
} else {
|
| 608 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
633 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
| 609 |
tagListingRepository.persist(tl);
|
634 |
tagListingRepository.persist(tl);
|
| - |
|
635 |
// Collect catalogIds for Solr updates
|
| - |
|
636 |
try {
|
| - |
|
637 |
Item item = itemRepository.selectById(itemId);
|
| - |
|
638 |
updatedCatalogIds.add(item.getCatalogItemId());
|
| - |
|
639 |
} catch (Exception e) {
|
| - |
|
640 |
LOGGER.error("Failed to get catalogId for itemId: {}", itemId, e);
|
| - |
|
641 |
}
|
| 610 |
}
|
642 |
}
|
| 611 |
}
|
643 |
}
|
| - |
|
644 |
|
| - |
|
645 |
// Publish events for all updated catalogs
|
| - |
|
646 |
for (Integer catalogId : updatedCatalogIds) {
|
| - |
|
647 |
try {
|
| - |
|
648 |
tagListingEventPublisher.publishStatusChange(0, catalogId);
|
| - |
|
649 |
} catch (Exception e) {
|
| - |
|
650 |
LOGGER.error("Failed to publish status change event for catalogId: {}", catalogId, e);
|
| - |
|
651 |
}
|
| - |
|
652 |
}
|
| - |
|
653 |
|
| 612 |
model.addAttribute("response1", true);
|
654 |
model.addAttribute("response1", true);
|
| 613 |
return "response";
|
655 |
return "response";
|
| 614 |
}
|
656 |
}
|
| 615 |
|
657 |
|
| 616 |
private void createPayment(User user, double totalAmount, long transactionId)
|
658 |
private void createPayment(User user, double totalAmount, long transactionId)
|