|
@@ -12,6 +12,7 @@ import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.common.service.BaseService;
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
|
|
|
+import com.dk.mdm.infrastructure.util.AuthUtils;
|
|
|
import com.dk.mdm.mapper.ivt.InboundItemMapper;
|
|
import com.dk.mdm.mapper.ivt.InboundItemMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
import com.dk.mdm.mapper.pur.PurchaseItemMapper;
|
|
import com.dk.mdm.mapper.pur.PurchaseItemMapper;
|
|
@@ -78,6 +79,8 @@ public class InboundReturnService extends BaseService<Inbound> {
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private AuthUtils authUtils;
|
|
|
|
|
+ @Autowired
|
|
|
private InboundPurchaseReturnService inboundPurchaseReturnService;
|
|
private InboundPurchaseReturnService inboundPurchaseReturnService;
|
|
|
|
|
|
|
|
@Pagination
|
|
@Pagination
|
|
@@ -121,7 +124,7 @@ public class InboundReturnService extends BaseService<Inbound> {
|
|
|
return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
|
|
return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
|
|
|
}
|
|
}
|
|
|
//查询采购订单
|
|
//查询采购订单
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId()); //采购订单id
|
|
|
|
|
|
|
|
inboundVO.setReturnQty(inboundVO.getReturnQty().abs());
|
|
inboundVO.setReturnQty(inboundVO.getReturnQty().abs());
|
|
|
inboundVO.setReturnAmt(inboundVO.getReturnAmt().abs());
|
|
inboundVO.setReturnAmt(inboundVO.getReturnAmt().abs());
|
|
@@ -135,13 +138,13 @@ public class InboundReturnService extends BaseService<Inbound> {
|
|
|
//反写入库订单明细、反写订单明细
|
|
//反写入库订单明细、反写订单明细
|
|
|
for (InboundItemVO inboundItemVO : itemList) {
|
|
for (InboundItemVO inboundItemVO : itemList) {
|
|
|
//根据退货明细中入库明细id查询入库明细数据
|
|
//根据退货明细中入库明细id查询入库明细数据
|
|
|
- InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
|
|
|
|
+ InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId()); //原入库单明细id
|
|
|
BigDecimal returnQty = inboundItemResponse.getReturnQty().add(inboundItemVO.getReturnQty().setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
BigDecimal returnQty = inboundItemResponse.getReturnQty().add(inboundItemVO.getReturnQty().setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
|
BigDecimal returnAmt = inboundItemResponse.getReturnAmt().add(inboundItemVO.getReturnAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
BigDecimal returnAmt = inboundItemResponse.getReturnAmt().add(inboundItemVO.getReturnAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
|
sumReturnQty = sumReturnQty.add(returnQty);
|
|
sumReturnQty = sumReturnQty.add(returnQty);
|
|
|
sumReturnAmt = sumReturnAmt.add(returnAmt);
|
|
sumReturnAmt = sumReturnAmt.add(returnAmt);
|
|
|
//反写入库单退货数量金额 todo
|
|
//反写入库单退货数量金额 todo
|
|
|
- InboundResponse inboundResponse = inboundMapper.selectById(inboundItemVO.getIntoId());
|
|
|
|
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(inboundItemVO.getIntoId()); //原入库单id
|
|
|
inboundMapper.updateAmount(new Inbound().setIntoId(inboundItemVO.getIntoId())
|
|
inboundMapper.updateAmount(new Inbound().setIntoId(inboundItemVO.getIntoId())
|
|
|
.setReturnQty(inboundResponse.getReturnQty().add(sumReturnQty))
|
|
.setReturnQty(inboundResponse.getReturnQty().add(sumReturnQty))
|
|
|
.setReturnAmt(inboundResponse.getReturnAmt().add(sumReturnAmt)));
|
|
.setReturnAmt(inboundResponse.getReturnAmt().add(sumReturnAmt)));
|
|
@@ -163,6 +166,36 @@ public class InboundReturnService extends BaseService<Inbound> {
|
|
|
|
|
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
+ inboundVO.setFromId(inboundVO.getIntoId());
|
|
|
|
|
+ inboundVO.setFromNo(inboundVO.getIntoNo());
|
|
|
|
|
+ inboundVO.setIntoingQty(inboundVO.getReturnQty().multiply(new BigDecimal(-1)));
|
|
|
|
|
+ inboundVO.setIntoingAmt(inboundVO.getReturnAmt().multiply(new BigDecimal(-1)));
|
|
|
|
|
+ List<InboundItemVO> list = new ArrayList<>();
|
|
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
|
|
+
|
|
|
|
|
+ inboundItemVO.setIntoingQty(inboundItemVO.getReturnQty().multiply(new BigDecimal(-1)));
|
|
|
|
|
+ inboundItemVO.setIntoingAmt(inboundItemVO.getReturnAmt().multiply(new BigDecimal(-1)));
|
|
|
|
|
+ inboundItemVO.setPriceInto(inboundItemVO.getPriceInto());
|
|
|
|
|
+ inboundItemVO.setFromItemId(inboundItemVO.getItemId());
|
|
|
|
|
+ inboundItemVO.setSkuId(inboundItemVO.getSkuId());
|
|
|
|
|
+ inboundItemVO.setItemIndex(inboundItemVO.getItemIndex());
|
|
|
|
|
+ inboundItemVO.setNonStdCode(inboundItemVO.getNonStdCode());
|
|
|
|
|
+ inboundItemVO.setReturnQty(inboundItemVO.getReturnQty());
|
|
|
|
|
+ inboundItemVO.setReturnAmt(inboundItemVO.getReturnAmt());
|
|
|
|
|
+
|
|
|
|
|
+ //源入库单ID(采购退货时记录)
|
|
|
|
|
+ inboundItemVO.setSIntoId(inboundItemVO.getIntoId());
|
|
|
|
|
+ //源入库单明细ID(采购退货时记录)
|
|
|
|
|
+ inboundItemVO.setSIntoItemId(inboundItemVO.getItemId());
|
|
|
|
|
+ //源采购订单ID(采购退货时记录)
|
|
|
|
|
+ inboundItemVO.setSPurId(inboundItemVO.getFromId());
|
|
|
|
|
+ //源采购明细ID(采购退货时记录)
|
|
|
|
|
+ inboundItemVO.setSPurItemId(inboundItemVO.getFromItemId());
|
|
|
|
|
+ inboundItemVO.setItemId(null);
|
|
|
|
|
+ list.add(inboundItemVO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ inboundVO.setItemList(list);
|
|
|
//获取 id/单号
|
|
//获取 id/单号
|
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALERETURN.getName(), false);
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALERETURN.getName(), false);
|
|
|
inboundVO.setIntoId(codeMap.get("outId").toString()).
|
|
inboundVO.setIntoId(codeMap.get("outId").toString()).
|
|
@@ -234,33 +267,6 @@ public class InboundReturnService extends BaseService<Inbound> {
|
|
|
inboundItemMapper.insert(inboundItem);
|
|
inboundItemMapper.insert(inboundItem);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- inboundVO.setFromId(inboundVO.getIntoId());
|
|
|
|
|
- inboundVO.setFromNo(inboundVO.getIntoNo());
|
|
|
|
|
-
|
|
|
|
|
- inboundVO.setIntoingQty(inboundVO.getReturnQty().multiply(new BigDecimal(-1)));
|
|
|
|
|
- inboundVO.setIntoingAmt(inboundVO.getReturnAmt().multiply(new BigDecimal(-1)));
|
|
|
|
|
- List<InboundItemVO> list = new ArrayList<>();
|
|
|
|
|
- for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
|
|
-
|
|
|
|
|
- inboundItemVO.setIntoingQty(inboundItemVO.getReturnQty().multiply(new BigDecimal(-1)));
|
|
|
|
|
- inboundItemVO.setIntoingAmt(inboundItemVO.getReturnAmt().multiply(new BigDecimal(-1)));
|
|
|
|
|
- inboundItemVO.setPriceInto(inboundItemVO.getPriceInto());
|
|
|
|
|
- inboundItemVO.setFromItemId(inboundItemVO.getItemId());
|
|
|
|
|
- inboundItemVO.setSkuId(inboundItemVO.getSkuId());
|
|
|
|
|
- inboundItemVO.setItemIndex(inboundItemVO.getItemIndex());
|
|
|
|
|
- inboundItemVO.setNonStdCode(inboundItemVO.getNonStdCode());
|
|
|
|
|
- inboundItemVO.setReturnQty(inboundItemVO.getReturnQty());
|
|
|
|
|
- inboundItemVO.setReturnAmt(inboundItemVO.getReturnAmt());
|
|
|
|
|
- list.add(inboundItemVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- inboundVO.setItemList(list);
|
|
|
|
|
-
|
|
|
|
|
- inboundPurchaseReturnService.purchaseReturnInboundInsert(inboundVO);
|
|
|
|
|
-
|
|
|
|
|
return ResponseResultUtil.success();
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|