add
yj
2024-12-05 b9900893177c78fc559223521fe839aa21000017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
package com.dobbinsoft.fw.pay.client;
 
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.AlipayConstants;
import com.alipay.easysdk.kernel.Client;
import com.alipay.easysdk.kernel.Config;
import com.alipay.easysdk.kernel.Context;
import com.alipay.easysdk.kms.aliyun.AliyunKMSClient;
import com.alipay.easysdk.kms.aliyun.AliyunKMSSigner;
import com.aliyun.tea.TeaModel;
 
public class AliClient {
 
    public Payment payment = new Payment();
 
    public Base base = new Base();
 
    public Marketing marketing = new Marketing();
 
    public Member member = new Member();
 
    public Security security = new Security();
 
    public Util util = new Util();
 
    /**
     * 将一些初始化耗时较多的信息缓存在上下文中
     */
    private Context context;
 
    private Config config;
 
    public AliClient(Config options) {
        try {
            this.config = options;
            this.context = new Context(options, Factory.SDK_VERSION);
            if (AlipayConstants.AliyunKMS.equals(context.getConfig(AlipayConstants.SIGN_PROVIDER_CONFIG_KEY))) {
                context.setSigner(new AliyunKMSSigner(new AliyunKMSClient(TeaModel.buildMap(options))));
            }
 
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
 
    /**
     * 支付能力相关
     */
    public class Payment {
        /**
         * 获取支付通用API Client
         *
         * @return 支付通用API Client
         */
        public com.alipay.easysdk.payment.common.Client Common() throws Exception {
            return new com.alipay.easysdk.payment.common.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.common.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
 
        /**
         * 获取花呗相关API Client
         *
         * @return 花呗相关API Client
         */
        public com.alipay.easysdk.payment.huabei.Client Huabei() throws Exception {
            return new com.alipay.easysdk.payment.huabei.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.huabei.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
 
        /**
         * 获取当面付相关API Client
         *
         * @return 当面付相关API Client
         */
        public com.alipay.easysdk.payment.facetoface.Client FaceToFace() throws Exception {
            return new com.alipay.easysdk.payment.facetoface.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.facetoface.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
 
        /**
         * 获取电脑网站支付相关API Client
         *
         * @return 电脑网站支付相关API Client
         */
        public com.alipay.easysdk.payment.page.Client Page() throws Exception {
            return new com.alipay.easysdk.payment.page.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.page.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
 
        /**
         * 获取手机网站支付相关API Client
         *
         * @return 手机网站支付相关API Client
         */
        public com.alipay.easysdk.payment.wap.Client Wap() throws Exception {
            return new com.alipay.easysdk.payment.wap.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.wap.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
 
        /**
         * 获取手机APP支付相关API Client
         *
         * @return 手机APP支付相关API Client
         */
        public com.alipay.easysdk.payment.app.Client App() throws Exception {
            return new com.alipay.easysdk.payment.app.Client(new Client(AliClient.this.context)) {
                @Override
                public com.alipay.easysdk.payment.app.Client optional(String key, Object value) {
                    if (value != null) {
                        return this;
                    }
                    return super.optional(key, value);
                }
            };
        }
    }
 
    /**
     * 基础能力相关
     */
    public class Base {
        /**
         * 获取图片相关API Client
         *
         * @return 图片相关API Client
         */
        public com.alipay.easysdk.base.image.Client Image() throws Exception {
            return new com.alipay.easysdk.base.image.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取视频相关API Client
         *
         * @return 视频相关API Client
         */
        public com.alipay.easysdk.base.video.Client Video() throws Exception {
            return new com.alipay.easysdk.base.video.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取OAuth认证相关API Client
         *
         * @return OAuth认证相关API Client
         */
        public com.alipay.easysdk.base.oauth.Client OAuth() throws Exception {
            return new com.alipay.easysdk.base.oauth.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取小程序二维码相关API Client
         *
         * @return 小程序二维码相关API Client
         */
        public com.alipay.easysdk.base.qrcode.Client Qrcode() throws Exception {
            return new com.alipay.easysdk.base.qrcode.Client(new Client(AliClient.this.context));
        }
    }
 
    /**
     * 营销能力相关
     */
    public class Marketing {
        /**
         * 获取生活号相关API Client
         *
         * @return 生活号相关API Client
         */
        public com.alipay.easysdk.marketing.openlife.Client OpenLife() throws Exception {
            return new com.alipay.easysdk.marketing.openlife.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取支付宝卡包相关API Client
         *
         * @return 支付宝卡包相关API Client
         */
        public com.alipay.easysdk.marketing.pass.Client Pass() throws Exception {
            return new com.alipay.easysdk.marketing.pass.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取小程序模板消息相关API Client
         *
         * @return 小程序模板消息相关API Client
         */
        public com.alipay.easysdk.marketing.templatemessage.Client TemplateMessage() throws Exception {
            return new com.alipay.easysdk.marketing.templatemessage.Client(new Client(AliClient.this.context));
        }
    }
 
    /**
     * 会员能力相关
     */
    public class Member {
        /**
         * 获取支付宝身份认证相关API Client
         *
         * @return 支付宝身份认证相关API Client
         */
        public com.alipay.easysdk.member.identification.Client Identification() throws Exception {
            return new com.alipay.easysdk.member.identification.Client(new Client(AliClient.this.context));
        }
    }
 
    /**
     * 安全能力相关
     */
    public class Security {
        /**
         * 获取文本风险识别相关API Client
         *
         * @return 文本风险识别相关API Client
         */
        public com.alipay.easysdk.security.textrisk.Client TextRisk() throws Exception {
            return new com.alipay.easysdk.security.textrisk.Client(new Client(AliClient.this.context));
        }
    }
 
    /**
     * 辅助工具
     */
    public class Util {
        /**
         * 获取OpenAPI通用接口,可通过自行拼装参数,调用几乎所有OpenAPI
         *
         * @return OpenAPI通用接口
         */
        public com.alipay.easysdk.util.generic.Client Generic() throws Exception {
            return new com.alipay.easysdk.util.generic.Client(new Client(AliClient.this.context));
        }
 
        /**
         * 获取AES128加解密相关API Client,常用于会员手机号的解密
         *
         * @return AES128加解密相关API Client
         */
        public com.alipay.easysdk.util.aes.Client AES() throws Exception {
            return new com.alipay.easysdk.util.aes.Client(new Client(AliClient.this.context));
        }
    }
 
    public Config getConfig() {
        return config;
    }
}