binarywang/WxJava · warning · IllegalArgumentException
更新门店时wxStoreId 或 outStoreId 至少要有一个不为null
Error message
更新门店时wxStoreId 或 outStoreId 至少要有一个不为null
What it means
Unchecked IllegalArgumentException from updateStore(WxMaStore) when both wxStoreId and outStoreId are null. updateStore builds a 'keys' map to identify the target store via exactly one of these IDs; without either, the update target is ambiguous so it aborts before the HTTP call.
Source
Thrown at weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaIntracityServiceImpl.java:62
}
@Override
public String createStore(WxMaStore store) throws WxErrorException {
if (store.getOutStoreId() == null) {
throw new IllegalArgumentException("创建门店时outStoreId不能为空");
}
if (store.getWxStoreId() != null) {
throw new IllegalArgumentException("创建门店时wxStoreId只能是null");
}
String response = this.wxMaService.postWithSignature(Intracity.CREATE_STORE_URL, store);
Map<?, ?> map = gson.fromJson(response, Map.class);
return (String) map.get("wx_store_id");
}
@Override
public void updateStore(WxMaStore store) throws WxErrorException {
if (store.getWxStoreId() == null && store.getOutStoreId() == null) {
throw new IllegalArgumentException("更新门店时wxStoreId 或 outStoreId 至少要有一个不为null");
}
JsonObject request = new JsonObject();
Map<String, String> keys = new HashMap<>();
if (store.getWxStoreId() != null) {
keys.put("wx_store_id", store.getWxStoreId());
} else {
keys.put("out_store_id", store.getOutStoreId());
}
request.add("keys", gson.toJsonTree(keys));
Map<String, Object> updateContent = new HashMap<>();
if (store.getStoreName() != null) {
updateContent.put("store_name", store.getStoreName());
}
if (store.getOrderPattern() == 1 || store.getOrderPattern() == 2) {
updateContent.put("order_pattern", store.getOrderPattern());
}
if (store.getServiceTransPrefer() != null) {
updateContent.put("service_trans_prefer", store.getServiceTransPrefer());View on GitHub (pinned to 1c43293a3c)
Solutions
- Set at least one identifier — preferably store.setWxStoreId(id) using the id from the create/query result, or store.setOutStoreId(merchantId).
- Carry the identifier through your update flow from the original create/query response.
Example fix
// before
WxMaStore s = new WxMaStore();
s.setStoreName("new name");
intracityService.updateStore(s);
// after
WxMaStore s = new WxMaStore();
s.setWxStoreId(wxStoreIdFromCreate);
s.setStoreName("new name");
intracityService.updateStore(s); Defensive patterns
Strategy: validation
Validate before calling
if (store.getWxStoreId() == null && store.getOutStoreId() == null) {
throw new IllegalArgumentException("need wxStoreId or outStoreId to update");
} Try / catch
try {
intracityService.updateStore(store);
} catch (IllegalArgumentException e) {
throw e;
} Prevention
- Always retain the wxStoreId returned by createStore for subsequent updates.
- Validate identifier presence in your update DTO before mapping to WxMaStore.
When it happens
Trigger: Calling intracityService.updateStore(store) on a WxMaStore with neither identifier set.
Common situations: Constructing a new WxMaStore, setting only mutable fields (storeName, orderPattern) and forgetting the identifier; a partial-update DTO that dropped the id field during mapping.
Related errors
- 创建门店时outStoreId不能为空
- 创建门店时wxStoreId只能是null
- 查询请求 wxStoreId 不可为空
- payMode是PAY_MODE_STORE或null时,必须传递wxStoreId
- 查询请求 flowType 不正确,只能是1、2、3之一
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/66f93d307dbb70ad.
Report an issue: GitHub.