Subversion Repositories SmartDukaan

Rev

Rev 34587 | Rev 34813 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34587 Rev 34788
Line 1606... Line 1606...
1606
 
1606
 
1607
        return "response";
1607
        return "response";
1608
 
1608
 
1609
    }
1609
    }
1610
 
1610
 
-
 
1611
 
-
 
1612
    @RequestMapping(value = "/CheckIfExistCustomerOfferItem", method = RequestMethod.POST)
-
 
1613
    public String CheckIfExistCustomerOfferItem(HttpServletRequest request,
-
 
1614
                                                @RequestBody CustomerOfferItemModel customerOfferItemModel, Model model) throws Throwable {
-
 
1615
 
-
 
1616
        CustomerOffer customerOffer = customerOfferRepository.selectById(customerOfferItemModel.getOfferId());
-
 
1617
 
-
 
1618
        if (!(customerOffer.getEndDate().toLocalDate().equals(LocalDate.now()))
-
 
1619
                && customerOffer.getEndDate().isBefore(LocalDateTime.now())) {
-
 
1620
            throw new ProfitMandiBusinessException("Catalog Id", customerOffer.getOfferName(), "Offer is Expired");
-
 
1621
 
-
 
1622
        }
-
 
1623
 
-
 
1624
        List<CustomerOfferItem> customerOfferItems = customerOfferItemRepository
-
 
1625
                .selectByOfferAndCatalogId(customerOfferItemModel.getOfferId(), customerOfferItemModel.getCatalogId());
-
 
1626
        boolean response = true;
-
 
1627
        if (!customerOfferItems.isEmpty()) {
-
 
1628
            for (CustomerOfferItem coi : customerOfferItems) {
-
 
1629
                if (!(coi.getEndDate().equals(LocalDate.now())) && coi.getEndDate().isAfter(LocalDate.now())) {
-
 
1630
                    response = false;
-
 
1631
 
-
 
1632
                }
-
 
1633
            }
-
 
1634
        }
-
 
1635
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
-
 
1636
        return "response";
-
 
1637
 
-
 
1638
    }
-
 
1639
 
1611
    @RequestMapping(value = "/addCustomerOfferItem", method = RequestMethod.POST)
1640
    @RequestMapping(value = "/addCustomerOfferItem", method = RequestMethod.POST)
1612
    public String addCustomerOfferItem(HttpServletRequest request,
1641
    public String addCustomerOfferItem(HttpServletRequest request,
1613
                                       @RequestBody CustomerOfferItemModel customerOfferItemModel, Model model) throws Throwable {
1642
                                       @RequestBody CustomerOfferItemModel customerOfferItemModel, Model model) throws Throwable {
1614
 
1643
 
1615
        CustomerOffer customerOffer = customerOfferRepository.selectById(customerOfferItemModel.getOfferId());
1644
        CustomerOffer customerOffer = customerOfferRepository.selectById(customerOfferItemModel.getOfferId());
Line 1618... Line 1647...
1618
                && customerOffer.getEndDate().isBefore(LocalDateTime.now())) {
1647
                && customerOffer.getEndDate().isBefore(LocalDateTime.now())) {
1619
            throw new ProfitMandiBusinessException("Catalog Id", customerOffer.getOfferName(), "Offer is Expired");
1648
            throw new ProfitMandiBusinessException("Catalog Id", customerOffer.getOfferName(), "Offer is Expired");
1620
 
1649
 
1621
        }
1650
        }
1622
 
1651
 
1623
        List<CustomerOfferItem> customerOfferItems = customerOfferItemRepository
1652
       /* List<CustomerOfferItem> customerOfferItems = customerOfferItemRepository
1624
                .selectByOfferAndCatalogId(customerOfferItemModel.getOfferId(), customerOfferItemModel.getCatalogId());
1653
                .selectByOfferAndCatalogId(customerOfferItemModel.getOfferId(), customerOfferItemModel.getCatalogId());
1625
 
1654
 
1626
        if (!customerOfferItems.isEmpty()) {
1655
        if (!customerOfferItems.isEmpty()) {
1627
 
1656
 
1628
            for (CustomerOfferItem coi : customerOfferItems) {
1657
            for (CustomerOfferItem coi : customerOfferItems) {
1629
                if (!(coi.getEndDate().equals(LocalDate.now())) && coi.getEndDate().isAfter(LocalDate.now())) {
1658
                if (!(coi.getEndDate().equals(LocalDate.now())) && coi.getEndDate().isAfter(LocalDate.now())) {
1630
                    throw new ProfitMandiBusinessException("Catalog Id", coi.getCatalogId(), "Item is already exist.");
1659
                    throw new ProfitMandiBusinessException("Catalog Id", coi.getCatalogId(), "Item is already exist.");
1631
                }
1660
                }
1632
            }
1661
            }
1633
 
1662
 
1634
        }
1663
        }*/
1635
 
1664
 
1636
        LocalDate startDate = customerOfferItemModel.getStartDate().toLocalDate();
1665
        LocalDate startDate = customerOfferItemModel.getStartDate().toLocalDate();
1637
        LocalDate endDate = customerOfferItemModel.getEndDate().toLocalDate();
1666
        LocalDate endDate = customerOfferItemModel.getEndDate().toLocalDate();
1638
        CustomerOfferItem coi = new CustomerOfferItem();
1667
        CustomerOfferItem coi = new CustomerOfferItem();
1639
        coi.setCatalogId(customerOfferItemModel.getCatalogId());
1668
        coi.setCatalogId(customerOfferItemModel.getCatalogId());