|
|
@@ -191,7 +191,7 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
OutboundItem outboundItemForUpdate;
|
|
|
|
|
|
// 编辑出库明细
|
|
|
- List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
|
|
|
+ List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList();
|
|
|
for (OutboundItemVO outboundItemVO : editOutboundItemVOList) {
|
|
|
// 出库中数量不能小于出库数量
|
|
|
if (outboundItemVO.getOutingQty().compareTo(outboundItemVO.getOutQty()) == -1) {
|
|
|
@@ -241,9 +241,13 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
* @date : 2024-03-08 16:38
|
|
|
*/
|
|
|
public ResponseResultVO<?> invalid(String id) {
|
|
|
- Outbound outbound = outboundMapper.selectByIdForUpdate(id);
|
|
|
+ Outbound outboundForUpdate = outboundMapper.selectByIdForUpdate(id);
|
|
|
+ // 并发校验
|
|
|
+ if(!outboundForUpdate.getFlgValid()){
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
|
|
|
+ }
|
|
|
// 如果退货数量不是0,不能作废
|
|
|
- if (outbound.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ if (outboundForUpdate.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
|
|
|
}
|
|
|
|
|
|
@@ -257,11 +261,14 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()))
|
|
|
.setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()))
|
|
|
.setItemId(orderItemForUpdate.getItemId());
|
|
|
+ if(orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ orderItemUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
|
|
|
+ }
|
|
|
orderItemService.updateByUuid(orderItemUpdate);
|
|
|
}
|
|
|
|
|
|
// 计算订单明细的出库中数量,金额合计
|
|
|
- List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outbound.getFromId());
|
|
|
+ List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundForUpdate.getFromId());
|
|
|
OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
|
|
|
OrderItem item = new OrderItem();
|
|
|
item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
|
|
|
@@ -270,7 +277,11 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
}).get();
|
|
|
// 更新订单上的出库中数量,金额
|
|
|
Order orderUpdate = new Order();
|
|
|
- orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outbound.getFromId());
|
|
|
+ orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundForUpdate.getFromId());
|
|
|
+ if(orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ orderUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
|
|
|
+ }
|
|
|
+
|
|
|
orderService.updateByUuid(orderUpdate);
|
|
|
|
|
|
// 作废
|
|
|
@@ -292,7 +303,7 @@ public class OutboundService extends BaseService<Outbound> {
|
|
|
outboundInfo.put("outbound", outboundResponse);
|
|
|
|
|
|
// 商品明细
|
|
|
- List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
|
|
|
+ List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCondForOutEdit(id);
|
|
|
outboundInfo.put("outboundItem", outboundItemResponse);
|
|
|
return ResponseResultUtil.success(outboundInfo);
|
|
|
}
|