{"record":{"id":"4df41ca446e51c98","repo":"paascloud/paascloud-master","slug":"omc10031003","errorCode":"OMC10031003","errorMessage":"OMC10031003","messagePattern":"OMC10031003","errorType":"error_code","errorClass":"OmcBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java","lineNumber":131,"sourceCode":"\t\tomcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);\n\n\t\t//生成成功,我们要减少我们产品的库存\n\t\tthis.reduceProductStock(omcOrderDetailList);\n\t\t//清空一下购物车\n\t\tthis.cleanCart(cartList);\n\n\t\t//返回给前端数据\n\n\t\treturn assembleOrderVo(order, omcOrderDetailList);\n\t}\n\n\t@Override\n\tpublic int cancelOrderDoc(LoginAuthDto loginAuthDto, String orderNo) {\n\t\tLong userId = loginAuthDto.getUserId();\n\t\tOmcOrder order = omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);\n\t\tif (order == null) {\n\t\t\tlogger.error(\"该用户此订单不存在, userId={}, orderNo={}\", userId, orderNo);\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031003);\n\t\t}\n\t\tif (order.getStatus() != OmcApiConstant.OrderStatusEnum.NO_PAY.getCode()) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031004);\n\t\t}\n\t\tOmcOrder updateOrder = new OmcOrder();\n\t\tupdateOrder.setId(order.getId());\n\t\tupdateOrder.setStatus(OmcApiConstant.OrderStatusEnum.CANCELED.getCode());\n\n\t\treturn omcOrderMapper.updateByPrimaryKeySelective(updateOrder);\n\t}\n\n\t@Override\n\tpublic PageInfo queryUserOrderListWithPage(Long userId, BaseQuery baseQuery) {\n\t\tPageHelper.startPage(baseQuery.getPageNum(), baseQuery.getPageSize());\n\t\tList<OmcOrder> orderList = omcOrderMapper.selectByUserId(userId);\n\t\tList<OrderVo> orderVoList = assembleOrderVoList(orderList, userId);\n\t\treturn new PageInfo<>(orderVoList);\n\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java#L113-L149","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\norderService.cancelOrderDoc(loginAuthDto, orderNo); // orderNo may belong to another user\n// after\nOmcOrder order = orderService.queryByUserIdAndOrderNo(loginAuthDto.getUserId(), orderNo);\nif (order == null) {\n    throw new IllegalArgumentException(\"order \" + orderNo + \" not found for user\");\n}\norderService.cancelOrderDoc(loginAuthDto, orderNo);","handlingStrategy":"validation","validationCode":"OmcOrder order = orderService.queryByUserIdAndOrderNo(userId, orderNo);\nif (order == null) {\n    throw new IllegalArgumentException(\"order \" + orderNo + \" not found for user \" + userId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    orderService.cancelOrderDoc(loginAuthDto, orderNo);\n} catch (OmcBizException e) {\n    if (e.getCode() == 10031003) {\n        // order does not exist for this user: surface 'order not found'\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["order","cancel","not-found","business-exception"],"backgroundTag":"record-not-found","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}