|
|
@@ -1,5 +1,6 @@
|
|
|
package com.dk.mdm.service.ivt;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
@@ -44,8 +45,10 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -54,7 +57,6 @@ import java.util.Map;
|
|
|
* @date : 2024/3/7 14:11
|
|
|
*/
|
|
|
@Service
|
|
|
-@Transactional
|
|
|
public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
|
|
|
@Override
|
|
|
@@ -95,6 +97,24 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
inboundMapper.selectInboundAndItemCountByCond(inboundQuery));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc : 查询明细
|
|
|
+ * @date : 2024/3/15 16:43
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Pagination
|
|
|
+ public ResponseResultVO<Map<String, Object>> selectOtherInboundItemInfoById(String id) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ // 商品明细
|
|
|
+ List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(id));
|
|
|
+ result.put("itemList", inboundItemResponses);
|
|
|
+ // 收款
|
|
|
+
|
|
|
+ // 附件
|
|
|
+ return ResponseResultUtil.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @desc : 销售退货入库新建
|
|
|
@@ -105,7 +125,7 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
public ResponseResultVO<?> saleReturnInboundInsert(InboundVO inboundVO) {
|
|
|
//region 总单
|
|
|
//获取 id/单号
|
|
|
- Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUND.getName(), false);
|
|
|
+ Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALERETURN.getName(), false);
|
|
|
inboundVO.setIntoId(codeMap.get("outId").toString()).
|
|
|
setIntoNo(codeMap.get("outNote").toString());
|
|
|
//入库类型
|
|
|
@@ -129,6 +149,10 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
|
;
|
|
|
+ }else{
|
|
|
+ inboundVO.setIntoQty(BigDecimal.ZERO)
|
|
|
+ .setIntoAmt(BigDecimal.ZERO)
|
|
|
+ ;
|
|
|
}
|
|
|
|
|
|
//实体转换
|
|
|
@@ -169,10 +193,6 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
}
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
- //region 明细
|
|
|
- Map<String, Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(), true);
|
|
|
- //明细id
|
|
|
- inboundItemVO.setItemId(map.get("outId").toString());
|
|
|
//总单id
|
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
//入库类型
|
|
|
@@ -180,7 +200,14 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
|
|
|
if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
+ .setIntoingQty(BigDecimal.ZERO)
|
|
|
+ .setIntoingAmt(BigDecimal.ZERO)
|
|
|
+ ;
|
|
|
+ }else{
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(BigDecimal.ZERO)
|
|
|
+ .setIntoAmt(BigDecimal.ZERO);
|
|
|
}
|
|
|
//成本单价
|
|
|
inboundItemVO.setCostPrice(inboundItemVO.getCostPrice());
|
|
|
@@ -245,64 +272,111 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public ResponseResultVO<?> saleReturnHandleInbound(InboundVO inboundVO) {
|
|
|
- //大编辑标识
|
|
|
- if (inboundVO.getAllEdit() != null && inboundVO.getAllEdit()) {
|
|
|
- //region 编辑明细
|
|
|
- //校验明细
|
|
|
- if (inboundVO.getItemList().size() == 0) {
|
|
|
- return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
- ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ //region 编辑明细
|
|
|
+ //校验明细
|
|
|
+ if (inboundVO.getItemList().size() == 0) {
|
|
|
+ return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
+ ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ }
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
+ if (inboundItemVO.getIntoId() != null) {
|
|
|
+ //编辑明细
|
|
|
+ inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
|
|
|
+ .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
+ .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
+ .setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
+ inboundItemVO.setIntoStatus(intoStatus);
|
|
|
+ //实体转换
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
}
|
|
|
- for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
- if (inboundItemVO.getIntoId() != null) {
|
|
|
- //编辑明细
|
|
|
- inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
|
|
|
- .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
- .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
- inboundItemVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- //修改
|
|
|
- inboundItemMapper.updateById(inboundItem);
|
|
|
+ //endregion
|
|
|
+ //region 新建明细
|
|
|
+ else {
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
+ .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
+ .setIntoId(inboundVO.getIntoId())
|
|
|
+ .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
+ .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
+ .setIntoType(Constant.IntoType.PURRETURN.getName());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
+ inboundItemVO.setIntoStatus(intoStatus);
|
|
|
+ //实体转换
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ //新建
|
|
|
+ inboundItemMapper.insert(inboundItem);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 销售退货明细
|
|
|
+ if (inboundItemVO.getFromItemId() != null) {
|
|
|
+// IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ IntoReturnItem intoReturnItem = new IntoReturnItem();
|
|
|
+ intoReturnItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+// intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
|
|
|
+// intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
|
|
|
+// intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
|
|
|
+// intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
|
|
|
+ intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
|
|
|
+ intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
|
|
|
+ intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
|
|
|
+ intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ //出库状态
|
|
|
+ String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
|
|
|
+ intoReturnItem.setOutStatus(outStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = intoReturnItemMapper.updateById(intoReturnItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
}
|
|
|
- //endregion
|
|
|
- //region 新建明细
|
|
|
- else {
|
|
|
- Map<String, Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(), true);
|
|
|
- inboundItemVO
|
|
|
- .setItemId(map.get("outId").toString())
|
|
|
- .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
- .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
- .setIntoId(inboundVO.getIntoId())
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
- .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
- .setIntoType(Constant.IntoType.PURRETURN.getName());
|
|
|
- //入库状态
|
|
|
- String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
- inboundItemVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 删除明细
|
|
|
+ BigDecimal sumDelOutQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal sumDelOutAmt = BigDecimal.ZERO;
|
|
|
+ BigDecimal sumDelOutingQty = BigDecimal.ZERO;
|
|
|
+ BigDecimal sumDelOutingAmt = BigDecimal.ZERO;
|
|
|
+ if (inboundVO.getDeleteItemList() != null) {
|
|
|
+ sumDelOutQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumDelOutAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumDelOutingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumDelOutingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
|
|
|
+ if (inboundItemVO.getItemId() != null) {
|
|
|
InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- //新建
|
|
|
- inboundItemMapper.insert(inboundItem);
|
|
|
+ inboundItem.setFlgValid(false);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
}
|
|
|
- //endregion
|
|
|
-
|
|
|
//region 销售退货明细
|
|
|
if (inboundItemVO.getFromItemId() != null) {
|
|
|
-// IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ //region 销售退货订单明细
|
|
|
+// IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
IntoReturnItem intoReturnItem = new IntoReturnItem();
|
|
|
intoReturnItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
-// intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
|
|
|
-// intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
|
|
|
-// intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
|
|
|
-// intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
|
|
|
- intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
|
|
|
- intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
|
|
|
- intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
|
|
|
- intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
|
|
|
+// intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemVO.getIntoQty()));
|
|
|
+// intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemVO.getIntoAmt()));
|
|
|
+// intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().subtract(inboundItemVO.getIntoingQty()));
|
|
|
+// intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().subtract(inboundItemVO.getIntoingAmt()));
|
|
|
+ intoReturnItem.setOutQty(inboundItemVO.getIntoQty().negate());
|
|
|
+ intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
+ intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty().negate());
|
|
|
+ intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt().negate());
|
|
|
//出库状态
|
|
|
String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
|
|
|
intoReturnItem.setOutStatus(outStatus);
|
|
|
@@ -312,113 +386,72 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
if (countRow == 0) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
}
|
|
|
+ //endregion
|
|
|
}
|
|
|
//endregion
|
|
|
- }
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 删除明细
|
|
|
- BigDecimal sumDelOutQty = BigDecimal.ZERO;
|
|
|
- BigDecimal sumDelOutAmt = BigDecimal.ZERO;
|
|
|
- BigDecimal sumDelOutingQty = BigDecimal.ZERO;
|
|
|
- BigDecimal sumDelOutingAmt = BigDecimal.ZERO;
|
|
|
- if (inboundVO.getDeleteItemList() != null) {
|
|
|
- sumDelOutQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- sumDelOutAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- sumDelOutingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- sumDelOutingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
|
|
|
- if (inboundItemVO.getItemId() != null) {
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- inboundItem.setFlgValid(false);
|
|
|
- inboundItemMapper.updateById(inboundItem);
|
|
|
- }
|
|
|
- //region 销售退货明细
|
|
|
- if (inboundItemVO.getFromItemId() != null) {
|
|
|
- //region 销售退货订单明细
|
|
|
-// IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
- IntoReturnItem intoReturnItem = new IntoReturnItem();
|
|
|
- intoReturnItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
-// intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemVO.getIntoQty()));
|
|
|
-// intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemVO.getIntoAmt()));
|
|
|
-// intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().subtract(inboundItemVO.getIntoingQty()));
|
|
|
-// intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().subtract(inboundItemVO.getIntoingAmt()));
|
|
|
- intoReturnItem.setOutQty(inboundItemVO.getIntoQty().negate());
|
|
|
- intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
- intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty().negate());
|
|
|
- intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt().negate());
|
|
|
- //出库状态
|
|
|
- String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
|
|
|
- intoReturnItem.setOutStatus(outStatus);
|
|
|
- //修改
|
|
|
- int countRow = intoReturnItemMapper.updateById(intoReturnItem);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- //endregion
|
|
|
- }
|
|
|
- //endregion
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
- //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 编辑总单
|
|
|
- BigDecimal sumOutQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumOutAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumOutingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumOutingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- inboundVO.setIntoQty(sumOutQty);
|
|
|
- inboundVO.setIntoAmt(sumOutAmt);
|
|
|
- inboundVO.setIntoingQty(sumOutingQty);
|
|
|
- inboundVO.setIntoAmt(sumOutingAmt);
|
|
|
- //已入库数量==入库中数量 入库完成
|
|
|
- if (inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty()) == 0) {
|
|
|
- //已入库
|
|
|
- inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
|
|
|
- } else {
|
|
|
- //入库中
|
|
|
- inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
- }
|
|
|
- //实体转换
|
|
|
- Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
- //修改
|
|
|
- inboundMapper.updateById(inbound);
|
|
|
- //endregion
|
|
|
+ //region 编辑总单
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
+ BigDecimal sumOutQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumOutAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumOutingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumOutingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ inboundVO.setIntoQty(sumOutQty);
|
|
|
+ inboundVO.setIntoAmt(sumOutAmt);
|
|
|
+ inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumOutingQty));
|
|
|
+ inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumOutingAmt));
|
|
|
+ //已入库数量==入库中数量 入库完成
|
|
|
+ if (inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty()) == 0) {
|
|
|
+ //已入库
|
|
|
+ inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
|
|
|
+ } else {
|
|
|
+ //入库中
|
|
|
+ inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
+ }
|
|
|
+ //实体转换
|
|
|
+ Inbound inbound = inboundConvert.convertToPo(inboundVO);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda()
|
|
|
+ .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
|
|
|
- //region 修改销售退货订单
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
- //查询
|
|
|
+ //region 修改销售退货订单
|
|
|
+ if (inboundVO.getFromId() != null) {
|
|
|
+ //查询
|
|
|
// IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
|
|
|
- IntoReturn intoReturn = new IntoReturn();
|
|
|
- intoReturn.setReturnId(inboundVO.getFromId());
|
|
|
+ IntoReturn intoReturn = new IntoReturn();
|
|
|
+ intoReturn.setReturnId(inboundVO.getFromId());
|
|
|
// intoReturn.setOutQty(intoReturnResponse.getOutQty().add(sumOutQty).subtract(sumDelOutQty));
|
|
|
// intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(sumOutAmt).subtract(sumDelOutAmt));
|
|
|
// intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(sumOutQty).subtract(sumDelOutingQty));
|
|
|
// intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(sumOutAmt).subtract(sumDelOutingAmt));
|
|
|
- intoReturn.setOutQty(sumOutQty.subtract(sumDelOutQty));
|
|
|
- intoReturn.setOutAmt(sumOutAmt.subtract(sumDelOutAmt));
|
|
|
- intoReturn.setOutingQty((sumOutQty.add(sumDelOutingQty)).negate());
|
|
|
- intoReturn.setOutingAmt((sumOutAmt.add(sumDelOutingAmt)).negate());
|
|
|
- //入库状态
|
|
|
- String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
|
|
|
- intoReturn.setOutStatus(outStatus);
|
|
|
- //修改
|
|
|
- int countRow = intoReturnMapper.updateById(intoReturn);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
+ intoReturn.setOutQty(sumOutQty.subtract(sumDelOutQty));
|
|
|
+ intoReturn.setOutAmt(sumOutAmt.subtract(sumDelOutAmt));
|
|
|
+ intoReturn.setOutingQty((sumOutQty.add(sumDelOutingQty)).negate());
|
|
|
+ intoReturn.setOutingAmt((sumOutAmt.add(sumDelOutingAmt)).negate());
|
|
|
+ //入库状态
|
|
|
+ String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
|
|
|
+ intoReturn.setOutStatus(outStatus);
|
|
|
+ //修改
|
|
|
+ int countRow = intoReturnMapper.updateById(intoReturn);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
}
|
|
|
- //endregion
|
|
|
-
|
|
|
- //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
- //region 修改库存
|
|
|
|
|
|
- //endregion
|
|
|
}
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
+ //region 修改库存
|
|
|
+
|
|
|
+ //endregion
|
|
|
return ResponseResultUtil.success(inboundVO);
|
|
|
}
|
|
|
|
|
|
@@ -468,7 +501,11 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
|
|
|
inbound.setIntoQty(BigDecimal.ZERO);
|
|
|
inbound.setIntoAmt(BigDecimal.ZERO);
|
|
|
- inboundMapper.updateById(inbound);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda()
|
|
|
+ .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
//endregion
|
|
|
|
|
|
//region 明细数据
|
|
|
@@ -510,7 +547,11 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
.setIntoQty(BigDecimal.ZERO)
|
|
|
.setIntoAmt(BigDecimal.ZERO)
|
|
|
.setItemId(inboundItemResponse.getItemId());
|
|
|
- inboundItemMapper.updateById(inboundItem);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
//endregion
|
|
|
}
|
|
|
//endregion
|
|
|
@@ -533,8 +574,8 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) {
|
|
|
//入库状态
|
|
|
String intoStatus = null;
|
|
|
- //已入库数量=0 入库中数量>0
|
|
|
- if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //已入库数量>0 入库中数量>0
|
|
|
+ if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0 ) {
|
|
|
//入库中
|
|
|
intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
|
}
|
|
|
@@ -543,10 +584,10 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
//待入库
|
|
|
intoStatus = Constant.IntoStatus.DAIRUKU.getName();
|
|
|
}
|
|
|
- //已入库数量>0 入库中数量>0
|
|
|
- else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- //入库中
|
|
|
- intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
|
+ //已入库数量>0 入库中数量=0
|
|
|
+ else if (intoQty.compareTo(BigDecimal.ZERO) >0 && intoingQty.compareTo(BigDecimal.ZERO)==0) {
|
|
|
+ //已入库
|
|
|
+ intoStatus = Constant.IntoStatus.YIRUKU.getName();
|
|
|
}
|
|
|
return intoStatus;
|
|
|
}
|
|
|
@@ -558,24 +599,26 @@ public class InboundSaleReturnService extends BaseService<Inbound> {
|
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
|
public String setOutStatus(BigDecimal outingQty, BigDecimal outQty) {
|
|
|
- //入库状态
|
|
|
+ //出库状态
|
|
|
String outStatus = null;
|
|
|
- //已入库数量=0 入库中数量>0
|
|
|
- if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- //入库中
|
|
|
- outStatus = Constant.OutStatus.CHUKUZHONG.getName();
|
|
|
+ //已出库数量>0 出库中数量>0
|
|
|
+ if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0 ) {
|
|
|
+ //出库中
|
|
|
+ outStatus =Constant.OutStatus.CHUKUZHONG.getName();
|
|
|
}
|
|
|
- //已入库数量=0 入库中数量=0
|
|
|
+ //出入库数量=0 出库中数量=0
|
|
|
else if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- //待入库
|
|
|
+ //待出库
|
|
|
outStatus = Constant.OutStatus.DAICHUKU.getName();
|
|
|
}
|
|
|
- //已入库数量>0 入库中数量>0
|
|
|
- else if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- //入库中
|
|
|
+ //已出库数量>0 出库中数量=0
|
|
|
+ else if (outQty.compareTo(BigDecimal.ZERO) >0 && outingQty.compareTo(BigDecimal.ZERO)==0) {
|
|
|
+ //已出库
|
|
|
outStatus = Constant.OutStatus.YICHUKU.getName();
|
|
|
}
|
|
|
return outStatus;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|