{"record":{"id":"0f93260a5bb26b13","repo":"paascloud/paascloud-master","slug":"omc10031002","errorCode":"OMC10031002","errorMessage":"OMC10031002","messagePattern":"OMC10031002","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":100,"sourceCode":"\t\tList<OmcCart> cartList = omcCartMapper.selectCheckedCartByUserId(userId);\n\t\tif (CollectionUtils.isEmpty(cartList)) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031001, userId);\n\t\t}\n\t\t//计算这个订单的总价\n\t\tList<OmcOrderDetail> omcOrderDetailList = omcCartService.getCartOrderItem(userId, cartList);\n\n\t\tif (CollectionUtils.isEmpty(omcOrderDetailList)) {\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031001, userId);\n\t\t}\n\n\t\tBigDecimal payment = this.getOrderTotalPrice(omcOrderDetailList);\n\n\n\t\t//生成订单\n\t\tOmcOrder order = this.assembleOrder(userId, shippingId, payment);\n\t\tif (order == null) {\n\t\t\tlogger.error(\"生成订单失败, userId={}, shippingId={}, payment={}\", userId, shippingId, payment);\n\t\t\tthrow new OmcBizException(ErrorCodeEnum.OMC10031002);\n\t\t}\n\t\torder.setUpdateInfo(loginAuthDto);\n\t\tfor (OmcOrderDetail orderDetail : omcOrderDetailList) {\n\t\t\torderDetail.setUpdateInfo(loginAuthDto);\n\t\t\torderDetail.setOrderNo(order.getOrderNo());\n\n\n\t\t\torderDetail.setId(super.generateId());\n\t\t\torderDetail.setUpdateInfo(loginAuthDto);\n\t\t}\n\n\t\t//mybatis 批量插入\n\t\tomcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);\n\n\t\t//生成成功,我们要减少我们产品的库存\n\t\tthis.reduceProductStock(omcOrderDetailList);\n\t\t//清空一下购物车\n\t\tthis.cleanCart(cartList);","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderServiceImpl.java#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"Client passing a shipping address ID from another account; a deleted default address still cached in the frontend; stale shippingId after address management changes.","solutions":["Verify the shippingId exists and belongs to the authenticated user before checkout (query the shipping table).","Log/inspect userId, shippingId, payment (the service already logs these) to identify which value is invalid.","Correct the shipping address selection in the client and retry.","Check the shipping-address table for the user to rule out deleted or cross-tenant addresses."],"exampleFix":"// before\nOmcOrder order = orderService.createOrderDoc(loginAuthDto, otherUsersShippingId, cartList);\n// after\nShipping shipping = shippingService.selectByKey(loginAuthDto.getUserId(), shippingId);\nif (shipping == null) {\n    throw new IllegalArgumentException(\"shippingId \" + shippingId + \" not owned by user\");\n}\nOmcOrder order = orderService.createOrderDoc(loginAuthDto, shippingId, cartList);","handlingStrategy":"validation","validationCode":"Shipping shipping = shippingService.selectByKey(userId, shippingId);\nif (shippingId == null || shipping == null || !userId.equals(shipping.getUserId())) {\n    throw new IllegalArgumentException(\"invalid shippingId=\" + shippingId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    orderService.createOrderDoc(loginAuthDto, shippingId, cartList);\n} catch (OmcBizException e) {\n    if (e.getCode() == 10031002) {\n        // order assembly failed: re-check shipping address ownership\n    } else { throw e; }\n}","preventionTips":["Always verify the shipping address belongs to the current user before checkout.","Re-fetch shipping addresses from the server rather than trusting stale client IDs.","Clear cached shippingId after address deletion.","Log userId/shippingId/payment on failure to speed diagnosis."],"tags":["order","shipping-address","null-return","business-exception"],"backgroundTag":"entity-not-found","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"}