Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序自定义组件之接入商品前必需接口 #2255

Merged
merged 8 commits into from
Aug 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ public interface WxMaService extends WxService {
*/
WxMaShopImgService getShopImgService();

/**
* 小程序交易组件-接入商品前必需接口-审核相关接口
*
* @return
*/
WxMaShopAuditService getShopAuditService();

/**
* 获取小程序 URL Link服务接口
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -540,6 +541,11 @@ public WxMaShopImgService getShopImgService() {
return this.shopImgService;
}

@Override
public WxMaShopAuditService getShopAuditService() {
return this.shopAuditService;
}

@Override
public WxMaLinkService getLinkService() {
return this.linkService;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package cn.binarywang.wx.miniapp.bean.shop.request;

import com.google.gson.annotations.SerializedName;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
* @author liming1019
* @date 2021/8/12
*/
@Data
@Builder
public class WxMaShopAuditBrandRequest implements Serializable {
private static final long serialVersionUID = -969331692973992066L;

/**
* audit_req : {"license":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"brand_info":{"brand_audit_type":1,"trademark_type":"29","brand_management_type":2,"commodity_origin_type":2,"brand_wording":"346225226351203275","sale_authorization":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registration_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_change_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registrant":"https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg","trademark_registrant_nu":"1249305","trademark_authorization_period":"2020-03-25 12:05:25","trademark_registration_application":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_applicant":"张三","trademark_application_time":"2020-03-25 12:05:25","imported_goods_form":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]}}
*/

@SerializedName("audit_req")
private AuditReqBean auditReq;

@Data
@Builder
public static class AuditReqBean implements Serializable {
/**
* license : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
* brand_info : {"brand_audit_type":1,"trademark_type":"29","brand_management_type":2,"commodity_origin_type":2,"brand_wording":"346225226351203275","sale_authorization":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registration_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_change_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registrant":"https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg","trademark_registrant_nu":"1249305","trademark_authorization_period":"2020-03-25 12:05:25","trademark_registration_application":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_applicant":"张三","trademark_application_time":"2020-03-25 12:05:25","imported_goods_form":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]}
*/

@SerializedName("brand_info")
private BrandInfoBean brandInfo;
@SerializedName("license")
private List<String> license;

@Data
@Builder
public static class BrandInfoBean implements Serializable {
/**
* brand_audit_type : 1
* trademark_type : 29
* brand_management_type : 2
* commodity_origin_type : 2
* brand_wording : 346225226351203275
* sale_authorization : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
* trademark_registration_certificate : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
* trademark_change_certificate : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
* trademark_registrant : https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg
* trademark_registrant_nu : 1249305
* trademark_authorization_period : 2020-03-25 12:05:25
* trademark_registration_application : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
* trademark_applicant : 张三
* trademark_application_time : 2020-03-25 12:05:25
* imported_goods_form : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]
*/

@SerializedName("brand_audit_type")
private Integer brandAuditType;
@SerializedName("trademark_type")
private String trademarkType;
@SerializedName("brand_management_type")
private Integer brandManagementType;
@SerializedName("commodity_origin_type")
private Integer commodityOriginType;
@SerializedName("brand_wording")
private String brandWording;
@SerializedName("trademark_registrant")
private String trademarkRegistrant;
@SerializedName("trademark_registrant_nu")
private String trademarkRegistrantNu;
@SerializedName("trademark_authorization_period")
private String trademarkAuthorizationPeriod;
@SerializedName("trademark_applicant")
private String trademarkApplicant;
@SerializedName("trademark_application_time")
private String trademarkApplicationTime;
@SerializedName("sale_authorization")
private List<String> saleAuthorization;
@SerializedName("trademark_registration_certificate")
private List<String> trademarkRegistrationCertificate;
@SerializedName("trademark_change_certificate")
private List<String> trademarkChangeCertificate;
@SerializedName("trademark_registration_application")
private List<String> trademarkRegistrationApplication;
@SerializedName("imported_goods_form")
private List<String> importedGoodsForm;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package cn.binarywang.wx.miniapp.bean.shop.request;

import com.google.gson.annotations.SerializedName;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
* @author liming1019
* @date 2021/8/12
*/
@Data
@Builder
public class WxMaShopAuditCategoryRequest implements Serializable {
private static final long serialVersionUID = -6730876344556487071L;

/**
* audit_req : {"license":["www.xxxxx.com"],"category_info":{"level1":7419,"level2":7439,"level3":7448,"certificate":["www.xxx.com"]}}
*/

@SerializedName("audit_req")
private AuditReqBean auditReq;

@Data
@Builder
public static class AuditReqBean implements Serializable {
/**
* license : ["www.xxxxx.com"]
* category_info : {"level1":7419,"level2":7439,"level3":7448,"certificate":["www.xxx.com"]}
*/

@SerializedName("category_info")
private CategoryInfoBean categoryInfo;
@SerializedName("license")
private List<String> license;

@Data
@Builder
public static class CategoryInfoBean implements Serializable {
/**
* level1 : 7419
* level2 : 7439
* level3 : 7448
* certificate : ["www.xxx.com"]
*/

@SerializedName("level1")
private Integer level1;
@SerializedName("level2")
private Integer level2;
@SerializedName("level3")
private Integer level3;
@SerializedName("certificate")
private List<String> certificate;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/12
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMaShopAuditBrandResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = -4643316662725276237L;

@SerializedName("audit_id")
private String auditId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cn.binarywang.wx.miniapp.bean.shop.response;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
* @author liming1019
* @date 2021/8/12
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxMaShopAuditCategoryResponse extends WxMaShopBaseResponse implements Serializable {
private static final long serialVersionUID = -1822188134865177738L;

@SerializedName("audit_id")
private String auditId;
}
Loading