mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-17 01:06:40 +08:00
码支付更新
This commit is contained in:
parent
a1707612dc
commit
b19e0039f2
@ -27,9 +27,9 @@ class IndexController
|
||||
if ($action === 'mpay') {
|
||||
$data = json_decode($info['data'], true);
|
||||
$config = \think\facade\Config::load("payconfig/{$data['pid']}_{$data['aid']}", 'payconfig');
|
||||
$payclient_path = "\\payclient\\Mpay";
|
||||
$payclient_path = "\\payclient\\{$config['pay']['payclass']}";
|
||||
$Payclient = new $payclient_path($info, $config);
|
||||
$res = $Payclient->notify($info);
|
||||
$res = $Payclient->notify();
|
||||
return $res;
|
||||
} else {
|
||||
return 202;
|
||||
|
@ -90,11 +90,12 @@ class PayController
|
||||
if ($order_id) {
|
||||
$act_order = Order::where('order_id', $order_id)->find();
|
||||
if ($act_order) {
|
||||
$qrcode = PayChannel::where('id', $act_order->cid)->value('qrcode');
|
||||
$channel = PayChannel::where('id', $act_order->cid)->find();
|
||||
View::assign($act_order->toArray());
|
||||
$passtime = strtotime($act_order->close_time) - time();
|
||||
View::assign('passtime', $passtime > 0 ? $passtime : 0);
|
||||
View::assign('payUrl', $qrcode);
|
||||
View::assign('payUrl', $channel->qrcode);
|
||||
View::assign('code_type', $channel->type);
|
||||
return View::fetch();
|
||||
} else {
|
||||
return '订单不存在';
|
||||
@ -329,6 +330,22 @@ class PayController
|
||||
return json($info);
|
||||
}
|
||||
}
|
||||
// 处理微信/支付宝收款通知
|
||||
public function mpayNotify(Request $request)
|
||||
{
|
||||
$info = $request->post();
|
||||
$action = isset($info['action']) ? $info['action'] : '';
|
||||
if ($action === 'mpay') {
|
||||
$data = json_decode($info['data'], true);
|
||||
$config = \think\facade\Config::load("payconfig/{$data['pid']}_{$data['aid']}", 'payconfig');
|
||||
$payclient_path = "\\payclient\\{$config['pay']['payclass']}";
|
||||
$Payclient = new $payclient_path($info, $config, $request->domain());
|
||||
$Payclient->notify();
|
||||
return 200;
|
||||
} else {
|
||||
return 202;
|
||||
}
|
||||
}
|
||||
// 签名
|
||||
private static function getSign(array $param = [], string $key = ''): string
|
||||
{
|
||||
|
@ -63,6 +63,7 @@ class PayManageController extends BaseController
|
||||
'qrcode' => $channel->qrcode,
|
||||
'last_time' => $channel->last_time,
|
||||
'state' => $channel->state,
|
||||
'type' => $channel->type,
|
||||
]);
|
||||
return View::fetch();
|
||||
}
|
||||
|
@ -119,12 +119,23 @@ class Order extends BaseModel
|
||||
$channel_infos = PayChannel::whereIn('account_id', $aids)->where('state', 1)->order('last_time', 'asc')->select();
|
||||
if (!$channel_infos || !$aids) return [];
|
||||
// 微信/支付宝收款处理
|
||||
$patt_wx = '/^wxpay/i';
|
||||
$patt_ali = '/^alipay/i';
|
||||
foreach ($channel_infos as $key => $value) {
|
||||
|
||||
$check_wx = preg_match('/^wxpay\d+#/i', $value->channel);
|
||||
$check_ali = preg_match('/^alipay\d+#/i', $value->channel);
|
||||
if ($check_wx && $type === 'wxpay') {
|
||||
$channel_info = $channel_infos[$key];
|
||||
break;
|
||||
} elseif ($check_ali && $type === 'alipay') {
|
||||
$channel_info = $channel_infos[$key];
|
||||
break;
|
||||
} else {
|
||||
if ($check_wx || $check_ali) {
|
||||
continue;
|
||||
}
|
||||
$channel_info = $channel_infos[$key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$channel_info = $channel_infos[0];
|
||||
// 选取收款通道
|
||||
$patt = PayAccount::find($channel_info->account_id);
|
||||
$channel = ['aid' => $channel_info->account_id, 'cid' => $channel_info->id, 'patt' => $patt->getData('pattern')];
|
||||
|
BIN
public/files/wxpay2K103516.jpg
Normal file
BIN
public/files/wxpay2K103516.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
@ -16,6 +16,8 @@ Route::rule('checkOrder/[:pid]/[:sign]', 'Pay/checkOrder');
|
||||
Route::rule('payHeart', 'Pay/payHeart');
|
||||
// 监听收款通知
|
||||
Route::rule('checkPayResult', 'Pay/checkPayResult');
|
||||
// 监听微信/支付宝收款通知
|
||||
Route::rule('mpayNotify', 'Pay/mpayNotify');
|
||||
// 验证支付结果
|
||||
Route::rule('validatePayResult', 'Pay/validatePayResult');
|
||||
|
||||
|
@ -1 +1 @@
|
||||
{"code":0,"msg":"没有新订单"}
|
||||
{"code":1,"msg":"\u67092\u4e2a\u65b0\u8ba2\u5355","orders":[{"id":36348,"pid":1001,"aid":46,"cid":39,"patt":1},{"id":36350,"pid":1001,"aid":1,"cid":1,"patt":1}]}
|
@ -152,6 +152,7 @@
|
||||
<script src="/static/js/awesome-qr.min.js"></script>
|
||||
<script>
|
||||
const payCode = '<?php echo htmlentities($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;
|
||||
@ -167,7 +168,11 @@
|
||||
payTypeText.innerText = '请使用支付宝扫码支付'
|
||||
}
|
||||
// 生成二维码
|
||||
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
|
||||
if (codeType == 0) {
|
||||
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
|
||||
} else {
|
||||
document.getElementById('qrcode').src = payCode;
|
||||
}
|
||||
// 订单过期时间
|
||||
let passtime = 0;
|
||||
// 订单状态查询
|
||||
|
@ -22,6 +22,16 @@
|
||||
<input type="text" name="channel" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款样式</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="type">
|
||||
<option value="">请选择</option>
|
||||
<option value="0">付款链接</option>
|
||||
<option value="1">图片地址</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款码</label>
|
||||
<div class="layui-input-block">
|
||||
|
@ -28,18 +28,28 @@
|
||||
<select class="type" lay-filter="select-type">
|
||||
<option value="">请选择</option>
|
||||
<!-- <?php if ($platform == 'wxpay') { ?> -->
|
||||
<option value="wx1">个人码</option>
|
||||
<option value="wx2">赞赏码</option>
|
||||
<option value="wx3">经营码</option>
|
||||
<option value="wx4">商家码</option>
|
||||
<option value="wxpay1">个人码</option>
|
||||
<option value="wxpay2">赞赏码</option>
|
||||
<!-- <option value="wxpay3">经营码</option>
|
||||
<option value="wxpay4">商家码</option> -->
|
||||
<!-- <?php } ?> -->
|
||||
<!-- <?php if ($platform == 'alipay') { ?> -->
|
||||
<option value="ali1">个人码</option>
|
||||
<option value="ali2">经营码</option>
|
||||
<option value="alipay1">个人码</option>
|
||||
<option value="alipay2">经营码</option>
|
||||
<!-- <?php } ?> -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款样式</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="type">
|
||||
<option value="">请选择</option>
|
||||
<option value="0">付款链接</option>
|
||||
<option value="1">图片地址</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收款码</label>
|
||||
<div class="layui-input-block">
|
||||
@ -76,7 +86,7 @@
|
||||
form.on('select(select-type)', function (data) {
|
||||
const value = data.value; // 获得被选中的值
|
||||
const channel = document.querySelector('input[name="channel"]');
|
||||
channel.value = '<?php echo $account ?>' + value;
|
||||
channel.value = value + '#<?php echo $account ?>';
|
||||
});
|
||||
form.on('submit(save)', function (obj) {
|
||||
let field = obj.field;
|
||||
|
@ -39,7 +39,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">付款链接</label>
|
||||
<label class="layui-form-label">收款样式</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="type">
|
||||
<option value="">请选择</option>
|
||||
<option value="0">付款链接</option>
|
||||
<option value="1">图片地址</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">付款地址</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="qrcode" autocomplete="off" lay-affix="upload-drag"
|
||||
lay-filter="scanning" class="layui-input">
|
||||
@ -84,7 +94,8 @@
|
||||
form.val('edit-channel', {
|
||||
"channel": "<?php echo $channel ?>",
|
||||
"qrcode": "<?php echo $qrcode ?>",
|
||||
"state": '<?php echo $state ?>' == 1 ? true : false
|
||||
"state": '<?php echo $state ?>' == 1 ? true : false,
|
||||
"type": '<?php echo $type ?>'
|
||||
});
|
||||
|
||||
form.on('input-affix(scanning)', function () {
|
||||
|
@ -85,9 +85,9 @@
|
||||
<script type="text/html" id="account-checkUrl">
|
||||
{{#
|
||||
if (d.platform == '微信支付') {
|
||||
return `{"payway":"wxpay","pid":"${d.pid}","aid":"${d.id}","uid":"\{\{UID\}\}","title":"\{\{TITLE\}\}","msg":"\{\{MSG\}\}","time":"\{\{RECEIVE_TIME\}\}","divice":"\{\{DEVICE_NAME\}\}"}`;
|
||||
return `{"pid":"${d.pid}","aid":"${d.id}","uid":"\{\{UID\}\}","title":"\{\{TITLE\}\}","msg":"\{\{MSG\}\}","time":"\{\{RECEIVE_TIME\}\}","divice":"\{\{DEVICE_NAME\}\}"}`;
|
||||
} else if (d.platform == '支付宝') {
|
||||
return `{"payway":"alipay","pid":"${d.pid}","aid":"${d.id}","uid":"\{\{UID\}\}","title":"\{\{TITLE\}\}","msg":"\{\{MSG\}\}","time":"\{\{RECEIVE_TIME\}\}","divice":"\{\{DEVICE_NAME\}\}"}`;
|
||||
return `{"pid":"${d.pid}","aid":"${d.id}","uid":"\{\{UID\}\}","title":"\{\{TITLE\}\}","msg":"\{\{MSG\}\}","time":"\{\{RECEIVE_TIME\}\}","divice":"\{\{DEVICE_NAME\}\}"}`;
|
||||
} else {
|
||||
return '<?php echo $domain ?>/checkPayResult?pid=' + d.pid + '&aid=' + d.id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user