🆕 #2255 【小程序】增加自定义组件之接入商品前必需的接口

This commit is contained in:
liming1019
2021-08-13 13:46:33 +08:00
committed by GitHub
parent 5326c5b155
commit b3eadb4ffa
11 changed files with 499 additions and 0 deletions

View File

@@ -433,6 +433,13 @@ public interface WxMaService extends WxService {
*/
WxMaShopImgService getShopImgService();
/**
* 小程序交易组件-接入商品前必需接口-审核相关接口
*
* @return
*/
WxMaShopAuditService getShopAuditService();
/**
* 获取小程序 URL Link服务接口
*

View File

@@ -0,0 +1,53 @@
package cn.binarywang.wx.miniapp.api;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAuditBrandRequest;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAuditCategoryRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditBrandResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditCategoryResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditResultResponse;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.error.WxErrorException;
/**
* 小程序交易组件-接入商品前必需接口(审核相关接口)
*
* @author liming1019
* @date 2021/8/12
*/
public interface WxMaShopAuditService {
/**
* 上传品牌信息(品牌审核)
*
* @param request
* @return WxMaShopAuditBrandResponse
* @throws WxErrorException
*/
WxMaShopAuditBrandResponse auditBrand(WxMaShopAuditBrandRequest request) throws WxErrorException;
/**
* 上传类目资质(类目审核)
*
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopAuditCategoryResponse auditCategory(WxMaShopAuditCategoryRequest request) throws WxErrorException;
/**
* 获取审核结果
*
* @param auditId
* @return WxMaShopAuditResultResponse
* @throws WxErrorException
*/
WxMaShopAuditResultResponse getAuditResult(String auditId) throws WxErrorException;
/**
* 获取小程序提交过的入驻资质信息
*
* @param reqType
* @return JsonObject
* @throws WxErrorException
*/
JsonObject getMiniappCertificate(int reqType) throws WxErrorException;
}

View File

@@ -69,6 +69,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
private final WxMaShopAccountService shopAccountService = new WxMaShopAccountServiceImpl(this);
private final WxMaShopCatService shopCatService = new WxMaShopCatServiceImpl(this);
private final WxMaShopImgService shopImgService = new WxMaShopImgServiceImpl(this);
private final WxMaShopAuditService shopAuditService = new WxMaShopAuditServiceImpl(this);
private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
private Map<String, WxMaConfig> configMap;
@@ -540,6 +541,11 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
return this.shopImgService;
}
@Override
public WxMaShopAuditService getShopAuditService() {
return this.shopAuditService;
}
@Override
public WxMaLinkService getLinkService() {
return this.linkService;

View File

@@ -0,0 +1,101 @@
package cn.binarywang.wx.miniapp.api.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopAuditService;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAuditBrandRequest;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAuditCategoryRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditBrandResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditCategoryResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopAuditResultResponse;
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.GsonHelper;
import me.chanjar.weixin.common.util.json.GsonParser;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Audit.*;
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ERRCODE;
/**
* 小程序交易组件-接入商品前必需接口(审核相关接口)
*
* @author liming1019
* @date 2021/8/12
*/
@RequiredArgsConstructor
@Slf4j
public class WxMaShopAuditServiceImpl implements WxMaShopAuditService {
private final WxMaService wxMaService;
/**
* 上传品牌信息(品牌审核)
*
* @param request
* @return WxMaShopAuditBrandResponse
* @throws WxErrorException
*/
@Override
public WxMaShopAuditBrandResponse auditBrand(WxMaShopAuditBrandRequest request) throws WxErrorException {
String responseContent = this.wxMaService.post(AUDIT_BRAND, request);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditBrandResponse.class);
}
/**
* 上传类目资质(类目审核)
*
* @param request
* @return
* @throws WxErrorException
*/
@Override
public WxMaShopAuditCategoryResponse auditCategory(WxMaShopAuditCategoryRequest request) throws WxErrorException {
String responseContent = this.wxMaService.post(AUDIT_CATEGORY, request);
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditCategoryResponse.class);
}
/**
* 获取审核结果
*
* @param auditId
* @return WxMaShopAuditResultResponse
* @throws WxErrorException
*/
@Override
public WxMaShopAuditResultResponse getAuditResult(String auditId) throws WxErrorException {
String responseContent = this.wxMaService.post(AUDIT_RESULT, GsonHelper.buildJsonObject("audit_id", auditId));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaShopAuditResultResponse.class);
}
/**
* 获取小程序提交过的入驻资质信息
*
* @param reqType
* @return JsonObject
* @throws WxErrorException
*/
@Override
public JsonObject getMiniappCertificate(int reqType) throws WxErrorException {
String responseContent = this.wxMaService.post(GET_MINIAPP_CERTIFICATE, GsonHelper.buildJsonObject("req_type", reqType));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERRCODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, JsonObject.class);
}
}