租车套餐设置调整,取消时租和以租代售绑定租电套餐逻辑

This commit is contained in:
majian314
2025-09-24 16:38:39 +08:00
parent d1b31a6820
commit 53cb688448
7 changed files with 54 additions and 21 deletions

View File

@ -125,7 +125,12 @@ public class ZcRentBatteyRuleController extends BaseController
@ResponseBody @ResponseBody
public List<ZcRentBatteyRule> listByLeaseType(@RequestParam("leaseType") Long leaseType) { public List<ZcRentBatteyRule> listByLeaseType(@RequestParam("leaseType") Long leaseType) {
ZcRentBatteyRule zcRentBatteyRule = new ZcRentBatteyRule(); 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); return zcRentBatteyRuleService.selectZcRentBatteyRuleList(zcRentBatteyRule);
} }
} }

View File

@ -7,12 +7,8 @@ import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.operation.domain.Company; import com.ruoyi.operation.domain.*;
import com.ruoyi.operation.domain.ZcCarModel; import com.ruoyi.operation.service.*;
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.orders.domain.ZcOrderMain; import com.ruoyi.orders.domain.ZcOrderMain;
import com.ruoyi.orders.service.IZcOrderMainService; import com.ruoyi.orders.service.IZcOrderMainService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -22,8 +18,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType; 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.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
@ -51,6 +45,8 @@ public class ZcRentCarRuleController extends BaseController
private IZcCarModelService zcCarModelService; private IZcCarModelService zcCarModelService;
@Autowired @Autowired
private IZcOrderMainService zcOrderMainService; private IZcOrderMainService zcOrderMainService;
@Autowired
private IZcRentBatteyRuleService zcRentBatteyRuleService;
@RequiresPermissions("operation:rentCarRule:view") @RequiresPermissions("operation:rentCarRule:view")
@GetMapping() @GetMapping()
@ -118,6 +114,18 @@ public class ZcRentCarRuleController extends BaseController
@ResponseBody @ResponseBody
public AjaxResult addSave(@RequestParam("batteryRules") List<Long> batteryRuleIds, ZcRentCarRule zcRentCarRule) public AjaxResult addSave(@RequestParam("batteryRules") List<Long> batteryRuleIds, ZcRentCarRule zcRentCarRule)
{ {
// 如果是按天租,验证选择的租电套餐支持天数是否一致
if("3".equals(zcRentCarRule.getRentalType())){
String[] stringArray = batteryRuleIds.stream()
.map(String::valueOf)
.toArray(String[]::new);
List<ZcRentBatteyRule> batteyRuleList = zcRentBatteyRuleService.selectZcRentBatteyRuleByIds(stringArray);
for (ZcRentBatteyRule batteyRule : batteyRuleList) {
if(!String.valueOf(batteyRule.getDuration()).equals(String.valueOf(zcRentCarRule.getRentalDays()))){
return error("选择租电套餐的租赁天数与租车套餐的租赁天数不一致。");
}
}
}
zcRentCarRule.setRuleCode(generateTimestampBasedCode()); zcRentCarRule.setRuleCode(generateTimestampBasedCode());
zcRentCarRule.setCreateBy(getLoginName()); zcRentCarRule.setCreateBy(getLoginName());
int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule); int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule);

View File

@ -19,6 +19,7 @@ public interface ZcRentBatteyRuleMapper
*/ */
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id); public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
public List<ZcRentBatteyRule> selectZcRentBatteyRuleByIds(String[] ids);
/** /**
* 查询租电套餐列表 * 查询租电套餐列表
* *

View File

@ -19,6 +19,7 @@ public interface IZcRentBatteyRuleService
*/ */
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id); public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
public List<ZcRentBatteyRule> selectZcRentBatteyRuleByIds(String[] ids);
/** /**
* 查询租电套餐列表 * 查询租电套餐列表
* *

View File

@ -31,7 +31,11 @@ public class ZcRentBatteyRuleServiceImpl implements IZcRentBatteyRuleService
{ {
return zcRentBatteyRuleMapper.selectZcRentBatteyRuleById(id); return zcRentBatteyRuleMapper.selectZcRentBatteyRuleById(id);
} }
@Override
public List<ZcRentBatteyRule> selectZcRentBatteyRuleByIds(String[] ids)
{
return zcRentBatteyRuleMapper.selectZcRentBatteyRuleByIds(ids);
}
/** /**
* 查询租电套餐列表 * 查询租电套餐列表
* *

View File

@ -74,6 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectZcRentBatteyRuleVo"/> <include refid="selectZcRentBatteyRuleVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="selectZcRentBatteyRuleByIds" resultType="com.ruoyi.operation.domain.ZcRentBatteyRule">
select * from zc_rent_battey_rule where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertZcRentBatteyRule" parameterType="ZcRentBatteyRule" useGeneratedKeys="true" keyProperty="id"> <insert id="insertZcRentBatteyRule" parameterType="ZcRentBatteyRule" useGeneratedKeys="true" keyProperty="id">
insert into zc_rent_battey_rule insert into zc_rent_battey_rule

View File

@ -84,7 +84,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">租电套餐:</label> <label class="col-sm-3 control-label ">租电套餐:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div id="batteryRuleList"></div> <div id="batteryRuleList"></div>
</div> </div>
@ -151,7 +151,11 @@
} else { } else {
$rentalDaysGroup.hide().find('input').val(''); $rentalDaysGroup.hide().find('input').val('');
} }
if(newRentalType === '1' || newRentalType === '4') {
$('#batteryRuleList').empty();
$('#batteryRuleList').html("<div><label style='padding-top: 6px'>无</label></div>");
return;
}
// 清空规则列表 // 清空规则列表
$('#batteryRuleList').empty(); $('#batteryRuleList').empty();
@ -163,7 +167,7 @@
$.modal.alert("未找到与租赁类型相同的租电套餐"); $.modal.alert("未找到与租赁类型相同的租电套餐");
} }
data.forEach(function(rule) { data.forEach(function(rule) {
html += `<div class="checkbox"><label><input type="checkbox" id="batteryRules" name="batteryRules" value="${rule.id}"> ${rule.title}</label></div>`; html += `<div class="checkbox"><label><input type="checkbox" id="batteryRules" name="batteryRules" value="${rule.id}"> ${rule.title},电压${rule.voltage},电容${rule.ah},租赁${rule.duration}</label></div>`;
}); });
$('#batteryRuleList').html(html); $('#batteryRuleList').html(html);
}); });
@ -171,10 +175,14 @@
}); });
}); });
function submitHandler() { function submitHandler() {
var currentRentalType = $('input[name="rentalType"]:checked').val();
// 检查初始选中项
if(currentRentalType === '2' || currentRentalType === '3') {
if ($('input[name="batteryRules"]:checked').length === 0) { if ($('input[name="batteryRules"]:checked').length === 0) {
$.modal.alert("请选择租电套餐"); $.modal.alert("请选择租电套餐");
return; return;
} }
}
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-rentCarRule-add').serialize()); $.operate.save(prefix + "/add", $('#form-rentCarRule-add').serialize());
} }