diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java index 8bdb7647..b99c32cb 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/utils/collection/CollectionUtils.java @@ -130,6 +130,22 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils { } return true; } + public static boolean equalsDecimal(List l1, List l2) { + if (Objects.equals(l1, l2)) { + return true; + } + if (l1.size() != l2.size()) { + return false; + } + for(int i = 0; i < l1.size(); i ++) { + BigDecimal o1 = l1.get(i); + BigDecimal o2 = l2.get(i); + if (o1.compareTo(o2) != 0) { + return false; + } + } + return true; + } /** 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 2f048c36..19a07922 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 @@ -36,6 +36,7 @@ import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.transactionBill.service.TransactionBillValidator; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.UserValidator; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -50,6 +51,7 @@ import java.util.stream.Collectors; * 2024/4/22 */ @Service +@Slf4j public class TransactionBillValidatorImpl extends BaseValidator implements TransactionBillValidator { @Autowired @@ -175,10 +177,12 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans if (!Objects.equals(suit.getTimeUnit(), dto.getSuitTimeUnit())) { return error("当前套餐时间已发生变化,请重新下单"); } - if (!CollectionUtils.equals(suit.getGearAmount(), dto.getSuitGearAmount())) { + if (!CollectionUtils.equalsDecimal(suit.getGearAmount(), dto.getSuitGearAmount())) { + log.error("套餐收费方式已发生变化,请重新下单:suit.getGearAmount()={}, dto.getSuitGearAmount()={}", suit.getGearAmount(), dto.getSuitGearAmount()); return error("套餐收费方式已发生变化,请重新下单"); } if (!CollectionUtils.equals(suit.getGearTime(), dto.getSuitGearTime())) { + log.error("套餐收费方式已发生变化,请重新下单:suit.getGearTime()={}, dto.getSuitGearTime()={}", suit.getGearTime(), dto.getSuitGearTime()); return error("套餐收费方式已发生变化,请重新下单"); }