mzeros e5ab00f136 feat(merchant): 添加回调失败自定义规则切换渠道功能
- 在商户表单中添加回调失败自定义规则切换渠道选项
- 实现订单回调失败时根据自定义规则切换到其他渠道的功能
- 优化订单状态监控和预警逻辑
- 修复部分渠道充值接口问题
2025-01-20 12:17:16 +08:00

68 lines
1.4 KiB
PHP

<?php
use think\exception\HttpResponseException;
$version = request()->post('version');
//var_dump($version);die;
if(!$version){
$version = request()->param('version');
}
app()->http->name('gateway'); #应用
//#设置指定应用的命名空间
app()->setNamespace('app\gateway'); #应用的命名空间
//默认跳转到v1版本
if ($version == null) $version = "api";#api.notify,url
if (str_contains($version, '.')) {
$version = explode('.', $version);
if($version[1] == '0'){
$version = $version[0];
}else{
$version = $version[0].'_'.$version[1];
}
}
$pathInfo = request()->pathinfo();
if ($pathInfo == null) {
$json = [
'code' => -802,
'data'=>'',
'msg' =>'请求错误'
];
throw new HttpResponseException(json($json));
}
if($version!='api'){
if(!str_contains($pathInfo, 'api.')){
if(str_contains($version, '.')){
$versions = str_replace(".", "", $version);
#支持小版本的更新
app()->route->any('call','/gateway/'.$versions.'.notify/call');
}else{
app()->route->any('call','/gateway/'.$version.'.notify/call');
}
}
}else{
if(!str_contains($pathInfo, 'api.')){
// app()->route->any('call','/gateway/'.$version.'.notify/call');
app()->route->any('call','/gateway/api.notify/call');
}
}