更新支付宝插件

This commit is contained in:
技术老胡 2025-06-28 10:09:45 +08:00
parent 5b69aded08
commit 924042aa5e
3 changed files with 58 additions and 38 deletions

View File

@ -68,7 +68,14 @@ class PayController
View::assign('passtime', $passtime > 0 ? $passtime : 0);
// Alipay免输
if (preg_match('/^alipay4#\d+$/', $channel->channel)) {
$payurl = \payclient\AliPayf::getPayUrl($act_order->order_id, $act_order->money, $channel->qrcode);
$chan = request()->get('chan', '');
if ($chan && $chan == 'Alipayf') {
$payurl = \payclient\AliPayf::getPayUrl($act_order->order_id, $act_order->money, $channel->qrcode, 1);
View::assign('payUrl', $payurl['data'] ?? $payurl['msg']);
View::assign('payclient', 'Alipayf');
} else {
$payurl = \payclient\AliPayf::getPayUrl($act_order->order_id, $act_order->money, $channel->qrcode);
}
View::assign('payUrl', $payurl['data'] ?? $payurl['msg']);
} else {
View::assign('payUrl', $channel->qrcode);
@ -237,7 +244,7 @@ class PayController
$config = PayAccount::getAccountConfig($req_aid);
if ($config === false) return json(['code' => 4, 'msg' => '监听收款配置错误']);
// 登陆账号
$pay_config = ['username' => $config['account'], 'password' => $config['password']];
$pay_config = ['username' => $config['account'], 'password' => $config['password'], 'aid' => $config['aid']];
// 配置参数
$params = $config['params'];
// 实例监听客户端

View File

@ -194,7 +194,7 @@ class PayManageController extends BaseController
if ($config === false) return json(backMsg(1, '账号配置文件错误'));
if ($req_aid != $config['aid'] || $req_pid != session('pid')) return json(backMsg(1, '监听收款配置不一致'));
// 登陆账号
$pay_config = ['username' => $config['account'], 'password' => $config['password']];
$pay_config = ['username' => $config['account'], 'password' => $config['password'], 'aid' => $config['aid']];
// 收款查询
$params = $config['params'];
// 实例监听客户端

View File

@ -6,6 +6,44 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>收银台</title>
<link rel="stylesheet" href="/component/pear/css/pear.css" />
<script>
function detectBrowserEnvironment() {
const userAgent = navigator.userAgent.toLowerCase();
let environment = 'other';
if (userAgent.includes('micromessenger')) {
if (userAgent.includes('miniprogram')) {
environment = 'wxapp'; // 微信小程序
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
environment = 'wxphone'; // 手机微信
} else {
environment = 'wxpc'; // PC微信
}
} else if (userAgent.includes('aliapp') || userAgent.includes('alipayclient')) {
if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
environment = 'aliphone'; // 手机支付宝
} else {
environment = 'alipc'; // PC支付宝
}
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
// 先判断是否是已知的手机APP内置浏览器如果不是则认为是手机浏览器
if (!userAgent.includes('micromessenger') && !userAgent.includes('aliapp') && !userAgent.includes('qq')) {
environment = 'phone'; // 手机浏览器
}
} else {
environment = 'pc'; // 剩下的情况认为是PC浏览器
}
return environment;
}
const payCode = '<?php echo $payUrl; ?>';
const codeType = '<?php echo htmlentities($code_type); ?>';
const payType = '<?php echo htmlentities($type); ?>';
const order = '<?php echo htmlentities($order_id); ?>';
const environment = detectBrowserEnvironment();
const payclient = '<?php echo htmlentities($payclient ?? ""); ?>';
if (payclient == 'Alipayf' && environment == 'aliphone') {
window.location.href = payCode;
}
</script>
<style>
body {
background: #f7f7f7;
@ -157,39 +195,6 @@
<script src="/component/layui/layui.js"></script>
<script src="/static/js/awesome-qr.min.js"></script>
<script>
function detectBrowserEnvironment() {
const userAgent = navigator.userAgent.toLowerCase();
let environment = 'other';
if (userAgent.includes('micromessenger')) {
if (userAgent.includes('miniprogram')) {
environment = 'wxapp'; // 微信小程序
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
environment = 'wxphone'; // 手机微信
} else {
environment = 'wxpc'; // PC微信
}
} else if (userAgent.includes('aliapp') || userAgent.includes('alipayclient')) {
if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
environment = 'aliphone'; // 手机支付宝
} else {
environment = 'alipc'; // PC支付宝
}
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
// 先判断是否是已知的手机APP内置浏览器如果不是则认为是手机浏览器
if (!userAgent.includes('micromessenger') && !userAgent.includes('aliapp') && !userAgent.includes('qq')) {
environment = 'phone'; // 手机浏览器
}
} else {
environment = 'pc'; // 剩下的情况认为是PC浏览器
}
return environment;
}
</script>
<script>
const payCode = '<?php echo $payUrl; ?>';
const codeType = '<?php echo htmlentities($code_type); ?>';
const payType = '<?php echo htmlentities($type); ?>';
const order = '<?php echo htmlentities($order_id); ?>';
const QR = AwesomeQR.AwesomeQR;
(async () => {
// 支付类型
@ -207,7 +212,16 @@
}
// 生成二维码
if (codeType == 0) {
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
if (payType === 'alipay' && environment === 'pc') {
// 解析网址
const url = new URL(payCode);
const queryParams = new URLSearchParams(url.search);
const qrcode = queryParams.get('qrcode');
const decodedQrcode = decodeURIComponent(qrcode);
document.getElementById('qrcode').src = await getQrcode(decodedQrcode, QR);
} else {
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
}
} else {
document.getElementById('qrcode').src = payCode;
}
@ -284,7 +298,6 @@
/* <?php } ?> */
// 环境判断
const environment = detectBrowserEnvironment();
if (payType === 'wxpay' && environment === 'aliphone') {
layer.alert('请使用微信打开此页面');
} else if (payType === 'alipay' && environment === 'wxphone') {