Subversion Repositories SmartDukaan

Rev

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

Rev 31020 Rev 31152
Line 1... Line 1...
1
package com.spice.profitmandi.dao.repository.cs;
1
package com.spice.profitmandi.dao.repository.cs;
2
 
2
 
-
 
3
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.model.CustomRetailer;
5
import com.spice.profitmandi.common.model.CustomRetailer;
5
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.util.Utils;
7
import com.spice.profitmandi.common.util.Utils;
7
import com.spice.profitmandi.dao.entity.auth.AuthUser;
8
import com.spice.profitmandi.dao.entity.auth.AuthUser;
Line 534... Line 535...
534
		}
535
		}
535
		return storeGuyMap;
536
		return storeGuyMap;
536
	}
537
	}
537
 
538
 
538
	@Override
539
	@Override
-
 
540
	@Cacheable(value = "authUserPartnerEmailPartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
-
 
541
	public Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds) {
-
 
542
		Map<String, Set<Integer>> authUserPartnerMap = new HashMap<>();
-
 
543
		Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
-
 
544
				.collect(Collectors.toSet());
-
 
545
 
-
 
546
		List<Position> categoryPositions = positionRepository.selectPositionByCategoryIds(categoryIds);
-
 
547
		Map<Integer, Position> positionsMap = categoryPositions.stream()
-
 
548
				.collect(Collectors.toMap(x -> x.getId(), x -> x));
-
 
549
 
-
 
550
		Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
-
 
551
		for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
-
 
552
			int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
-
 
553
			Set<Integer> partnerIds = positionPartnerEntry.getValue().stream()
-
 
554
					.filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getPartnerId())
-
 
555
					.collect(Collectors.toSet());
-
 
556
			AuthUser authUser = authRepository.selectById(authUserId);
-
 
557
			if (authUser.isActive()) {
-
 
558
				if (!authUserPartnerMap.containsKey(authUser.getEmailId())) {
-
 
559
					authUserPartnerMap.put(authUser.getEmailId(), partnerIds);
-
 
560
				} else {
-
 
561
					authUserPartnerMap.get(authUser.getEmailId()).addAll(partnerIds);
-
 
562
				}
-
 
563
			}
-
 
564
		}
-
 
565
		return authUserPartnerMap;
-
 
566
	}
-
 
567
 
-
 
568
	@Override
539
	public List<String> getAuthUserByPartnerId(int fofoId) {
569
	public List<String> getAuthUserByPartnerId(int fofoId) {
540
 
570
 
541
		List<String> emails = new ArrayList<>();
571
		List<String> emails = new ArrayList<>();
542
		List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
572
		List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
543
				.collect(Collectors.toList());
573
				.collect(Collectors.toList());
Line 930... Line 960...
930
		}
960
		}
931
		return partnerIdSalesHeadersMap;
961
		return partnerIdSalesHeadersMap;
932
 
962
 
933
	}
963
	}
934
 
964
 
-
 
965
	@Override
-
 
966
	public Set<Integer> getAuthFofoIds(String email) throws ProfitMandiBusinessException {
-
 
967
 
-
 
968
		List<Integer> categoryIds = ticketCategoryRepository.selectAll().stream().map(x -> x.getId())
-
 
969
				.collect(Collectors.toList());
-
 
970
		Map<String, Set<Integer>> storeGuyMap = this.getAuthUserPartnerIdMappingByCategoryIds(categoryIds);
-
 
971
		Set<Integer> authfofoIds = storeGuyMap.get(email);
-
 
972
 
-
 
973
		AuthUser authUser = authRepository.selectByEmailOrMobile(email);
-
 
974
		if (authfofoIds == null) {
-
 
975
			List<Position> positions1 = positionRepository.selectAll(authUser.getId());
-
 
976
			if (positions1.stream().filter(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)
-
 
977
					.count() > 0) {
-
 
978
				authfofoIds = this.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
-
 
979
						.map(x -> x.getPartnerId()).collect(Collectors.toSet());
-
 
980
			}
-
 
981
		}
-
 
982
 
-
 
983
		return authfofoIds;
-
 
984
	}
-
 
985
 
935
}
986
}