| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | // 批量更新(需要 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 计算,避免精度丢失) |
| | |
| | | product.setType(type); |
| | | salesLedgerProductMapper.updateById(product); |
| | | }); |
| | | if(isUpdated.get()){ |
| | | throw new RuntimeException("来票数不可全部为空"); |
| | | } |
| | | } |
| | | } |
| | | |