paascloud/paascloud-master · error · OmcBizException
OMC10031003
OMC10031003
Error message
OMC10031003
What it means
OmcBizException with ErrorCodeEnum.OMC10031003 (code 10031003, message "该用户此订单不存在" / this order does not exist for this user). Thrown by cancelOrderDoc when omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo) finds no order for the given user/orderNo pair, before any cancellation is attempted.
Solutions
- Confirm the orderNo is correct and belongs to the authenticated userId (query orders by userId and check).
- Query the order first (e.g. via queryByOrderNo or a pay-status endpoint) before cancelling.
- Check whether the order was already cancelled/deleted by another flow.
- Fix client-side order state so it only offers cancellation for orders owned by the current user.
Example fix
// before
orderService.cancelOrderDoc(loginAuthDto, orderNo); // orderNo may belong to another user
// after
OmcOrder order = orderService.queryByUserIdAndOrderNo(loginAuthDto.getUserId(), orderNo);
if (order == null) {
throw new IllegalArgumentException("order " + orderNo + " not found for user");
}
orderService.cancelOrderDoc(loginAuthDto, orderNo); Defensive patterns
Strategy: validation
Validate before calling
OmcOrder order = orderService.queryByUserIdAndOrderNo(userId, orderNo);
if (order == null) {
throw new IllegalArgumentException("order " + orderNo + " not found for user " + userId);
} Try / catch
try {
orderService.cancelOrderDoc(loginAuthDto, orderNo);
} catch (OmcBizException e) {
if (e.getCode() == 10031003) {
// order does not exist for this user: surface 'order not found'
} else { throw e; }
} Prevention
- Only allow cancellation of orders listed under the current user's order history.
- Validate orderNo format before sending it to the API.
- Reload the user's order list instead of reusing stale order numbers.
- Check whether an order was already cancelled/deleted by another flow.
When it happens
Trigger: Calling cancelOrderDoc with an orderNo that does not exist; the order exists but belongs to a different userId (lookup is scoped by both userId and orderNo); typo'd or truncated order number.
Common situations: Client retrying cancellation after the order was already deleted; passing an orderNo from another account; stale order number stored in frontend after order cleanup jobs run.
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/4df41ca446e51c98.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java:131
omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);
//生成成功,我们要减少我们产品的库存
this.reduceProductStock(omcOrderDetailList);
//清空一下购物车
this.cleanCart(cartList);
//返回给前端数据
return assembleOrderVo(order, omcOrderDetailList);
}
@Override
public int cancelOrderDoc(LoginAuthDto loginAuthDto, String orderNo) {
Long userId = loginAuthDto.getUserId();
OmcOrder order = omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);
if (order == null) {
logger.error("该用户此订单不存在, userId={}, orderNo={}", userId, orderNo);
throw new OmcBizException(ErrorCodeEnum.OMC10031003);
}
if (order.getStatus() != OmcApiConstant.OrderStatusEnum.NO_PAY.getCode()) {
throw new OmcBizException(ErrorCodeEnum.OMC10031004);
}
OmcOrder updateOrder = new OmcOrder();
updateOrder.setId(order.getId());
updateOrder.setStatus(OmcApiConstant.OrderStatusEnum.CANCELED.getCode());
return omcOrderMapper.updateByPrimaryKeySelective(updateOrder);
}
@Override
public PageInfo queryUserOrderListWithPage(Long userId, BaseQuery baseQuery) {
PageHelper.startPage(baseQuery.getPageNum(), baseQuery.getPageSize());
List<OmcOrder> orderList = omcOrderMapper.selectByUserId(userId);
List<OrderVo> orderVoList = assembleOrderVoList(orderList, userId);
return new PageInfo<>(orderVoList);
}View on GitHub (pinned to 781281a950)