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

合单审批业务修改

parent f03e57e3
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.order.service.merge;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.BoxCheckOrderSchedulingEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
......@@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.order.convert.orderConsignee.OrderConsigneeConver
import cn.iocoder.yudao.module.order.convert.orderConsignor.OrderConsignorConvert;
import cn.iocoder.yudao.module.order.convert.orderDeparture.OrderDepartureConvert;
import cn.iocoder.yudao.module.order.convert.orderObjective.OrderObjectiveConvert;
import cn.iocoder.yudao.module.order.dal.dataobject.approval.OrderApprovalDO;
import cn.iocoder.yudao.module.order.dal.dataobject.merge.MergeDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderFeeApplication.OrderFeeApplicationDO;
......@@ -43,6 +45,7 @@ import cn.iocoder.yudao.module.order.service.orderCargoControl.OrderCargoControl
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import cn.iocoder.yudao.module.order.service.orderWarehousePicture.OrderWarehousePictureService;
import cn.iocoder.yudao.module.order.service.targetLog.TargetLogService;
import cn.iocoder.yudao.module.order.vo.approval.OrderApprovalQueryVO;
import cn.iocoder.yudao.module.order.vo.merge.*;
import cn.iocoder.yudao.module.order.vo.order.OrderBackVO;
import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemQueryVO;
......@@ -66,6 +69,7 @@ import java.util.stream.Collectors;
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.OrderApprovalTypeEnum.*;
/**
* 订单合单申请 Service 实现类
......@@ -135,18 +139,26 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
@Override
@Transactional
public void createMerge(List<MergeCreateReqVO> createReqVOS) {
List<OrderDO> approvalOrderList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(createReqVOS)) {
List<String> collect = createReqVOS.stream().map(MergeBaseVO::getOrderNos).collect(Collectors.toList());
collect.add(createReqVOS.get(0).getApplyOrderNo());
//判断这些订单是否已经已出
checkOrderCanOut(collect);
collect.stream().forEach(item -> {
for (String item : collect) {
OrderDO one = orderService.getOne(new LambdaQueryWrapperX<OrderDO>().eq(OrderDO::getOrderNo, item));
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(one.getOrderId()));
orderQueryService.throwPendingExceptionOrProcessingApproval(one.getOrderId());
});
if (one.getAbnormalState() != 0) {
throw exception(ORDER_HAS_PENDING_EXCEPTION, one.getOrderNo());
}
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(one.getOrderId(), null, merge_order.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, one.getOrderNo());
}
approvalOrderList.add(one);
}
}
OrderDO one = orderService.getOne(new LambdaQueryWrapperX<OrderDO>().eq(OrderDO::getOrderNo, createReqVOS.get(0).getApplyOrderNo()));
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(one.getOrderId()));
......@@ -160,24 +172,33 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
Long id = 0L;
Long userId = SecurityFrameworkUtils.getLoginUserId();
Date now = new Date();
List<MergeDO> mergeDOList = new ArrayList<>();
for (MergeCreateReqVO createReqVO : createReqVOS) {
MergeDO merge = MergeConvert.INSTANCE.convert(createReqVO);
merge.setAddTime(now);
mergeMapper.insert(merge);
id = merge.getId();
mergeDOList.add(merge);
}
//创建审批流
//创建审批流,这里只保存随便一个合并订单记录的主键id
String bpmProcessId = bpmCreateServiceFactory.createBmp(userId, id, WorkFlowEmus.ORDER_MERGE_ORDER.getKey(), createReqVOS.get(0).getApplyOrderNo(), createReqVOS.get(0).getCopyUserId());
Integer auditType = OrderApprovalTypeResultEnum.merge_order_processing.getType();
orderService.updateStatus(null, createReqVOS.get(0).getApplyOrderNo(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.order_merge_applying.getValue(), null, auditType, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, 1).getDesc());
for (MergeCreateReqVO createReqVO : createReqVOS) {
for (MergeDO merge : mergeDOList) {
mergeMapper.update(null, new LambdaUpdateWrapper<MergeDO>()
.eq(MergeDO::getApplyOrderNo, createReqVO.getApplyOrderNo())
.eq(MergeDO::getOrderNos, createReqVO.getOrderNos())
.eq(MergeDO::getId, merge.getId())
.set(MergeDO::getBpmProcessId, bpmProcessId));
orderService.updateStatus(null, createReqVO.getOrderNos(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.order_merge_applying.getValue(), null, auditType, OrderApprovalTypeResultEnum.typeAndResultOf(auditType, 1).getDesc());
}
// orderService.addOrderOperateLog(one.getOrderId(),"","提交合单申请","");
for (OrderDO orderDO : approvalOrderList) {
//创建审批单,发起流程
OrderApprovalDO orderApprovalDO = new OrderApprovalDO();
orderApprovalDO.setFollowUpSalesmanId(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
orderApprovalDO.setOrderId(orderDO.getOrderId());
//批量费用申请
orderApprovalDO.setType(expense_apply_BATCH.getValue());
orderApprovalDO.setStatus(ApprovalResultStatusEnum.processing.getValue());
orderApprovalDO.setFormId(bpmProcessId);
orderApprovalService.save(orderApprovalDO);
orderService.updateStatus(orderDO.getOrderId(), null, OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.order_merge_applying.getValue(), null, merge_order.getValue(), OrderApprovalTypeResultEnum.merge_order_processing.getDesc());
}
}
private void checkOrderCanOut(List<String> orderNoList) {
......@@ -185,8 +206,8 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
long count = orderList.stream()
.filter(t -> t.getAirShipment() > 1)
.count();
if(count > 0) {
throw new ServiceException(500, "订单已出,不能合");
if (count > 0) {
throw new ServiceException(500, "订单已出,不能合");
}
}
......@@ -247,13 +268,13 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
if (!CollectionUtil.isEmpty(mergeDOS1)) {
map.put("bpmProcessId", mergeDOS1.get(0).getBpmProcessId());
}
OrderBackVO applyOrder = orderQueryService.getOrder(orderService.selectOne(OrderDO::getOrderNo, mergeDOS.get(0).getApplyOrderNo()).getOrderId());
OrderBackVO applyOrder = orderQueryService.getOrderByNo(mergeDOS.get(0).getApplyOrderNo());
MergeBackVO applyConvertor = MergeConvert.INSTANCE.convert(mergeDOS.get(0));
applyConvertor.setMergedOrder(applyOrder);
backVOList.add(applyConvertor);
for (MergeDO mergeDO : mergeDOS) {
MergeBackVO convert = MergeConvert.INSTANCE.convert(mergeDO);
OrderBackVO order = orderQueryService.getOrder(orderService.selectOne(OrderDO::getOrderNo, mergeDO.getOrderNos()).getOrderId());
OrderBackVO order = orderQueryService.getOrderByNo(mergeDO.getOrderNos());
convert.setMergedOrder(order);
backVOList.add(convert);
}
......@@ -274,9 +295,16 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
@Override
@Transactional(rollbackFor = Exception.class)
public void updateOrderMergeResult(String id, int result) {
MergeDO mergeDO = mergeMapper.selectById(id);
// 需要先更新订单合单审批信息
OrderApprovalQueryVO query = new OrderApprovalQueryVO();
query.setFormId(mergeDO.getBpmProcessId());
List<OrderApprovalDO> approvalDOList = orderApprovalService.getApprovalList(query);
if (CollectionUtil.isNotEmpty(approvalDOList)) {
orderApprovalService.updateBatchById(approvalDOList.stream().peek(it -> it.setStatus(result)).collect(Collectors.toList()));
}
//审批拒绝则修改所有流程编号一致的合单申请状态
if (result == 3) {
MergeDO mergeDO = mergeMapper.selectById(id);
List<MergeDO> mergeDOS = mergeMapper.selectList(MergeDO::getBpmProcessId, mergeDO.getBpmProcessId());
Integer type = OrderApprovalTypeResultEnum.merge_order_reject.getType();
orderService.updateStatus(null, mergeDOS.get(0).getApplyOrderNo(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.warehouse_finished.getValue(), null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(type, 3).getDesc());
......@@ -285,8 +313,8 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
mergeMapper.updateById(mergeDO1);
orderService.updateStatus(null, mergeDO1.getOrderNos(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.warehouse_finished.getValue(), null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(type, 3).getDesc());
}
} else if (result == 2) {//审批通过,需考虑分多次提交的合单申请
MergeDO mergeDO = mergeMapper.selectById(id);
} else if (result == 2) {
//审批通过,需考虑分多次提交的合单申请
List<MergeDO> mergeDOS = new ArrayList<>();
if (mergeDO.getOrderNos().endsWith("S") || mergeDO.getApplyOrderNo().endsWith("S")) {
mergeDOS = mergeMapper.selectList(new LambdaQueryWrapperX<MergeDO>()
......@@ -379,7 +407,7 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
orderService.updateStatus(null, orderNo, OrderStatusEnum.MERGED_ORDER.getValue(), null, OrderWarehouseInStatusEnum.order_merge_apply_finish.getValue(), null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(type, 2).getDesc());
receivableService.remove(new LambdaQueryWrapperX<ReceivableDO>().eq(ReceivableDO::getOrderId, orderDO1.getOrderId()).eq(ReceivableDO::getFeeSource, 1));
//修改入仓数据
orderWarehouseInList.addAll(orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId,orderDO1.getOrderId()));
orderWarehouseInList.addAll(orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId, orderDO1.getOrderId()));
specialNeedList.addAll(orderSpecialNeedService.getListByOrderId(orderDO1.getOrderId()));
feeApplicationList.addAll(orderFeeApplicationService.getFeeApplicationListByOrderId(orderDO1.getOrderId()));
orderLocationList.addAll(orderLocationService.getOrderLocationListByOrderId(orderDO1.getOrderId()));
......@@ -516,13 +544,13 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
List<Long> orderIds = new ArrayList<>();
String applyOrderNo = "";
Integer type = OrderApprovalTypeResultEnum.merge_order_pass.getType();
List<OrderWarehouseInDO> orderWarehouseInList = orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId,orderDO2.getOrderId());
List<OrderWarehouseInDO> orderWarehouseInList = orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId, orderDO2.getOrderId());
List<OrderSpecialNeedDO> specialNeedList = orderSpecialNeedService.getListByOrderId(orderDO2.getOrderId());
List<OrderFeeApplicationDO> feeApplicationList = orderFeeApplicationService.getFeeApplicationListByOrderId(orderDO2.getOrderId());
List<OrderLocationDO> orderLocationList = orderLocationService.getOrderLocationListByOrderId(orderDO2.getOrderId());
List<OrderWarehousePictureDO> warehousePictureList = orderWarehousePictureService.selectList(new LambdaQueryWrapper<OrderWarehousePictureDO>()
.eq(OrderWarehousePictureDO::getType,5)
.in(OrderWarehousePictureDO::getBizId,orderItemIds)
.eq(OrderWarehousePictureDO::getType, 5)
.in(OrderWarehousePictureDO::getBizId, orderItemIds)
);
//处理和原订单合并的其他订单的信息
for (MergeDO mergeDO1 : mergeDOList) {
......@@ -570,7 +598,7 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
applyOrderNo = mergeDO1.getApplyOrderNo();
receivableService.remove(new LambdaQueryWrapperX<ReceivableDO>().eq(ReceivableDO::getOrderId, orderDO1.getOrderId()).eq(ReceivableDO::getFeeSource, 1));
//合并除订单外的其他数据 TODO 入仓数据怎么处理? 复制原来的加上订单id来新增?
orderWarehouseInList.addAll(orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId,orderDO1.getOrderId()));
orderWarehouseInList.addAll(orderWarehouseInService.selectList(OrderWarehouseInDO::getOrderId, orderDO1.getOrderId()));
specialNeedList.addAll(orderSpecialNeedService.getListByOrderId(orderDO1.getOrderId()));
feeApplicationList.addAll(orderFeeApplicationService.getFeeApplicationListByOrderId(orderDO1.getOrderId()));
orderLocationList.addAll(orderLocationService.getOrderLocationListByOrderId(orderDO1.getOrderId()));
......@@ -648,15 +676,12 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
// orderLocationService.insertBatch(orderLocationList);
}
} else if (result == 4) {
MergeDO mergeDO = mergeMapper.selectById(id);
Integer type = OrderApprovalTypeResultEnum.merge_order_cancel.getType();
List<MergeDO> cancelList = mergeMapper.selectList(new LambdaQueryWrapperX<MergeDO>().eq(MergeDO::getBpmProcessId, mergeDO.getBpmProcessId()).eq(MergeDO::getStatus, 1));
if (CollectionUtil.isNotEmpty(cancelList)) {
orderService.updateStatus(null, cancelList.get(0).getApplyOrderNo(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.warehouse_finished.getValue(), null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(type, 4).getDesc());
cancelList.stream().forEach(item -> orderService.updateStatus(null, item.getOrderNos(), OrderStatusEnum.IN_WAREHOUSE.getValue(), null, OrderWarehouseInStatusEnum.warehouse_finished.getValue(), null, 0, OrderApprovalTypeResultEnum.typeAndResultOf(type, 4).getDesc()));
}
mergeMapper.delete(new LambdaQueryWrapperX<MergeDO>().eq(MergeDO::getBpmProcessId, mergeDO.getBpmProcessId()));
}
}
......@@ -725,7 +750,7 @@ public class MergeServiceImpl extends AbstractService<MergeMapper, MergeDO> impl
private void feeApplicationCreateReceivable(List<OrderFeeApplicationDO> batchFeeList) {
List<FeeDto> feeDtos = new ArrayList<>();
if (CollectionUtil.isNotEmpty(batchFeeList)) {
OrderDO order = orderService.selectOne(OrderDO::getOrderId,batchFeeList.get(0).getOrderId());
OrderDO order = orderService.selectOne(OrderDO::getOrderId, batchFeeList.get(0).getOrderId());
for (OrderFeeApplicationDO feeApplicationDO : batchFeeList) {
//生成应收
DictDataRespDTO dictDto = DictFrameworkUtils.getDictDataFromCache("receivable_fee_type", String.valueOf(feeApplicationDO.getFeeType()));
......
......@@ -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.orderItem.OrderItemDO;
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.OrderSpecialApplyVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyVO;
......@@ -37,6 +38,7 @@ public interface OrderQueryService {
* @return 订单
*/
OrderBackVO getOrder(Long orderId);
OrderBackVO getOrderByNo(String orderNo);
OrderBackVO getParentOrder(Long orderId);
......@@ -296,7 +298,7 @@ public interface OrderQueryService {
*
* @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;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
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.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
......@@ -104,6 +105,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
......@@ -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.module.order.enums.ErrorCodeConstants.*;
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;
/**
......@@ -154,6 +157,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
private final AdminUserApi adminUserApi;
private final ReceiptService receiptService;
private final CurrencyApi currencyApi;
private final ApplicationContext applicationContext;
private final UserCardAuthService userCardAuthService;
......@@ -161,7 +165,6 @@ public class OrderQueryServiceImpl implements OrderQueryService {
private final OrderWarehousePictureService orderWarehousePictureService;
private final OrderItemPackLogMapper itemPackLogMapper;
private final OrderWarehouseInMapper orderWarehouseInMapper;
......@@ -520,6 +523,72 @@ public class OrderQueryServiceImpl implements OrderQueryService {
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
public OrderBackVO getParentOrder(Long orderId) {
// TODO 后面可以在订单列表返回初始母订单id,前端可以直接通过初始母订单id查询订单详情
......@@ -1542,7 +1611,6 @@ public class OrderQueryServiceImpl implements OrderQueryService {
@Override
public void throwPendingExceptionOrProcessingApproval(Long orderId) {
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
......@@ -1556,16 +1624,18 @@ public class OrderQueryServiceImpl implements OrderQueryService {
}
//判断未处理审核
this.throwProcessingApproval(orderId);
// this.throwProcessingApproval(orderId);
}
@Override
public void throwProcessingApproval(Long orderId) {
public void throwProcessingApproval(Long orderId, OrderApprovalTypeEnum approvalTypeEnum) {
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
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());
}
}
......
......@@ -175,20 +175,23 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
public Boolean createSplit(OrderSplitCreateReqVO createReqVO) {
String parentOrderNo = createReqVO.getParentOrderNo();
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()) {
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) {
throw exception(AIR_ORDER_IS_CONFIRM_CAN_NOT_SPLIT);
}
......@@ -591,15 +594,17 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
Long orderId = applyReqVO.getOrderId();
//该订单是否有待处理异常或待处理审核则抛出异常
orderQueryService.throwPendingExceptionOrProcessingApproval(orderId);
//草稿不可拆单
OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
if (OrderStatusEnum.DRAFT.getValue().equals(orderDO.getStatus())) {
throw exception(ORDER_DRAFT_STATUS_NOT_ALLOWED_SPLIT);
}
if (orderDO.getAbnormalState() != 0) {
throw exception(ORDER_HAS_PENDING_EXCEPTION, orderDO.getOrderNo());
}
//出货拆单不需要校验
if (applyReqVO.isCheckOrderScheduling()) {
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId));
......
......@@ -140,8 +140,12 @@ public class OrderWarehouseAdjustServiceImpl extends AbstractService<OrderWareho
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);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
......
......@@ -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.common.exception.util.ServiceExceptionUtil.exception;
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.WAREHOUSE_UPDATE;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.*;
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
else {
//完成入仓之后修改信息才发起审批流程
// 需要提交审批,则不能有其他任何审批
orderQueryService.throwProcessingApproval(orderId);
orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_UPDATE);
if (orderQueryService.isSplitOrderChildren(orderDO)) {
int sumOld = orderWarehouseInListOld.stream().mapToInt(OrderWarehouseInDO::getCartonsNum).sum();
......@@ -4221,7 +4220,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
applicationContext.publishEvent(new BoxCheckOrderSchedulingEvent(orderId));
// 判断是否有未处理的审核单
orderQueryService.throwProcessingApproval(orderId);
orderQueryService.throwProcessingApproval(orderId, WAREHOUSE_ROLLBACK);
String orderNo = orderWarehouseInRollbackApplyReqVO.getOrderNo();
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