分润显示错误bug,设置车型同类型套餐只能设置一个

This commit is contained in:
majian314
2025-09-28 16:02:21 +08:00
parent 9bef984c0c
commit 077ce82739
6 changed files with 77 additions and 7 deletions

View File

@ -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<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray);
// 按类型分组
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);
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("新增失败,同一车型不允许设置相同租赁天数的按天租套餐.");
}
}
}
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<ZcRentCarRule> carRuleList = zcRentCarRuleService.selectZcRentCarRuleByIds(stringArray);
// 按类型分组
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);
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("新增失败,同一车型不允许设置相同租赁天数的按天租套餐.");
}
}
}
zcCarModel.setUpdateBy(getLoginName());
return toAjax(zcCarModelService.updateZcCarModel(rentCarRuleIds,zcCarModel));
}

View File

@ -19,6 +19,7 @@ public interface ZcRentCarRuleMapper
*/
public ZcRentCarRule selectZcRentCarRuleById(Long id);
public List<ZcRentCarRule> selectZcRentCarRuleByIds(String[] ids);
/**
* 查询租车计费规则列表
*

View File

@ -20,6 +20,9 @@ public interface IZcRentCarRuleService
*/
public ZcRentCarRule selectZcRentCarRuleById(Long id);
public List<ZcRentCarRule> selectZcRentCarRuleByIds(String[] ids);
/**
* 查询租车计费规则列表
*

View File

@ -43,6 +43,11 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
return zcRentCarRuleMapper.selectZcRentCarRuleById(id);
}
@Override
public List<ZcRentCarRule> selectZcRentCarRuleByIds(String[] ids) {
return zcRentCarRuleMapper.selectZcRentCarRuleByIds(ids);
}
/**
* 查询租车计费规则列表
*

View File

@ -65,7 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectZcRentCarRuleVo"/>
where id = #{id}
</select>
<select id="selectZcRentCarRuleByIds" resultMap="ZcRentCarRuleResult">
<include refid="selectZcRentCarRuleVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertZcRentCarRule" parameterType="ZcRentCarRule" useGeneratedKeys="true" keyProperty="id">
insert into zc_rent_car_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -164,4 +170,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -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 @@
};
</script>
</body>
</html>
</html>