| Line 76... |
Line 76... |
| 76 |
private UserRepository userRepository;
|
76 |
private UserRepository userRepository;
|
| 77 |
@Autowired
|
77 |
@Autowired
|
| 78 |
ObjectMapper objectMapper;
|
78 |
ObjectMapper objectMapper;
|
| 79 |
|
79 |
|
| 80 |
|
80 |
|
| 81 |
|
- |
|
| 82 |
@Autowired
|
81 |
@Autowired
|
| 83 |
private CartRepository cartRepository;
|
82 |
private CartRepository cartRepository;
|
| 84 |
|
83 |
|
| 85 |
@Autowired
|
84 |
@Autowired
|
| 86 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
85 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
| Line 974... |
Line 973... |
| 974 |
if (fofoIds == null || fofoIds.isEmpty()) {
|
973 |
if (fofoIds == null || fofoIds.isEmpty()) {
|
| 975 |
return new HashMap<>();
|
974 |
return new HashMap<>();
|
| 976 |
}
|
975 |
}
|
| 977 |
|
976 |
|
| 978 |
List<com.spice.profitmandi.dao.entity.user.User> saholicUsers = userUserRepository.selectByIds(fofoIds);
|
977 |
List<com.spice.profitmandi.dao.entity.user.User> saholicUsers = userUserRepository.selectByIds(fofoIds);
|
| - |
|
978 |
|
| - |
|
979 |
// Check for saholicUsers without corresponding dtrUser
|
| - |
|
980 |
List<String> saholicEmails = saholicUsers.stream()
|
| - |
|
981 |
.map(com.spice.profitmandi.dao.entity.user.User::getEmailId)
|
| - |
|
982 |
.filter(email -> email != null)
|
| - |
|
983 |
.collect(Collectors.toList());
|
| - |
|
984 |
Set<String> dtrUserEmails = userRepository.selectAllByEmailIds(saholicEmails).stream()
|
| - |
|
985 |
.map(User::getEmailId)
|
| - |
|
986 |
.collect(Collectors.toSet());
|
| - |
|
987 |
for (com.spice.profitmandi.dao.entity.user.User saholicUser : saholicUsers) {
|
| - |
|
988 |
if (saholicUser.getEmailId() != null && !dtrUserEmails.contains(saholicUser.getEmailId())) {
|
| - |
|
989 |
LOGGER.warn("dtrUser not found for saholicUser - id: {}, email: {}", saholicUser.getId(), saholicUser.getEmailId());
|
| - |
|
990 |
}
|
| - |
|
991 |
}
|
| - |
|
992 |
|
| 979 |
Map<Integer, com.spice.profitmandi.dao.entity.user.User> userAddressMap = saholicUsers.stream()
|
993 |
Map<Integer, com.spice.profitmandi.dao.entity.user.User> userAddressMap = saholicUsers.stream()
|
| 980 |
.filter(x -> x.getAddressId() != null)
|
994 |
.filter(x -> x.getAddressId() != null)
|
| 981 |
.collect(Collectors.toMap(com.spice.profitmandi.dao.entity.user.User::getAddressId, x -> x));
|
995 |
.collect(Collectors.toMap(com.spice.profitmandi.dao.entity.user.User::getAddressId, x -> x));
|
| 982 |
List<Address> addresses = addressRepository.selectByIds(new ArrayList<>(userAddressMap.keySet()));
|
996 |
List<Address> addresses = addressRepository.selectByIds(new ArrayList<>(userAddressMap.keySet()));
|
| 983 |
|
997 |
|
| Line 995... |
Line 1009... |
| 995 |
.filter(pdu -> pdu.getCounterId() != null)
|
1009 |
.filter(pdu -> pdu.getCounterId() != null)
|
| 996 |
.map(PrivateDealUser::getCounterId)
|
1010 |
.map(PrivateDealUser::getCounterId)
|
| 997 |
.collect(Collectors.toSet());
|
1011 |
.collect(Collectors.toSet());
|
| 998 |
Map<Integer, Counter> counterMap = counterIds.isEmpty() ? Collections.emptyMap()
|
1012 |
Map<Integer, Counter> counterMap = counterIds.isEmpty() ? Collections.emptyMap()
|
| 999 |
: counterRepository.selectByIds(new ArrayList<>(counterIds))
|
1013 |
: counterRepository.selectByIds(new ArrayList<>(counterIds))
|
| 1000 |
.stream().collect(Collectors.toMap(Counter::getId, c -> c));
|
1014 |
.stream().collect(Collectors.toMap(Counter::getId, c -> c));
|
| 1001 |
|
1015 |
|
| 1002 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
1016 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
| 1003 |
for (Address address : addresses) {
|
1017 |
for (Address address : addresses) {
|
| 1004 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
1018 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
| 1005 |
FofoStore fs = fofoStoreMap.get(address.getRetaierId());
|
1019 |
FofoStore fs = fofoStoreMap.get(address.getRetaierId());
|
| Line 1015... |
Line 1029... |
| 1015 |
|
1029 |
|
| 1016 |
/**
|
1030 |
/**
|
| 1017 |
* Helper method to build CustomRetailer from fetched entities
|
1031 |
* Helper method to build CustomRetailer from fetched entities
|
| 1018 |
*/
|
1032 |
*/
|
| 1019 |
private CustomRetailer buildCustomRetailer(com.spice.profitmandi.dao.entity.user.User user, Address address,
|
1033 |
private CustomRetailer buildCustomRetailer(com.spice.profitmandi.dao.entity.user.User user, Address address,
|
| 1020 |
FofoStore fs, Map<Integer, PrivateDealUser> privateDealUserMap,
|
1034 |
FofoStore fs, Map<Integer, PrivateDealUser> privateDealUserMap,
|
| 1021 |
Map<Integer, Counter> counterMap) {
|
1035 |
Map<Integer, Counter> counterMap) {
|
| 1022 |
CustomRetailer customRetailer = new CustomRetailer();
|
1036 |
CustomRetailer customRetailer = new CustomRetailer();
|
| 1023 |
customRetailer.setEmail(user.getEmailId());
|
1037 |
customRetailer.setEmail(user.getEmailId());
|
| 1024 |
customRetailer.setBusinessName(address.getName());
|
1038 |
customRetailer.setBusinessName(address.getName());
|
| 1025 |
customRetailer.setMobileNumber(address.getPhoneNumber());
|
1039 |
customRetailer.setMobileNumber(address.getPhoneNumber());
|
| 1026 |
customRetailer.setCode(fs.getCode());
|
1040 |
customRetailer.setCode(fs.getCode());
|
| Line 1063... |
Line 1077... |
| 1063 |
|
1077 |
|
| 1064 |
@Override
|
1078 |
@Override
|
| 1065 |
@Cacheable(value = "getFofoRetailer", cacheManager = "thirtyMinsTimeOutCacheManager")
|
1079 |
@Cacheable(value = "getFofoRetailer", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 1066 |
public CustomRetailer getFofoRetailer(int fofoId) throws ProfitMandiBusinessException {
|
1080 |
public CustomRetailer getFofoRetailer(int fofoId) throws ProfitMandiBusinessException {
|
| 1067 |
com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(fofoId);
|
1081 |
com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(fofoId);
|
| - |
|
1082 |
User dtrUser = null;
|
| - |
|
1083 |
try {
|
| 1068 |
User dtrUser = userRepository.selectByEmailId(saholicUser.getEmailId());
|
1084 |
dtrUser = userRepository.selectByEmailId(saholicUser.getEmailId());
|
| - |
|
1085 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
1086 |
LOGGER.info("User not found for emailId: {} and id is : {}", saholicUser.getEmailId(), saholicUser.getId());
|
| - |
|
1087 |
}
|
| 1069 |
FofoStore store = fofoStoreRepository.selectByRetailerId(fofoId);
|
1088 |
FofoStore store = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 1070 |
Address address = addressRepository.selectById(saholicUser.getAddressId());
|
1089 |
Address address = addressRepository.selectById(saholicUser.getAddressId());
|
| 1071 |
|
1090 |
|
| 1072 |
CustomRetailer customRetailer = new CustomRetailer();
|
1091 |
CustomRetailer customRetailer = new CustomRetailer();
|
| 1073 |
customRetailer.setEmail(saholicUser.getEmailId());
|
1092 |
customRetailer.setEmail(saholicUser.getEmailId());
|
| Line 1126... |
Line 1145... |
| 1126 |
.filter(pdu -> pdu.getCounterId() != null)
|
1145 |
.filter(pdu -> pdu.getCounterId() != null)
|
| 1127 |
.map(PrivateDealUser::getCounterId)
|
1146 |
.map(PrivateDealUser::getCounterId)
|
| 1128 |
.collect(Collectors.toSet());
|
1147 |
.collect(Collectors.toSet());
|
| 1129 |
Map<Integer, Counter> counterMap = counterIds.isEmpty() ? Collections.emptyMap()
|
1148 |
Map<Integer, Counter> counterMap = counterIds.isEmpty() ? Collections.emptyMap()
|
| 1130 |
: counterRepository.selectByIds(new ArrayList<>(counterIds))
|
1149 |
: counterRepository.selectByIds(new ArrayList<>(counterIds))
|
| 1131 |
.stream().collect(Collectors.toMap(Counter::getId, c -> c));
|
1150 |
.stream().collect(Collectors.toMap(Counter::getId, c -> c));
|
| 1132 |
|
1151 |
|
| 1133 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
1152 |
Map<Integer, CustomRetailer> customRetailersMap = new HashMap<>();
|
| 1134 |
for (Address address : addresses) {
|
1153 |
for (Address address : addresses) {
|
| 1135 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
1154 |
com.spice.profitmandi.dao.entity.user.User user = userAddressMap.get(address.getId());
|
| 1136 |
Integer userId = retailerIdToUserIdMap.get(user.getId());
|
1155 |
Integer userId = retailerIdToUserIdMap.get(user.getId());
|