From 8b2dbf2b209f208330a94feeeb96aea3ff81f1d6 Mon Sep 17 00:00:00 2001 From: zeyan <258785420@qq.com> Date: Sat, 9 Aug 2025 10:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- niucloud/app/common.php | 40 ++++++++++++++----- niucloud/app/service/admin/pay/PayService.php | 2 - niucloud/core/pay/Wechatpay.php | 1 + uniapp/components/order-form-popup/index.vue | 3 ++ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/niucloud/app/common.php b/niucloud/app/common.php index 94a8c5bd..85c38815 100644 --- a/niucloud/app/common.php +++ b/niucloud/app/common.php @@ -1101,7 +1101,20 @@ function return_pay_config($campus_id, $order_id) { $campus_pay = new \app\model\campus_pay\CampusPay(); $pay_config = $campus_pay->where(['campus_id' => $campus_id])->find(); - + /** + * [ + * "id" => 3 + * "campus_id" => 3 + * "mchid" => "1683015573" + * "pay_sign_key" => "eMxxEaxmzWo0FeMasMGPZDAC2vEZtVpE" + * "apiclient_key" => "upload/attachment/document/cert/202508/08/apiclient_cert.pem" + * "apiclient_cert" => "upload/attachment/document/cert/202508/08/apiclient_key.pem" + * "wx_pay_key" => "upload/attachment/document/cert/202508/09/pub_key.pem" + * "wx_pay_key_id" => "PUB_KEY_ID_0116830155732025080800112116001001" + * "created_at" => "2025-08-08 19:34:38" + * "updated_at" => "2025-08-09 00:02:13" + * ] + */ $sysConfig = new SysConfig(); $vx_config = $sysConfig->where(['config_key' => 'weapp'])->value("value"); @@ -1124,6 +1137,8 @@ function return_pay_config($campus_id, $order_id) // 选填-小程序 的 app_id 'mini_app_id' => '', 'mch_secret_key' => $pay_config['pay_sign_key'], + 'wechat_public_cert_path' => $pay_config['wx_pay_key'] ?? '', + 'wechat_public_cert_id' => $pay_config['wx_pay_key_id'] ?? '', ]; return $config; @@ -1304,7 +1319,8 @@ function get_role_type($role_id) */ -function isDateInThisWeek($date) { +function isDateInThisWeek($date) +{ $timestamp = strtotime($date); // 获取本周开始和结束时间戳(周一到周日) @@ -1314,7 +1330,8 @@ function isDateInThisWeek($date) { return $timestamp >= $monday && $timestamp <= $sunday; } -function isDateInLastWeek($date) { +function isDateInLastWeek($date) +{ $timestamp = strtotime($date); // 获取上周的周一(开始)和周日(结束) @@ -1325,7 +1342,6 @@ function isDateInLastWeek($date) { } - function getChineseWeekday($date) { $weekdays = ['日', '一', '二', '三', '四', '五', '六']; @@ -1391,7 +1407,8 @@ function get_staff_performance_total(int $staffId, string $performanceType = '', } } -function httpGet($url) { +function httpGet($url) +{ $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); @@ -1406,8 +1423,8 @@ function httpGet($url) { } - -function getAccessToken() { +function getAccessToken() +{ $appId = 'wxe48c268ac1c97ab9'; $appSecret = 'fc355f42f55e693595d31e0e644bd11c'; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appId&secret=$appSecret"; @@ -1419,13 +1436,14 @@ function getAccessToken() { //$touser 用户的openid //$template_id 模板id //$value 发送的 消息 数组 -function sendMessage($touser,$template_id,$value) { +function sendMessage($touser, $template_id, $value) +{ // 构建请求参数 $accessToken = getAccessToken(); - $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" .$accessToken; + $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $accessToken; - if($template_id == 'K5YS7UBbD18PZvqUmnBKfX_j8tKP_AUAKa75mwUsX0A'){ + if ($template_id == 'K5YS7UBbD18PZvqUmnBKfX_j8tKP_AUAKa75mwUsX0A') { $data = [ 'touser' => $touser, 'template_id' => $template_id, @@ -1443,7 +1461,7 @@ function sendMessage($touser,$template_id,$value) { } - if($template_id == 'FrAKIn9zs0qdxWFW1R9vnR2WDJgil2KCg-9cLFaHFWM'){ + if ($template_id == 'FrAKIn9zs0qdxWFW1R9vnR2WDJgil2KCg-9cLFaHFWM') { $data = [ 'touser' => $touser, 'template_id' => $template_id, diff --git a/niucloud/app/service/admin/pay/PayService.php b/niucloud/app/service/admin/pay/PayService.php index eaa0d0a4..f0a649ac 100644 --- a/niucloud/app/service/admin/pay/PayService.php +++ b/niucloud/app/service/admin/pay/PayService.php @@ -239,11 +239,9 @@ class PayService extends BaseAdminService 'body' => '订单扫码支付:' . $out_trade_no, 'money' => $order_info['order_amount'] * 100, ]; - $pay = new PayLoader('Wechatpay', $config); $url = $pay->scan($params); - $path = qrcode($url['code_url'], '', [], 'upload/qrcode/pay/'); $order->where(['id' => $data['order_id']])->update(['payment_id' => $out_trade_no,'ipv3' => $config['mch_secret_key']]); diff --git a/niucloud/core/pay/Wechatpay.php b/niucloud/core/pay/Wechatpay.php index 8aae6d52..f98303aa 100644 --- a/niucloud/core/pay/Wechatpay.php +++ b/niucloud/core/pay/Wechatpay.php @@ -214,6 +214,7 @@ class Wechatpay extends BasePay // if ($e instanceof InvalidResponseException) { // throw new PayException($e->response->all()['message'] ?? ''); // } + dd($e); throw new PayException($e->getMessage()); } } diff --git a/uniapp/components/order-form-popup/index.vue b/uniapp/components/order-form-popup/index.vue index d366586a..26b873c5 100644 --- a/uniapp/components/order-form-popup/index.vue +++ b/uniapp/components/order-form-popup/index.vue @@ -261,6 +261,7 @@ export default { this.pickerTitle = '选择课程' this.pickerOptions = this.courseList this.pickerValue = [0] + this.selectedIndex = 0 // 重置选择索引 this.$refs.pickerPopup.open() }, @@ -269,6 +270,7 @@ export default { this.pickerTitle = '选择支付方式' this.pickerOptions = this.paymentTypes this.pickerValue = [0] + this.selectedIndex = 0 // 重置选择索引 this.$refs.pickerPopup.open() }, @@ -277,6 +279,7 @@ export default { this.pickerTitle = '选择订单类型' this.pickerOptions = this.orderTypes this.pickerValue = [0] + this.selectedIndex = 0 // 重置选择索引 this.$refs.pickerPopup.open() },