租车套餐设置调整,取消时租和以租代售绑定租电套餐逻辑
This commit is contained in:
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -19,6 +19,7 @@ public interface ZcRentBatteyRuleMapper
|
|||||||
*/
|
*/
|
||||||
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
|
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
|
||||||
|
|
||||||
|
public List<ZcRentBatteyRule> selectZcRentBatteyRuleByIds(String[] ids);
|
||||||
/**
|
/**
|
||||||
* 查询租电套餐列表
|
* 查询租电套餐列表
|
||||||
*
|
*
|
||||||
|
|||||||
@ -19,6 +19,7 @@ public interface IZcRentBatteyRuleService
|
|||||||
*/
|
*/
|
||||||
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
|
public ZcRentBatteyRule selectZcRentBatteyRuleById(Long id);
|
||||||
|
|
||||||
|
public List<ZcRentBatteyRule> selectZcRentBatteyRuleByIds(String[] ids);
|
||||||
/**
|
/**
|
||||||
* 查询租电套餐列表
|
* 查询租电套餐列表
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 查询租电套餐列表
|
* 查询租电套餐列表
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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,9 +175,13 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
function submitHandler() {
|
function submitHandler() {
|
||||||
if($('input[name="batteryRules"]:checked').length === 0){
|
var currentRentalType = $('input[name="rentalType"]:checked').val();
|
||||||
$.modal.alert("请选择租电套餐");
|
// 检查初始选中项
|
||||||
return;
|
if(currentRentalType === '2' || currentRentalType === '3') {
|
||||||
|
if ($('input[name="batteryRules"]:checked').length === 0) {
|
||||||
|
$.modal.alert("请选择租电套餐");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($.validate.form()) {
|
if ($.validate.form()) {
|
||||||
$.operate.save(prefix + "/add", $('#form-rentCarRule-add').serialize());
|
$.operate.save(prefix + "/add", $('#form-rentCarRule-add').serialize());
|
||||||
|
|||||||
Reference in New Issue
Block a user