系统类型优化
parent
bb0a08892d
commit
80c7b13705
|
|
@ -195,19 +195,8 @@ class OrderService
|
|||
}
|
||||
|
||||
// 回调地址
|
||||
$url = __MY_URL__.'payment_order_'.strtolower($payment['payment']);
|
||||
|
||||
// url模式, pathinfo模式下采用自带url生成url, 避免非index.php多余
|
||||
if(MyC('home_seo_url_model', 0) == 0)
|
||||
{
|
||||
$call_back_url = $url.'_respond.php';
|
||||
} else {
|
||||
$call_back_url = MyUrl('index/order/respond', ['paymentname'=>$payment['payment']]);
|
||||
if(stripos($call_back_url, '?') !== false)
|
||||
{
|
||||
$call_back_url = $url.'_respond.php';
|
||||
}
|
||||
}
|
||||
$respond_url = $pay_checked['data']['respond'];
|
||||
$notify_url = $pay_checked['data']['notify'];
|
||||
|
||||
// 是否指定同步回调地址
|
||||
if(!empty($params['redirect_url']))
|
||||
|
|
@ -216,7 +205,7 @@ class OrderService
|
|||
if(!empty($redirect_url))
|
||||
{
|
||||
// 赋值同步返回地址
|
||||
$call_back_url = $redirect_url;
|
||||
$respond_url = $redirect_url;
|
||||
}
|
||||
}
|
||||
if(empty($redirect_url))
|
||||
|
|
@ -273,8 +262,8 @@ class OrderService
|
|||
'name' => '订单支付',
|
||||
'total_price' => $total_price,
|
||||
'client_type' => $client_type,
|
||||
'notify_url' => $url.'_notify.php',
|
||||
'call_back_url' => $call_back_url,
|
||||
'notify_url' => $notify_url,
|
||||
'call_back_url' => $respond_url,
|
||||
'redirect_url' => $redirect_url,
|
||||
'site_name' => MyC('home_site_name', 'ShopXO', true),
|
||||
'check_url' => MyUrl('index/order/paycheck'),
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
namespace app\service;
|
||||
|
||||
use think\facade\Db;
|
||||
use app\service\SystemService;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\StoreService;
|
||||
|
||||
|
|
@ -127,6 +128,15 @@ class PaymentService
|
|||
closedir($dh);
|
||||
}
|
||||
}
|
||||
|
||||
// 支付方式列表钩子
|
||||
$hook_name = 'plugins_service_payment_list';
|
||||
MyEventTrigger($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'data' => &$data,
|
||||
]);
|
||||
|
||||
return DataReturn('success', 0, $data);
|
||||
}
|
||||
|
||||
|
|
@ -803,6 +813,9 @@ class PaymentService
|
|||
// 处理业务
|
||||
$business_all = empty($params['business']) ? self::$payment_business_type_all : $params['business'];
|
||||
|
||||
// 系统类型
|
||||
$system_type = SystemService::SystemTypeValue();
|
||||
|
||||
// 批量创建
|
||||
foreach($business_all as $v)
|
||||
{
|
||||
|
|
@ -821,6 +834,9 @@ namespace think;
|
|||
// 默认绑定模块
|
||||
\$_GET['s'] = '{$params["notify"]}';
|
||||
|
||||
// 指定系统类型
|
||||
define('SYSTEM_TYPE', '{$system_type}');
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$params["payment"]}');
|
||||
|
||||
|
|
@ -853,6 +869,9 @@ namespace think;
|
|||
// 默认绑定模块
|
||||
\$_GET['s'] = '{$params["respond"]}';
|
||||
|
||||
// 指定系统类型
|
||||
define('SYSTEM_TYPE', '{$system_type}');
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$params["payment"]}');
|
||||
|
||||
|
|
@ -887,6 +906,9 @@ namespace think;
|
|||
// 默认绑定模块
|
||||
\$_GET['s'] = '{$params["notify"]}';
|
||||
|
||||
// 指定系统类型
|
||||
define('SYSTEM_TYPE', '{$system_type}');
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$params["payment"]}');
|
||||
|
||||
|
|
@ -916,6 +938,9 @@ namespace think;
|
|||
// 默认绑定模块
|
||||
\$_GET['s'] = '{$params["respond"]}';
|
||||
|
||||
// 指定系统类型
|
||||
define('SYSTEM_TYPE', '{$system_type}');
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$params["payment"]}');
|
||||
|
||||
|
|
@ -933,13 +958,17 @@ require __DIR__ . '/../vendor/autoload.php';
|
|||
?>
|
||||
php;
|
||||
}
|
||||
|
||||
// 文件名称
|
||||
$file = self::EntranceFileData($params['payment'], $business_name);
|
||||
|
||||
@file_put_contents(self::$dir_root_path.'payment_'.$business_name.'_'.strtolower($params['payment']).'_respond.php', $respond);
|
||||
// 同步文件
|
||||
@file_put_contents(self::$dir_root_path.$file['respond'], $respond);
|
||||
|
||||
// 线下支付不生成异步入口文件
|
||||
if(!in_array($params['payment'], $not_notify))
|
||||
{
|
||||
@file_put_contents(self::$dir_root_path.'payment_'.$business_name.'_'.strtolower($params['payment']).'_notify.php', $notify);
|
||||
@file_put_contents(self::$dir_root_path.$file['notify'], $notify);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -974,18 +1003,16 @@ php;
|
|||
|
||||
// 处理业务
|
||||
$business_all = empty($params['business']) ? self::$payment_business_type_all : $params['business'];
|
||||
|
||||
$payment = strtolower($params['payment']);
|
||||
foreach($business_all as $v)
|
||||
{
|
||||
$business_name = strtolower($v['name']);
|
||||
if(file_exists(self::$dir_root_path.'payment_'.$business_name.'_'.$payment.'_notify.php'))
|
||||
$file = self::EntranceFileData($params['payment'], $v['name']);
|
||||
if(file_exists(self::$dir_root_path.$file['notify']))
|
||||
{
|
||||
@unlink(self::$dir_root_path.'payment_'.$business_name.'_'.$payment.'_notify.php');
|
||||
@unlink(self::$dir_root_path.$file['notify']);
|
||||
}
|
||||
if(file_exists(self::$dir_root_path.'payment_'.$business_name.'_'.$payment.'_respond.php'))
|
||||
if(file_exists(self::$dir_root_path.$file['respond']))
|
||||
{
|
||||
@unlink(self::$dir_root_path.'payment_'.$business_name.'_'.$payment.'_respond.php');
|
||||
@unlink(self::$dir_root_path.$file['respond']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -993,7 +1020,30 @@ php;
|
|||
}
|
||||
|
||||
/**
|
||||
* 入库文件检查
|
||||
* 入口文件信息
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-12-26
|
||||
* @desc description
|
||||
* @param [string] $payment [支付标记]
|
||||
* @param [string] $name [支付业务方式名称]
|
||||
*/
|
||||
public static function EntranceFileData($payment, $name)
|
||||
{
|
||||
// 系统类型
|
||||
$system_type = SystemService::SystemTypeValue();
|
||||
|
||||
// 地址路径名称
|
||||
$dir = 'payment_'.$system_type.'_'.strtolower($name).'_'.strtolower($payment);
|
||||
return [
|
||||
'respond' => $dir.'_respond.php',
|
||||
'notify' => $dir.'_notify.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 入口文件检查
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
|
|
@ -1004,21 +1054,30 @@ php;
|
|||
*/
|
||||
public static function EntranceFileChecked($payment, $name)
|
||||
{
|
||||
// 文件名称
|
||||
$file = self::EntranceFileData($payment, $name);
|
||||
|
||||
// 统一返回数据
|
||||
$result = [
|
||||
'respond' => __MY_URL__.$file['respond'],
|
||||
'notify' => __MY_URL__.$file['notify'],
|
||||
];
|
||||
|
||||
// 同步返回文件
|
||||
if(!file_exists(self::$dir_root_path.'payment_'.strtolower($name).'_'.strtolower($payment).'_respond.php'))
|
||||
if(!file_exists(self::$dir_root_path.$file['respond']))
|
||||
{
|
||||
return DataReturn('支付返回入口文件不存在,请联系管理员处理', -10);
|
||||
return DataReturn('支付返回入口文件不存在,请联系管理员处理', -10, $result);
|
||||
}
|
||||
|
||||
// 线下支付不生成异步入口文件
|
||||
if(!in_array($payment, MyConfig('shopxo.under_line_list')))
|
||||
{
|
||||
if(!file_exists(self::$dir_root_path.'payment_'.strtolower($name).'_'.strtolower($payment).'_notify.php'))
|
||||
if(!file_exists(self::$dir_root_path.$file['notify']))
|
||||
{
|
||||
return DataReturn('支付通知入口文件不存在,请联系管理员处理', -10);
|
||||
return DataReturn('支付通知入口文件不存在,请联系管理员处理', -11, $result);
|
||||
}
|
||||
}
|
||||
return DataReturn('校验成功', 0);
|
||||
return DataReturn('校验成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -115,5 +115,29 @@ class SystemService
|
|||
MyRedirect(__MY_URL__.'install.php?s=index/index', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统类型值
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2022-04-15
|
||||
* @desc description
|
||||
*/
|
||||
public static function SystemTypeValue()
|
||||
{
|
||||
// 取默认值
|
||||
$value = SYSTEM_TYPE;
|
||||
|
||||
// 系统类型钩子
|
||||
$hook_name = 'plugins_service_system_system_type_value';
|
||||
MyEventTrigger($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'value' => &$value,
|
||||
]);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
namespace app\service;
|
||||
|
||||
use think\facade\Db;
|
||||
use app\service\SystemService;
|
||||
use app\service\RegionService;
|
||||
use app\service\SafetyService;
|
||||
use app\service\ResourcesService;
|
||||
|
|
@ -2150,7 +2151,7 @@ class UserService
|
|||
}
|
||||
|
||||
$where = [
|
||||
['system_type', '=', SYSTEM_TYPE],
|
||||
['system_type', '=', SystemService::SystemTypeValue()],
|
||||
[$where_field, '=', $where_value],
|
||||
['is_delete_time', '=', 0],
|
||||
];
|
||||
|
|
@ -2261,7 +2262,7 @@ class UserService
|
|||
public static function UserBaseHandle($data, $params)
|
||||
{
|
||||
// 系统类型
|
||||
$data['system_type'] = SYSTEM_TYPE;
|
||||
$data['system_type'] = SystemService::SystemTypeValue();
|
||||
|
||||
// 基础参数处理
|
||||
if(!empty($params) && is_array($params))
|
||||
|
|
|
|||
|
|
@ -82,8 +82,11 @@ define('ROOT', substr(ROOT_PATH, 0, -7));
|
|||
// 定义应用目录
|
||||
define('APP_PATH', ROOT.'app'.DS);
|
||||
|
||||
// 系统类型 [default] 默认default、可根据终端区分系统类型
|
||||
define('SYSTEM_TYPE', empty($_REQUEST['system_type']) ? 'default' : trim($_REQUEST['system_type']));
|
||||
// 防止独立入口文件已定义,系统类型 [default] 默认default、可根据终端区分系统类型
|
||||
if(!defined('SYSTEM_TYPE'))
|
||||
{
|
||||
define('SYSTEM_TYPE', empty($_REQUEST['system_type']) ? 'default' : trim($_REQUEST['system_type']));
|
||||
}
|
||||
|
||||
// 请求应用 [web, app] 默认web(ios|android|小程序 均为app)
|
||||
define('APPLICATION', empty($_REQUEST['application']) ? 'web' : trim($_REQUEST['application']));
|
||||
|
|
|
|||
Loading…
Reference in New Issue