| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.repository.cs;
|
1 |
package com.spice.profitmandi.dao.repository.cs;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
| - |
|
5 |
import java.util.Arrays;
|
| 5 |
import java.util.HashMap;
|
6 |
import java.util.HashMap;
|
| 6 |
import java.util.HashSet;
|
7 |
import java.util.HashSet;
|
| 7 |
import java.util.List;
|
8 |
import java.util.List;
|
| 8 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| 9 |
import java.util.Set;
|
10 |
import java.util.Set;
|
| Line 21... |
Line 22... |
| 21 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
22 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
23 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 23 |
import com.spice.profitmandi.common.util.Utils;
|
24 |
import com.spice.profitmandi.common.util.Utils;
|
| 24 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
25 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 25 |
import com.spice.profitmandi.dao.entity.cs.Activity;
|
26 |
import com.spice.profitmandi.dao.entity.cs.Activity;
|
| - |
|
27 |
import com.spice.profitmandi.dao.entity.cs.PartnerPosition;
|
| 26 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
28 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
| 27 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
29 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 28 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
30 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
| 29 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
31 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| 30 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
32 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| Line 487... |
Line 489... |
| 487 |
List<Position> categoryPositions = positionRepository
|
489 |
List<Position> categoryPositions = positionRepository
|
| 488 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
490 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| 489 |
Map<Integer, Position> positionsMap = categoryPositions.stream()
|
491 |
Map<Integer, Position> positionsMap = categoryPositions.stream()
|
| 490 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
492 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 491 |
|
493 |
|
| 492 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this
|
494 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
| 493 |
.getPositionCustomRetailerMap(categoryPositions);
|
- |
|
| 494 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
495 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
| 495 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
496 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
| 496 |
Set<String> partnerEmails = positionPartnerEntry.getValue().stream()
|
497 |
Set<String> partnerEmails = positionPartnerEntry.getValue().stream()
|
| 497 |
.filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getEmail())
|
498 |
.filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getEmail())
|
| 498 |
.collect(Collectors.toSet());
|
499 |
.collect(Collectors.toSet());
|
| Line 501... |
Line 502... |
| 501 |
storeGuyMap.put(authUser.getEmailId(), partnerEmails);
|
502 |
storeGuyMap.put(authUser.getEmailId(), partnerEmails);
|
| 502 |
}
|
503 |
}
|
| 503 |
}
|
504 |
}
|
| 504 |
return storeGuyMap;
|
505 |
return storeGuyMap;
|
| 505 |
}
|
506 |
}
|
| - |
|
507 |
|
| - |
|
508 |
@Override
|
| - |
|
509 |
public Map<String, Set<Integer>> getAuthUserPartnerIdMapping() {
|
| - |
|
510 |
Map<String, Set<Integer>> storeGuyMap = new HashMap<>();
|
| - |
|
511 |
|
| - |
|
512 |
List<Position> categoryPositions = positionRepository
|
| - |
|
513 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| - |
|
514 |
Map<Integer, Position> positionsMap = categoryPositions.stream()
|
| - |
|
515 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
516 |
|
| - |
|
517 |
Map<Integer, List<CustomRetailer>> positonPartnerMap = this.getPositionCustomRetailerMap(categoryPositions);
|
| - |
|
518 |
for (Map.Entry<Integer, List<CustomRetailer>> positionPartnerEntry : positonPartnerMap.entrySet()) {
|
| - |
|
519 |
int authUserId = positionsMap.get(positionPartnerEntry.getKey()).getAuthUserId();
|
| - |
|
520 |
|
| - |
|
521 |
Set<Integer> activeFofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
|
| - |
|
522 |
.collect(Collectors.toSet());
|
| - |
|
523 |
/*
|
| - |
|
524 |
* Set<String> partnerEmails = positionPartnerEntry.getValue().stream()
|
| - |
|
525 |
* .filter(x -> activeFofoIds.contains(x.getPartnerId())).map(x -> x.getEmail())
|
| - |
|
526 |
* .collect(Collectors.toSet());
|
| - |
|
527 |
*/
|
| - |
|
528 |
AuthUser authUser = authRepository.selectById(authUserId);
|
| - |
|
529 |
if (authUser.isActive()) {
|
| - |
|
530 |
storeGuyMap.put(authUser.getEmailId(), activeFofoIds);
|
| - |
|
531 |
}
|
| - |
|
532 |
}
|
| - |
|
533 |
return storeGuyMap;
|
| - |
|
534 |
}
|
| - |
|
535 |
|
| - |
|
536 |
@Override
|
| - |
|
537 |
public List<String> getAuthUserByPartnerId(int fofoId) {
|
| - |
|
538 |
|
| - |
|
539 |
List<String> emails = new ArrayList<>();
|
| - |
|
540 |
List<Integer> regionIds = partnerRegionRepository.selectByfofoId(fofoId).stream().map(x -> x.getRegionId())
|
| - |
|
541 |
.collect(Collectors.toList());
|
| - |
|
542 |
|
| - |
|
543 |
regionIds.add(5);// All partners Id;
|
| - |
|
544 |
List<Integer> fofoIds = new ArrayList<>();
|
| - |
|
545 |
fofoIds.add(fofoId);
|
| - |
|
546 |
fofoIds.add(0);
|
| - |
|
547 |
List<Integer> partnerPositionIds = partnersPositionRepository.selectByRegionIdAndPartnerId(regionIds, fofoIds)
|
| - |
|
548 |
.stream().map(x -> x.getPositionId()).collect(Collectors.toList());
|
| - |
|
549 |
|
| - |
|
550 |
for (Integer partnerPostionId : partnerPositionIds) {
|
| - |
|
551 |
Position position = positionRepository.selectById(partnerPostionId);
|
| - |
|
552 |
|
| - |
|
553 |
AuthUser authUser = authRepository.selectById(position.getAuthUserId());
|
| - |
|
554 |
emails.add(authUser.getEmailId());
|
| - |
|
555 |
}
|
| - |
|
556 |
|
| - |
|
557 |
return emails;
|
| - |
|
558 |
}
|
| 506 |
}
|
559 |
}
|