套餐应用到车型

This commit is contained in:
19173159168
2025-08-09 00:13:29 +08:00
parent 9018d8eef1
commit 55ff442dc9
18 changed files with 208 additions and 97 deletions

View File

@ -8,8 +8,10 @@ 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 org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -43,7 +45,8 @@ public class ZcRentCarRuleController extends BaseController
private ICompanyService companyService;
@Autowired
private IZcRentCarRuleBatteryService zcRentCarRuleBatteryService;
@Autowired
private IZcCarModelService zcCarModelService;
@RequiresPermissions("operation:rentCarRule:view")
@GetMapping()
@ -155,6 +158,12 @@ public class ZcRentCarRuleController extends BaseController
.map(String::valueOf)
.collect(Collectors.joining(","));
mmap.put("modelRuleNames", modelRuleNames);
ZcCarModel zcCarModel = new ZcCarModel();
zcCarModel.setStatus("0");
List<ZcCarModel> modelList = zcCarModelService.selectCarModelListByCarRuleId(id);
mmap.put("modelList", modelList);
return prefix + "/edit";
}
@ -165,10 +174,10 @@ public class ZcRentCarRuleController extends BaseController
@Log(title = "租车计费规则", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(ZcRentCarRule zcRentCarRule)
public AjaxResult editSave(@RequestParam("carModelIds") List<Long> carModelIds, ZcRentCarRule zcRentCarRule)
{
zcRentCarRule.setUpdateBy(getLoginName());
return toAjax(zcRentCarRuleService.updateZcRentCarRule(zcRentCarRule));
return toAjax(zcRentCarRuleService.updateZcRentCarRule(carModelIds,zcRentCarRule));
}
@GetMapping("/detail/{id}")

View File

@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.data.annotation.Transient;
/**
* 车型管理对象 zc_car_model
@ -62,6 +63,10 @@ public class ZcCarModel extends BaseEntity
private List<ZcRentCarRule> rentCarRuleList;
/** 套餐是否关联此车型标识 默认不存在 */
@Transient
private boolean flag = false;
public void setId(Long id)
{
this.id = id;
@ -187,6 +192,16 @@ public class ZcCarModel extends BaseEntity
this.image = image;
}
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)

View File

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

View File

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

View File

@ -27,6 +27,7 @@ public interface IZcCarModelService
*/
public List<ZcCarModel> selectZcCarModelList(ZcCarModel zcCarModel);
public List<ZcCarModel> selectCarModelListByCarRuleId(Long rentCarRuleId);
/**
* 新增车型管理
*

View File

@ -44,7 +44,7 @@ public interface IZcRentCarRuleService
* @param zcRentCarRule 租车计费规则
* @return 结果
*/
public int updateZcRentCarRule(ZcRentCarRule zcRentCarRule);
public int updateZcRentCarRule(List<Long> carModelIds, ZcRentCarRule zcRentCarRule);
/**
* 批量删除租车计费规则

View File

@ -95,6 +95,11 @@ public class ZcCarModelPackageServiceImpl implements IZcCarModelPackageService
return zcCarModelPackageMapper.deleteZcCarModelPackageByModeId(modeId);
}
@Override
public int deleteZcCarModelPackageByRuleId(Long ruleId)
{
return zcCarModelPackageMapper.deleteZcCarModelPackageByRuleId(ruleId);
}
/**
* 删除车型与租车规则关联信息
*

View File

@ -1,6 +1,7 @@
package com.ruoyi.operation.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
@ -51,6 +52,30 @@ public class ZcCarModelServiceImpl implements IZcCarModelService
return zcCarModelMapper.selectZcCarModelList(zcCarModel);
}
@Override
public List<ZcCarModel> selectCarModelListByCarRuleId(Long rentCarRuleId) {
ZcCarModel zcCarModel = new ZcCarModel();
zcCarModel.setStatus("0");
List<ZcCarModel> zcCarModelList = zcCarModelMapper.selectZcCarModelList(zcCarModel);
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarRuleId(rentCarRuleId);
List<ZcCarModelPackage> carModeBatteryList = zcCarModelPackageService.selectZcCarModelPackageList(zcCarModelPackage);
for (ZcCarModel zcm : zcCarModelList)
{
for (ZcCarModelPackage modeRcr : carModeBatteryList)
{
if (zcm.getId().longValue() == modeRcr.getCarModelId().longValue())
{
zcm.setFlag(true);
break;
}
}
}
return zcCarModelList;
}
/**
* 新增车型管理
*

View File

@ -1,5 +1,7 @@
package com.ruoyi.operation.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysRole;
@ -96,10 +98,25 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
* @return 结果
*/
@Override
public int updateZcRentCarRule(ZcRentCarRule zcRentCarRule)
public int updateZcRentCarRule(List<Long> carModelIds,ZcRentCarRule zcRentCarRule)
{
zcRentCarRule.setUpdateTime(DateUtils.getNowDate());
return zcRentCarRuleMapper.updateZcRentCarRule(zcRentCarRule);
int flag = zcRentCarRuleMapper.updateZcRentCarRule(zcRentCarRule);
zcCarModelPackageService.deleteZcCarModelPackageByRuleId(zcRentCarRule.getId());
// 保存关联表 ZcRentCarRuleBattery 数据
List<ZcCarModelPackage> carModelPackageList = new ArrayList<>();
for (Long carModelId : carModelIds) {
ZcCarModelPackage zcCarModelPackage = new ZcCarModelPackage();
zcCarModelPackage.setCarModelId(carModelId);
zcCarModelPackage.setCarRuleId(zcRentCarRule.getId());
zcCarModelPackage.setCreateTime(new Date());
carModelPackageList.add(zcCarModelPackage);
}
if (!carModelPackageList.isEmpty()) {
zcCarModelPackageService.batchInsert(carModelPackageList);
}
return flag;
}
/**