|
|
@@ -169,8 +169,8 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
|
|
|
// 反写订单出库中数量、金额
|
|
|
orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItem.getFromItemId());
|
|
|
- // 如果商品数量小于订单+本次出库单上的出库中数量
|
|
|
- if (orderItemForUpdate.getItemQty().compareTo(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty())) == -1) {
|
|
|
+ // 如果(商品数量-已出库数量) 小于(订单出库中数量+本次出库单出库中数量)
|
|
|
+ if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().add(outboundItem.getOutingQty())) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
|
|
|
}
|
|
|
OrderItem orderItemUpdate = new OrderItem();
|
|
|
@@ -219,8 +219,8 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
}
|
|
|
orderItemForUpdate = orderItemMapper.selectByIdForUpdate(outboundItemVO.getFromItemId());
|
|
|
|
|
|
- // 订单的商品数量不能小于(订单之前的出库中数量 - 出库明细之前的出库中数量 + 出库明细现在的出库中数量)
|
|
|
- if (orderItemForUpdate.getItemQty().compareTo(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty())) == -1) {
|
|
|
+ // (订单的商品数量-订单已出库数量)不能小于(订单之前的出库中数量 - 出库明细之前的出库中数量 + 出库明细现在的出库中数量)
|
|
|
+ if ((orderItemForUpdate.getItemQty().subtract(orderItemForUpdate.getOutQty())).compareTo(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()).add(outboundItemVO.getOutingQty())) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ITEMQTY_NO_LESS_OUTQTY.getMessage());
|
|
|
}
|
|
|
// 更新订单明细出库中数量
|
|
|
@@ -264,8 +264,8 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
if(!outboundForUpdate.getFlgValid()){
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
|
|
|
}
|
|
|
- // 如果退货数量不是0,不能作废
|
|
|
- if (outboundForUpdate.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ // 如果出库数量或退货数量不是0,不能作废
|
|
|
+ if (outboundForUpdate.getOutQty().compareTo(BigDecimal.ZERO) != 0 || outboundForUpdate.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
|
|
|
}
|
|
|
|