{"record":{"id":"6b934f05fe2013b7","repo":"paascloud/paascloud-master","slug":"omc10031006","errorCode":"OMC10031006","errorMessage":"OMC10031006","messagePattern":"OMC10031006","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":311,"sourceCode":"\t\treturn orderItemVo;\n\t}\n\n\tprivate void reduceProductStock(List<OmcOrderDetail> omcOrderDetailList) {\n\t\tfor (OmcOrderDetail orderItem : omcOrderDetailList) {\n\t\t\tProductDto product = mdcProductService.selectById(orderItem.getProductId());\n\t\t\tproduct.setChangeStock(0 - orderItem.getQuantity());\n\t\t\tmdcProductService.updateProductStockById(product);\n\t\t}\n\t}\n\n\tprivate void cleanCart(List<OmcCart> cartList) {\n\t\tList<Long> idList = Lists.newArrayList();\n\t\tfor (OmcCart cart : cartList) {\n\t\t\tidList.add(cart.getId());\n\t\t}\n\t\tint deleteCount = omcCartMapper.batchDeleteCart(idList);\n\t\tif (deleteCount < idList.size()) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031006);\n\t\t}\n\t}\n\n\tprivate List<OrderVo> assembleOrderVoList(List<OmcOrder> orderList, Long userId) {\n\t\tList<OrderVo> orderVoList = Lists.newArrayList();\n\t\tfor (OmcOrder order : orderList) {\n\t\t\tList<OmcOrderDetail> orderItemList;\n\t\t\tif (userId == null) {\n\t\t\t\torderItemList = omcOrderDetailService.getListByOrderNo(order.getOrderNo());\n\t\t\t} else {\n\t\t\t\torderItemList = omcOrderDetailService.getListByOrderNoUserId(order.getOrderNo(), userId);\n\t\t\t}\n\t\t\tOrderVo orderVo = assembleOrderVo(order, orderItemList);\n\t\t\torderVoList.add(orderVo);\n\t\t}\n\t\treturn orderVoList;\n\t}\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java#L293-L329","documentation":"ErrorCodeEnum.OMC10031006 ('failed to clean cart', 清空购物车失败) is thrown by cleanCart when batchDeleteCart deletes fewer rows than the number of cart item ids collected from the user's cart. It signals a partial or failed delete during order creation, leaving stale cart items behind.","triggerScenarios":"During createOrderDoc: omcCartMapper.batchDeleteCart(idList) returns a count < idList.size(), e.g. because a cart row was concurrently deleted by another request, a row was already removed, or the DB delete hit a constraint/error swallowed by the mapper.","commonSituations":"Double-submitting an order so the second transaction finds cart rows already deleted; concurrent sessions on the same account; replication/tx isolation issues in the cart table.","solutions":["Make the delete idempotent: treat already-deleted rows as success, e.g. compare against rows that actually existed (SELECT ... FOR UPDATE before delete) or remove the strict count check","Retry the order creation transaction; on retry the cart list will be empty and creation should proceed","Check omc_cart for triggers/soft-delete flags that could reduce the affected-row count"],"exampleFix":"// before\nint deleteCount = omcCartMapper.batchDeleteCart(idList);\nif (deleteCount < idList.size()) {\n    throw new OmcBizException(ErrorCodeEnum.OMC10031006);\n}\n// after\nomcCartMapper.batchDeleteCart(idList); // idempotent delete; tolerate already-removed rows","handlingStrategy":"try-catch","validationCode":"List<Long> existingIds = cartList.stream().map(OmcCart::getId).collect(Collectors.toList());\nint deleteCount = omcCartMapper.batchDeleteCart(existingIds);\n// treat deleteCount < existingIds.size() as warning, not failure","typeGuard":null,"tryCatchPattern":"try {\n    orderService.createOrder(...); // internally calls cleanCart\n} catch (OmcBizException e) {\n    if (e.getCode() == 10031006) { retryOrderCreation(); }\n    else throw e;\n}","preventionTips":["Make cart cleanup idempotent — don't fail when rows were already deleted","Avoid double-submission of order creation (disable button, idempotency key)","Run cart delete and order insert in one transaction to keep state consistent"],"tags":["cart","database-write","concurrency"],"backgroundTag":"database-write-failed","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"}