{"record":{"id":"9a2ab5452e953748","repo":"paascloud/paascloud-master","slug":"omc10031011","errorCode":"OMC10031011","errorMessage":"OMC10031011","messagePattern":"OMC10031011","errorType":"error_code","errorClass":"OmcBizException","httpStatus":null,"severity":"warning","filePath":"paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java","lineNumber":259,"sourceCode":"\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);\n\t\tpayInfo.setUpdateTime(new Date());\n\t\tpayInfo.setCreatedTime(new Date());\n\t\tpayInfo.setCreator(order.getCreator());","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/PtcAlipayServiceImpl.java#L241-L277","documentation":"OmcBizException with code OMC10031011 thrown by aliPayCallback when the order referenced by an Alipay callback already has status >= PAID. It is an idempotency guard: Alipay re-sends success notifications repeatedly until acknowledged, and processing an already-paid order again would double-apply payment state.","triggerScenarios":"Alipay re-delivers a TRADE_SUCCESS notification for an order already marked PAID (retry until ack), duplicate notifications for the same trade, or a repeated manual notify triggered from the Alipay merchant console.","commonSituations":"Server processed the first callback but returned a non-ack response (network timeout, exception after marking paid) so Alipay retries; duplicate callback listeners registered; operator re-sending the notify from Alipay console.","solutions":["Treat as expected duplicate: log and immediately return ack (\"success\") to Alipay so retries stop","Check why the first callback did not ack Alipay (exception after update, response lost) and fix the response path","If the order is stuck below PAID but above expected, inspect the status enum values for mismatched ordering","Do not retry the update blindly; verify payment records for the trade_no before manual correction"],"exampleFix":"// before\nif (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {\n    throw new OmcBizException(ErrorCodeEnum.OMC10031011);\n}\n// after\nif (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {\n    log.info(\"aliPayCallback - order {} already paid, ack duplicate notify\", orderNo);\n    return \"success\"; // idempotent ack instead of throwing\n}","handlingStrategy":"validation","validationCode":"if (order != null && order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {\n    return \"success\"; // idempotent ack for duplicate notifications\n}","typeGuard":"if (order == null || order.getStatus() == null) { return \"fail\"; }","tryCatchPattern":"try { return aliPayCallback(params); } catch (OmcBizException e) { if (\"OMC10031011\".equals(e.getCode())) return \"success\"; return \"fail\"; }","preventionTips":["Make callback handling idempotent: treat already-paid as success and ack","Always ack Alipay after successful processing to prevent retries","Verify updates with a conditional WHERE status < PAID to race-proof","Alert on high duplicate-notify rates which indicate lost acks"],"tags":["alipay","payment-callback","idempotency","duplicate-notification"],"backgroundTag":"invalid-state-transition","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"}