paascloud/paascloud-master · error · OmcBizException

OMC10031002

OMC10031002

Error message

OMC10031002

What it means

OmcBizException with ErrorCodeEnum.OMC10031002 (code 10031002, message "生成订单失败" / failed to generate order). Thrown in createOrderDoc when assembleOrder(userId, shippingId, payment) returns null, meaning the order could not be assembled — typically because the given shippingId does not correspond to a shipping address belonging to that user.

Solutions

  1. Verify the shippingId exists and belongs to the authenticated user before checkout (query the shipping table).
  2. Log/inspect userId, shippingId, payment (the service already logs these) to identify which value is invalid.
  3. Correct the shipping address selection in the client and retry.
  4. Check the shipping-address table for the user to rule out deleted or cross-tenant addresses.

Example fix

// before
OmcOrder order = orderService.createOrderDoc(loginAuthDto, otherUsersShippingId, cartList);
// after
Shipping shipping = shippingService.selectByKey(loginAuthDto.getUserId(), shippingId);
if (shipping == null) {
    throw new IllegalArgumentException("shippingId " + shippingId + " not owned by user");
}
OmcOrder order = orderService.createOrderDoc(loginAuthDto, shippingId, cartList);
Defensive patterns

Strategy: validation

Validate before calling

Shipping shipping = shippingService.selectByKey(userId, shippingId);
if (shippingId == null || shipping == null || !userId.equals(shipping.getUserId())) {
    throw new IllegalArgumentException("invalid shippingId=" + shippingId);
}

Try / catch

try {
    orderService.createOrderDoc(loginAuthDto, shippingId, cartList);
} catch (OmcBizException e) {
    if (e.getCode() == 10031002) {
        // order assembly failed: re-check shipping address ownership
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling createOrderDoc with a shippingId that is null, nonexistent, or owned by a different user, so assembleOrder's shipping-address lookup fails and returns null; DB insert/lookup failure during order assembly.

Common situations: Client passing a shipping address ID from another account; a deleted default address still cached in the frontend; stale shippingId after address management changes.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java:100

		List<OmcCart> cartList = omcCartMapper.selectCheckedCartByUserId(userId);
		if (CollectionUtils.isEmpty(cartList)) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
		}
		//计算这个订单的总价
		List<OmcOrderDetail> omcOrderDetailList = omcCartService.getCartOrderItem(userId, cartList);

		if (CollectionUtils.isEmpty(omcOrderDetailList)) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
		}

		BigDecimal payment = this.getOrderTotalPrice(omcOrderDetailList);


		//生成订单
		OmcOrder order = this.assembleOrder(userId, shippingId, payment);
		if (order == null) {
			logger.error("生成订单失败, userId={}, shippingId={}, payment={}", userId, shippingId, payment);
			throw new OmcBizException(ErrorCodeEnum.OMC10031002);
		}
		order.setUpdateInfo(loginAuthDto);
		for (OmcOrderDetail orderDetail : omcOrderDetailList) {
			orderDetail.setUpdateInfo(loginAuthDto);
			orderDetail.setOrderNo(order.getOrderNo());


			orderDetail.setId(super.generateId());
			orderDetail.setUpdateInfo(loginAuthDto);
		}

		//mybatis 批量插入
		omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);

		//生成成功,我们要减少我们产品的库存
		this.reduceProductStock(omcOrderDetailList);
		//清空一下购物车
		this.cleanCart(cartList);

View on GitHub (pinned to 781281a950)