paascloud/paascloud-master · error · OmcBizException
OMC10031003
OMC10031003
Error message
OMC10031003
What it means
ErrorCodeEnum.OMC10031003 ('this order does not exist for this user', 该用户此订单不存在) is thrown by PtcAlipayServiceImpl.pay when omcOrderService.queryOrderDtoByUserIdAndOrderNo(userId, orderNo) yields no order for that user/orderNo pair, so an Alipay payment cannot be initiated. Note the underlying lookup may itself throw OMC10031005; this check guards the null-return path.
Solutions
- Confirm the order exists for that user: SELECT * FROM omc_order WHERE order_no = ? AND user_id = ?
- Ensure the frontend passes the currently authenticated userId (fresh LoginAuthDto), not a cached session
- Wrap pay() in a handler that converts OmcBizException into a user-facing 'order not found' message and redirects back to the order list
Example fix
// before
public Wrapper pay(String orderNo, LoginAuthDto loginAuthDto) {
OrderDto order = omcOrderService.queryOrderDtoByUserIdAndOrderNo(loginAuthDto.getUserId(), orderNo);
if (order == null) {
throw new OmcBizException(ErrorCodeEnum.OMC10031003);
}
// after
public Wrapper pay(String orderNo, LoginAuthDto loginAuthDto) {
OrderDto order;
try {
order = omcOrderService.queryOrderDtoByUserIdAndOrderNo(loginAuthDto.getUserId(), orderNo);
} catch (OmcBizException e) {
return Wrapper.fail(404, "订单不存在");
}
if (order == null) {
return Wrapper.fail(404, "订单不存在");
} Defensive patterns
Strategy: try-catch
Validate before calling
OrderDto order = omcOrderMapper.selectByUserIdAndOrderNo(loginAuthDto.getUserId(), orderNo);
if (order == null) { return Wrapper.fail(404, "order not found"); } Type guard
boolean userCanPay(Long userId, String orderNo) {
return omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo) != null;
} Try / catch
try {
alipayService.pay(orderNo, loginAuthDto);
} catch (OmcBizException e) {
if (e.getCode() == 10031003 || e.getCode() == 10031005) {
return Wrapper.fail(404, "订单不存在");
}
throw e;
} Prevention
- Always use the fresh LoginAuthDto userId for payment flows
- Block payment entry points for orders that are cancelled or deleted
- Catch both OMC10031003 and OMC10031005 in payment handlers
When it happens
Trigger: Calling pay(orderNo, loginAuthDto) with an orderNo that doesn't exist for the authenticated user — e.g. wrong login token, order belonging to someone else, or the order row missing from the DB.
Common situations: Payment page opened from a bookmark with an old orderNo after re-login as another account, orders created in a different environment, or race where the order was cancelled/deleted before payment.
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/ea8f513fc9d27842.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java:108
@Value("${paascloud.alipay.qrCode.pcPath}")
private String qrCodePcPath;
@Value("${paascloud.alipay.qrCode.qiniuPath}")
private String qrCodeQiniuPath;
/**
* Pay wrapper.
*
* @param orderNo the order no
* @param loginAuthDto the login auth dto
*
* @return the wrapper
*/
@Override
public Wrapper pay(String orderNo, LoginAuthDto loginAuthDto) {
Long userId = loginAuthDto.getUserId();
OrderDto order = omcOrderService.queryOrderDtoByUserIdAndOrderNo(userId, orderNo);
if (order == null) {
throw new OmcBizException(ErrorCodeEnum.OMC10031003);
}
// (必填) 商户网站订单系统中唯一订单号, 64个字符以内, 只能包含字母、数字、下划线,
// 需保证商户系统端不能重复, 建议通过数据库sequence生成,
String outTradeNo = order.getOrderNo();
// (必填) 订单标题, 粗略描述用户的支付目的。如“xxx品牌xxx门店当面付扫码消费”
String subject = "PCMall扫码支付,订单号:" + outTradeNo;
// (必填) 订单总金额, 单位为元, 不能超过1亿元
// 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】
String totalAmount = order.getPayment().toString();
// (可选) 订单不可打折金额, 可以配合商家平台配置折扣活动, 如果酒水不参与打折, 则将对应金额填写至此字段
// 如果该值未传入,但传入了【订单总金额】,【打折金额】,则该值默认为【订单总金额】-【打折金额】View on GitHub (pinned to 781281a950)