debug:套餐精度

This commit is contained in:
磷叶 2025-01-16 13:51:42 +08:00
parent fc10f9ff1e
commit 96dd651d80
2 changed files with 21 additions and 1 deletions

View File

@ -130,6 +130,22 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils {
}
return true;
}
public static boolean equalsDecimal(List<BigDecimal> l1, List<BigDecimal> 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;
}
/**

View File

@ -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("套餐收费方式已发生变化,请重新下单");
}