Skip to content

Commit 16d98a6

Browse files
authored
🆕 #2249 【小程序】增加自定义组件之商家入驻相关接口
1 parent 5c71b2a commit 16d98a6

18 files changed

+582
-0
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,30 +393,49 @@ public interface WxMaService extends WxService {
393393

394394
/**
395395
* 返回小程序交易组件-订单服务接口
396+
*
396397
* @return
397398
*/
398399
WxMaShopOrderService getShopOrderService();
399400

400401
/**
401402
* 返回小程序交易组件-spu商品服务接口
403+
*
402404
* @return
403405
*/
404406
WxMaShopSpuService getShopSpuService();
405407

406408
/**
407409
* 返回小程序交易组件-接入申请接口
410+
*
408411
* @return
409412
*/
410413
WxMaShopRegisterService getShopRegisterService();
411414

415+
/**
416+
* 返回小程序交易组件-商户入驻接口
417+
*
418+
* @return
419+
*/
420+
WxMaShopAccountService getShopAccountService();
421+
422+
/**
423+
* 小程序交易组件-接入商品前必需接口-类目相关
424+
*
425+
* @return
426+
*/
427+
WxMaShopCatService getShopCatService();
428+
412429
/**
413430
* 获取小程序 URL Link服务接口
431+
*
414432
* @return
415433
*/
416434
WxMaLinkService getLinkService();
417435

418436
/**
419437
* 获取电子发票报销方服务接口
438+
*
420439
* @return
421440
*/
422441
WxMaReimburseInvoiceService getReimburseInvoiceService();
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package cn.binarywang.wx.miniapp.api;
2+
3+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
4+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
10+
/**
11+
* 小程序交易组件-商家入驻接口
12+
*
13+
* @author liming1019
14+
*/
15+
public interface WxMaShopAccountService {
16+
/**
17+
* 获取商家类目列表
18+
*
19+
* @return WxMaShopAccountGetCategoryListResponse
20+
* @throws WxErrorException
21+
*/
22+
WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException;
23+
24+
/**
25+
* 获取商家品牌列表
26+
*
27+
* @return WxMaShopAccountGetBrandListResponse
28+
* @throws WxErrorException
29+
*/
30+
WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException;
31+
32+
/**
33+
* 更新商家信息
34+
*
35+
* @param request
36+
* @return WxMaShopBaseResponse
37+
* @throws WxErrorException
38+
*/
39+
WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException;
40+
41+
/**
42+
* 获取商家信息
43+
*
44+
* @return WxMaShopAccountGetInfoResponse
45+
* @throws WxErrorException
46+
*/
47+
WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException;
48+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cn.binarywang.wx.miniapp.api;
2+
3+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
6+
/**
7+
* 小程序交易组件-接入商品前必需接口
8+
*
9+
* @author liming1019
10+
*/
11+
public interface WxMaShopCatService {
12+
/**
13+
* 获取商品类目
14+
*
15+
* @return WxMaShopCatGetResponse
16+
* @throws WxErrorException
17+
*/
18+
WxMaShopCatGetResponse getCat() throws WxErrorException;
19+
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
6666
private final WxMaShopSpuService shopSpuService = new WxMaShopSpuServiceImpl(this);
6767
private final WxMaShopOrderService shopOrderService = new WxMaShopOrderServiceImpl(this);
6868
private final WxMaShopRegisterService shopRegisterService = new WxMaShopRegisterServiceImpl(this);
69+
private final WxMaShopAccountService shopAccountService = new WxMaShopAccountServiceImpl(this);
70+
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
6971
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
7072
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
7173
private Map<String, WxMaConfig> configMap;
@@ -522,6 +524,16 @@ public WxMaShopRegisterService getShopRegisterService() {
522524
return this.shopRegisterService;
523525
}
524526

527+
@Override
528+
public WxMaShopAccountService getShopAccountService() {
529+
return this.shopAccountService;
530+
}
531+
532+
@Override
533+
public WxMaShopCatService getShopCatService() {
534+
return this.shopCatService;
535+
}
536+
525537
@Override
526538
public WxMaLinkService getLinkService() {
527539
return this.linkService;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package cn.binarywang.wx.miniapp.api.impl;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.api.WxMaShopAccountService;
5+
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
6+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
7+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
8+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
9+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
10+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
11+
import com.google.gson.JsonObject;
12+
import lombok.RequiredArgsConstructor;
13+
import lombok.extern.slf4j.Slf4j;
14+
import me.chanjar.weixin.common.enums.WxType;
15+
import me.chanjar.weixin.common.error.WxError;
16+
import me.chanjar.weixin.common.error.WxErrorException;
17+
import me.chanjar.weixin.common.util.json.GsonParser;
18+
19+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Account.*;
20+
21+
/**
22+
* @author liming1019
23+
*/
24+
@RequiredArgsConstructor
25+
@Slf4j
26+
public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
27+
private static final String ERR_CODE = "errcode";
28+
private final WxMaService wxMaService;
29+
30+
@Override
31+
public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException {
32+
String responseContent = this.wxMaService.post(GET_CATEGORY_LIST, new JsonObject());
33+
JsonObject jsonObject = GsonParser.parse(responseContent);
34+
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
35+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
36+
}
37+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetCategoryListResponse.class);
38+
}
39+
40+
@Override
41+
public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException {
42+
String responseContent = this.wxMaService.post(GET_BRAND_LIST, new JsonObject());
43+
JsonObject jsonObject = GsonParser.parse(responseContent);
44+
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
45+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
46+
}
47+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetBrandListResponse.class);
48+
}
49+
50+
@Override
51+
public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException {
52+
String responseContent = this.wxMaService.post(UPDATE_INFO, request);
53+
JsonObject jsonObject = GsonParser.parse(responseContent);
54+
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
55+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
56+
}
57+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
58+
}
59+
60+
@Override
61+
public WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException {
62+
String responseContent = this.wxMaService.post(GET_INFO, new JsonObject());
63+
JsonObject jsonObject = GsonParser.parse(responseContent);
64+
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
65+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
66+
}
67+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetInfoResponse.class);
68+
}
69+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cn.binarywang.wx.miniapp.api.impl;
2+
3+
import cn.binarywang.wx.miniapp.api.WxMaService;
4+
import cn.binarywang.wx.miniapp.api.WxMaShopCatService;
5+
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
6+
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
7+
import com.google.gson.JsonObject;
8+
import lombok.RequiredArgsConstructor;
9+
import lombok.extern.slf4j.Slf4j;
10+
import me.chanjar.weixin.common.enums.WxType;
11+
import me.chanjar.weixin.common.error.WxError;
12+
import me.chanjar.weixin.common.error.WxErrorException;
13+
import me.chanjar.weixin.common.util.json.GsonParser;
14+
15+
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Cat.GET_CAT;
16+
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
17+
18+
/**
19+
* @author liming1019
20+
*/
21+
@RequiredArgsConstructor
22+
@Slf4j
23+
public class WxMaShopCatServiceImpl implements WxMaShopCatService {
24+
private final WxMaService wxMaService;
25+
26+
@Override
27+
public WxMaShopCatGetResponse getCat() throws WxErrorException {
28+
String responseContent = this.wxMaService.post(GET_CAT, new JsonObject());
29+
JsonObject jsonObject = GsonParser.parse(responseContent);
30+
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
31+
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
32+
}
33+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCatGetResponse.class);
34+
}
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cn.binarywang.wx.miniapp.bean.shop;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author liming1019
10+
* @date 2021/8/9
11+
*/
12+
@Data
13+
public class WxMaShopAccountGetBrandListItem implements Serializable {
14+
private static final long serialVersionUID = -8889271375365538573L;
15+
16+
/**
17+
* 品牌ID
18+
*/
19+
@SerializedName("brand_id")
20+
private Long brandId;
21+
22+
/**
23+
* 品牌名称
24+
*/
25+
@SerializedName("brand_wording")
26+
private String brandWording;
27+
}
28+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package cn.binarywang.wx.miniapp.bean.shop;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author liming1019
10+
* @date 2021/8/9
11+
*/
12+
@Data
13+
public class WxMaShopAccountGetCategoryListItem implements Serializable {
14+
private static final long serialVersionUID = -6574489801942310752L;
15+
16+
/**
17+
* 一级类目ID
18+
*/
19+
@SerializedName("first_cat_id")
20+
private Long firstCatId;
21+
/**
22+
* 二级类目ID
23+
*/
24+
@SerializedName("second_cat_id")
25+
private Long secondCatId;
26+
/**
27+
* 类目ID
28+
*/
29+
@SerializedName("third_cat_id")
30+
private Long thirdCatId;
31+
/**
32+
* 一级类目名称
33+
*/
34+
@SerializedName("first_cat_name")
35+
private String firstCatName;
36+
/**
37+
* 二级类目名称
38+
*/
39+
@SerializedName("second_cat_name")
40+
private String secondCatName;
41+
42+
/**
43+
* 类目名称
44+
*/
45+
@SerializedName("third_cat_name")
46+
private String thirdCatName;
47+
}
48+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cn.binarywang.wx.miniapp.bean.shop;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author liming1019
10+
* @date 2021/8/9
11+
*/
12+
@Data
13+
public class WxMaShopAccountGetInfo implements Serializable {
14+
/**
15+
* 品牌ID
16+
*/
17+
@SerializedName("brand_id")
18+
private Long brandId;
19+
20+
/**
21+
* 品牌名称
22+
*/
23+
@SerializedName("brand_wording")
24+
private String brandWording;
25+
}
26+

0 commit comments

Comments
 (0)