1
1
package me .chanjar .weixin .cp .tp .service .impl ;
2
2
3
+ import com .google .gson .JsonArray ;
3
4
import com .google .gson .JsonObject ;
5
+ import com .google .gson .JsonPrimitive ;
4
6
import lombok .RequiredArgsConstructor ;
5
7
import me .chanjar .weixin .common .error .WxErrorException ;
8
+ import me .chanjar .weixin .cp .bean .WxCpTpConvertTmpExternalUserIdResult ;
9
+ import me .chanjar .weixin .cp .bean .WxCpTpOpenKfIdConvertResult ;
10
+ import me .chanjar .weixin .cp .bean .WxCpTpTagIdListConvertResult ;
6
11
import me .chanjar .weixin .cp .bean .WxCpTpUnionidToExternalUseridResult ;
7
12
import me .chanjar .weixin .cp .config .WxCpTpConfigStorage ;
13
+ import me .chanjar .weixin .cp .constant .WxCpApiPathConsts ;
8
14
import me .chanjar .weixin .cp .tp .service .WxCpTpIdConvertService ;
9
15
import me .chanjar .weixin .cp .tp .service .WxCpTpService ;
10
16
17
+ import java .util .List ;
18
+
11
19
12
20
/**
13
21
* @author cocoa
@@ -26,11 +34,57 @@ public WxCpTpUnionidToExternalUseridResult unionidToExternalUserid(String cropId
26
34
}
27
35
WxCpTpConfigStorage wxCpTpConfigStorage = mainService .getWxCpTpConfigStorage ();
28
36
String accessToken = wxCpTpConfigStorage .getAccessToken (cropId );
29
- String url = wxCpTpConfigStorage .getApiUrl ("/cgi-bin/idconvert/unionid_to_external_userid" );
37
+ String url = wxCpTpConfigStorage .getApiUrl (WxCpApiPathConsts . IdConvert . UNION_ID_TO_EXTERNAL_USER_ID );
30
38
url += "?access_token=" + accessToken ;
31
39
String responseContent = this .mainService .post (url , json .toString ());
32
40
return WxCpTpUnionidToExternalUseridResult .fromJson (responseContent );
33
41
}
34
42
43
+ @ Override
44
+ public WxCpTpTagIdListConvertResult externalTagId (String corpId , String ... externalTagIdList ) throws WxErrorException {
45
+ WxCpTpConfigStorage wxCpTpConfigStorage = mainService .getWxCpTpConfigStorage ();
46
+ String url = wxCpTpConfigStorage .getApiUrl (WxCpApiPathConsts .IdConvert .EXTERNAL_TAG_ID ) + "?access_token=" + mainService .getWxCpTpConfigStorage ().getAccessToken (corpId );
47
+
48
+ JsonObject jsonObject = new JsonObject ();
49
+ JsonArray jsonArray = new JsonArray ();
50
+ for (String tagId : externalTagIdList ) {
51
+ jsonArray .add (new JsonPrimitive (tagId ));
52
+ }
53
+ jsonObject .add ("external_tagid_list" , jsonArray );
54
+ String responseContent = this .mainService .post (url , jsonObject .toString ());
55
+
56
+ return WxCpTpTagIdListConvertResult .fromJson (responseContent );
57
+ }
58
+
59
+ @ Override
60
+ public WxCpTpOpenKfIdConvertResult ConvertOpenKfId (String corpId , String ... openKfIdList ) throws WxErrorException {
61
+ WxCpTpConfigStorage wxCpTpConfigStorage = mainService .getWxCpTpConfigStorage ();
62
+ String url = wxCpTpConfigStorage .getApiUrl (WxCpApiPathConsts .IdConvert .OPEN_KF_ID + "?access_token=" + mainService .getWxCpTpConfigStorage ().getAccessToken (corpId ));
63
+ JsonObject jsonObject = new JsonObject ();
64
+ JsonArray jsonArray = new JsonArray ();
65
+ for (String kfId : openKfIdList ) {
66
+ jsonArray .add (new JsonPrimitive (kfId ));
67
+ }
68
+ jsonObject .add ("open_kfid_list" , jsonArray );
69
+ String responseContent = this .mainService .post (url , jsonObject .toString ());
70
+ return WxCpTpOpenKfIdConvertResult .fromJson (responseContent );
71
+ }
72
+
73
+ @ Override
74
+ public WxCpTpConvertTmpExternalUserIdResult convertTmpExternalUserId (String corpId , int businessType , int userType , String ... tmpExternalUserIdList ) throws WxErrorException {
75
+ WxCpTpConfigStorage wxCpTpConfigStorage = mainService .getWxCpTpConfigStorage ();
76
+ String url = wxCpTpConfigStorage .getApiUrl (WxCpApiPathConsts .IdConvert .CONVERT_TMP_EXTERNAL_USER_ID + "?access_token=" + mainService .getWxCpTpConfigStorage ().getAccessToken (corpId ));
77
+ JsonObject jsonObject = new JsonObject ();
78
+ JsonArray jsonArray = new JsonArray ();
79
+ jsonObject .addProperty ("business_type" , businessType );
80
+ jsonObject .addProperty ("user_type" , userType );
81
+ for (String userId : tmpExternalUserIdList ) {
82
+ jsonArray .add (new JsonPrimitive (userId ));
83
+ }
84
+ jsonObject .add ("tmp_external_userid_list" , jsonArray );
85
+ String responseContent = mainService .post (url , jsonObject .toString ());
86
+ return WxCpTpConvertTmpExternalUserIdResult .fromJson (responseContent );
87
+ }
88
+
35
89
36
90
}
0 commit comments