From 0c53e63ce30b4d05a8140dc98ef1025b9278f6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Fri, 13 Sep 2024 17:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/ss/device/domain/Device.java | 14 ++++++++++---- .../java/com/ruoyi/ss/device/domain/DeviceBO.java | 4 ++++ .../com/ruoyi/ss/device/mapper/DeviceMapper.xml | 8 ++++++++ .../service/impl/TransactionBillValidatorImpl.java | 3 +++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/Device.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/Device.java index ed2c4889..5578ebb8 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/Device.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/Device.java @@ -13,10 +13,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Range; import org.springframework.format.annotation.DateTimeFormat; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Past; +import javax.validation.constraints.*; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.Date; @@ -199,4 +196,13 @@ public class Device extends BaseEntity @ApiModelProperty("剩余电量(度)") @JsonView(JsonViewProfile.App.class) private BigDecimal surplusEle; + + @Excel(name = "限制充值时间", readConverterExp = "到=期之前不允许充值") + @ApiModelProperty("限制充值时间") + private LocalDateTime limitRechargeTime; + + @Excel(name = "限制充值原因") + @ApiModelProperty("限制充值原因") + @Size(max = 200, message = "限制充值原因长度不能超过200个字符") + private String limitRechargeReason; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java index 03104dfc..e6155b78 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java @@ -36,6 +36,8 @@ public class DeviceBO extends Device { bo.setOverPrice(getOverPrice()); bo.setOverUnit(getOverUnit()); bo.setSuitIds(getSuitIds()); + bo.setLimitRechargeTime(getLimitRechargeTime()); + bo.setLimitRechargeReason(getLimitRechargeReason()); return bo; } @@ -59,6 +61,8 @@ public class DeviceBO extends Device { bo.setOverPrice(getOverPrice()); bo.setOverUnit(getOverUnit()); bo.setSuitIds(getSuitIds()); + bo.setLimitRechargeTime(getLimitRechargeTime()); + bo.setLimitRechargeReason(getLimitRechargeReason()); return bo; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml index fac9b934..66f9844a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml @@ -125,6 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sd.rent_time, sd.lock_user_id, sd.surplus_ele, + sd.limit_recharge_time, + sd.limit_recharge_reason, sm.model_name as model, sm.picture as picture, sm.tags as model_tags, @@ -291,6 +293,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rent_time, lock_user_id, surplus_ele, + limit_recharge_time, + limit_recharge_reason, #{storeId}, @@ -331,6 +335,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{rentTime}, #{lockUserId}, #{surplusEle}, + #{limitRechargeTime}, + #{limitRechargeReason}, @@ -392,6 +398,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" rent_time = #{rentTime}, lock_user_id = #{lockUserId}, surplus_ele = #{surplusEle}, + limit_recharge_time = #{limitRechargeTime}, + limit_recharge_reason = #{limitRechargeReason}, where device_id = #{deviceId} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java index f51c761a..f4f8588b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java @@ -86,6 +86,9 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans if (StringUtils.isEmpty(device.getMac())) { return error("当前设备Mac为空,无法充值"); } + if (device.getLimitRechargeTime() != null && LocalDateTime.now().isBefore(device.getLimitRechargeTime())) { + return error("当前设备被限制充值:" + device.getLimitRechargeReason()); + } // 判断设备是否有正在使用中的订单 TransactionBillQuery query = new TransactionBillQuery();