| | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED; |
| | | |
| | | /** |
| | | * ERP 采购订单 API 实现类 |
| | |
| | | // 累加退货数量 |
| | | BigDecimal oldReturnCount = item.getReturnCount() != null ? item.getReturnCount() : BigDecimal.ZERO; |
| | | BigDecimal newReturnCount = oldReturnCount.add(returnCount); |
| | | BigDecimal inCount = item.getInCount() != null ? item.getInCount() : BigDecimal.ZERO; |
| | | if (returnCount.compareTo(BigDecimal.ZERO) <= 0 || newReturnCount.compareTo(inCount) > 0) { |
| | | throw exception(PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED, |
| | | "产品ID:" + item.getProductId(), inCount); |
| | | } |
| | | purchaseOrderItemMapper.updateById(new ErpPurchaseOrderItemDO() |
| | | .setId(orderItemId) |
| | | .setReturnCount(newReturnCount)); |