paascloud/paascloud-master · error · OmcBizException

OMC10031005

OMC10031005

Error message

OMC10031005

What it means

OmcBizException with ErrorCodeEnum.OMC10031005 means 'order not found' (找不到订单信息, orderNo=%s). queryOrderDtoByOrderNo first resolves the OmcOrder entity by orderNo; when no row exists it aborts with this business exception instead of returning null, so callers never receive a half-populated DTO.

Solutions

  1. Verify the orderNo exists in the omc_order table with SELECT * FROM omc_order WHERE order_no = ? against the same DB the provider is wired to
  2. Confirm the client is pointing at the correct environment/config (registry, datasource) before retrying
  3. Catch OmcBizException and return a friendly 'order not found' response to the caller instead of letting it bubble up

Example fix

// before
OrderDto dto = omcOrderService.queryOrderDtoByOrderNo("2021090112345");
// after
OrderDto dto;
try {
    dto = omcOrderService.queryOrderDtoByOrderNo(orderNo);
} catch (OmcBizException e) {
    log.warn("order not found: {}", orderNo);
    dto = null; // or return error response
}
Defensive patterns

Strategy: try-catch

Validate before calling

OmcOrder check = omcOrderMapper.selectByOrderNo(orderNo);
if (check == null) { throw new OrderNotFoundException(orderNo); }

Type guard

boolean orderExists(String orderNo) {
    return omcOrderMapper.selectByOrderNo(orderNo) != null;
}

Try / catch

try {
    OrderDto dto = omcOrderService.queryOrderDtoByOrderNo(orderNo);
} catch (OmcBizException e) {
    if (e.getCode() == 10031005) { /* handle order-not-found */ }
    else throw e;
}

Prevention

When it happens

Trigger: Calling queryOrderDtoByOrderNo(orderNo) with an orderNo that has no matching row in the omc_order table (typo, wrong environment/database, order soft-deleted, or order created in another service/shard).

Common situations: Developers passing an orderNo from a different DB environment (dev vs prod), querying an order that was cleaned up by retention jobs, or copying an order number from a payment gateway whose numbering differs.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/284ef8594fd6f23c. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java:179

	public OmcOrder queryByOrderNo(String orderNo) {
		Preconditions.checkArgument(StringUtils.isNotEmpty(orderNo), "订单号不能为空");

		return omcOrderMapper.selectByOrderNo(orderNo);
	}

	@Override
	public OmcOrder queryByUserIdAndOrderNo(Long userId, String orderNo) {
		Preconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());
		Preconditions.checkArgument(StringUtils.isNotEmpty(orderNo), "订单号不能为空");

		return omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);
	}

	@Override
	public OrderDto queryOrderDtoByOrderNo(String orderNo) {
		OmcOrder omcOrder = this.queryByOrderNo(orderNo);
		if (omcOrder == null) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
		}
		ModelMapper modelMapper = new ModelMapper();
		return modelMapper.map(omcOrder, OrderDto.class);
	}

	@Override
	public OrderDto queryOrderDtoByUserIdAndOrderNo(Long userId, String orderNo) {
		OmcOrder omcOrder = this.queryByUserIdAndOrderNo(userId, orderNo);
		if (omcOrder == null) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
		}
		ModelMapper modelMapper = new ModelMapper();
		return modelMapper.map(omcOrder, OrderDto.class);
	}

	private BigDecimal getOrderTotalPrice(List<OmcOrderDetail> orderItemList) {
		BigDecimal payment = new BigDecimal("0");
		for (OmcOrderDetail orderItem : orderItemList) {

View on GitHub (pinned to 781281a950)