Subversion Repositories SmartDukaan

Rev

Rev 37160 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37160 Rev 37307
Line 74... Line 74...
74
    private static final List<SchemeType> HALF_DAYS_CD_REJECT_SCHEME_TYPES = Arrays.asList(SchemeType.CASH_DISCOUNT1);
74
    private static final List<SchemeType> HALF_DAYS_CD_REJECT_SCHEME_TYPES = Arrays.asList(SchemeType.CASH_DISCOUNT1);
75
 
75
 
76
 
76
 
77
    private static final List<SchemeType> ACTIVATION_SCHEME_TYPES = Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT);
77
    private static final List<SchemeType> ACTIVATION_SCHEME_TYPES = Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT);
78
    private static final List<SchemeType> NOFITY_SCHEME_TYPES = Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT, SchemeType.SELLIN);
78
    private static final List<SchemeType> NOFITY_SCHEME_TYPES = Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT, SchemeType.SELLIN);
-
 
79
    private static final List<SchemeType> ITEM_REQUIRED_SCHEME_TYPES = Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.SELLOUT, SchemeType.SELLIN);
79
 
80
 
80
    @Autowired
81
    @Autowired
81
    SchemeBlockedImeiRepository schemeBlockedImeiRepository;
82
    SchemeBlockedImeiRepository schemeBlockedImeiRepository;
82
    @Autowired
83
    @Autowired
83
    StateGstRateRepository stateGstRateRepository;
84
    StateGstRateRepository stateGstRateRepository;
Line 192... Line 193...
192
            throw new ProfitMandiBusinessException(ProfitMandiConstants.END_DATE, createSchemeRequest.getEndDate(),
193
            throw new ProfitMandiBusinessException(ProfitMandiConstants.END_DATE, createSchemeRequest.getEndDate(),
193
                    "SCHM_VE_1004");
194
                    "SCHM_VE_1004");
194
        }
195
        }
195
    }
196
    }
196
 
197
 
-
 
198
    private void validateSchemeHasItems(Scheme scheme) throws ProfitMandiBusinessException {
-
 
199
        if (!ITEM_REQUIRED_SCHEME_TYPES.contains(scheme.getType())) {
-
 
200
            return;
-
 
201
        }
-
 
202
        List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(Collections.singleton(scheme.getId()));
-
 
203
        if (schemeItems.isEmpty()) {
-
 
204
            throw new ProfitMandiBusinessException(ProfitMandiConstants.SCHEME_ID, scheme.getId(), "SCHM_1009");
-
 
205
        }
-
 
206
    }
-
 
207
 
197
    private void validateItemIds(CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
208
    private void validateItemIds(CreateSchemeRequest createSchemeRequest) throws ProfitMandiBusinessException {
198
        if (createSchemeRequest.getCatalogIds() == null || createSchemeRequest.getCatalogIds().isEmpty()) {
209
        if (createSchemeRequest.getCatalogIds() == null || createSchemeRequest.getCatalogIds().isEmpty()) {
199
            throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getCatalogIds(),
210
            throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, createSchemeRequest.getCatalogIds(),
200
                    "SCHM_1003");
211
                    "SCHM_1003");
201
        }
212
        }
Line 293... Line 304...
293
        }
304
        }
294
        if (scheme.getExpireTimestamp() != null) {
305
        if (scheme.getExpireTimestamp() != null) {
295
            throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
306
            throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
296
                    "SCHM_1006");
307
                    "SCHM_1006");
297
        }
308
        }
-
 
309
        this.validateSchemeHasItems(scheme);
298
        scheme.setActiveTimestamp(LocalDateTime.now());
310
        scheme.setActiveTimestamp(LocalDateTime.now());
299
        this.sendSchemeNotification(scheme);
311
        this.sendSchemeNotification(scheme);
300
 
312
 
301
 
313
 
302
        /*
314
        /*
Line 311... Line 323...
311
        if (schemes.size() > 0) {
323
        if (schemes.size() > 0) {
312
            for (Scheme scheme : schemes) {
324
            for (Scheme scheme : schemes) {
313
                if (scheme.getActiveTimestamp() != null || scheme.getExpireTimestamp() != null) {
325
                if (scheme.getActiveTimestamp() != null || scheme.getExpireTimestamp() != null) {
314
                    continue;
326
                    continue;
315
                }
327
                }
-
 
328
                this.validateSchemeHasItems(scheme);
-
 
329
            }
-
 
330
            for (Scheme scheme : schemes) {
-
 
331
                if (scheme.getActiveTimestamp() != null || scheme.getExpireTimestamp() != null) {
-
 
332
                    continue;
-
 
333
                }
316
                scheme.setActiveTimestamp(LocalDateTime.now());
334
                scheme.setActiveTimestamp(LocalDateTime.now());
317
            }
335
            }
318
            this.sendCombinedSchemesNotification(schemes);
336
            this.sendCombinedSchemesNotification(schemes);
319
        }
337
        }
320
    }
338
    }