mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-12 06:18:12 +08:00
fix: 修改微信配置
This commit is contained in:
parent
c860a90b2c
commit
58859b98cc
@ -82,7 +82,7 @@ class PaymentService
|
|||||||
if ($oPayed + $pAmount > floatval($oAmount)) {
|
if ($oPayed + $pAmount > floatval($oAmount)) {
|
||||||
return ['code' => 0, 'info' => '支付总额超出!', 'data' => [], 'params' => []];
|
return ['code' => 0, 'info' => '支付总额超出!', 'data' => [], 'params' => []];
|
||||||
}
|
}
|
||||||
$config = WechatService::getConfig();
|
$config = WechatService::getConfig('', true);
|
||||||
do $pCode = CodeExtend::uniqidNumber(16, 'P');
|
do $pCode = CodeExtend::uniqidNumber(16, 'P');
|
||||||
while (WechatPaymentRecord::mk()->master()->where(['code' => $pCode])->findOrEmpty()->isExists());
|
while (WechatPaymentRecord::mk()->master()->where(['code' => $pCode])->findOrEmpty()->isExists());
|
||||||
$data = [
|
$data = [
|
||||||
@ -328,7 +328,7 @@ class PaymentService
|
|||||||
*/
|
*/
|
||||||
protected static function withPayment(?array $config = null): Order
|
protected static function withPayment(?array $config = null): Order
|
||||||
{
|
{
|
||||||
return Order::instance($config ?: WechatService::getConfig());
|
return Order::instance($config ?: WechatService::getConfig('', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -178,19 +178,21 @@ class WechatService extends Service
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公众号配置参数
|
* 获取公众号配置参数
|
||||||
* @param string $appid
|
* @param string $appid 指定公众号
|
||||||
|
* @param boolean $ispay 获取支付参数
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \think\admin\Exception
|
* @throws \think\admin\Exception
|
||||||
*/
|
*/
|
||||||
public static function getConfig(string $appid = ''): array
|
public static function getConfig(string $appid = '', bool $ispay = false): array
|
||||||
{
|
{
|
||||||
return static::withWxpayCert([
|
$config = [
|
||||||
'appid' => $appid ?: static::getAppid(),
|
'appid' => $appid ?: static::getAppid(),
|
||||||
'token' => sysconf('wechat.token'),
|
'token' => sysconf('wechat.token'),
|
||||||
'appsecret' => sysconf('wechat.appsecret'),
|
'appsecret' => sysconf('wechat.appsecret'),
|
||||||
'encodingaeskey' => sysconf('wechat.encodingaeskey'),
|
'encodingaeskey' => sysconf('wechat.encodingaeskey'),
|
||||||
'cache_path' => syspath('runtime/wechat'),
|
'cache_path' => syspath('runtime/wechat'),
|
||||||
]);
|
];
|
||||||
|
return $ispay ? $config : static::withWxpayCert($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,6 +222,9 @@ class WechatService extends Service
|
|||||||
{
|
{
|
||||||
// 文本模式主要是为了解决分布式部署
|
// 文本模式主要是为了解决分布式部署
|
||||||
$data = sysdata('plugin.wechat.payment');
|
$data = sysdata('plugin.wechat.payment');
|
||||||
|
if (empty($data['mch_id'])) {
|
||||||
|
throw new Exception('无效的支付配置!');
|
||||||
|
}
|
||||||
$name1 = sprintf("wxpay/%s_%s_cer.pem", $data['mch_id'], md5($data['ssl_cer_text']));
|
$name1 = sprintf("wxpay/%s_%s_cer.pem", $data['mch_id'], md5($data['ssl_cer_text']));
|
||||||
$name2 = sprintf("wxpay/%s_%s_key.pem", $data['mch_id'], md5($data['ssl_key_text']));
|
$name2 = sprintf("wxpay/%s_%s_key.pem", $data['mch_id'], md5($data['ssl_key_text']));
|
||||||
$local = LocalStorage::instance();
|
$local = LocalStorage::instance();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user