Skip to content

Commit 460a52b

Browse files
committed
添加删除门店的接口, for issue #17
1 parent 091aefe commit 460a52b

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ public interface WxMpStoreService {
3636
* 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
3737
* 详情请见: <a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444378120&token=&lang=zh_CN">微信门店接口</a>
3838
* </pre>
39-
* @param poiId 门店poiId
39+
* @param poiId 门店Id
4040
* @throws WxErrorException
4141
*/
4242
WxMpStoreBaseInfo get(String poiId) throws WxErrorException;
4343

44+
/**
45+
* <pre>
46+
* 删除门店
47+
* 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。
48+
* 详情请见: <a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444378120&token=&lang=zh_CN">微信门店接口</a>
49+
* </pre>
50+
* @param poiId 门店Id
51+
* @throws WxErrorException
52+
*/
53+
void delete(String poiId) throws WxErrorException;
54+
4455
/**
4556
* <pre>
4657
* 查询门店列表(指定查询起始位置和个数)

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ public WxMpStoreBaseInfo get(String poiId) throws WxErrorException {
5757
.get("business").getAsJsonObject().get("base_info").toString());
5858
}
5959

60+
@Override
61+
public void delete(String poiId) throws WxErrorException {
62+
String url = API_BASE_URL + "/delpoi";
63+
JsonObject paramObject = new JsonObject();
64+
paramObject.addProperty("poi_id",poiId);
65+
String response = this.wxMpService.post(url, paramObject.toString());
66+
WxError wxError = WxError.fromJson(response);
67+
if (wxError.getErrorCode() != 0) {
68+
throw new WxErrorException(wxError);
69+
}
70+
}
71+
6072
private void checkParameters(WxMpStoreBaseInfo request) {
6173
List<String> nullFields = Lists.newArrayList();
6274
for (Entry<String, Reflect> entry : Reflect.on(request).fields()

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public void testGet() throws WxErrorException {
5252
System.err.println(result);
5353
}
5454

55+
public void testDelete() throws WxErrorException {
56+
this.wxMpService.getStoreService().delete("463558057");
57+
}
58+
5559
public void testList() throws WxErrorException {
5660
WxMpStoreListResult result = this.wxMpService.getStoreService().list(0, 10);
5761
assertNotNull(result);

0 commit comments

Comments
 (0)