🆕 【开放平台】接入小程序认证(年审)相关接口,同时增加公共的文件上传方法

This commit is contained in:
天朝红雨
2024-01-12 20:01:42 +08:00
committed by GitHub
parent d957896ac1
commit 774579186c
39 changed files with 1353 additions and 270 deletions

View File

@ -0,0 +1,82 @@
package me.chanjar.weixin.open.api;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.bean.auth.*;
/**
* 微信第三方平台 小程序认证接口 (年审)
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/product/weapp_wxverify.html
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
public interface WxOpenMaAuthService {
/**
* 1 小程程序认证
*/
String OPEN_MA_AUTH_SUBMIT = "https://api.weixin.qq.com/wxa/sec/wxaauth";
/**
* 2 小程程序认证任务进度查询.
*/
String OPEN_MA_AUTH_QUERY = "https://api.weixin.qq.com/wxa/sec/queryauth";
/**
* 3 小程序认证上传补充材料.
*/
String OPEN_MA_AUTH_UPLOAD = "https://api.weixin.qq.com/wxa/sec/uploadauthmaterial";
/**
* 4 小程序认证重新提审.
*/
String OPEN_MA_AUTH_RESUBMIT = "https://api.weixin.qq.com/wxa/sec/reauth";
/**
* 5 查询个人认证身份选项列表.
*/
String OPEN_MA_AUTH_IDENTITY = "https://api.weixin.qq.com/wxa/sec/authidentitytree";
/**
* 小程序认证(提审)
*
* @param param 参数
* @return 提交结果须保存任务ID 和 授权链接
*/
MaAuthSubmitResult submit(MaAuthSubmitParam param) throws WxErrorException;
/**
* 进度查询
*
* @param taskId 任务ID提交任务时返回
*/
MaAuthQueryResult query(String taskId) throws WxErrorException;
/**
* 上传补充材料
*
* @param data 上传数据仅支持png\jpeg\jpg\gif格式文件后缀名如果填写不对会导致上传失败建议写死1.jpg
*/
MaAuthUploadResult upload(CommonUploadData data) throws WxErrorException;
/**
* 重新提审
*
* @param param 参数
* @return 提交结果
*/
MaAuthSubmitResult resubmit(MaAuthResubmitParam param) throws WxErrorException;
/**
* 查询个人认证身份选项列表
*
* @return 职业身份认证树
*/
MaAuthQueryIdentityTreeResult queryIdentityTree() throws WxErrorException;
}

View File

@ -702,6 +702,13 @@ public interface WxOpenMaService extends WxMaService {
*/
WxOpenMaBasicService getBasicService();
/**
* 小程序认证(年审)服务
*
* @return 小程序认证(年审)服务
*/
WxOpenMaAuthService getAuthService();
/**
* 小程序用户隐私保护指引服务
*
@ -719,7 +726,7 @@ public interface WxOpenMaService extends WxMaService {
/**
* 小程序审核 提审素材上传接口
*
* @return
* @return 结果
*/
WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException;

View File

@ -0,0 +1,56 @@
package me.chanjar.weixin.open.api.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import kotlin.Pair;
import kotlin.collections.MapsKt;
import me.chanjar.weixin.common.bean.CommonUploadData;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenMaAuthService;
import me.chanjar.weixin.open.bean.auth.*;
/**
* 微信第三方平台 小程序认证接口 (年审)
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* Created on 2024/01/11
*/
public class WxOpenMaAuthServiceImpl implements WxOpenMaAuthService {
private final WxMaService wxMaService;
public WxOpenMaAuthServiceImpl(WxMaService wxMaService) {
this.wxMaService = wxMaService;
}
@Override
public MaAuthSubmitResult submit(MaAuthSubmitParam param) throws WxErrorException {
String response = wxMaService.post(OPEN_MA_AUTH_SUBMIT, param);
return WxMaGsonBuilder.create().fromJson(response, MaAuthSubmitResult.class);
}
@Override
public MaAuthQueryResult query(String taskId) throws WxErrorException {
String response = wxMaService.post(OPEN_MA_AUTH_QUERY, MapsKt.mapOf(new Pair<>("taskid", taskId)));
return WxMaGsonBuilder.create().fromJson(response, MaAuthQueryResult.class);
}
@Override
public MaAuthUploadResult upload(CommonUploadData data) throws WxErrorException {
String response = wxMaService.upload(OPEN_MA_AUTH_UPLOAD, new CommonUploadParam("media", data));
return WxMaGsonBuilder.create().fromJson(response, MaAuthUploadResult.class);
}
@Override
public MaAuthSubmitResult resubmit(MaAuthResubmitParam param) throws WxErrorException {
String response = wxMaService.post(OPEN_MA_AUTH_RESUBMIT, param);
return WxMaGsonBuilder.create().fromJson(response, MaAuthSubmitResult.class);
}
@Override
public MaAuthQueryIdentityTreeResult queryIdentityTree() throws WxErrorException {
String response = wxMaService.get(OPEN_MA_AUTH_IDENTITY, null);
return WxMaGsonBuilder.create().fromJson(response, MaAuthQueryIdentityTreeResult.class);
}
}

View File

@ -14,6 +14,7 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import lombok.Getter;
import me.chanjar.weixin.common.bean.CommonUploadParam;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.*;
import me.chanjar.weixin.open.bean.ma.WxMaPrefetchDomain;
@ -47,6 +48,8 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
@Getter
private final WxOpenMaBasicService basicService;
@Getter
private final WxOpenMaAuthService authService;
@Getter
private final WxOpenMaPrivacyService privacyService;
@Getter
private final WxOpenMaShoppingOrdersService shoppingOrdersService;
@ -56,6 +59,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
this.appId = appId;
this.wxMaConfig = wxMaConfig;
this.basicService = new WxOpenMaBasicServiceImpl(this);
this.authService = new WxOpenMaAuthServiceImpl(this);
this.privacyService = new WxOpenMaPrivacyServiceImpl(this);
this.shoppingOrdersService = new WxOpenMaShoppingOrdersServiceImpl(this);
initHttp();
@ -429,7 +433,9 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
@Override
public WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException {
return (WxMaAuditMediaUploadResult) this.execute(AuditMediaUploadRequestExecutor.create(getRequestHttp()), API_AUDIT_UPLOAD_MEDIA, file);
CommonUploadParam param = CommonUploadParam.fromFile("media", file);
String result = upload(API_AUDIT_UPLOAD_MEDIA, param);
return WxMaAuditMediaUploadResult.fromJson(result);
}
private JsonArray toJsonArray(List<String> strList) {

View File

@ -0,0 +1,29 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* 小程序认证 查询个人认证身份选项列表 响应
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Getter
@Setter
@NoArgsConstructor
public class MaAuthQueryIdentityTreeResult extends WxOpenResult {
/**
* 子节点信息 非叶子节点必有
*/
@Nullable
@SerializedName("node_list")
private List<MaAuthQueryIdentityTreeResultIdentityNode> nodeList;
}

View File

@ -0,0 +1,20 @@
package me.chanjar.weixin.open.bean.auth;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 职业身份叶子信息
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthQueryIdentityTreeResultIdentityLeaf {
/**
* 要求说明
*/
private String requirement;
}

View File

@ -0,0 +1,47 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* 职业身份 节点信息
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthQueryIdentityTreeResultIdentityNode {
/**
* 职业身份名
*/
@NotNull
private String name;
/**
* 职业身份节点ID
*/
@NotNull
@SerializedName("node_id")
private Integer nodeId;
/**
* 要求信息 叶子节点特有
*/
@Nullable
@SerializedName("leaf_info")
private MaAuthQueryIdentityTreeResultIdentityLeaf leafInfo;
/**
* 子节点信息 非叶子节点必有
*/
@Nullable
@SerializedName("node_list")
private List<MaAuthQueryIdentityTreeResultIdentityNode> nodeList;
}

View File

@ -0,0 +1,64 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 查询操作 响应
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Getter
@Setter
public class MaAuthQueryResult extends WxOpenResult {
/**
* 小程序ID
*/
@NotNull
@SerializedName("appid")
private String appId;
/**
* 状态 0初始 1超24小时 2用户拒绝 3用户同意 4发起人脸 5人脸失败 6人脸ok 7人脸认证后手机验证码 8手机验证失败 9手机验证成功 11创建审核单失败 12创建审核单成功 14验证失败 15等待支付
*/
@NotNull
@SerializedName("task_status")
private Integer taskStatus;
/**
* 授权链接
*/
@NotNull
@SerializedName("auth_url")
private String authUrl;
/**
* 审核单状态,创建审核单成功后有效 0审核单不存在 1待支付 2审核中 3打回重填 4认证通过 5认证最终失败不能再修改
*/
@SerializedName("apply_status")
private Integer applyStatus;
/**
* 小程序后台展示的认证订单号
*/
@SerializedName("orderid")
private String orderId;
/**
* 当审核单被打回重填(apply_status=3)时有效
*/
@SerializedName("refill_reason")
private String refillReason;
/**
* 审核最终失败的原因(apply_status=5)时有效
*/
@SerializedName("fail_reason")
private String failReason;
}

View File

@ -0,0 +1,36 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 查询操作 响应数据
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthQueryResultDispatchInfo {
/**
* 提供商,如:上海倍通企业信用征信有限公司
*/
@NotNull
private String provider;
/**
* 联系方式咨询电话0411-84947888咨询时间周一至周五工作日830-1730
*/
@NotNull
private String contact;
/**
* 派遣时间戳(秒)1704952913
*/
@NotNull
@SerializedName("dispatch_time")
private Integer dispatchTime;
}

View File

@ -0,0 +1,22 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 重新提交操作 参数
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
public class MaAuthResubmitParam {
/**
* 认证信息
*/
@NotNull
@SerializedName("auth_data")
private MaAuthResubmitParamAuthData authData;
}

View File

@ -0,0 +1,24 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 重新提交操作 认证参数
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Getter
@Setter
public class MaAuthResubmitParamAuthData extends MaAuthSubmitParamAuthData {
/**
* 认证任务id
*/
@NotNull
@SerializedName("taskid")
private String taskId;
}

View File

@ -0,0 +1,27 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 提交操作 参数
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParam {
/**
* 认证信息
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@NotNull
@SerializedName("auth_data")
private MaAuthSubmitParamAuthData authData;
}

View File

@ -0,0 +1,110 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
import java.util.List;
/**
* 小程序认证 提交操作 参数 数据
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParamAuthData {
/**
* 1企业 12个体户 15个人 参考:https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/basic-info-management/getAccountBasicInfo.html#realname-status-%E5%AE%9E%E5%90%8D%E8%AE%A4%E8%AF%81%E7%8A%B6%E6%80%81%E6%9E%9A%E4%B8%BE%E5%80%BC
*/
@NotNull
@SerializedName("customer_type")
private String customerType;
/**
* 联系人信息
*/
@NotNull
@SerializedName("contact_info")
private MaAuthSubmitParamContactInfo contactInfo;
/**
* 发票信息,如果是服务商代缴模式,不需要改参数
*/
@Nullable
@SerializedName("invoice_info")
private MaAuthSubmitParamInvoiceInfo invoiceInfo;
/**
* 非个人类型必填。主体资质材料 media_id 支持jpg,jpeg .bmp.gif .png格式仅支持一张图片
*/
@Nullable
private String qualification;
/**
* 主体资质其他证明材料 media_id 支持jpg,jpeg .bmp.gif .png格式最多上传10张图片
*/
@Nullable
@SerializedName("qualification_other")
private List<String> qualificationOther;
/**
* 小程序账号名称
*/
@NotNull
@SerializedName("account_name")
private String accountName;
/**
* 小程序账号名称命名类型 1基于自选词汇命名 2基于商标命名
*/
@NotNull
@SerializedName("account_name_type")
private Integer accountNameType;
/**
* 名称命中关键词-补充材料 media_id 支持jpg,jpeg .bmp.gif .png格式支持上传多张图片
*/
@Nullable
@SerializedName("account_supplemental")
private List<String> accountSupplemental;
/**
* 支付方式 1消耗服务商预购包 2小程序开发者自行支付
*/
@NotNull
@SerializedName("pay_type")
private String payType;
/**
* 认证类型为个人类型时可以选择要认证的身份,从/wxa/sec/authidentitytree 里获取填叶节点的name
*/
@Nullable
@SerializedName("auth_identification")
private String authIdentification;
/**
* 填了auth_identification则必填。身份证明材料 media_id 1基于不同认证身份上传不同的材料2认证类型=1时选填支持上传10张图片3支持jpg,jpeg .bmp.gif .png格式
*/
@Nullable
@SerializedName("auth_ident_material")
private String authIdentMaterial;
/**
* 第三方联系电话
*/
@NotNull
@SerializedName("third_party_phone")
private String thirdPartyPhone;
/**
* 选择服务商代缴模式时必填。服务市场appid
*/
@Nullable
@SerializedName("service_appid")
private String serviceAppid;
}

View File

@ -0,0 +1,28 @@
package me.chanjar.weixin.open.bean.auth;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
/**
* 联系人信息
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParamContactInfo {
/**
* 姓名
*/
@NotNull
private String name;
/**
* 邮箱
*/
@NotNull
private String email;
}

View File

@ -0,0 +1,29 @@
package me.chanjar.weixin.open.bean.auth;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
/**
* 发票 - 电子发票
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParamInvoiceElectronic {
/**
* 纳税识别号15位、17、18或20位
*/
@NotNull
private String id;
/**
* 发票备注(选填)
*/
@Nullable
private String desc;
}

View File

@ -0,0 +1,44 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
/**
* 发票信息
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParamInvoiceInfo {
/**
* 发票类型 1: 不开发票 2: 电子发票 3: 增值税专票
*/
@NotNull
@SerializedName("invoice_type")
private Integer invoiceType;
/**
* 发票类型=2时必填 电子发票开票信息
*/
@Nullable
private MaAuthSubmitParamInvoiceElectronic electronic;
/**
* 发票类型=3时必填 增值税专票开票信息
*/
@Nullable
private MaAuthSubmitParamInvoiceVat vat;
/**
* 发票抬头,发票类型!=1时必填 需要和认证主体名称一样
*/
@Nullable
@SerializedName("invoice_title")
private String invoiceTitle;
}

View File

@ -0,0 +1,102 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.lang.Nullable;
/**
* 发票 - 增值税专票
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Data
@NoArgsConstructor
public class MaAuthSubmitParamInvoiceVat {
/**
* 企业电话
*/
@NotNull
@SerializedName("enterprise_phone")
private String enterprisePhone;
/**
* 纳税识别号15位、17、18或20位
*/
@NotNull
private String id;
/**
* 企业注册地址
*/
@NotNull
@SerializedName("enterprise_address")
private String enterpriseAddress;
/**
* 企业开户银行
*/
@NotNull
@SerializedName("bank_name")
private String bankName;
/**
* 企业银行账号
*/
@NotNull
@SerializedName("bank_account")
private String bankAccount;
/**
* 发票邮寄地址邮编
*/
@NotNull
@SerializedName("mailing_address")
private String mailingAddress;
/**
* 街道地址
*/
@NotNull
private String address;
/**
* 联系人
*/
@NotNull
private String name;
/**
* 联系电话
*/
@NotNull
private String phone;
/**
* 省份
*/
@NotNull
private String province;
/**
* 城市
*/
@NotNull
private String city;
/**
* 县区
*/
@NotNull
private String district;
/**
* 发票备注(选填)
*/
@Nullable
private String desc;
}

View File

@ -0,0 +1,34 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 提交操作 响应
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Getter
@Setter
@NoArgsConstructor
public class MaAuthSubmitResult extends WxOpenResult {
/**
* 任务ID
*/
@NotNull
@SerializedName("taskid")
private String taskId;
/**
* 小程序管理员授权链接
*/
@NotNull
@SerializedName("auth_url")
private String authUrl;
}

View File

@ -0,0 +1,27 @@
package me.chanjar.weixin.open.bean.auth;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import org.jetbrains.annotations.NotNull;
/**
* 小程序认证 上传补充材料操作 响应
*
* @author <a href="https://www.sacoc.cn">广州跨界</a>
* created on 2024/01/11
*/
@Getter
@Setter
@NoArgsConstructor
public class MaAuthUploadResult extends WxOpenResult {
/**
* 媒体ID
*/
@NotNull
@SerializedName("mediaid")
private String mediaId;
}