支付方式
parent
1d81c85437
commit
5f926928b0
|
|
@ -2,7 +2,7 @@
|
|||
namespace app\admin\controller;
|
||||
|
||||
use app\service\OrderService;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\PaymentService;
|
||||
use app\service\ExpressService;
|
||||
|
||||
/**
|
||||
|
|
@ -89,10 +89,10 @@ class Order extends Common
|
|||
$pay_where = [
|
||||
'where' => ['is_enable'=>1, 'is_open_user'=>1, 'payment'=>config('under_line_list')],
|
||||
];
|
||||
$this->assign('buy_payment_list', ResourcesService::BuyPaymentList($pay_where));
|
||||
$this->assign('buy_payment_list', PaymentService::BuyPaymentList($pay_where));
|
||||
|
||||
// 支付方式
|
||||
$this->assign('payment_list', ResourcesService::PaymentList());
|
||||
$this->assign('payment_list', PaymentService::PaymentList());
|
||||
|
||||
// 评价状态
|
||||
$this->assign('common_comments_status_list', lang('common_comments_status_list'));
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use Service\ResourcesService;
|
||||
use app\service\PaymentService;
|
||||
|
||||
/**
|
||||
* 支付方式管理
|
||||
|
|
@ -13,10 +12,6 @@ use Service\ResourcesService;
|
|||
*/
|
||||
class Payment extends Common
|
||||
{
|
||||
private $payment_dir;
|
||||
private $payment_business_type_all;
|
||||
private $cannot_deleted_list;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
|
|
@ -34,15 +29,6 @@ class Payment extends Common
|
|||
|
||||
// 权限校验
|
||||
$this->Is_Power();
|
||||
|
||||
// 插件目录
|
||||
$this->payment_dir = APP_PATH.'Library'.DS.'Payment'.DS;
|
||||
|
||||
// 支付业务类型
|
||||
$this->payment_business_type_all = config('payment_business_type_all');
|
||||
|
||||
// 不删除的支付方式
|
||||
$this->cannot_deleted_list = ['DeliveryPayment', 'CashPayment'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,115 +40,18 @@ class Payment extends Common
|
|||
*/
|
||||
public function Index()
|
||||
{
|
||||
$this->assign('list', $this->GetPaymentList());
|
||||
$this->assign('cannot_deleted_list', $this->cannot_deleted_list);
|
||||
$this->display('Index');
|
||||
// 插件列表
|
||||
$this->assign('data_list', PaymentService::PlugPaymentList());
|
||||
|
||||
// 不删除的支付方式
|
||||
$this->assign('cannot_deleted_list', PaymentService::$cannot_deleted_list);
|
||||
|
||||
// 适用平台
|
||||
$this->assign('common_platform_type', lang('common_platform_type'));
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付插件列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
*/
|
||||
private function GetPaymentList()
|
||||
{
|
||||
$data = [];
|
||||
if(is_dir($this->payment_dir))
|
||||
{
|
||||
if($dh = opendir($this->payment_dir))
|
||||
{
|
||||
while(($temp_file = readdir($dh)) !== false)
|
||||
{
|
||||
if(substr($temp_file, 0, 1) != '.')
|
||||
{
|
||||
// 获取模块配置信息
|
||||
$payment = htmlentities(str_replace('.class.php', '', $temp_file));
|
||||
$config = $this->GetPaymentConfig($payment);
|
||||
if($config !== false)
|
||||
{
|
||||
// 数据组装
|
||||
$temp = $this->DataAnalysis($config);
|
||||
$temp['id'] = date('YmdHis').GetNumberCode(8);
|
||||
$temp['payment'] = $payment;
|
||||
|
||||
// 获取数据库配置信息
|
||||
$db_config = ResourcesService::PaymentList(['where'=>['payment'=>$payment]]);
|
||||
if(!empty($db_config[0]))
|
||||
{
|
||||
$temp['is_install'] = 1;
|
||||
$temp['id'] = $db_config[0]['id'];
|
||||
$temp['name'] = $db_config[0]['name'];
|
||||
$temp['logo'] = $db_config[0]['logo'];
|
||||
$temp['apply_terminal'] = $db_config[0]['apply_terminal'];
|
||||
$temp['config'] = $db_config[0]['config'];
|
||||
$temp['is_enable'] = $db_config[0]['is_enable'];
|
||||
$temp['is_open_user'] = $db_config[0]['is_open_user'];
|
||||
}
|
||||
$data[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据解析
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $data [插件配置信息]
|
||||
*/
|
||||
private function DataAnalysis($data)
|
||||
{
|
||||
return [
|
||||
'name' => isset($data['base']['name']) ? htmlentities($data['base']['name']) : $payment,
|
||||
'version' => isset($data['base']['version']) ? htmlentities($data['base']['version']) : '',
|
||||
'apply_version' => isset($data['base']['apply_version']) ? htmlentities($data['base']['apply_version']) : '',
|
||||
'desc' => isset($data['base']['desc']) ? $data['base']['desc'] : '',
|
||||
'author' => isset($data['base']['author']) ? htmlentities($data['base']['author']) : '',
|
||||
'author_url' => isset($data['base']['author_url']) ? htmlentities($data['base']['author_url']) : '',
|
||||
'element' => isset($data['element']) ? $data['element'] : [],
|
||||
|
||||
'logo' => '',
|
||||
'is_enable' => 0,
|
||||
'is_open_user' => 0,
|
||||
'is_install' => 0,
|
||||
'apply_terminal'=> array_column(lang('common_platform_type'), 'value'),
|
||||
'config' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付模块配置信息
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [string] $payment [模块名称]
|
||||
*/
|
||||
private function GetPaymentConfig($payment)
|
||||
{
|
||||
$payment = '\base\Payment\\'.$payment;
|
||||
if(class_exists($payment))
|
||||
{
|
||||
$obj = new $payment();
|
||||
if(method_exists($obj, 'Config') && method_exists($obj, 'Pay') && method_exists($obj, 'Respond'))
|
||||
{
|
||||
return $obj->Config();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* [SaveInfo 添加/编辑页面]
|
||||
* @author Devil
|
||||
|
|
@ -172,21 +61,32 @@ class Payment extends Common
|
|||
*/
|
||||
public function SaveInfo()
|
||||
{
|
||||
// 轮播图片信息
|
||||
$data = empty($_REQUEST['id']) ? array() : db('Payment')->find(I('id'));
|
||||
$data['apply_terminal'] = empty($data['apply_terminal']) ? [] : json_decode($data['apply_terminal'], true);
|
||||
$data['element'] = empty($data['element']) ? [] : json_decode($data['element'], true);
|
||||
$data['config'] = empty($data['config']) ? [] : json_decode($data['config'], true);
|
||||
//print_r($data['config']);
|
||||
$this->assign('data', $data);
|
||||
// 参数
|
||||
$params = input();
|
||||
|
||||
// 商品信息
|
||||
if(!empty($params['id']))
|
||||
{
|
||||
$data_params = [
|
||||
'where' => ['id'=>$params['id']],
|
||||
'm' => 0,
|
||||
'n' => 1,
|
||||
];
|
||||
$data = PaymentService::PaymentList($data_params);
|
||||
if(empty($data[0]))
|
||||
{
|
||||
return $this->error('没有相关支付方式', url('admin/payment/index'));
|
||||
}
|
||||
$this->assign('data', $data[0]);
|
||||
}
|
||||
|
||||
// 适用平台
|
||||
$this->assign('common_platform_type', lang('common_platform_type'));
|
||||
|
||||
// 参数
|
||||
$this->assign('param', array_merge($_POST, $_GET));
|
||||
$this->assign('params', $params);
|
||||
|
||||
$this->display('SaveInfo');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,67 +99,15 @@ class Payment extends Common
|
|||
public function Save()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 图片
|
||||
$this->FileSave('logo', 'file_logo', 'payment');
|
||||
|
||||
// id为空则表示是新增
|
||||
$m = D('Payment');
|
||||
|
||||
// 公共额外数据处理
|
||||
$_POST['is_enable'] = intval(I('is_enable', 0));
|
||||
$_POST['is_open_user'] = intval(I('is_open_user', 0));
|
||||
|
||||
// 编辑
|
||||
if($m->create($_POST, 2))
|
||||
{
|
||||
// 额外数据处理
|
||||
$m->upd_time = time();
|
||||
$m->apply_terminal = empty($_POST['apply_terminal']) ? '' : json_encode(explode(',', I('apply_terminal')));
|
||||
$m->name = I('name');
|
||||
$m->sort = intval(I('sort'));
|
||||
|
||||
// 插件配置信息处理
|
||||
$m->config = json_encode($this->GetPlugConfig());
|
||||
|
||||
// 移除 id
|
||||
unset($m->id);
|
||||
|
||||
// 更新数据库
|
||||
if($m->where(array('id'=>I('id')))->save())
|
||||
{
|
||||
$this->ajaxReturn('编辑成功');
|
||||
} else {
|
||||
$this->ajaxReturn('编辑失败或数据未改变', -100);
|
||||
}
|
||||
} else {
|
||||
$this->ajaxReturn($m->getError(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-18
|
||||
* @desc description
|
||||
*/
|
||||
private function GetPlugConfig()
|
||||
{
|
||||
$data = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
if(substr($k, 0, 8) == 'plugins_')
|
||||
{
|
||||
$data[substr($k, 8)] = $v;
|
||||
}
|
||||
$this->error('非法访问');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 开始操作
|
||||
$ret = PaymentService::PaymentUpdate(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* [StatusUpdate 状态更新]
|
||||
|
|
@ -270,47 +118,15 @@ class Payment extends Common
|
|||
*/
|
||||
public function StatusUpdate()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 参数
|
||||
if(empty($_POST['id']) || !isset($_POST['state']))
|
||||
{
|
||||
$this->ajaxReturn('参数错误', -1);
|
||||
}
|
||||
$field = I('field', 'is_enable');
|
||||
|
||||
// 数据更新
|
||||
if(db('Payment')->where(array('payment'=>I('id')))->save(array($field=>I('state'))))
|
||||
{
|
||||
$this->ajaxReturn('编辑成功');
|
||||
} else {
|
||||
$this->ajaxReturn('编辑失败或数据未改变', -100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [PowerCheck 权限校验]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-29T00:01:49+0800
|
||||
*/
|
||||
private function PowerCheck()
|
||||
{
|
||||
// 主目录权限
|
||||
if(!is_writable(ROOT_PATH))
|
||||
{
|
||||
$this->ajaxReturn('服务器用户没操作权限'.'['.ROOT_PATH.']', -3);
|
||||
}
|
||||
|
||||
// 插件权限
|
||||
if(!is_writable($this->payment_dir))
|
||||
{
|
||||
$this->ajaxReturn('服务器用户没操作权限'.'['.$this->payment_dir.']', -3);
|
||||
}
|
||||
// 开始操作
|
||||
$ret = PaymentService::PaymentStatusUpdate(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -323,50 +139,15 @@ class Payment extends Common
|
|||
*/
|
||||
public function Install()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 权限
|
||||
$this->PowerCheck();
|
||||
|
||||
// 参数
|
||||
if(empty($_POST['id']))
|
||||
{
|
||||
$this->ajaxReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 数据处理
|
||||
$payment = I('id');
|
||||
$config = $this->GetPaymentConfig($payment);
|
||||
if($config !== false)
|
||||
{
|
||||
$data = $this->DataAnalysis($config);
|
||||
$data['payment'] = $payment;
|
||||
$data['element'] = empty($data['element']) ? '' : json_encode($data['element']);
|
||||
$data['apply_terminal'] = empty($data['apply_terminal']) ? '' : json_encode($data['apply_terminal']);
|
||||
$data['add_time'] = time();
|
||||
|
||||
// 开始安装
|
||||
$m = D('Payment');
|
||||
if($m->create($data, 1))
|
||||
{
|
||||
if($m->add($data))
|
||||
{
|
||||
// 入口文件生成
|
||||
$this->PaymentEntranceCreated($payment);
|
||||
|
||||
$this->ajaxReturn('安装成功');
|
||||
} else {
|
||||
$this->ajaxReturn('安装失败', -100);
|
||||
}
|
||||
} else {
|
||||
$this->ajaxReturn($m->getError(), -1);
|
||||
}
|
||||
} else {
|
||||
$this->ajaxReturn('插件配置有误', -10);
|
||||
}
|
||||
// 开始操作
|
||||
$ret = PaymentService::Install(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -379,28 +160,15 @@ class Payment extends Common
|
|||
*/
|
||||
public function Uninstall()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 参数
|
||||
if(empty($_POST['id']))
|
||||
{
|
||||
$this->ajaxReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 开始卸载
|
||||
$payment = I('id');
|
||||
if(db('Payment')->where(['payment'=>$payment])->delete())
|
||||
{
|
||||
// 删除入口文件
|
||||
$this->PaymentEntranceDelete($payment);
|
||||
|
||||
$this->ajaxReturn('卸载成功');
|
||||
} else {
|
||||
$this->ajaxReturn('卸载失败', -100);
|
||||
}
|
||||
// 开始操作
|
||||
$ret = PaymentService::Uninstall(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -413,49 +181,15 @@ class Payment extends Common
|
|||
*/
|
||||
public function Delete()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 权限
|
||||
$this->PowerCheck();
|
||||
|
||||
// 参数
|
||||
if(empty($_POST['id']))
|
||||
{
|
||||
$this->ajaxReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 是否禁止删除
|
||||
$payment = I('id');
|
||||
if(in_array($payment, $this->cannot_deleted_list))
|
||||
{
|
||||
$this->ajaxReturn('该支付方式禁止删除', -10);
|
||||
}
|
||||
|
||||
// 是否存在
|
||||
$file = $this->payment_dir.$payment.'.class.php';
|
||||
if(!file_exists($file))
|
||||
{
|
||||
$this->ajaxReturn('资源不存在或已被删除', -2);
|
||||
}
|
||||
// 权限
|
||||
if(!is_writable($file))
|
||||
{
|
||||
$this->ajaxReturn('服务器用户没操作权限', -3);
|
||||
}
|
||||
|
||||
// 删除
|
||||
if(!@unlink($file))
|
||||
{
|
||||
$this->ajaxReturn('删除失败或资源不存在', -100);
|
||||
}
|
||||
|
||||
// 删除入口文件
|
||||
$this->PaymentEntranceDelete($payment);
|
||||
|
||||
$this->ajaxReturn('删除成功');
|
||||
// 开始操作
|
||||
$ret = PaymentService::Delete(input());
|
||||
return json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -468,148 +202,15 @@ class Payment extends Common
|
|||
*/
|
||||
public function Upload()
|
||||
{
|
||||
// 是否ajax
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 权限
|
||||
$this->PowerCheck();
|
||||
|
||||
// 文件上传校验
|
||||
$error = FileUploadError('file');
|
||||
if($error !== true)
|
||||
{
|
||||
$this->ajaxReturn($error, -1);
|
||||
}
|
||||
|
||||
// 文件格式化校验
|
||||
$type = array('text/php');
|
||||
if(!in_array($_FILES['file']['type'], $type))
|
||||
{
|
||||
$this->ajaxReturn('文件格式有误,必须php文件', -2);
|
||||
}
|
||||
|
||||
// 是否已有存在插件
|
||||
if(file_exists($this->payment_dir.$_FILES['file']['name']))
|
||||
{
|
||||
$this->ajaxReturn('已存在相同插件', -3);
|
||||
}
|
||||
|
||||
// 存储文件
|
||||
if(!move_uploaded_file($_FILES['file']['tmp_name'], $this->payment_dir.$_FILES['file']['name']))
|
||||
{
|
||||
$this->ajaxReturn('上传失败', -100);
|
||||
}
|
||||
|
||||
// 文件校验
|
||||
$payment = htmlentities(str_replace('.class.php', '', $_FILES['file']['name']));
|
||||
$config = $this->GetPaymentConfig($payment);
|
||||
if($config === false)
|
||||
{
|
||||
@unlink($this->payment_dir.$_FILES['file']['name']);
|
||||
$this->ajaxReturn('插件编写有误,请参考文档编写', -10);
|
||||
}
|
||||
$this->ajaxReturn('上传成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* [PaymentEntranceCreated 入口文件创建]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-28T23:38:52+0800
|
||||
* @param [string] $payment [支付唯一标记]
|
||||
*/
|
||||
private function PaymentEntranceCreated($payment)
|
||||
{
|
||||
// 批量创建
|
||||
foreach($this->payment_business_type_all as $v)
|
||||
{
|
||||
// 异步
|
||||
$notify=<<<php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* {$v['desc']}支付异步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
\$_GET['m'] = 'Api';
|
||||
\$_GET['c'] = '{$v['name']}Notify';
|
||||
\$_GET['a'] = 'Notify';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$payment}');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
||||
php;
|
||||
|
||||
// 同步
|
||||
$respond=<<<php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* {$v['desc']}支付同步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
\$_GET['m'] = 'Home';
|
||||
\$_GET['c'] = '{$v['name']}';
|
||||
\$_GET['a'] = 'Respond';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$payment}');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
||||
php;
|
||||
$name = strtolower($v['name']);
|
||||
@file_put_contents(ROOT_PATH.'payment_'.$name.'_'.strtolower($payment).'_respond.php', $respond);
|
||||
|
||||
// 线下支付不生成异步入口文件
|
||||
if(!in_array($payment, config('under_line_list')))
|
||||
{
|
||||
@file_put_contents(ROOT_PATH.'payment_'.$name.'_'.strtolower($payment).'_notify.php', $notify);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [PaymentEntranceDelete 入口文件删除]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-28T23:38:52+0800
|
||||
* @param [string] $payment [支付唯一标记]
|
||||
*/
|
||||
private function PaymentEntranceDelete($payment)
|
||||
{
|
||||
$payment = strtolower($payment);
|
||||
foreach($this->payment_business_type_all as $v)
|
||||
{
|
||||
$name = strtolower($v['name']);
|
||||
if(file_exists(ROOT_PATH.'payment_'.$name.'_'.$payment.'_notify.php'))
|
||||
{
|
||||
@unlink(ROOT_PATH.'payment_'.$name.'_'.$payment.'_notify.php');
|
||||
}
|
||||
if(file_exists(ROOT_PATH.'payment_'.$name.'_'.$payment.'_respond.php'))
|
||||
{
|
||||
@unlink(ROOT_PATH.'payment_'.$name.'_'.$payment.'_respond.php');
|
||||
}
|
||||
}
|
||||
// 开始操作
|
||||
$ret = PaymentService::Upload(input());
|
||||
return json($ret);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<!-- operation end -->
|
||||
|
||||
<!-- list start -->
|
||||
<table class="am-table am-table-striped am-table-hover am-text-middle m-t-1)}}
|
||||
<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if !empty($list)}}
|
||||
<foreach name="list" item="v">
|
||||
<tr id="data-list-{{$v.payment}}" {{if $v['is_install'] eq 0)}}class="am-warning"<elseif condition="$v['is_enable'] eq 0" />class="am-active"{{/if}} >
|
||||
{{if !empty($data_list)}}
|
||||
{{foreach $data_list as $v}}
|
||||
<tr id="data-list-{{$v.payment}}" {{if $v['is_install'] eq 0}}class="am-warning"{{elseif $v['is_enable'] eq 0 /}}class="am-active"{{/if}} >
|
||||
<td>
|
||||
{{$v.name}}
|
||||
{{if !empty($v['version'])}}
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<img src="{{$v['logo']}}" class="am-radius" width="100" />
|
||||
</a>
|
||||
{{else /}}
|
||||
<span class="cr-ddd">暂无图片</span>
|
||||
<span class="cr-ddd">暂无LOGO</span>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="am-hide-sm-only">
|
||||
|
|
@ -48,9 +48,9 @@
|
|||
</td>
|
||||
<td>
|
||||
{{if !empty($v['apply_terminal'])}}
|
||||
<foreach name="v.apply_terminal" key="terminal_k" item="terminal_v">
|
||||
{{:lang('common_platform_type')[$terminal_v]['name']}}
|
||||
{{if $terminal_k LT count($v['apply_terminal'])-1)}}<br />{{/if}}
|
||||
{{foreach $v.apply_terminal as $terminal_k=>$terminal_v}}
|
||||
{{$common_platform_type[$terminal_v]['name']}}
|
||||
{{if $terminal_k LT count($v['apply_terminal'])-1}}<br />{{/if}}
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
<span class="cr-ddd">未填写</span>
|
||||
|
|
@ -69,35 +69,35 @@
|
|||
{{/if}}
|
||||
</td>
|
||||
<td class="am-hide-sm-only td-desc">
|
||||
{{if empty($v['desc'])}}<span class="cr-ddd">未填写</span>{{else /}}{{$v.desc}}{{/if}}
|
||||
{{if empty($v['desc'])}}<span class="cr-ddd">未填写</span>{{else /}}{{$v.desc||raw}}{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{if $v['is_install'] eq 1)}}
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1)}}am-success{{else /}}am-default{{/if}}" data-url="{{:url('Admin/Payment/StatusUpdate')}}" data-id="{{$v.payment}}" data-field="is_enable" data-state="{{$v['is_enable']}}" data-is-update-status="1)}}</a>
|
||||
{{if $v['is_install'] eq 1}}
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:url('admin/payment/StatusUpdate')}}" data-id="{{$v.payment}}" data-field="is_enable" data-state="{{$v['is_enable']}}" data-is-update-status="1"></a>
|
||||
{{else /}}
|
||||
<span class="cr-ddd">未安装</span>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{if $v['is_install'] eq 1)}}
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_open_user'] eq 1)}}am-success{{else /}}am-default{{/if}}" data-url="{{:url('Admin/Payment/StatusUpdate')}}" data-id="{{$v.payment}}" data-field="is_open_user" data-state="{{$v['is_open_user']}}"></a>
|
||||
{{if $v['is_install'] eq 1}}
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_open_user'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:url('admin/payment/StatusUpdate')}}" data-id="{{$v.payment}}" data-field="is_open_user" data-state="{{$v['is_open_user']}}"></a>
|
||||
{{else /}}
|
||||
<span class="cr-ddd">未安装</span>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="view-operation">
|
||||
{{if $v['is_install'] eq 0)}}
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax" data-url="{{:url('Admin/Payment/Install')}}" data-id="{{$v.payment}}" data-view="reload" data-msg="安装进行中、确认操作吗?"> 安装</button>
|
||||
{{if $v['is_install'] eq 0}}
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax" data-url="{{:url('admin/payment/install')}}" data-id="{{$v.payment}}" data-view="reload" data-msg="安装进行中、确认操作吗?"> 安装</button>
|
||||
|
||||
{{if !in_array($v['payment'], $cannot_deleted_list)}}
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:url('Admin/Payment/Delete')}}" data-id="{{$v.payment}}"> 删除</button>
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:url('admin/payment/Delete')}}" data-id="{{$v.payment}}"> 删除</button>
|
||||
{{/if}}
|
||||
{{else /}}
|
||||
<a href="{{:url('Admin/Payment/SaveInfo', array('id'=>$v['id']))}}">
|
||||
<a href="{{:url('admin/payment/saveinfo', array('id'=>$v['id']))}}">
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit"> 编辑</button>
|
||||
</a>
|
||||
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-genderless submit-ajax" data-url="{{:url('Admin/Payment/Uninstall')}}" data-id="{{$v.payment}}" data-view="reload" data-msg="卸载后不可恢复、确认操作吗?"> 卸载</button>
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-genderless submit-ajax" data-url="{{:url('admin/payment/uninstall')}}" data-id="{{$v.payment}}" data-view="reload" data-msg="卸载后不可恢复、确认操作吗?"> 卸载</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
</div>
|
||||
<div class="am-popup-bd">
|
||||
<!-- win form start -->
|
||||
<form class="am-form form-validation" action="{{:url('Admin/Payment/Upload')}}" method="POST" request-type="ajax-reload" enctype="multipart/form-data">
|
||||
<form class="am-form form-validation" action="{{:url('admin/payment/upload')}}" method="POST" request-type="ajax-reload" enctype="multipart/form-data">
|
||||
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_file', 51200000)}}" />
|
||||
<div class="am-alert am-radius am-alert-tips m-t-0" data-am-alert>
|
||||
<p class="m-t-1)}}1 类名必须于文件名一致(去除 .class.php ),如 Alipay.class.php 则取 Alipay <br />2 类必须定义三个方法<br /> 2.1 Config 配置方法<br /> 2.2 Pay 支付方法<br /> 2.3 Respond 回调方法</p>
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
<div class="content-right">
|
||||
<div class="content">
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:url('Admin/Payment/Save')}}" method="POST" request-type="ajax-url" request-value="{{:url('Admin/Payment/Index')}}" enctype="multipart/form-data">
|
||||
<form class="am-form form-validation view-save" action="{{:url('admin/payment/save')}}" method="POST" request-type="ajax-url" request-value="{{:url('admin/payment/index')}}" enctype="multipart/form-data">
|
||||
<input type="hidden" name="max_file_size" value="{{:MyC('home_max_limit_image', 2048000)}}" />
|
||||
<legend>
|
||||
<span class="fs-16)}}支付方式编辑</span>
|
||||
<a href="{{:url('Admin/Payment/Index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
<span class="fs-16">支付方式编辑</span>
|
||||
<a href="{{:url('admin/payment/index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
|
||||
</legend>
|
||||
<div class="am-form-group">
|
||||
<label>名称</label>
|
||||
<input type="text" name="name" placeholder="名称" minlength="2" maxlength="60" data-validation-message="名称格式 2~30 个字符" class="am-radius" <notempty name="data"> value="{{$data.name}}"{{/if}} required />
|
||||
<input type="text" name="name" placeholder="名称" minlength="2" maxlength="60" data-validation-message="名称格式 2~30 个字符" class="am-radius" {{if !empty($data)}} value="{{$data.name}}"{{/if}} required />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>适用终端</label>
|
||||
<select name="apply_terminal" class="am-radius c-p chosen-select" multiple="multiple" minchecked="1" data-placeholder="可选择..." data-validation-message="至少选择一个适用终端" required>
|
||||
<foreach name="common_platform_type" item="v">
|
||||
{{foreach $common_platform_type as $v}}
|
||||
<option value="{{$v.value}}" {{if isset($data['apply_terminal']) and in_array($v['value'], $data['apply_terminal'])}}selected{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
|
|
@ -25,36 +25,46 @@
|
|||
|
||||
<div class="am-form-group am-form-file">
|
||||
<label class="block">LOGO</label>
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm am-radius">
|
||||
<i class="am-icon-cloud-upload"></i> 选择图片</button>
|
||||
<input type="text" name="logo" class="am-radius js-choice-one original-images-url" data-choice-one-to=".images-file-event" <notempty name="data"> value="{{$data.logo}}"{{/if}}" data-validation-message="请选择需要上传的图片" readonly="readonly" <notempty name="data"> value="{{$data.logo}}"{{/if}} />
|
||||
<input type="file" name="file_logo" multiple data-validation-message="请选择需要上传的图片" accept="image/gif,image/jpeg,image/jpg,image/png" class="js-choice-one images-file-event" data-choice-one-to=".original-images-url" data-tips-tag="#form-logo-tips" data-image-tag="#form-img-logo" />
|
||||
<div id="form-logo-tips" class="m-t-5)}}</div>
|
||||
<img src="{{if !empty($data['logo'])}}{{$image_host}}{{$data.logo}}{{else /}}{{$image_host}}/Public/Admin/Default/Images/default-images.png{{/if}}" id="form-img-logo" class="block m-t-5 am-img-thumbnail am-radius" width="100" data-default="{{if !empty($data['logo'])}}{{$image_host}}{{$data.logo}}{{else /}}{{$image_host}}/Public/Admin/Default/Images/default-images.png{{/if}}" />
|
||||
<ul class="plug-file-upload-view logo-images-view" data-form-name="logo" data-max-number="1" data-dialog-type="images">
|
||||
{{if !empty($data['logo'])}}
|
||||
<li>
|
||||
<input type="text" name="logo" value="{{$data.logo}}" />
|
||||
<img src="{{$data.logo}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
<div class="plug-file-upload-submit" data-view-tag="ul.logo-images-view">+上传图片</div>
|
||||
</div>
|
||||
|
||||
<!-- plugins config start -->
|
||||
<notempty name="data.element">
|
||||
{{if !empty($data['element'])}}
|
||||
<div class="plugins-element">
|
||||
<p class="tips">该区域为插件配置填写项,请按照插件文档填写相应的值。</p>
|
||||
<foreach name="data.element" item="element">
|
||||
{{foreach $data.element as $element}}
|
||||
<div class="am-form-group">
|
||||
<label class="block">{{$element.title}}</label>
|
||||
<switch name="element.element">
|
||||
<case value="input">
|
||||
{{switch element.element}}
|
||||
{{case input}}
|
||||
{{if in_array($element['type'], ['radio', 'checkbox']) and !empty($element['element_data']) and is_array($element['element_data'])}}
|
||||
<foreach name="element.element_data" key="element_data_key" item="element_data">
|
||||
<label class="{{if isset($element['is_block']) and $element['is_block'] eq 1)}}am-{{$element.type}}{{else /}}am-{{$element.type}}-inline{{/if}}">
|
||||
{{foreach $element.element_data as $element_data_key=>$element_data}}
|
||||
<label class="{{if isset($element['is_block']) and $element['is_block'] eq 1}}am-{{$element.type}}{{else /}}am-{{$element.type}}-inline{{/if}}">
|
||||
<input
|
||||
type="{{$element.type}}"
|
||||
name="plugins_{{$element.name}}"
|
||||
value="{{$element_data.value}}"
|
||||
{{if (isset($element_data['is_checked']) and $element_data['is_checked'] eq 1) or (isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']])))}}checked{{/if}}
|
||||
{{if isset($element['minchecked']) and $element['type'] eq 'checkbox'">minchecked="{{$element.minchecked}}"{{/if}}
|
||||
{{if isset($element['maxchecked']) and $element['type'] eq 'checkbox'">maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
{{if isset($element['message'])}}data-validation-message="{{$element.message}}"{{/if}}
|
||||
{{if $element_data_key eq 0 and isset($element['is_required']) and $element['is_required'] eq 1)}}required{{/if}}
|
||||
data-am-ucheck />{{$element_data.name}}
|
||||
|
||||
{{if isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']]))}} checked{{/if}}
|
||||
|
||||
{{if isset($element['minchecked']) and $element['type'] eq 'checkbox'}} minchecked="{{$element.minchecked}}"{{/if}}
|
||||
|
||||
{{if isset($element['maxchecked']) and $element['type'] eq 'checkbox'}} maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if $element_data_key eq 0 and isset($element['is_required']) and $element['is_required'] eq 1}}required{{/if}}
|
||||
data-am-ucheck />
|
||||
{{$element_data.name}}
|
||||
</label>
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
|
|
@ -63,52 +73,64 @@
|
|||
type="{{$element.type}}"
|
||||
name="plugins_{{$element.name}}"
|
||||
value="{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}"
|
||||
{{if isset($element['placeholder'])}}placeholder="{{$element.placeholder}}"{{/if}}
|
||||
{{if isset($element['message'])}}data-validation-message="{{$element.message}}"{{/if}}
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1)}}required{{/if}}
|
||||
|
||||
{{if isset($element['placeholder'])}} placeholder="{{$element.placeholder}}"{{/if}}
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}} required{{/if}}
|
||||
/>
|
||||
{{/if}}
|
||||
</case>
|
||||
<case value="select">
|
||||
{{/case}}
|
||||
{{case select}}
|
||||
{{if !empty($element['element_data']) and is_array($element['element_data'])}}
|
||||
<select
|
||||
class="chosen-select am-radius"
|
||||
name="plugins_{{$element.name}}"
|
||||
{{if isset($element['message'])}}data-validation-message="{{$element.message}}"{{/if}}
|
||||
{{if isset($element['placeholder'])}}data-placeholder="{{$element.placeholder}}"{{else /}}可选择...{{/if}}
|
||||
{{if isset($element['is_multiple']) and $element['is_multiple'] eq 1)}}
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if isset($element['placeholder'])}} data-placeholder="{{$element.placeholder}}"{{else /}}可选择...{{/if}}
|
||||
|
||||
{{if isset($element['is_multiple']) and $element['is_multiple'] eq 1}}
|
||||
multiple
|
||||
{{if isset($element['minchecked'])}}minchecked="{{$element.minchecked}}"{{/if}}
|
||||
{{if isset($element['maxchecked'])}}maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
{{if isset($element['minchecked'])}} minchecked="{{$element.minchecked}}"{{/if}}
|
||||
{{if isset($element['maxchecked'])}} maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
{{/if}}
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1)}}required{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}}required{{/if}}
|
||||
>
|
||||
{{if !isset($element['is_multiple']) or $element['is_multiple'] neq 1)}}
|
||||
<option value="">{{if isset($element['placeholder'])}}{{$element.placeholder}}{{else /}}可选择...{{/if}}</option>
|
||||
{{if !isset($element['is_multiple']) or $element['is_multiple'] neq 1}}
|
||||
<option value="">
|
||||
{{if isset($element['placeholder'])}}{{$element.placeholder}}{{else /}}可选择...{{/if}}
|
||||
</option>
|
||||
{{/if}}
|
||||
<foreach name="element.element_data" key="element_data_key" item="element_data">
|
||||
{{foreach $element.element_data as $element_data_key=>$element_data}}
|
||||
<option
|
||||
value="{{$element_data.value}}"
|
||||
{{if (isset($element_data['is_selected']) and $element_data['is_selected'] eq 1) or (isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']])))}}selected{{/if}}
|
||||
{{if isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']]))}}selected{{/if}}
|
||||
>{{$element_data.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
{{/if}}
|
||||
</case>
|
||||
<case value="textarea">
|
||||
{{/case}}
|
||||
{{case textarea}}
|
||||
<textarea
|
||||
class="am-radius"
|
||||
name="plugins_{{$element.name}}"
|
||||
{{if isset($element['rows'])}}rows="{{$element.rows}}"{{/if}}
|
||||
{{if isset($element['placeholder'])}}placeholder="{{$element.placeholder}}"{{/if}}
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1)}}
|
||||
{{if isset($element['minlength'])}}minlength="{{$element.minlength}}"{{/if}}
|
||||
{{if isset($element['maxlength'])}}maxlength="{{$element.maxlength}}"{{/if}}
|
||||
|
||||
{{if isset($element['rows'])}} rows="{{$element.rows}}"{{/if}}
|
||||
|
||||
{{if isset($element['placeholder'])}} placeholder="{{$element.placeholder}}"{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}}
|
||||
{{if isset($element['minlength'])}} minlength="{{$element.minlength}}"{{/if}}
|
||||
{{if isset($element['maxlength'])}} maxlength="{{$element.maxlength}}"{{/if}}
|
||||
required
|
||||
{{/if}}
|
||||
>{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}</textarea>
|
||||
</case>
|
||||
</switch>
|
||||
{{/case}}
|
||||
{{/switch}}
|
||||
</div>
|
||||
{{/foreach}}
|
||||
</div>
|
||||
|
|
@ -130,7 +152,7 @@
|
|||
<input name="is_enable" value="1" type="checkbox" data-off-text="否" data-on-text="是" data-size="xs" data-on-color="success" data-off-color="default" data-handle-width="50" data-am-switch {{if (isset($data['is_enable']) and $data['is_enable'] eq 1) or !isset($data['is_enable'])}}checked="true"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<input type="hidden" name="id" <notempty name="data"> value="{{$data.id}}"{{/if}} />
|
||||
<input type="hidden" name="id" {{if !empty($data)}} value="{{$data.id}}"{{/if}} />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace app\index\controller;
|
|||
|
||||
use app\service\GoodsService;
|
||||
use app\service\UserService;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\PaymentService;
|
||||
use app\service\BuyService;
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ class Buy extends Common
|
|||
$this->assign('user_address_list', UserService::UserAddressList(['user'=>$this->user])['data']);
|
||||
|
||||
// 支付方式
|
||||
$this->assign('payment_list', ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
$this->assign('payment_list', PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
|
||||
// 商品/基础信息
|
||||
$base = [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
namespace app\index\controller;
|
||||
|
||||
use app\service\OrderService;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\PaymentService;
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
|
|
@ -74,7 +74,7 @@ class Order extends Common
|
|||
$this->assign('data_list', $data['data']);
|
||||
|
||||
// 支付方式
|
||||
$this->assign('payment_list', ResourcesService::PaymentList());
|
||||
$this->assign('payment_list', PaymentService::PaymentList());
|
||||
|
||||
// 订单状态
|
||||
$this->assign('common_order_user_status', lang('common_order_user_status'));
|
||||
|
|
@ -118,7 +118,7 @@ class Order extends Common
|
|||
if(!empty($data['data'][0]))
|
||||
{
|
||||
// 发起支付 - 支付方式
|
||||
$this->assign('buy_payment_list', ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
$this->assign('buy_payment_list', PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
|
||||
|
||||
$this->assign('data', $data['data'][0]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1461,7 +1461,7 @@ class GoodsService
|
|||
}
|
||||
|
||||
/**
|
||||
* 商品上下架状态更新
|
||||
* 商品状态更新
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace app\service;
|
|||
|
||||
use think\Db;
|
||||
use app\service\GoodsService;
|
||||
use app\service\ResourcesService;
|
||||
use app\service\PaymentService;
|
||||
use app\service\BuyService;
|
||||
use app\service\IntegralService;
|
||||
use app\service\RegionService;
|
||||
|
|
@ -67,7 +67,7 @@ class OrderService
|
|||
|
||||
// 支付方式
|
||||
$payment_id = empty($params['payment_id']) ? $order['payment_id'] : intval($params['payment_id']);
|
||||
$payment = ResourcesService::PaymentList(['where'=>['id'=>$payment_id]]);
|
||||
$payment = PaymentService::PaymentList(['where'=>['id'=>$payment_id]]);
|
||||
if(empty($payment[0]))
|
||||
{
|
||||
return DataReturn('支付方式有误', -1);
|
||||
|
|
@ -170,7 +170,7 @@ class OrderService
|
|||
|
||||
// 支付方式
|
||||
$payment_id = empty($params['payment_id']) ? $order['payment_id'] : intval($params['payment_id']);
|
||||
$payment = ResourcesService::PaymentList(['where'=>['id'=>$payment_id]]);
|
||||
$payment = PaymentService::PaymentList(['where'=>['id'=>$payment_id]]);
|
||||
if(empty($payment[0]))
|
||||
{
|
||||
return DataReturn('支付方式有误', -1);
|
||||
|
|
@ -242,7 +242,7 @@ class OrderService
|
|||
}
|
||||
|
||||
// 支付方式
|
||||
$payment = ResourcesService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]);
|
||||
$payment = PaymentService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]);
|
||||
if(empty($payment[0]))
|
||||
{
|
||||
return DataReturn('支付方式有误', -1);
|
||||
|
|
@ -280,7 +280,7 @@ class OrderService
|
|||
public static function Notify($params = [])
|
||||
{
|
||||
// 支付方式
|
||||
$payment = ResourcesService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]);
|
||||
$payment = PaymentService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]);
|
||||
if(empty($payment[0]))
|
||||
{
|
||||
return DataReturn('支付方式有误', -1);
|
||||
|
|
@ -550,7 +550,7 @@ class OrderService
|
|||
$v['express_name'] = ExpressService::ExpressName($v['express_id']);
|
||||
|
||||
// 支付方式
|
||||
$v['payment_name'] = ($v['status'] <= 1) ? null : ResourcesService::OrderPaymentName($v['id']);
|
||||
$v['payment_name'] = ($v['status'] <= 1) ? null : PaymentService::OrderPaymentName($v['id']);
|
||||
|
||||
// 收件人地址
|
||||
$v['receive_province_name'] = RegionService::RegionName($v['receive_province']);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,711 @@
|
|||
<?php
|
||||
namespace app\service;
|
||||
|
||||
use think\Db;
|
||||
use app\service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 支付方式服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class PaymentService
|
||||
{
|
||||
// 插件目录
|
||||
public static $payment_dir;
|
||||
|
||||
// 支付业务类型
|
||||
public static $payment_business_type_all;
|
||||
|
||||
// 不删除的支付方式
|
||||
public static $cannot_deleted_list;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-12-24
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
private static function Init($params = [])
|
||||
{
|
||||
// 插件目录
|
||||
self::$payment_dir = ROOT.'extend'.DS.'payment'.DS;
|
||||
|
||||
// 支付业务类型
|
||||
self::$payment_business_type_all = config('payment_business_type_all');
|
||||
|
||||
// 不删除的支付方式
|
||||
self::$cannot_deleted_list = ['DeliveryPayment', 'CashPayment'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付插件列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
*/
|
||||
public static function PlugPaymentList()
|
||||
{
|
||||
// 初始化
|
||||
self::Init();
|
||||
|
||||
// 开始处理
|
||||
$data = [];
|
||||
if(is_dir(self::$payment_dir))
|
||||
{
|
||||
if($dh = opendir(self::$payment_dir))
|
||||
{
|
||||
while(($temp_file = readdir($dh)) !== false)
|
||||
{
|
||||
if(substr($temp_file, 0, 1) != '.')
|
||||
{
|
||||
// 获取模块配置信息
|
||||
$payment = htmlentities(str_replace('.php', '', $temp_file));
|
||||
$config = self::GetPaymentConfig($payment);
|
||||
if($config !== false)
|
||||
{
|
||||
// 数据组装
|
||||
$temp = self::DataAnalysis($config);
|
||||
$temp['id'] = date('YmdHis').GetNumberCode(8);
|
||||
$temp['payment'] = $payment;
|
||||
|
||||
// 获取数据库配置信息
|
||||
$db_config = self::PaymentList(['where'=>['payment'=>$payment]]);
|
||||
if(!empty($db_config[0]))
|
||||
{
|
||||
$temp['is_install'] = 1;
|
||||
$temp['id'] = $db_config[0]['id'];
|
||||
$temp['name'] = $db_config[0]['name'];
|
||||
$temp['logo'] = $db_config[0]['logo'];
|
||||
$temp['apply_terminal'] = $db_config[0]['apply_terminal'];
|
||||
$temp['config'] = $db_config[0]['config'];
|
||||
$temp['is_enable'] = $db_config[0]['is_enable'];
|
||||
$temp['is_open_user'] = $db_config[0]['is_open_user'];
|
||||
}
|
||||
$data[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付模块配置信息
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [string] $payment [模块名称]
|
||||
*/
|
||||
private static function GetPaymentConfig($payment)
|
||||
{
|
||||
$payment = '\payment\\'.$payment;
|
||||
if(class_exists($payment))
|
||||
{
|
||||
$obj = new $payment();
|
||||
if(method_exists($obj, 'Config') && method_exists($obj, 'Pay') && method_exists($obj, 'Respond'))
|
||||
{
|
||||
return $obj->Config();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据解析
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $data [插件配置信息]
|
||||
*/
|
||||
private static function DataAnalysis($data)
|
||||
{
|
||||
return [
|
||||
'name' => isset($data['base']['name']) ? htmlentities($data['base']['name']) : $payment,
|
||||
'version' => isset($data['base']['version']) ? htmlentities($data['base']['version']) : '',
|
||||
'apply_version' => isset($data['base']['apply_version']) ? htmlentities($data['base']['apply_version']) : '',
|
||||
'desc' => isset($data['base']['desc']) ? $data['base']['desc'] : '',
|
||||
'author' => isset($data['base']['author']) ? htmlentities($data['base']['author']) : '',
|
||||
'author_url' => isset($data['base']['author_url']) ? htmlentities($data['base']['author_url']) : '',
|
||||
'element' => isset($data['element']) ? $data['element'] : [],
|
||||
|
||||
'logo' => '',
|
||||
'is_enable' => 0,
|
||||
'is_open_user' => 0,
|
||||
'is_install' => 0,
|
||||
'apply_terminal'=> empty($data['base']['apply_terminal']) ? array_column(lang('common_platform_type'), 'value') : $data['base']['apply_terminal'],
|
||||
'config' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function PaymentList($params = [])
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
if(isset($params['is_enable']))
|
||||
{
|
||||
$where['is_enable'] = intval($params['is_enable']);
|
||||
}
|
||||
if(isset($params['is_open_user']))
|
||||
{
|
||||
$where['is_open_user'] = intval($params['is_open_user']);
|
||||
}
|
||||
|
||||
$data = Db::name('Payment')->where($where)->field('id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user')->order('sort asc')->select();
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
$images_host = config('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['logo_old'] = $v['logo'];
|
||||
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
|
||||
$v['element'] = empty($v['element']) ? '' : json_decode($v['element'], true);
|
||||
$v['config'] = empty($v['config']) ? '' : json_decode($v['config'], true);
|
||||
$v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付方式列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc 下订单根据终端自动筛选支付方式
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function BuyPaymentList($params = [])
|
||||
{
|
||||
$data = self::PaymentList($params);
|
||||
|
||||
$result = [];
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
// 根据终端类型筛选
|
||||
if(in_array(APPLICATION_CLIENT_TYPE, $v['apply_terminal']))
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单支付名称
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [int] $order_id [订单id]
|
||||
*/
|
||||
public static function OrderPaymentName($order_id = 0)
|
||||
{
|
||||
return empty($order_id) ? null : Db::name('PayLog')->where(['order_id'=>intval($order_id)])->value('payment_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据更新
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-12-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function PaymentUpdate($params = [])
|
||||
{
|
||||
// 请求类型
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'id',
|
||||
'error_msg' => '操作id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'length',
|
||||
'key_name' => 'name',
|
||||
'checked_data' => '2,60',
|
||||
'error_msg' => '名称长度 2~60 个字符',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'apply_terminal',
|
||||
'error_msg' => '至少选择一个适用终端',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'length',
|
||||
'key_name' => 'sort',
|
||||
'checked_data' => '3',
|
||||
'error_msg' => '顺序 0~255 之间的数值',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 附件
|
||||
$data_fields = ['logo'];
|
||||
$attachment = ResourcesService::AttachmentParams($params, $data_fields);
|
||||
|
||||
// 数据
|
||||
$data = [
|
||||
'name' => $params['name'],
|
||||
'apply_terminal' => empty($params['apply_terminal']) ? '' : json_encode(explode(',', $params['apply_terminal'])),
|
||||
'logo' => $attachment['data']['logo'],
|
||||
'config' => json_encode(self::GetPlugConfig($params)),
|
||||
'sort' => intval($params['sort']),
|
||||
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
|
||||
'is_open_user' => isset($params['is_open_user']) ? intval($params['is_open_user']) : 0,
|
||||
];
|
||||
|
||||
$data['upd_time'] = time();
|
||||
if(Db::name('Payment')->where(['id'=>intval($params['id'])])->update($data))
|
||||
{
|
||||
return DataReturn('编辑成功', 0);
|
||||
}
|
||||
return DataReturn('编辑失败', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-18
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
private static function GetPlugConfig($params = [])
|
||||
{
|
||||
$data = [];
|
||||
foreach($params as $k=>$v)
|
||||
{
|
||||
if(substr($k, 0, 8) == 'plugins_')
|
||||
{
|
||||
$data[substr($k, 8)] = $v;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态更新
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function PaymentStatusUpdate($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'id',
|
||||
'error_msg' => '操作id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'field',
|
||||
'error_msg' => '未指定操作字段',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'in',
|
||||
'key_name' => 'state',
|
||||
'checked_data' => [0,1],
|
||||
'error_msg' => '状态有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
if(Db::name('Payment')->where(['payment'=>$params['id']])->update([$params['field']=>intval($params['state']), 'upd_time'=>time()]))
|
||||
{
|
||||
return DataReturn('操作成功');
|
||||
}
|
||||
return DataReturn('操作失败', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限校验
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-29T00:01:49+0800
|
||||
*/
|
||||
private static function PowerCheck()
|
||||
{
|
||||
// 主目录权限
|
||||
$root_path = ROOT.'public';
|
||||
if(!is_writable($root_path))
|
||||
{
|
||||
return DataReturn('目录没有操作权限'.'['.$root_path.']', -3);
|
||||
}
|
||||
|
||||
// 插件权限
|
||||
if(!is_writable(self::$payment_dir))
|
||||
{
|
||||
return DataReturn('目录没有操作权限'.'['.self::$payment_dir.']', -3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传插件
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Upload($params = [])
|
||||
{
|
||||
// 初始化
|
||||
self::Init();
|
||||
|
||||
// 权限
|
||||
$ret = self::PowerCheck();
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 文件上传校验
|
||||
$error = FileUploadError('file');
|
||||
if($error !== true)
|
||||
{
|
||||
return DataReturn($error, -1);
|
||||
}
|
||||
|
||||
// 文件格式化校验
|
||||
$type = array('text/php');
|
||||
if(!in_array($_FILES['file']['type'], $type))
|
||||
{
|
||||
return DataReturn('文件格式有误,必须php文件', -2);
|
||||
}
|
||||
|
||||
// 是否已有存在插件
|
||||
if(file_exists(self::$payment_dir.$_FILES['file']['name']))
|
||||
{
|
||||
return DataReturn('已存在相同插件', -3);
|
||||
}
|
||||
|
||||
// 存储文件
|
||||
if(!move_uploaded_file($_FILES['file']['tmp_name'], self::$payment_dir.$_FILES['file']['name']))
|
||||
{
|
||||
return DataReturn('上传失败', -100);
|
||||
}
|
||||
|
||||
// 文件校验
|
||||
$payment = htmlentities(str_replace('.php', '', $_FILES['file']['name']));
|
||||
$config = self::GetPaymentConfig($payment);
|
||||
if($config === false)
|
||||
{
|
||||
@unlink(self::$payment_dir.$_FILES['file']['name']);
|
||||
return DataReturn('插件编写有误,请参考文档编写', -10);
|
||||
}
|
||||
return DataReturn('上传成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Install($params = [])
|
||||
{
|
||||
// 初始化
|
||||
self::Init();
|
||||
|
||||
// 参数
|
||||
if(empty($params['id']))
|
||||
{
|
||||
return DataReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 数据处理
|
||||
$payment = $params['id'];
|
||||
$config = self::GetPaymentConfig($payment);
|
||||
if($config !== false)
|
||||
{
|
||||
$data = self::DataAnalysis($config);
|
||||
$data['payment'] = $payment;
|
||||
$data['element'] = empty($data['element']) ? '' : json_encode($data['element']);
|
||||
$data['apply_terminal'] = empty($data['apply_terminal']) ? '' : json_encode($data['apply_terminal']);
|
||||
$data['sort'] = 0;
|
||||
$data['add_time'] = time();
|
||||
|
||||
// 移除多余的字段
|
||||
unset($data['is_install']);
|
||||
|
||||
// 开启事务
|
||||
Db::startTrans();
|
||||
if(Db::name('Payment')->insertGetId($data) > 0)
|
||||
{
|
||||
// 入口文件生成
|
||||
$ret = self::PaymentEntranceCreated($payment);
|
||||
if($ret['code'] == 'code')
|
||||
{
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
|
||||
return DataReturn('安装成功');
|
||||
} else {
|
||||
// 事务回滚
|
||||
Db::rollback();
|
||||
return $ret;
|
||||
}
|
||||
} else {
|
||||
// 事务回滚
|
||||
Db::rollback();
|
||||
return DataReturn('安装失败', -100);
|
||||
}
|
||||
} else {
|
||||
return DataReturn('插件配置有误', -10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除插件
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Delete($params = [])
|
||||
{
|
||||
// 初始化
|
||||
self::Init();
|
||||
|
||||
// 权限
|
||||
$ret = self::PowerCheck();
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 参数
|
||||
if(empty($params['id']))
|
||||
{
|
||||
return DataReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 是否禁止删除
|
||||
$payment = $params['id'];
|
||||
if(in_array($payment, self::$cannot_deleted_list))
|
||||
{
|
||||
return DataReturn('该支付方式禁止删除', -10);
|
||||
}
|
||||
|
||||
// 是否存在
|
||||
$file = self::$payment_dir.$payment.'.php';
|
||||
if(!file_exists($file))
|
||||
{
|
||||
return DataReturn('资源不存在或已被删除', -2);
|
||||
}
|
||||
// 权限
|
||||
if(!is_writable($file))
|
||||
{
|
||||
return DataReturn('没操作权限', -3);
|
||||
}
|
||||
|
||||
// 删除
|
||||
if(!@unlink($file))
|
||||
{
|
||||
return DataReturn('删除失败', -100);
|
||||
}
|
||||
|
||||
// 删除入口文件
|
||||
self::PaymentEntranceDelete($payment);
|
||||
|
||||
return DataReturn('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-17
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Uninstall($params = [])
|
||||
{
|
||||
// 参数
|
||||
if(empty($params['id']))
|
||||
{
|
||||
return DataReturn('参数错误', -1);
|
||||
}
|
||||
|
||||
// 初始化
|
||||
self::Init();
|
||||
|
||||
// 开始卸载
|
||||
$payment = $params['id'];
|
||||
if(db('Payment')->where(['payment'=>$payment])->delete())
|
||||
{
|
||||
// 删除入口文件
|
||||
self::PaymentEntranceDelete($payment);
|
||||
|
||||
return DataReturn('卸载成功', 0);
|
||||
}
|
||||
return DataReturn('卸载失败', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* [PaymentEntranceCreated 入口文件创建]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-28T23:38:52+0800
|
||||
* @param [string] $payment [支付唯一标记]
|
||||
*/
|
||||
private static function PaymentEntranceCreated($payment)
|
||||
{
|
||||
// 权限
|
||||
$ret = self::PowerCheck();
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// 批量创建
|
||||
foreach(self::$payment_business_type_all as $v)
|
||||
{
|
||||
// 异步
|
||||
$notify=<<<php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* {$v['desc']}支付异步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
\$_GET['m'] = 'Api';
|
||||
\$_GET['c'] = '{$v['name']}Notify';
|
||||
\$_GET['a'] = 'Notify';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$payment}');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
||||
php;
|
||||
|
||||
// 同步
|
||||
$respond=<<<php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* {$v['desc']}支付同步入口
|
||||
*/
|
||||
|
||||
// 默认绑定模块
|
||||
\$_GET['m'] = 'Home';
|
||||
\$_GET['c'] = '{$v['name']}';
|
||||
\$_GET['a'] = 'Respond';
|
||||
|
||||
// 支付模块标记
|
||||
define('PAYMENT_TYPE', '{$payment}');
|
||||
|
||||
// 引入公共入口文件
|
||||
require './core.php';
|
||||
|
||||
// 引入ThinkPHP入口文件
|
||||
require './ThinkPHP/ThinkPHP.php';
|
||||
|
||||
?>
|
||||
php;
|
||||
$name = strtolower($v['name']);
|
||||
@file_put_contents(ROOT.'public'.DS.'payment_'.$name.'_'.strtolower($payment).'_respond.php', $respond);
|
||||
|
||||
// 线下支付不生成异步入口文件
|
||||
if(!in_array($payment, config('under_line_list')))
|
||||
{
|
||||
@file_put_contents(ROOT.'public'.DS.'payment_'.$name.'_'.strtolower($payment).'_notify.php', $notify);
|
||||
}
|
||||
}
|
||||
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* [PaymentEntranceDelete 入口文件删除]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-28T23:38:52+0800
|
||||
* @param [string] $payment [支付唯一标记]
|
||||
*/
|
||||
private static function PaymentEntranceDelete($payment)
|
||||
{
|
||||
// 权限
|
||||
$ret = self::PowerCheck();
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
$payment = strtolower($payment);
|
||||
foreach(self::$payment_business_type_all as $v)
|
||||
{
|
||||
$name = strtolower($v['name']);
|
||||
if(file_exists(ROOT.'public'.DS.'payment_'.$name.'_'.$payment.'_notify.php'))
|
||||
{
|
||||
@unlink(ROOT.'public'.DS.'payment_'.$name.'_'.$payment.'_notify.php');
|
||||
}
|
||||
if(file_exists(ROOT.'public'.DS.'payment_'.$name.'_'.$payment.'_respond.php'))
|
||||
{
|
||||
@unlink(ROOT.'public'.DS.'payment_'.$name.'_'.$payment.'_respond.php');
|
||||
}
|
||||
}
|
||||
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -12,85 +12,6 @@ use think\Db;
|
|||
*/
|
||||
class ResourcesService
|
||||
{
|
||||
/**
|
||||
* 获取订单支付名称
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [int] $order_id [订单id]
|
||||
*/
|
||||
public static function OrderPaymentName($order_id = 0)
|
||||
{
|
||||
return empty($order_id) ? null : Db::name('PayLog')->where(['order_id'=>intval($order_id)])->value('payment_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function PaymentList($params = [])
|
||||
{
|
||||
$where = empty($params['where']) ? [] : $params['where'];
|
||||
if(isset($params['is_enable']))
|
||||
{
|
||||
$where['is_enable'] = intval($params['is_enable']);
|
||||
}
|
||||
if(isset($params['is_open_user']))
|
||||
{
|
||||
$where['is_open_user'] = intval($params['is_open_user']);
|
||||
}
|
||||
|
||||
$data = Db::name('Payment')->where($where)->field('id,logo,name,sort,payment,config,apply_terminal,apply_terminal,element,is_enable,is_open_user')->order('sort asc')->select();
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
$images_host = config('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['logo_old'] = $v['logo'];
|
||||
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
|
||||
$v['element'] = empty($v['element']) ? '' : json_decode($v['element'], true);
|
||||
$v['config'] = empty($v['config']) ? '' : json_decode($v['config'], true);
|
||||
$v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付方式列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc 下订单根据终端自动筛选支付方式
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function BuyPaymentList($params = [])
|
||||
{
|
||||
$data = self::PaymentList($params);
|
||||
|
||||
$result = [];
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as $v)
|
||||
{
|
||||
// 根据终端类型筛选
|
||||
if(in_array(APPLICATION_CLIENT_TYPE, $v['apply_terminal']))
|
||||
{
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ContentStaticReplace 编辑器中内容的静态资源替换]
|
||||
* @author Devil
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
namespace app\service;
|
||||
|
||||
use think\Db;
|
||||
use app\service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 轮播图服务层
|
||||
|
|
|
|||
|
|
@ -43,9 +43,10 @@ class Alipay
|
|||
'name' => '支付宝', // 插件名称
|
||||
'version' => '0.0.1', // 插件版本
|
||||
'apply_version' => '1.0~1.3', // 适用系统版本描述
|
||||
'desc' => '即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'apply_terminal'=> ['pc','h5'], // 适用终端 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
|
||||
'desc' => '适用PC+H5,即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://gong.gg/', // 开发者主页
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
];
|
||||
|
||||
// 配置信息
|
||||
|
|
@ -80,91 +81,91 @@ class Alipay
|
|||
'is_required' => 1,
|
||||
'message' => '请填写交易安全校验码 key',
|
||||
],
|
||||
[
|
||||
'element' => 'input', // 表单标签
|
||||
'type' => 'text', // input类型
|
||||
'default' => '', // 默认值
|
||||
'name' => 'testinput', // name名称
|
||||
'placeholder' => '测试输入框不需要验证', // input默认显示文字
|
||||
'title' => '测试输入框不需要验证', // 展示title名称
|
||||
'is_required' => 0, // 是否需要强制填写/选择
|
||||
'message' => '请填写测试输入框不需要验证', // 错误提示(is_required=1方可有效)
|
||||
],
|
||||
[
|
||||
'element' => 'textarea',
|
||||
'default' => '',
|
||||
'name' => 'rsa_private',
|
||||
'placeholder' => 'RSA证书',
|
||||
'title' => 'RSA证书',
|
||||
'is_required' => 0,
|
||||
'minlength' => 10, // 最小输入字符(is_required=1方可有效)
|
||||
//'maxlength' => 300, // 最大输入字符, 填则不限(is_required=1方可有效)
|
||||
'rows' => 6,
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'checkbox',
|
||||
'element_data' => [
|
||||
['value'=>1, 'name'=>'选项1'],
|
||||
['value'=>2, 'name'=>'选项2', 'is_checked'=>1],
|
||||
['value'=>3, 'name'=>'选项3'],
|
||||
['value'=>4, 'name'=>'选项4']
|
||||
],
|
||||
'is_block' => 1, // 是否每个选项行内展示(默认0)
|
||||
'minchecked' => 2, // 最小选项(默认以is_required=1至少一项,则0)
|
||||
'maxchecked' => 3, // 最大选项
|
||||
'name' => 'checkbox',
|
||||
'title' => '多选项测试', // 展示title名称
|
||||
'is_required' => 1, // 是否需要强制填写/选择
|
||||
'message' => '请选择多选项测试选择 至少选择2项最多选择3项', // 错误提示信息
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'radio',
|
||||
'element_data' => [
|
||||
['value'=>1, 'name'=>'选项1', 'is_checked'=>1],
|
||||
['value'=>2, 'name'=>'选项2'],
|
||||
['value'=>3, 'name'=>'选项3'],
|
||||
['value'=>4, 'name'=>'选项4']
|
||||
],
|
||||
'is_block' => 1, // 是否每个选项行内展示(默认0)
|
||||
'name' => 'radio',
|
||||
'title' => '单选项测试', // 展示title名称
|
||||
'is_required' => 1, // 是否需要强制填写/选择
|
||||
'message' => '请选择单选项测试',
|
||||
],
|
||||
[
|
||||
'element' => 'select',
|
||||
'placeholder' => '选一个撒1',
|
||||
'is_multiple' => 0, // 是否开启多选(默认0 关闭)
|
||||
'element_data' => [
|
||||
['value'=>1, 'name'=>'选项1'],
|
||||
['value'=>2, 'name'=>'选项2'],
|
||||
['value'=>3, 'name'=>'选项3'],
|
||||
['value'=>4, 'name'=>'选项4']
|
||||
],
|
||||
'name' => 'select1',
|
||||
'title' => '下拉单选测试', // 展示title名称
|
||||
'is_required' => 1, // 是否需要强制填写/选择
|
||||
'message' => '请选择下拉单选测试',
|
||||
],
|
||||
[
|
||||
'element' => 'select',
|
||||
'placeholder' => '选一个撒2',
|
||||
'is_multiple' => 1, // 是否开启多选(默认0 关闭)
|
||||
'element_data' => [
|
||||
['value'=>1, 'name'=>'选项1'],
|
||||
['value'=>2, 'name'=>'选项2'],
|
||||
['value'=>3, 'name'=>'选项3'],
|
||||
['value'=>4, 'name'=>'选项4']
|
||||
],
|
||||
'minchecked' => 2, // 最小选项(默认以is_required=1至少一项,则0)
|
||||
'maxchecked' => 3, // 最大选项
|
||||
'name' => 'select2',
|
||||
'title' => '下拉多选测试', // 展示title名称
|
||||
'is_required' => 1, // 是否需要强制填写/选择
|
||||
'message' => '请选择下拉多选测试 至少选择2项最多选择3项',
|
||||
],
|
||||
// [
|
||||
// 'element' => 'input', // 表单标签
|
||||
// 'type' => 'text', // input类型
|
||||
// 'default' => '', // 默认值
|
||||
// 'name' => 'testinput', // name名称
|
||||
// 'placeholder' => '测试输入框不需要验证', // input默认显示文字
|
||||
// 'title' => '测试输入框不需要验证', // 展示title名称
|
||||
// 'is_required' => 0, // 是否需要强制填写/选择
|
||||
// 'message' => '请填写测试输入框不需要验证', // 错误提示(is_required=1方可有效)
|
||||
// ],
|
||||
// [
|
||||
// 'element' => 'textarea',
|
||||
// 'default' => '',
|
||||
// 'name' => 'rsa_private',
|
||||
// 'placeholder' => 'RSA证书',
|
||||
// 'title' => 'RSA证书',
|
||||
// 'is_required' => 0,
|
||||
// 'minlength' => 10, // 最小输入字符(is_required=1方可有效)
|
||||
// //'maxlength' => 300, // 最大输入字符, 填则不限(is_required=1方可有效)
|
||||
// 'rows' => 6,
|
||||
// ],
|
||||
// [
|
||||
// 'element' => 'input',
|
||||
// 'type' => 'checkbox',
|
||||
// 'element_data' => [
|
||||
// ['value'=>1, 'name'=>'选项1'],
|
||||
// ['value'=>2, 'name'=>'选项2',],
|
||||
// ['value'=>3, 'name'=>'选项3'],
|
||||
// ['value'=>4, 'name'=>'选项4']
|
||||
// ],
|
||||
// 'is_block' => 1, // 是否每个选项行内展示(默认0)
|
||||
// 'minchecked' => 2, // 最小选项(默认以is_required=1至少一项,则0)
|
||||
// 'maxchecked' => 3, // 最大选项
|
||||
// 'name' => 'checkbox',
|
||||
// 'title' => '多选项测试', // 展示title名称
|
||||
// 'is_required' => 1, // 是否需要强制填写/选择
|
||||
// 'message' => '请选择多选项测试选择 至少选择2项最多选择3项', // 错误提示信息
|
||||
// ],
|
||||
// [
|
||||
// 'element' => 'input',
|
||||
// 'type' => 'radio',
|
||||
// 'element_data' => [
|
||||
// ['value'=>1, 'name'=>'选项1',],
|
||||
// ['value'=>2, 'name'=>'选项2'],
|
||||
// ['value'=>3, 'name'=>'选项3'],
|
||||
// ['value'=>4, 'name'=>'选项4']
|
||||
// ],
|
||||
// 'is_block' => 1, // 是否每个选项行内展示(默认0)
|
||||
// 'name' => 'radio',
|
||||
// 'title' => '单选项测试', // 展示title名称
|
||||
// 'is_required' => 1, // 是否需要强制填写/选择
|
||||
// 'message' => '请选择单选项测试',
|
||||
// ],
|
||||
// [
|
||||
// 'element' => 'select',
|
||||
// 'placeholder' => '选一个撒1',
|
||||
// 'is_multiple' => 0, // 是否开启多选(默认0 关闭)
|
||||
// 'element_data' => [
|
||||
// ['value'=>1, 'name'=>'选项1'],
|
||||
// ['value'=>2, 'name'=>'选项2'],
|
||||
// ['value'=>3, 'name'=>'选项3'],
|
||||
// ['value'=>4, 'name'=>'选项4']
|
||||
// ],
|
||||
// 'name' => 'select1',
|
||||
// 'title' => '下拉单选测试', // 展示title名称
|
||||
// 'is_required' => 1, // 是否需要强制填写/选择
|
||||
// 'message' => '请选择下拉单选测试',
|
||||
// ],
|
||||
// [
|
||||
// 'element' => 'select',
|
||||
// 'placeholder' => '选一个撒2',
|
||||
// 'is_multiple' => 1, // 是否开启多选(默认0 关闭)
|
||||
// 'element_data' => [
|
||||
// ['value'=>1, 'name'=>'选项1'],
|
||||
// ['value'=>2, 'name'=>'选项2'],
|
||||
// ['value'=>3, 'name'=>'选项3'],
|
||||
// ['value'=>4, 'name'=>'选项4']
|
||||
// ],
|
||||
// 'minchecked' => 2, // 最小选项(默认以is_required=1至少一项,则0)
|
||||
// 'maxchecked' => 3, // 最大选项
|
||||
// 'name' => 'select2',
|
||||
// 'title' => '下拉多选测试', // 展示title名称
|
||||
// 'is_required' => 1, // 是否需要强制填写/选择
|
||||
// 'message' => '请选择下拉多选测试 至少选择2项最多选择3项',
|
||||
// ],
|
||||
];
|
||||
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ class AlipayMini
|
|||
'name' => '支付宝', // 插件名称
|
||||
'version' => '0.0.1', // 插件版本
|
||||
'apply_version' => '不限', // 适用系统版本描述
|
||||
'desc' => '即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'apply_terminal'=> ['alipay'], // 适用终端 ['pc', 'h5', 'app', 'alipay', 'wechat', 'baidu']
|
||||
'desc' => '适用支付宝小程序,即时到帐支付方式,买家的交易资金直接打入卖家支付宝账户,快速回笼交易资金。 <a href="http://www.alipay.com/" target="_blank">立即申请</a>', // 插件描述(支持html)
|
||||
'author' => 'Devil', // 开发者
|
||||
'author_url' => 'http://shopxo.net/', // 开发者主页
|
||||
];
|
||||
|
|
@ -60,36 +61,6 @@ class AlipayMini
|
|||
'is_required' => 1,
|
||||
'message' => '请填写小程序appid',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'account',
|
||||
'placeholder' => '支付宝账号',
|
||||
'title' => '支付宝账号',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写支付宝账号',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'partner',
|
||||
'placeholder' => '合作者身份 partner ID',
|
||||
'title' => '合作者身份 partner ID',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写合作者身份 partner ID',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'key',
|
||||
'placeholder' => '交易安全校验码 key',
|
||||
'title' => '交易安全校验码 key',
|
||||
'is_required' => 1,
|
||||
'message' => '请填写交易安全校验码 key',
|
||||
],
|
||||
[
|
||||
'element' => 'textarea',
|
||||
'name' => 'rsa_public',
|
||||
|
|
|
|||
Loading…
Reference in New Issue