租车套餐
This commit is contained in:
@ -1,20 +1,20 @@
|
||||
package com.ruoyi.operation.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.operation.domain.Company;
|
||||
import com.ruoyi.operation.domain.ZcRentCarRuleBattery;
|
||||
import com.ruoyi.operation.service.ICompanyService;
|
||||
import com.ruoyi.operation.service.IZcRentCarRuleBatteryService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.operation.domain.ZcRentCarRule;
|
||||
@ -40,6 +40,9 @@ public class ZcRentCarRuleController extends BaseController
|
||||
private IZcRentCarRuleService zcRentCarRuleService;
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
@Autowired
|
||||
private IZcRentCarRuleBatteryService zcRentCarRuleBatteryService;
|
||||
|
||||
|
||||
@RequiresPermissions("operation:rentCarRule:view")
|
||||
@GetMapping()
|
||||
@ -101,11 +104,26 @@ public class ZcRentCarRuleController extends BaseController
|
||||
@Log(title = "租车计费规则", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(ZcRentCarRule zcRentCarRule)
|
||||
public AjaxResult addSave(@RequestParam("batteryRules") List<Long> batteryRuleIds, ZcRentCarRule zcRentCarRule)
|
||||
{
|
||||
zcRentCarRule.setRuleCode(generateTimestampBasedCode());
|
||||
zcRentCarRule.setCreateBy(getLoginName());
|
||||
return toAjax(zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule));
|
||||
int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule);
|
||||
|
||||
|
||||
// 保存关联表 ZcRentCarRuleBattery 数据
|
||||
List<ZcRentCarRuleBattery> ruleBatteryList = new ArrayList<>();
|
||||
for (Long batteryRuleId : batteryRuleIds) {
|
||||
ZcRentCarRuleBattery ruleBattery = new ZcRentCarRuleBattery();
|
||||
ruleBattery.setCarRuleId(zcRentCarRule.getId());
|
||||
ruleBattery.setBatteryRuleId(batteryRuleId);
|
||||
ruleBattery.setCreateTime(new Date());
|
||||
ruleBatteryList.add(ruleBattery);
|
||||
}
|
||||
if (!ruleBatteryList.isEmpty()) {
|
||||
zcRentCarRuleBatteryService.batchInsert(ruleBatteryList);
|
||||
}
|
||||
return toAjax(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,6 +154,18 @@ public class ZcRentCarRuleController extends BaseController
|
||||
return toAjax(zcRentCarRuleService.updateZcRentCarRule(zcRentCarRule));
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{id}")
|
||||
public String detail(@PathVariable("id") Long id, ModelMap mmap) {
|
||||
ZcRentCarRule zcRentCarRule = zcRentCarRuleService.selectZcRentCarRuleById(id);
|
||||
mmap.put("zcRentCarRule", zcRentCarRule);
|
||||
List<Company> companyList = companyService.getCompanyList(new Company(),getSysUser()); // 获取运营商列表
|
||||
mmap.put("companyList", companyList); // 将运营商列表传递到前端
|
||||
// 查询已绑定的电池规则ID列表
|
||||
List<Long> batteryRuleIds = zcRentCarRuleBatteryService.selectBatteryRuleIdsByCarRuleId(id);
|
||||
mmap.put("selectedBatteryRuleIds", batteryRuleIds);
|
||||
return prefix + "/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租车计费规则
|
||||
*/
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ruoyi.operation.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.operation.domain.ZcRentCarRuleBattery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 租车规则租电规则关联Mapper接口
|
||||
@ -27,6 +28,7 @@ public interface ZcRentCarRuleBatteryMapper
|
||||
*/
|
||||
public List<ZcRentCarRuleBattery> selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery);
|
||||
|
||||
List<Long> selectBatteryRuleIdsByCarRuleId(Long carRuleId);
|
||||
/**
|
||||
* 新增租车规则租电规则关联
|
||||
*
|
||||
@ -58,4 +60,7 @@ public interface ZcRentCarRuleBatteryMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteZcRentCarRuleBatteryByIds(String[] ids);
|
||||
|
||||
|
||||
int batchInsert(@Param("list") List<ZcRentCarRuleBattery> ruleBatteryList);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ public interface IZcRentCarRuleBatteryService
|
||||
*/
|
||||
public List<ZcRentCarRuleBattery> selectZcRentCarRuleBatteryList(ZcRentCarRuleBattery zcRentCarRuleBattery);
|
||||
|
||||
List<Long> selectBatteryRuleIdsByCarRuleId(Long carRuleId);
|
||||
/**
|
||||
* 新增租车规则租电规则关联
|
||||
*
|
||||
@ -35,6 +36,8 @@ public interface IZcRentCarRuleBatteryService
|
||||
*/
|
||||
public int insertZcRentCarRuleBattery(ZcRentCarRuleBattery zcRentCarRuleBattery);
|
||||
|
||||
public int batchInsert(List<ZcRentCarRuleBattery> zcRentCarRuleBatteryList);
|
||||
|
||||
/**
|
||||
* 修改租车规则租电规则关联
|
||||
*
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.operation.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -45,6 +46,11 @@ public class ZcRentCarRuleBatteryServiceImpl implements IZcRentCarRuleBatterySer
|
||||
return zcRentCarRuleBatteryMapper.selectZcRentCarRuleBatteryList(zcRentCarRuleBattery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> selectBatteryRuleIdsByCarRuleId(Long carRuleId) {
|
||||
return zcRentCarRuleBatteryMapper.selectBatteryRuleIdsByCarRuleId(carRuleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租车规则租电规则关联
|
||||
*
|
||||
@ -58,6 +64,11 @@ public class ZcRentCarRuleBatteryServiceImpl implements IZcRentCarRuleBatterySer
|
||||
return zcRentCarRuleBatteryMapper.insertZcRentCarRuleBattery(zcRentCarRuleBattery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchInsert(List<ZcRentCarRuleBattery> zcRentCarRuleBatteryList) {
|
||||
return zcRentCarRuleBatteryMapper.batchInsert(zcRentCarRuleBatteryList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租车规则租电规则关联
|
||||
*
|
||||
|
||||
@ -34,7 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectZcRentCarRuleBatteryVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectBatteryRuleIdsByCarRuleId" resultType="long">
|
||||
SELECT battery_rule_id FROM zc_rent_car_rule_battery WHERE car_rule_id = #{carRuleId}
|
||||
</select>
|
||||
|
||||
<insert id="insertZcRentCarRuleBattery" parameterType="ZcRentCarRuleBattery" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zc_rent_car_rule_battery
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
@ -88,4 +92,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchInsert">
|
||||
INSERT INTO zc_rent_car_rule_battery (car_rule_id, battery_rule_id,create_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.carRuleId}, #{item.batteryRuleId}, #{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -12,12 +12,6 @@
|
||||
<input name="ruleName" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">套餐编码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="ruleCode" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">租赁类型:</label>
|
||||
<div class="col-sm-8">
|
||||
@ -156,7 +150,7 @@
|
||||
$.get(prefix2 + '/list/byLeaseType', { leaseType: newRentalType }, function(data) {
|
||||
var html = '';
|
||||
data.forEach(function(rule) {
|
||||
html += `<div class="checkbox"><label><input type="checkbox" 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}</label></div>`;
|
||||
});
|
||||
$('#batteryRuleList').html(html);
|
||||
});
|
||||
|
||||
@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('租车计费规则')" />
|
||||
</head>
|
||||
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-rentCarRule-edit" th:object="${zcRentCarRule}">
|
||||
<input name="id" th:field="*{id}" type="hidden">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">套餐名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="ruleName" th:field="*{ruleName}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">租赁类型:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('key_rent_type')}">
|
||||
<input type="radio" th:id="${'rentalType_' + dict.dictCode}" name="rentalType" th:value="${dict.dictValue}" th:checked="${dict.default}" th:field="*{rentalType}" >
|
||||
<label th:for="${'rentalType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">租赁天数:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="rentalDays" th:field="*{rentalDays}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">租车价格(元):</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="rentalPrice" th:field="*{rentalPrice}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">押金价格(元):</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="depositPrice" th:field="*{depositPrice}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">逾期金额(元):</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="overdueFee" th:field="*{overdueFee}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">逾期计费类型:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('key_rent_overdue_type')}">
|
||||
<input type="radio" th:id="${'overdueType_' + dict.dictCode}" name="overdueType" th:value="${dict.dictValue}" th:checked="${dict.default}" th:field="*{overdueType}" >
|
||||
<label th:for="${'overdueType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">是否支持免押:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('key_rent_deposit_free')}">
|
||||
<input type="radio" th:id="${'depositFree_' + dict.dictCode}" name="depositFree" th:value="${dict.dictValue}" th:checked="${dict.default}" th:field="*{depositFree}" >
|
||||
<label th:for="${'depositFree_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">是否支持代扣:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('key_rent_auto_deduct')}">
|
||||
<input type="radio" th:id="${'autoDeduct_' + dict.dictCode}" name="autoDeduct" th:value="${dict.dictValue}" th:checked="${dict.default}" th:field="*{autoDeduct}" >
|
||||
<label th:for="${'autoDeduct_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">所属运营商:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="operatingCompanyId" id="operatingCompanyId" class="form-control m-b" disabled>
|
||||
<option value="">请选择所属运营商</option>
|
||||
<option th:each="company : ${companyList}" th:value="${company.id}" th:text="${company.companyName}" th:field="*{operatingCompanyId}" ></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">租电套餐:</label>
|
||||
<div class="col-sm-8">
|
||||
<div id="batteryRuleList"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "operation/rentCarRule";
|
||||
var prefix2 = ctx + "operation/rentBatteyRule"
|
||||
var selectedBatteryRuleIds = [[${#strings.listJoin(selectedBatteryRuleIds, ',')}]];
|
||||
$("#form-rentCarRule-edit").validate({
|
||||
rules:{
|
||||
rentalPrice:{
|
||||
number:true
|
||||
},
|
||||
depositPrice:{
|
||||
number:true
|
||||
},
|
||||
overdueFee:{
|
||||
number:true
|
||||
}
|
||||
},
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// 初始隐藏租赁天数
|
||||
$('input[name="rentalDays"]').closest('.form-group').hide();
|
||||
|
||||
// 检查初始选中项
|
||||
if($('input[name="rentalType"]:checked').val() === '3') {
|
||||
$('input[name="rentalDays"]').closest('.form-group').show();
|
||||
}
|
||||
var currentRentalType = $('input[name="rentalType"]:checked').val();
|
||||
|
||||
// 加载租电规则并回显已选中的项
|
||||
loadBatteryRules(currentRentalType, /* 回显已选中 */ true);
|
||||
});
|
||||
|
||||
function loadBatteryRules(leaseType, isEdit) {
|
||||
$.get(prefix2 + '/list/byLeaseType', { leaseType: leaseType }, function(data) {
|
||||
var html = '';
|
||||
data.forEach(function(rule) {
|
||||
var checked = '';
|
||||
if (isEdit && selectedBatteryRuleIds.includes(rule.id)) {
|
||||
checked = 'checked';
|
||||
}
|
||||
html += `<div class="checkbox"><label><input type="checkbox" name="batteryRules" value="${rule.id}" ${checked}> ${rule.title}</label></div>`;
|
||||
});
|
||||
$('#batteryRuleList').html(html);
|
||||
});
|
||||
}
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/edit", $('#form-rentCarRule-edit').serialize());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -13,12 +13,6 @@
|
||||
<input name="ruleName" th:field="*{ruleName}" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">套餐编码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="ruleCode" th:field="*{ruleCode}" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">租赁类型:</label>
|
||||
<div class="col-sm-8">
|
||||
|
||||
@ -97,6 +97,7 @@
|
||||
url: prefix + "/list",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
detailUrl: prefix + "/detail/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
modalName: "租车套餐",
|
||||
@ -160,10 +161,6 @@
|
||||
return $.table.selectDictLabel(autoDeductDatas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'operatingCompanyId',
|
||||
title: '关联电池套餐'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
@ -180,13 +177,14 @@
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
if (row.status == 1) {
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="enable(\'' + row.id + '\',\'' + row.phone + '\')"><i class="fa fa-edit"></i>启用</a> ');
|
||||
} else {
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="disable(\'' + row.id + '\',\'' + row.phone + '\')"><i class="fa fa-edit"></i>停用</a> ');
|
||||
}
|
||||
actions.push('<a class="btn btn-primary btn-xs btnOption" href="javascript:void(0)" onClick="$.operate.detail(\''+row.id+'\', 900, 700)"><i class="fa fa-sticky-note-o"></i> 查看</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
@ -195,7 +193,7 @@
|
||||
});
|
||||
|
||||
/* 停用 */
|
||||
function disable(id,phone) {
|
||||
function disable(id, phone) {
|
||||
$.modal.confirm("确认是否停用该套餐?<span style='color: red'>此套餐停用后正在租用订单继续生效,续租订单继续以原订单为准</span>", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user