paascloud/paascloud-master · error · OmcBizException
OMC10031006
OMC10031006
Error message
OMC10031006
What it means
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.
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
Example fix
// before
int deleteCount = omcCartMapper.batchDeleteCart(idList);
if (deleteCount < idList.size()) {
throw new OmcBizException(ErrorCodeEnum.OMC10031006);
}
// after
omcCartMapper.batchDeleteCart(idList); // idempotent delete; tolerate already-removed rows Defensive patterns
Strategy: try-catch
Validate before calling
List<Long> existingIds = cartList.stream().map(OmcCart::getId).collect(Collectors.toList()); int deleteCount = omcCartMapper.batchDeleteCart(existingIds); // treat deleteCount < existingIds.size() as warning, not failure
Try / catch
try {
orderService.createOrder(...); // internally calls cleanCart
} catch (OmcBizException e) {
if (e.getCode() == 10031006) { retryOrderCreation(); }
else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/6b934f05fe2013b7.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java:311
return orderItemVo;
}
private void reduceProductStock(List<OmcOrderDetail> omcOrderDetailList) {
for (OmcOrderDetail orderItem : omcOrderDetailList) {
ProductDto product = mdcProductService.selectById(orderItem.getProductId());
product.setChangeStock(0 - orderItem.getQuantity());
mdcProductService.updateProductStockById(product);
}
}
private void cleanCart(List<OmcCart> cartList) {
List<Long> idList = Lists.newArrayList();
for (OmcCart cart : cartList) {
idList.add(cart.getId());
}
int deleteCount = omcCartMapper.batchDeleteCart(idList);
if (deleteCount < idList.size()) {
throw new OmcBizException(ErrorCodeEnum.OMC10031006);
}
}
private List<OrderVo> assembleOrderVoList(List<OmcOrder> orderList, Long userId) {
List<OrderVo> orderVoList = Lists.newArrayList();
for (OmcOrder order : orderList) {
List<OmcOrderDetail> orderItemList;
if (userId == null) {
orderItemList = omcOrderDetailService.getListByOrderNo(order.getOrderNo());
} else {
orderItemList = omcOrderDetailService.getListByOrderNoUserId(order.getOrderNo(), userId);
}
OrderVo orderVo = assembleOrderVo(order, orderItemList);
orderVoList.add(orderVo);
}
return orderVoList;
}
View on GitHub (pinned to 781281a950)