Commit 7eb461fe authored by 332784038@qq.com's avatar 332784038@qq.com

对订单相关审批互斥拦截业务调用

parent 9a1b39fb
......@@ -3,6 +3,8 @@ package cn.iocoder.yudao.framework.apollo.core.event.Order;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
@Data
@AllArgsConstructor
public class OrderApprovalTypeCheckEvent {
......@@ -15,7 +17,7 @@ public class OrderApprovalTypeCheckEvent {
/**
* 订单项id
*/
private Long orderItemId;
private List<Long> orderItemIdList;
/**
* 订单审批类型 {@link cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum}
......
......@@ -202,7 +202,7 @@ public interface OrderApprovalMapper extends AbstractMapper<OrderApprovalDO> {
List<OrderApprovalDO> approvalListBytTypeAndStatus(@Param("orderId") Long orderId, @Param("typeList") List<Integer> typeList, @Param("status") Integer status);
@ResultType(OrderApprovalDO.class)
@ResultType(Long.class)
@Select({
"<script>",
"select",
......@@ -213,12 +213,11 @@ public interface OrderApprovalMapper extends AbstractMapper<OrderApprovalDO> {
"<when test = 'types != null && types.size() > 0'>",
"and a.type in <foreach item='type' index='index' collection='typeList' open='(' separator=',' close=')'>#{type}</foreach> ",
"</when>",
"<when test = 'orderItemId != null'>",
"and (a.order_item_id is null or (a.order_item_id is not null && a.order_item_id = #{orderItemId})) ",
"<when test = 'orderItemIdList != null && orderItemIdList.size() > 0'>",
"and (a.details->>'$.orderItemId' is null or (a.details->>'$.orderItemId' is not null && a.details->>'$.orderItemId' in <foreach item='orderItemId' index='index' collection='orderItemIdList' open='(' separator=',' close=')'>#{orderItemId}</foreach>)) ",
"</when>",
"and a.status = 1 ",
"order by a.order_approval_id desc",
"</script>"
})
long countProcessingApproval(@Param("orderId") Long orderId, @Param("orderItemId") Long orderItemId, @Param("types") List<Integer> types);
long countProcessingApproval(@Param("orderId") Long orderId, @Param("orderItemIdList") List<Long> orderItemIdList, @Param("types") List<Integer> types);
}
......@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseApproval.OrderWarehouseApprovalQueryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
/**
......@@ -69,4 +70,23 @@ public interface OrderWarehouseApprovalMapper extends AbstractMapper<OrderWareho
@Select("select * from ecw_order_warehouse_approval where deleted = 0 and type = #{type} and order_ids = #{orderId} order by id desc limit 1")
OrderWarehouseApprovalDO selectOne(@Param("type") Integer type, @Param("orderId") Long orderId);
@ResultType(Long.class)
@Select({
"<script>",
"select",
" count(1),",
"from ecw_order_warehouse_approval a",
"where ",
"a.order_ids = #{orderId} ",
"<when test = 'types != null && types.size() > 0'>",
"and a.type in <foreach item='type' index='index' collection='typeList' open='(' separator=',' close=')'>#{type}</foreach> ",
"</when>",
"<when test = 'orderItemIdList != null && orderItemIdList.size() > 0'>",
"and (a.order_item_id is null or (a.order_item_id is not null && a.order_item_id in <foreach item='orderItemId' index='index' collection='orderItemIdList' open='(' separator=',' close=')'>#{orderItemId}</foreach>)) ",
"</when>",
"and a.status = 1 ",
"</script>"
})
long countProcessingApproval(@Param("orderId") Long orderId, @Param("orderItemIdList") List<Long> orderItemIdList, @Param("typeList") List<Integer> typeList);
}
......@@ -428,4 +428,5 @@ public interface ErrorCodeConstants {
ErrorCode ORDER_IS_OVERSEAS_WAREHOUSE_ORDER = new ErrorCode(1004001169, "order.is.overseas.warehouse.order");
// 该订单已经是非海外仓订单
ErrorCode ORDER_NOT_IS_OVERSEAS_WAREHOUSE_ORDER = new ErrorCode(1004001170, "order.not.is.overseas.warehouse.order");
ErrorCode ORDER_APPROVAL_IS_NOT_EXISTS = new ErrorCode(1004001171, "order.approval.is.not.exists");
}
......@@ -3,12 +3,14 @@ package cn.iocoder.yudao.module.order.listener;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
import cn.iocoder.yudao.module.order.service.orderWarehouseApproval.OrderWarehouseApprovalService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
......@@ -23,6 +25,7 @@ import java.util.Objects;
public class OrderApprovalTypeCheckListener {
private final OrderApprovalService orderApprovalService;
private final OrderWarehouseApprovalService orderWarehouseApprovalService;
@EventListener(OrderApprovalTypeCheckEvent.class)
public void orderApprovalTypeCheckEvent(OrderApprovalTypeCheckEvent event) {
......@@ -46,9 +49,30 @@ public class OrderApprovalTypeCheckListener {
typeList.add(event.getApprovalType());
}
// 查询当前订单正在进行的审批
boolean result = orderApprovalService.countProcessingApproval(event.getOrderId(), event.getOrderItemIdList(), typeList);
// 入仓相关正在进行的审批业务查询
if (!result){
List<Integer> warehouseApprovalTypeList = null;
if (Objects.nonNull(typeList)){
// 1 入仓修改 2 调仓 3 退仓
warehouseApprovalTypeList = new ArrayList<>();
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_UPDATE.getValue())){
warehouseApprovalTypeList.add(1);
}
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_ADJUST.getValue())){
warehouseApprovalTypeList.add(2);
}
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_ROLLBACK.getValue())){
warehouseApprovalTypeList.add(3);
}
if (warehouseApprovalTypeList.size() == 0){
event.setResult(result);
return;
}
}
result = orderWarehouseApprovalService.countProcessingApproval(event.getOrderId(), event.getOrderItemIdList(), warehouseApprovalTypeList);
}
// TODO 当订单互斥所有审批类型时,是否也要对自编号的审批状态进行校验
boolean result = orderApprovalService.countProcessingApproval(event.getOrderId(), event.getOrderItemId(), typeList);
event.setResult(result);
}
}
......@@ -116,11 +116,11 @@ public interface OrderApprovalService extends IService<OrderApprovalDO> {
/**
* 获取正在处理中的批量审批(批量优惠/批量特价)
* @param orderId 订单id
* @param orderItemId 订单项id
* @param orderItemIdList 订单项id列表
* @param approvalTypes 类型
* @return
*/
boolean countProcessingApproval(Long orderId, Long orderItemId, List<Integer> approvalTypes);
boolean countProcessingApproval(Long orderId, List<Long> orderItemIdList, List<Integer> approvalTypes);
/**
* 获取正在处理中的批量审批(批量优惠/批量特价)
......
......@@ -177,9 +177,9 @@ public class OrderApprovalServiceImpl extends AbstractService<OrderApprovalMappe
}
@Override
public boolean countProcessingApproval(Long orderId, Long orderItemId, List<Integer> types) {
long count = approvalMapper.countProcessingApproval(orderId, orderItemId, types);
return count == 0;
public boolean countProcessingApproval(Long orderId, List<Long> orderItemIdList, List<Integer> types) {
long count = approvalMapper.countProcessingApproval(orderId, orderItemIdList, types);
return count > 0;
}
@Override
......
......@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.dto.OrderDto;
import cn.iocoder.yudao.framework.apollo.core.event.*;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderYeJiTypeEvent;
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.bigDecimal.BigDecimalUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
......@@ -1803,8 +1804,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
return;
}
if (vo.getAuditType() != 0) {
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(vo.getOrderId(), null, ORDER_UPDATE.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
if (vo.getShipmentState() > 0) {
......@@ -1862,6 +1864,11 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
this.updateOrderApply(updateReqVO, memberUserDO);
return;
}
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(vo.getOrderId(), null, ORDER_UPDATE.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
// 获取功能开关
List<DictDataRespDTO> dictList = dictDataApi.getDictDatas("part_function_switch");
// 智慧预装功能开关
......@@ -5050,7 +5057,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.isNull(orderDO)) {
throw exception(ORDER_NOT_EXISTS);
}
if (orderDO.getAuditType() != 0) {
OrderApprovalTypeEnum typeEnum = OrderApprovalTypeEnum.valueOf(specialApplyVO.getApplyType());
if (Objects.isNull(typeEnum)){
throw exception(ORDER_APPROVAL_IS_NOT_EXISTS);
}
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(specialApplyVO.getOrderId(), Objects.nonNull(specialApplyVO.getOrderItemId())?
Collections.singletonList(specialApplyVO.getOrderItemId()) : null, typeEnum.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
int count = orderApprovalMapper.processingItemApproval(specialApplyVO.getOrderItemId(), specialApplyVO.getOrderId(), Arrays.asList(1, 2, 3));
......@@ -5246,7 +5260,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.isNull(orderDO)) {
throw exception(ORDER_NOT_EXISTS);
}
if (orderDO.getAuditType() != 0) {
OrderApprovalTypeEnum typeEnum = OrderApprovalTypeEnum.valueOf(specialBatchApplyVO.getApplyType());
if (Objects.isNull(typeEnum)){
throw exception(ORDER_APPROVAL_IS_NOT_EXISTS);
}
List<Long> orderItemIdList = specialBatchApplyVO.getBatchApplyOrderItemDetailVOList().stream().map(OrderSpecialBatchApplyOrderItemDetailVO::getOrderItemId).filter(Objects::nonNull).collect(Collectors.toList());
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(specialBatchApplyVO.getOrderId(), orderItemIdList, typeEnum.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
int count = orderApprovalMapper.processingItemApproval(null, specialBatchApplyVO.getOrderId(),
......
......@@ -5,6 +5,7 @@ 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.BoxCheckOrdersSchedulingEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.code.CodeUtils;
......@@ -54,6 +55,7 @@ import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInSe
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.OrderApprovalCancelApplyReqVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyOrderItemDetailVO;
import cn.iocoder.yudao.module.order.vo.order.ApplyInfoVO;
import cn.iocoder.yudao.module.order.vo.order.CostVO;
import cn.iocoder.yudao.module.order.vo.order.OrderBackVO;
......@@ -87,6 +89,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.ORDER_SPLIT;
import static cn.iocoder.yudao.module.order.enums.TargetLogEnum.SPLIT;
/**
......@@ -192,7 +195,9 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
if (orderDO.getTransportId() == 4 && OrderStatusEnum.IN_WAREHOUSE.getValue().equals(orderDO.getStatus()) && orderDO.getAirShipment() > 2) {
throw exception(AIR_ORDER_IS_READY_STOCK_NOT_SPLIT);
}
if (orderDO.getAuditType() != 0) {
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, ORDER_SPLIT.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.SPLIT_ORDER.getValue())) {
......@@ -475,7 +480,7 @@ public class OrderSplitServiceImpl extends AbstractService<OrderSplitMapper, Ord
throw exception(ORDER_NOT_EXISTS);
}
// TODO 需要调整异常说明为 -> 订单正在进行拆单审批,无法重置拆单
if (Objects.equals(orderDO.getAuditType(), OrderApprovalTypeEnum.ORDER_SPLIT.getValue())) {
if (Objects.equals(orderDO.getAuditType(), ORDER_SPLIT.getValue())) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
}
// if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.SPLIT_ORDER.getValue())) {
......
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.order.service.orderWarehouseAdjust;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.apollo.core.event.BoxCheckOrderDestWarehouseEvent;
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.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
......@@ -49,6 +50,8 @@ 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.ORDER_SPLIT;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_ADJUST;
/**
* 调仓记录 Service 实现类
......@@ -139,7 +142,9 @@ public class OrderWarehouseAdjustServiceImpl extends AbstractService<OrderWareho
}
orderQueryService.throwPendingExceptionOrProcessingApproval(orderId);
if (orderDO.getAuditType() != 0){
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, WAREHOUSE_ADJUST.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
orderStatusSet.add(orderDO.getStatus());
......
......@@ -167,6 +167,5 @@ public interface OrderWarehouseApprovalService extends IService<OrderWarehouseAp
OrderWarehouseApprovalBackVO getLastUpdateApprovalInfo(Long orderId, Long orderItemId);
boolean countProcessingApproval(Long orderId, List<Long> orderItemIdList, List<Integer> typeList);
}
......@@ -289,4 +289,10 @@ public class OrderWarehouseApprovalServiceImpl extends AbstractService<OrderWare
OrderWarehouseApprovalBackVO convert = OrderWarehouseApprovalConvert.INSTANCE.convert(orderWarehouseApprovalDO);
return convert;
}
@Override
public boolean countProcessingApproval(Long orderId, List<Long> orderItemIdList, List<Integer> typeList) {
long count = orderWarehouseApprovalMapper.countProcessingApproval(orderId, orderItemIdList, typeList);
return count > 0;
}
}
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
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.apollo.core.event.QueryChannelInfoEvent;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
......@@ -132,6 +133,8 @@ 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.wealth.enums.ErrorCodeConstants.RECEIVABLE_WRITE_OFF_ING_NO_NEED_TO_PACK;
/**
......@@ -2766,6 +2769,11 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
}
}
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderId, null, WAREHOUSE_UPDATE.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
//如仓记录项
List<OrderWarehouseInItemDto> orderWarehouseInUpdateItemDoList =
updateReqVO.getOrderWarehouseInUpdateItemDoList();
......
......@@ -37,6 +37,7 @@ import cn.iocoder.yudao.module.order.service.order.OrderBusinessService;
import cn.iocoder.yudao.module.order.service.order.OrderItemService;
import cn.iocoder.yudao.module.order.service.order.OrderQueryService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import cn.iocoder.yudao.module.order.service.orderWarehouseApproval.OrderWarehouseApprovalService;
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.order.*;
......@@ -107,6 +108,8 @@ public class OrderController {
@Autowired
private OrderApprovalService orderApprovalService;
@Autowired
private OrderWarehouseApprovalService orderWarehouseApprovalService;
@Autowired
private RoleApi roleApi;
@Autowired
private OrderItemService orderItemService;
......@@ -857,14 +860,14 @@ public class OrderController {
}
@GetMapping("/getDestCountryByOrderId")
@ApiOperation("根据订单ID查询目的国")
@GetMapping("/approvalTypeCheck")
@ApiOperation("校验订单审批是否存在互斥类型:是 或 否 ")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", required = true, example = "1024", dataTypeClass = Long.class),
@ApiImplicitParam(name = "orderItemId", value = "订单项id", required = true, example = "1024", dataTypeClass = Long.class),
@ApiImplicitParam(name = "approvalType", value = "审批类型", required = true, example = "1024", dataTypeClass = Integer.class)
@ApiImplicitParam(name = "orderItemIdList", value = "订单项id列表(针对品名的审批需要传此参数)", required = false, example = "1024", dataTypeClass = List.class),
@ApiImplicitParam(name = "approvalType", value = "审批类型:见字典表", required = true, example = "1024", dataTypeClass = Integer.class)
})
public CommonResult<Boolean> getDestCountryByOrderId(Long orderId, Long orderItemId, Integer approvalType) {
public CommonResult<Boolean> getDestCountryByOrderId(Long orderId, List<Long> orderItemIdList, Integer approvalType) {
OrderApprovalTypeEnum approvalTypeEnum = OrderApprovalTypeEnum.valueOf(approvalType);
if (Objects.isNull(approvalTypeEnum)){
// 没有配置相关审批类型则不做校验
......@@ -883,7 +886,28 @@ public class OrderController {
typeList.add(approvalType);
}
// 查询当前订单正在进行的审批
boolean result = orderApprovalService.countProcessingApproval(orderId, orderItemId, typeList);
boolean result = orderApprovalService.countProcessingApproval(orderId, orderItemIdList, typeList);
// 入仓相关正在进行的审批业务查询
if (!result){
List<Integer> warehouseApprovalTypeList = null;
if (Objects.nonNull(typeList)){
// 1 入仓修改 2 调仓 3 退仓
warehouseApprovalTypeList = new ArrayList<>();
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_UPDATE.getValue())){
warehouseApprovalTypeList.add(1);
}
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_ADJUST.getValue())){
warehouseApprovalTypeList.add(2);
}
if (typeList.contains(OrderApprovalTypeEnum.WAREHOUSE_ROLLBACK.getValue())){
warehouseApprovalTypeList.add(3);
}
if (warehouseApprovalTypeList.size() == 0){
return success(result);
}
}
result = orderWarehouseApprovalService.countProcessingApproval(orderId, orderItemIdList, warehouseApprovalTypeList);
}
// TODO 当订单互斥所有审批类型时,是否也要对自编号的审批状态进行校验
return success(result);
}
......
......@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigne
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderSplitItem.OrderSplitItemDO;
import cn.iocoder.yudao.module.order.enums.OrderAirTimeEnum;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum;
import cn.iocoder.yudao.module.order.enums.OrderSeaTimeEnum;
import cn.iocoder.yudao.module.order.enums.TargetLogEnum;
import cn.iocoder.yudao.module.order.vo.order.OrderBackPageVO;
......@@ -693,7 +694,7 @@ public interface BoxService extends IService<BoxDO> {
void splitWorthConsistencyCheck(List<OrderSplitItemDO> orderAllSplitItemDOList, BigDecimal worth);
void checkOrdersApprovaling(Long shipmentId);
void checkOrdersApprovaling(Long shipmentId, OrderApprovalTypeEnum approvalTypeEnum);
void splitUsed(Long spiltId);
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
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.common.util.code.CodeUtils;
......@@ -206,6 +207,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
......@@ -222,7 +224,9 @@ import java.util.*;
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.ORDER_IS_APPROVAL_IN_PROCESS;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_LINE_CHANNEL_NOT_NULL;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.WAREHOUSE_ADJUST;
import static cn.iocoder.yudao.module.shipment.enums.BoxAirStatusEnum.TO_WAREHOUSED;
import static cn.iocoder.yudao.module.shipment.enums.BoxStatusEnum.UNLOADED;
import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.*;
......@@ -393,6 +397,9 @@ public class BoxServiceImpl extends AbstractService<BoxMapper, BoxDO> implements
@Resource
private BoxBookAirService boxBookAirService;
@Resource
private ApplicationContext applicationContext;
private static final Long NIGERIA = 4174L;
private static Map<String, Integer> minNumMap = new HashMap<>();
......@@ -4653,19 +4660,22 @@ public class BoxServiceImpl extends AbstractService<BoxMapper, BoxDO> implements
}
@Override
public void checkOrdersApprovaling(Long shipmentId) {
public void checkOrdersApprovaling(Long shipmentId, OrderApprovalTypeEnum orderApprovalTypeEnum) {
Set<Long> orderIdSet = boxPreloadGoodsService.getShipOrderIdList(shipmentId);
if (CollectionUtil.isEmpty(orderIdSet)) return;
List<OrderDO> orderDOList = orderQueryService.getOrderList(orderIdSet);
List<String> orderNoList = new ArrayList<>();
orderDOList = orderDOList.stream()
.filter(t -> t.getAuditType() != 0)
.collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(orderDOList)) {
// throw new ServiceException(500, "出货有订单在审核中");
if (CollectionUtil.isNotEmpty(orderDOList)) {
List<String> orderNoList = orderDOList.stream()
.map(OrderDO::getOrderNo)
.collect(Collectors.toList());
for (OrderDO orderDO : orderDOList) {
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(orderDO.getOrderId(), null, orderApprovalTypeEnum.getValue(), false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
orderNoList.add(orderDO.getOrderNo());
}
}
if (CollectionUtil.isNotEmpty(orderNoList) && orderNoList.size() > 0) {
String orderNoStrs = Joiner.on(",").join(orderNoList);
throw new ServiceException(500, "出货有订单(" + orderNoStrs + ")在审核中");
}
......
......@@ -63,6 +63,8 @@ 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.pre_install;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.sorting;
import static cn.iocoder.yudao.module.order.enums.TargetLogEnum.LOADING;
import static cn.iocoder.yudao.module.order.enums.TargetLogEnum.WITHDRAWAL;
import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.*;
......@@ -107,8 +109,7 @@ public class BoxApprovalServiceImpl extends AbstractService<BoxApprovalMapper, B
// checkApproval(createReqVO.getShipmentId(), approvalType);
//同时只能有一个在审核中
checkApproval(createReqVO.getShipmentId(), null);
//校验订单是否有在审核中的
boxService.checkOrdersApprovaling(createReqVO.getShipmentId());
BoxApprovalDO boxApproval = BoxApprovalConvert.INSTANCE.convert(createReqVO);
boxApproval.setApprovalStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
......@@ -123,6 +124,8 @@ public class BoxApprovalServiceImpl extends AbstractService<BoxApprovalMapper, B
//----------------------------------------预装---------------------------------------
if (createReqVO.getApprovalType() ==
BoxApprovalTypeEnum.PRELOAD.getType()) {
//校验订单是否有在审核中的
boxService.checkOrdersApprovaling(createReqVO.getShipmentId(), pre_install);
//检查是否有预装订单
boxService.checkPreInstallNum(shipmentId);
......@@ -486,7 +489,8 @@ public class BoxApprovalServiceImpl extends AbstractService<BoxApprovalMapper, B
else if (createReqVO.getApprovalType() == BoxApprovalTypeEnum.AIR_SORTING.getType()) {
//检查是否有分拣订单
boxService.checkPreInstallNum(shipmentId);
//校验订单是否有在审核中的
boxService.checkOrdersApprovaling(createReqVO.getShipmentId(), sorting);
//分拣
flowKey = WorkFlowEmus.SHIPMENT_ORDER_SORTING.getKey();
StStatusEnum stStatusEnum = StStatusEnum.SORTING_APPROVAL_ING;
......
......@@ -304,4 +304,6 @@ order.not.is.overseas.warehouse.order=
area.code.not.null=
currency.id.not.null=
\ No newline at end of file
currency.id.not.null=
order.approval.is.not.exists=
\ No newline at end of file
......@@ -1118,4 +1118,6 @@ order.not.is.overseas.warehouse.order=This order is already a non overseas wareh
area.code.not.null=The national mobile phone area code cannot be empty
currency.id.not.null=The country ID cannot be empty
\ No newline at end of file
currency.id.not.null=The country ID cannot be empty
order.approval.is.not.exists=Order approval type does not exist
\ No newline at end of file
......@@ -1118,4 +1118,6 @@ order.not.is.overseas.warehouse.order=\u8be5\u8ba2\u5355\u5df2\u7ecf\u662f\u975e
area.code.not.null=\u56fd\u5bb6\u624b\u673a\u533a\u53f7\u4e0d\u80fd\u4e3a\u7a7a
currency.id.not.null=\u56fd\u5bb6id\u4e0d\u80fd\u4e3a\u7a7a
\ No newline at end of file
currency.id.not.null=\u56fd\u5bb6id\u4e0d\u80fd\u4e3a\u7a7a
order.approval.is.not.exists=\u8ba2\u5355\u5ba1\u6279\u7c7b\u578b\u4e0d\u5b58\u5728
\ No newline at end of file
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