From cd38b4cc04932091c88fb63ffab5ef3ee66dc53a 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: Thu, 7 Nov 2024 11:59:28 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E4=BA=9B=E4=BE=BF?=
=?UTF-8?q?=E6=8D=B7=E6=93=8D=E4=BD=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controller/PluginController.php | 131 ---------------------
app/controller/api/PayManageController.php | 26 +++-
config/payconfig/1001_45.php | 35 ------
config/payconfig/1006_6.php | 35 ------
view/pay_manage/channel_list.html | 27 ++++-
view/pay_manage/edit_account.html | 10 +-
6 files changed, 57 insertions(+), 207 deletions(-)
delete mode 100644 config/payconfig/1001_45.php
delete mode 100644 config/payconfig/1006_6.php
diff --git a/app/controller/PluginController.php b/app/controller/PluginController.php
index 9f20e80..ea210a1 100644
--- a/app/controller/PluginController.php
+++ b/app/controller/PluginController.php
@@ -15,135 +15,4 @@ class PluginController extends BaseController
{
return View::fetch();
}
- /**
- * 列表
- * @param Request $request
- * @return Response
- * @throws GuzzleException
- */
- public function list(Request $request) {}
-
- /**
- * 安装
- * @param Request $request
- * @return Response
- * @throws GuzzleException|BusinessException
- */
- public function install(Request $request) {}
-
- /**
- * 卸载
- * @param Request $request
- * @return Response
- */
- public function uninstall(Request $request) {}
-
- /**
- * 支付
- * @param Request $request
- * @return string|Response
- * @throws GuzzleException
- */
- public function pay(Request $request) {}
-
- /**
- * 获取zip下载url
- * @param $name
- * @param $version
- * @return mixed
- * @throws BusinessException
- * @throws GuzzleException
- */
- protected function getDownloadUrl($name, $version) {}
-
- /**
- * 下载zip
- * @param $url
- * @param $file
- * @return void
- * @throws BusinessException
- * @throws GuzzleException
- */
- protected function downloadZipFile($url, $file) {}
-
- /**
- * 获取系统支持的解压命令
- * @param $zip_file
- * @param $extract_to
- * @return mixed|string|null
- */
- protected function getUnzipCmd($zip_file, $extract_to)
- {
- if ($cmd = $this->findCmd('unzip')) {
- $cmd = "$cmd -o -qq $zip_file -d $extract_to";
- } else if ($cmd = $this->findCmd('7z')) {
- $cmd = "$cmd x -bb0 -y $zip_file -o$extract_to";
- } else if ($cmd = $this->findCmd('7zz')) {
- $cmd = "$cmd x -bb0 -y $zip_file -o$extract_to";
- }
- return $cmd;
- }
-
- /**
- * 使用解压命令解压
- * @param $cmd
- * @return void
- * @throws BusinessException
- */
- protected function unzipWithCmd($cmd) {}
-
- /**
- * 获取已安装的插件列表
- * @return array
- */
- protected function getLocalPlugins() {}
-
- /**
- * 获取已安装的插件列表
- * @param Request $request
- * @return Response
- */
- public function getInstalledPlugins(Request $request) {}
-
-
- /**
- * 获取本地插件版本
- * @param $name
- * @return array|mixed|null
- */
- protected function getPluginVersion($name) {}
-
- /**
- * 获取webman/admin版本
- * @return string
- */
- protected function getAdminVersion() {}
-
- /**
- * 删除目录
- * @param $src
- * @return void
- */
- protected function rmDir($src) {}
-
- /**
- * 获取httpclient
- * @return Client
- */
- protected function httpClient() {}
-
- /**
- * 获取下载httpclient
- * @return Client
- */
- protected function downloadClient() {}
-
- /**
- * 查找系统命令
- * @param string $name
- * @param string|null $default
- * @param array $extraDirs
- * @return mixed|string|null
- */
- protected function findCmd(string $name, string $default = null, array $extraDirs = []) {}
}
diff --git a/app/controller/api/PayManageController.php b/app/controller/api/PayManageController.php
index 2c0114e..58c966b 100644
--- a/app/controller/api/PayManageController.php
+++ b/app/controller/api/PayManageController.php
@@ -54,8 +54,12 @@ class PayManageController extends BaseController
{
$ids = $this->request->post('ids');
$res = PayAccount::destroy($ids);
- $res2 = PayChannel::destroy($ids);
+ $res2 = PayChannel::whereIn('account_id', $ids)->select()->delete();
if ($res && $res2) {
+ $accs = PayAccount::whereIn('id', $ids)->withTrashed()->select();
+ foreach ($accs as $acc) {
+ $this->delAccountConfig($acc);
+ }
return \json(\backMsg(0, '已删除'));
} else {
return \json(\backMsg(1, '失败'));
@@ -105,6 +109,17 @@ class PayManageController extends BaseController
return json(\backMsg(1, '修改失败'));
}
}
+ // 删除收款终端
+ public function delChannel()
+ {
+ $cid = $this->request->post('id');
+ $res = PayChannel::destroy($cid);
+ if ($res) {
+ return \json(\backMsg(0, '已删除'));
+ } else {
+ return \json(\backMsg(1, '失败'));
+ }
+ }
// 收款终端列表
public function getChannelList()
{
@@ -116,6 +131,15 @@ class PayManageController extends BaseController
return \json(\backMsg(1, '失败'));
}
}
+ // 删除账号配置
+ public function delAccountConfig($acc)
+ {
+ $path = config_path() . "/payconfig/{$acc->pid}_{$acc->id}.php";
+ if (file_exists($path)) {
+ unlink($path);
+ }
+ }
+
// 生成账号配置
private function createAccountConfig($acc)
{
diff --git a/config/payconfig/1001_45.php b/config/payconfig/1001_45.php
deleted file mode 100644
index d8117ab..0000000
--- a/config/payconfig/1001_45.php
+++ /dev/null
@@ -1,35 +0,0 @@
- [
- 'pid' => 1001,
- 'key' => '953c4d682d9ab148277b76a06e215ce7'
- ],
- // 收款平台账号配置
- 'pay' => [
- // 账号id
- 'aid' => 45,
- // 收款平台
- 'platform' => 'storepay',
- // 插件类名
- 'payclass' => 'ZhiHuiJingYing',
- // 账号
- 'account' => '16546465',
- // 密码
- 'password' => '5464564654',
- // 订单查询参数配置
- 'query' => array (
- 'pageNo' => 1,
- 'pageSize' => 10,
- 'payClient' => 4,
- 'status' => 2,
- '_t' => NULL,
- 'createTime_begin' => NULL,
- 'createTime_end' => NULL,
-),
- ]
-];
diff --git a/config/payconfig/1006_6.php b/config/payconfig/1006_6.php
deleted file mode 100644
index 5ea0590..0000000
--- a/config/payconfig/1006_6.php
+++ /dev/null
@@ -1,35 +0,0 @@
- [
- 'pid' => 1006,
- 'key' => ''
- ],
- // 收款平台账号配置
- 'pay' => [
- // 账号id
- 'aid' => 6,
- // 收款平台
- 'platform' => 'storepay',
- // 插件类名
- 'payclass' => 'ZhiHuiJingYing',
- // 账号
- 'account' => '18239931385',
- // 密码
- 'password' => '12345678',
- // 订单查询参数配置
- 'query' => array (
- 'pageNo' => 1,
- 'pageSize' => 10,
- 'payClient' => 4,
- 'status' => 2,
- '_t' => NULL,
- 'createTime_begin' => NULL,
- 'createTime_end' => NULL,
-),
- ]
-];
diff --git a/view/pay_manage/channel_list.html b/view/pay_manage/channel_list.html
index 3e51574..576876b 100644
--- a/view/pay_manage/channel_list.html
+++ b/view/pay_manage/channel_list.html
@@ -53,11 +53,11 @@
})()
},
edit: function () {
- const cid = this.getAttribute("data-cid")
+ const cid = this.getAttribute("data-cid");
layer.open({
id: 'iframe-channel-edit',
type: 2,
- title: '添加收款终端',
+ title: '修改终端',
shade: 0.1,
area: [common.isModile() ? '80%' : '400px', common.isModile() ? '70%' : '300px'],
content: `/PayManage/editChannel?cid=${cid}`,
@@ -74,6 +74,24 @@
content: `/PayManage/addChannel?aid=${aid}`,
});
},
+ delete: function () {
+ const cid = this.getAttribute("data-cid");
+ layer.confirm('确定删除终端?', { icon: 3, title: '提示' },
+ function (index) {
+ fetch('/api/PayManage/delChannel', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: cid }) })
+ .then(res => res.json())
+ .then(res => {
+ if (res.code === 0) {
+ layer.msg(res.msg, { icon: 1, time: 1200 }, function () {
+ location.reload();
+ });
+ } else {
+ layer.msg(res.msg, { icon: 2, time: 1200 });
+ }
+ })
+ layer.close(index);
+ });
+ },
});
// 工具
let channel = {};
@@ -89,7 +107,10 @@
最后使用${item.last_time}
启用状态${item.state == 1 ? '启用' : '禁用'}
-
+