diff --git a/!.env b/!!.env similarity index 71% rename from !.env rename to !!.env index 3410a9b..74406fb 100644 --- a/!.env +++ b/!!.env @@ -2,9 +2,9 @@ APP_DEBUG = true DB_TYPE = mysql DB_HOST = 127.0.0.1 -DB_NAME = mpay -DB_USER = admin -DB_PASS = Aa123456 +DB_NAME = test +DB_USER = test +DB_PASS = 123456 DB_PORT = 3306 DB_CHARSET = utf8 DB_PREFIX = mpay_ diff --git a/.env b/.env index 74406fb..3410a9b 100644 --- a/.env +++ b/.env @@ -2,9 +2,9 @@ APP_DEBUG = true DB_TYPE = mysql DB_HOST = 127.0.0.1 -DB_NAME = test -DB_USER = test -DB_PASS = 123456 +DB_NAME = mpay +DB_USER = admin +DB_PASS = Aa123456 DB_PORT = 3306 DB_CHARSET = utf8 DB_PREFIX = mpay_ diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index b75af60..6e8c573 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -3,6 +3,7 @@ namespace app\controller; use think\facade\View; +use payclient\LaKaLa; class IndexController { @@ -16,6 +17,8 @@ class IndexController } public function test() { - return request()->domain(); + $key = "0383d7088b6947b68e4a626af119e2bd"; + + return $key; } } diff --git a/app/controller/UserController.php b/app/controller/UserController.php index 14b5cc2..d860454 100644 --- a/app/controller/UserController.php +++ b/app/controller/UserController.php @@ -17,6 +17,8 @@ class UserController extends BaseController $userinfo = User::find(\session('userid'))->toArray(); View::assign($userinfo); View::assign('url', $this->request->domain()); + $sign = md5($userinfo['pid'] . $userinfo['secret_key']); + View::assign('orderurl', $this->request->domain() . "/checkOrder/{$userinfo['pid']}/{$sign}"); return View::fetch(); } // 登陆视图 diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php index 7af59d0..62c260d 100644 --- a/app/controller/api/PayManageController.php +++ b/app/controller/api/PayManageController.php @@ -112,9 +112,9 @@ class PayManageController extends BaseController // 生成账号配置 private function createAccountConfig($acc) { - $platform = Platform::where('platform', $acc->getData('platform'))->find(); + $platform = \app\controller\api\PluginController::getPluginInfo($acc->getData('platform')); $user = User::where('pid', $acc->pid)->find(); - $query = var_export(\unserialize($platform->query), \true); + $query = var_export($platform['query'], \true); $config = << [ 'pid' => {$user->pid}, - 'key' => '$user->secret_key' + 'key' => '{$user->secret_key}' ], // 收款平台账号配置 'pay' => [ @@ -134,7 +134,7 @@ return [ // 收款平台 'platform' => '{$acc->getData('platform')}', // 插件类名 - 'payclass' => '{$platform->class_name}', + 'payclass' => '{$platform['class_name']}', // 账号 'account' => '{$acc->account}', // 密码 diff --git a/app/controller/api/PluginController.php b/app/controller/api/PluginController.php index db89c17..2eecc79 100644 --- a/app/controller/api/PluginController.php +++ b/app/controller/api/PluginController.php @@ -13,7 +13,7 @@ class PluginController extends BaseController // 获取插件列表 public function getPluginList() { - $plugin_config = $this->getPluginConfig(); + $plugin_config = self::getPluginConfig(); if ($plugin_config) { return json(['code' => 0, 'msg' => 'OK', 'count' => \count($plugin_config), 'data' => $plugin_config]); } else { @@ -38,7 +38,7 @@ class PluginController extends BaseController $config[$key] = $value; } } - $plugin_config = $this->getPluginConfig(); + $plugin_config = self::getPluginConfig(); $plugin_platform = $config['platform'] ?: ''; foreach ($plugin_config as $value) { if ($plugin_platform == $value['platform']) { @@ -52,7 +52,7 @@ class PluginController extends BaseController // 删除插件 public function delPlugin($plugin_name = '') { - $plugin_config = $this->getPluginConfig(); + $plugin_config = self::getPluginConfig(); $keys = []; foreach ($plugin_config as $index => $value) { if ($value['platform'] == $plugin_name) { @@ -69,12 +69,12 @@ class PluginController extends BaseController // 修改插件 public function setPlugin($platform = '', $option = []) { - $config = $this->getPluginConfig(); + $config = self::getPluginConfig(); if (!$platform) { - return 1; //'请选择插件' + return 1; // 请选择插件 } if (!$option) { - return 2; //请添加插件配置 + return 2; // 请添加插件配置 } foreach ($config as $index => $options) { if ($options['platform'] == $platform) { @@ -103,39 +103,35 @@ class PluginController extends BaseController public function pluginOption() { // 加载平台配置 - $config = $this->getPluginConfig(); + $config = self::getPluginConfig(); $option = []; foreach ($config as $value) { $option[] = ['platform' => $value['platform'], 'name' => $value['name']]; } return json($option); } - // 生成插件配置 - public function crtPlfConfig() + // 获取指定插件配置 + public static function getPluginInfo($platform = '') { - $info = Platform::where('state', 1)->field('platform, name')->select()->toArray(); - $data = []; - foreach ($info as $value) { - $data[$value['platform']] = $value['name']; - } - $config = View::fetch('tpl/platform_config', $data); - $path = "../config/extendconfig/platform.php"; - $res = \file_put_contents($path, $config); - if ($res) { - return \json(\backMsg(msg: '创建成功')); - } else { - return \json(\backMsg(1, '创建成功')); + $config = self::getPluginConfig(); + $info = []; + foreach ($config as $item) { + if ($item['platform'] == $platform) { + $info = $item; + break; + } } + return $info; } // 获取插件配置 - private function getPluginConfig(): array + private static function getPluginConfig(): array { $payplugin_path = config_path() . '/extendconfig/payplugin.php'; if (!file_exists($payplugin_path)) { return []; } // 加载插件配置 - $payplugin_config = require_once $payplugin_path; + $payplugin_config = require $payplugin_path; return $payplugin_config; } // 保存插件配置 diff --git a/app/model/PayAccount.php b/app/model/PayAccount.php index b699756..c5a24f9 100644 --- a/app/model/PayAccount.php +++ b/app/model/PayAccount.php @@ -32,7 +32,7 @@ class PayAccount extends BaseModel return []; } // 加载插件配置 - $payplugin_config = require_once $payplugin_path; + $payplugin_config = require $payplugin_path; $option = []; foreach ($payplugin_config as $config) { $option[$config['platform']] = $config['name']; diff --git a/config/extendconfig/payplugin.php b/config/extendconfig/payplugin.php index 2bf0228..4a0555c 100644 --- a/config/extendconfig/payplugin.php +++ b/config/extendconfig/payplugin.php @@ -3,9 +3,9 @@ // | 支付插件列表 // +---------------------------------------------------------------------- -return array ( - 0 => - array ( +return array( + 0 => + array( 'platform' => 'sqbpay', 'name' => '收钱吧', 'class_name' => 'ShouQianBa', @@ -13,10 +13,20 @@ return array ( 'describe' => '主流移动支付全能收 信用卡,花呗都能用,生意帮手收钱吧,移动收款就用它!', 'website' => 'https://www.shouqianba.com/', 'state' => 1, - 'query' => 'a:8:{s:8:"date_end";N;s:10:"date_start";N;s:4:"page";i:1;s:9:"page_size";i:10;s:13:"upayQueryType";i:0;s:6:"status";s:4:"2000";s:8:"store_sn";s:0:"";s:4:"type";s:2:"30";}', + 'query' => + array( + 'date_end' => NULL, + 'date_start' => NULL, + 'page' => 1, + 'page_size' => 10, + 'upayQueryType' => 0, + 'status' => '2000', + 'store_sn' => '', + 'type' => '30', + ), ), - 1 => - array ( + 1 => + array( 'platform' => 'storepay', 'name' => '数字门店', 'class_name' => 'ZhiHuiJingYing', @@ -24,10 +34,19 @@ return array ( 'describe' => '数字门店', 'website' => 'https://store.zhihuijingyingba.com/', 'state' => 1, - 'query' => 'a:7:{s:6:"pageNo";i:1;s:8:"pageSize";i:10;s:9:"payClient";i:4;s:6:"status";i:2;s:2:"_t";N;s:16:"createTime_begin";N;s:14:"createTime_end";N;}', + 'query' => + array( + 'pageNo' => 1, + 'pageSize' => 10, + 'payClient' => 4, + 'status' => 2, + '_t' => NULL, + 'createTime_begin' => NULL, + 'createTime_end' => NULL, + ), ), - 2 => - array ( + 2 => + array( 'platform' => 'ysepay', 'name' => '小Y经营', 'class_name' => 'Ysepay', @@ -35,10 +54,22 @@ return array ( 'describe' => '为商户和消费者提供安全、便捷、高效的支付产品与服务助力商户提升运营效率,实现数字化运营', 'website' => 'https://xym.ysepay.com/', 'state' => 1, - 'query' => 'a:10:{s:7:"storeNo";s:0:"";s:7:"bizType";i:3;s:7:"payType";s:0:"";s:11:"orderStatus";i:3;s:5:"trmNo";s:0:"";s:12:"operatorUser";s:0:"";s:13:"codeBoardCode";s:0:"";s:8:"pageSize";i:10;s:6:"pageNo";i:1;s:7:"orderNo";s:0:"";}', + 'query' => + array( + 'storeNo' => '', + 'bizType' => 3, + 'payType' => '', + 'orderStatus' => 3, + 'trmNo' => '', + 'operatorUser' => '', + 'codeBoardCode' => '', + 'pageSize' => 10, + 'pageNo' => 1, + 'orderNo' => '', + ), ), - 3 => - array ( + 3 => + array( 'platform' => 'mqpay', 'name' => '码钱', 'class_name' => 'MaQian', @@ -46,10 +77,24 @@ return array ( 'describe' => '码钱商管平台', 'website' => 'https://m.hkrt.cn/', 'state' => 1, - 'query' => 'a:12:{s:12:"terminalType";s:0:"";s:7:"payType";s:0:"";s:7:"payMode";s:0:"";s:11:"tradeStatus";s:1:"1";s:7:"tradeNo";s:0:"";s:7:"storeId";s:0:"";s:4:"page";i:1;s:4:"rows";i:10;s:7:"endDate";N;s:7:"endTime";N;s:9:"startDate";N;s:9:"startTime";N;}', + 'query' => + array( + 'terminalType' => '', + 'payType' => '', + 'payMode' => '', + 'tradeStatus' => '1', + 'tradeNo' => '', + 'storeId' => '', + 'page' => 1, + 'rows' => 10, + 'endDate' => NULL, + 'endTime' => NULL, + 'startDate' => NULL, + 'startTime' => NULL, + ), ), - 4 => - array ( + 4 => + array( 'platform' => 'lklpay', 'name' => '拉卡拉', 'class_name' => 'LaKaLa', @@ -57,10 +102,37 @@ return array ( 'describe' => '数字支付,更安全,更高效', 'website' => 'https://customer.lakala.com/', 'state' => 1, - 'query' => '', + 'query' => + array( + 'requestTime' => NULL, + 'systemCode' => 'MERDASH', + 'version' => '1.0', + 'openEntity' => NULL, + 'requestId' => NULL, + 'pageSize' => 10, + 'pageNum' => 1, + 'startTime' => NULL, + 'timeOption' => NULL, + 'tranSts' => 'SUCCESS', + 'orderNo' => NULL, + 'srefno' => NULL, + 'ornNo' => NULL, + 'endTime' => NULL, + 'startDate' => NULL, + 'endDate' => NULL, + 'page' => 1, + 'size' => 10, + 'merchantNos' => NULL, + 'merInnerNos' => NULL, + ), + 'param' => [ + 'openEntity' => '822581058121GYW', + 'merchantNos' => '822581058121GYW', + 'merInnerNos' => '4002022071722760372', + ], ), - 5 => - array ( + 5 => + array( 'platform' => 'sftpay', 'name' => '盛付通', 'class_name' => 'ShengPay', @@ -70,17 +142,4 @@ return array ( 'state' => 0, 'query' => '', ), - 6 => - array ( - 'platform' => 'haopay', - 'name' => '好支付', - 'class_name' => 'Haopay', - 'price' => 99, - 'describe' => '好支付', - 'website' => 'https://store.zhihuijingyingba.com/', - 'state' => 0, - 'query' => - array ( - ), - ), ); diff --git a/config/payconfig/1001_7.php b/config/payconfig/1001_7.php new file mode 100644 index 0000000..5d785e5 --- /dev/null +++ b/config/payconfig/1001_7.php @@ -0,0 +1,48 @@ + [ + 'pid' => 1001, + 'key' => '953c4d682d9ab148277b76a06e215ce7' + ], + // 收款平台账号配置 + 'pay' => [ + // 账号id + 'aid' => 7, + // 收款平台 + 'platform' => 'lklpay', + // 插件类名 + 'payclass' => 'LaKaLa', + // 账号 + 'account' => '13822254817', + // 密码 + 'password' => 'n8omf1FNqK+Irq9IlOPZJA==', + // 订单查询参数配置 + 'query' => array ( + 'requestTime' => NULL, + 'systemCode' => 'MERDASH', + 'version' => '1.0', + 'openEntity' => '822581058121GYW', + 'requestId' => NULL, + 'pageSize' => 10, + 'pageNum' => 1, + 'startTime' => NULL, + 'timeOption' => NULL, + 'tranSts' => 'SUCCESS', + 'orderNo' => NULL, + 'srefno' => NULL, + 'ornNo' => NULL, + 'endTime' => NULL, + 'startDate' => NULL, + 'endDate' => NULL, + 'page' => 1, + 'size' => 10, + 'merchantNos' => '822581058121GYW', + 'merInnerNos' => '4002022071722760372', +), + ] +]; diff --git a/extend/payclient/ShouQianBa.php b/extend/payclient/ShouQianBa.php index fe77448..029481c 100644 --- a/extend/payclient/ShouQianBa.php +++ b/extend/payclient/ShouQianBa.php @@ -97,45 +97,49 @@ class ShouQianBa public function payQuery(array $query): array { $token = $this->getToken(); - $url = $this->host . $this->find_transactions . '?client_version=7.0.0&token=' . $token; - $header = ['Content-Type: application/json;charset=UTF-8']; - // 构建订单查询 - $now = time(); - $begin_time = ($now - 175) * 1000; - $end_time = $now * 1000; - $query['date_start'] = $begin_time; - $query['date_end'] = $end_time; - // 查询订单列表 - $res_order = $this->getHttpResponse($url, $header, json_encode($query)); - $arr_res = json_decode($res_order, true); - $list = []; - if ($arr_res['code'] === 50000) { - $list = $arr_res['data']['records']; - } - // 重构订单流水,返回数组 - $moneyList = []; - if ($list) { - $order_no = []; - $payway = []; - $price = []; - $channel = []; - $payways = [2 => 'alipay', 3 => 'wxpay']; - foreach ($list as $value) { - // 平台订单流水号 - $order_no[] = $value['order_sn']; - // 支付类型 - $payway[] = $payways[$value['payway']]; - // 收款金额 - $price[] = $value['original_amount'] / 100; - // 收款渠道(二维码编号) - $channel[] = $value['terminal_device_fingerprint']; + if ($token) { + $url = $this->host . $this->find_transactions . '?client_version=7.0.0&token=' . $token; + $header = ['Content-Type: application/json;charset=UTF-8']; + // 构建订单查询 + $now = time(); + $begin_time = ($now - 175) * 1000; + $end_time = $now * 1000; + $query['date_start'] = $begin_time; + $query['date_end'] = $end_time; + // 查询订单列表 + $res_order = $this->getHttpResponse($url, $header, json_encode($query)); + $arr_res = json_decode($res_order, true); + $list = []; + if ($arr_res['code'] === 50000) { + $list = $arr_res['data']['records']; } - $moneyList['order_no'] = $order_no; - $moneyList['payway'] = $payway; - $moneyList['price'] = $price; - $moneyList['channel'] = $channel; + // 重构订单流水,返回数组 + $moneyList = []; + if ($list) { + $order_no = []; + $payway = []; + $price = []; + $channel = []; + $payways = [2 => 'alipay', 3 => 'wxpay']; + foreach ($list as $value) { + // 平台订单流水号 + $order_no[] = $value['order_sn']; + // 支付类型 + $payway[] = $payways[$value['payway']]; + // 收款金额 + $price[] = $value['original_amount'] / 100; + // 收款渠道(二维码编号) + $channel[] = $value['terminal_device_fingerprint']; + } + $moneyList['order_no'] = $order_no; + $moneyList['payway'] = $payway; + $moneyList['price'] = $price; + $moneyList['channel'] = $channel; + } + return $moneyList; + } else { + return []; } - return $moneyList; } // 请求外部资源 private function getHttpResponse($url, $header = [], $post = null, $timeout = 10) diff --git a/extend/payclient/payclient.zip b/extend/payclient/payclient.zip deleted file mode 100644 index fc2e00b..0000000 Binary files a/extend/payclient/payclient.zip and /dev/null differ diff --git a/view/pay_manage/index.html b/view/pay_manage/index.html index d95146e..dd884d3 100644 --- a/view/pay_manage/index.html +++ b/view/pay_manage/index.html @@ -106,6 +106,7 @@ { title: '密 码', field: 'password', align: 'center' }, { title: '启用状态', field: 'state', align: 'center', templet: '#account-state' }, { title: '监听模式', field: 'pattern', align: 'center' }, + { title: '监听地址', field: 'payurl', align: 'center', templet: `
{{# return window.location.origin + '/checkPayResult?pid='+d.pid+'&aid='+d.id }}
` }, { title: '终端数量', field: 'channel', align: 'center', templet: '
{{= d.channel }}
' }, { title: '操作', align: 'center', fixed: 'right', templet: '
编辑
' } ]] diff --git a/view/user/index.html b/view/user/index.html index 24ec84c..36a8147 100644 --- a/view/user/index.html +++ b/view/user/index.html @@ -19,7 +19,7 @@
-
+
@@ -81,11 +81,22 @@
+
+ +
+
+ + +
+
+
-
+
我的文章