车型添加时如果套餐未选择,则不验证
This commit is contained in:
		| @ -108,31 +108,33 @@ public class ZcCarModelController extends BaseController | ||||
|         { | ||||
|             return error("新增失败,该车型已存在"); | ||||
|         } | ||||
|         String[] stringArray = rentCarRuleIds.stream() | ||||
|                 .map(String::valueOf) | ||||
|                 .toArray(String[]::new); | ||||
|         List<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); | ||||
|         if(rentCarRuleIds.size() > 0){ | ||||
|             String[] stringArray = rentCarRuleIds.stream() | ||||
|                     .map(String::valueOf) | ||||
|                     .toArray(String[]::new); | ||||
|             List<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); | ||||
|  | ||||
|         // 按类型分组 | ||||
|         Map<String, List<ZcRentCarRule>> typeGroups = carRuleList.stream() | ||||
|                 .collect(Collectors.groupingBy(ZcRentCarRule::getRentalType)); | ||||
|             // 按类型分组 | ||||
|             Map<String, List<ZcRentCarRule>> typeGroups = carRuleList.stream() | ||||
|                     .collect(Collectors.groupingBy(ZcRentCarRule::getRentalType)); | ||||
|  | ||||
|         // 检查类型1、2、4的重复 | ||||
|         boolean hasDuplicateCommon = typeGroups.entrySet().stream() | ||||
|                 .filter(entry -> !"3".equals(entry.getKey())) // 排除类型3 | ||||
|                 .anyMatch(entry -> entry.getValue().size() > 1); | ||||
|             // 检查类型1、2、4的重复 | ||||
|             boolean hasDuplicateCommon = typeGroups.entrySet().stream() | ||||
|                     .filter(entry -> !"3".equals(entry.getKey())) // 排除类型3 | ||||
|                     .anyMatch(entry -> entry.getValue().size() > 1); | ||||
|  | ||||
|         if (hasDuplicateCommon) { | ||||
|             return error("新增失败,同一车型不允许设置相同类型套餐。"); | ||||
|         } | ||||
|             if (hasDuplicateCommon) { | ||||
|                 return error("新增失败,同一车型不允许设置相同类型套餐。"); | ||||
|             } | ||||
|  | ||||
|         // 专门检查类型3的租赁天数重复 | ||||
|         List<ZcRentCarRule> type3Rules = typeGroups.get("3"); | ||||
|         if (type3Rules != null) { | ||||
|             Set<Long> rentalDaysSet = new HashSet<>(); | ||||
|             for (ZcRentCarRule rule : type3Rules) { | ||||
|                 if (!rentalDaysSet.add(rule.getRentalDays())) { | ||||
|                     return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); | ||||
|             // 专门检查类型3的租赁天数重复 | ||||
|             List<ZcRentCarRule> type3Rules = typeGroups.get("3"); | ||||
|             if (type3Rules != null) { | ||||
|                 Set<Long> rentalDaysSet = new HashSet<>(); | ||||
|                 for (ZcRentCarRule rule : type3Rules) { | ||||
|                     if (!rentalDaysSet.add(rule.getRentalDays())) { | ||||
|                         return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -173,31 +175,33 @@ public class ZcCarModelController extends BaseController | ||||
|         { | ||||
|             return error("修改失败,该车型已存在"); | ||||
|         } | ||||
|         String[] stringArray = rentCarRuleIds.stream() | ||||
|                 .map(String::valueOf) | ||||
|                 .toArray(String[]::new); | ||||
|         List<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); | ||||
|         if(rentCarRuleIds.size() > 0) { | ||||
|             String[] stringArray = rentCarRuleIds.stream() | ||||
|                     .map(String::valueOf) | ||||
|                     .toArray(String[]::new); | ||||
|             List<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); | ||||
|  | ||||
|         // 按类型分组 | ||||
|         Map<String, List<ZcRentCarRule>> typeGroups = carRuleList.stream() | ||||
|                 .collect(Collectors.groupingBy(ZcRentCarRule::getRentalType)); | ||||
|             // 按类型分组 | ||||
|             Map<String, List<ZcRentCarRule>> typeGroups = carRuleList.stream() | ||||
|                     .collect(Collectors.groupingBy(ZcRentCarRule::getRentalType)); | ||||
|  | ||||
|         // 检查类型1、2、4的重复 | ||||
|         boolean hasDuplicateCommon = typeGroups.entrySet().stream() | ||||
|                 .filter(entry -> !"3".equals(entry.getKey())) // 排除类型3 | ||||
|                 .anyMatch(entry -> entry.getValue().size() > 1); | ||||
|             // 检查类型1、2、4的重复 | ||||
|             boolean hasDuplicateCommon = typeGroups.entrySet().stream() | ||||
|                     .filter(entry -> !"3".equals(entry.getKey())) // 排除类型3 | ||||
|                     .anyMatch(entry -> entry.getValue().size() > 1); | ||||
|  | ||||
|         if (hasDuplicateCommon) { | ||||
|             return error("新增失败,同一车型不允许设置相同类型套餐。"); | ||||
|         } | ||||
|             if (hasDuplicateCommon) { | ||||
|                 return error("新增失败,同一车型不允许设置相同类型套餐。"); | ||||
|             } | ||||
|  | ||||
|         // 专门检查类型3的租赁天数重复 | ||||
|         List<ZcRentCarRule> type3Rules = typeGroups.get("3"); | ||||
|         if (type3Rules != null) { | ||||
|             Set<Long> rentalDaysSet = new HashSet<>(); | ||||
|             for (ZcRentCarRule rule : type3Rules) { | ||||
|                 if (!rentalDaysSet.add(rule.getRentalDays())) { | ||||
|                     return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); | ||||
|             // 专门检查类型3的租赁天数重复 | ||||
|             List<ZcRentCarRule> type3Rules = typeGroups.get("3"); | ||||
|             if (type3Rules != null) { | ||||
|                 Set<Long> rentalDaysSet = new HashSet<>(); | ||||
|                 for (ZcRentCarRule rule : type3Rules) { | ||||
|                     if (!rentalDaysSet.add(rule.getRentalDays())) { | ||||
|                         return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 19173159168
					19173159168