|
@@ -1,7 +1,9 @@
|
|
package com.hys.app.service.erp.impl;
|
|
package com.hys.app.service.erp.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.io.IoUtil;
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -13,6 +15,7 @@ import com.hys.app.framework.database.mybatisplus.base.BaseServiceImpl;
|
|
import com.hys.app.framework.exception.ServiceException;
|
|
import com.hys.app.framework.exception.ServiceException;
|
|
import com.hys.app.framework.rabbitmq.MessageSender;
|
|
import com.hys.app.framework.rabbitmq.MessageSender;
|
|
import com.hys.app.framework.rabbitmq.MqMessage;
|
|
import com.hys.app.framework.rabbitmq.MqMessage;
|
|
|
|
+import com.hys.app.framework.util.BeanUtils;
|
|
import com.hys.app.framework.util.CurrencyUtil;
|
|
import com.hys.app.framework.util.CurrencyUtil;
|
|
import com.hys.app.framework.util.DateUtil;
|
|
import com.hys.app.framework.util.DateUtil;
|
|
import com.hys.app.framework.util.PageConvert;
|
|
import com.hys.app.framework.util.PageConvert;
|
|
@@ -25,14 +28,13 @@ import com.hys.app.model.erp.dto.OrderReturnQueryParams;
|
|
import com.hys.app.model.erp.dto.OrderReturnStatisticsQueryParam;
|
|
import com.hys.app.model.erp.dto.OrderReturnStatisticsQueryParam;
|
|
import com.hys.app.model.erp.dto.message.OrderReturnAuditPassMessage;
|
|
import com.hys.app.model.erp.dto.message.OrderReturnAuditPassMessage;
|
|
import com.hys.app.model.erp.enums.*;
|
|
import com.hys.app.model.erp.enums.*;
|
|
-import com.hys.app.model.erp.vo.OrderReturnAllowable;
|
|
|
|
-import com.hys.app.model.erp.vo.OrderReturnStatistics;
|
|
|
|
-import com.hys.app.model.erp.vo.OrderReturnVO;
|
|
|
|
|
|
+import com.hys.app.model.erp.vo.*;
|
|
import com.hys.app.model.system.dos.AdminUser;
|
|
import com.hys.app.model.system.dos.AdminUser;
|
|
import com.hys.app.model.system.dos.DeptDO;
|
|
import com.hys.app.model.system.dos.DeptDO;
|
|
import com.hys.app.service.erp.*;
|
|
import com.hys.app.service.erp.*;
|
|
import com.hys.app.service.system.AdminUserManager;
|
|
import com.hys.app.service.system.AdminUserManager;
|
|
import com.hys.app.service.system.DeptManager;
|
|
import com.hys.app.service.system.DeptManager;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -53,49 +55,21 @@ import static com.hys.app.framework.util.CollectionUtils.convertMap;
|
|
* @since 2023-12-14 15:42:07
|
|
* @since 2023-12-14 15:42:07
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@AllArgsConstructor
|
|
public class OrderReturnManagerImpl extends BaseServiceImpl<OrderReturnMapper, OrderReturnDO> implements OrderReturnManager {
|
|
public class OrderReturnManagerImpl extends BaseServiceImpl<OrderReturnMapper, OrderReturnDO> implements OrderReturnManager {
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderReturnConverter converter;
|
|
private OrderReturnConverter converter;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderReturnItemConverter itemConverter;
|
|
private OrderReturnItemConverter itemConverter;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderReturnItemManager orderReturnItemManager;
|
|
private OrderReturnItemManager orderReturnItemManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private DeptManager deptManager;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private WarehouseManager warehouseManager;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderManager orderManager;
|
|
private OrderManager orderManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ private OrderItemManager orderItemManager;
|
|
private WarehouseOutItemManager warehouseOutItemManager;
|
|
private WarehouseOutItemManager warehouseOutItemManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private NoGenerateManager noGenerateManager;
|
|
private NoGenerateManager noGenerateManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderReturnMapper orderReturnMapper;
|
|
private OrderReturnMapper orderReturnMapper;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private WarehouseEntryBatchManager batchManager;
|
|
private WarehouseEntryBatchManager batchManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private MessageSender messageSender;
|
|
private MessageSender messageSender;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private AdminUserManager adminUserManager;
|
|
private AdminUserManager adminUserManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private FinanceItemManager financeItemManager;
|
|
private FinanceItemManager financeItemManager;
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private OrderItemManager orderItemManager;
|
|
|
|
|
|
+ private GoodsManager goodsManager;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public WebPage<OrderReturnVO> list(OrderReturnQueryParams queryParams) {
|
|
public WebPage<OrderReturnVO> list(OrderReturnQueryParams queryParams) {
|
|
@@ -113,142 +87,88 @@ public class OrderReturnManagerImpl extends BaseServiceImpl<OrderReturnMapper, O
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void add(OrderReturnDTO orderReturnDTO) {
|
|
public void add(OrderReturnDTO orderReturnDTO) {
|
|
- check(orderReturnDTO);
|
|
|
|
-
|
|
|
|
- // 保存退货单
|
|
|
|
- OrderReturnDO orderReturnDO = converter.combination(orderReturnDTO);
|
|
|
|
- orderReturnDO.setSn(noGenerateManager.generate(NoBusinessTypeEnum.OrderReturn, orderReturnDTO.getDeptId()));
|
|
|
|
- orderReturnDO.setStatus(OrderReturnStatusEnum.NotSubmit);
|
|
|
|
- save(orderReturnDO);
|
|
|
|
|
|
+ OrderDO aDo = orderManager.getById(orderReturnDTO.getOrderId());
|
|
|
|
+ if (ObjectUtil.isNull(aDo)) {
|
|
|
|
+ throw new ServiceException("要发起售后的订单不存在");
|
|
|
|
+ }
|
|
|
|
+ if (SaleOrderStatusEnum.SALE_AFTER_END.equals(aDo.getStatus())){
|
|
|
|
+ throw new ServiceException("一个订单只能做一次售后");
|
|
|
|
+ }
|
|
|
|
+ //判断要退货的商品有没有超过订单数量的商品
|
|
|
|
+ for (OrderReturnItemDTO dto : orderReturnDTO.getItemList()) {
|
|
|
|
+ OrderItemDO itemDO = orderItemManager.getById(dto.getOrderItemId());
|
|
|
|
+ if (ObjectUtil.isNull(itemDO)) {
|
|
|
|
+ throw new ServiceException("退货的商品必须在订单里");
|
|
|
|
+ }
|
|
|
|
+ if (itemDO.getNum() < dto.getReturnNum()) {
|
|
|
|
+ throw new ServiceException("退貨的数量不能大于原订单的物品数量");
|
|
|
|
+ }
|
|
|
|
+ itemDO.setReturnNum(dto.getReturnNum());
|
|
|
|
+ orderItemManager.updateById(itemDO);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ //更改订单的状态
|
|
|
|
+ aDo.setStatus(SaleOrderStatusEnum.AFTER_SALE);
|
|
|
|
+ orderManager.updateById(aDo);
|
|
|
|
+ //新增售后订单主题
|
|
|
|
+ OrderReturnDO returnDO = BeanUtil.copyProperties(orderReturnDTO, OrderReturnDO.class);
|
|
|
|
+ returnDO.setSn(noGenerateManager.generate(NoBusinessTypeEnum.OrderReturn, 66L));
|
|
|
|
+ save(returnDO);
|
|
// 保存退货单明细
|
|
// 保存退货单明细
|
|
- List<OrderReturnItemDO> itemList = itemConverter.combination(orderReturnDO.getId(), orderReturnDTO);
|
|
|
|
- orderReturnItemManager.saveBatch(itemList);
|
|
|
|
|
|
+ List<OrderReturnItemDO> itemBean = BeanUtils.toBean(orderReturnDTO.getItemList(), OrderReturnItemDO.class);
|
|
|
|
+ itemBean.forEach(item ->item.setOrderReturnId(returnDO.getId()));
|
|
|
|
+ orderReturnItemManager.saveBatch(itemBean);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void edit(OrderReturnDTO orderReturnDTO) {
|
|
public void edit(OrderReturnDTO orderReturnDTO) {
|
|
|
|
+ //还原原订单的数据
|
|
OrderReturnDO oldDO = getById(orderReturnDTO.getId());
|
|
OrderReturnDO oldDO = getById(orderReturnDTO.getId());
|
|
- if (!new OrderReturnAllowable(oldDO).getEdit()) {
|
|
|
|
- throw new ServiceException("不能进行编辑操作");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- check(orderReturnDTO);
|
|
|
|
-
|
|
|
|
// 保存退货单
|
|
// 保存退货单
|
|
OrderReturnDO orderReturnDO = converter.combination(orderReturnDTO);
|
|
OrderReturnDO orderReturnDO = converter.combination(orderReturnDTO);
|
|
updateById(orderReturnDO);
|
|
updateById(orderReturnDO);
|
|
-
|
|
|
|
// 保存退货单明细
|
|
// 保存退货单明细
|
|
- List<OrderReturnItemDO> itemList = itemConverter.combination(orderReturnDO.getId(), orderReturnDTO);
|
|
|
|
- orderReturnItemManager.deleteByOrderReturnId(Collections.singletonList(orderReturnDTO.getId()));
|
|
|
|
- orderReturnItemManager.saveBatch(itemList);
|
|
|
|
|
|
+// List<OrderReturnItemDO> itemList = itemConverter.combination(orderReturnDO.getId(), orderReturnDTO);
|
|
|
|
+// orderReturnItemManager.deleteByOrderReturnId(Collections.singletonList(orderReturnDTO.getId()));
|
|
|
|
+// orderReturnItemManager.saveBatch(itemList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public OrderReturnVO getDetail(String id) {
|
|
public OrderReturnVO getDetail(String id) {
|
|
OrderReturnVO orderReturnVO = converter.convert(getById(id));
|
|
OrderReturnVO orderReturnVO = converter.convert(getById(id));
|
|
List<OrderReturnItemDO> itemList = orderReturnItemManager.listByOrderReturnId(id);
|
|
List<OrderReturnItemDO> itemList = orderReturnItemManager.listByOrderReturnId(id);
|
|
- orderReturnVO.setItemList(itemConverter.convert(itemList));
|
|
|
|
- return orderReturnVO;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public void delete(List<String> ids) {
|
|
|
|
- List<OrderReturnDO> orderReturnList = listByIds(ids);
|
|
|
|
- for (OrderReturnDO orderReturnDO : orderReturnList) {
|
|
|
|
- if (!new OrderReturnAllowable(orderReturnDO).getDelete()) {
|
|
|
|
- throw new ServiceException(orderReturnDO.getSn() + "不允许进行删除操作");
|
|
|
|
- }
|
|
|
|
|
|
+ List<OrderReturnItemVO> convert = itemConverter.convert(itemList);
|
|
|
|
+ for (OrderReturnItemVO vo : convert) {
|
|
|
|
+ OrderItemDO itemDO = orderItemManager.getById(vo.getOrderItemId());
|
|
|
|
+ GoodsDO goodsDO = goodsManager.getById(itemDO.getGoodsId());
|
|
|
|
+ vo.setGoodsVO(BeanUtil.copyProperties(goodsDO, GoodsVO.class));
|
|
|
|
+ vo.setNum(itemDO.getNum());
|
|
}
|
|
}
|
|
-
|
|
|
|
- removeBatchByIds(ids);
|
|
|
|
- orderReturnItemManager.deleteByOrderReturnId(ids);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void submit(Long id) {
|
|
|
|
- // 校验
|
|
|
|
- OrderReturnDO oldDO = getById(id);
|
|
|
|
- if (!new OrderReturnAllowable(oldDO).getSubmit()) {
|
|
|
|
- throw new ServiceException("不允许进行提交操作");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- lambdaUpdate()
|
|
|
|
- .set(OrderReturnDO::getStatus, OrderReturnStatusEnum.Submit)
|
|
|
|
- .eq(OrderReturnDO::getId, id)
|
|
|
|
- .update();
|
|
|
|
|
|
+ orderReturnVO.setItemList(convert);
|
|
|
|
+ return orderReturnVO;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void withdraw(Long id) {
|
|
|
|
- // 校验
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ public void cancel(String edit, Long id) {
|
|
|
|
+ // 更改原定单状态,更改售后订单状态
|
|
OrderReturnDO oldDO = getById(id);
|
|
OrderReturnDO oldDO = getById(id);
|
|
- if (!new OrderReturnAllowable(oldDO).getWithdraw()) {
|
|
|
|
- throw new ServiceException("不允许进行提交操作");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- lambdaUpdate()
|
|
|
|
- .set(OrderReturnDO::getStatus, OrderReturnStatusEnum.NotSubmit)
|
|
|
|
- .eq(OrderReturnDO::getId, id)
|
|
|
|
- .update();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public void audit(List<Long> ids, OrderReturnStatusEnum status, String remark) {
|
|
|
|
- if (status != OrderReturnStatusEnum.AuditPass && status != OrderReturnStatusEnum.AuditReject) {
|
|
|
|
- throw new ServiceException("审核参数错误");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<OrderReturnDO> orderReturnList = listByIds(ids);
|
|
|
|
- for (OrderReturnDO orderReturnDO : orderReturnList) {
|
|
|
|
- // 校验
|
|
|
|
- if (!new OrderReturnAllowable(orderReturnDO).getAudit()) {
|
|
|
|
- throw new ServiceException(orderReturnDO.getSn() + "不能进行审核操作");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- AdminUser currUser = adminUserManager.getCurrUser();
|
|
|
|
- lambdaUpdate()
|
|
|
|
- // 如果是驳回,状态改为未提交状态
|
|
|
|
- .set(OrderReturnDO::getStatus, status == OrderReturnStatusEnum.AuditReject ? OrderReturnStatusEnum.NotSubmit : status)
|
|
|
|
- .set(OrderReturnDO::getAuditRemark, remark)
|
|
|
|
- .set(OrderReturnDO::getAuditById, currUser.getId())
|
|
|
|
- .set(OrderReturnDO::getAuditBy, currUser.getRealName())
|
|
|
|
- .in(OrderReturnDO::getId, ids)
|
|
|
|
- .update();
|
|
|
|
-
|
|
|
|
- // 如果审核通过
|
|
|
|
- if (status == OrderReturnStatusEnum.AuditPass) {
|
|
|
|
- for (OrderReturnDO orderReturnDO : orderReturnList) {
|
|
|
|
- List<OrderReturnItemDO> returnItemList = orderReturnItemManager.listByOrderReturnId(orderReturnDO.getId());
|
|
|
|
-
|
|
|
|
- // 因为不是退回原来的仓库,所以需要新创建批次
|
|
|
|
- List<WarehouseEntryBatchDO> batchList = itemConverter.combination(returnItemList, orderReturnDO, noGenerateManager);
|
|
|
|
- batchManager.create(StockChangeSourceEnum.ORDER_RETURN, orderReturnDO.getSn(), batchList);
|
|
|
|
-
|
|
|
|
- // 更新已退货数量
|
|
|
|
- for (OrderReturnItemDO orderReturnItemDO : returnItemList) {
|
|
|
|
- if (orderReturnDO.getOrderType() == OrderTypeEnum.TO_B) {
|
|
|
|
- warehouseOutItemManager.increaseReturnNum(orderReturnItemDO.getWarehouseOutItemId(), orderReturnItemDO.getReturnNum());
|
|
|
|
- } else {
|
|
|
|
- orderItemManager.increaseReturnNum(orderReturnItemDO.getOrderItemId(), orderReturnItemDO.getReturnNum());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 生成财务明细
|
|
|
|
- Double totalPrice = CurrencyUtil.sum(returnItemList, itemDO -> CurrencyUtil.add(itemDO.getProductPrice(), itemDO.getReturnNum()));
|
|
|
|
- financeItemManager.addExpand(FinanceExpandTypeEnum.OrderReturn, orderReturnDO.getSn(), totalPrice);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 发送审核通过消息
|
|
|
|
- OrderReturnAuditPassMessage message = new OrderReturnAuditPassMessage();
|
|
|
|
- message.setList(orderReturnList);
|
|
|
|
- this.messageSender.send(new MqMessage(AmqpExchange.ORDER_RETURN_AUDIT_PASS, AmqpExchange.ORDER_RETURN_AUDIT_PASS + "_ROUTING", message));
|
|
|
|
|
|
+ OrderDO orderDo = orderManager.getById(oldDO.getOrderId());
|
|
|
|
+ switch (edit) {
|
|
|
|
+ case "end":
|
|
|
|
+ orderDo.setStatus(SaleOrderStatusEnum.SALE_AFTER_END);
|
|
|
|
+ oldDO.setStatus(ReturnOrderStatusEnum.SALE_AFTER_END);
|
|
|
|
+ break;
|
|
|
|
+ case "cancel":
|
|
|
|
+ orderDo.setStatus(SaleOrderStatusEnum.SALE_AFTER_CANCEL);
|
|
|
|
+ oldDO.setStatus(ReturnOrderStatusEnum.SALE_AFTER_CANCEL);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ throw new ServiceException("非法操作");
|
|
}
|
|
}
|
|
|
|
+ updateById(oldDO);
|
|
|
|
+ orderManager.updateById(orderDo);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -309,67 +229,6 @@ public class OrderReturnManagerImpl extends BaseServiceImpl<OrderReturnMapper, O
|
|
IoUtil.close(out);
|
|
IoUtil.close(out);
|
|
}
|
|
}
|
|
|
|
|
|
- private void check(OrderReturnDTO orderReturnDTO) {
|
|
|
|
- OrderDO orderDO = orderManager.getById(orderReturnDTO.getOrderId());
|
|
|
|
- if (orderDO == null) {
|
|
|
|
- throw new ServiceException("订单不存在");
|
|
|
|
- }
|
|
|
|
- boolean isToC = orderDO.getType() == OrderTypeEnum.TO_C;
|
|
|
|
- if (!isToC && !orderDO.getShipFlag()) {
|
|
|
|
- throw new ServiceException("只能选择已发货的订单");
|
|
|
|
- }
|
|
|
|
- if (isToC) {
|
|
|
|
- // 零售订单校验订单项
|
|
|
|
- Map<Long, OrderItemDO> orderItemMap = checkOrderItem(orderReturnDTO);
|
|
|
|
- orderReturnDTO.setOrderItemMap(orderItemMap);
|
|
|
|
- // 查询订单项的批次信息
|
|
|
|
- List<Long> batchIds = convertList(orderItemMap.values(), OrderItemDO::getBatchId);
|
|
|
|
- List<WarehouseEntryBatchDO> batchList = batchManager.listByIds(batchIds);
|
|
|
|
- Map<Long, WarehouseEntryBatchDO> batchMap = convertMap(batchList, WarehouseEntryBatchDO::getId, Function.identity());
|
|
|
|
- orderReturnDTO.setBatchMap(batchMap);
|
|
|
|
- } else {
|
|
|
|
- // 销售订单校验出库单项
|
|
|
|
- Map<Long, WarehouseOutItemDO> warehouseOutItemMap = checkWarehouseOutItem(orderReturnDTO);
|
|
|
|
- orderReturnDTO.setWarehouseOutItemMap(warehouseOutItemMap);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// DeptDO deptDO = deptManager.getDept(orderReturnDTO.getDeptId());
|
|
|
|
-// if (deptDO == null) {
|
|
|
|
-// throw new ServiceException("部门不存在");
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- WarehouseDO warehouseDO = warehouseManager.getById(orderReturnDTO.getWarehouseId());
|
|
|
|
- if (warehouseDO == null) {
|
|
|
|
- throw new ServiceException("仓库不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- AdminUser handleBy = adminUserManager.getModel(orderReturnDTO.getHandleById());
|
|
|
|
- if (handleBy == null) {
|
|
|
|
- throw new ServiceException("经手人不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- orderReturnDTO.setOrderDO(orderDO);
|
|
|
|
-// orderReturnDTO.setDeptDO(deptDO);
|
|
|
|
- orderReturnDTO.setWarehouseDO(warehouseDO);
|
|
|
|
- orderReturnDTO.setHandleBy(handleBy);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Map<Long, WarehouseOutItemDO> checkWarehouseOutItem(OrderReturnDTO orderReturnDTO) {
|
|
|
|
- List<Long> warehouseOutItemIdIds = convertList(orderReturnDTO.getItemList(), OrderReturnItemDTO::getWarehouseOutItemId);
|
|
|
|
- Map<Long, WarehouseOutItemDO> warehouseOutItemMap = warehouseOutItemManager.listAndConvertMap(warehouseOutItemIdIds, WarehouseOutItemDO::getId);
|
|
|
|
-
|
|
|
|
- for (OrderReturnItemDTO returnItemDTO : orderReturnDTO.getItemList()) {
|
|
|
|
- WarehouseOutItemDO warehouseOutItemDO = warehouseOutItemMap.get(returnItemDTO.getWarehouseOutItemId());
|
|
|
|
- if (warehouseOutItemDO == null) {
|
|
|
|
- throw new ServiceException("出库单项:" + returnItemDTO.getWarehouseOutItemId() + "不存在");
|
|
|
|
- }
|
|
|
|
- if ((warehouseOutItemDO.getReturnNum() + returnItemDTO.getReturnNum()) > warehouseOutItemDO.getOutNum()) {
|
|
|
|
- throw new ServiceException(warehouseOutItemDO.getProductName() + "可退货数量不足");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return warehouseOutItemMap;
|
|
|
|
- }
|
|
|
|
|
|
|
|
private Map<Long, OrderItemDO> checkOrderItem(OrderReturnDTO orderReturnDTO) {
|
|
private Map<Long, OrderItemDO> checkOrderItem(OrderReturnDTO orderReturnDTO) {
|
|
if (orderReturnDTO.getItemList().stream().anyMatch(orderReturnItemDTO -> orderReturnItemDTO.getOrderItemId() == null)) {
|
|
if (orderReturnDTO.getItemList().stream().anyMatch(orderReturnItemDTO -> orderReturnItemDTO.getOrderItemId() == null)) {
|