paascloud/paascloud-master · error · OmcBizException

MDC10021015

MDC10021015

Error message

MDC10021015

What it means

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.

Solutions

  1. Re-enable the product (set its status back to ON_SALE) in the MDC product admin/service if it should be sellable.
  2. Remove the offending product from the user's cart and let the user re-checkout with valid items.
  3. Catch OmcBizException code 10021015 and surface 'product X is no longer available, please remove it from your cart'.
  4. When loading the cart page, validate product statuses up-front so users fix the cart before checkout.

Example fix

// before
ProductDto product = mdcProductService.selectById(cartItem.getProductId());
if (MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {
    throw new OmcBizException(ErrorCodeEnum.MDC10021015, product.getId());
}
// after (caller-side pre-check that filters unsellable items)
ProductDto product = mdcProductService.selectById(cartItem.getProductId());
if (product == null || MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {
    omcCartService.deleteByUserIdProductId(userId, cartItem.getProductId());
    continue;
}
Defensive patterns

Strategy: validation

Validate before calling

// Java, pre-check each product before checkout
for (OmcCart item : cartList) {
    ProductDto p = mdcProductService.selectById(item.getProductId());
    if (p == null || MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != p.getStatus()) {
        throw new OmcBizException(ErrorCodeEnum.MDC10021015, item.getProductId());
    }
}

Type guard

// Java
private static boolean isOnSale(ProductDto product) {
    return product != null
        && product.getStatus() == MdcApiConstant.ProductStatusEnum.ON_SALE.getCode();
}

Try / catch

try {
    orderService.createOrderDoc(loginAuthDto, shippingId);
} catch (OmcBizException e) {
    if (e.getCode() == ErrorCodeEnum.MDC10021015.getCode()) {
        return ResultHelper.fail(e.getCode(), "One or more products are no longer for sale");
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/87ea5481dc69e282. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcCartServiceImpl.java:319

		Preconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());
		return omcCartMapper.selectUnCheckedCartProductCountByUserId(userId) == 0;

	}

	@Override
	public List<OmcOrderDetail> getCartOrderItem(Long userId, List<OmcCart> cartList) {
		List<OmcOrderDetail> orderItemList = Lists.newArrayList();
		if (CollectionUtils.isEmpty(cartList)) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
		}

		//校验购物车的数据,包括产品的状态和数量
		for (OmcCart cartItem : cartList) {
			OmcOrderDetail orderDetail = new OmcOrderDetail();
			ProductDto product = mdcProductService.selectById(cartItem.getProductId());
			if (MdcApiConstant.ProductStatusEnum.ON_SALE.getCode() != product.getStatus()) {
				logger.error("商品不是在线售卖状态, productId={}", product.getId());
				throw new OmcBizException(ErrorCodeEnum.MDC10021015, product.getId());
			}

			//校验库存
			if (cartItem.getQuantity() > product.getStock()) {
				logger.error("商品库存不足, productId={}", product.getId());
				throw new OmcBizException(ErrorCodeEnum.MDC10021016, product.getId());
			}

			orderDetail.setUserId(userId);
			orderDetail.setProductId(product.getId());
			orderDetail.setProductName(product.getName());
			orderDetail.setProductImage(product.getMainImage());
			orderDetail.setCurrentUnitPrice(product.getPrice());
			orderDetail.setQuantity(cartItem.getQuantity());
			orderDetail.setTotalPrice(BigDecimalUtil.mul(product.getPrice().doubleValue(), cartItem.getQuantity()));
			orderItemList.add(orderDetail);
		}
		return orderItemList;

View on GitHub (pinned to 781281a950)