Subversion Repositories SmartDukaan

Rev

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

Rev 25069 Rev 25111
Line 1... Line 1...
1
package com.spice.profitmandi.service.scheme;
1
package com.spice.profitmandi.service.scheme;
2
 
2
 
3
import java.time.LocalDate;
-
 
4
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
5
import java.time.LocalTime;
-
 
6
import java.util.ArrayList;
4
import java.util.ArrayList;
7
import java.util.HashMap;
5
import java.util.HashMap;
8
import java.util.HashSet;
6
import java.util.HashSet;
9
import java.util.List;
7
import java.util.List;
10
import java.util.Map;
8
import java.util.Map;
Line 34... Line 32...
34
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
32
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
35
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
33
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
36
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
34
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
37
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
35
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
38
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
36
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
-
 
37
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
39
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
38
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
40
import com.spice.profitmandi.dao.repository.catalog.RetailerSchemeRepository;
39
import com.spice.profitmandi.dao.repository.catalog.RetailerSchemeRepository;
41
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
40
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
42
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
41
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
43
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
42
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
Line 474... Line 473...
474
	}
473
	}
475
 
474
 
476
	@Override
475
	@Override
477
	public void expireSchemeById(int schemeId, LocalDateTime expiryTime) throws ProfitMandiBusinessException {
476
	public void expireSchemeById(int schemeId, LocalDateTime expiryTime) throws ProfitMandiBusinessException {
478
		Scheme scheme = schemeRepository.selectById(schemeId);
477
		Scheme scheme = schemeRepository.selectById(schemeId);
479
		if (scheme==null || scheme.getActiveTimestamp() == null) {
478
		if (scheme == null || scheme.getActiveTimestamp() == null) {
480
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
479
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ACTIVE_TIMESTAMP, scheme.getActiveTimestamp(),
481
					"SCHM_1007");
480
					"SCHM_1007");
482
		}
481
		}
483
		if (scheme.getExpireTimestamp() != null) {
482
		if (scheme.getExpireTimestamp() != null) {
484
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
483
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EXPIRE_TIMESTAMP, scheme.getExpireTimestamp(),
Line 559... Line 558...
559
			float totalCashback = 0;
558
			float totalCashback = 0;
560
			if (schemes.isEmpty()) {
559
			if (schemes.isEmpty()) {
561
				return;
560
				return;
562
			}
561
			}
563
			List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
562
			List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
564
 
-
 
-
 
563
			inventoryItems.stream().filter(x -> !x.getLastScanType().equals(ScanType.PURCHASE_RET_BAD)
-
 
564
					&& !x.getLastScanType().equals(ScanType.PURCHASE_RET));
565
			Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap = this.toInventoryItemSchemesMap(schemes,
565
			Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap = this.toInventoryItemSchemesMap(schemes,
566
					inventoryItems);
566
					inventoryItems);
567
 
567
 
568
			if (inventoryItemSchemesMap.isEmpty()) {
568
			if (inventoryItemSchemesMap.isEmpty()) {
569
				return;
569
				return;