mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-16 13:26:23 +08:00
🆕 #2243 【小程序】增加自定义组件申请接入相关接口
This commit is contained in:
@@ -403,6 +403,12 @@ public interface WxMaService extends WxService {
|
||||
*/
|
||||
WxMaShopSpuService getShopSpuService();
|
||||
|
||||
/**
|
||||
* 返回小程序交易组件-接入申请接口
|
||||
* @return
|
||||
*/
|
||||
WxMaShopRegisterService getShopRegisterService();
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link服务接口
|
||||
* @return
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopRegisterApplySceneRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopRegisterFinishAccessInfoRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopRegisterCheckResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 小程序交易组件-申请接入服务
|
||||
*
|
||||
* @author liming1019
|
||||
*/
|
||||
public interface WxMaShopRegisterService {
|
||||
/**
|
||||
* 接入申请
|
||||
*
|
||||
* @return WxMaShopBaseResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse registerApply() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取接入状态
|
||||
*
|
||||
* @return WxMaShopRegisterCheckResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopRegisterCheckResponse registerCheck() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 完成接入任务
|
||||
*
|
||||
* @return WxMaShopBaseResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse registerFinishAccessInfo(WxMaShopRegisterFinishAccessInfoRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 场景接入申请
|
||||
*
|
||||
* @return WxMaShopBaseResponse
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMaShopBaseResponse registerApplyScene(WxMaShopRegisterApplySceneRequest request) throws WxErrorException;
|
||||
}
|
||||
@@ -65,6 +65,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
private final WxImgProcService imgProcService = new WxMaImgProcServiceImpl(this);
|
||||
private final WxMaShopSpuService shopSpuService = new WxMaShopSpuServiceImpl(this);
|
||||
private final WxMaShopOrderService shopOrderService = new WxMaShopOrderServiceImpl(this);
|
||||
private final WxMaShopRegisterService shopRegisterService = new WxMaShopRegisterServiceImpl(this);
|
||||
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
|
||||
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
|
||||
private Map<String, WxMaConfig> configMap;
|
||||
@@ -516,6 +517,11 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
return this.shopOrderService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopRegisterService getShopRegisterService() {
|
||||
return this.shopRegisterService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaLinkService getLinkService() {
|
||||
return this.linkService;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShopRegisterService;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopRegisterApplySceneRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopRegisterFinishAccessInfoRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
|
||||
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopRegisterCheckResponse;
|
||||
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.Register.*;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WxMaShopRegisterServiceImpl implements WxMaShopRegisterService {
|
||||
private static final String ERR_CODE = "errcode";
|
||||
private final WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse registerApply() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(REGISTER_APPLY, 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, WxMaShopBaseResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopRegisterCheckResponse registerCheck() throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(REGISTER_CHECK, 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, WxMaShopRegisterCheckResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShopBaseResponse registerFinishAccessInfo(WxMaShopRegisterFinishAccessInfoRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(REGISTER_FINISH_ACCESS_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 WxMaShopBaseResponse registerApplyScene(WxMaShopRegisterApplySceneRequest request) throws WxErrorException {
|
||||
String responseContent = this.wxMaService.post(REGISTER_APPLY_SCENE, 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.binarywang.wx.miniapp.bean.shop.request;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
* @date 2021/8/6
|
||||
*/
|
||||
@Data
|
||||
public class WxMaShopRegisterApplySceneRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3008686013597621522L;
|
||||
/**
|
||||
* 1:视频号、公众号场景
|
||||
*/
|
||||
@SerializedName("scene_group_id")
|
||||
private Long sceneGroupId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.binarywang.wx.miniapp.bean.shop.request;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
* @date 2021/8/6
|
||||
*/
|
||||
@Data
|
||||
public class WxMaShopRegisterFinishAccessInfoRequest implements Serializable {
|
||||
private static final long serialVersionUID = 8679586799807671563L;
|
||||
/**
|
||||
* 6:完成spu接口,7:完成订单接口,8:完成物流接口,9:完成售后接口,10:测试完成,11:发版完成
|
||||
*/
|
||||
@SerializedName("access_info_item")
|
||||
private Long accessInfoItem;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.binarywang.wx.miniapp.bean.shop.response;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author liming1019
|
||||
* @date 2021/8/5
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxMaShopRegisterCheckResponse extends WxMaShopBaseResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9061844525630614116L;
|
||||
|
||||
@SerializedName("data")
|
||||
private JsonObject data;
|
||||
}
|
||||
@@ -319,6 +319,13 @@ public class WxMaApiUrlConstants {
|
||||
String ORDER_PAY = "https://api.weixin.qq.com/shop/order/pay";
|
||||
String ORDER_GET = "https://api.weixin.qq.com/shop/order/get";
|
||||
}
|
||||
|
||||
interface Register {
|
||||
String REGISTER_APPLY = "https://api.weixin.qq.com/shop/register/apply";
|
||||
String REGISTER_CHECK = "https://api.weixin.qq.com/shop/register/check";
|
||||
String REGISTER_FINISH_ACCESS_INFO = "https://api.weixin.qq.com/shop/register/finish_access_info";
|
||||
String REGISTER_APPLY_SCENE = "https://api.weixin.qq.com/shop/register/apply_scene";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user