车型与套餐

This commit is contained in:
19173159168
2025-07-12 23:26:47 +08:00
parent 092d866283
commit f0812d0cba
13 changed files with 271 additions and 36 deletions

View File

@ -97,21 +97,7 @@ public class ZcCarModelController extends BaseController
public AjaxResult addSave(@RequestParam("rentCarRuleIds") List<Long> rentCarRuleIds, ZcCarModel zcCarModel)
{
zcCarModel.setCreateBy(getLoginName());
int flag = zcCarModelService.insertZcCarModel(zcCarModel);
// 保存关联表 ZcRentCarRuleBattery 数据
List<ZcCarModelPackage> carModelPackageList = new ArrayList<>();
for (Long rentCarRuleId : rentCarRuleIds) {
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarModelId(zcCarModel.getId());
zcCarModelPackage.setCarRuleId(rentCarRuleId);
zcCarModelPackage.setCreateTime(new Date());
carModelPackageList.add(zcCarModelPackage);
}
if (!carModelPackageList.isEmpty()) {
zcCarModelPackageService.batchInsert(carModelPackageList);
}
return toAjax(flag);
return toAjax(zcCarModelService.insertZcCarModel(rentCarRuleIds, zcCarModel));
}
/**
@ -121,6 +107,9 @@ public class ZcCarModelController extends BaseController
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleService.selectZcRentCarRuleListByCarModelId(id);
mmap.put("rentCarRuleList", rentCarRuleList);
ZcCarModel zcCarModel = zcCarModelService.selectZcCarModelById(id);
mmap.put("zcCarModel", zcCarModel);
return prefix + "/edit";
@ -133,10 +122,10 @@ public class ZcCarModelController extends BaseController
@Log(title = "车型管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(ZcCarModel zcCarModel)
public AjaxResult editSave(@RequestParam("rentCarRuleIds") List<Long> rentCarRuleIds, ZcCarModel zcCarModel)
{
zcCarModel.setUpdateBy(getLoginName());
return toAjax(zcCarModelService.updateZcCarModel(zcCarModel));
return toAjax(zcCarModelService.updateZcCarModel(rentCarRuleIds,zcCarModel));
}
/**

View File

@ -1,6 +1,8 @@
package com.ruoyi.operation.domain;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -55,6 +57,9 @@ public class ZcCarModel extends BaseEntity
/** 扩展字段3 */
private String extend3;
private List<ZcRentCarRule> rentCarRuleList;
public void setId(Long id)
{
this.id = id;
@ -164,6 +169,14 @@ public class ZcCarModel extends BaseEntity
return extend3;
}
public List<ZcRentCarRule> getRentCarRuleList() {
return rentCarRuleList;
}
public void setRentCarRuleList(List<ZcRentCarRule> rentCarRuleList) {
this.rentCarRuleList = rentCarRuleList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -89,6 +89,11 @@ public class ZcRentCarRule extends BaseEntity
/** 扩展字段5 */
private String extend5;
@Transient
private Long carRuleId;
/** 车型是否关联此套餐标识 默认不存在 */
@Transient
private boolean flag = false;
@Transient
private String operatingCompanyName;
@ -281,10 +286,29 @@ public class ZcRentCarRule extends BaseEntity
this.operatingCompanyName = operatingCompanyName;
}
public Long getCarRuleId() {
return carRuleId;
}
public void setCarRuleId(Long carRuleId) {
this.id = carRuleId;
this.carRuleId = carRuleId;
}
public boolean isFlag()
{
return flag;
}
public void setFlag(boolean flag)
{
this.flag = flag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("carRuleId", getCarRuleId())
.append("ruleName", getRuleName())
.append("ruleCode", getRuleCode())
.append("rentalType", getRentalType())

View File

@ -54,6 +54,7 @@ public interface ZcCarModelPackageMapper
*/
public int deleteZcCarModelPackageById(Long id);
public int deleteZcCarModelPackageByModeId(Long modeId);
/**
* 批量删除车型与租车规则关联
*

View File

@ -52,6 +52,7 @@ public interface IZcCarModelPackageService
*/
public int deleteZcCarModelPackageByIds(String ids);
public int deleteZcCarModelPackageByModeId(Long modeId);
/**
* 删除车型与租车规则关联信息
*

View File

@ -33,7 +33,7 @@ public interface IZcCarModelService
* @param zcCarModel 车型管理
* @return 结果
*/
public int insertZcCarModel(ZcCarModel zcCarModel);
public int insertZcCarModel(List<Long> rentCarRuleIds, ZcCarModel zcCarModel);
/**
* 修改车型管理
@ -43,6 +43,8 @@ public interface IZcCarModelService
*/
public int updateZcCarModel(ZcCarModel zcCarModel);
public int updateZcCarModel(List<Long> rentCarRuleIds, ZcCarModel zcCarModel);
/**
* 批量删除车型管理
*

View File

@ -28,6 +28,8 @@ public interface IZcRentCarRuleService
*/
public List<ZcRentCarRule> selectZcRentCarRuleList(ZcRentCarRule zcRentCarRule);
public List<ZcRentCarRule> selectZcRentCarRuleListByCarModelId(Long carModelId);
/**
* 新增租车计费规则
*

View File

@ -88,6 +88,13 @@ public class ZcCarModelPackageServiceImpl implements IZcCarModelPackageService
return zcCarModelPackageMapper.deleteZcCarModelPackageByIds(Convert.toStrArray(ids));
}
@Override
public int deleteZcCarModelPackageByModeId(Long modeId)
{
return zcCarModelPackageMapper.deleteZcCarModelPackageByModeId(modeId);
}
/**
* 删除车型与租车规则关联信息
*

View File

@ -1,13 +1,18 @@
package com.ruoyi.operation.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.operation.domain.ZcCarModelPackage;
import com.ruoyi.operation.service.IZcCarModelPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.operation.mapper.ZcCarModelMapper;
import com.ruoyi.operation.domain.ZcCarModel;
import com.ruoyi.operation.service.IZcCarModelService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
/**
* 车型管理Service业务层处理
@ -20,7 +25,8 @@ public class ZcCarModelServiceImpl implements IZcCarModelService
{
@Autowired
private ZcCarModelMapper zcCarModelMapper;
@Autowired
private IZcCarModelPackageService zcCarModelPackageService;
/**
* 查询车型管理
*
@ -52,11 +58,27 @@ public class ZcCarModelServiceImpl implements IZcCarModelService
* @return 结果
*/
@Override
public int insertZcCarModel(ZcCarModel zcCarModel)
@Transactional
public int insertZcCarModel(List<Long> rentCarRuleIds, ZcCarModel zcCarModel)
{
zcCarModel.setCreateTime(DateUtils.getNowDate());
zcCarModel.setUpdateTime(DateUtils.getNowDate());
return zcCarModelMapper.insertZcCarModel(zcCarModel);
int flag = zcCarModelMapper.insertZcCarModel(zcCarModel);
// 保存关联表 ZcRentCarRuleBattery 数据
List<ZcCarModelPackage> carModelPackageList = new ArrayList<>();
for (Long rentCarRuleId : rentCarRuleIds) {
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarModelId(zcCarModel.getId());
zcCarModelPackage.setCarRuleId(rentCarRuleId);
zcCarModelPackage.setCreateTime(new Date());
carModelPackageList.add(zcCarModelPackage);
}
if (!carModelPackageList.isEmpty()) {
zcCarModelPackageService.batchInsert(carModelPackageList);
}
return flag;
}
/**
@ -72,6 +94,29 @@ public class ZcCarModelServiceImpl implements IZcCarModelService
return zcCarModelMapper.updateZcCarModel(zcCarModel);
}
@Override
@Transactional
public int updateZcCarModel(List<Long> rentCarRuleIds,ZcCarModel zcCarModel)
{
zcCarModel.setUpdateTime(DateUtils.getNowDate());
int flag = zcCarModelMapper.updateZcCarModel(zcCarModel);
zcCarModelPackageService.deleteZcCarModelPackageByModeId(zcCarModel.getId());
// 保存关联表 ZcRentCarRuleBattery 数据
List<ZcCarModelPackage> carModelPackageList = new ArrayList<>();
for (Long rentCarRuleId : rentCarRuleIds) {
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarModelId(zcCarModel.getId());
zcCarModelPackage.setCarRuleId(rentCarRuleId);
zcCarModelPackage.setCreateTime(new Date());
carModelPackageList.add(zcCarModelPackage);
}
if (!carModelPackageList.isEmpty()) {
zcCarModelPackageService.batchInsert(carModelPackageList);
}
return flag;
}
/**
* 批量删除车型管理
*

View File

@ -1,7 +1,13 @@
package com.ruoyi.operation.service.impl;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.operation.domain.ZcCarModelPackage;
import com.ruoyi.operation.domain.ZcRentCarRuleBattery;
import com.ruoyi.operation.service.IZcCarModelPackageService;
import com.ruoyi.operation.service.IZcRentCarRuleBatteryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.operation.mapper.ZcRentCarRuleMapper;
@ -20,7 +26,8 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
{
@Autowired
private ZcRentCarRuleMapper zcRentCarRuleMapper;
@Autowired
private IZcCarModelPackageService zcCarModelPackageService;
/**
* 查询租车计费规则
*
@ -45,6 +52,29 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
return zcRentCarRuleMapper.selectZcRentCarRuleList(zcRentCarRule);
}
@Override
public List<ZcRentCarRule> selectZcRentCarRuleListByCarModelId(Long carModelId)
{
ZcRentCarRule zcRentCarRule = new ZcRentCarRule();
zcRentCarRule.setStatus("0");
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleMapper.selectZcRentCarRuleList(zcRentCarRule);
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarModelId(carModelId);
List<ZcCarModelPackage> carModeBatteryList = zcCarModelPackageService.selectZcCarModelPackageList(zcCarModelPackage);
for (ZcRentCarRule rcr : rentCarRuleList)
{
for (ZcCarModelPackage modeRcr : carModeBatteryList)
{
if (rcr.getId().longValue() == modeRcr.getCarRuleId().longValue())
{
rcr.setFlag(true);
break;
}
}
}
return rentCarRuleList;
}
/**
* 新增租车计费规则
*