Subversion Repositories SmartDukaan

Rev

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

Rev 31732 Rev 31754
Line 15... Line 15...
15
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.LogManager;
16
import org.apache.logging.log4j.Logger;
16
import org.apache.logging.log4j.Logger;
17
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.scheduling.annotation.Scheduled;
18
import org.springframework.scheduling.annotation.Scheduled;
19
import org.springframework.stereotype.Component;
19
import org.springframework.stereotype.Component;
-
 
20
import org.springframework.transaction.annotation.Transactional;
20
 
21
 
21
import java.time.LocalDate;
22
import java.time.LocalDate;
22
import java.time.LocalDateTime;
23
import java.time.LocalDateTime;
23
import java.util.*;
24
import java.util.*;
24
import java.util.stream.Collectors;
25
import java.util.stream.Collectors;
25
 
26
 
26
@Component
27
@Component
-
 
28
@Transactional(rollbackFor = Throwable.class)
27
public class Listing {
29
public class Listing {
28
    @Autowired
30
    @Autowired
29
    private WebListingRepository webListingRepository;
31
    private WebListingRepository webListingRepository;
30
 
32
 
31
    @Autowired
33
    @Autowired
Line 64... Line 66...
64
    }
66
    }
65
 
67
 
66
    public void getBestSeller() throws ProfitMandiBusinessException {
68
    public void getBestSeller() throws ProfitMandiBusinessException {
67
        WebListing webListing = webListingRepository.selectByUrl("partner-best-sellers");
69
        WebListing webListing = webListingRepository.selectByUrl("partner-best-sellers");
68
 
70
 
69
        List<WebProductListing> webProductListings = webProductListingRepository
71
        List<WebProductListing> webProductListings = webProductListingRepository.selectAllByWebListingId(webListing.getId());
70
                .selectAllByWebListingId(webListing.getId());
-
 
71
 
72
 
72
        List<Integer> catalogItemIds = orderRepository.selectAllOrderWeight(LocalDateTime.now().minusDays(30),
73
        List<Integer> catalogItemIds = orderRepository.selectAllOrderWeight(LocalDateTime.now().minusDays(30), LocalDateTime.now(), OrderStatus.DELIVERY_SUCCESS);
73
                LocalDateTime.now(), OrderStatus.DELIVERY_SUCCESS);
-
 
74
 
74
 
75
        LOGGER.info("catalogItemIds {}", catalogItemIds);
75
        LOGGER.info("catalogItemIds {}", catalogItemIds);
76
        if (!catalogItemIds.isEmpty()) {
76
        if (!catalogItemIds.isEmpty()) {
77
            webProductListingRepository.deleteByEqual(webListing.getId());
77
            webProductListingRepository.deleteByEqual(webListing.getId());
78
            int count = 0;
78
            int count = 0;
Line 92... Line 92...
92
    }
92
    }
93
 
93
 
94
    public void getPriceDrop() throws ProfitMandiBusinessException {
94
    public void getPriceDrop() throws ProfitMandiBusinessException {
95
        WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
95
        WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
96
 
96
 
97
        List<WebProductListing> webProductListings = webProductListingRepository
97
        List<WebProductListing> webProductListings = webProductListingRepository.selectAllByWebListingId(webListing.getId());
98
                .selectAllByWebListingId(webListing.getId());
-
 
99
 
98
 
100
        Set<Integer> catalogItemIds = priceDropRepository
-
 
101
                .selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
99
        Set<Integer> catalogItemIds = priceDropRepository.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream().filter(x -> x.getAmount() > 0).map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
102
                .filter(x->x.getAmount()>0).map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
-
 
103
 
100
 
104
        LOGGER.info("catalogItemIds {}", catalogItemIds);
101
        LOGGER.info("catalogItemIds {}", catalogItemIds);
105
        if (!catalogItemIds.isEmpty()) {
102
        if (!catalogItemIds.isEmpty()) {
106
            webProductListingRepository.deleteByEqual(webListing.getId());
103
            webProductListingRepository.deleteByEqual(webListing.getId());
107
            int count = 0;
104
            int count = 0;
Line 120... Line 117...
120
    }
117
    }
121
 
118
 
122
    public void getNewLaunches() throws ProfitMandiBusinessException {
119
    public void getNewLaunches() throws ProfitMandiBusinessException {
123
        WebListing webListing = webListingRepository.selectByUrl("new-launches");
120
        WebListing webListing = webListingRepository.selectByUrl("new-launches");
124
 
121
 
125
        List<Integer> catalogItemIds = tagListingRepository.getRecentLanuch(LocalDate.now().minusDays(30),
122
        List<Integer> catalogItemIds = tagListingRepository.getRecentLanuch(LocalDate.now().minusDays(30), LocalDate.now().plusDays(1));
126
                LocalDate.now().plusDays(1));
-
 
127
 
123
 
128
        if (!catalogItemIds.isEmpty()) {
124
        if (!catalogItemIds.isEmpty()) {
129
            webProductListingRepository.deleteByEqual(webListing.getId());
125
            webProductListingRepository.deleteByEqual(webListing.getId());
130
            int count = 0;
126
            int count = 0;
131
            for (Integer catalogItemId : catalogItemIds) {
127
            for (Integer catalogItemId : catalogItemIds) {
Line 143... Line 139...
143
    }
139
    }
144
 
140
 
145
    public void getSpecialSupport() throws ProfitMandiBusinessException {
141
    public void getSpecialSupport() throws ProfitMandiBusinessException {
146
        WebListing webListing = webListingRepository.selectByUrl("special-support");
142
        WebListing webListing = webListingRepository.selectByUrl("special-support");
147
 
143
 
148
        List<Integer> catalogItemIds = schemeRepository.getActiveScheme(SchemeType.SPECIAL_SUPPORT,
144
        List<Integer> catalogItemIds = schemeRepository.getActiveScheme(SchemeType.SPECIAL_SUPPORT, LocalDate.now().plusDays(1));
149
                LocalDate.now().plusDays(1));
-
 
150
 
145
 
151
        LOGGER.info("catalogItemIds {}", catalogItemIds);
146
        LOGGER.info("catalogItemIds {}", catalogItemIds);
152
        if (!catalogItemIds.isEmpty()) {
147
        if (!catalogItemIds.isEmpty()) {
153
            webProductListingRepository.deleteByEqual(webListing.getId());
148
            webProductListingRepository.deleteByEqual(webListing.getId());
154
            int count = 0;
149
            int count = 0;
Line 168... Line 163...
168
 
163
 
169
    public void getUpgradeOffer() throws ProfitMandiBusinessException {
164
    public void getUpgradeOffer() throws ProfitMandiBusinessException {
170
        WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
165
        WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
171
        webProductListingRepository.deleteByEqual(webListing.getId());
166
        webProductListingRepository.deleteByEqual(webListing.getId());
172
 
167
 
173
        List<Integer> customerOfferIds = customerOfferRepository.selectOffers(LocalDate.now()).stream()
168
        List<Integer> customerOfferIds = customerOfferRepository.selectOffers(LocalDate.now()).stream().map(x -> x.getId()).collect(Collectors.toList());
174
                .map(x -> x.getId()).collect(Collectors.toList());
-
 
175
 
169
 
176
        List<Integer> catalogItemIds = customerOfferItemRepository
-
 
177
                .selectByOfferIdsRange(customerOfferIds, LocalDate.now()).stream().map(x -> x.getCatalogId()).distinct()
170
        List<Integer> catalogItemIds = customerOfferItemRepository.selectByOfferIdsRange(customerOfferIds, LocalDate.now()).stream().map(x -> x.getCatalogId()).distinct().collect(Collectors.toList());
178
                .collect(Collectors.toList());
-
 
179
 
171
 
180
        LOGGER.info("catalogItemIds {}", catalogItemIds);
172
        LOGGER.info("catalogItemIds {}", catalogItemIds);
181
        if (!catalogItemIds.isEmpty()) {
173
        if (!catalogItemIds.isEmpty()) {
182
            int count = 0;
174
            int count = 0;
183
            for (Integer catalogItemId : catalogItemIds) {
175
            for (Integer catalogItemId : catalogItemIds) {
Line 223... Line 215...
223
    public void scheduledGetUpgradeOffer() throws Throwable {
215
    public void scheduledGetUpgradeOffer() throws Throwable {
224
        this.getUpgradeOffer();
216
        this.getUpgradeOffer();
225
    }
217
    }
226
}
218
}
227
 
219
 
228
 
-