paascloud/paascloud-master · error · OmcBizException

OMC10031010

OMC10031010

Error message

OMC10031010

What it means

OmcBizException with code OMC10031010 thrown by aliPayCallback when the Alipay async notification references an order that does not exist in the OMC order store. The callback parses out_trade_no from Alipay's params and loads the order via omcOrderService.queryOrderDtoByOrderNo; a null result means the payment callback cannot be reconciled to any local order, so processing is aborted to avoid crediting a phantom order.

Solutions

  1. Verify the order exists for the out_trade_no in the receiving DB: query the order table by that orderNo
  2. Confirm the Alipay notify_url points to the same environment/database where orders are created
  3. Check that order creation persists the orderNo before redirecting the user to Alipay (race: callback arrives before insert commits)
  4. If replaying historical notifications, re-create or re-import the missing order record first

Example fix

// before
OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
if (order == null) {
    throw new OmcBizException(ErrorCodeEnum.OMC10031010);
}
// after
OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
if (order == null) {
    log.error("aliPayCallback - unknown orderNo={}, verify env and notify_url", orderNo);
    return "fail"; // let Alipay retry only if the order should exist; ack otherwise
}
Defensive patterns

Strategy: validation

Validate before calling

OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
if (order == null) {
    log.error("Alipay callback for unknown orderNo={}; not processing", orderNo);
    return "fail";
}
if (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {
    return "success";
}

Type guard

if (orderNo == null || orderNo.isEmpty()) { return "fail"; }

Try / catch

try { aliPayCallback(params); } catch (OmcBizException e) { log.error("callback rejected: {}", e.getMessage()); return "fail"; }

Prevention

When it happens

Trigger: Alipay sends a trade_status notify whose out_trade_no has no matching row in the order table: the order was never created locally, was created in a different environment/database than the one receiving callbacks, the orderNo was corrupted before submit, or the order data was deleted before payment completed.

Common situations: Split environments where the sandbox callback hits the production DB (or vice versa); callbacks for orders created before a database migration/cleanup; manual replay of old Alipay notifications from the merchant console; a bug sending a wrong out_trade_no during order creation.

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/0d5f4c60f255b2f2. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java:256

		if (response != null) {
			log.info(String.format("code:%s, msg:%s", response.getCode(), response.getMsg()));
			if (StringUtils.isNotEmpty(response.getSubCode())) {
				log.info(String.format("subCode:%s, subMsg:%s", response.getSubCode(),
						response.getSubMsg()));
			}
			log.info("body:" + response.getBody());
		}
	}

	@Override
	public Wrapper aliPayCallback(Map<String, String> params) {
		log.info("支付宝回调. - aliPayCallback. params={}", params);
		String orderNo = params.get("out_trade_no");
		String tradeNo = params.get("trade_no");
		String tradeStatus = params.get("trade_status");
		OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
		if (order == null) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031010);
		}
		if (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031011);
		}
		if (PtcApiConstant.AlipayCallback.TRADE_STATUS_TRADE_SUCCESS.equals(tradeStatus)) {
			order.setPaymentTime(DateUtil.parseDate(params.get("gmt_payment")));
			order.setStatus(OmcApiConstant.OrderStatusEnum.PAID.getCode());
			ModelMapper modelMapper = new ModelMapper();
			OmcOrder omcOrder = modelMapper.map(order, OmcOrder.class);
			omcOrderService.update(omcOrder);
		}

		PtcPayInfo payInfo = new PtcPayInfo();
		payInfo.setUserId(order.getUserId());
		payInfo.setOrderNo(order.getOrderNo());
		payInfo.setPayPlatform(PtcApiConstant.PayPlatformEnum.ALIPAY.getCode());
		payInfo.setPlatformNumber(tradeNo);
		payInfo.setPlatformStatus(tradeStatus);

View on GitHub (pinned to 781281a950)