From a1707612dc1f7910225e67e6981283555a02697e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=80=E6=9C=AF=E8=80=81=E8=83=A1?= <1094551889@qq.com> Date: Tue, 19 Nov 2024 17:28:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E6=94=B6=E6=AC=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/IndexController.php | 15 ++- app/controller/PayManageController.php | 7 +- app/controller/api/PayManageController.php | 92 +++++++++--------- app/controller/api/PluginController.php | 8 -- app/model/Order.php | 17 +++- config/extendconfig/menu.php | 18 ++-- config/extendconfig/payplugin.php | 88 +++++++++++------ runtime/log.txt | 2 +- view/pay_manage/add_account.html | 21 +++- view/pay_manage/add_channel.html | 2 +- view/pay_manage/add_channel_code.html | 108 +++++++++++++++++++++ view/pay_manage/add_code.html | 100 +++++++++++++++++++ view/pay_manage/channel_list.html | 6 +- view/pay_manage/edit_account.html | 36 ++++++- view/pay_manage/index.html | 22 ++++- 15 files changed, 426 insertions(+), 116 deletions(-) create mode 100644 view/pay_manage/add_channel_code.html create mode 100644 view/pay_manage/add_code.html diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index d449a03..b8b4205 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -2,6 +2,7 @@ namespace app\controller; +use think\facade\Log; use think\facade\View; class IndexController @@ -21,7 +22,17 @@ class IndexController } public function test() { - $web = \request()->domain(); - return $web; + $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\\Mpay"; + $Payclient = new $payclient_path($info, $config); + $res = $Payclient->notify($info); + return $res; + } else { + return 202; + } } } diff --git a/app/controller/PayManageController.php b/app/controller/PayManageController.php index 637adc2..eacd3da 100644 --- a/app/controller/PayManageController.php +++ b/app/controller/PayManageController.php @@ -42,7 +42,12 @@ class PayManageController extends BaseController public function addChannel() { $aid = $this->request->get('aid'); - View::assign(['aid' => $aid]); + $account = PayAccount::find($aid); + $platform = $account->getData('platform'); + View::assign(['aid' => $aid, 'platform' => $platform, 'account' => $account->account]); + if ($platform == 'wxpay' || $platform == 'alipay') { + return View::fetch('add_channel_code'); + } return View::fetch(); } // 编辑收款终端 diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php index 58c966b..540642c 100644 --- a/app/controller/api/PayManageController.php +++ b/app/controller/api/PayManageController.php @@ -22,6 +22,50 @@ class PayManageController extends BaseController return json(['code' => 1, 'msg' => '无数据记录', 'count' => 0, 'data' => []]); } } + // 收款终端列表 + public function getChannelList() + { + $aid = $this->request->post('aid'); + $res = PayChannel::where(['account_id' => $aid])->order('last_time', 'desc')->select(); + if ($res) { + return \json(\backMsg(0, '获取成功', $res)); + } else { + return \json(\backMsg(1, '失败')); + } + } + // 账号状态 + public function accountEnable() + { + $info = $this->request->post(); + $up_res = PayAccount::update($info); + if ($up_res) { + return json(\backMsg(0, '成功')); + } else { + return json(\backMsg(1, '失败')); + } + } + // 添加账号 + public function addAccount() + { + $info = $this->request->post(); + $pid = $this->request->session('pid'); + $info['pid'] = $pid; + $info['params'] = '{}'; + $check_acc = PayAccount::where(['account' => $info['account'], 'platform' => $info['platform'], 'pid' => $pid])->find(); + if ($check_acc) { + return \json(\backMsg(1, '账号已存在')); + } + $acc = PayAccount::create($info); + if ($acc) { + $state = $this->createAccountConfig($acc); + if (!$state) { + return json(\backMsg(1, '自字义参数错误')); + } + return \json(\backMsg(0, '添加成功')); + } else { + return \json(\backMsg(1, '添加失败')); + } + } // 编辑账号 public function editAccount() { @@ -38,17 +82,6 @@ class PayManageController extends BaseController return json(\backMsg(1, '修改失败')); } } - // 账号状态 - public function accountEnable() - { - $info = $this->request->post(); - $up_res = PayAccount::update($info); - if ($up_res) { - return json(\backMsg(0, '成功')); - } else { - return json(\backMsg(1, '失败')); - } - } // 删除账号 public function delAccount() { @@ -65,32 +98,14 @@ class PayManageController extends BaseController return \json(\backMsg(1, '失败')); } } - // 添加账号 - public function addAccount() - { - $info = $this->request->post(); - $pid = $this->request->session('pid'); - $info['pid'] = $pid; - $info['params'] = '{}'; - $check_acc = PayAccount::where(['account' => $info['account'], 'pid' => $pid])->find(); - if ($check_acc) { - return \json(\backMsg(1, '账号已存在')); - } - $acc = PayAccount::create($info); - if ($acc) { - $state = $this->createAccountConfig($acc); - if (!$state) { - return json(\backMsg(1, '自字义参数错误')); - } - return \json(\backMsg(0, '添加成功')); - } else { - return \json(\backMsg(1, '添加失败')); - } - } // 添加收款终端 public function addChannel() { $info = $this->request->post(); + $check = PayChannel::where(['account_id' => $info['account_id'], 'channel' => $info['channel']])->count(); + if ($check) { + return \json(\backMsg(1, '编号已存在')); + } $res = PayChannel::create($info); if ($res) { return \json(\backMsg(0, '添加成功')); @@ -120,17 +135,6 @@ class PayManageController extends BaseController return \json(\backMsg(1, '失败')); } } - // 收款终端列表 - public function getChannelList() - { - $aid = $this->request->post('aid'); - $res = PayChannel::where(['account_id' => $aid])->order('last_time', 'desc')->select(); - if ($res) { - return \json(\backMsg(0, '获取成功', $res)); - } else { - return \json(\backMsg(1, '失败')); - } - } // 删除账号配置 public function delAccountConfig($acc) { diff --git a/app/controller/api/PluginController.php b/app/controller/api/PluginController.php index 6563622..036482b 100644 --- a/app/controller/api/PluginController.php +++ b/app/controller/api/PluginController.php @@ -18,14 +18,6 @@ class PluginController extends BaseController return json(['code' => 1, 'msg' => '无数据记录', 'count' => 0, 'data' => []]); } } - // 测试 - public function test() - { - // $res = $this->addPlugin(['platform' => 'haopay', 'name' => '好支付', 'class_name' => 'Haopay', 'price' => 99, 'describe' => '好支付', 'website' => 'https://store.zhihuijingyingba.com/', 'state' => 1, 'query' => []]); - // $res = $this->delPlugin('haopay'); - $res = $this->setPlugin('haopay', ['state' => 0]); - return $res; - } // 添加插件 public function addPlugin(array $option = []) { diff --git a/app/model/Order.php b/app/model/Order.php index 8e8b0b5..46480cf 100644 --- a/app/model/Order.php +++ b/app/model/Order.php @@ -16,7 +16,7 @@ class Order extends BaseModel public static function createOrder($data) { $my_time = time(); - $channel = self::setChannel($data['pid']); + $channel = self::setChannel($data['pid'], $data['type']); $new_order = [ // 订单号 'order_id' => self::createOrderID('H'), @@ -112,13 +112,20 @@ class Order extends BaseModel return $order->toArray(); } // 选择收款通道 - private static function setChannel($pid): array + private static function setChannel($pid, $type): array { + // 查询有效收款账户及通道 $aids = PayAccount::where('pid', $pid)->where('state', 1)->column('id'); - $channel_info = PayChannel::whereIn('account_id', $aids)->where('state', 1)->order('last_time', 'asc')->find(); - if (!$channel_info || !$aids) { - return []; + $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) { + } + $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')]; PayChannel::update(['last_time' => self::getFormatTime(), 'id' => $channel['cid']]); diff --git a/config/extendconfig/menu.php b/config/extendconfig/menu.php index 9206f33..6df8559 100644 --- a/config/extendconfig/menu.php +++ b/config/extendconfig/menu.php @@ -7,7 +7,7 @@ return [ [ 'id' => 'console', 'title' => '平台首页', - 'icon' => 'layui-icon layui-icon-console', + 'icon' => 'icon pear-icon pear-icon-home', 'type' => 1, 'openType' => '_iframe', 'href' => 'Console/console', @@ -15,15 +15,15 @@ return [ [ 'id' => 'order', 'title' => '订单管理', - 'icon' => 'layui-icon layui-icon-console', + 'icon' => 'icon pear-icon pear-icon-survey', 'type' => 1, 'openType' => '_iframe', 'href' => '/Order/index', ], [ 'id' => 'payManage', - 'title' => '支付管理', - 'icon' => 'layui-icon layui-icon-console', + 'title' => '账号管理', + 'icon' => 'icon pear-icon pear-icon-security', 'type' => 1, 'openType' => '_iframe', 'href' => '/PayManage/index', @@ -31,7 +31,7 @@ return [ [ 'id' => 'pluginManage', 'title' => '插件管理', - 'icon' => 'layui-icon layui-icon-console', + 'icon' => 'icon pear-icon pear-icon-modular', 'type' => 1, 'openType' => '_iframe', 'href' => '/Plugin/index', @@ -39,7 +39,7 @@ return [ [ 'id' => 'userCenter', 'title' => '用户中心', - 'icon' => 'layui-icon layui-icon-console', + 'icon' => 'icon pear-icon pear-icon-user', 'type' => 1, 'openType' => '_iframe', 'href' => '/User/index', @@ -47,7 +47,7 @@ return [ // [ // 'id' => 'system', // 'title' => '系统设置', - // 'icon' => 'layui-icon layui-icon-console', + // 'icon' => 'icon pear-icon pear-icon-import', // 'type' => 1, // 'openType' => '_iframe', // 'href' => '/System/index', @@ -55,14 +55,14 @@ return [ // [ // 'id' => 'pay', // 'title' => '支付管理', - // 'icon' => 'layui-icon layui-icon-console', + // 'icon' => 'icon pear-icon pear-icon-import', // 'type' => 0, // 'href' => '', // 'children' => [ // [ // 'id' => 'pay_qrcode_list', // 'title' => '收款账户', - // 'icon' => 'layui-icon layui-icon-console', + // 'icon' => 'icon pear-icon pear-icon-import', // 'type' => 1, // 'openType' => '_iframe', // 'href' => '/PayQrcode/index', diff --git a/config/extendconfig/payplugin.php b/config/extendconfig/payplugin.php index da5edba..ac20975 100644 --- a/config/extendconfig/payplugin.php +++ b/config/extendconfig/payplugin.php @@ -3,9 +3,35 @@ // | 支付插件列表 // +---------------------------------------------------------------------- -return array( - 0 => - array( +return array ( + 0 => + array ( + 'platform' => 'wxpay', + 'name' => '微信支付', + 'class_name' => 'WxPay', + 'price' => '0.00', + 'describe' => '支持微信个人收款码、赞赏码、经营码、商家码收款,监听回调', + 'website' => 'https://weixin.qq.com/', + 'state' => 1, + 'query' => + array ( + ), + ), + 1 => + array ( + 'platform' => 'alipay', + 'name' => '支付宝', + 'class_name' => 'AliPay', + 'price' => '0.00', + 'describe' => '支持支付宝个人收款码、经营码收款,监听回调', + 'website' => 'https://www.alipay.com/', + 'state' => 1, + 'query' => + array ( + ), + ), + 2 => + array ( 'platform' => 'sqbpay', 'name' => '收钱吧', 'class_name' => 'ShouQianBa', @@ -13,8 +39,8 @@ return array( 'describe' => '主流移动支付全能收 信用卡,花呗都能用,生意帮手收钱吧,移动收款就用它!', 'website' => 'https://www.shouqianba.com/', 'state' => 1, - 'query' => - array( + 'query' => + array ( 'date_end' => NULL, 'date_start' => NULL, 'page' => 1, @@ -23,10 +49,10 @@ return array( 'status' => '2000', 'store_sn' => '', 'type' => '30', - ) + ), ), - 1 => - array( + 3 => + array ( 'platform' => 'storepay', 'name' => '数字门店', 'class_name' => 'ZhiHuiJingYing', @@ -34,8 +60,8 @@ return array( 'describe' => '数字门店', 'website' => 'https://store.zhihuijingyingba.com/', 'state' => 1, - 'query' => - array( + 'query' => + array ( 'pageNo' => 1, 'pageSize' => 10, 'payClient' => 4, @@ -43,10 +69,10 @@ return array( '_t' => NULL, 'createTime_begin' => NULL, 'createTime_end' => NULL, - ) + ), ), - 2 => - array( + 4 => + array ( 'platform' => 'ysepay', 'name' => '小Y经营', 'class_name' => 'YsePay', @@ -54,8 +80,8 @@ return array( 'describe' => '为商户和消费者提供安全、便捷、高效的支付产品与服务助力商户提升运营效率,实现数字化运营', 'website' => 'https://xym.ysepay.com/', 'state' => 1, - 'query' => - array( + 'query' => + array ( 'storeNo' => '', 'bizType' => 3, 'payType' => '', @@ -66,10 +92,10 @@ return array( 'pageSize' => 10, 'pageNo' => 1, 'orderNo' => '', - ) + ), ), - 3 => - array( + 5 => + array ( 'platform' => 'mqpay', 'name' => '码钱', 'class_name' => 'MaQian', @@ -77,8 +103,8 @@ return array( 'describe' => '码钱商管平台', 'website' => 'https://m.hkrt.cn/', 'state' => 1, - 'query' => - array( + 'query' => + array ( 'terminalType' => '', 'payType' => '', 'payMode' => '', @@ -91,19 +117,19 @@ return array( 'endTime' => NULL, 'startDate' => NULL, 'startTime' => NULL, - ) + ), ), - 4 => - array( + 6 => + array ( 'platform' => 'lklpay', 'name' => '拉卡拉', 'class_name' => 'LaKaLa', 'price' => '99.00', 'describe' => '数字支付,更安全,更高效', 'website' => 'https://customer.lakala.com/', - 'state' => 1, - 'query' => - array( + 'state' => 0, + 'query' => + array ( 'requestTime' => NULL, 'systemCode' => 'MERDASH', 'version' => '1.0', @@ -124,10 +150,10 @@ return array( 'size' => 10, 'merchantNos' => NULL, 'merInnerNos' => NULL, - ) + ), ), - 5 => - array( + 7 => + array ( 'platform' => 'sftpay', 'name' => '盛付通', 'class_name' => 'ShengPay', @@ -135,6 +161,8 @@ return array( 'describe' => '轻松生活 放心支付', 'website' => 'https://b.shengpay.com/', 'state' => 0, - 'query' => '' + 'query' => + array ( + ), ), ); diff --git a/runtime/log.txt b/runtime/log.txt index 89797f7..168babf 100644 --- a/runtime/log.txt +++ b/runtime/log.txt @@ -1 +1 @@ -2024-11-12 11:06:42 \ No newline at end of file +1731391345 \ No newline at end of file diff --git a/view/pay_manage/add_account.html b/view/pay_manage/add_account.html index 078d550..0396aa4 100644 --- a/view/pay_manage/add_account.html +++ b/view/pay_manage/add_account.html @@ -19,7 +19,7 @@
-
@@ -40,7 +40,7 @@
@@ -78,9 +78,22 @@ select.innerHTML = option_str; form.render('select'); })() - + // select 事件 + form.on('select(select-platform)', function (data) { + const value = data.value; // 获得被选中的值 + const field1 = document.querySelector('input[name="password"]').parentNode.parentNode; + const field2 = document.querySelector('select[name="pattern"]').parentNode.parentNode; + if (value === 'wxpay' || value === 'alipay') { + field1.style.display = 'none'; + field2.style.display = 'none'; + } else { + field1.style.display = 'block'; + field2.style.display = 'block'; + } + }); form.on('submit(add-account)', function (obj) { - const field = obj.field; + let field = obj.field; + field.pattern = field.pattern === '' ? 1 : field.pattern; (async () => { const url = '/api/PayManage/addAccount'; const info = field; diff --git a/view/pay_manage/add_channel.html b/view/pay_manage/add_channel.html index 3ff7dd4..116f8fc 100644 --- a/view/pay_manage/add_channel.html +++ b/view/pay_manage/add_channel.html @@ -3,7 +3,7 @@ - 添加收款终端 + 添加二维码 + + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/view/pay_manage/add_code.html b/view/pay_manage/add_code.html new file mode 100644 index 0000000..47c817e --- /dev/null +++ b/view/pay_manage/add_code.html @@ -0,0 +1,100 @@ + + + + + + 添加收款通道 + + + + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ + + + + + \ No newline at end of file diff --git a/view/pay_manage/channel_list.html b/view/pay_manage/channel_list.html index 576876b..fbf3648 100644 --- a/view/pay_manage/channel_list.html +++ b/view/pay_manage/channel_list.html @@ -3,7 +3,7 @@ - 终端列表 + 收款码