{"record":{"id":"284ef8594fd6f23c","repo":"paascloud/paascloud-master","slug":"omc10031005","errorCode":"OMC10031005","errorMessage":"OMC10031005","messagePattern":"OMC10031005","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":179,"sourceCode":"\tpublic OmcOrder queryByOrderNo(String orderNo) {\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(orderNo), \"订单号不能为空\");\n\n\t\treturn omcOrderMapper.selectByOrderNo(orderNo);\n\t}\n\n\t@Override\n\tpublic OmcOrder queryByUserIdAndOrderNo(Long userId, String orderNo) {\n\t\tPreconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(orderNo), \"订单号不能为空\");\n\n\t\treturn omcOrderMapper.selectByUserIdAndOrderNo(userId, orderNo);\n\t}\n\n\t@Override\n\tpublic OrderDto queryOrderDtoByOrderNo(String orderNo) {\n\t\tOmcOrder omcOrder = this.queryByOrderNo(orderNo);\n\t\tif (omcOrder == null) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);\n\t\t}\n\t\tModelMapper modelMapper = new ModelMapper();\n\t\treturn modelMapper.map(omcOrder, OrderDto.class);\n\t}\n\n\t@Override\n\tpublic OrderDto queryOrderDtoByUserIdAndOrderNo(Long userId, String orderNo) {\n\t\tOmcOrder omcOrder = this.queryByUserIdAndOrderNo(userId, orderNo);\n\t\tif (omcOrder == null) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);\n\t\t}\n\t\tModelMapper modelMapper = new ModelMapper();\n\t\treturn modelMapper.map(omcOrder, OrderDto.class);\n\t}\n\n\tprivate BigDecimal getOrderTotalPrice(List<OmcOrderDetail> orderItemList) {\n\t\tBigDecimal payment = new BigDecimal(\"0\");\n\t\tfor (OmcOrderDetail orderItem : orderItemList) {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java#L161-L197","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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","Confirm the client is pointing at the correct environment/config (registry, datasource) before retrying","Catch OmcBizException and return a friendly 'order not found' response to the caller instead of letting it bubble up"],"exampleFix":"// before\nOrderDto dto = omcOrderService.queryOrderDtoByOrderNo(\"2021090112345\");\n// after\nOrderDto dto;\ntry {\n    dto = omcOrderService.queryOrderDtoByOrderNo(orderNo);\n} catch (OmcBizException e) {\n    log.warn(\"order not found: {}\", orderNo);\n    dto = null; // or return error response\n}","handlingStrategy":"try-catch","validationCode":"OmcOrder check = omcOrderMapper.selectByOrderNo(orderNo);\nif (check == null) { throw new OrderNotFoundException(orderNo); }","typeGuard":"boolean orderExists(String orderNo) {\n    return omcOrderMapper.selectByOrderNo(orderNo) != null;\n}","tryCatchPattern":"try {\n    OrderDto dto = omcOrderService.queryOrderDtoByOrderNo(orderNo);\n} catch (OmcBizException e) {\n    if (e.getCode() == 10031005) { /* handle order-not-found */ }\n    else throw e;\n}","preventionTips":["Validate the orderNo against the DB before calling the service","Verify datasource/registry config points at the environment where the order was created","Treat order numbers as user input; never trust them from URLs without validation","Log orderNo and userId on lookup failures for fast triage"],"tags":["order-not-found","business-exception","database"],"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"}