maven
2 天以前 0dd70afb7815d34a02ba7f5cd4f0ad8457072607
src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
@@ -52,6 +52,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
/**
@@ -420,19 +421,20 @@
        // 批量更新(需要 MyBatis 提供批量更新方法)
        if (!updateList.isEmpty()) {
            AtomicBoolean isUpdated = new AtomicBoolean(true);
            updateList.forEach(product -> {
                // 非空校验,任一字段为空则抛出异常
                if (product.getQuantity() == null) {
                    throw new BaseException("数量不能为空");
                if (product.getQuantity() != null) {
                    isUpdated.set(false);
                }
                if (product.getTicketsNum() == null) {
                    throw new BaseException("已开票数量不能为空");
                if (product.getTicketsNum() != null) {
                    isUpdated.set(false);
                }
                if (product.getTaxInclusiveTotalPrice() == null) {
                    throw new BaseException("含税总价不能为空");
                if (product.getTaxInclusiveTotalPrice() != null) {
                    isUpdated.set(false);
                }
                if (product.getTicketsAmount() == null) {
                    throw new BaseException("本次来票金额(元)不能为空");
                if (product.getTicketsAmount() != null) {
                    isUpdated.set(false);
                }
                // 计算 futureTickets(直接使用 BigDecimal 计算,避免精度丢失)
@@ -450,6 +452,9 @@
                product.setType(type);
                salesLedgerProductMapper.updateById(product);
            });
            if(isUpdated.get()){
                throw new RuntimeException("来票数不可全部为空");
            }
        }
    }