From 53cb6884489611847d8c51fc77120167dc687e44 Mon Sep 17 00:00:00 2001 From: majian314 Date: Wed, 24 Sep 2025 16:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=9F=E8=BD=A6=E5=A5=97=E9=A4=90=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=B0=83=E6=95=B4=EF=BC=8C=E5=8F=96=E6=B6=88=E6=97=B6?= =?UTF-8?q?=E7=A7=9F=E5=92=8C=E4=BB=A5=E7=A7=9F=E4=BB=A3=E5=94=AE=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E7=A7=9F=E7=94=B5=E5=A5=97=E9=A4=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ZcRentBatteyRuleController.java | 7 ++++- .../controller/ZcRentCarRuleController.java | 26 ++++++++++++------- .../mapper/ZcRentBatteyRuleMapper.java | 1 + .../service/IZcRentBatteyRuleService.java | 1 + .../impl/ZcRentBatteyRuleServiceImpl.java | 6 ++++- .../operation/ZcRentBatteyRuleMapper.xml | 10 +++++-- .../templates/operation/rentCarRule/add.html | 24 +++++++++++------ 7 files changed, 54 insertions(+), 21 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentBatteyRuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentBatteyRuleController.java index 2d44199..a2304d1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentBatteyRuleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentBatteyRuleController.java @@ -125,7 +125,12 @@ public class ZcRentBatteyRuleController extends BaseController @ResponseBody public List listByLeaseType(@RequestParam("leaseType") Long leaseType) { ZcRentBatteyRule zcRentBatteyRule = new ZcRentBatteyRule(); - zcRentBatteyRule.setMealType(leaseType); + // 租车套餐的租赁类型2标识日租,3标识按天租;租电套餐1标识日租,2标识按天租 + Long durationType = 1L; + if(leaseType == 3L) { + durationType = 2L; + } + zcRentBatteyRule.setDurationType(durationType); return zcRentBatteyRuleService.selectZcRentBatteyRuleList(zcRentBatteyRule); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java index ca73128..bc223a1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/controller/ZcRentCarRuleController.java @@ -7,12 +7,8 @@ import java.util.Random; import java.util.stream.Collectors; import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.operation.domain.Company; -import com.ruoyi.operation.domain.ZcCarModel; -import com.ruoyi.operation.domain.ZcRentCarRuleBattery; -import com.ruoyi.operation.service.ICompanyService; -import com.ruoyi.operation.service.IZcCarModelService; -import com.ruoyi.operation.service.IZcRentCarRuleBatteryService; +import com.ruoyi.operation.domain.*; +import com.ruoyi.operation.service.*; import com.ruoyi.orders.domain.ZcOrderMain; import com.ruoyi.orders.service.IZcOrderMainService; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -22,8 +18,6 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.operation.domain.ZcRentCarRule; -import com.ruoyi.operation.service.IZcRentCarRuleService; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; @@ -51,7 +45,9 @@ public class ZcRentCarRuleController extends BaseController private IZcCarModelService zcCarModelService; @Autowired private IZcOrderMainService zcOrderMainService; - + @Autowired + private IZcRentBatteyRuleService zcRentBatteyRuleService; + @RequiresPermissions("operation:rentCarRule:view") @GetMapping() public String rentCarRule(ModelMap mmap) @@ -118,6 +114,18 @@ public class ZcRentCarRuleController extends BaseController @ResponseBody public AjaxResult addSave(@RequestParam("batteryRules") List batteryRuleIds, ZcRentCarRule zcRentCarRule) { + // 如果是按天租,验证选择的租电套餐支持天数是否一致 + if("3".equals(zcRentCarRule.getRentalType())){ + String[] stringArray = batteryRuleIds.stream() + .map(String::valueOf) + .toArray(String[]::new); + List batteyRuleList = zcRentBatteyRuleService.selectZcRentBatteyRuleByIds(stringArray); + for (ZcRentBatteyRule batteyRule : batteyRuleList) { + if(!String.valueOf(batteyRule.getDuration()).equals(String.valueOf(zcRentCarRule.getRentalDays()))){ + return error("选择租电套餐的租赁天数与租车套餐的租赁天数不一致。"); + } + } + } zcRentCarRule.setRuleCode(generateTimestampBasedCode()); zcRentCarRule.setCreateBy(getLoginName()); int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentBatteyRuleMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentBatteyRuleMapper.java index 2e93bc2..593ede2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentBatteyRuleMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/mapper/ZcRentBatteyRuleMapper.java @@ -19,6 +19,7 @@ public interface ZcRentBatteyRuleMapper */ public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id); + public List selectZcRentBatteyRuleByIds(String[] ids); /** * 查询租电套餐列表 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentBatteyRuleService.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentBatteyRuleService.java index d42103e..316fce6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentBatteyRuleService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/IZcRentBatteyRuleService.java @@ -19,6 +19,7 @@ public interface IZcRentBatteyRuleService */ public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id); + public List selectZcRentBatteyRuleByIds(String[] ids); /** * 查询租电套餐列表 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentBatteyRuleServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentBatteyRuleServiceImpl.java index de4e03d..169d6f0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentBatteyRuleServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/service/impl/ZcRentBatteyRuleServiceImpl.java @@ -31,7 +31,11 @@ public class ZcRentBatteyRuleServiceImpl implements IZcRentBatteyRuleService { return zcRentBatteyRuleMapper.selectZcRentBatteyRuleById(id); } - + @Override + public List selectZcRentBatteyRuleByIds(String[] ids) + { + return zcRentBatteyRuleMapper.selectZcRentBatteyRuleByIds(ids); + } /** * 查询租电套餐列表 * diff --git a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentBatteyRuleMapper.xml b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentBatteyRuleMapper.xml index cc156a0..92e008c 100644 --- a/ruoyi-admin/src/main/resources/mapper/operation/ZcRentBatteyRuleMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/operation/ZcRentBatteyRuleMapper.xml @@ -74,7 +74,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + insert into zc_rent_battey_rule @@ -179,4 +185,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - \ No newline at end of file + diff --git a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html index 8a201d9..785e115 100644 --- a/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html +++ b/ruoyi-admin/src/main/resources/templates/operation/rentCarRule/add.html @@ -84,7 +84,7 @@
- +
@@ -135,7 +135,7 @@ if(newRentalType === currentRentalType) { return; } - + // 更新当前值 currentRentalType = newRentalType; @@ -151,7 +151,11 @@ } else { $rentalDaysGroup.hide().find('input').val(''); } - + if(newRentalType === '1' || newRentalType === '4') { + $('#batteryRuleList').empty(); + $('#batteryRuleList').html("
"); + return; + } // 清空规则列表 $('#batteryRuleList').empty(); @@ -163,7 +167,7 @@ $.modal.alert("未找到与租赁类型相同的租电套餐"); } data.forEach(function(rule) { - html += `
`; + html += `
`; }); $('#batteryRuleList').html(html); }); @@ -171,9 +175,13 @@ }); }); function submitHandler() { - if($('input[name="batteryRules"]:checked').length === 0){ - $.modal.alert("请选择租电套餐"); - return; + var currentRentalType = $('input[name="rentalType"]:checked').val(); + // 检查初始选中项 + if(currentRentalType === '2' || currentRentalType === '3') { + if ($('input[name="batteryRules"]:checked').length === 0) { + $.modal.alert("请选择租电套餐"); + return; + } } if ($.validate.form()) { $.operate.save(prefix + "/add", $('#form-rentCarRule-add').serialize()); @@ -181,4 +189,4 @@ } - \ No newline at end of file +