chengkun
2025-09-15 3c9050e82e582414dc7b208c8283fe47be37eeba
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
<?php
 
namespace Alipay\EasySDK\Kernel;
 
use Alipay\EasySDK\Base\Image\Client as imageClient;
use Alipay\EasySDK\Base\OAuth\Client as oauthClient;
use Alipay\EasySDK\Base\Qrcode\Client as qrcodeClient;
use Alipay\EasySDK\Base\Video\Client as videoClient;
use Alipay\EasySDK\Marketing\OpenLife\Client as openLifeClient;
use Alipay\EasySDK\Marketing\Pass\Client as passClient;
use Alipay\EasySDK\Marketing\TemplateMessage\Client as templateMessageClient;
use Alipay\EasySDK\Member\Identification\Client as identificationClient;
use Alipay\EasySDK\Payment\App\Client as appClient;
use Alipay\EasySDK\Payment\Common\Client as commonClient;
use Alipay\EasySDK\Payment\FaceToFace\Client as faceToFaceClient;
use Alipay\EasySDK\Payment\Huabei\Client as huabeiClient;
use Alipay\EasySDK\Payment\Page\Client as pageClient;
use Alipay\EasySDK\Payment\Wap\Client as wapClient;
use Alipay\EasySDK\Security\TextRisk\Client as textRiskClient;
use Alipay\EasySDK\Util\Generic\Client as genericClient;
use Alipay\EasySDK\Util\AES\Client as aesClient;
 
/**
 * 多账号实例使用
 * Class MultipleFactory
 * @package Alipay\EasySDK\Kernel
 */
class MultipleFactory
{
    public $config = null;
    public $kernel = null;
    private static $instance;
    protected static $base;
    protected static $marketing;
    protected static $member;
    protected static $payment;
    protected static $security;
    protected static $util;
 
    private function __construct($config)
    {
        if (!empty($config->alipayCertPath)) {
            $certEnvironment = new CertEnvironment();
            $certEnvironment->certEnvironment(
                $config->merchantCertPath,
                $config->alipayCertPath,
                $config->alipayRootCertPath
            );
            $config->merchantCertSN = $certEnvironment->getMerchantCertSN();
            $config->alipayRootCertSN = $certEnvironment->getRootCertSN();
            $config->alipayPublicKey = $certEnvironment->getCachedAlipayPublicKey();
        }
 
        $kernel = new EasySDKKernel($config);
        self::$base = new Base($kernel);
        self::$marketing = new Marketing($kernel);
        self::$member = new Member($kernel);
        self::$payment = new Payment($kernel);
        self::$security = new Security($kernel);
        self::$util = new Util($kernel);
    }
 
    public static function setOptions($config)
    {
        self::$instance = new self($config);
        return self::$instance;
    }
 
    private function __clone()
    {
    }
 
    public static function base()
    {
        return self::$base;
    }
 
    public static function marketing()
    {
        return self::$marketing;
    }
 
    public static function member()
    {
        return self::$member;
    }
 
    public static function payment()
    {
        return self::$payment;
    }
 
    public static function security()
    {
        return self::$security;
    }
 
    public static function util()
    {
        return self::$util;
    }
}
 
 
class Base
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function image()
    {
        return new imageClient($this->kernel);
    }
 
    public function oauth()
    {
        return new oauthClient($this->kernel);
    }
 
    public function qrcode()
    {
        return new qrcodeClient($this->kernel);
    }
 
    public function video()
    {
        return new videoClient($this->kernel);
    }
}
 
class Marketing
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function openLife()
    {
        return new openLifeClient($this->kernel);
    }
 
    public function pass()
    {
        return new passClient($this->kernel);
    }
 
    public function templateMessage()
    {
        return new templateMessageClient($this->kernel);
    }
}
 
class Member
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function identification()
    {
        return new identificationClient($this->kernel);
    }
}
 
class Payment
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function app()
    {
        return new appClient($this->kernel);
    }
 
    public function common()
    {
        return new commonClient($this->kernel);
    }
 
    public function faceToFace()
    {
        return new faceToFaceClient($this->kernel);
    }
 
    public function huabei()
    {
        return new huabeiClient($this->kernel);
    }
 
    public function page()
    {
        return new pageClient($this->kernel);
    }
 
    public function wap()
    {
        return new wapClient($this->kernel);
    }
}
 
class Security
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function textRisk()
    {
        return new textRiskClient($this->kernel);
    }
}
 
class Util
{
    private $kernel;
 
    public function __construct($kernel)
    {
        $this->kernel = $kernel;
    }
 
    public function generic()
    {
        return new genericClient($this->kernel);
    }
 
    public function aes()
    {
        return new aesClient($this->kernel);
    }
}