new files
This commit is contained in:
79
pro_v3.5.1/crmeb/services/wechat/config/HttpCommonConfig.php
Normal file
79
pro_v3.5.1/crmeb/services/wechat/config/HttpCommonConfig.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use crmeb\services\wechat\contract\ServeConfigInterface;
|
||||
use crmeb\services\wechat\DefaultConfig;
|
||||
|
||||
/**
|
||||
* Http请求配置
|
||||
* Class HttpCommonConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class HttpCommonConfig implements ConfigHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var bool[]
|
||||
*/
|
||||
protected array $config = [
|
||||
'verify' => false,
|
||||
'timeout' => 5
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $serve;
|
||||
|
||||
/**
|
||||
* @param string $serve
|
||||
* @return $this
|
||||
*/
|
||||
public function setServe(string $serve): static
|
||||
{
|
||||
$this->serve = $serve;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务端实例
|
||||
* @return ServeConfigInterface
|
||||
*/
|
||||
public function getServe()
|
||||
{
|
||||
return app()->make($this->serve);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接获取配置
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $key, $default = null)
|
||||
{
|
||||
if ($value = DefaultConfig::value($key)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $this->getServe()->getConfig(DefaultConfig::key($key), $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
/**
|
||||
* 小微商户
|
||||
* Class MicroMerchantConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class MicroMerchantConfig
|
||||
{
|
||||
|
||||
}
|
||||
127
pro_v3.5.1/crmeb/services/wechat/config/MiniProgramConfig.php
Normal file
127
pro_v3.5.1/crmeb/services/wechat/config/MiniProgramConfig.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use crmeb\services\wechat\DefaultConfig;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
/**
|
||||
* 小程序配置
|
||||
* Class MiniProgramConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class MiniProgramConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* APPid
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
/**
|
||||
* APPsecret
|
||||
* @var string
|
||||
*/
|
||||
public string $secret;
|
||||
|
||||
/**
|
||||
* Token
|
||||
* @var string
|
||||
*/
|
||||
public string $token;
|
||||
|
||||
/**
|
||||
* EncodingAESKey
|
||||
* @var string
|
||||
*/
|
||||
public string $aesKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $responseType = 'array';
|
||||
|
||||
/**
|
||||
* http配置
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $httpConfig;
|
||||
|
||||
/**
|
||||
* 是否初始化过
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* MiniProgramConfig constructor.
|
||||
* @param HttpCommonConfig $commonConfig
|
||||
*/
|
||||
public function __construct(HttpCommonConfig $commonConfig)
|
||||
{
|
||||
$this->httpConfig = $commonConfig;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->httpConfig->getConfig(DefaultConfig::MINI_APPID, '');
|
||||
$this->secret = $this->httpConfig->getConfig('mini.secret', '');
|
||||
$this->token = $this->httpConfig->getConfig('mini.token', '');
|
||||
$this->aesKey = $this->httpConfig->getConfig('mini.key', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $key, $default = null)
|
||||
{
|
||||
return $this->httpConfig->getConfig($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部
|
||||
* @return array
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'app_id' => "string",
|
||||
'secret' => "string",
|
||||
'response_type' => "string",
|
||||
'log' => "array",
|
||||
'http' => "bool[]"
|
||||
])]
|
||||
#[Pure]
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->appId,
|
||||
'secret' => $this->secret,
|
||||
'token' => $this->token,
|
||||
'aes_key' => $this->aesKey,
|
||||
'response_type' => $this->responseType,
|
||||
'http' => $this->httpConfig->all()
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
/**
|
||||
* 公众号配置
|
||||
* Class OfficialAccountConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class OfficialAccountConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* AppID
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
/**
|
||||
* AppSecret
|
||||
* @var string
|
||||
*/
|
||||
public string $secret;
|
||||
|
||||
/**
|
||||
* Token
|
||||
* @var string
|
||||
*/
|
||||
public string $token;
|
||||
|
||||
/**
|
||||
* EncodingAESKey
|
||||
* @var string
|
||||
*/
|
||||
public string $aesKey;
|
||||
|
||||
/**
|
||||
* 指定 API 调用返回结果的类型
|
||||
* @var string
|
||||
*/
|
||||
protected string $responseType = 'array';
|
||||
|
||||
/**
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $httpConfig;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* OfficialAccountConfig constructor.
|
||||
* @param HttpCommonConfig $commonConfig
|
||||
*/
|
||||
public function __construct(HttpCommonConfig $commonConfig)
|
||||
{
|
||||
$this->httpConfig = $commonConfig;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->httpConfig->getConfig('official.appid', '');
|
||||
$this->secret = $this->httpConfig->getConfig('official.secret', '');
|
||||
$this->token = $this->httpConfig->getConfig('official.token', '');
|
||||
$this->aesKey = ($this->httpConfig->getConfig('official.encode', -1) > 0 ? $this->httpConfig->getConfig('official.key', '') : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有配置
|
||||
* @return array
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'app_id' => "string",
|
||||
'secret' => "string",
|
||||
'token' => "string",
|
||||
'aes_key' => "string",
|
||||
'response_type' => "string",
|
||||
'log' => "array",
|
||||
'http' => "bool[]"
|
||||
])]
|
||||
#[Pure]
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->appId,
|
||||
'secret' => $this->secret,
|
||||
'token' => $this->token,
|
||||
'aes_key' => $this->aesKey,
|
||||
'response_type' => $this->responseType,
|
||||
'http' => $this->httpConfig->all()
|
||||
];
|
||||
}
|
||||
}
|
||||
36
pro_v3.5.1/crmeb/services/wechat/config/OpenAppConfig.php
Normal file
36
pro_v3.5.1/crmeb/services/wechat/config/OpenAppConfig.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
/**
|
||||
* 开放平台APP配置
|
||||
* Class OpenAppConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class OpenAppConfig extends OpenWebConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* OpenAppConfig constructor.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->config->getConfig('app.appid', '');
|
||||
$this->secret = $this->config->getConfig('app.secret', '');
|
||||
$this->token = $this->config->getConfig('app.token', '');
|
||||
$this->aesKey = $this->config->getConfig('app.key', '');
|
||||
}
|
||||
}
|
||||
116
pro_v3.5.1/crmeb/services/wechat/config/OpenWebConfig.php
Normal file
116
pro_v3.5.1/crmeb/services/wechat/config/OpenWebConfig.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
/**
|
||||
* 开放平台网页端配置
|
||||
* Class OpenWebConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class OpenWebConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Appid
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
/**
|
||||
* Appsecret
|
||||
* @var string
|
||||
*/
|
||||
public string $secret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $token;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $aesKey;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $config;
|
||||
|
||||
/**
|
||||
* OpenWebConfig constructor.
|
||||
* @param HttpCommonConfig $config
|
||||
*/
|
||||
public function __construct(HttpCommonConfig $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenWebConfig constructor.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->config->getConfig('web.appid', '');
|
||||
$this->secret = $this->config->getConfig('web.secret', '');
|
||||
$this->token = $this->config->getConfig('web.token', '');
|
||||
$this->aesKey = $this->config->getConfig('web.key', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $key, $default = null)
|
||||
{
|
||||
return $this->config->getConfig($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'app_id' => "string",
|
||||
'secret' => "string",
|
||||
'token' => "string",
|
||||
'aes_key' => "string",
|
||||
'http' => "bool[]"
|
||||
])]
|
||||
#[Pure]
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->appId,
|
||||
'secret' => $this->secret,
|
||||
'token' => $this->token,
|
||||
'aes_key' => $this->aesKey,
|
||||
'http' => $this->config->all()
|
||||
];
|
||||
}
|
||||
}
|
||||
159
pro_v3.5.1/crmeb/services/wechat/config/PaymentConfig.php
Normal file
159
pro_v3.5.1/crmeb/services/wechat/config/PaymentConfig.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use crmeb\services\wechat\DefaultConfig;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
/**
|
||||
* 支付配置
|
||||
* Class PaymentConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class PaymentConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* appid
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
/**
|
||||
* 商户密钥
|
||||
* @var string
|
||||
*/
|
||||
public string $mchId;
|
||||
|
||||
/**
|
||||
* 小程序商户号
|
||||
* @var string
|
||||
*/
|
||||
public string $routineMchId;
|
||||
|
||||
/**
|
||||
* API密钥
|
||||
* @var string
|
||||
*/
|
||||
public string $key;
|
||||
|
||||
/**
|
||||
* 证书cert
|
||||
* @var string
|
||||
*/
|
||||
public string $certPath;
|
||||
|
||||
/**
|
||||
* 证书key
|
||||
* @var string
|
||||
*/
|
||||
public string $keyPath;
|
||||
|
||||
/**
|
||||
* 支付异步回调地址
|
||||
* @var string
|
||||
*/
|
||||
public string $notifyUrl;
|
||||
|
||||
/**
|
||||
* 退款异步通知
|
||||
* @var string
|
||||
*/
|
||||
public string $refundUrl;
|
||||
|
||||
/**
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $httpConfig;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* PaymentConfig constructor.
|
||||
* @param HttpCommonConfig $commonConfig
|
||||
*/
|
||||
public function __construct(HttpCommonConfig $commonConfig)
|
||||
{
|
||||
$this->httpConfig = $commonConfig;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/18
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->httpConfig->getConfig(DefaultConfig::OFFICIAL_APPID, '');
|
||||
$this->mchId = $this->httpConfig->getConfig(DefaultConfig::PAY_MCHID, '');
|
||||
$this->routineMchId = $this->httpConfig->getConfig('pay.routine_mchid', '');
|
||||
$this->key = $this->httpConfig->getConfig('pay.key', '');
|
||||
|
||||
$certPath = env('RECEPTACLE_ENABLE', false) ? env('RECEPTACLE_PAYCERT', '') : $this->httpConfig->getConfig('pay.client_cert', '');
|
||||
$keyPath = env('RECEPTACLE_ENABLE', false) ? env('RECEPTACLE_PAYKEY', '') : $this->httpConfig->getConfig('pay.client_key', '');
|
||||
|
||||
$this->certPath = str_replace('//', '/', public_path() . $certPath);
|
||||
$this->keyPath = str_replace('//', '/', public_path() . $keyPath);
|
||||
$this->notifyUrl = trim($this->httpConfig->getConfig(DefaultConfig::COMMENT_URL)) . DefaultConfig::value('pay.notifyUrl');
|
||||
$this->refundUrl = trim($this->httpConfig->getConfig(DefaultConfig::COMMENT_URL)) . DefaultConfig::value('pay.refundUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $key, $default = null)
|
||||
{
|
||||
return $this->httpConfig->getConfig($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部配置
|
||||
* @return array
|
||||
*/
|
||||
#[Pure]
|
||||
#[ArrayShape([
|
||||
'app_id' => "string",
|
||||
'mch_id' => "string",
|
||||
'v2_secret_key' => "string",
|
||||
'private_key' => "string",
|
||||
'certificate' => "string",
|
||||
'notify_url' => "string",
|
||||
'log' => "array",
|
||||
'http' => "bool[]"
|
||||
])]
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->appId,
|
||||
'mch_id' => $this->mchId,
|
||||
'v2_secret_key' => $this->key,
|
||||
'private_key' => $this->keyPath,
|
||||
'certificate' => $this->certPath,
|
||||
'notify_url' => $this->notifyUrl,
|
||||
'http' => $this->httpConfig->all()
|
||||
];
|
||||
}
|
||||
}
|
||||
201
pro_v3.5.1/crmeb/services/wechat/config/V3PaymentConfig.php
Normal file
201
pro_v3.5.1/crmeb/services/wechat/config/V3PaymentConfig.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use crmeb\services\wechat\DefaultConfig;
|
||||
|
||||
/**
|
||||
* Class V3PaymentConfig
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/9/30
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class V3PaymentConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* appid
|
||||
* @var string
|
||||
*/
|
||||
public string $appId;
|
||||
|
||||
/**
|
||||
* 商户密钥
|
||||
* @var string
|
||||
*/
|
||||
public string $mchId;
|
||||
|
||||
/**
|
||||
* API密钥
|
||||
* @var string
|
||||
*/
|
||||
public string $key;
|
||||
|
||||
/**
|
||||
* 证书序列号
|
||||
* @var string
|
||||
*/
|
||||
public string $serialNo;
|
||||
|
||||
/**
|
||||
* 证书cert
|
||||
* @var string
|
||||
*/
|
||||
public string $certPath;
|
||||
|
||||
/**
|
||||
* 证书key
|
||||
* @var string
|
||||
*/
|
||||
public string $keyPath;
|
||||
|
||||
/**
|
||||
* 支付异步回调地址
|
||||
* @var string
|
||||
*/
|
||||
public string $notifyUrl;
|
||||
|
||||
/**
|
||||
* 退款异步通知
|
||||
* @var string
|
||||
*/
|
||||
public string $refundUrl;
|
||||
|
||||
/**
|
||||
* 小程序appid
|
||||
* @var string
|
||||
*/
|
||||
public string $miniprogAppid;
|
||||
|
||||
/**
|
||||
* 应用appid
|
||||
* @var string
|
||||
*/
|
||||
public string $appAppid;
|
||||
|
||||
/**
|
||||
* 微信公众号appid
|
||||
* @var string
|
||||
*/
|
||||
public string $wechatAppid;
|
||||
|
||||
/**
|
||||
* v3支付公钥
|
||||
* @var string
|
||||
*/
|
||||
public string $publicKey;
|
||||
|
||||
/**
|
||||
* v3支付公钥证书
|
||||
* @var string
|
||||
*/
|
||||
public string $publicPem;
|
||||
|
||||
/**
|
||||
* web appid
|
||||
* @var string
|
||||
*/
|
||||
public string $webAppid;
|
||||
|
||||
/**
|
||||
* 是否v3支付
|
||||
* @var bool
|
||||
*/
|
||||
public bool $isV3PAy = true;
|
||||
|
||||
/**
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $httpConfig;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* V3PaymentConfig constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->httpConfig = app()->make(HttpCommonConfig::class);
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/15
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->appId = $this->httpConfig->getConfig(DefaultConfig::OFFICIAL_APPID, '');
|
||||
$this->mchId = $this->httpConfig->getConfig(DefaultConfig::PAY_MCHID, '');
|
||||
$this->serialNo = $this->httpConfig->getConfig('v3_pay.serial_no', '');
|
||||
$this->key = $this->httpConfig->getConfig('v3_pay.key', '');
|
||||
$this->isV3PAy = !!$this->httpConfig->getConfig('v3_pay.pay_type', false);
|
||||
$this->certPath = str_replace('//', '/', public_path() . $this->httpConfig->getConfig('pay.client_cert', ''));
|
||||
$this->keyPath = str_replace('//', '/', public_path() . $this->httpConfig->getConfig('pay.client_key', ''));
|
||||
$this->notifyUrl = trim($this->httpConfig->getConfig(DefaultConfig::COMMENT_URL)) . DefaultConfig::value('pay.notifyUrl');
|
||||
$this->refundUrl = trim($this->httpConfig->getConfig(DefaultConfig::COMMENT_URL)) . DefaultConfig::value('pay.refundUrl');
|
||||
$this->appAppid = $this->httpConfig->getConfig(DefaultConfig::APP_APPID, '');
|
||||
$this->webAppid = $this->httpConfig->getConfig(DefaultConfig::WEB_APPID, '');
|
||||
$this->wechatAppid = $this->httpConfig->getConfig(DefaultConfig::OFFICIAL_APPID, '');
|
||||
$this->miniprogAppid = $this->httpConfig->getConfig(DefaultConfig::MINI_APPID, '');
|
||||
$this->publicKey = $this->httpConfig->getConfig('v3_pay.public_key', '');
|
||||
$this->publicPem = str_replace('//', '/', public_path() . $this->httpConfig->getConfig('v3_pay.public_pem', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/9/30
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'app_id' => $this->appId,
|
||||
'serial_no' => $this->serialNo,
|
||||
'mch_id' => $this->mchId,
|
||||
'key' => $this->key,
|
||||
'cert_path' => $this->certPath,
|
||||
'key_path' => $this->keyPath,
|
||||
'notify_url' => $this->notifyUrl,
|
||||
'http' => $this->httpConfig->all(),
|
||||
'other' => [
|
||||
'wechat' => [
|
||||
'appid' => $this->wechatAppid,
|
||||
],
|
||||
'web' => [
|
||||
'appid' => $this->webAppid,
|
||||
],
|
||||
'app' => [
|
||||
'appid' => $this->appAppid,
|
||||
],
|
||||
'miniprog' => [
|
||||
'appid' => $this->miniprogAppid,
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
162
pro_v3.5.1/crmeb/services/wechat/config/WorkConfig.php
Normal file
162
pro_v3.5.1/crmeb/services/wechat/config/WorkConfig.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace crmeb\services\wechat\config;
|
||||
|
||||
|
||||
use crmeb\services\wechat\contract\ConfigHandlerInterface;
|
||||
use crmeb\services\wechat\contract\WorkAppConfigHandlerInterface;
|
||||
use crmeb\services\wechat\DefaultConfig;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
/**
|
||||
* 企业微信配置
|
||||
* Class WorkConfig
|
||||
* @package crmeb\services\wechat\config
|
||||
*/
|
||||
class WorkConfig implements ConfigHandlerInterface
|
||||
{
|
||||
|
||||
//应用
|
||||
const TYPE_APP = 'app';
|
||||
//客户联系
|
||||
const TYPE_USER = 'user';
|
||||
//通讯录同步
|
||||
const TYPE_ADDRESS = 'address';
|
||||
//客服
|
||||
const TYPE_KEFU = 'kefu';
|
||||
//审批
|
||||
const TYPE_APPROVE = 'approve';
|
||||
//会议室
|
||||
const TYPE_MEETING = 'meeting';
|
||||
//自建应用
|
||||
const TYPE_USER_APP = 'build';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $corpId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $token;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $aesKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $responseType = 'array';
|
||||
|
||||
/**
|
||||
* @var HttpCommonConfig
|
||||
*/
|
||||
protected HttpCommonConfig $httpConfig;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $init = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $handler;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $appConfig;
|
||||
|
||||
/**
|
||||
* WorkConfig constructor.
|
||||
* @param HttpCommonConfig $commonConfig
|
||||
*/
|
||||
public function __construct(HttpCommonConfig $commonConfig)
|
||||
{
|
||||
$this->httpConfig = $commonConfig;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/9/18
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
if ($this->init) {
|
||||
return;
|
||||
}
|
||||
$this->init = true;
|
||||
$this->corpId = $this->httpConfig->getConfig(DefaultConfig::WORK_CORP_ID, '');
|
||||
$this->token = $this->httpConfig->getConfig('work.token', '');
|
||||
$this->aesKey = $this->httpConfig->getConfig('work.key', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部值
|
||||
* @return array
|
||||
*/
|
||||
#[ArrayShape([
|
||||
'corp_id' => "string",
|
||||
'token' => "string",
|
||||
'aes_key' => "string",
|
||||
'response_type' => "string",
|
||||
'log' => "array",
|
||||
'http' => "bool[]"
|
||||
])]
|
||||
#[Pure]
|
||||
public function all(): array
|
||||
{
|
||||
return [
|
||||
'corp_id' => $this->corpId,
|
||||
'token' => $this->token,
|
||||
'aes_key' => $this->aesKey,
|
||||
'response_type' => $this->responseType,
|
||||
'http' => $this->httpConfig->all()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用配置
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getAppConfig(string $type): array
|
||||
{
|
||||
if (!isset($this->appConfig[$type])) {
|
||||
/** @var WorkAppConfigHandlerInterface $make */
|
||||
$make = app()->make($this->handler);
|
||||
if (!$this->corpId) {
|
||||
$this->init();
|
||||
}
|
||||
$this->appConfig[$type] = $make->getAppConfig($this->corpId, $type);
|
||||
}
|
||||
return $this->appConfig[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
* @param string $handler
|
||||
* @return $this
|
||||
*/
|
||||
public function setHandler(string $handler): self
|
||||
{
|
||||
$this->handler = $handler;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user