From 2447ebd52dbf8fec010f83f24c58ac72091bb726 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: Mon, 26 Aug 2024 12:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=AF=E4=BB=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 36 ------------------ app/controller/PayController.php | 4 +- app/controller/api/PayManageController.php | 43 +++++++++------------- app/controller/api/PluginController.php | 16 ++++++-- config/payconfig/1001_39.php | 33 +++++++++++++++++ config/payconfig/1001_40.php | 37 +++++++++++++++++++ view/plugin/index.html | 16 +++++++- 7 files changed, 116 insertions(+), 69 deletions(-) delete mode 100644 README.en.md create mode 100644 config/payconfig/1001_39.php create mode 100644 config/payconfig/1001_40.php diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 74faf79..0000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# 码支付 - -#### Description -个人使用,聚合收款码收款回调通知。 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/app/controller/PayController.php b/app/controller/PayController.php index 9ad5fb4..8f0f6ef 100644 --- a/app/controller/PayController.php +++ b/app/controller/PayController.php @@ -208,7 +208,7 @@ class PayController } } } - // [定时任务]监听新订单 + // [定时任务]监听新订单,生成JSON文件信息 public function checkOrder($pid = '', $sign = '') { if (!($pid && $sign)) { @@ -240,7 +240,7 @@ class PayController return json($info); } } - // [定时任务]监听收款通知 + // 获取收款通知,提交收款订单明细 public function checkPayResult(Request $request) { $req_info = $request->get(); diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php index 2497058..9c1e5e3 100644 --- a/app/controller/api/PayManageController.php +++ b/app/controller/api/PayManageController.php @@ -8,6 +8,7 @@ use app\BaseController; use app\model\PayAccount; use app\model\PayChannel; use app\model\Platform; +use app\model\User; use think\facade\View; class PayManageController extends BaseController @@ -29,6 +30,8 @@ class PayManageController extends BaseController $info = $this->request->post(); $up_res = PayAccount::update($info); if ($up_res) { + $acc = PayAccount::find($info['id']); + $this->createAccountConfig($acc); return json(\backMsg(0, '修改成功')); } else { return json(\backMsg(1, '修改失败')); @@ -62,8 +65,9 @@ class PayManageController extends BaseController $info = $this->request->post(); $pid = $this->request->session('pid'); $info['pid'] = $pid; - $res = PayAccount::create($info); - if ($res) { + $acc = PayAccount::create($info); + if ($acc) { + $this->createAccountConfig($acc); return \json(\backMsg(0, '添加成功')); } else { return \json(\backMsg(1, '添加失败')); @@ -103,37 +107,24 @@ class PayManageController extends BaseController } } // 生成账号配置 - public function createAccountConfig() + private function createAccountConfig($acc) { - $query = [ - "date_end" => null, - "date_start" => null, - "page" => 1, - "page_size" => 10, - "upayQueryType" => 0, - "status" => "2000", - "store_sn" => "", - "type" => "30" - ]; - + $platform = Platform::where('platform', $acc->getData('platform'))->find(); + $user = User::where('pid', $acc->pid)->find(); + $query = \unserialize($platform->query); $data = [ - 'pid' => 1001, - 'key' => '154556b80a3f02ab6b57d4199cd6ebdf', - 'aid' => 1, - 'platform' => 'sqbpay', - 'account' => '18872410423', - 'password' => '7698177hcnSQB', + 'pid' => $user->pid, + 'key' => $user->secret_key, + 'aid' => $acc->id, + 'platform' => $acc->getData('platform'), + 'account' => $acc->account, + 'password' => $acc->password, 'query' => \var_export($query, \true) ]; $config = View::fetch('tpl/account_config', $data); $name = "{$data['pid']}_{$data['aid']}"; $path = "../config/payconfig/{$name}.php"; - $res = \file_put_contents($path, $config); - if ($res) { - return \json(\backMsg(msg: '创建成功')); - } else { - return \json(\backMsg(1, '创建成功')); - } + \file_put_contents($path, $config); } // 生成平台列表配置 public function crtPlfConfig() diff --git a/app/controller/api/PluginController.php b/app/controller/api/PluginController.php index 7e48ef3..223bcb9 100644 --- a/app/controller/api/PluginController.php +++ b/app/controller/api/PluginController.php @@ -9,10 +9,7 @@ use app\model\Platform; class PluginController extends BaseController { - public function index() - { - // - } + // 插件列表 public function getPluginList() { $query = $this->request->get(); @@ -23,4 +20,15 @@ class PluginController extends BaseController return json(['code' => 1, 'msg' => '无数据记录', 'count' => 0, 'data' => []]); } } + // 插件启用 + public function pluginEnable() + { + $info = $this->request->post(); + $up_res = Platform::update($info); + if ($up_res) { + return json(\backMsg(0, '成功')); + } else { + return json(\backMsg(1, '失败')); + } + } } diff --git a/config/payconfig/1001_39.php b/config/payconfig/1001_39.php new file mode 100644 index 0000000..dd44926 --- /dev/null +++ b/config/payconfig/1001_39.php @@ -0,0 +1,33 @@ + [ + 'pid' => 1001, + 'key' => '7ImzF6Rf8OciQcmRJv8oTNBwIp6uqF0p' + ], + // 收款平台账号配置 + 'pay' => [ + // 账号id + 'aid' => 39, + // 收款平台 + 'platform' => 'sqbpay', + // 账号 + 'account' => '18727623516', + // 密码 + 'password' => '123456', + // 订单查询参数配置 + 'query' => array ( + 'date_end' => NULL, + 'date_start' => NULL, + 'page' => 1, + 'page_size' => 10, + 'upayQueryType' => 0, + 'status' => '2000', + 'store_sn' => '', + 'type' => '30', +), + ] +]; diff --git a/config/payconfig/1001_40.php b/config/payconfig/1001_40.php new file mode 100644 index 0000000..07a8dbb --- /dev/null +++ b/config/payconfig/1001_40.php @@ -0,0 +1,37 @@ + [ + 'pid' => 1001, + 'key' => '7ImzF6Rf8OciQcmRJv8oTNBwIp6uqF0p' + ], + // 收款平台账号配置 + 'pay' => [ + // 账号id + 'aid' => 40, + // 收款平台 + 'platform' => 'mqpay', + // 账号 + 'account' => '258000000', + // 密码 + 'password' => '123456', + // 订单查询参数配置 + 'query' => array ( + 'terminalType' => '', + 'payType' => '', + 'payMode' => '', + 'tradeStatus' => '1', + 'tradeNo' => '', + 'storeId' => '', + 'page' => 1, + 'rows' => 10, + 'endDate' => NULL, + 'endTime' => NULL, + 'startDate' => NULL, + 'startTime' => NULL, +), + ] +]; diff --git a/view/plugin/index.html b/view/plugin/index.html index 3842681..ed5ff9e 100644 --- a/view/plugin/index.html +++ b/view/plugin/index.html @@ -107,7 +107,7 @@ const state = obj.elem.checked == true ? 1 : 0; const id = obj.value; const field = { state: state, id: id }; - layer.msg(id + ', ' + state); + plugin.enable(obj, field); return false; }); @@ -124,6 +124,20 @@ } }); } + // 启用 + plugin.enable = async (obj, field) => { + const res = await fetch('/api/Plugin/pluginEnable', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) }); + if (res.status !== 200) { + layer.msg('请求失败,请重试!', { tips: 2, time: 1200 }, () => { obj.elem.checked = !obj.elem.checked }); + return false; + } + const rec_info = await res.json(); + if (rec_info.code === 0) { + layer.tips(rec_info.msg, obj.othis, { tips: 1, time: 1200 }); + } else { + layer.msg(rec_info.msg, { icon: 2, time: 1200 }, () => { obj.elem.checked = !obj.elem.checked }); + } + } });