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

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
public List<ZcRentBatteyRule> 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);
}
}

View File

@ -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<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.setCreateBy(getLoginName());
int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule);

View File

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

View File

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

View File

@ -74,7 +74,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectZcRentBatteyRuleVo"/>
where id = #{id}
</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 into zc_rent_battey_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -179,4 +185,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -84,7 +84,7 @@
</div>
</div>
<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 id="batteryRuleList"></div>
</div>
@ -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("<div><label style='padding-top: 6px'>无</label></div>");
return;
}
// 清空规则列表
$('#batteryRuleList').empty();
@ -163,7 +167,7 @@
$.modal.alert("未找到与租赁类型相同的租电套餐");
}
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);
});
@ -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 @@
}
</script>
</body>
</html>
</html>