Subversion Repositories SmartDukaan

Rev

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

Rev 32145 Rev 32218
Line 1... Line 1...
1
package com.spice.profitmandi.service.order;
1
package com.spice.profitmandi.service.order;
2
 
2
 
-
 
3
import java.io.ByteArrayInputStream;
-
 
4
import java.io.InputStream;
-
 
5
import java.time.LocalDate;
-
 
6
import java.time.LocalDateTime;
-
 
7
import java.time.LocalTime;
-
 
8
import java.util.AbstractMap.SimpleEntry;
-
 
9
import java.util.ArrayList;
-
 
10
import java.util.Arrays;
-
 
11
import java.util.HashMap;
-
 
12
import java.util.HashSet;
-
 
13
import java.util.Iterator;
-
 
14
import java.util.List;
-
 
15
import java.util.Map;
-
 
16
import java.util.Optional;
-
 
17
import java.util.Random;
-
 
18
import java.util.Set;
-
 
19
import java.util.function.Function;
-
 
20
import java.util.stream.Collectors;
-
 
21
 
-
 
22
import javax.persistence.criteria.CriteriaBuilder;
-
 
23
import javax.persistence.criteria.CriteriaQuery;
-
 
24
import javax.persistence.criteria.Predicate;
-
 
25
import javax.persistence.criteria.Root;
-
 
26
 
-
 
27
import org.apache.logging.log4j.LogManager;
-
 
28
import org.apache.logging.log4j.Logger;
-
 
29
import org.hibernate.Session;
-
 
30
import org.hibernate.SessionFactory;
-
 
31
import org.json.JSONObject;
-
 
32
import org.springframework.beans.factory.annotation.Autowired;
-
 
33
import org.springframework.beans.factory.annotation.Qualifier;
-
 
34
import org.springframework.beans.factory.annotation.Value;
-
 
35
import org.springframework.cache.annotation.Cacheable;
-
 
36
import org.springframework.core.io.InputStreamResource;
-
 
37
import org.springframework.http.HttpHeaders;
-
 
38
import org.springframework.http.HttpStatus;
-
 
39
import org.springframework.http.ResponseEntity;
-
 
40
import org.springframework.stereotype.Component;
-
 
41
 
3
import com.spice.profitmandi.common.enumuration.ItemType;
42
import com.spice.profitmandi.common.enumuration.ItemType;
4
import com.spice.profitmandi.common.enumuration.SearchType;
43
import com.spice.profitmandi.common.enumuration.SearchType;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
44
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
45
import com.spice.profitmandi.common.model.BadReturnRequest;
-
 
46
import com.spice.profitmandi.common.model.CartFofo;
-
 
47
import com.spice.profitmandi.common.model.CreateOrderRequest;
-
 
48
import com.spice.profitmandi.common.model.CreditNotePdfModel;
-
 
49
import com.spice.profitmandi.common.model.CustomAddress;
-
 
50
import com.spice.profitmandi.common.model.CustomCustomer;
-
 
51
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
-
 
52
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
-
 
53
import com.spice.profitmandi.common.model.CustomOrderItem;
-
 
54
import com.spice.profitmandi.common.model.CustomPaymentOption;
-
 
55
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
56
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
6
import com.spice.profitmandi.common.model.*;
57
import com.spice.profitmandi.common.model.GstRate;
-
 
58
import com.spice.profitmandi.common.model.InsuranceModel;
-
 
59
import com.spice.profitmandi.common.model.InvoicePdfModel;
-
 
60
import com.spice.profitmandi.common.model.ItemIdQuantityAvailability;
-
 
61
import com.spice.profitmandi.common.model.PriceModel;
-
 
62
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
63
import com.spice.profitmandi.common.model.Quantity;
-
 
64
import com.spice.profitmandi.common.model.SerialNumberDetail;
7
import com.spice.profitmandi.common.util.FormattingUtils;
65
import com.spice.profitmandi.common.util.FormattingUtils;
8
import com.spice.profitmandi.common.util.StringUtils;
66
import com.spice.profitmandi.common.util.StringUtils;
9
import com.spice.profitmandi.common.util.Utils;
67
import com.spice.profitmandi.common.util.Utils;
10
import com.spice.profitmandi.common.web.client.RestClient;
68
import com.spice.profitmandi.common.web.client.RestClient;
11
import com.spice.profitmandi.dao.entity.catalog.Item;
69
import com.spice.profitmandi.dao.entity.catalog.Item;
12
import com.spice.profitmandi.dao.entity.catalog.TagListing;
70
import com.spice.profitmandi.dao.entity.catalog.TagListing;
-
 
71
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
-
 
72
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
-
 
73
import com.spice.profitmandi.dao.entity.dtr.Retailer;
-
 
74
import com.spice.profitmandi.dao.entity.dtr.ScratchOffer;
13
import com.spice.profitmandi.dao.entity.dtr.*;
75
import com.spice.profitmandi.dao.entity.dtr.User;
-
 
76
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
14
import com.spice.profitmandi.dao.entity.fofo.*;
77
import com.spice.profitmandi.dao.entity.fofo.Customer;
-
 
78
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
-
 
79
import com.spice.profitmandi.dao.entity.fofo.CustomerCreditNote;
-
 
80
import com.spice.profitmandi.dao.entity.fofo.CustomerReturnItem;
-
 
81
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
-
 
82
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
-
 
83
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
-
 
84
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
-
 
85
import com.spice.profitmandi.dao.entity.fofo.HygieneData;
-
 
86
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
-
 
87
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
-
 
88
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
-
 
89
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
-
 
90
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
-
 
91
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
15
import com.spice.profitmandi.dao.entity.inventory.State;
92
import com.spice.profitmandi.dao.entity.inventory.State;
16
import com.spice.profitmandi.dao.entity.transaction.Order;
93
import com.spice.profitmandi.dao.entity.transaction.Order;
17
import com.spice.profitmandi.dao.entity.user.Address;
94
import com.spice.profitmandi.dao.entity.user.Address;
18
import com.spice.profitmandi.dao.entity.user.Counter;
95
import com.spice.profitmandi.dao.entity.user.Counter;
19
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
96
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
Line 26... Line 103...
26
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
103
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
27
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
104
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
28
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
105
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
29
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
106
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
30
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
107
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
-
 
108
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
109
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
-
 
110
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
31
import com.spice.profitmandi.dao.repository.dtr.*;
111
import com.spice.profitmandi.dao.repository.dtr.Mongo;
-
 
112
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
-
 
113
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
-
 
114
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
-
 
115
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
-
 
116
import com.spice.profitmandi.dao.repository.dtr.ScratchOfferRepository;
-
 
117
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
32
import com.spice.profitmandi.dao.repository.fofo.*;
118
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
-
 
119
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
-
 
120
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
-
 
121
import com.spice.profitmandi.dao.repository.fofo.CustomerCreditNoteRepository;
-
 
122
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
-
 
123
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
-
 
124
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
-
 
125
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
-
 
126
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
-
 
127
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
-
 
128
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
-
 
129
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
-
 
130
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
-
 
131
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
-
 
132
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
-
 
133
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
-
 
134
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
-
 
135
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
33
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
136
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
34
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
137
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
35
import com.spice.profitmandi.dao.repository.user.AddressRepository;
138
import com.spice.profitmandi.dao.repository.user.AddressRepository;
36
import com.spice.profitmandi.dao.repository.user.CounterRepository;
139
import com.spice.profitmandi.dao.repository.user.CounterRepository;
37
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
140
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
Line 44... Line 147...
44
import com.spice.profitmandi.service.offers.ItemCriteria;
147
import com.spice.profitmandi.service.offers.ItemCriteria;
45
import com.spice.profitmandi.service.pricing.PricingService;
148
import com.spice.profitmandi.service.pricing.PricingService;
46
import com.spice.profitmandi.service.scheme.SchemeService;
149
import com.spice.profitmandi.service.scheme.SchemeService;
47
import com.spice.profitmandi.service.user.RetailerService;
150
import com.spice.profitmandi.service.user.RetailerService;
48
import com.spice.profitmandi.service.wallet.WalletService;
151
import com.spice.profitmandi.service.wallet.WalletService;
49
import org.apache.logging.log4j.LogManager;
-
 
50
import org.apache.logging.log4j.Logger;
-
 
51
import org.hibernate.Session;
-
 
52
import org.hibernate.SessionFactory;
-
 
53
import org.json.JSONObject;
-
 
54
import org.springframework.beans.factory.annotation.Autowired;
-
 
55
import org.springframework.beans.factory.annotation.Qualifier;
-
 
56
import org.springframework.beans.factory.annotation.Value;
-
 
57
import org.springframework.cache.annotation.Cacheable;
-
 
58
import org.springframework.core.io.InputStreamResource;
-
 
59
import org.springframework.http.HttpHeaders;
-
 
60
import org.springframework.http.HttpStatus;
-
 
61
import org.springframework.http.ResponseEntity;
-
 
62
import org.springframework.stereotype.Component;
-
 
63
 
-
 
64
import javax.persistence.criteria.CriteriaBuilder;
-
 
65
import javax.persistence.criteria.CriteriaQuery;
-
 
66
import javax.persistence.criteria.Predicate;
-
 
67
import javax.persistence.criteria.Root;
-
 
68
import java.io.ByteArrayInputStream;
-
 
69
import java.io.InputStream;
-
 
70
import java.time.LocalDate;
-
 
71
import java.time.LocalDateTime;
-
 
72
import java.time.LocalTime;
-
 
73
import java.util.AbstractMap.SimpleEntry;
-
 
74
import java.util.*;
-
 
75
import java.util.function.Function;
-
 
76
import java.util.stream.Collectors;
-
 
77
 
152
 
78
@Component
153
@Component
79
public class OrderServiceImpl implements OrderService {
154
public class OrderServiceImpl implements OrderService {
80
 
155
 
81
    private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
156
    private static final Logger LOGGER = LogManager.getLogger(OrderServiceImpl.class);
Line 541... Line 616...
541
            PendingOrderItem poi = pendingOrderItemRepository.selectById(createOrderRequest.getPoItemId());
616
            PendingOrderItem poi = pendingOrderItemRepository.selectById(createOrderRequest.getPoItemId());
542
            poi.setStatus(OrderStatus.BILLED);
617
            poi.setStatus(OrderStatus.BILLED);
543
            poi.setBilledTimestamp(LocalDateTime.now());
618
            poi.setBilledTimestamp(LocalDateTime.now());
544
        }
619
        }
545
 
620
 
546
        LocalDate startDate = LocalDate.of(2023, 01, 13);
621
        LocalDate startDate = LocalDate.of(2023, 07, 22);
547
        LocalDate endDate = LocalDate.of(2023, 01, 27);
622
        LocalDate endDate = LocalDate.of(2023, 07, 23);
-
 
623
 
548
 
624
 
549
        if (smartPhone) {
625
        if (smartPhone) {
-
 
626
            LOGGER.error("hellloooo23 {}", "kjhkjhkjhkjhkjhkjh23");
-
 
627
 
550
            if (LocalDateTime.now().isAfter(startDate.atStartOfDay()) && LocalDateTime.now().isBefore(endDate.atStartOfDay())) {
628
            if (LocalDateTime.now().isAfter(startDate.atStartOfDay()) && LocalDateTime.now().isBefore(endDate.atStartOfDay())) {
551
 
629
 
552
                try {
630
                try {
553
                    this.sendAppDownloadBillingOffer(customer.getMobileNumber());
631
                    this.sendAppDownloadBillingOffer(customer.getMobileNumber());
554
                } catch (Exception e) {
632
                } catch (Exception e) {
555
                    // TODO Auto-generated catch block
633
                    // TODO Auto-generated catch block
556
                    e.printStackTrace();
634
                    e.printStackTrace();
557
                }
635
                }
-
 
636
                LOGGER.info("hellloooo {}", "kjhkjhkjhkjhkjhkjh");
-
 
637
 
558
                this.createScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
638
                this.createScratchOffer(fofoId, fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
559
            }
639
            }
560
        }
640
        }
561
        return fofoOrder.getId();
641
        return fofoOrder.getId();
562
    }
642
    }
563
 
643
 
Line 591... Line 671...
591
        String response = restClient.post(SMS_GATEWAY, map, new HashMap<>());
671
        String response = restClient.post(SMS_GATEWAY, map, new HashMap<>());
592
        LOGGER.info(response);
672
        LOGGER.info(response);
593
 
673
 
594
    }
674
    }
595
 
675
 
596
    private void createScratchOffer(String invoiceNumber, int customerId) {
-
 
597
 
676
 
-
 
677
    private void createScratchOffer(int fofoId, String invoiceNumber, int customerId) {
-
 
678
 
-
 
679
        Map<Integer, ScratchedGift> giftSeries = new HashMap<>();
-
 
680
        giftSeries.put(1, ScratchedGift.MINI_CHOPPER);
-
 
681
        giftSeries.put(2, ScratchedGift.FRUIT_JUICER);
-
 
682
        giftSeries.put(3, ScratchedGift.STEAM_IRON);
-
 
683
 
-
 
684
        LocalDate startDate = LocalDate.of(2023, 07, 22);
-
 
685
        LocalDate endDate = LocalDate.of(2023, 07, 23);
-
 
686
 
-
 
687
 
-
 
688
        List<FofoOrder> fofoOrders = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(fofoId, startDate.atStartOfDay(), endDate.atStartOfDay());
-
 
689
        ScratchedGift gift = ScratchedGift.BLNT;
-
 
690
 
-
 
691
        Random random = new Random();
-
 
692
        int rand = 0;
-
 
693
 
-
 
694
        LOGGER.info("Processing insurane for serialNumbers");
-
 
695
 
-
 
696
        while (true) {
-
 
697
            rand = random.nextInt(4);
-
 
698
            if (rand != 0) break;
598
        /*
699
        }
-
 
700
 
-
 
701
        LOGGER.info("rand {}", rand);
-
 
702
 
-
 
703
        if (fofoOrders.isEmpty()) {
-
 
704
 
-
 
705
            gift = giftSeries.get(rand);
-
 
706
 
-
 
707
            LOGGER.info("gift11 {}", gift);
-
 
708
 
-
 
709
        } else {
-
 
710
 
-
 
711
            List<String> invoiceNumbers = fofoOrders.stream().filter(x -> x.getCancelledTimestamp() == null).map(x -> x.getInvoiceNumber()).collect(Collectors.toList());
-
 
712
 
-
 
713
 
599
         * ScratchOffer so = new ScratchOffer(); so.setInvoiceNumber(invoiceNumber);
714
            List<ScratchOffer> scratchOffers = scratchOfferRepository.selectByInvoiceNumbers(invoiceNumbers);
-
 
715
 
-
 
716
 
-
 
717
            if (scratchOffers.isEmpty()) {
-
 
718
 
-
 
719
                gift = giftSeries.get(rand);
-
 
720
                LOGGER.info("gift3 {}", gift);
-
 
721
 
-
 
722
 
-
 
723
            } else {
-
 
724
 
-
 
725
                List<ScratchOffer> bigGifts = scratchOffers.stream().filter(x -> !x.getOfferName().equals(ScratchedGift.BLNT) && !x.getOfferName().equals(ScratchedGift.EW)).collect(Collectors.toList());
-
 
726
                LOGGER.info("bigGifts {}", bigGifts);
-
 
727
 
-
 
728
                if (bigGifts.size() <= 10) {
-
 
729
                    List<Integer> scratchCustomerIds = scratchOffers.stream().map(x -> x.getCustomerId()).collect(Collectors.toList());
-
 
730
 
600
         * so.setOfferName(ScratchedGift.EW); so.setScratched(false);
731
                    if (scratchCustomerIds.contains(customerId)) {
-
 
732
 
-
 
733
 
601
         * so.setCreatedTimestamp(LocalDateTime.now());
734
                        gift = ScratchedGift.BLNT;
-
 
735
 
-
 
736
                        LOGGER.info("gift2 {}", gift);
-
 
737
 
-
 
738
                    } else {
-
 
739
 
-
 
740
                        int miniChopper = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.MINI_CHOPPER)).count();
-
 
741
                        int fruitJuicer = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.FRUIT_JUICER)).count();
-
 
742
                        int streanIron = (int) bigGifts.stream().filter(x -> x.getOfferName().equals(ScratchedGift.STEAM_IRON)).count();
-
 
743
                        LOGGER.info("miniChopper {}", miniChopper);
-
 
744
 
602
         * so.setExpiredTimestamp(so.getCreatedTimestamp().plusDays(1));
745
                        LOGGER.info("fruitJuicer {}", fruitJuicer);
-
 
746
 
-
 
747
 
-
 
748
                        LOGGER.info("streanIron {}", streanIron);
-
 
749
 
-
 
750
 
-
 
751
                        if (rand == 1) {
-
 
752
                            if (miniChopper < 4) {
-
 
753
                                LOGGER.info("miniChopper {}", miniChopper);
-
 
754
 
-
 
755
 
-
 
756
                                gift = giftSeries.get(rand);
-
 
757
                            }
-
 
758
                        }
-
 
759
 
-
 
760
                        if (rand == 2) {
-
 
761
                            if (fruitJuicer < 3) {
-
 
762
 
603
         * so.setUnlockedAt(LocalDateTime.now()); so.setCustomerId(customerId);
763
                                LOGGER.info("fruitJuicer {}", fruitJuicer);
-
 
764
 
-
 
765
                                gift = giftSeries.get(rand);
-
 
766
                            }
-
 
767
                        }
-
 
768
 
-
 
769
                        if (rand == 3) {
604
         * scratchOfferRepository.persist(so);
770
                            if (streanIron < 3) {
-
 
771
 
-
 
772
                                LOGGER.info("streanIron {}", streanIron);
-
 
773
 
-
 
774
 
-
 
775
                                gift = giftSeries.get(rand);
-
 
776
 
-
 
777
                            }
-
 
778
                        }
-
 
779
 
-
 
780
                        LOGGER.info("gift4 {}", gift);
-
 
781
                    }
-
 
782
                }
-
 
783
            }
-
 
784
 
-
 
785
 
605
         */
786
        }
-
 
787
 
-
 
788
 
606
        LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
789
        //  LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
607
 
790
 
608
        ScratchOffer so2 = new ScratchOffer();
791
        ScratchOffer so2 = new ScratchOffer();
609
        so2.setInvoiceNumber(invoiceNumber);
792
        so2.setInvoiceNumber(invoiceNumber);
610
        so2.setScratched(false);
793
        so2.setScratched(false);
611
        so2.setCreatedTimestamp(LocalDateTime.now());
794
        so2.setCreatedTimestamp(LocalDateTime.now());
612
        so2.setExpiredTimestamp(endDate.plusDays(1).toLocalDate().atTime(LocalTime.MAX));
795
        so2.setExpiredTimestamp(LocalDateTime.now().plusDays(1));
613
        so2.setOfferName(ScratchedGift.BLNT);
796
        so2.setOfferName(gift);
614
        so2.setCustomerId(customerId);
797
        so2.setCustomerId(customerId);
615
 
-
 
-
 
798
        so2.setUnlockedAt(LocalDateTime.now());
616
        LocalDate date = LocalDate.now();
799
        LocalDate date = LocalDate.now();
617
        LocalDateTime seven = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(), 19, 0);
800
        /* LocalDateTime seven = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(), 19, 0);
618
        LocalDateTime nine = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(), 21, 0);
801
        LocalDateTime nine = LocalDateTime.of(date.getYear(), date.getMonth(), date.getDayOfMonth(), 21, 0);
619
 
802
        
620
        if (LocalDateTime.now().isAfter(seven)) {
803
        if (LocalDateTime.now().isAfter(seven)) {
621
            so2.setUnlockedAt(nine.plusDays(1));
804
        so2.setUnlockedAt(nine.plusDays(1));
622
        } else {
805
        } else {
623
            so2.setUnlockedAt(nine);
806
        so2.setUnlockedAt(nine);
624
        }
807
        }*/
-
 
808
 
625
 
809
 
626
        scratchOfferRepository.persist(so2);
810
        scratchOfferRepository.persist(so2);
627
 
811
 
-
 
812
 
-
 
813
        ScratchOffer so = new ScratchOffer();
-
 
814
        so.setInvoiceNumber(invoiceNumber);
-
 
815
        so.setOfferName(ScratchedGift.EW);
-
 
816
        so.setScratched(false);
-
 
817
        so.setCreatedTimestamp(LocalDateTime.now());
-
 
818
        so.setExpiredTimestamp(so.getCreatedTimestamp().plusDays(1));
-
 
819
        so.setUnlockedAt(LocalDateTime.now());
-
 
820
        so.setCustomerId(customerId);
-
 
821
        scratchOfferRepository.persist(so);
-
 
822
 
-
 
823
 
628
    }
824
    }
629
 
825
 
630
    private HygieneData createAndGetHygieneData(int id, int fofoId) {
826
    private HygieneData createAndGetHygieneData(int id, int fofoId) {
631
        HygieneData hygieneData = new HygieneData();
827
        HygieneData hygieneData = new HygieneData();
632
        hygieneData.setOrderId(id);
828
        hygieneData.setOrderId(id);