{"record":{"id":"0d5f4c60f255b2f2","repo":"paascloud/paascloud-master","slug":"omc10031010","errorCode":"OMC10031010","errorMessage":"OMC10031010","messagePattern":"OMC10031010","errorType":"error_code","errorClass":"OmcBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java","lineNumber":256,"sourceCode":"\t\tif (response != null) {\n\t\t\tlog.info(String.format(\"code:%s, msg:%s\", response.getCode(), response.getMsg()));\n\t\t\tif (StringUtils.isNotEmpty(response.getSubCode())) {\n\t\t\t\tlog.info(String.format(\"subCode:%s, subMsg:%s\", response.getSubCode(),\n\t\t\t\t\t\tresponse.getSubMsg()));\n\t\t\t}\n\t\t\tlog.info(\"body:\" + response.getBody());\n\t\t}\n\t}\n\n\t@Override\n\tpublic Wrapper aliPayCallback(Map<String, String> params) {\n\t\tlog.info(\"支付宝回调. - aliPayCallback. params={}\", params);\n\t\tString orderNo = params.get(\"out_trade_no\");\n\t\tString tradeNo = params.get(\"trade_no\");\n\t\tString tradeStatus = params.get(\"trade_status\");\n\t\tOrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);\n\t\tif (order == null) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031010);\n\t\t}\n\t\tif (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031011);\n\t\t}\n\t\tif (PtcApiConstant.AlipayCallback.TRADE_STATUS_TRADE_SUCCESS.equals(tradeStatus)) {\n\t\t\torder.setPaymentTime(DateUtil.parseDate(params.get(\"gmt_payment\")));\n\t\t\torder.setStatus(OmcApiConstant.OrderStatusEnum.PAID.getCode());\n\t\t\tModelMapper modelMapper = new ModelMapper();\n\t\t\tOmcOrder omcOrder = modelMapper.map(order, OmcOrder.class);\n\t\t\tomcOrderService.update(omcOrder);\n\t\t}\n\n\t\tPtcPayInfo payInfo = new PtcPayInfo();\n\t\tpayInfo.setUserId(order.getUserId());\n\t\tpayInfo.setOrderNo(order.getOrderNo());\n\t\tpayInfo.setPayPlatform(PtcApiConstant.PayPlatformEnum.ALIPAY.getCode());\n\t\tpayInfo.setPlatformNumber(tradeNo);\n\t\tpayInfo.setPlatformStatus(tradeStatus);","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java#L238-L274","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the order exists for the out_trade_no in the receiving DB: query the order table by that orderNo","Confirm the Alipay notify_url points to the same environment/database where orders are created","Check that order creation persists the orderNo before redirecting the user to Alipay (race: callback arrives before insert commits)","If replaying historical notifications, re-create or re-import the missing order record first"],"exampleFix":"// before\nOrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);\nif (order == null) {\n    throw new OmcBizException(ErrorCodeEnum.OMC10031010);\n}\n// after\nOrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);\nif (order == null) {\n    log.error(\"aliPayCallback - unknown orderNo={}, verify env and notify_url\", orderNo);\n    return \"fail\"; // let Alipay retry only if the order should exist; ack otherwise\n}","handlingStrategy":"validation","validationCode":"OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);\nif (order == null) {\n    log.error(\"Alipay callback for unknown orderNo={}; not processing\", orderNo);\n    return \"fail\";\n}\nif (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {\n    return \"success\";\n}","typeGuard":"if (orderNo == null || orderNo.isEmpty()) { return \"fail\"; }","tryCatchPattern":"try { aliPayCallback(params); } catch (OmcBizException e) { log.error(\"callback rejected: {}\", e.getMessage()); return \"fail\"; }","preventionTips":["Persist the order before redirecting to Alipay so callbacks always find it","Point notify_url at the same environment as order creation","Monitor unknown-orderNo callbacks as a data-integrity signal","Include environment-specific order number prefixes to catch cross-env callbacks"],"tags":["alipay","payment-callback","order-not-found"],"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"}