Commit 9a1b39fb authored by 332784038@qq.com's avatar 332784038@qq.com

校验订单审批业务互斥逻辑业务提供前端校验接口

parent 53b1aa90
......@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
......@@ -37,15 +38,16 @@ public class OrderApprovalTypeCheckListener {
event.setResult(Boolean.FALSE);
return;
}
if (types.contains(-1)){
// 包含负一则表示订单不能有任何审批状态存在
types = null;
}else {
types.add(event.getApprovalType());
// 枚举配置中的互斥类型集合不能添加新值,这里需要重新定义新集合补充当前审批类型进行查询
List<Integer> typeList = null;
// 包含-1则表示订单不能有任何审批状态存在,所以不用区分类型,查询所有的进行中审批
if (!types.contains(-1)){
typeList = new ArrayList<>(types);
typeList.add(event.getApprovalType());
}
// 查询当前订单正在进行的审批
// TODO 当订单互斥所有审批类型时,是否也要对自编号的审批状态进行校验
boolean result = orderApprovalService.countProcessingApproval(event.getOrderId(), event.getOrderItemId(), types);
boolean result = orderApprovalService.countProcessingApproval(event.getOrderId(), event.getOrderItemId(), typeList);
event.setResult(result);
}
......
......@@ -29,8 +29,10 @@ import cn.iocoder.yudao.module.order.convert.order.OrderConvert;
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.enums.OrderTempLateEnum;
import cn.iocoder.yudao.module.order.enums.TransportTypeShortEnum;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
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;
......@@ -103,6 +105,8 @@ public class OrderController {
@Autowired
private OrderQueryService orderQueryService;
@Autowired
private OrderApprovalService orderApprovalService;
@Autowired
private RoleApi roleApi;
@Autowired
private OrderItemService orderItemService;
......@@ -829,6 +833,7 @@ public class OrderController {
@GetMapping("/getDestCountryByOrderId")
@ApiOperation("根据订单ID查询目的国")
@ApiImplicitParam(name = "orderId", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<String> getDestCountryByOrderId(Long orderId) {
return success(orderQueryService.getDestCountryByOrderId(orderId));
}
......@@ -852,4 +857,36 @@ public class OrderController {
}
@GetMapping("/getDestCountryByOrderId")
@ApiOperation("根据订单ID查询目的国")
@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)
})
public CommonResult<Boolean> getDestCountryByOrderId(Long orderId, Long orderItemId, Integer approvalType) {
OrderApprovalTypeEnum approvalTypeEnum = OrderApprovalTypeEnum.valueOf(approvalType);
if (Objects.isNull(approvalTypeEnum)){
// 没有配置相关审批类型则不做校验
return success(Boolean.FALSE);
}
List<Integer> types = approvalTypeEnum.getMutualExclusionValues();
if (Objects.isNull(types)){
// 没有配置相关审批类型则不做校验
return success(Boolean.FALSE);
}
// 枚举配置中的互斥类型集合不能添加新值,这里需要重新定义新集合补充当前审批类型进行查询
List<Integer> typeList = null;
// 包含-1则表示订单不能有任何审批状态存在,所以不用区分类型,查询所有的进行中审批
if (!types.contains(-1)){
typeList = new ArrayList<>(types);
typeList.add(approvalType);
}
// 查询当前订单正在进行的审批
boolean result = orderApprovalService.countProcessingApproval(orderId, orderItemId, typeList);
// TODO 当订单互斥所有审批类型时,是否也要对自编号的审批状态进行校验
return success(result);
}
}
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