Subversion Repositories SmartDukaan

Rev

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

Rev 32648 Rev 32672
Line 43... Line 43...
43
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
43
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
44
import com.spice.profitmandi.service.offers.ItemCriteria;
44
import com.spice.profitmandi.service.offers.ItemCriteria;
45
import com.spice.profitmandi.service.pricing.PricingService;
45
import com.spice.profitmandi.service.pricing.PricingService;
46
import com.spice.profitmandi.service.scheme.SchemeService;
46
import com.spice.profitmandi.service.scheme.SchemeService;
47
import com.spice.profitmandi.service.user.RetailerService;
47
import com.spice.profitmandi.service.user.RetailerService;
48
import com.spice.profitmandi.service.wallet.WalletService;
-
 
49
import org.apache.logging.log4j.LogManager;
48
import org.apache.logging.log4j.LogManager;
50
import org.apache.logging.log4j.Logger;
49
import org.apache.logging.log4j.Logger;
51
import org.hibernate.Session;
50
import org.hibernate.Session;
52
import org.hibernate.SessionFactory;
51
import org.hibernate.SessionFactory;
53
import org.json.JSONObject;
52
import org.json.JSONObject;
Line 101... Line 100...
101
 
100
 
102
    @Autowired
101
    @Autowired
103
    private InsuranceService insuranceService;
102
    private InsuranceService insuranceService;
104
 
103
 
105
    @Autowired
104
    @Autowired
106
    private WalletService walletService;
-
 
107
 
-
 
108
    @Autowired
-
 
109
    @Qualifier("fofoCurrentInventorySnapshotRepository")
105
    @Qualifier("fofoCurrentInventorySnapshotRepository")
110
    private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
106
    private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
111
 
107
 
112
    @Autowired
108
    @Autowired
113
    private InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
109
    private InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
Line 564... Line 560...
564
        }
560
        }
565
        return fofoOrder.getId();
561
        return fofoOrder.getId();
566
    }
562
    }
567
 
563
 
568
    public void sendAppDownloadBillingOffer(String mobileNumber) throws Exception {
564
    public void sendAppDownloadBillingOffer(String mobileNumber) throws Exception {
569
        // In case of Cant receive SMS?
-
 
570
        // String mailMessage = java.text.MessageFormat.format(text, otp.getOtp());
-
 
571
        String sdurl = "http://surl.li/anhfn";
565
        String sdurl = "http://surl.li/anhfn";
572
        try {
566
        try {
573
            if (prodEnv) {
567
            if (prodEnv) {
574
                this.sendSms(APP_DOWNLOAD_BILLING_TEMPLATE_ID, String.format(APP_DOWNLOAD_BILLING_OFFER, sdurl), mobileNumber);
568
                this.sendSms(APP_DOWNLOAD_BILLING_TEMPLATE_ID, String.format(APP_DOWNLOAD_BILLING_OFFER, sdurl), mobileNumber);
575
            }
569
            }
Line 608... Line 602...
608
        if (scratchOffers.size() == 0) {
602
        if (scratchOffers.size() == 0) {
609
            ScratchOffer so2 = new ScratchOffer();
603
            ScratchOffer so2 = new ScratchOffer();
610
            so2.setInvoiceNumber(invoiceNumber);
604
            so2.setInvoiceNumber(invoiceNumber);
611
            so2.setScratched(false);
605
            so2.setScratched(false);
612
            so2.setCreatedTimestamp(LocalDateTime.now());
606
            so2.setCreatedTimestamp(LocalDateTime.now());
613
//            so2.setExpiredTimestamp(LocalDateTime.now().plusDays(5));
-
 
614
            so2.setExpiredTimestamp(ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(5).atTime(LocalTime.MAX));
607
            so2.setExpiredTimestamp(ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(5).atTime(LocalTime.MAX));
615
            so2.setOfferName(ScratchedGift.BLNT);
608
            so2.setOfferName(ScratchedGift.BLNT);
616
            so2.setCustomerId(customerId);
609
            so2.setCustomerId(customerId);
617
 
610
 
618
            LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
611
            LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
Line 638... Line 631...
638
                ProfitMandiConstants.SCRATCH_OFFER_END_DATE.atTime(Utils.MAX_TIME));
631
                ProfitMandiConstants.SCRATCH_OFFER_END_DATE.atTime(Utils.MAX_TIME));
639
 
632
 
640
        ScratchedGift gift = ScratchedGift.BLNT;
633
        ScratchedGift gift = ScratchedGift.BLNT;
641
 
634
 
642
        Random random = new Random();
635
        Random random = new Random();
643
        int rand = 0;
636
        int rand;
644
 
-
 
645
        LOGGER.info("Processing insurane for serialNumbers");
-
 
646
 
-
 
647
        while (true) {
637
        while (true) {
648
            rand = random.nextInt(4);
638
            rand = random.nextInt(4);
649
            if (rand != 0) break;
639
            if (rand != 0) break;
650
        }
640
        }
651
 
-
 
652
        LOGGER.info("rand {}", rand);
-
 
653
 
-
 
654
        if (fofoOrders.isEmpty()) {
641
        if (fofoOrders.isEmpty()) {
655
 
-
 
656
            gift = giftSeries.get(rand);
642
            gift = giftSeries.get(rand);
657
 
-
 
658
            LOGGER.info("gift11 {}", gift);
-
 
659
 
-
 
660
        } else {
643
        } else {
661
 
644
 
662
            List<String> invoiceNumbers = fofoOrders.stream().filter(x -> x.getCancelledTimestamp() == null).map(x -> x.getInvoiceNumber()).collect(Collectors.toList());
645
            List<String> invoiceNumbers = fofoOrders.stream().filter(x -> x.getCancelledTimestamp() == null).map(x -> x.getInvoiceNumber()).collect(Collectors.toList());
663
 
646
 
664
            List<ScratchOffer> scratchOffers = scratchOfferRepository.selectByInvoiceNumbers(invoiceNumbers);
647
            List<ScratchOffer> scratchOffers = scratchOfferRepository.selectByInvoiceNumbers(invoiceNumbers);