Subversion Repositories SmartDukaan

Rev

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

Rev 30576 Rev 30616
Line 6... Line 6...
6
import com.smartdukaan.cron.scheduled.ScheduledTasks;
6
import com.smartdukaan.cron.scheduled.ScheduledTasks;
7
import com.smartdukaan.cron.scheduled.amazon.shop.AmazonPurchaseService;
7
import com.smartdukaan.cron.scheduled.amazon.shop.AmazonPurchaseService;
8
import com.spice.profitmandi.common.enumuration.ItemType;
8
import com.spice.profitmandi.common.enumuration.ItemType;
9
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
9
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
10
import com.spice.profitmandi.common.model.CustomRetailer;
10
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
11
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
11
import com.spice.profitmandi.common.model.ProfitMandiConstants;
12
import com.spice.profitmandi.common.model.ProfitMandiConstants;
12
import com.spice.profitmandi.common.services.mandii.*;
13
import com.spice.profitmandi.common.services.mandii.*;
13
import com.spice.profitmandi.common.util.FileUtil;
14
import com.spice.profitmandi.common.util.FileUtil;
14
import com.spice.profitmandi.common.util.FormattingUtils;
15
import com.spice.profitmandi.common.util.FormattingUtils;
15
import com.spice.profitmandi.common.util.Utils;
16
import com.spice.profitmandi.common.util.Utils;
Line 35... Line 36...
35
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
36
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
36
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
37
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
37
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
38
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
38
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
39
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
39
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
40
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
-
 
41
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
40
import com.spice.profitmandi.dao.model.ContentPojo;
42
import com.spice.profitmandi.dao.model.ContentPojo;
41
import com.spice.profitmandi.dao.model.MediaPojo;
43
import com.spice.profitmandi.dao.model.MediaPojo;
42
import com.spice.profitmandi.dao.model.TargetSlab;
44
import com.spice.profitmandi.dao.model.TargetSlab;
43
import com.spice.profitmandi.dao.repository.GenericRepository;
45
import com.spice.profitmandi.dao.repository.GenericRepository;
44
import com.spice.profitmandi.dao.repository.catalog.*;
46
import com.spice.profitmandi.dao.repository.catalog.*;
Line 1031... Line 1033...
1031
			offerTargetSlabRepository.persist(ts1);
1033
			offerTargetSlabRepository.persist(ts1);
1032
		});
1034
		});
1033
 
1035
 
1034
	}
1036
	}
1035
 
1037
 
-
 
1038
	@Autowired
-
 
1039
	PriceDropRepository priceDropRepository;
-
 
1040
 
-
 
1041
 
-
 
1042
	@Autowired
-
 
1043
	PriceDropIMEIRepository priceDropIMEIRepository;
-
 
1044
 
-
 
1045
	public void fixPriceDrop() throws ProfitMandiBusinessException {
-
 
1046
		List<Integer> priceDropIds = Arrays.asList(609, 610, 611, 648, 649, 650, 651, 653, 667, 691, 692, 693, 695, 696, 697, 698);
-
 
1047
		//List<Integer> priceDropIds = Arrays.asList(609, 610, 611, 648, 649, 650, 651, 653, 667, 691, 692, 693, 695, 696, 697, 698);
-
 
1048
		for (int priceDropId : priceDropIds) {
-
 
1049
			PriceDrop pd = priceDropRepository.selectById(priceDropId);
-
 
1050
			LOGGER.info("Price Drop ---- {}", pd);
-
 
1051
			List<ImeiDropSummaryModel> actualList = priceDropService.getAllSerialNumbersByAffectedDate(pd.getAffectedOn(), pd.getCatalogItemId());
-
 
1052
			Map<String, ImeiDropSummaryModel> actualMap = actualList.stream().collect(Collectors.toMap(x -> x.getSerialNumber(), x -> x));
-
 
1053
 
-
 
1054
			List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByPriceDropId(pd.getId());
-
 
1055
			Map<String, PriceDropIMEI> oldImeisMap = priceDropIMEIs.stream().collect(Collectors.toMap(x -> x.getImei(), x -> x));
-
 
1056
 
-
 
1057
			for (Map.Entry<String, PriceDropIMEI> entry : oldImeisMap.entrySet()) {
-
 
1058
				String imei = entry.getKey();
-
 
1059
				if (!actualMap.containsKey(imei)) {
-
 
1060
					//This imei is invalid and need to be checked
-
 
1061
					if (!entry.getValue().getStatus().equals(PriceDropImeiStatus.REJECTED)) {
-
 
1062
						if (entry.getValue().getStatus().equals(PriceDropImeiStatus.PENDING)) {
-
 
1063
							LOGGER.info("Invalid pending imei -- {} should be deleted", imei);
-
 
1064
						} else if (entry.getValue().getStatus().equals(PriceDropImeiStatus.APPROVED)) {
-
 
1065
							LOGGER.info("Invalid approved imei -- {} should be reversed", imei);
-
 
1066
						}
-
 
1067
						//These values should either be rejected or rolledBack
-
 
1068
						LOGGER.info("Should be rejected or rolledBack -- Imei --- {}, Status --- {}", imei, entry.getValue().getStatus());
-
 
1069
					} else {
-
 
1070
						//Rejections can be ignored
-
 
1071
					}
-
 
1072
				} else {
-
 
1073
					if (entry.getValue().getStatus().equals(PriceDropImeiStatus.REJECTED)) {
-
 
1074
						LOGGER.info("Valid but rejected imeis should be retried, marked pending --- {}", imei);
-
 
1075
						//entry.getValue().setStatus(PriceDropImeiStatus.PENDING);
-
 
1076
					}
-
 
1077
				}
-
 
1078
			}
-
 
1079
 
-
 
1080
			for (Map.Entry<String, ImeiDropSummaryModel> entry : actualMap.entrySet()) {
-
 
1081
				ImeiDropSummaryModel imeiDropSummaryModel = entry.getValue();
-
 
1082
				String imei = entry.getKey();
-
 
1083
				if (!oldImeisMap.containsKey(imei)) {
-
 
1084
					//this imei should be added for processing in pending state
-
 
1085
					PriceDropIMEI priceDropIMEI = new PriceDropIMEI();
-
 
1086
					priceDropIMEI.setPriceDropId(priceDropId);
-
 
1087
					priceDropIMEI.setStatus(PriceDropImeiStatus.PENDING);
-
 
1088
					priceDropIMEI.setImei(imei);
-
 
1089
					priceDropIMEI.setPartnerId(imeiDropSummaryModel.getRetailerId());
-
 
1090
					priceDropIMEI.setUpdateTimestamp(LocalDateTime.now());
-
 
1091
					//priceDropIMEIRepository.persist(priceDropIMEI);
-
 
1092
					LOGGER.info("These imeis are added and were missing earlier --- {}", imei);
-
 
1093
 
-
 
1094
				}
-
 
1095
			}
-
 
1096
 
-
 
1097
		}
-
 
1098
	}
-
 
1099
 
1036
 
1100
 
1037
	private class SioTuple {
1101
	private class SioTuple {
1038
		int inventoryId;
1102
		int inventoryId;
1039
		SchemeType schemeType;
1103
		SchemeType schemeType;
1040
 
1104