| Line 38... |
Line 38... |
| 38 |
|
38 |
|
| 39 |
@Component
|
39 |
@Component
|
| 40 |
public class NotificationServiceImpl implements NotificationService {
|
40 |
public class NotificationServiceImpl implements NotificationService {
|
| 41 |
|
41 |
|
| 42 |
private static final Logger LOGGER = LogManager.getLogger(NotificationServiceImpl.class);
|
42 |
private static final Logger LOGGER = LogManager.getLogger(NotificationServiceImpl.class);
|
| - |
|
43 |
|
| - |
|
44 |
// Region id that represents "all partners". Schemes meant for everyone are tagged to this region;
|
| - |
|
45 |
// partner_region is not populated for it, so it must be expanded to all partners here.
|
| - |
|
46 |
private static final int ALL_PARTNERS_REGION = 5;
|
| - |
|
47 |
|
| 43 |
@Autowired
|
48 |
@Autowired
|
| 44 |
UserCampaignRepository userCampaignRepository;
|
49 |
UserCampaignRepository userCampaignRepository;
|
| 45 |
@Autowired
|
50 |
@Autowired
|
| 46 |
UserRepository dtrUserRepository;
|
51 |
UserRepository dtrUserRepository;
|
| 47 |
@Autowired
|
52 |
@Autowired
|
| Line 125... |
Line 130... |
| 125 |
userIds.addAll(userAccountRepository.selectUserIdsByRetailerIds(fofoIds));
|
130 |
userIds.addAll(userAccountRepository.selectUserIdsByRetailerIds(fofoIds));
|
| 126 |
}
|
131 |
}
|
| 127 |
|
132 |
|
| 128 |
}
|
133 |
}
|
| 129 |
if(sendNotificationModel.getRegionIds() != null && sendNotificationModel.getRegionIds().size() > 0) {
|
134 |
if(sendNotificationModel.getRegionIds() != null && sendNotificationModel.getRegionIds().size() > 0) {
|
| - |
|
135 |
if (sendNotificationModel.getRegionIds().contains(ALL_PARTNERS_REGION)) {
|
| - |
|
136 |
// "ALL partners" region: partner_region only holds a sentinel, so expand to every partner.
|
| - |
|
137 |
userIds.addAll(fofoStoreRepository.selectAllDtrUserIds());
|
| - |
|
138 |
} else {
|
| 130 |
List<Integer> fofoIds = partnerRegionRepository.selectAllByRegionIds(sendNotificationModel.getRegionIds()).stream().map(x->x.getFofoId()).collect(Collectors.toList());
|
139 |
List<Integer> fofoIds = partnerRegionRepository.selectAllByRegionIds(sendNotificationModel.getRegionIds()).stream().map(x->x.getFofoId()).collect(Collectors.toList());
|
| 131 |
if(fofoIds.size()>0) {
|
140 |
if(fofoIds.size()>0) {
|
| 132 |
userIds.addAll(userAccountRepository.selectUserIdsByRetailerIds(fofoIds));
|
141 |
userIds.addAll(userAccountRepository.selectUserIdsByRetailerIds(fofoIds));
|
| - |
|
142 |
}
|
| 133 |
}
|
143 |
}
|
| 134 |
}
|
144 |
}
|
| 135 |
|
145 |
|
| 136 |
if (userIds.size() > 0) {
|
146 |
if (userIds.size() > 0) {
|
| 137 |
for (Integer userId : userIds) {
|
147 |
for (Integer userId : userIds) {
|