diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 151a1df..1c8027f 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -67,7 +67,7 @@ public class AppVerifyController extends BaseController private TokenService tokenService; @Autowired - private ISysConfigService sysConfigService; + private IEtOperatingAreaService etOperatingAreaService; @@ -235,7 +235,8 @@ public class AppVerifyController extends BaseController throw new ServiceException("提现失败,用户还有未完成订单"); } EtOrder etOrder1 = etOrders.get(0); - BigDecimal deposit = new BigDecimal(sysConfigService.selectConfigByKey("deposit"));//押金 + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(etOrder1.getAreaId()); + BigDecimal deposit = new BigDecimal(area.getDeposit()); if(deposit.compareTo(etOrder1.getTotalFee())!=0){ throw new ServiceException("订单充值金额与系统押金不相等"); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java index a0ae724..91d966c 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java @@ -10,6 +10,7 @@ import com.ruoyi.common.mybatis.MyGeometryTypeHandler; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -134,4 +135,20 @@ public class EtOperatingArea implements Serializable @Excel(name = "超出电子围栏多少时长断电(s)") private Integer outage; + + /** 预约服务费 */ + private BigDecimal appointmentServiceFee; + + /** 调度费 */ + private BigDecimal dispatchFee; + + /** 管理费*/ + private BigDecimal vehicleManagementFee; + + /** 预约超时保留分钟*/ + private Integer timeoutMinutes; + + /** 电量低于多少值自动生成换电订单*/ + private Integer autoReplacementOrder; + } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index 802a05d..692f0d4 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -137,10 +137,17 @@ public class AsDeviceServiceImpl extends ServiceImpl i // JSONObject data =jsonObject.getJSONObject("data"); // } // } + Long areaId = asDevice.getAreaId(); + EtOperatingArea etOperatingArea; + if (ObjectUtil.isNotNull(areaId)) { + etOperatingArea = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); + }else{ + throw new ServiceException("区域信息不存在"); + } /** TODO 电量低于系统设置值时,自动生成换电工单 唯一 */ - String replacementOrder = sysConfigService.selectConfigByKey("auto.replacement.order");//车辆里程数 + Integer replacementOrder = etOperatingArea.getAutoReplacementOrder(); Boolean aBoolean = etAdminOrderService.checkOrderUnique(asDevice.getSn()); - if (Integer.parseInt(asDevice.getRemainingPower()) < Integer.parseInt(replacementOrder) && !aBoolean) { + if (Integer.parseInt(asDevice.getRemainingPower()) < replacementOrder && !aBoolean) { Boolean execute = transactionTemplate.execute(e -> { /** 生成换电工单 */ EtAdminOrder adminOrder = new EtAdminOrder(); @@ -182,7 +189,6 @@ public class AsDeviceServiceImpl extends ServiceImpl i Integer remainingPower = Integer.parseInt(asDevice.getRemainingPower()); // mileage与remainingPower相乘 asDevice.setRemainingMileage(mileage * remainingPower/100);//剩余里程 - EtOperatingArea etOperatingArea = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); if(ObjectUtil.isNotNull(etOperatingArea)){ asDevice.setAreaName(etOperatingArea.getAreaName()); } @@ -861,14 +867,15 @@ public class AsDeviceServiceImpl extends ServiceImpl i BigDecimal divide = new BigDecimal(minutes).divide(new BigDecimal(10)); BigDecimal result = divide.setScale(0, RoundingMode.UP); //BigDecimal divide 取整 有小数点则+1 - String appointmentServiceFee = sysConfigService.selectConfigByKey("appointment.service.fee");//预约服务费 - String timeoutMinutes = sysConfigService.selectConfigByKey("timeout.minutes");//预约超时保留分钟 - if(minutes>Integer.parseInt(timeoutMinutes)){ + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId()); + BigDecimal appointmentServiceFee = area.getAppointmentServiceFee(); + Integer timeoutMinutes = area.getTimeoutMinutes(); + if(minutes>timeoutMinutes){ //预约分钟数超过最多保留时间 throw new ServiceException("预约时间超过最多保留分钟"); }else{ //根据开始时间和结束时间计算费用 预约费 = (预约结束时间 - 开始时间) * 预约服务费 - BigDecimal appointmentFee = new BigDecimal(appointmentServiceFee).multiply(result); + BigDecimal appointmentFee = appointmentServiceFee.multiply(result); log.info("【计算预约费】:预约分钟数:"+minutes+",取整:"+result+",预约费:"+appointmentFee); order.setAppointmentFee(appointmentFee); } @@ -989,17 +996,18 @@ public class AsDeviceServiceImpl extends ServiceImpl i } + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId()); /** 管理费*/ // 根据车辆的定位判断是否在停车区内 if(!isParkingZone(order.getSn(), order.getAreaId())){ - String vehicleManagementFee = sysConfigService.selectConfigByKey("vehicle.management.fee");//车辆管理费 - order.setManageFee(new BigDecimal(vehicleManagementFee)); + BigDecimal vehicleManagementFee = area.getVehicleManagementFee();//车辆管理费 + order.setManageFee(vehicleManagementFee); } /** 调度费*/ //判断是否在运营区内 - if(!isAreaZone(order.getSn(), order.getAreaId())){ - String dispatchFee = sysConfigService.selectConfigByKey("dispatch.fee");//调度费 - order.setDispatchFee(new BigDecimal(dispatchFee)); + if(!isAreaZone(order.getSn(), area)){ + BigDecimal dispatchFee = area.getDispatchFee();//调度费 + order.setDispatchFee(dispatchFee); } BigDecimal totalFee = BigDecimal.ZERO; if (order != null) { @@ -1182,9 +1190,8 @@ public class AsDeviceServiceImpl extends ServiceImpl i /** * 是否在运营区内 */ - private Boolean isAreaZone(String sn,Long areaId) { + private Boolean isAreaZone(String sn,EtOperatingArea area) { Boolean inCircle = false; - EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); String latitude = device.getLatitude(); String longitude = device.getLongitude(); diff --git a/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml index e2b91a3..69505bf 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml @@ -33,6 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + @@ -40,7 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" boundary_str, longitude, latitude, create_by, create_time, contact, phone, status, area_time, service_phone, slogan, province,city, county, area_out_outage, parking_out_dispatch, area_out_dispatch, - no_riding_outage, authentication, msg_switch, undercharge, error, agreement, deposit, outage from et_operating_area + no_riding_outage, authentication, msg_switch, undercharge, error, agreement, deposit, + outage, appointment_service_fee, dispatch_fee, vehicle_management_fee, timeout_minutes, auto_replacement_order from et_operating_area - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -