| Line 335... |
Line 335... |
| 335 |
throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
|
335 |
throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
|
| 336 |
}
|
336 |
}
|
| 337 |
|
337 |
|
| 338 |
// Validate fofoIds exist (0 means "All Partners")
|
338 |
// Validate fofoIds exist (0 means "All Partners")
|
| 339 |
List<Integer> fofoIds = createPositionModel.getFofoIds();
|
339 |
List<Integer> fofoIds = createPositionModel.getFofoIds();
|
| 340 |
if (fofoIds != null && !fofoIds.isEmpty()) {
|
340 |
if (fofoIds == null || fofoIds.isEmpty()) {
|
| - |
|
341 |
throw new ProfitMandiBusinessException("Position", 0, "At least one partner must be specified");
|
| - |
|
342 |
}
|
| 341 |
boolean hasAllPartners = fofoIds.contains(0);
|
343 |
boolean hasAllPartners = fofoIds.contains(0);
|
| 342 |
if (hasAllPartners && fofoIds.size() > 1) {
|
344 |
if (hasAllPartners && fofoIds.size() > 1) {
|
| 343 |
throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
|
345 |
throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
|
| 344 |
}
|
346 |
}
|
| 345 |
if (!hasAllPartners) {
|
347 |
if (!hasAllPartners) {
|
| 346 |
Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
|
348 |
Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
|
| 347 |
for (int fofoId : fofoIds) {
|
349 |
for (int fofoId : fofoIds) {
|
| 348 |
if (!validRetailers.containsKey(fofoId)) {
|
350 |
if (!validRetailers.containsKey(fofoId)) {
|
| 349 |
throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
|
351 |
throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
|
| 350 |
}
|
- |
|
| 351 |
}
|
352 |
}
|
| 352 |
}
|
353 |
}
|
| 353 |
}
|
354 |
}
|
| 354 |
|
355 |
|
| 355 |
Position position = positionRepository.selectPosition(authUserId, categoryId, regionId, createPositionModel.getEscalationType());
|
356 |
Position position = positionRepository.selectPosition(authUserId, categoryId, regionId, createPositionModel.getEscalationType());
|
| Line 394... |
Line 395... |
| 394 |
if (regionId > 0 && regionId != 5 && regionRepository.selectById(regionId) == null) {
|
395 |
if (regionId > 0 && regionId != 5 && regionRepository.selectById(regionId) == null) {
|
| 395 |
throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
|
396 |
throw new ProfitMandiBusinessException("Position", regionId, "Invalid regionId");
|
| 396 |
}
|
397 |
}
|
| 397 |
|
398 |
|
| 398 |
// Validate fofoIds exist (0 means "All Partners")
|
399 |
// Validate fofoIds exist (0 means "All Partners")
|
| 399 |
if (selectedFofoIds != null && !selectedFofoIds.isEmpty()) {
|
400 |
if (selectedFofoIds == null || selectedFofoIds.isEmpty()) {
|
| - |
|
401 |
throw new ProfitMandiBusinessException("Position", 0, "At least one partner must be specified");
|
| - |
|
402 |
}
|
| 400 |
boolean hasAllPartners = selectedFofoIds.contains(0);
|
403 |
boolean hasAllPartners = selectedFofoIds.contains(0);
|
| 401 |
if (hasAllPartners && selectedFofoIds.size() > 1) {
|
404 |
if (hasAllPartners && selectedFofoIds.size() > 1) {
|
| 402 |
throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
|
405 |
throw new ProfitMandiBusinessException("Position", 0, "Cannot mix 'All Partners' (0) with specific partner IDs");
|
| 403 |
}
|
406 |
}
|
| 404 |
if (!hasAllPartners) {
|
407 |
if (!hasAllPartners) {
|
| 405 |
Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
|
408 |
Map<Integer, CustomRetailer> validRetailers = retailerService.getFofoRetailers(false);
|
| 406 |
for (int fofoId : selectedFofoIds) {
|
409 |
for (int fofoId : selectedFofoIds) {
|
| 407 |
if (!validRetailers.containsKey(fofoId)) {
|
410 |
if (!validRetailers.containsKey(fofoId)) {
|
| 408 |
throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
|
411 |
throw new ProfitMandiBusinessException("Position", fofoId, "Invalid fofoId");
|
| 409 |
}
|
- |
|
| 410 |
}
|
412 |
}
|
| 411 |
}
|
413 |
}
|
| 412 |
}
|
414 |
}
|
| 413 |
|
415 |
|
| 414 |
partnerPositionRepository.delete(positionId);
|
416 |
partnerPositionRepository.delete(positionId);
|