{"record":{"id":"87ea5481dc69e282","repo":"paascloud/paascloud-master","slug":"mdc10021015","errorCode":"MDC10021015","errorMessage":"MDC10021015","messagePattern":"MDC10021015","errorType":"error_code","errorClass":"OmcBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcCartServiceImpl.java","lineNumber":319,"sourceCode":"\t\tPreconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());\n\t\treturn omcCartMapper.selectUnCheckedCartProductCountByUserId(userId) == 0;\n\n\t}\n\n\t@Override\n\tpublic List<OmcOrderDetail> getCartOrderItem(Long userId, List<OmcCart> cartList) {\n\t\tList<OmcOrderDetail> orderItemList = Lists.newArrayList();\n\t\tif (CollectionUtils.isEmpty(cartList)) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031001, userId);\n\t\t}\n\n\t\t//校验购物车的数据,包括产品的状态和数量\n\t\tfor (OmcCart cartItem : cartList) {\n\t\t\tOmcOrderDetail orderDetail = new OmcOrderDetail();\n\t\t\tProductDto product = mdcProductService.selectById(cartItem.getProductId());\n\t\t\tif (MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {\n\t\t\t\tlogger.error(\"商品不是在线售卖状态, productId={}\", product.getId());\n\t\t\t\tthrow new OmcBizException(ErrorCodeEnum.MDC10021015, product.getId());\n\t\t\t}\n\n\t\t\t//校验库存\n\t\t\tif (cartItem.getQuantity() > product.getStock()) {\n\t\t\t\tlogger.error(\"商品库存不足, productId={}\", product.getId());\n\t\t\t\tthrow new OmcBizException(ErrorCodeEnum.MDC10021016, product.getId());\n\t\t\t}\n\n\t\t\torderDetail.setUserId(userId);\n\t\t\torderDetail.setProductId(product.getId());\n\t\t\torderDetail.setProductName(product.getName());\n\t\t\torderDetail.setProductImage(product.getMainImage());\n\t\t\torderDetail.setCurrentUnitPrice(product.getPrice());\n\t\t\torderDetail.setQuantity(cartItem.getQuantity());\n\t\t\torderDetail.setTotalPrice(BigDecimalUtil.mul(product.getPrice().doubleValue(), cartItem.getQuantity()));\n\t\t\torderItemList.add(orderDetail);\n\t\t}\n\t\treturn orderItemList;","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcCartServiceImpl.java#L301-L337","documentation":"MDC10021015 means '商品不是在线售卖状态' (product is not in on-sale status, productId=%s). While validating each cart item, getCartOrderItem loads the product via mdcProductService.selectById and throws if product.getStatus() != ON_SALE, refusing to order products that are off-shelf, deleted, or otherwise not sellable.","triggerScenarios":"A cart item references a product whose status is not MdcApiConstant.ProductStatusEnum.ON_SALE at order time — product was taken off-shelf, marked deleted, or its status changed between adding to cart and checkout.","commonSituations":"Merchant unpublishes a product that users still have in their carts; product data changed in the MDC service after the cart was built; stale cart data across long-lived sessions; test/dev products switched to non-sale status.","solutions":["Re-enable the product (set its status back to ON_SALE) in the MDC product admin/service if it should be sellable.","Remove the offending product from the user's cart and let the user re-checkout with valid items.","Catch OmcBizException code 10021015 and surface 'product X is no longer available, please remove it from your cart'.","When loading the cart page, validate product statuses up-front so users fix the cart before checkout."],"exampleFix":"// before\nProductDto product = mdcProductService.selectById(cartItem.getProductId());\nif (MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {\n    throw new OmcBizException(ErrorCodeEnum.MDC10021015, product.getId());\n}\n// after (caller-side pre-check that filters unsellable items)\nProductDto product = mdcProductService.selectById(cartItem.getProductId());\nif (product == null || MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {\n    omcCartService.deleteByUserIdProductId(userId, cartItem.getProductId());\n    continue;\n}","handlingStrategy":"validation","validationCode":"// Java, pre-check each product before checkout\nfor (OmcCart item : cartList) {\n    ProductDto p = mdcProductService.selectById(item.getProductId());\n    if (p == null || MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != p.getStatus()) {\n        throw new OmcBizException(ErrorCodeEnum.MDC10021015, item.getProductId());\n    }\n}","typeGuard":"// Java\nprivate static boolean isOnSale(ProductDto product) {\n    return product != null\n        && product.getStatus() == MdcApiConstant.ProductStatusEnum.ON_SALE.getCode();\n}","tryCatchPattern":"try {\n    orderService.createOrderDoc(loginAuthDto, shippingId);\n} catch (OmcBizException e) {\n    if (e.getCode() == ErrorCodeEnum.MDC10021015.getCode()) {\n        return ResultHelper.fail(e.getCode(), \"One or more products are no longer for sale\");\n    }\n    throw e;\n}","preventionTips":["Validate product status when rendering the cart and again at checkout.","Prompt users to remove off-shelf products instead of failing the whole order.","Keep product status synchronized between cart UI and MDC service.","Monitor for frequent occurrences to catch merchants unpublishing popular items."],"tags":["product-status","inventory","cart","product-not-on-sale"],"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"}