From 9bda8d93fe12c90858682dd58475e46ddafc873c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Tue, 18 Oct 2022 17:39:45 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crmeb/services/app/MiniProgramService.php | 22 ++++++++++--------- crmeb/crmeb/services/app/WechatService.php | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crmeb/crmeb/services/app/MiniProgramService.php b/crmeb/crmeb/services/app/MiniProgramService.php index d9a7f67cd..44ab81890 100644 --- a/crmeb/crmeb/services/app/MiniProgramService.php +++ b/crmeb/crmeb/services/app/MiniProgramService.php @@ -91,7 +91,7 @@ class MiniProgramService public static function options() { $wechat = SystemConfigService::more(['wechat_app_appsecret', 'wechat_app_appid', 'site_url', 'routine_appId', 'routine_appsecret']); - $payment = SystemConfigService::more(['pay_weixin_mchid', 'pay_weixin_key', 'pay_weixin_client_cert', 'pay_weixin_client_key', 'pay_weixin_open','pay_new_weixin_open','pay_new_weixin_mchid']); + $payment = SystemConfigService::more(['pay_weixin_mchid', 'pay_weixin_key', 'pay_weixin_client_cert', 'pay_weixin_client_key', 'pay_weixin_open', 'pay_new_weixin_open', 'pay_new_weixin_mchid']); $config = []; if (request()->isApp()) { $appId = isset($wechat['wechat_app_appid']) ? trim($wechat['wechat_app_appid']) : ''; @@ -108,10 +108,10 @@ class MiniProgramService ]; $config['payment'] = [ 'app_id' => $appId, - 'merchant_id' => empty($payment['pay_new_weixin_open']) ? trim($payment['pay_weixin_mchid']) : trim($payment['pay_new_weixin_mchid']), + 'merchant_id' => empty($payment['pay_new_weixin_open']) ? trim($payment['pay_weixin_mchid']) : trim($payment['pay_new_weixin_mchid']), 'key' => trim($payment['pay_weixin_key']), - 'cert_path' => public_path() . $payment['pay_weixin_client_cert'], - 'key_path' => public_path() . $payment['pay_weixin_client_key'], + 'cert_path' => substr(public_path(parse_url($payment['pay_weixin_client_cert'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_cert'])['path'])) - 1), + 'key_path' => substr(public_path(parse_url($payment['pay_weixin_client_key'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_key'])['path'])) - 1), 'notify_url' => trim($wechat['site_url']) . Url::buildUrl('/api/routine/notify') ]; return $config; @@ -343,6 +343,7 @@ class MiniProgramService } } } + /** * 获得下单ID * @param $openid @@ -368,7 +369,7 @@ class MiniProgramService Cache::set($key, $result->payment_params, 7000); return $result->payment_params; } else { - exception('微信支付错误返回:'.'['.$result->errcode.']'. $result->errmsg); + exception('微信支付错误返回:' . '[' . $result->errcode . ']' . $result->errmsg); exit; } } @@ -451,6 +452,7 @@ class MiniProgramService return self::paymentService()->refundByTransactionId($orderNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundAccount, $refundReason); } } + /** * 使用商户订单号退款 * @param $orderNo @@ -469,11 +471,11 @@ class MiniProgramService $order = [ 'openid' => $opt['open_id'], - 'trade_no'=>$opt['order_id'], - 'transaction_id'=>$opt['trade_no'], - 'refund_no'=>$opt['refund_no'], - 'total_amount'=>$totalFee, - 'refund_amount'=>$refundFee, + 'trade_no' => $opt['order_id'], + 'transaction_id' => $opt['trade_no'], + 'refund_no' => $opt['refund_no'], + 'total_amount' => $totalFee, + 'refund_amount' => $refundFee, ]; return self::application()->minipay->refundorder($order); } diff --git a/crmeb/crmeb/services/app/WechatService.php b/crmeb/crmeb/services/app/WechatService.php index b0b5331b6..d75a5d780 100644 --- a/crmeb/crmeb/services/app/WechatService.php +++ b/crmeb/crmeb/services/app/WechatService.php @@ -78,8 +78,8 @@ class WechatService 'app_id' => $appId, 'merchant_id' => trim($payment['pay_weixin_mchid']), 'key' => trim($payment['pay_weixin_key']), - 'cert_path' => public_path() . $payment['pay_weixin_client_cert'], - 'key_path' => public_path() . $payment['pay_weixin_client_key'], + 'cert_path' => substr(public_path(parse_url($payment['pay_weixin_client_cert'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_cert'])['path'])) - 1), + 'key_path' => substr(public_path(parse_url($payment['pay_weixin_client_key'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_key'])['path'])) - 1), 'notify_url' => trim(sys_config('site_url')) . '/api/wechat/notify' ]; }