Subversion Repositories SmartDukaan

Rev

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

Rev 32596 Rev 32599
Line 600... Line 600...
600
 
600
 
601
        //ScratchedGift gift = getScratchedGiftRandom(fofoId, customerId);
601
        //ScratchedGift gift = getScratchedGiftRandom(fofoId, customerId);
602
 
602
 
603
 
603
 
604
        //  LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
604
        //  LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
-
 
605
        List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(customerId, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
-
 
606
        if(scratchOffers.size() > 0) {
-
 
607
            ScratchOffer so2 = new ScratchOffer();
-
 
608
            so2.setInvoiceNumber(invoiceNumber);
-
 
609
            so2.setScratched(false);
-
 
610
            so2.setCreatedTimestamp(LocalDateTime.now());
-
 
611
            so2.setExpiredTimestamp(LocalDateTime.now().plusDays(1));
-
 
612
            so2.setOfferName(ScratchedGift.BLNT);
-
 
613
            so2.setCustomerId(customerId);
605
 
614
 
606
        ScratchOffer so2 = new ScratchOffer();
-
 
607
        so2.setInvoiceNumber(invoiceNumber);
-
 
608
        so2.setScratched(false);
-
 
609
        so2.setCreatedTimestamp(LocalDateTime.now());
-
 
610
        so2.setExpiredTimestamp(LocalDateTime.now().plusDays(1));
-
 
611
        so2.setOfferName(ScratchedGift.BLNT);
-
 
612
        so2.setCustomerId(customerId);
-
 
613
        //so2.setUnlockedAt(LocalDateTime.now());
-
 
614
        //LocalDate date = LocalDate.now();
-
 
615
 
-
 
616
        LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
615
            LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
617
        LocalDateTime today9PM = LocalDate.now().atTime(21, 0);
616
            LocalDateTime today9PM = LocalDate.now().atTime(21, 0);
618
        ;
-
 
619
 
617
 
620
        if (LocalDateTime.now().isAfter(today830PM)) {
618
            if (LocalDateTime.now().isAfter(today830PM)) {
621
            so2.setUnlockedAt(today9PM.plusDays(1));
619
                so2.setUnlockedAt(today9PM.plusDays(1));
622
        } else {
620
            } else {
623
            so2.setUnlockedAt(today9PM);
621
                so2.setUnlockedAt(today9PM);
-
 
622
            }
-
 
623
            scratchOfferRepository.persist(so2);
624
        }
624
        }
625
 
-
 
626
 
-
 
627
        scratchOfferRepository.persist(so2);
-
 
628
 
-
 
629
/*
-
 
630
 
-
 
631
        ScratchOffer so = new ScratchOffer();
-
 
632
        so.setInvoiceNumber(invoiceNumber);
-
 
633
        so.setOfferName(ScratchedGift.EW);
-
 
634
        so.setScratched(false);
-
 
635
        so.setCreatedTimestamp(LocalDateTime.now());
-
 
636
        so.setExpiredTimestamp(so.getCreatedTimestamp().plusDays(1));
-
 
637
        so.setUnlockedAt(LocalDateTime.now());
-
 
638
        so.setCustomerId(customerId);
-
 
639
        scratchOfferRepository.persist(so);
-
 
640
*/
-
 
641
 
-
 
642
 
-
 
643
    }
625
    }
644
 
626
 
645
    private ScratchedGift getScratchedGiftRandom(int fofoId, int customerId) {
627
    private ScratchedGift getScratchedGiftRandom(int fofoId, int customerId) {
646
        Map<Integer, ScratchedGift> giftSeries = new HashMap<>();
628
        Map<Integer, ScratchedGift> giftSeries = new HashMap<>();
647
        giftSeries.put(1, ScratchedGift.MINI_CHOPPER);
629
        giftSeries.put(1, ScratchedGift.MINI_CHOPPER);
Line 674... Line 656...
674
 
656
 
675
        } else {
657
        } else {
676
 
658
 
677
            List<String> invoiceNumbers = fofoOrders.stream().filter(x -> x.getCancelledTimestamp() == null).map(x -> x.getInvoiceNumber()).collect(Collectors.toList());
659
            List<String> invoiceNumbers = fofoOrders.stream().filter(x -> x.getCancelledTimestamp() == null).map(x -> x.getInvoiceNumber()).collect(Collectors.toList());
678
 
660
 
679
 
-
 
680
            List<ScratchOffer> scratchOffers = scratchOfferRepository.selectByInvoiceNumbers(invoiceNumbers);
661
            List<ScratchOffer> scratchOffers = scratchOfferRepository.selectByInvoiceNumbers(invoiceNumbers);
681
 
-
 
682
 
-
 
683
            if (scratchOffers.isEmpty()) {
662
            if (scratchOffers.isEmpty()) {
684
 
-
 
685
                gift = giftSeries.get(rand);
663
                gift = giftSeries.get(rand);
686
                LOGGER.info("gift3 {}", gift);
-
 
687
 
-
 
688
 
-
 
689
            } else {
664
            } else {
690
 
-
 
691
                List<ScratchOffer> bigGifts = scratchOffers.stream().filter(x -> !x.getOfferName().equals(ScratchedGift.BLNT) && !x.getOfferName().equals(ScratchedGift.EW)).collect(Collectors.toList());
665
                List<ScratchOffer> bigGifts = scratchOffers.stream().filter(x -> !x.getOfferName().equals(ScratchedGift.BLNT) && !x.getOfferName().equals(ScratchedGift.EW)).collect(Collectors.toList());
692
                LOGGER.info("bigGifts {}", bigGifts);
-
 
693
 
-
 
694
                if (bigGifts.size() <= 10) {
666
                if (bigGifts.size() <= 10) {
695
                    List<Integer> scratchCustomerIds = scratchOffers.stream().map(x -> x.getCustomerId()).collect(Collectors.toList());
667
                    List<Integer> scratchCustomerIds = scratchOffers.stream().map(x -> x.getCustomerId()).collect(Collectors.toList());
696
 
-
 
697
                    if (scratchCustomerIds.contains(customerId)) {
668
                    if (scratchCustomerIds.contains(customerId)) {
698
 
669
 
699
 
670
 
700
                        gift = ScratchedGift.BLNT;
671
                        gift = ScratchedGift.BLNT;
701
 
672
 
Line 704... Line 675...
704
                    } else {
675
                    } else {
705
 
676
 
706
                        int miniChopper = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.MINI_CHOPPER)).count();
677
                        int miniChopper = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.MINI_CHOPPER)).count();
707
                        int fruitJuicer = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.FRUIT_JUICER)).count();
678
                        int fruitJuicer = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.FRUIT_JUICER)).count();
708
                        int streanIron = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.STEAM_IRON)).count();
679
                        int streanIron = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.STEAM_IRON)).count();
709
                        LOGGER.info("miniChopper {}", miniChopper);
-
 
710
 
-
 
711
                        LOGGER.info("fruitJuicer {}", fruitJuicer);
-
 
712
 
-
 
713
 
-
 
714
                        LOGGER.info("streanIron {}", streanIron);
-
 
715
 
-
 
716
 
680
 
717
                        if (rand == 1) {
681
                        if (rand == 1) {
718
                            if (miniChopper < 4) {
682
                            if (miniChopper < 4) {
719
                                LOGGER.info("miniChopper {}", miniChopper);
683
                                LOGGER.info("miniChopper {}", miniChopper);
720
 
684