mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #2249 【小程序】增加自定义组件之商家入驻相关接口
This commit is contained in:
@@ -393,30 +393,49 @@ public interface WxMaService extends WxService {
|
||||
|
||||
/**
|
||||
* 返回小程序交易组件-订单服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopOrderService getShopOrderService();
|
||||
|
||||
/**
|
||||
* 返回小程序交易组件-spu商品服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopSpuService getShopSpuService();
|
||||
|
||||
/**
|
||||
* 返回小程序交易组件-接入申请接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopRegisterService getShopRegisterService();
|
||||
|
||||
/**
|
||||
* 返回小程序交易组件-商户入驻接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopAccountService getShopAccountService();
|
||||
|
||||
/**
|
||||
* 小程序交易组件-接入商品前必需接口-类目相关
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaShopCatService getShopCatService();
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaLinkService getLinkService();
|
||||
|
||||
/**
|
||||
* 获取电子发票报销方服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaReimburseInvoiceService getReimburseInvoiceService();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-商家入驻接口
|
||||
*
|
||||
* @author liming1019
|
||||
*/
|
||||
public interface WxMaShopAccountService {
|
||||
/**
|
||||
* 获取商家类目列表
|
||||
*
|
||||
* @return WxMaShopAccountGetCategoryListResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取商家品牌列表
|
||||
*
|
||||
* @return WxMaShopAccountGetBrandListResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新商家信息
|
||||
*
|
||||
* @param request
|
||||
* @return WxMaShopBaseResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取商家信息
|
||||
*
|
||||
* @return WxMaShopAccountGetInfoResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-接入商品前必需接口
|
||||
*
|
||||
* @author liming1019
|
||||
*/
|
||||
public interface WxMaShopCatService {
|
||||
/**
|
||||
* 获取商品类目
|
||||
*
|
||||
* @return WxMaShopCatGetResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopCatGetResponse getCat() throws WxErrorException;
|
||||
}
|
||||
@@ -66,6 +66,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
private final WxMaShopSpuService shopSpuService = new WxMaShopSpuServiceImpl(this);
|
||||
private final WxMaShopOrderService shopOrderService = new WxMaShopOrderServiceImpl(this);
|
||||
private final WxMaShopRegisterService shopRegisterService = new WxMaShopRegisterServiceImpl(this);
|
||||
private final WxMaShopAccountService shopAccountService = new WxMaShopAccountServiceImpl(this);
|
||||
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
|
||||
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
|
||||
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
|
||||
private Map<String, WxMaConfig> configMap;
|
||||
@@ -522,6 +524,16 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
return this.shopRegisterService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopAccountService getShopAccountService() {
|
||||
return this.shopAccountService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopCatService getShopCatService() {
|
||||
return this.shopCatService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaLinkService getLinkService() {
|
||||
return this.linkService;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopAccountService;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAccountUpdateInfoRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetBrandListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetCategoryListResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAccountGetInfoResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Account.*;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopAccountServiceImpl implements WxMaShopAccountService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaShopAccountGetCategoryListResponse getCategoryList() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_CATEGORY_LIST, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetCategoryListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopAccountGetBrandListResponse getBrandList() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_BRAND_LIST, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetBrandListResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse updateInfo(WxMaShopAccountUpdateInfoRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(UPDATE_INFO, request);
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopAccountGetInfoResponse getInfo() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_INFO, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAccountGetInfoResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopCatService;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopCatGetResponse;
|
||||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.enums.WxType;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Cat.GET_CAT;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopCatServiceImpl implements WxMaShopCatService {
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaShopCatGetResponse getCat() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(GET_CAT, new JsonObject());
|
||||
JsonObject jsonObject = GsonParser.parse(responseContent);
|
||||
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
||||
}
|
||||
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopCatGetResponse.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user