Subversion Repositories SmartDukaan

Rev

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

Rev 36993 Rev 37040
Line 2114... Line 2114...
2114
            }
2114
            }
2115
        }
2115
        }
2116
 
2116
 
2117
    }
2117
    }
2118
 
2118
 
-
 
2119
    public void updatePartnerActivationTypeByMonthlySale() throws Exception {
-
 
2120
        LocalDateTime now = LocalDateTime.now();
-
 
2121
        LocalDateTime thirtyDaysAgo = now.minusDays(30);
-
 
2122
        LocalDateTime sixtyDaysAgo = now.minusDays(60);
-
 
2123
        long threshold = 99_999L;
-
 
2124
 
-
 
2125
        List<FofoStore> candidates = fofoStoreRepository.selectByStatus(true).stream().filter(x-> !x.isInternal()).collect(toList());
-
 
2126
 
-
 
2127
        if (candidates.isEmpty()) {
-
 
2128
            LOGGER.info("updatePartnerActivationTypeByMonthlySale: no candidate stores");
-
 
2129
            return;
-
 
2130
        }
-
 
2131
 
-
 
2132
        List<Integer> ids = candidates.stream().map(FofoStore::getId).collect(Collectors.toList());
-
 
2133
        Set<Integer> met30 = orderRepository.selectFofoIdsWithMtdBillingAboveThreshold(ids, thirtyDaysAgo, now, threshold);
-
 
2134
        Set<Integer> met60 = orderRepository.selectFofoIdsWithMtdBillingAboveThreshold(ids, sixtyDaysAgo, now, threshold);
-
 
2135
 
-
 
2136
        int toFocus = 0;
-
 
2137
        int toRevival = 0;
-
 
2138
        for (FofoStore store : candidates) {
-
 
2139
            int id = store.getId();
-
 
2140
            boolean below30 = !met30.contains(id);
-
 
2141
            boolean below60 = !met60.contains(id);
-
 
2142
            ActivationType current = store.getActivationType();
-
 
2143
            ActivationType target = current;
-
 
2144
 
-
 
2145
            if (below60) {
-
 
2146
                target = ActivationType.REVIVAL;
-
 
2147
            } else if (below30 && current == ActivationType.ACTIVE) {
-
 
2148
                target = ActivationType.FOCUS;
-
 
2149
            }
-
 
2150
 
-
 
2151
            if (target != current) {
-
 
2152
                LOGGER.info("Auto-downgrade fofoId={} code={} from {} to {} (below30={}, below60={})",
-
 
2153
                        id, store.getCode(), current, target, below30, below60);
-
 
2154
                store.setActivationType(target);
-
 
2155
                store.setActive(false);
-
 
2156
                store.setActiveTimeStamp(null);
-
 
2157
                fofoStoreRepository.persist(store);
-
 
2158
                if (target == ActivationType.FOCUS) {
-
 
2159
                    toFocus++;
-
 
2160
                } else {
-
 
2161
                    toRevival++;
-
 
2162
                }
-
 
2163
            }
-
 
2164
        }
-
 
2165
        LOGGER.info("updatePartnerActivationTypeByMonthlySale done: scanned={}, toFocus={}, toRevival={}",
-
 
2166
                candidates.size(), toFocus, toRevival);
-
 
2167
    }
-
 
2168
 
2119
    public void sendAgeingReport() throws Exception {
2169
    public void sendAgeingReport() throws Exception {
2120
        sendAgeingReport("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "kuldeep.kumar@smartdukaan.com");
2170
        sendAgeingReport("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "kuldeep.kumar@smartdukaan.com");
2121
    }
2171
    }
2122
 
2172
 
2123
    public void moveImeisToPriceDropImeis() throws Exception {
2173
    public void moveImeisToPriceDropImeis() throws Exception {