Commit 5ec19d6c authored by 332784038@qq.com's avatar 332784038@qq.com

合单审批业务修改

parent f03e57e3
...@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; ...@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO; import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO; import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dto.*; import cn.iocoder.yudao.module.order.dto.*;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum;
import cn.iocoder.yudao.module.order.vo.approval.OrderApprovalHeadBaseVO; import cn.iocoder.yudao.module.order.vo.approval.OrderApprovalHeadBaseVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialApplyVO; import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialApplyVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyVO; import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyVO;
...@@ -37,6 +38,7 @@ public interface OrderQueryService { ...@@ -37,6 +38,7 @@ public interface OrderQueryService {
* @return 订单 * @return 订单
*/ */
OrderBackVO getOrder(Long orderId); OrderBackVO getOrder(Long orderId);
OrderBackVO getOrderByNo(String orderNo);
OrderBackVO getParentOrder(Long orderId); OrderBackVO getParentOrder(Long orderId);
...@@ -296,7 +298,7 @@ public interface OrderQueryService { ...@@ -296,7 +298,7 @@ public interface OrderQueryService {
* *
* @param orderId 订单id * @param orderId 订单id
*/ */
void throwProcessingApproval(Long orderId); void throwProcessingApproval(Long orderId, OrderApprovalTypeEnum approvalTypeEnum);
/** /**
......
...@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.order.service.order.impl; ...@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.order.service.order.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
...@@ -104,6 +105,7 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -104,6 +105,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -124,6 +126,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU ...@@ -124,6 +126,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.*; import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.*;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.ORDER_UPDATE; import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.ORDER_UPDATE;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.merge_order;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.NOT_FIND_CURRENCY; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.NOT_FIND_CURRENCY;
/** /**
...@@ -154,6 +157,7 @@ public class OrderQueryServiceImpl implements OrderQueryService { ...@@ -154,6 +157,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
private final AdminUserApi adminUserApi; private final AdminUserApi adminUserApi;
private final ReceiptService receiptService; private final ReceiptService receiptService;
private final CurrencyApi currencyApi; private final CurrencyApi currencyApi;
private final ApplicationContext applicationContext;
private final UserCardAuthService userCardAuthService; private final UserCardAuthService userCardAuthService;
...@@ -161,7 +165,6 @@ public class OrderQueryServiceImpl implements OrderQueryService { ...@@ -161,7 +165,6 @@ public class OrderQueryServiceImpl implements OrderQueryService {
private final OrderWarehousePictureService orderWarehousePictureService; private final OrderWarehousePictureService orderWarehousePictureService;
private final OrderItemPackLogMapper itemPackLogMapper;
private final OrderWarehouseInMapper orderWarehouseInMapper; private final OrderWarehouseInMapper orderWarehouseInMapper;
...@@ -520,6 +523,72 @@ public class OrderQueryServiceImpl implements OrderQueryService { ...@@ -520,6 +523,72 @@ public class OrderQueryServiceImpl implements OrderQueryService {
return backVO; return backVO;
} }
@Override
public OrderBackVO getOrderByNo(String orderNo) {
OrderDO orderDO = orderMapper.selectOne(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getOrderNo, orderNo).last("limit 1"));
if (Objects.isNull(orderDO)) {
throw exception(ORDER_NOT_EXISTS);
}
OrderBackVO backVO = OrderConvert.INSTANCE.convert(orderDO);
if (StringUtils.isNotBlank(backVO.getExternalWarehouseJson())) {
backVO.setExternalWarehouseDtoList(JSONObject.parseArray(backVO.getExternalWarehouseJson(), ExternalWarehouseDto.class));
}
// 发货人信息
OrderConsignorDO orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
// if (Objects.isNull(orderConsignorDO)) {
// throw exception(ORDER_CONSIGNOR_NOT_EXISTS);
// }
if (Objects.nonNull(orderConsignorDO)) {
backVO.setConsignorVO(OrderConsignorConvert.INSTANCE.convert(orderConsignorDO));
backVO.setConsignorId(orderConsignorDO.getCustomerId());
backVO.setConsignorContactsId(orderConsignorDO.getCustomerContactsId());
}
// 收货人信息
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
// if (Objects.isNull(orderConsigneeDO)) {
// throw exception(ORDER_CONSIGNEE_NOT_EXISTS);
// }
if (Objects.nonNull(orderConsigneeDO)) {
backVO.setConsigneeVO(OrderConsigneeConvert.INSTANCE.convert(orderConsigneeDO));
backVO.setConsigneeId(orderConsigneeDO.getCustomerId());
backVO.setConsigneeContactsId(orderConsigneeDO.getCustomerContactsId());
backVO.setConsigneeAddress(orderConsigneeDO.getAddress());
backVO.setHarvestMethod(orderConsigneeDO.getHarvestMethod());
backVO.setCity(orderConsigneeDO.getCity());
backVO.setProvince(orderConsigneeDO.getProvince());
backVO.setCountry(orderConsigneeDO.getCountry());
}
// 始发地
OrderDepartureDO orderDepartureDO = orderDepartureService.getOne(new LambdaQueryWrapper<OrderDepartureDO>().eq(OrderDepartureDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderDepartureDO::getId).last("limit 1"));
backVO.setOrderDepartureVO(OrderDepartureConvert.INSTANCE.convert(orderDepartureDO));
backVO.setDepartureId(orderDepartureDO.getDepartureId());
// 目的地
OrderObjectiveDO orderObjectiveDO = orderObjectiveService.getOne(new LambdaQueryWrapper<OrderObjectiveDO>().eq(OrderObjectiveDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderObjectiveDO::getId).last("limit 1"));
backVO.setOrderObjectiveVO(OrderObjectiveConvert.INSTANCE.convert(orderObjectiveDO));
backVO.setObjectiveId(orderObjectiveDO.getObjectiveId());
// 商品信息
List<OrderItemDO> itemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderItemDO::getOrderItemId));
if (CollectionUtil.isNotEmpty(itemDOList)) {
backVO.setOrderItemVOList(OrderItemConvert.INSTANCE.convertList(itemDOList));
}
// 物流信息查询
LogisticsInfoDto logisticsInfoDto = warehouseLineMapper.getStartInfoAndDestInfoByLineId(backVO.getLineId());
if (Objects.isNull(logisticsInfoDto)) {
throw exception(NOT_FIND_LOGISTICS_INFO);
}
logisticsInfoDto.setLineId(backVO.getLineId());
logisticsInfoDto.setTransportId(backVO.getTransportId());
logisticsInfoDto.setChannelId(backVO.getChannelId());
backVO.setLogisticsInfoDto(logisticsInfoDto);
// if (backVO.getOrderNo().startsWith("DRAFT")) {
// backVO.setOrderNo("");
// }
return backVO;
}
@Override @Override
public OrderBackVO getParentOrder(Long orderId) { public OrderBackVO getParentOrder(Long orderId) {
// TODO 后面可以在订单列表返回初始母订单id,前端可以直接通过初始母订单id查询订单详情 // TODO 后面可以在订单列表返回初始母订单id,前端可以直接通过初始母订单id查询订单详情
...@@ -1542,7 +1611,6 @@ public class OrderQueryServiceImpl implements OrderQueryService { ...@@ -1542,7 +1611,6 @@ public class OrderQueryServiceImpl implements OrderQueryService {
@Override @Override
public void throwPendingExceptionOrProcessingApproval(Long orderId) { public void throwPendingExceptionOrProcessingApproval(Long orderId) {
OrderDO orderDO = orderMapper.selectById(orderId); OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) { if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS); throw exception(ORDER_NOT_EXISTS);
...@@ -1556,16 +1624,18 @@ public class OrderQueryServiceImpl implements OrderQueryService { ...@@ -1556,16 +1624,18 @@ public class OrderQueryServiceImpl implements OrderQueryService {
} }
//判断未处理审核 //判断未处理审核
this.throwProcessingApproval(orderId); // this.throwProcessingApproval(orderId);
} }
@Override @Override
public void throwProcessingApproval(Long orderId) { public void throwProcessingApproval(Long orderId, OrderApprovalTypeEnum approvalTypeEnum) {
OrderDO orderDO = orderMapper.selectById(orderId); OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) { if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS); throw exception(ORDER_NOT_EXISTS);
} }
if (orderDO.getAuditType() != 0) { OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, approvalTypeEnum.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo()); throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
} }
} }
......
...@@ -175,20 +175,23 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord ...@@ -175,20 +175,23 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
public Boolean createSplit(OrderSplitCreateReqVO createReqVO) { public Boolean createSplit(OrderSplitCreateReqVO createReqVO) {
String parentOrderNo = createReqVO.getParentOrderNo(); String parentOrderNo = createReqVO.getParentOrderNo();
Long parentOrderId = createReqVO.getParentOrderId(); Long parentOrderId = createReqVO.getParentOrderId();
//草稿不可拆单
OrderDO orderDO = orderService.getById(parentOrderId);
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) {
throw exception(ORDER_DRAFT_STATUS_NOT_ALLOWED_SPLIT);
}
//该订单是否有待处理异常或待处理审核则抛出异常 //该订单是否有待处理异常或待处理审核则抛出异常
orderQueryService.throwPendingExceptionOrProcessingApproval(parentOrderId); if (orderDO.getAbnormalState() != 0) {
throw exception(ORDER_HAS_PENDING_EXCEPTION, orderDO.getOrderNo());
}
//出货拆单不需要校验 //出货拆单不需要校验
if (createReqVO.isCheckOrderScheduling()) { if (createReqVO.isCheckOrderScheduling()) {
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(parentOrderId)); applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(parentOrderId));
} }
//草稿不可拆单
OrderDO orderDO = orderService.getById(parentOrderId);
if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) {
throw exception(ORDER_DRAFT_STATUS_NOT_ALLOWED_SPLIT);
}
if (orderDO.getTransportId() == 4 && OrderStatusEnum.IN_WAREHOUSE.getValue().equals(orderDO.getStatus()) && orderDO.getAirShipment() == 2) { if (orderDO.getTransportId() == 4 && OrderStatusEnum.IN_WAREHOUSE.getValue().equals(orderDO.getStatus()) && orderDO.getAirShipment() == 2) {
throw exception(AIR_ORDER_IS_CONFIRM_CAN_NOT_SPLIT); throw exception(AIR_ORDER_IS_CONFIRM_CAN_NOT_SPLIT);
} }
...@@ -591,15 +594,17 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord ...@@ -591,15 +594,17 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
Long orderId = applyReqVO.getOrderId(); Long orderId = applyReqVO.getOrderId();
//该订单是否有待处理异常或待处理审核则抛出异常
orderQueryService.throwPendingExceptionOrProcessingApproval(orderId);
//草稿不可拆单 //草稿不可拆单
OrderDO orderDO = orderService.getById(orderId); OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) { if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) {
throw exception(ORDER_DRAFT_STATUS_NOT_ALLOWED_SPLIT); throw exception(ORDER_DRAFT_STATUS_NOT_ALLOWED_SPLIT);
} }
if (orderDO.getAbnormalState() != 0) {
throw exception(ORDER_HAS_PENDING_EXCEPTION, orderDO.getOrderNo());
}
//出货拆单不需要校验 //出货拆单不需要校验
if (applyReqVO.isCheckOrderScheduling()) { if (applyReqVO.isCheckOrderScheduling()) {
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId)); applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId));
......
...@@ -140,8 +140,12 @@ public class OrderWarehouseAdjustServiceImpl extends AbstractService<OrderWareho ...@@ -140,8 +140,12 @@ public class OrderWarehouseAdjustServiceImpl extends AbstractService<OrderWareho
adjustDirectList.add(orderId); adjustDirectList.add(orderId);
} }
} }
orderQueryService.throwPendingExceptionOrProcessingApproval(orderId); if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
if (orderDO.getAbnormalState() != 0) {
throw exception(ORDER_HAS_PENDING_EXCEPTION, orderDO.getOrderNo());
}
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, WAREHOUSE_ADJUST.getValue(), null, false); OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, WAREHOUSE_ADJUST.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent); applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) { if (approvalTypeCheckEvent.getResult()) {
......
...@@ -133,8 +133,7 @@ import java.util.stream.Collectors; ...@@ -133,8 +133,7 @@ import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.apollo.core.constants.Constants.NOT_ACCEPTED_PROD_CODE; import static cn.iocoder.yudao.framework.apollo.core.constants.Constants.NOT_ACCEPTED_PROD_CODE;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_ADJUST; import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_UPDATE;
import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIVABLE_WRITE_OFF_ING_NO_NEED_TO_PACK; import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.RECEIVABLE_WRITE_OFF_ING_NO_NEED_TO_PACK;
/** /**
...@@ -2885,7 +2884,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -2885,7 +2884,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
else { else {
//完成入仓之后修改信息才发起审批流程 //完成入仓之后修改信息才发起审批流程
// 需要提交审批,则不能有其他任何审批 // 需要提交审批,则不能有其他任何审批
orderQueryService.throwProcessingApproval(orderId); orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_UPDATE);
if (orderQueryService.isSplitOrderChildren(orderDO)) { if (orderQueryService.isSplitOrderChildren(orderDO)) {
int sumOld = orderWarehouseInListOld.stream().mapToInt(OrderWarehouseInDO::getCartonsNum).sum(); int sumOld = orderWarehouseInListOld.stream().mapToInt(OrderWarehouseInDO::getCartonsNum).sum();
...@@ -4221,7 +4220,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -4221,7 +4220,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId)); applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId));
// 判断是否有未处理的审核单 // 判断是否有未处理的审核单
orderQueryService.throwProcessingApproval(orderId); orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_ROLLBACK);
String orderNo = orderWarehouseInRollbackApplyReqVO.getOrderNo(); String orderNo = orderWarehouseInRollbackApplyReqVO.getOrderNo();
OrderWarehouseApprovalDO orderWarehouseApprovalDO = OrderWarehouseApprovalDO.builder() OrderWarehouseApprovalDO orderWarehouseApprovalDO = OrderWarehouseApprovalDO.builder()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment