Skip to content

Commit 5ece315

Browse files
Molzxbinarywang
authored andcommitted
🆕 #3455 【开放平台】增加小程序认证及备案相关接口
1 parent 29a76bc commit 5ece315

9 files changed

+259
-2
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaIcpService.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ public interface WxOpenMaIcpService {
9797
*/
9898
String GET_ICP_MEDIA = "https://api.weixin.qq.com/wxa/icp/get_icp_media";
9999

100+
/**
101+
* 申请小程序认证及备案
102+
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/wxverifyicp/submitAuthAndIcp.html
103+
*/
104+
String SUBMIT_AUTH_AND_ICP = "https://api.weixin.qq.com/wxa/sec/submit_auth_and_icp";
105+
106+
/**
107+
* 查询小程序认证及备案进度
108+
* https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/wxverifyicp/queryAuthAndIcp.html
109+
*/
110+
String QUERY_AUTH_AND_ICP = "https://api.weixin.qq.com/wxa/sec/query_auth_and_icp";
111+
112+
100113
/**
101114
* 查询人脸核身任务状态
102115
*
@@ -114,6 +127,15 @@ public interface WxOpenMaIcpService {
114127
*/
115128
WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask() throws WxErrorException;
116129

130+
/**
131+
* 发起小程序管理员人脸核身
132+
*
133+
* @param alongWithAuth 小程序认证及备案二合一场景,填 true,否则为小程序备案场景。默认值为 false。
134+
* @return 人脸核验任务结果
135+
* @throws WxErrorException e
136+
*/
137+
WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask(boolean alongWithAuth) throws WxErrorException;
138+
117139
/**
118140
* 上传小程序备案媒体材料
119141
*
@@ -204,4 +226,22 @@ public interface WxOpenMaIcpService {
204226
* @throws WxErrorException e
205227
*/
206228
File getIcpMedia(String mediaId) throws WxErrorException;
229+
230+
/**
231+
* 申请小程序认证及备案
232+
*
233+
* @param param 参数
234+
* @return r
235+
* @throws WxErrorException e
236+
*/
237+
WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException;
238+
239+
/**
240+
* 查询小程序认证及备案进度
241+
* @param procedureId 小程序认证及备案任务流程id
242+
* @return r
243+
* @throws WxErrorException e
244+
*/
245+
WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException;
246+
207247
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaIcpServiceImpl.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,21 @@ public WxOpenIcpVerifyTaskResult queryIcpVerifyTask(String taskId) throws WxErro
5454
*/
5555
@Override
5656
public WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask() throws WxErrorException {
57-
String response = wxMaService.post(CREATE_ICP_VERIFY_TASK, "");
57+
return createIcpVerifyTask(false);
58+
}
59+
60+
/**
61+
* 发起小程序管理员人脸核身
62+
*
63+
* @param alongWithAuth 小程序认证及备案二合一场景,填 true,否则为小程序备案场景。默认值为 false。
64+
* @return 人脸核验任务结果
65+
* @throws WxErrorException e
66+
*/
67+
@Override
68+
public WxOpenIcpCreateIcpVerifyTaskResult createIcpVerifyTask(boolean alongWithAuth) throws WxErrorException {
69+
JsonObject params = new JsonObject();
70+
params.addProperty("along_with_auth", alongWithAuth);
71+
String response = wxMaService.post(CREATE_ICP_VERIFY_TASK, params);
5872
return WxMaGsonBuilder.create().fromJson(response, WxOpenIcpCreateIcpVerifyTaskResult.class);
5973
}
6074

@@ -212,4 +226,32 @@ public File getIcpMedia(String mediaId) throws WxErrorException {
212226
throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e);
213227
}
214228
}
229+
230+
/**
231+
* 申请小程序认证及备案
232+
*
233+
* @param param 参数
234+
* @return r
235+
* @throws WxErrorException e
236+
*/
237+
@Override
238+
public WxOpenSubmitAuthAndIcpResult submitAuthAndIcp(WxOpenSubmitAuthAndIcpParam param) throws WxErrorException {
239+
String response = wxMaService.post(SUBMIT_AUTH_AND_ICP, param);
240+
return WxMaGsonBuilder.create().fromJson(response, WxOpenSubmitAuthAndIcpResult.class);
241+
}
242+
243+
/**
244+
* 查询小程序认证及备案进度
245+
*
246+
* @param procedureId 小程序认证及备案任务流程id
247+
* @return r
248+
* @throws WxErrorException e
249+
*/
250+
@Override
251+
public WxOpenQueryAuthAndIcpResult queryAuthAndIcp(String procedureId) throws WxErrorException {
252+
JsonObject params = new JsonObject();
253+
params.addProperty("procedure_id", procedureId);
254+
String response = wxMaService.post(QUERY_AUTH_AND_ICP, params);
255+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenQueryAuthAndIcpResult.class);
256+
}
215257
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/icp/WxOpenApplyIcpFilingParam.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.gson.annotations.SerializedName;
44
import lombok.*;
5+
import lombok.experimental.SuperBuilder;
56

67
import java.io.Serializable;
78
import java.util.List;
@@ -12,7 +13,7 @@
1213
* @createTime 2024/08/14 15:09
1314
*/
1415
@Data
15-
@Builder
16+
@SuperBuilder
1617
@NoArgsConstructor
1718
@AllArgsConstructor
1819
public class WxOpenApplyIcpFilingParam implements Serializable {

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/icp/WxOpenIcpCreateIcpVerifyTaskResult.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ public class WxOpenIcpCreateIcpVerifyTaskResult extends WxOpenResult {
2626
@SerializedName("task_id")
2727
private String taskId;
2828

29+
/**
30+
* 人脸核验任务url,along_with_auth 填 true 时返回。
31+
*/
32+
@SerializedName("verify_url")
33+
private String verifyUrl;
2934
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/icp/WxOpenIcpVerifyTaskResult.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ public class WxOpenIcpVerifyTaskResult extends WxOpenResult {
3030
*/
3131
@SerializedName("face_status")
3232
private Integer faceStatus;
33+
34+
/**
35+
* 发起时 along_with_auth 填 true 时有效:9. 认证短信核验通过。
36+
*/
37+
@SerializedName("along_with_auth_result")
38+
private Integer alongWithAuthResult;
3339
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package me.chanjar.weixin.open.bean.icp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.*;
5+
import me.chanjar.weixin.open.bean.result.WxOpenResult;
6+
7+
import java.util.List;
8+
9+
/**
10+
* @author xzh
11+
* @Description
12+
* @createTime 2024/12/19 16:56
13+
*/
14+
@Getter
15+
@Setter
16+
@NoArgsConstructor
17+
public class WxOpenQueryAuthAndIcpResult extends WxOpenResult {
18+
private static final long serialVersionUID = 1626895037788760364L;
19+
20+
21+
/**
22+
* 当前任务流程状态,见下方任务流程状态枚举
23+
* 值 含义
24+
* 15 等待支付认证审核费用
25+
* 16 认证审核费用支付成功
26+
* 17 认证审核中
27+
* 18 认证审核驳回
28+
* 19 认证审核通过
29+
* 20 认证审核最终失败(不能再修改)
30+
* 21 创建备案审核单失败
31+
* 22 备案平台审核中
32+
* 23 备案平台审核驳回
33+
* 24 备案管局审核中
34+
* 25 管局审核驳回
35+
* 26 认证及备案完成
36+
*/
37+
@SerializedName("procedure_status")
38+
private Integer procedureStatus;
39+
40+
/**
41+
* 小程序后台展示的认证订单号
42+
*/
43+
@SerializedName("orderid")
44+
private Long orderId;
45+
46+
/**
47+
* 小程序认证审核单被驳回(procedure_status 为 18)时有效
48+
*/
49+
@SerializedName("refill_reason")
50+
private String refillReason;
51+
/**
52+
* 小程序认证审核最终失败的原因(procedure_status 为 20)时有效
53+
*/
54+
@SerializedName("fail_reason")
55+
private String failReason;
56+
57+
/**
58+
* 小程序备案相关信息
59+
*/
60+
@SerializedName("icp_audit")
61+
private IcpAudit icpAudit;
62+
63+
@Data
64+
public static class IcpAudit {
65+
66+
/**
67+
* 错误提示,创建备案审核单失败时返回(procedure_status 为 21)
68+
*/
69+
@SerializedName("hints")
70+
private List<WxOpenApplyIcpFilingResult.Hint> hints;
71+
72+
/**
73+
* 驳回原因,备案不通过时返回(procedure_status 为 23、25)
74+
*/
75+
@SerializedName("audit_data")
76+
private List<WxOpenIcpEntranceInfoResult.AuditData> auditData;
77+
78+
/**
79+
* 管局短信核验状态,仅当任务流程状态为 24(备案管局审核中)的时候才有效。1:等待核验中,2:核验完成,3:核验超时。
80+
*/
81+
@SerializedName("sms_verify_status")
82+
private Integer smsVerifyStatus;
83+
}
84+
85+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package me.chanjar.weixin.open.bean.icp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
import lombok.experimental.SuperBuilder;
8+
import me.chanjar.weixin.open.bean.auth.MaAuthSubmitParamAuthData;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
/**
12+
* @author xzh
13+
* @Description
14+
* @createTime 2024/12/19 16:42
15+
*/
16+
@Data
17+
@SuperBuilder
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
public class WxOpenSubmitAuthAndIcpParam extends WxOpenApplyIcpFilingParam {
21+
private static final long serialVersionUID = -1302523168779484802L;
22+
23+
/**
24+
* 认证信息
25+
*/
26+
@NotNull
27+
@SerializedName("auth_data")
28+
private MaAuthSubmitParamAuthData authData;
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.chanjar.weixin.open.bean.icp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
import lombok.Setter;
7+
8+
/**
9+
* @author xzh
10+
* @Description
11+
* @createTime 2024/12/19 16:47
12+
*/
13+
@Getter
14+
@Setter
15+
@NoArgsConstructor
16+
public class WxOpenSubmitAuthAndIcpResult extends WxOpenApplyIcpFilingResult {
17+
private static final long serialVersionUID = 2338143380820535842L;
18+
19+
/**
20+
* 小程序认证及备案任务流程 id
21+
*/
22+
@SerializedName("procedure_id")
23+
private String procedureId;
24+
25+
/**
26+
* 小程序认证认证审核费用付费链接,当 pay_type 为 2 时返回
27+
*/
28+
@SerializedName("pay_url")
29+
private String payUrl;
30+
}

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ public class WxOpenXmlMessage implements Serializable {
140140
*/
141141
@XStreamAlias("result")
142142
private Integer result;
143+
/**
144+
* 发起时 along_with_auth 填 true 时有效:9. 认证短信核验通过。
145+
*/
146+
@XStreamAlias("along_with_auth_result")
147+
private Integer alongWithAuthResult;
143148
//endregion
144149

145150
//region 当备案审核被驳回或通过时会推送该事件 推送的消息 infoType=notify_apply_icpfiling_result
@@ -155,6 +160,20 @@ public class WxOpenXmlMessage implements Serializable {
155160
private Integer beianStatus;
156161
//endregion
157162

163+
//region 认证及备案流程的主要节点均有事件推送到第三方平台的授权事件接收接口,包括支付完成、派单给审核机构、审核打回、审核通过、审核失败等。消息类型,固定为 notify_3rd_wxa_auth_and_icp
164+
165+
/**
166+
* 小程序认证及备案任务流程 id
167+
*/
168+
@XStreamAlias("procedure_id")
169+
private String procedureId;
170+
/**
171+
* 当前任务流程状态,见“小程序认证及备案进度查询” API 文档中的任务流程状态枚举
172+
*/
173+
@XStreamAlias("procedure_status")
174+
private Integer procedureStatus;
175+
//endregion
176+
158177
/**
159178
* 快速创建的小程序appId,已弃用,未来将删除
160179
*

0 commit comments

Comments
 (0)