diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcCarModelController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcCarModelController.java index 6866709..f538f86 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcCarModelController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcCarModelController.java @@ -1,8 +1,7 @@ package com.ruoyi.operation.controller; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.operation.domain.*; @@ -109,6 +108,34 @@ public class ZcCarModelController extends BaseController { return error("新增失败,该车型已存在"); } + String[] stringArray = rentCarRuleIds.stream() + .map(String::valueOf) + .toArray(String[]::new); + List carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); + + // 按类型分组 + Map> 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); + + if (hasDuplicateCommon) { + return error("新增失败,同一车型不允许设置相同类型套餐。"); + } + + // 专门检查类型3的租赁天数重复 + List type3Rules = typeGroups.get("3"); + if (type3Rules != null) { + Set rentalDaysSet = new HashSet<>(); + for (ZcRentCarRule rule : type3Rules) { + if (!rentalDaysSet.add(rule.getRentalDays())) { + return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); + } + } + } zcCarModel.setCreateBy(getLoginName()); return toAjax(zcCarModelService.insertZcCarModel(rentCarRuleIds, zcCarModel)); } @@ -146,6 +173,34 @@ public class ZcCarModelController extends BaseController { return error("修改失败,该车型已存在"); } + String[] stringArray = rentCarRuleIds.stream() + .map(String::valueOf) + .toArray(String[]::new); + List carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray); + + // 按类型分组 + Map> 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); + + if (hasDuplicateCommon) { + return error("新增失败,同一车型不允许设置相同类型套餐。"); + } + + // 专门检查类型3的租赁天数重复 + List type3Rules = typeGroups.get("3"); + if (type3Rules != null) { + Set rentalDaysSet = new HashSet<>(); + for (ZcRentCarRule rule : type3Rules) { + if (!rentalDaysSet.add(rule.getRentalDays())) { + return error("新增失败,同一车型不允许设置相同租赁天数的按天租套餐."); + } + } + } zcCarModel.setUpdateBy(getLoginName()); return toAjax(zcCarModelService.updateZcCarModel(rentCarRuleIds,zcCarModel)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java index 01d992f..7c3aec9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentCarRuleMapper.java @@ -19,6 +19,7 @@ public interface ZcRentCarRuleMapper */ public ZcRentCarRule selectZcRentCarRuleById(Long id); + public List selectZcRentCarRuleByIds(String[] ids); /** * 查询租车计费规则列表 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java index bedbc85..db5a553 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentCarRuleService.java @@ -20,6 +20,9 @@ public interface IZcRentCarRuleService */ public ZcRentCarRule selectZcRentCarRuleById(Long id); + public List selectZcRentCarRuleByIds(String[] ids); + + /** * 查询租车计费规则列表 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java index 9755493..0b5cfe4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentCarRuleServiceImpl.java @@ -43,6 +43,11 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService return zcRentCarRuleMapper.selectZcRentCarRuleById(id); } + @Override + public List selectZcRentCarRuleByIds(String[] ids) { + return zcRentCarRuleMapper.selectZcRentCarRuleByIds(ids); + } + /** * 查询租车计费规则列表 * diff --git a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml index 169ec22..d1af438 100644 --- a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentCarRuleMapper.xml @@ -65,7 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into zc_rent_car_rule @@ -164,4 +170,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - \ No newline at end of file + diff --git a/ruoyi-admin/src/main/resources/templates/orders/distrib/distrib.html b/ruoyi-admin/src/main/resources/templates/orders/distrib/distrib.html index 60fe4d7..33db53f 100644 --- a/ruoyi-admin/src/main/resources/templates/orders/distrib/distrib.html +++ b/ruoyi-admin/src/main/resources/templates/orders/distrib/distrib.html @@ -293,7 +293,7 @@ // 更新统计信息 $(".stat-item:eq(0) .value").text(formatAmount(result.orderCount) + "笔"); $(".stat-item:eq(1) .value").text(formatAmount(result.totalOrderAmount) + "元"); - $(".stat-item:eq(2) .value").text(formatNumber(result.totalDistribAmount)+ "元"); + $(".stat-item:eq(2) .value").text(formatAmount(result.totalDistribAmount)+ "元"); } } }); @@ -323,4 +323,4 @@ }; - \ No newline at end of file +