[上传]初始化V6版本代码

This commit is contained in:
Anyon 2019-11-01 16:42:24 +08:00
parent f678fece61
commit d96ccdfbd6
1184 changed files with 3947 additions and 138019 deletions

24
.gitignore vendored
View File

@ -1,17 +1,7 @@
/.git
/.svn
/.idea
/runtime
/safefile
/nbproject
/config/cert
/composer.lock
/public/upload
/public/static/theme/css/console.custom.css
/public/static/theme/css/console.custom.css.map
/public/static/theme/css/console.form.css
/public/static/theme/css/console.form.css.map
/public/static/theme/css/console.layout.css
/public/static/theme/css/console.layout.css.map
/public/static/theme/css/console.layui.css
/public/static/theme/css/console.layui.css.map
.env
.idea
*.log
.vscode
vendor
runtime
public/upload

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019 邹景立
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

134
README.md
View File

@ -1,133 +1,3 @@
## 大道至简 · 原生框架
ThinkAdmin v6 基于 ThinkPHP6.0 开发。
ThinkAdmin V5 是一个基于 ThinkPHP 5.1 开发的后台管理系统。
我们致力于二次开发底层框架提供完整的组件及API基于此框架可以快速开发应用。
另外项目安装及二次开发可以参考 ThinkPHP 官方文档,数据库文件摆放在项目根目录下。
ThinkAdmin 非常适用快速二次开发,默认集成 微信开发组件支持微信服务号、微信支付、支付宝支付、阿里云OSS存储、七牛云存储、本地服务器存储等。
后台UI基于最新版本的 LayUI 及 RequireJs 加载第三方插件(建议自行了解 LayUI 及 RequireJs
#### 注意事项
* 项目测试需要自行搭建环境导入数据库( admin_v5.sql )并修改配置( config/database.php )
* 若操作提示“演示系统禁止操作”等字样,需要删除演示路由配置( route/demo.php )或清空路由文件;
* 当前版本使用 ThinkPHP 5.1.x对 PHP 版本标注不低于 PHP 5.6,具体请阅读 ThinkPHP 官方文档;
* 环境需开启 PATHINFO不再支持 ThinkPHP 的 URL 兼容模式运行(源于如何优雅的展示);
## 技术支持
开发文档http://doc.thinkadmin.top/thinkadmin-v5
开发前请认真阅读 ThinkPHP 官方文档会对您有帮助哦!
本地开发命令`php think run`,使用`http://127.0.0.1:8000`访问项目。
PHP 开发技术交流( QQ 群 513350915
[![PHP微信开发群 (SDK)](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=ae25cf789dafbef62e50a980ffc31242f150bc61a61164458216dd98c411832a)
## 注解权限
注解权限是指通过方法注释来实现后台RBAC授权管理用注解来管理功能节点。
开发人员只需要写好注释RBAC的节点会自动生成只需要配置角色及用户就可以使用RBAC权限。
* 此版本的权限使用注解实现
* 注释必需使用标准的块注释,如下案例
* 其中`@auth true`表示访问需要权限验证
* 其中`@menu true`显示在菜单编辑的节点可选项
```php
/**
* 操作的名称
* @auth true # 表示需要验证权限
* @menu true # 在菜单编辑的节点可选项
*/
public function index(){
// @todo
}
```
## 代码仓库
ThinkAdmin 为 MIT 协议开源项目,安装使用或二次开发不受约束,欢迎 fork 项目。
部分代码来自互联网,若有异议可以联系作者进行删除。
* 在线体验地址https://demo.thinkadmin.top (账号和密码都是 admin
* Gitee仓库地址https://gitee.com/zoujingli/ThinkAdmin
* GitHub仓库地址https://github.com/zoujingli/ThinkAdmin
## 框架指令
* 执行 `build.cmd` 可更新 `Composer` 插件,会删除并替换 `vendor` 目录
* 执行 `php think run` 启用本地开发环境,访问 `http://127.0.0.1:8000`
#### 1. 线上代码更新
* 执行 `php think xsync:admin` 从线上服务更新 `admin` 模块的所有文件(注意文件安全)
* 执行 `php think xsync:wechat` 从线上服务更新 `wechat` 模块的所有文件(注意文件安全)
* 执行 `php think xsync:service` 从线上服务更新 `service` 模块的所有文件(注意文件安全)
* 执行 `php think xsync:plugs` 从线上服务更新 `plugs` 静态插件的部分文件(注意文件安全)
* 执行 `php think xsync:config` 从线上服务更新 `config` 项目配置的部分文件(注意文件安全)
#### 2. 微信资料管理
* 执行 `php think xfans:all` 更新已经对接的公众号全部列表
* 执行 `php think xfans:list` 更新已经对接的公众号粉丝列表
* 执行 `php think xfans:tags` 更新已经对接的公众号标签列表
* 执行 `php think xfans:black` 更新已经对接的公众号黑名单列表
#### 3. 守护进程管理
* 执行 `php think xtask:listen` 启动异步任务监听守护主进程
* 执行 `php think xtask:query` 查询正在执行的所有任务进程
* 执行 `php think xtask:start` 创建异步任务监听守护主进程
* 执行 `php think xtask:state` 查看异步任务监听主进程状态
* 执行 `php think xtask:stop` 平滑停止异步任务所有的进程
#### 4. 其它自定工具
* 执行 `php think xclean:session` 清理无效的会话SESSION文件
* 执行 `php think xclean:store` 清理无效的订单信息及定时任务
## 特别感谢
|名称|描述|
|---|---|
|layui|后台基础UI组件库|
|ckeditor|后台富文本编辑器|
|awesome|后台扩展字体图标库|
|pluploader|后台文件上传工具|
|ThinkPHP|PHP基础支持框架|
|ThinkLibrary|ThinkPHP扩展组件|
|WeChatDeveloper|微信开放工具组件|
|WeOpenDeveloper|微信开放平台组件|
## 赞助打赏
![赞助](http://static.thinkadmin.top/pay.png)
## 项目版本
体验账号及密码都是`admin`
#### ThinkAdmin v1 基于 ThinkPHP 5.0 开发
* 在线体验地址https://v1.thinkadmin.top
* Gitee 代码地址https://gitee.com/zoujingli/ThinkAdmin/tree/v1
* Github 代码地址https://github.com/zoujingli/ThinkAdmin/tree/v1
#### ThinkAdmin v2 基于 ThinkPHP 5.0 开发
* 在线体验地址https://v2.thinkadmin.top
* Gitee 代码地址https://gitee.com/zoujingli/ThinkAdmin/tree/v2
* Github 代码地址https://github.com/zoujingli/ThinkAdmin/tree/v2
#### ThinkAdmin v3 基于 ThinkPHP 5.1 开发
* 在线体验地址https://v3.thinkadmin.top
* Gitee 代码地址https://gitee.com/zoujingli/ThinkAdmin/tree/v3
* Github 代码地址https://github.com/zoujingli/ThinkAdmin/tree/v3
#### ThinkAdmin v4 基于 ThinkPHP 5.1 开发
* 在线体验地址https://v4.thinkadmin.top
* Gitee 代码地址https://gitee.com/zoujingli/ThinkAdmin/tree/v4
* Github 代码地址https://github.com/zoujingli/ThinkAdmin/tree/v4
#### ThinkAdmin v5 基于 ThinkPHP 5.1 开发(后台权限基于注解实现)
* 在线体验地址https://v5.thinkadmin.top
* Gitee 代码地址https://gitee.com/zoujingli/ThinkAdmin/tree/v5
* Github 代码地址https://github.com/zoujingli/ThinkAdmin/tree/v5
目前处理开发阶段,请匆应用到线上版本项目开发!!!

View File

@ -1,859 +0,0 @@
/*
Navicat Premium Data Transfer
Source Server : local.server.cuci.cc
Source Server Type : MySQL
Source Server Version : 50562
Source Host : server.cuci.cc:3306
Source Schema : admin_v5
Target Server Type : MySQL
Target Server Version : 50562
File Encoding : 65001
Date: 19/08/2019 10:34:31
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for company_user
-- ----------------------------
DROP TABLE IF EXISTS `company_user`;
CREATE TABLE `company_user` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`nickname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '员工姓名',
`svn_username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '员工账号',
`svn_password` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '员工密码',
`svn_authorize` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '权限授权',
`user_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '员工身份',
`entry_date` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '入职日期',
`leave_date` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '离职日期',
`become_date` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '转正日期',
`contact_qq` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系QQ',
`contact_mail` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系邮箱',
`contact_phone` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系手机',
`mobile_macs` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '打卡手机',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1正常,2离职)',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除(1删除,0未删)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `idx_company_user_nickname`(`nickname`) USING BTREE,
INDEX `idx_company_user_svn_username`(`svn_username`) USING BTREE,
INDEX `idx_company_user_deleted`(`is_deleted`) USING BTREE,
INDEX `idx_company_user_status`(`status`) USING BTREE,
INDEX `idx_company_user_type`(`user_type`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业-员工信息';
-- ----------------------------
-- Table structure for company_user_auth
-- ----------------------------
DROP TABLE IF EXISTS `company_user_auth`;
CREATE TABLE `company_user_auth` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '权限名称',
`path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '权限路径',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1正常)',
`desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '权限描述',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除(1删除,0未删)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_company_user_auth_status`(`status`) USING BTREE,
INDEX `idx_company_user_auth_deleted`(`is_deleted`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业-仓库权限';
-- ----------------------------
-- Table structure for company_user_clock
-- ----------------------------
DROP TABLE IF EXISTS `company_user_clock`;
CREATE TABLE `company_user_clock` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '用户ID',
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户姓名',
`ip` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '权限名称',
`mac` char(17) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '1' COMMENT '状态(1:禁用,2:启用)',
`desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注说明',
`date` date NULL DEFAULT NULL,
`start_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`end_at` datetime NULL DEFAULT NULL COMMENT '结束时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_company_user_clock_date`(`date`) USING BTREE,
INDEX `idx_company_user_clock_uid`(`uid`) USING BTREE,
INDEX `idx_company_user_clock_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '企业-打卡记录';
-- ----------------------------
-- Table structure for store_express_company
-- ----------------------------
DROP TABLE IF EXISTS `store_express_company`;
CREATE TABLE `store_express_company` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`express_title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '快递公司名称',
`express_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '快递公司代码',
`express_desc` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '快递公司描述',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0.无效,1.有效)',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态(1删除,0未删除)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 95 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商城-快递-公司';
-- ----------------------------
-- Records of store_express_company
-- ----------------------------
INSERT INTO `store_express_company` VALUES (5, 'AAE全球专递', 'aae', NULL, 0, 0, 0, '2017-09-12 11:53:40');
INSERT INTO `store_express_company` VALUES (6, '安捷快递', 'anjie', '', 0, 0, 0, '2017-09-13 15:27:26');
INSERT INTO `store_express_company` VALUES (7, '安信达快递', 'anxindakuaixi', NULL, 0, 0, 0, '2017-09-13 16:05:19');
INSERT INTO `store_express_company` VALUES (8, '彪记快递', 'biaojikuaidi', NULL, 0, 0, 0, '2017-09-13 16:05:26');
INSERT INTO `store_express_company` VALUES (9, 'BHT', 'bht', '', 0, 0, 0, '2017-09-13 16:05:37');
INSERT INTO `store_express_company` VALUES (10, '百福东方国际物流', 'baifudongfang', NULL, 0, 0, 0, '2017-09-13 16:05:41');
INSERT INTO `store_express_company` VALUES (11, '中国东方COE', 'coe', NULL, 0, 0, 0, '2017-09-13 16:05:48');
INSERT INTO `store_express_company` VALUES (12, '长宇物流', 'changyuwuliu', NULL, 0, 0, 0, '2017-09-13 16:05:58');
INSERT INTO `store_express_company` VALUES (13, '大田物流', 'datianwuliu', NULL, 0, 0, 0, '2017-09-13 16:06:06');
INSERT INTO `store_express_company` VALUES (14, '德邦物流', 'debangwuliu', '', 0, 1, 0, '2017-09-13 16:06:14');
INSERT INTO `store_express_company` VALUES (15, 'DHL', 'dhl', NULL, 0, 0, 0, '2017-09-13 16:06:24');
INSERT INTO `store_express_company` VALUES (16, 'DPEX', 'dpex', NULL, 0, 0, 0, '2017-09-13 16:06:29');
INSERT INTO `store_express_company` VALUES (17, 'd速快递', 'dsukuaidi', NULL, 0, 0, 0, '2017-09-13 16:06:34');
INSERT INTO `store_express_company` VALUES (18, '递四方', 'disifang', NULL, 0, 0, 0, '2017-09-13 16:06:40');
INSERT INTO `store_express_company` VALUES (19, 'EMS快递', 'ems', '', 1, 0, 0, '2017-09-13 16:06:47');
INSERT INTO `store_express_company` VALUES (20, 'FEDEX国外', 'fedex', NULL, 0, 0, 0, '2017-09-13 16:06:56');
INSERT INTO `store_express_company` VALUES (21, '飞康达物流', 'feikangda', NULL, 0, 0, 0, '2017-09-13 16:07:03');
INSERT INTO `store_express_company` VALUES (22, '凤凰快递', 'fenghuangkuaidi', NULL, 0, 0, 0, '2017-09-13 16:07:10');
INSERT INTO `store_express_company` VALUES (23, '飞快达', 'feikuaida', NULL, 0, 0, 0, '2017-09-13 16:07:16');
INSERT INTO `store_express_company` VALUES (24, '国通快递', 'guotongkuaidi', NULL, 0, 0, 0, '2017-09-13 16:07:27');
INSERT INTO `store_express_company` VALUES (25, '港中能达物流', 'ganzhongnengda', NULL, 0, 0, 0, '2017-09-13 16:07:33');
INSERT INTO `store_express_company` VALUES (26, '广东邮政物流', 'guangdongyouzhengwuliu', NULL, 0, 0, 0, '2017-09-13 16:08:22');
INSERT INTO `store_express_company` VALUES (27, '共速达', 'gongsuda', NULL, 0, 0, 0, '2017-09-13 16:08:48');
INSERT INTO `store_express_company` VALUES (28, '汇通快运', 'huitongkuaidi', NULL, 0, 0, 0, '2017-09-13 16:08:56');
INSERT INTO `store_express_company` VALUES (29, '恒路物流', 'hengluwuliu', NULL, 0, 0, 0, '2017-09-13 16:09:02');
INSERT INTO `store_express_company` VALUES (30, '华夏龙物流', 'huaxialongwuliu', NULL, 0, 0, 0, '2017-09-13 16:09:12');
INSERT INTO `store_express_company` VALUES (31, '海红', 'haihongwangsong', NULL, 0, 0, 0, '2017-09-13 16:09:20');
INSERT INTO `store_express_company` VALUES (32, '海外环球', 'haiwaihuanqiu', NULL, 0, 0, 0, '2017-09-13 16:09:27');
INSERT INTO `store_express_company` VALUES (33, '佳怡物流', 'jiayiwuliu', NULL, 0, 0, 0, '2017-09-13 16:09:35');
INSERT INTO `store_express_company` VALUES (34, '京广速递', 'jinguangsudikuaijian', NULL, 0, 0, 0, '2017-09-13 16:09:42');
INSERT INTO `store_express_company` VALUES (35, '急先达', 'jixianda', NULL, 0, 0, 0, '2017-09-13 16:09:49');
INSERT INTO `store_express_company` VALUES (36, '佳吉物流', 'jjwl', NULL, 0, 0, 0, '2017-09-13 16:10:01');
INSERT INTO `store_express_company` VALUES (37, '加运美物流', 'jymwl', NULL, 0, 0, 0, '2017-09-13 16:10:13');
INSERT INTO `store_express_company` VALUES (38, '金大物流', 'jindawuliu', NULL, 0, 0, 0, '2017-09-13 16:10:22');
INSERT INTO `store_express_company` VALUES (39, '嘉里大通', 'jialidatong', NULL, 0, 0, 0, '2017-09-13 16:10:33');
INSERT INTO `store_express_company` VALUES (40, '晋越快递', 'jykd', NULL, 0, 0, 0, '2017-09-13 16:10:40');
INSERT INTO `store_express_company` VALUES (41, '快捷速递', 'kuaijiesudi', NULL, 0, 0, 0, '2017-09-13 16:10:49');
INSERT INTO `store_express_company` VALUES (42, '联邦快递(国内)', 'lianb', NULL, 0, 0, 0, '2017-09-13 16:10:58');
INSERT INTO `store_express_company` VALUES (43, '联昊通物流', 'lianhaowuliu', NULL, 0, 0, 0, '2017-09-13 16:11:07');
INSERT INTO `store_express_company` VALUES (44, '龙邦物流', 'longbanwuliu', NULL, 0, 0, 0, '2017-09-13 16:11:15');
INSERT INTO `store_express_company` VALUES (45, '立即送', 'lijisong', NULL, 0, 0, 0, '2017-09-13 16:11:25');
INSERT INTO `store_express_company` VALUES (46, '乐捷递', 'lejiedi', NULL, 0, 0, 0, '2017-09-13 16:11:36');
INSERT INTO `store_express_company` VALUES (47, '民航快递', 'minghangkuaidi', NULL, 0, 0, 0, '2017-09-13 16:11:45');
INSERT INTO `store_express_company` VALUES (48, '美国快递', 'meiguokuaidi', NULL, 0, 0, 0, '2017-09-13 16:11:53');
INSERT INTO `store_express_company` VALUES (49, '门对门', 'menduimen', NULL, 0, 0, 0, '2017-09-13 16:12:01');
INSERT INTO `store_express_company` VALUES (50, 'OCS', 'ocs', NULL, 0, 0, 0, '2017-09-13 16:12:10');
INSERT INTO `store_express_company` VALUES (51, '配思货运', 'peisihuoyunkuaidi', NULL, 0, 0, 0, '2017-09-13 16:12:18');
INSERT INTO `store_express_company` VALUES (52, '全晨快递', 'quanchenkuaidi', NULL, 0, 0, 0, '2017-09-13 16:12:26');
INSERT INTO `store_express_company` VALUES (53, '全峰快递', 'quanfengkuaidi', NULL, 0, 0, 0, '2017-09-13 16:12:34');
INSERT INTO `store_express_company` VALUES (54, '全际通物流', 'quanjitong', NULL, 0, 0, 0, '2017-09-13 16:12:41');
INSERT INTO `store_express_company` VALUES (55, '全日通快递', 'quanritongkuaidi', NULL, 0, 0, 0, '2017-09-13 16:12:49');
INSERT INTO `store_express_company` VALUES (56, '全一快递', 'quanyikuaidi', NULL, 0, 0, 0, '2017-09-13 16:12:56');
INSERT INTO `store_express_company` VALUES (57, '如风达', 'rufengda', NULL, 0, 0, 0, '2017-09-13 16:13:03');
INSERT INTO `store_express_company` VALUES (58, '三态速递', 'santaisudi', NULL, 0, 0, 0, '2017-09-13 16:13:15');
INSERT INTO `store_express_company` VALUES (59, '盛辉物流', 'shenghuiwuliu', NULL, 0, 0, 0, '2017-09-13 16:13:22');
INSERT INTO `store_express_company` VALUES (60, '申通', 'shentong', NULL, 0, 0, 0, '2017-09-13 16:13:34');
INSERT INTO `store_express_company` VALUES (61, '顺丰', 'shunfeng', '', 0, 0, 0, '2017-09-13 16:13:41');
INSERT INTO `store_express_company` VALUES (62, '速尔物流', 'sue', NULL, 0, 0, 0, '2017-09-13 16:13:48');
INSERT INTO `store_express_company` VALUES (63, '盛丰物流', 'shengfeng', NULL, 0, 0, 0, '2017-09-13 16:13:55');
INSERT INTO `store_express_company` VALUES (64, '赛澳递', 'saiaodi', NULL, 0, 0, 0, '2017-09-13 16:14:02');
INSERT INTO `store_express_company` VALUES (65, '天地华宇', 'tiandihuayu', NULL, 0, 0, 0, '2017-09-13 16:14:11');
INSERT INTO `store_express_company` VALUES (66, '天天快递', 'tiantian', NULL, 0, 0, 0, '2017-09-13 16:14:19');
INSERT INTO `store_express_company` VALUES (67, 'TNT', 'tnt', NULL, 0, 0, 0, '2017-09-13 16:14:26');
INSERT INTO `store_express_company` VALUES (68, 'UPS', 'ups', NULL, 0, 0, 0, '2017-09-13 16:14:29');
INSERT INTO `store_express_company` VALUES (69, '万家物流', 'wanjiawuliu', NULL, 0, 0, 0, '2017-09-13 16:14:37');
INSERT INTO `store_express_company` VALUES (70, '文捷航空速递', 'wenjiesudi', NULL, 0, 0, 0, '2017-09-13 16:14:46');
INSERT INTO `store_express_company` VALUES (71, '伍圆', 'wuyuan', NULL, 0, 0, 0, '2017-09-13 16:14:52');
INSERT INTO `store_express_company` VALUES (72, '万象物流', 'wxwl', NULL, 0, 0, 0, '2017-09-13 16:15:00');
INSERT INTO `store_express_company` VALUES (73, '新邦物流', 'xinbangwuliu', NULL, 0, 0, 0, '2017-09-13 16:15:06');
INSERT INTO `store_express_company` VALUES (74, '信丰物流', 'xinfengwuliu', NULL, 0, 0, 0, '2017-09-13 16:15:15');
INSERT INTO `store_express_company` VALUES (75, '亚风速递', 'yafengsudi', NULL, 0, 0, 0, '2017-09-13 16:15:23');
INSERT INTO `store_express_company` VALUES (76, '一邦速递', 'yibangwuliu', NULL, 0, 0, 0, '2017-09-13 16:15:30');
INSERT INTO `store_express_company` VALUES (77, '优速物流', 'youshuwuliu', NULL, 0, 0, 0, '2017-09-13 16:15:36');
INSERT INTO `store_express_company` VALUES (78, '邮政包裹挂号信', 'youzhengguonei', NULL, 0, 3, 0, '2017-09-13 16:15:44');
INSERT INTO `store_express_company` VALUES (79, '邮政国际包裹挂号信', 'youzhengguoji', NULL, 0, 2, 0, '2017-09-13 16:15:51');
INSERT INTO `store_express_company` VALUES (80, '远成物流', 'yuanchengwuliu', NULL, 0, 0, 0, '2017-09-13 16:15:57');
INSERT INTO `store_express_company` VALUES (81, '圆通速递', 'yuantong', '', 1, 1, 0, '2017-09-13 16:16:03');
INSERT INTO `store_express_company` VALUES (82, '源伟丰快递', 'yuanweifeng', NULL, 0, 0, 0, '2017-09-13 16:16:10');
INSERT INTO `store_express_company` VALUES (83, '元智捷诚快递', 'yuanzhijiecheng', NULL, 0, 0, 0, '2017-09-13 16:16:17');
INSERT INTO `store_express_company` VALUES (84, '韵达快运', 'yunda', NULL, 0, 0, 0, '2017-09-13 16:16:24');
INSERT INTO `store_express_company` VALUES (85, '运通快递', 'yuntongkuaidi', NULL, 0, 0, 0, '2017-09-13 16:16:33');
INSERT INTO `store_express_company` VALUES (86, '越丰物流', 'yuefengwuliu', NULL, 0, 0, 0, '2017-09-13 16:16:40');
INSERT INTO `store_express_company` VALUES (87, '源安达', 'yad', NULL, 0, 0, 0, '2017-09-13 16:16:47');
INSERT INTO `store_express_company` VALUES (88, '银捷速递', 'yinjiesudi', NULL, 0, 0, 0, '2017-09-13 16:16:56');
INSERT INTO `store_express_company` VALUES (89, '宅急送', 'zhaijisong', NULL, 0, 0, 0, '2017-09-13 16:17:03');
INSERT INTO `store_express_company` VALUES (90, '中铁快运', 'zhongtiekuaiyun', NULL, 0, 0, 0, '2017-09-13 16:17:10');
INSERT INTO `store_express_company` VALUES (91, '中通速递', 'zhongtong', '', 0, 0, 0, '2017-09-13 16:17:16');
INSERT INTO `store_express_company` VALUES (92, '中邮物流', 'zhongyouwuliu', NULL, 0, 0, 0, '2017-09-13 16:17:27');
INSERT INTO `store_express_company` VALUES (93, '忠信达', 'zhongxinda', NULL, 0, 0, 0, '2017-09-13 16:17:34');
INSERT INTO `store_express_company` VALUES (94, '芝麻开门', 'zhimakaimen', '', 1, 0, 0, '2017-09-13 16:17:41');
-- ----------------------------
-- Table structure for store_express_template
-- ----------------------------
DROP TABLE IF EXISTS `store_express_template`;
CREATE TABLE `store_express_template` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`rule` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '省份规则内容',
`order_reduction_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '订单满减状态',
`order_reduction_price` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '订单满减金额',
`first_number` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '首件数量',
`first_price` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '首件邮费',
`next_number` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '续件数量',
`next_price` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '续件邮费',
`is_default` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '默认规则',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_express_template_is_default`(`is_default`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商城-快递-模板';
-- ----------------------------
-- Table structure for store_goods
-- ----------------------------
DROP TABLE IF EXISTS `store_goods`;
CREATE TABLE `store_goods` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`cate_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品分类',
`title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品标题',
`logo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品图标',
`specs` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品规格JSON',
`lists` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品列表JSON',
`image` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品图片',
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '商品内容',
`number_sales` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '销售数量',
`number_stock` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '库库数量',
`price_rate` decimal(20, 4) UNSIGNED NULL DEFAULT 0.0000 COMMENT '返利比例',
`price_express` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '统一运费',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '销售状态',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_goods_status`(`status`) USING BTREE,
INDEX `idx_store_goods_cate_id`(`cate_id`) USING BTREE,
INDEX `idx_store_goods_is_deleted`(`is_deleted`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品-记录';
-- ----------------------------
-- Table structure for store_goods_cate
-- ----------------------------
DROP TABLE IF EXISTS `store_goods_cate`;
CREATE TABLE `store_goods_cate` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`logo` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '分类图标',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '分类名称',
`desc` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '分类描述',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '销售状态',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_goods_cate_is_deleted`(`is_deleted`) USING BTREE,
INDEX `idx_store_goods_cate_status`(`status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品-分类';
-- ----------------------------
-- Table structure for store_goods_list
-- ----------------------------
DROP TABLE IF EXISTS `store_goods_list`;
CREATE TABLE `store_goods_list` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`sku` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'sku',
`goods_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品ID',
`goods_spec` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '商品规格',
`price_market` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '商品标价',
`price_selling` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '商品售价',
`number_sales` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '销售数量',
`number_stock` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品库存',
`number_virtual` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '虚拟销量',
`number_express` bigint(20) UNSIGNED NULL DEFAULT 1 COMMENT '快递数量',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '商品状态',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_goods_list_id`(`goods_id`) USING BTREE,
INDEX `idx_store_goods_list_spec`(`goods_spec`) USING BTREE,
INDEX `idx_store_goods_list_status`(`status`) USING BTREE,
INDEX `idx_store_goods_list_sku`(`sku`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品-详情';
-- ----------------------------
-- Table structure for store_goods_stock
-- ----------------------------
DROP TABLE IF EXISTS `store_goods_stock`;
CREATE TABLE `store_goods_stock` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`goods_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品ID',
`goods_spec` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '商品规格',
`number_stock` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品库存',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_goods_stock_gid`(`goods_id`) USING BTREE,
INDEX `idx_store_goods_stock_spec`(`goods_spec`(191)) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品-入库';
-- ----------------------------
-- Table structure for store_member
-- ----------------------------
DROP TABLE IF EXISTS `store_member`;
CREATE TABLE `store_member` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '微信OPENID',
`headimg` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像地址',
`nickname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '微信昵称',
`phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系手机',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '真实姓名',
`vip_level` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '会员级别(0游客,1为临时,2为VIP1,3为VIP2)',
`vip_date` date NULL DEFAULT NULL COMMENT '保级日期',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_member_openid`(`openid`) USING BTREE,
INDEX `idx_store_member_phone`(`phone`) USING BTREE,
INDEX `idx_store_member_vip_level`(`vip_level`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员-记录';
-- ----------------------------
-- Table structure for store_member_address
-- ----------------------------
DROP TABLE IF EXISTS `store_member_address`;
CREATE TABLE `store_member_address` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`mid` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '会员ID',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货姓名',
`phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货手机',
`province` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '地址-省份',
`city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '地址-城市',
`area` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '地址-区域',
`address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '地址-详情',
`is_default` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '默认地址',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_member_address_mid`(`mid`) USING BTREE,
INDEX `idx_store_member_address_is_default`(`is_default`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会员-地址';
-- ----------------------------
-- Table structure for store_member_sms_history
-- ----------------------------
DROP TABLE IF EXISTS `store_member_sms_history`;
CREATE TABLE `store_member_sms_history` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`mid` bigint(20) unsigned DEFAULT '0' COMMENT '会员ID',
`phone` varchar(20) DEFAULT '' COMMENT '目标手机',
`content` varchar(512) DEFAULT '' COMMENT '短信内容',
`region` varchar(100) DEFAULT '' COMMENT '区域编码',
`result` varchar(100) DEFAULT '' COMMENT '返回结果',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_store_member_sms_history_phone` (`phone`) USING BTREE,
KEY `idx_store_member_sms_history_mid` (`mid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员-短信';
-- ----------------------------
-- Table structure for store_order
-- ----------------------------
DROP TABLE IF EXISTS `store_order`;
CREATE TABLE `store_order` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`mid` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '会员ID',
`order_no` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '订单单号',
`from_mid` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '推荐会员ID',
`price_total` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '待付金额统计',
`price_goods` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '商品费用统计',
`price_express` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '快递费用统计',
`price_rate_amount` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '返利金额统计',
`pay_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '支付状态(0未支付,1已支付)',
`pay_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付方式',
`pay_price` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '支付金额',
`pay_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '支付单号',
`pay_at` datetime NULL DEFAULT NULL COMMENT '支付时间',
`cancel_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '取消状态',
`cancel_at` datetime NULL DEFAULT NULL COMMENT '取消时间',
`cancel_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '取消描述',
`refund_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '退款状态(0未退款,1待退款,2已退款)',
`refund_at` datetime NULL DEFAULT NULL COMMENT '退款时间',
`refund_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '退款单号',
`refund_price` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '退款金额',
`refund_desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '退款描述',
`express_state` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '发货状态(0未发货,1已发货,2已签收)',
`express_company_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发货快递公司编码',
`express_company_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发货快递公司名称',
`express_send_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发货单号',
`express_send_at` datetime NULL DEFAULT NULL COMMENT '发货时间',
`express_address_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '收货地址ID',
`express_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货人姓名',
`express_phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货人手机',
`express_province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货地址省份',
`express_city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货地址城市',
`express_area` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货地址区域',
`express_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '收货详细地址',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '订单状态(0已取消,1预订单待补全,2新订单待支付,3已支付待发货,4已发货待签收,5已完成)',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_groups_order_mid`(`mid`) USING BTREE,
INDEX `idx_store_groups_order_order_no`(`order_no`) USING BTREE,
INDEX `idx_store_groups_order_pay_state`(`pay_state`) USING BTREE,
INDEX `idx_store_groups_order_cancel_state`(`cancel_state`) USING BTREE,
INDEX `idx_store_groups_order_refund_state`(`refund_state`) USING BTREE,
INDEX `idx_store_groups_order_status`(`status`) USING BTREE,
INDEX `idx_store_groups_order_pay_no`(`pay_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单-记录';
-- ----------------------------
-- Table structure for store_order_list
-- ----------------------------
DROP TABLE IF EXISTS `store_order_list`;
CREATE TABLE `store_order_list` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`mid` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '会员ID',
`from_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '推荐会员',
`order_no` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '订单单号',
`goods_id` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品标识',
`goods_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '商品标题',
`goods_logo` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '商品图标',
`goods_spec` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '商品规格',
`price_real` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '交易金额',
`price_selling` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '销售价格',
`price_market` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '市场价格',
`price_express` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '快递费用',
`price_rate` decimal(20, 4) UNSIGNED NULL DEFAULT 0.0000 COMMENT '分成比例',
`price_rate_amount` decimal(20, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '分成金额',
`number_goods` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '商品数量',
`number_express` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '快递数量',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_store_goods_list_id`(`goods_id`) USING BTREE,
INDEX `idx_store_goods_list_spec`(`goods_spec`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单-详情';
-- ----------------------------
-- Table structure for system_auth
-- ----------------------------
DROP TABLE IF EXISTS `system_auth`;
CREATE TABLE `system_auth` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限名称',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '权限状态',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序权重',
`desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注说明',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_auth_status`(`status`) USING BTREE,
INDEX `idx_system_auth_title`(`title`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-权限';
-- ----------------------------
-- Table structure for system_auth_node
-- ----------------------------
DROP TABLE IF EXISTS `system_auth_node`;
CREATE TABLE `system_auth_node` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`auth` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '角色',
`node` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '节点',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_auth_auth`(`auth`) USING BTREE,
INDEX `idx_system_auth_node`(`node`(191)) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-权限-授权';
-- ----------------------------
-- Table structure for system_config
-- ----------------------------
DROP TABLE IF EXISTS `system_config`;
CREATE TABLE `system_config` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '配置名',
`value` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '配置值',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_config_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 81 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-配置';
-- ----------------------------
-- Records of system_config
-- ----------------------------
INSERT INTO `system_config` VALUES (1, 'app_name', 'ThinkAdmin');
INSERT INTO `system_config` VALUES (2, 'site_name', 'ThinkAdmin');
INSERT INTO `system_config` VALUES (3, 'app_version', 'dev');
INSERT INTO `system_config` VALUES (4, 'site_copy', '©版权所有 2014-2018 楚才科技');
INSERT INTO `system_config` VALUES (5, 'site_icon', '/upload/decb0fe26fa3f486/b3f6521bf29403c8.png');
INSERT INTO `system_config` VALUES (7, 'miitbeian', '粤ICP备16006642号-2');
INSERT INTO `system_config` VALUES (8, 'storage_type', 'local');
INSERT INTO `system_config` VALUES (9, 'storage_local_exts', 'doc,gif,icon,jpg,mp3,mp4,p12,pem,png,rar');
INSERT INTO `system_config` VALUES (10, 'storage_qiniu_bucket', 'https');
INSERT INTO `system_config` VALUES (11, 'storage_qiniu_domain', '用你自己的吧');
INSERT INTO `system_config` VALUES (12, 'storage_qiniu_access_key', '用你自己的吧');
INSERT INTO `system_config` VALUES (13, 'storage_qiniu_secret_key', '用你自己的吧');
INSERT INTO `system_config` VALUES (14, 'storage_oss_bucket', 'cuci-mytest');
INSERT INTO `system_config` VALUES (15, 'storage_oss_endpoint', 'oss-cn-hangzhou.aliyuncs.com');
INSERT INTO `system_config` VALUES (16, 'storage_oss_domain', '用你自己的吧');
INSERT INTO `system_config` VALUES (17, 'storage_oss_keyid', '用你自己的吧');
INSERT INTO `system_config` VALUES (18, 'storage_oss_secret', '用你自己的吧');
INSERT INTO `system_config` VALUES (36, 'storage_oss_is_https', 'http');
INSERT INTO `system_config` VALUES (43, 'storage_qiniu_region', '华东');
INSERT INTO `system_config` VALUES (44, 'storage_qiniu_is_https', 'https');
INSERT INTO `system_config` VALUES (45, 'wechat_mch_id', '1332187001');
INSERT INTO `system_config` VALUES (46, 'wechat_mch_key', 'A82DC5BD1F3359081049C568D8502BC5');
INSERT INTO `system_config` VALUES (47, 'wechat_mch_ssl_type', 'p12');
INSERT INTO `system_config` VALUES (48, 'wechat_mch_ssl_p12', '65b8e4f56718182d/1bc857ee646aa15d.p12');
INSERT INTO `system_config` VALUES (49, 'wechat_mch_ssl_key', 'cc2e3e1345123930/c407d033294f283d.pem');
INSERT INTO `system_config` VALUES (50, 'wechat_mch_ssl_cer', '966eaf89299e9c95/7014872cc109b29a.pem');
INSERT INTO `system_config` VALUES (51, 'wechat_token', 'mytoken');
INSERT INTO `system_config` VALUES (52, 'wechat_appid', 'wx60a43dd8161666d4');
INSERT INTO `system_config` VALUES (53, 'wechat_appsecret', '9978422e0e431643d4b42868d183d60b');
INSERT INTO `system_config` VALUES (54, 'wechat_encodingaeskey', '');
INSERT INTO `system_config` VALUES (55, 'wechat_push_url', '消息推送地址http://127.0.0.1:8000/wechat/api.push');
INSERT INTO `system_config` VALUES (56, 'wechat_type', 'thr');
INSERT INTO `system_config` VALUES (57, 'wechat_thr_appid', 'wx60a43dd8161666d4');
INSERT INTO `system_config` VALUES (58, 'wechat_thr_appkey', '5caf4b0727f6e46a7e6ccbe773cc955d');
INSERT INTO `system_config` VALUES (60, 'wechat_thr_appurl', '消息推送地址http://127.0.0.1:2314/wechat/api.push');
INSERT INTO `system_config` VALUES (61, 'component_appid', 'wx28b58798480874f9');
INSERT INTO `system_config` VALUES (62, 'component_appsecret', '8d0e1ec14ea0adc5027dd0ad82c64bc9');
INSERT INTO `system_config` VALUES (63, 'component_token', 'P8QHTIxpBEq88IrxatqhgpBm2OAQROkI');
INSERT INTO `system_config` VALUES (64, 'component_encodingaeskey', 'L5uFIa0U6KLalPyXckyqoVIJYLhsfrg8k9YzybZIHsx');
INSERT INTO `system_config` VALUES (65, 'system_message_state', '0');
INSERT INTO `system_config` VALUES (66, 'sms_zt_username', '可以找CUCI申请');
INSERT INTO `system_config` VALUES (67, 'sms_zt_password', '可以找CUCI申请');
INSERT INTO `system_config` VALUES (68, 'sms_reg_template', '您的验证码为{code},请在十分钟内完成操作!');
INSERT INTO `system_config` VALUES (69, 'sms_secure', '可以找CUCI申请');
INSERT INTO `system_config` VALUES (70, 'store_title', '测试商城');
INSERT INTO `system_config` VALUES (71, 'store_order_wait_time', '0.50');
INSERT INTO `system_config` VALUES (72, 'store_order_clear_time', '24.00');
INSERT INTO `system_config` VALUES (73, 'store_order_confirm_time', '60.00');
INSERT INTO `system_config` VALUES (74, 'sms_zt_username2', '可以找CUCI申请2');
INSERT INTO `system_config` VALUES (75, 'sms_zt_password2', '可以找CUCI申请2');
INSERT INTO `system_config` VALUES (76, 'sms_secure2', '可以找CUCI申请2');
INSERT INTO `system_config` VALUES (77, 'sms_reg_template2', '您的验证码为{code}请在十分钟内完成操作2');
INSERT INTO `system_config` VALUES (78, 'michat_appid', '2882303761518074614');
INSERT INTO `system_config` VALUES (79, 'michat_appkey', '5861807470614');
INSERT INTO `system_config` VALUES (80, 'michat_appsecert', 'CP/WUTUgDuyOxgLQ5ztesg==');
-- ----------------------------
-- Table structure for system_data
-- ----------------------------
DROP TABLE IF EXISTS `system_data`;
CREATE TABLE `system_data` (
`id` bigint(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置名',
`value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '配置值',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_data_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-数据';
-- ----------------------------
-- Records of system_data
-- ----------------------------
INSERT INTO `system_data` VALUES (1, 'menudata', '[{\"name\":\"请输入名称\",\"type\":\"scancode_push\",\"key\":\"scancode_push\"}]');
-- ----------------------------
-- Table structure for system_log
-- ----------------------------
DROP TABLE IF EXISTS `system_log`;
CREATE TABLE `system_log` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`node` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '当前操作节点',
`geoip` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作者IP地址',
`action` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作行为名称',
`content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作内容描述',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作人用户名',
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-日志';
-- ----------------------------
-- Table structure for system_menu
-- ----------------------------
DROP TABLE IF EXISTS `system_menu`;
CREATE TABLE `system_menu` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`pid` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '父ID',
`title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '名称',
`node` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '节点代码',
`icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '菜单图标',
`url` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '链接',
`params` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '链接参数',
`target` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '_self' COMMENT '打开方式',
`sort` int(11) UNSIGNED NULL DEFAULT 0 COMMENT '菜单排序',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0:禁用,1:启用)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_menu_node`(`node`(191)) USING BTREE,
INDEX `idx_system_menu_status`(`status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 62 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-菜单';
-- ----------------------------
-- Records of system_menu
-- ----------------------------
INSERT INTO `system_menu` VALUES (1, 0, '后台首页', '', '', 'admin/index/main', '', '_self', 500, 1, '2018-09-05 17:59:38');
INSERT INTO `system_menu` VALUES (2, 0, '系统管理', '', '', '#', '', '_self', 100, 1, '2018-09-05 18:04:52');
INSERT INTO `system_menu` VALUES (3, 4, '系统菜单管理', '', 'layui-icon layui-icon-layouts', 'admin/menu/index', '', '_self', 1, 1, '2018-09-05 18:05:26');
INSERT INTO `system_menu` VALUES (4, 2, '系统配置', '', '', '#', '', '_self', 20, 1, '2018-09-05 18:07:17');
INSERT INTO `system_menu` VALUES (5, 12, '系统用户管理', '', 'layui-icon layui-icon-username', 'admin/user/index', '', '_self', 1, 1, '2018-09-06 11:10:42');
INSERT INTO `system_menu` VALUES (7, 12, '访问权限管理', '', 'layui-icon layui-icon-vercode', 'admin/auth/index', '', '_self', 2, 1, '2018-09-06 15:17:14');
INSERT INTO `system_menu` VALUES (11, 4, '系统参数配置', '', 'layui-icon layui-icon-set', 'admin/config/info', '', '_self', 4, 1, '2018-09-06 16:43:47');
INSERT INTO `system_menu` VALUES (12, 2, '权限管理', '', '', '#', '', '_self', 10, 1, '2018-09-06 18:01:31');
INSERT INTO `system_menu` VALUES (13, 0, '商城管理', '', '', '#', '', '_self', 400, 1, '2018-10-12 13:56:29');
INSERT INTO `system_menu` VALUES (14, 48, '商品信息管理', '', 'layui-icon layui-icon-component', 'store/goods/index', '', '_self', 3, 1, '2018-10-12 13:56:48');
INSERT INTO `system_menu` VALUES (16, 0, '微信管理', '', '', '#', '', '_self', 300, 1, '2018-10-31 15:15:27');
INSERT INTO `system_menu` VALUES (17, 16, '微信管理', '', '', '#', '', '_self', 20, 1, '2018-10-31 15:16:46');
INSERT INTO `system_menu` VALUES (18, 17, '微信授权配置', '', 'layui-icon layui-icon-set', 'wechat/config/options', '', '_self', 2, 1, '2018-10-31 15:17:11');
INSERT INTO `system_menu` VALUES (19, 17, '微信支付配置', '', 'layui-icon layui-icon-rmb', 'wechat/config/payment', '', '_self', 1, 1, '2018-10-31 18:28:09');
INSERT INTO `system_menu` VALUES (20, 16, '微信定制', '', '', '#', '', '_self', 10, 1, '2018-11-13 11:46:27');
INSERT INTO `system_menu` VALUES (21, 20, '图文素材管理', '', 'layui-icon layui-icon-template', 'wechat/news/index', '', '_self', 6, 1, '2018-11-13 11:46:55');
INSERT INTO `system_menu` VALUES (22, 20, '粉丝信息管理', '', 'layui-icon layui-icon-user', 'wechat/fans/index', '', '_self', 5, 1, '2018-11-15 09:51:13');
INSERT INTO `system_menu` VALUES (23, 20, '回复规则管理', '', 'layui-icon layui-icon-engine', 'wechat/keys/index', '', '_self', 4, 1, '2018-11-22 11:29:08');
INSERT INTO `system_menu` VALUES (24, 20, '关注回复配置', '', 'layui-icon layui-icon-senior', 'wechat/keys/subscribe', '', '_self', 3, 1, '2018-11-27 11:45:28');
INSERT INTO `system_menu` VALUES (25, 20, '默认回复配置', '', 'layui-icon layui-icon-survey', 'wechat/keys/defaults', '', '_self', 2, 1, '2018-11-27 11:45:58');
INSERT INTO `system_menu` VALUES (26, 20, '微信菜单管理', '', 'layui-icon layui-icon-cellphone', 'wechat/menu/index', '', '_self', 1, 1, '2018-11-27 17:56:56');
INSERT INTO `system_menu` VALUES (27, 4, '系统任务管理', '', 'layui-icon layui-icon-log', 'admin/queue/index', '', '_self', 3, 1, '2018-11-29 11:13:34');
INSERT INTO `system_menu` VALUES (37, 0, '开放平台', '', '', '#', '', '_self', 200, 1, '2018-12-28 13:29:25');
INSERT INTO `system_menu` VALUES (38, 40, '开放平台配置', '', 'layui-icon layui-icon-set', 'service/config/index', '', '_self', 0, 1, '2018-12-28 13:29:44');
INSERT INTO `system_menu` VALUES (39, 40, '公众授权管理', '', 'layui-icon layui-icon-template-1', 'service/index/index', '', '_self', 0, 1, '2018-12-28 13:30:07');
INSERT INTO `system_menu` VALUES (40, 37, '平台管理', '', '', '#', '', '_self', 0, 1, '2018-12-28 16:05:46');
INSERT INTO `system_menu` VALUES (42, 48, '会员信息管理', '', 'layui-icon layui-icon-user', 'store/member/index', '', '_self', 1, 1, '2019-01-22 14:24:23');
INSERT INTO `system_menu` VALUES (43, 48, '订单记录管理', '', 'layui-icon layui-icon-template-1', 'store/order/index', '', '_self', 2, 1, '2019-01-22 14:46:22');
INSERT INTO `system_menu` VALUES (44, 48, '商品分类管理', '', 'layui-icon layui-icon-app', 'store/goods_cate/index', '', '_self', 4, 1, '2019-01-23 10:41:06');
INSERT INTO `system_menu` VALUES (45, 47, '商城参数配置', '', 'layui-icon layui-icon-set', 'store/config/index', '', '_self', 5, 1, '2019-01-24 16:47:33');
INSERT INTO `system_menu` VALUES (46, 47, '短信发送记录', '', 'layui-icon layui-icon-console', 'store/message/index', '', '_self', 4, 1, '2019-01-24 18:09:58');
INSERT INTO `system_menu` VALUES (47, 13, '商城配置', '', '', '#', '', '_self', 20, 1, '2019-01-25 16:47:49');
INSERT INTO `system_menu` VALUES (48, 13, '数据管理', '', '', '#', '', '_self', 10, 1, '2019-01-25 16:48:35');
INSERT INTO `system_menu` VALUES (49, 4, '系统日志管理', '', 'layui-icon layui-icon-form', 'admin/oplog/index', '', '_self', 2, 1, '2019-02-18 12:56:56');
INSERT INTO `system_menu` VALUES (50, 47, '快递公司管理', '', 'layui-icon layui-icon-form', 'store/express_company/index', '', '_self', 3, 1, '2019-04-01 17:10:59');
INSERT INTO `system_menu` VALUES (52, 47, '邮费模板管理', '', 'layui-icon layui-icon-fonts-clear', 'store/express_template/index', '', '_self', 1, 1, '2019-04-23 13:17:10');
INSERT INTO `system_menu` VALUES (55, 17, '微信数据统计', '', 'layui-icon layui-icon-chart-screen', 'wechat/index/index', '', '_self', 3, 1, '2019-06-15 15:03:51');
INSERT INTO `system_menu` VALUES (56, 40, '微信粉丝管理', '', 'layui-icon layui-icon-username', 'service/fans/index', '', '_self', 0, 1, '2019-07-23 09:57:24');
INSERT INTO `system_menu` VALUES (57, 0, '企业管理', '', '', '#', '', '_self', 150, 1, '2019-08-08 17:20:29');
INSERT INTO `system_menu` VALUES (58, 57, '基础管理', '', '', '#', '', '_self', 0, 1, '2019-08-08 17:20:42');
INSERT INTO `system_menu` VALUES (59, 58, '企业员工管理', '', 'layui-icon layui-icon-username', 'company/user/index', '', '_self', 0, 1, '2019-08-08 17:20:59');
INSERT INTO `system_menu` VALUES (60, 58, '仓库权限管理', '', 'layui-icon layui-icon-template-1', 'company/auth/index', '', '_self', 0, 1, '2019-08-08 18:39:37');
INSERT INTO `system_menu` VALUES (61, 58, '网络打卡管理', '', 'layui-icon layui-icon-engine', 'company/clock/index', '', '_self', 0, 1, '2019-08-09 14:44:23');
-- ----------------------------
-- Table structure for system_queue
-- ----------------------------
DROP TABLE IF EXISTS `system_queue`;
CREATE TABLE `system_queue` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务名称',
`data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '执行参数',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '任务状态(1新任务,2处理中,3成功,4失败)',
`preload` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '执行内容',
`time` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行时间',
`double` tinyint(1) NULL DEFAULT 1 COMMENT '单例模式',
`desc` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '状态描述',
`start_at` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '开始时间',
`end_at` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '结束时间',
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_queue_double`(`double`) USING BTREE,
INDEX `idx_system_queue_time`(`time`) USING BTREE,
INDEX `idx_system_queue_title`(`title`) USING BTREE,
INDEX `idx_system_queue_create_at`(`create_at`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-任务';
-- ----------------------------
-- Table structure for system_user
-- ----------------------------
DROP TABLE IF EXISTS `system_user`;
CREATE TABLE `system_user` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户账号',
`password` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户密码',
`qq` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系QQ',
`mail` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系邮箱',
`phone` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '联系手机',
`login_at` datetime NULL DEFAULT NULL COMMENT '登录时间',
`login_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '登录IP',
`login_num` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '登录次数',
`authorize` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '权限授权',
`tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户标签',
`desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注说明',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1启用)',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除(1删除,0未删)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_user_username`(`username`) USING BTREE,
INDEX `idx_system_user_status`(`status`) USING BTREE,
INDEX `idx_system_user_deleted`(`is_deleted`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统-用户';
-- ----------------------------
-- Records of system_user
-- ----------------------------
INSERT INTO `system_user` VALUES (10000, 'admin', '21232f297a57a5a743894a0e4a801fc3', '22222222', '', '', '2019-08-18 18:34:14', '127.0.0.1', 661, '', '', '', 1, 0, '2015-11-13 15:14:22');
-- ----------------------------
-- Table structure for wechat_fans
-- ----------------------------
DROP TABLE IF EXISTS `wechat_fans`;
CREATE TABLE `wechat_fans` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`appid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号APPID',
`unionid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '粉丝unionid',
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '粉丝openid',
`tagid_list` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '粉丝标签id',
`is_black` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '是否为黑名单状态',
`subscribe` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '关注状态(0未关注,1已关注)',
`nickname` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户昵称',
`sex` tinyint(1) UNSIGNED NULL DEFAULT NULL COMMENT '用户性别(1男性,2女性,0未知)',
`country` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户所在国家',
`province` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户所在省份',
`city` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户所在城市',
`language` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户的语言(zh_CN)',
`headimgurl` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户头像',
`subscribe_time` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '关注时间',
`subscribe_at` datetime NULL DEFAULT NULL COMMENT '关注时间',
`remark` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
`subscribe_scene` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '扫码关注场景',
`qr_scene` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '二维码场景值',
`qr_scene_str` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '二维码场景内容',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_fans_openid`(`openid`) USING BTREE,
INDEX `idx_wechat_fans_unionid`(`unionid`) USING BTREE,
INDEX `idx_wechat_fans_is_back`(`is_black`) USING BTREE,
INDEX `idx_wechat_fans_subscribe`(`subscribe`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-粉丝';
-- ----------------------------
-- Table structure for wechat_fans_tags
-- ----------------------------
DROP TABLE IF EXISTS `wechat_fans_tags`;
CREATE TABLE `wechat_fans_tags` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '标签ID',
`appid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号APPID',
`name` varchar(35) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标签名称',
`count` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '总数',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建日期',
INDEX `idx_wechat_fans_tags_id`(`id`) USING BTREE,
INDEX `idx_wechat_fans_tags_appid`(`appid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-粉丝-标签';
-- ----------------------------
-- Table structure for wechat_keys
-- ----------------------------
DROP TABLE IF EXISTS `wechat_keys`;
CREATE TABLE `wechat_keys` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`appid` char(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号APPID',
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '类型(text,image,news)',
`keys` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关键字',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '文本内容',
`image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '图片链接',
`voice_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '语音链接',
`music_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '音乐标题',
`music_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '音乐链接',
`music_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '缩略图片',
`music_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '音乐描述',
`video_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '视频标题',
`video_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '视频URL',
`video_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '视频描述',
`news_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '图文ID',
`sort` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '排序字段',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1启用)',
`create_by` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '创建人',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_keys_appid`(`appid`) USING BTREE,
INDEX `idx_wechat_keys_type`(`type`) USING BTREE,
INDEX `idx_wechat_keys_keys`(`keys`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-关键字';
-- ----------------------------
-- Table structure for wechat_media
-- ----------------------------
DROP TABLE IF EXISTS `wechat_media`;
CREATE TABLE `wechat_media` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`appid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号ID',
`md5` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文件md5',
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '媒体类型',
`media_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '永久素材MediaID',
`local_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '本地文件链接',
`media_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '远程图片链接',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_media_appid`(`appid`) USING BTREE,
INDEX `idx_wechat_media_md5`(`md5`) USING BTREE,
INDEX `idx_wechat_media_type`(`type`) USING BTREE,
INDEX `idx_wechat_media_media_id`(`media_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-素材';
-- ----------------------------
-- Table structure for wechat_news
-- ----------------------------
DROP TABLE IF EXISTS `wechat_news`;
CREATE TABLE `wechat_news` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`media_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '永久素材MediaID',
`local_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '永久素材显示URL',
`article_id` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '关联图文ID(用英文逗号做分割)',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '是否删除',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_news_artcle_id`(`article_id`) USING BTREE,
INDEX `idx_wechat_news_media_id`(`media_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-图文';
-- ----------------------------
-- Table structure for wechat_news_article
-- ----------------------------
DROP TABLE IF EXISTS `wechat_news_article`;
CREATE TABLE `wechat_news_article` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '素材标题',
`local_url` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '永久素材显示URL',
`show_cover_pic` tinyint(4) UNSIGNED NULL DEFAULT 0 COMMENT '显示封面(0不显示,1显示)',
`author` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '文章作者',
`digest` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '摘要内容',
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '图文内容',
`content_source_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '原文地址',
`read_num` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '阅读数量',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-图文-文章';
-- ----------------------------
-- Table structure for wechat_service_config
-- ----------------------------
DROP TABLE IF EXISTS `wechat_service_config`;
CREATE TABLE `wechat_service_config` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`authorizer_appid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号APPID',
`authorizer_access_token` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号授权Token',
`authorizer_refresh_token` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号刷新Token',
`func_info` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号集权',
`nick_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号昵称',
`head_img` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号头像',
`expires_in` bigint(20) NULL DEFAULT NULL COMMENT 'Token有效时间',
`service_type` tinyint(2) NULL DEFAULT NULL COMMENT '微信类型(0代表订阅号,2代表服务号,3代表小程序)',
`service_type_info` tinyint(2) NULL DEFAULT NULL COMMENT '公众号实际类型',
`verify_type` tinyint(2) NULL DEFAULT NULL COMMENT '公众号认证类型(-1代表未认证, 0代表微信认证)',
`verify_type_info` tinyint(2) NULL DEFAULT NULL COMMENT '公众号实际认证类型',
`user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '众众号原始账号',
`alias` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号别名',
`qrcode_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公众号二维码',
`business_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`principal_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '公司名称',
`miniprograminfo` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '小程序JSON',
`idc` tinyint(1) UNSIGNED NULL DEFAULT NULL,
`signature` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '小程序的描述',
`total` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '统计调用次数',
`appkey` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '应用接口KEY',
`appuri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '应用接口URI',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(1正常授权,0取消授权)',
`is_deleted` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态(0未删除,1已删除)',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `idx_wechat_service_config_authorizer_appid`(`authorizer_appid`) USING BTREE,
INDEX `idx_wechat_service_config_status`(`status`) USING BTREE,
INDEX `idx_wechat_service_config_is_deleted`(`is_deleted`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微信-授权';
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -0,0 +1,147 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\AuthService;
use app\admin\service\MenuService;
use app\admin\service\NodeService;
use think\admin\Controller;
use think\Db;
/**
* 系统权限管理
* Class Auth
* @package app\admin\controller
*/
class Auth extends Controller
{
/**
* 绑定数据表
* @var string
*/
public $table = 'SystemAuth';
/**
* 系统权限管理
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->title = '系统权限管理';
$query = $this->_query($this->table)->dateBetween('create_at');
$query->like('title,desc')->equal('status')->order('sort desc,id desc')->page();
}
/**
* 添加系统权限
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function add()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 编辑系统权限
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 修改系统权限状态
* @auth true
* @throws \think\db\exception\DbException
*/
public function state()
{
$this->_applyFormToken();
$this->_save($this->table, ['status' => input('status')]);
}
/**
* 删除系统权限
* @auth true
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->_applyFormToken();
$this->_delete($this->table);
}
/**
* 权限配置节点
* @auth true
* @return mixed
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function apply()
{
$map = ['auth' => input('id', '0')];
$action = strtolower(input('action', ''));
if ($action === 'get') {
$checkeds = $this->app->db->name('SystemAuthNode')->where($map)->column('node');
$this->success('获取权限节点成功!', AuthService::getTree($checkeds));
} elseif ($action === 'save') {
list($post, $data) = [$this->request->post(), []];
foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) {
$data[] = ['auth' => $map['auth'], 'node' => $node];
}
$this->app->db->name('SystemAuthNode')->where($map)->delete();
$this->app->db->name('SystemAuthNode')->insertAll($data);
AuthService::apply(true);
$this->success('权限授权更新成功!', 'javascript:history.back()');
} else {
$this->title = '权限配置节点';
$this->_form($this->table, 'apply');
}
}
/**
* 删除结果处理
* @param boolean $result
* @throws \think\db\exception\DbException
*/
protected function _remove_delete_result($result)
{
if ($result) {
$map = ['auth' => $this->request->post('id')];
$this->app->db->name('SystemAuthNode')->where($map)->delete();
$this->success("权限删除成功!", '');
} else {
$this->error("权限删除失败,请稍候再试!");
}
}
}

View File

@ -0,0 +1,89 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\admin\Controller;
/**
* 系统参数配置
* Class Config
* @package app\admin\controller
*/
class Config extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'SystemConfig';
/**
* 绑定数据表
* @auth true
* @menu true
*/
public function index()
{
$this->title = '系统参数配置';
$this->fetch();
}
/**
* 修改系统能数配置
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function config()
{
$this->_applyFormToken();
if ($this->request->isGet()) {
$this->title = '系统参数配置';
$this->fetch();
}
foreach ($this->request->post() as $key => $value) {
sysconf($key, $value);
}
$this->success('系统参数配置成功!');
}
/**
* 文件存储引擎
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function storage()
{
$this->_applyFormToken();
if ($this->request->isGet()) {
$this->type = input('type', 'local');
$this->fetch("storage-{$this->type}");
}
$post = $this->request->post();
if (!empty($post['storage']['allow_exts'])) {
$exts = array_unique(explode(',', strtolower($post['storage']['allow_exts'])));
sort($exts);
if (in_array('php', $exts)) $this->error('禁止上传可执行文件到本地服务器!');
$post['storage']['allow_exts'] = join(',', $exts);
}
foreach ($post as $key => $value) sysconf($key, $value);
$this->success('文件存储配置成功!');
}
}

View File

@ -0,0 +1,122 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\AuthService;
use app\admin\service\MenuService;
use think\admin\Controller;
use think\admin\extend\DataExtend;
/**
* 后台界面入口
* Class Index
* @package app\admin\controller
*/
class Index extends Controller
{
/**
* 显示后台首页
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->title = '系统管理后台';
AuthService::apply(true);
$this->menus = MenuService::getTree();
if (empty($this->menus) && !AuthService::isLogin()) {
$this->redirect(url('@admin/login'));
} else {
$this->fetch();
}
}
/**
* 后台环境信息
*/
public function main()
{
$this->think_ver = $this->app->version();
$this->mysql_ver = $this->app->db->query('select version() as ver')[0]['ver'];
$this->fetch();
}
/**
* 修改用户资料
* @param integer $id 会员ID
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function info($id = 0)
{
if (!AuthService::isLogin()) {
$this->error('需要登录才能操作哦!');
}
$this->_applyFormToken();
if (intval($this->app->session->get('user.id')) === intval($id)) {
$this->_form('SystemUser', 'admin@user/form', 'id', [], ['id' => $id]);
} else {
$this->error('只能修改登录用户的资料!');
}
}
/**
* 修改当前用户密码
* @param integer $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function pass($id = 0)
{
if (!AuthService::isLogin()) {
$this->error('需要登录才能操作哦!');
}
$this->_applyFormToken();
if (intval($this->app->session->get('user.id')) !== intval($id)) {
$this->error('只能修改当前用户的密码!');
}
if ($this->app->request->isGet()) {
$this->verify = true;
$this->_form('SystemUser', 'admin@user/pass', 'id', [], ['id' => $id]);
} else {
$data = [
'password' => $this->app->request->post('password'),
'repassword' => $this->app->request->post('repassword'),
'oldpassword' => $this->app->request->post('oldpassword'),
];
if (empty($data['password'])) $this->error('登录密码不能为空!');
if (empty($data['oldpassword'])) $this->error('旧密码不能为空!');
if ($data['repassword'] !== $data['password']) {
$this->error('重复密码与登录密码不匹配,请重新输入!');
}
$user = $this->app->db->name('SystemUser')->where(['id' => $id])->find();
if (md5($data['oldpassword']) !== $user['password']) {
$this->error('旧密码验证失败,请重新输入!');
}
if (DataExtend::save('SystemUser', ['id' => $user['id'], 'password' => md5($data['password'])])) {
$this->success('密码修改成功,下次请使用新密码登录!', '');
} else {
$this->error('密码修改失败,请稍候再试!');
}
}
}
}

View File

@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\AuthService;
use think\admin\Controller;
use think\admin\extend\CaptchaExtend;
/**
* 用户登录管理
* Class Login
* @package app\admin\controller
*/
class Login extends Controller
{
/**
* 后台登录入口
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
if ($this->app->request->isGet()) {
if (AuthService::isLogin()) {
$this->redirect(url('@admin')->suffix(false)->build());
} else {
$this->title = '系统登录';
$this->domain = $this->app->request->host(true);
$this->devmode = in_array($this->domain, ['127.0.0.1', 'localhost']);
$this->devmode = $this->devmode ?: is_numeric(stripos($this->domain, 'thinkadmin.top'));
$this->captcha = CaptchaExtend::instance();
$this->fetch();
}
} elseif ($this->app->request->isPost()) {
$data = ['username' => input('username'), 'password' => input('password')];
if (empty($data['username'])) $this->error('登录账号不能为空!');
if (empty($data['password'])) $this->error('登录密码不能为空!');
if (!CaptchaExtend::check(input('verify'), input('uniqid'))) {
$this->error('图形验证码验证失败,请重新输入!');
}
// 用户信息验证
$map = ['username' => $data['username'], 'is_deleted' => '0'];
$user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
if (empty($user)) {
$this->error('登录账号或密码错误,请重新输入!');
}
if (md5("{$user['password']}{$user['username']}") !== $data['password']) {
$this->error('登录账号或密码错误,请重新输入!');
}
if (empty($user['status'])) {
$this->error('账号已经被禁用,请联系管理员!');
}
$this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
'login_ip' => $this->app->request->ip(),
'login_at' => $this->app->db->raw('now()'),
'login_num' => $this->app->db->raw('login_num+1'),
]);
$this->app->session->set('user', $user);
sysoplog('用户登录', "用户登录系统后台成功");
$this->success('登录成功', url('@admin')->build());
}
}
/**
* 生成验证码
*/
public function captcha()
{
$image = CaptchaExtend::instance();
$this->success('生成验证码成功', [
'image' => $image->getData(),
'uniqid' => $image->getUniqid(),
]);
}
/**
* 退出登录
*/
public function out()
{
$this->app->session->clear();
$this->app->session->destroy();
$this->success('退出登录成功!', url('@admin/login')->build());
}
}

View File

@ -15,10 +15,9 @@
namespace app\admin\controller;
use app\admin\service\NodeService;
use library\Controller;
use library\tools\Data;
use think\Db;
use app\admin\service\MenuService;
use think\admin\Controller;
use think\admin\extend\DataExtend;
/**
* 系统菜单管理
@ -27,7 +26,6 @@ use think\Db;
*/
class Menu extends Controller
{
/**
* 当前操作数据库
* @var string
@ -38,11 +36,9 @@ class Menu extends Controller
* 系统菜单管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
@ -60,38 +56,34 @@ class Menu extends Controller
if ($vo['url'] !== '#') {
$vo['url'] = url($vo['url']) . (empty($vo['params']) ? '' : "?{$vo['params']}");
}
$vo['ids'] = join(',', Data::getArrSubIds($data, $vo['id']));
$vo['ids'] = join(',', DataExtend::getArrSubIds($data, $vo['id']));
}
$data = Data::arr2table($data);
$data = DataExtend::arr2table($data);
}
/**
* 添加系统菜单
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 编辑系统菜单
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
@ -100,15 +92,15 @@ class Menu extends Controller
* @param array $vo
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function _form_filter(&$vo)
{
if ($this->request->isGet()) {
$menus = Db::name($this->table)->where(['status' => '1'])->order('sort desc,id asc')->select();
$menus = $this->app->db->name($this->table)->where(['status' => '1'])->order('sort desc,id asc')->select()->toArray();
$menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
foreach ($this->menus = Data::arr2table($menus) as $key => &$menu) {
foreach ($this->menus = DataExtend::arr2table($menus) as $key => &$menu) {
if (substr_count($menu['path'], '-') > 3) unset($this->menus[$key]); # 移除三级以下的菜单
elseif (isset($vo['pid']) && $vo['pid'] !== '' && $cur = "-{$vo['pid']}-{$vo['id']}") {
if (stripos("{$menu['path']}-", "{$cur}-") !== false || $menu['path'] === $cur) unset($this->menus[$key]); # 移除与自己相关联的菜单
@ -119,44 +111,29 @@ class Menu extends Controller
$vo['pid'] = $this->request->get('pid', '0');
}
// 读取系统功能节点
$this->nodes = NodeService::getMenuNodeList();
$this->nodes = MenuService::getList();
}
}
/**
* 启用系统菜单
* 修改系统菜单状态
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function resume()
public function state()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '1']);
}
/**
* 禁用系统菜单
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '0']);
$this->_applyFormToken();
$this->_save($this->table, ['status' => intval(input('status'))]);
}
/**
* 删除系统菜单
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_delete($this->table);
}
}
}

View File

@ -15,7 +15,7 @@
namespace app\admin\controller;
use library\Controller;
use think\admin\Controller;
use think\Db;
/**
@ -27,23 +27,22 @@ class Oplog extends Controller
{
/**
* 指定当前数据表
* 绑定数据表
* @var string
*/
public $table = 'SystemLog';
public $table = 'SystemOplog';
/**
* 系统操作日志
* 系统日志管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->title = '系统操作日志';
$this->title = '系统日志管理';
$query = $this->_query($this->table)->like('action,node,content,username,geoip');
$query->dateBetween('create_at')->order('id desc')->page();
}
@ -67,12 +66,11 @@ class Oplog extends Controller
/**
* 清理系统日志
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function clear()
{
if (Db::name($this->table)->whereRaw('1=1')->delete() !== false) {
if ($this->app->db->name($this->table)->whereRaw('1=1')->delete() !== false) {
$this->success('日志清理成功!');
} else {
$this->error('日志清理失败,请稍候再试!');
@ -82,13 +80,11 @@ class Oplog extends Controller
/**
* 删除系统日志
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_delete($this->table);
}
}
}

View File

@ -15,12 +15,12 @@
namespace app\admin\controller;
use library\Controller;
use think\Console;
use think\admin\Controller;
use think\admin\extend\ProcessExtend;
use think\exception\HttpResponseException;
/**
* 系统系统任务
* 系统任务管理
* Class Queue
* @package app\admin\controller
*/
@ -33,22 +33,22 @@ class Queue extends Controller
protected $table = 'SystemQueue';
/**
* 系统系统任务
* 系统任务管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
if (session('admin_user.username') === 'admin') try {
$this->cmd = 'php ' . env('root_path') . 'think xtask:start';
$this->message = Console::call('xtask:state')->fetch();
} catch (\Exception $exception) {
$this->message = $exception->getMessage();
if ($this->app->session->get('user.username') === 'admin') {
try {
$this->command = ProcessExtend::think('xtask:start');
$this->message = $this->app->console->call('xtask:state')->fetch();
} catch (\Exception $exception) {
$this->message = $exception->getMessage();
}
}
$this->title = '系统任务管理';
$this->iswin = PATH_SEPARATOR === ';';
@ -59,8 +59,7 @@ class Queue extends Controller
/**
* 重启系统任务
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function redo()
{
@ -71,10 +70,10 @@ class Queue extends Controller
* (WIN)创建任务监听进程
* @auth true
*/
public function processStart()
public function start()
{
try {
$this->success(nl2br(Console::call('xtask:start')->fetch()));
$this->success(nl2br($this->app->console->call('xtask:start')->fetch()));
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
@ -86,10 +85,10 @@ class Queue extends Controller
* (WIN)停止任务监听进程
* @auth true
*/
public function processStop()
public function stop()
{
try {
$this->success(nl2br(Console::call('xtask:stop')->fetch()));
$this->success(nl2br($this->app->console->call('xtask:stop')->fetch()));
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
@ -97,15 +96,15 @@ class Queue extends Controller
}
}
/**
* 删除系统任务
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->_delete($this->table);
}
}
}

View File

@ -15,10 +15,9 @@
namespace app\admin\controller;
use app\admin\service\NodeService;
use library\Controller;
use library\tools\Data;
use think\Db;
use app\admin\service\AuthService;
use think\admin\Controller;
use think\admin\extend\DataExtend;
/**
* 系统用户管理
@ -29,7 +28,7 @@ class User extends Controller
{
/**
* 指定当前数据表
* 绑定数据表
* @var string
*/
public $table = 'SystemUser';
@ -38,11 +37,9 @@ class User extends Controller
* 系统用户管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
@ -54,42 +51,39 @@ class User extends Controller
/**
* 添加系统用户
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 编辑系统用户
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 修改用户密码
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function pass()
{
$this->applyCsrfToken();
$this->_applyFormToken();
if ($this->request->isGet()) {
$this->verify = false;
$this->_form($this->table, 'pass');
@ -98,9 +92,7 @@ class User extends Controller
if ($post['password'] !== $post['repassword']) {
$this->error('两次输入的密码不一致!');
}
$result = NodeService::checkpwd($post['password']);
if (empty($result['code'])) $this->error($result['msg']);
if (Data::save($this->table, ['id' => $post['id'], 'password' => md5($post['password'])], 'id')) {
if (DataExtend::save($this->table, ['id' => $post['id'], 'password' => md5($post['password'])], 'id')) {
$this->success('密码修改成功,下次请使用新密码登录!', '');
} else {
$this->error('密码修改失败,请稍候再试!');
@ -112,67 +104,52 @@ class User extends Controller
* 表单数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _form_filter(&$data)
protected function _form_filter(&$data)
{
if ($this->request->isPost()) {
// 刷新系统授权
NodeService::applyUserAuth();
AuthService::apply();
// 用户权限处理
$data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : '';
// 用户账号重复检查
if (isset($data['id'])) unset($data['username']);
elseif (Db::name($this->table)->where(['username' => $data['username'], 'is_deleted' => '0'])->count() > 0) {
elseif ($this->app->db->name($this->table)->where(['username' => $data['username'], 'is_deleted' => '0'])->count() > 0) {
$this->error("账号{$data['username']}已经存在,请使用其它账号!");
}
} else {
$data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');
$this->authorizes = Db::name('SystemAuth')->where(['status' => '1'])->order('sort desc,id desc')->select();
$this->authorizes = $this->app->db->name('SystemAuth')->where(['status' => '1'])->order('sort desc,id desc')->select();
}
}
/**
* 禁用系统用户
* 修改系统用户状态
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function forbid()
public function state()
{
if (in_array('10000', explode(',', $this->request->post('id')))) {
$this->error('系统超级账号禁止操作!');
}
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用系统用户
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '1']);
$this->_applyFormToken();
$this->_save($this->table, ['status' => intval(input('status'))]);
}
/**
* 删除系统用户
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DbException
*/
public function remove()
{
if (in_array('10000', explode(',', $this->request->post('id')))) {
$this->error('系统超级账号禁止删除!');
}
$this->applyCsrfToken();
$this->_applyFormToken();
$this->_delete($this->table);
}
}
}

View File

@ -15,9 +15,9 @@
namespace app\admin\controller\api;
use app\admin\service\NodeService;
use library\Controller;
use library\File;
use app\admin\service\AuthService;
use think\admin\Controller;
use think\admin\Storage;
/**
* 后台插件管理
@ -40,16 +40,18 @@ class Plugs extends Controller
/**
* 获取文件上传参数
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function check()
{
$diff1 = explode(',', strtolower(input('exts', '')));
$diff2 = explode(',', strtolower(sysconf('storage_local_exts')));
$diff2 = explode(',', strtolower(sysconf('storage.allow_exts')));
$exts = array_intersect($diff1, $diff2);
$this->success('获取文件上传参数', [
'exts' => join('|', $exts),
'mime' => File::mine($exts),
'mine' => Storage::mime($exts),
'type' => $this->getUploadType(),
'data' => $this->getUploadData(),
]);
@ -59,27 +61,29 @@ class Plugs extends Controller
* 后台通用文件上传
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function upload()
{
if (!NodeService::islogin()) {
if (!AuthService::isLogin()) {
$this->error('访问授权失败,请重新登录授权再试!');
}
if (!($file = $this->getUploadFile()) || empty($file)) {
return json(['uploaded' => false, 'error' => ['message' => '文件上传异常,文件可能过大或未上传']]);
}
if (!$file->checkExt(strtolower(sysconf('storage_local_exts')))) {
$this->extension = $file->getOriginalExtension();
if (!in_array($this->extension, explode(',', sysconf('storage.allow_exts')))) {
return json(['uploaded' => false, 'error' => ['message' => '文件上传类型受限,请在后台配置']]);
}
if ($file->checkExt('php,sh')) {
if (in_array($this->extension, ['php', 'sh'])) {
return json(['uploaded' => false, 'error' => ['message' => '可执行文件禁止上传到本地服务器']]);
}
$this->safe = boolval(input('safe'));
$this->uptype = $this->getUploadType();
$this->extend = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
$name = File::name($file->getPathname(), $this->extend, '', 'md5_file');
$info = File::instance($this->uptype)->save($name, file_get_contents($file->getRealPath()), $this->safe);
$name = Storage::name($file->getPathname(), $this->extension, '', 'md5_file');
$info = Storage::instance($this->uptype)->set($name, file_get_contents($file->getRealPath()), $this->safe);
if (is_array($info) && isset($info['url'])) {
return json(['uploaded' => true, 'filename' => $name, 'url' => $this->safe ? $name : $info['url']]);
} else {
@ -91,12 +95,15 @@ class Plugs extends Controller
* 生成文件上传参数
* @return array
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
private function getUploadData()
{
if ($this->getUploadType() === 'qiniu') {
$file = File::instance('qiniu');
return ['url' => $file->upload(true), 'token' => $file->buildUploadToken(), 'uptype' => $this->getUploadType()];
$file = Storage::instance('qiniu');
return ['url' => $file->upload(), 'token' => $file->buildUploadToken(), 'uptype' => $this->getUploadType()];
} else {
return ['url' => '?s=admin/api.plugs/upload', 'token' => uniqid('local_upload_'), 'uptype' => $this->getUploadType()];
}
@ -105,21 +112,22 @@ class Plugs extends Controller
/**
* 获取文件上传方式
* @return string
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
private function getUploadType()
{
$this->uptype = input('uptype');
if (!in_array($this->uptype, ['local', 'oss', 'qiniu'])) {
$this->uptype = sysconf('storage_type');
$this->uptype = sysconf('storage.type');
}
return $this->uptype;
}
/**
* 获取本地文件对象
* @return \think\File
* @return \think\file\UploadedFile
*/
private function getUploadFile()
{

View File

@ -15,8 +15,7 @@
namespace app\admin\controller\api;
use library\command\Sync;
use library\Controller;
use think\admin\Controller;
/**
* 系统更新接口

View File

@ -0,0 +1,107 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\service;
use library\tools\Data;
use think\admin\extend\DataExtend;
use think\admin\extend\NodeExtend;
/**
* 系统授权服务
* Class MenuService
* @package app\admin\service
*/
class AuthService
{
/**
* 判断是否已经登录
* @return boolean
*/
public static function isLogin()
{
return app()->session->get('user.id') ? true : false;
}
/**
* 检查指定节点授权
* --- 需要读取缓存或扫描所有节点
* @param string $node
* @return boolean
* @throws \ReflectionException
*/
public static function check($node = '')
{
if (app()->session->get('user.username') === 'admin') return true;
list($real, $nodes) = [NodeExtend::fullnode($node), NodeExtend::getMethods()];
if (!empty($nodes[$real]['isauth'])) {
return in_array($real, app()->session->get('user.nodes', []));
}
return !(!empty($nodes[$real]['islogin']) && !self::isLogin());
}
/**
* 获取授权节点列表
* @param array $checkeds
* @return array
* @throws \ReflectionException
*/
public static function getTree($checkeds = [])
{
list($nodes, $pnodes, $methods) = [[], [], array_reverse(NodeExtend::getMethods())];
foreach ($methods as $node => $method) {
$count = substr_count($node, '/');
$pnode = substr($node, 0, strripos($node, '/'));
if ($count === 2 && !empty($method['isauth'])) {
in_array($pnode, $pnodes) or array_push($pnodes, $pnode);
$nodes[$node] = ['node' => $node, 'title' => $method['title'], 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)];
} elseif ($count === 1 && in_array($pnode, $pnodes)) {
$nodes[$node] = ['node' => $node, 'title' => $method['title'], 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)];
}
}
foreach (array_keys($nodes) as $key) foreach ($methods as $node => $method) if (stripos($key, "{$node}/") !== false) {
$pnode = substr($node, 0, strripos($node, '/'));
$nodes[$node] = ['node' => $node, 'title' => $method['title'], 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)];
$nodes[$pnode] = ['node' => $pnode, 'title' => ucfirst($pnode), 'pnode' => '', 'checked' => in_array($pnode, $checkeds)];
}
return DataExtend::arr2tree(array_reverse($nodes), 'node', 'pnode', '_sub_');
}
/**
* 初始化用户权限
* @param boolean $force 是否重置系统权限
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function apply($force = false)
{
$app = app();
if ($force) $app->cache->delete('system_auth_node');
if (($uid = $app->session->get('user.id'))) {
$user = $app->db->name('SystemUser')->where(['id' => $uid])->find();
if (($aids = $user['authorize'])) {
$where = [['status', 'eq', '1'], ['id', 'in', explode(',', $aids)]];
$subsql = $app->db->name('SystemAuth')->field('id')->where($where)->buildSql();
$user['nodes'] = array_unique($app->db->name('SystemAuthNode')->whereRaw("auth in {$subsql}")->column('node'));
$app->session->set('user', $user);
} else {
$user['nodes'] = [];
$app->session->set('user', $user);
}
}
}
}

View File

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\service;
use think\admin\extend\DataExtend;
use think\admin\extend\NodeExtend;
/**
* 系统菜单服务
* Class MenuService
* @package app\admin\service
*/
class MenuService
{
/**
* 获取可选菜单节点
* @return array
* @throws \ReflectionException
*/
public static function getList()
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
foreach (NodeExtend::getMethods() as $node => $method) if ($method['ismenu']) {
$nodes[] = ['node' => $node, 'title' => $method['title']];
}
return $nodes;
}
/**
* 获取系统菜单树数据
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getTree()
{
$result = app()->db->name('SystemMenu')->where(['status' => '1'])->order('sort desc,id asc')->select();
return self::buildData(DataExtend::arr2tree($result->toArray()), NodeExtend::getMethods());
}
/**
* 后台主菜单权限过滤
* @param array $menus 当前菜单列表
* @param array $nodes 系统权限节点
* @return array
* @throws \ReflectionException
*/
private static function buildData($menus, $nodes)
{
foreach ($menus as $key => &$menu) {
if (!empty($menu['sub'])) {
$menu['sub'] = self::buildData($menu['sub'], $nodes);
}
if (!empty($menu['sub'])) $menu['url'] = '#';
elseif ($menu['url'] === '#') unset($menus[$key]);
elseif (preg_match('|^https?://|i', $menu['url'])) continue;
else {
$node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3));
$menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}");
if (!AuthService::check($node)) unset($menus[$key]);
}
}
return $menus;
}
}

68
app/admin/sys.php Normal file
View File

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use app\admin\service\AuthService;
use think\admin\extend\NodeExtend;
if (!function_exists('auth')) {
/**
* 访问权限检查
* @param string $node
* @return boolean
* @throws ReflectionException
*/
function auth($node)
{
return AuthService::check($node);
}
}
if (!function_exists('sysdata')) {
/**
* JSON 数据读取与存储
* @param string $name 数据名称
* @param array|null $value 数据内容
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
function sysdata($name, array $value = null)
{
if (is_null($value)) {
$data = json_decode(app()->db->name('SystemData')->where(['name' => $name])->value('value'), true);
return empty($data) ? [] : $data;
} else {
return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, JSON_UNESCAPED_UNICODE)], 'name');
}
}
}
if (!function_exists('sysoplog')) {
/**
* 写入系统日志
* @param string $action 日志行为
* @param string $content 日志内容
* @return boolean
*/
function sysoplog($action, $content)
{
return app()->db->name('SystemOplog')->insert([
'node' => NodeExtend::getCurrent(),
'action' => $action, 'content' => $content,
'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : app()->request->ip(),
'username' => PHP_SAPI === 'cli' ? 'cli' : app()->session->get('user.username'),
]);
}
}

View File

@ -42,8 +42,8 @@
});
return childrens;
};
this.getData = function (that) {
var index = $.msg.loading();
this.getData = function (that, index) {
index = $.msg.loading();
$.form.load('{:url()}', {id: '{$vo.id}', action: 'get'}, 'post', function (ret) {
that.data = that.renderChildren(ret.data, 1);
return $.msg.close(index), that.showTree(), false;

View File

@ -4,13 +4,13 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">权限名称</label>
<div class="layui-input-inline">
<input name="title" value="{$Think.get.title|default=''}" placeholder="请输入权限名称" class="layui-input">
<input name="title" value="{:input('get.title')}" placeholder="请输入权限名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">权限描述</label>
<div class="layui-input-inline">
<input name="desc" value="{$Think.get.desc|default=''}" placeholder="请输入权限描述" class="layui-input">
<input name="desc" value="{:input('get.desc')}" placeholder="请输入权限描述" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
@ -18,11 +18,11 @@
<div class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'-- 全部状态 --','0'=>'已禁用的权限','1'=>'使用中的权限'] as $k=>$v}
{eq name='Think.get.status' value='$k.""'}
{if input('get.status') eq $k.""}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/if}
{/foreach}
</select>
</div>
@ -30,7 +30,7 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择创建时间" class="layui-input">
<input data-date-range name="create_at" value="{:input('get.create_at')}" placeholder="请选择创建时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">

View File

@ -11,10 +11,10 @@
<div class="think-box-shadow margin-bottom-15">
<span class="color-green font-w7 text-middle">文件存储引擎:</span>
{foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储','oss'=>'阿里云OSS存储'] as $k=>$v}
{if sysconf('storage_type') eq $k}
{if auth('file')}<a data-modal="{:url('file')}?type={$k}" class="layui-btn layui-btn-sm">{$v}</a>{else}<a class="layui-btn layui-btn-sm">{$v}</a>{/if}
{elseif auth('file')}<a data-modal="{:url('file')}?type={$k}" class="layui-btn layui-btn-sm layui-btn-primary">{$v}</a>{/if}
{foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储'] as $k=>$v}
{if sysconf('storage.type') eq $k}
{if auth('file')}<a data-modal="{:url('storage')}?type={$k}" class="layui-btn layui-btn-sm">{$v}</a>{else}<a class="layui-btn layui-btn-sm">{$v}</a>{/if}
{elseif auth('file')}<a data-modal="{:url('storage')}?type={$k}" class="layui-btn layui-btn-sm layui-btn-primary">{$v}</a>{/if}
{/foreach}
</div>

View File

@ -6,13 +6,13 @@
<div class="layui-form-item">
<label class="layui-form-label">AllowExts<br><span class="nowrap color-desc">允许类型</span></label>
<div class="layui-input-block">
<input type="text" name="storage_local_exts" required value="{:sysconf('storage_local_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<input type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开。如png,jpg,rar,doc</p>
</div>
</div>
<div class="hr-line-dashed margin-left-40"></div>
<div class="layui-form-item text-center padding-left-40">
<input type="hidden" name="storage_type" value="local">
<input type="hidden" name="storage.type" value="local">
<button class="layui-btn" type="submit">保存配置</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消修改吗?" data-close>取消修改</button>
</div>

View File

@ -7,7 +7,7 @@
<div class="layui-form-item">
<label class="layui-form-label">AllowExts<br><span class="nowrap color-desc">允许类型</span></label>
<div class="layui-input-block">
<input type="text" name="storage_local_exts" required value="{:sysconf('storage_local_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<input type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开。如png,jpg,rar,doc</p>
</div>
</div>
@ -16,10 +16,10 @@
<div class="layui-input-block">
{foreach ['http','https','auto'] as $pro}
<label class="think-radio">
{if sysconf('storage_qiniu_is_https') eq $pro}
<input checked type="radio" name="storage_qiniu_is_https" value="{$pro}" lay-ignore> {$pro}
{if sysconf('storage.qiniu_http_protocol') eq $pro}
<input checked type="radio" name="storage.qiniu_http_protocol" value="{$pro}" lay-ignore> {$pro}
{else}
<input type="radio" name="storage_qiniu_is_https" value="{$pro}" lay-ignore> {$pro}
<input type="radio" name="storage.qiniu_http_protocol" value="{$pro}" lay-ignore> {$pro}
{/if}
</label>
{/foreach}
@ -31,10 +31,10 @@
<div class="layui-input-block">
{foreach ['华东','华北','华南','北美'] as $area}
<label class="think-radio">
{if sysconf('storage_qiniu_region') eq $area}
<input checked type="radio" name="storage_qiniu_region" value="{$area}" lay-ignore>
{if sysconf('storage.qiniu_region') eq $area}
<input checked type="radio" name="storage.qiniu_region" value="{$area}" lay-ignore>
{else}
<input type="radio" name="storage_qiniu_region" value="{$area}" lay-ignore>
<input type="radio" name="storage.qiniu_region" value="{$area}" lay-ignore>
{/if}
{$area}
</label>
@ -45,34 +45,34 @@
<div class="layui-form-item" data-storage-type="qiniu">
<label class="layui-form-label">Bucket<br><span class="nowrap color-desc">空间名称</span></label>
<div class="layui-input-block">
<input type="text" name="storage_qiniu_bucket" required value="{:sysconf('storage_qiniu_bucket')}" placeholder="请输入七牛云存储 Bucket (空间名称)" class="layui-input">
<input type="text" name="storage.qiniu_bucket" required value="{:sysconf('storage.qiniu_bucket')}" placeholder="请输入七牛云存储 Bucket (空间名称)" class="layui-input">
<p class="help-block">填写七牛云存储空间名称static</p>
</div>
</div>
<div class="layui-form-item" data-storage-type="qiniu">
<label class="layui-form-label">Domain<br><span class="nowrap color-desc">访问域名</span></label>
<div class="layui-input-block">
<input type="text" name="storage_qiniu_domain" required value="{:sysconf('storage_qiniu_domain')}" placeholder="请输入七牛云存储 Domain (访问域名)" class="layui-input">
<input type="text" name="storage.qiniu_http_domain" required value="{:sysconf('storage.qiniu_http_domain')}" placeholder="请输入七牛云存储 Domain (访问域名)" class="layui-input">
<p class="help-block">填写七牛云存储访问域名static.ctolog.cc</p>
</div>
</div>
<div class="layui-form-item" data-storage-type="qiniu">
<label class="layui-form-label">AccessKey<br><span class="nowrap color-desc">访问密钥</span></label>
<div class="layui-input-block">
<input type="text" name="storage_qiniu_access_key" required value="{:sysconf('storage_qiniu_access_key')}" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input">
<input type="text" name="storage.qiniu_access_key" required value="{:sysconf('storage.qiniu_access_key')}" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到访问密钥。</p>
</div>
</div>
<div class="layui-form-item" data-storage-type="qiniu">
<label class="layui-form-label">SecretKey<br><span class="nowrap color-desc">安全密钥</span></label>
<div class="layui-input-block">
<input type="text" name="storage_qiniu_secret_key" required value="{:sysconf('storage_qiniu_secret_key')}" maxlength="43" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input">
<input type="text" name="storage.qiniu_secret_key" required value="{:sysconf('storage.qiniu_secret_key')}" maxlength="43" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到安全密钥。</p>
</div>
</div>
<div class="hr-line-dashed margin-left-40"></div>
<div class="layui-form-item text-center padding-left-40">
<input type="hidden" name="storage_type" value="qiniu">
<input type="hidden" name="storage.type" value="qiniu">
<button class="layui-btn" type="submit">保存配置</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消修改吗?" data-close>取消修改</button>
</div>

View File

@ -34,40 +34,43 @@
<i class="layui-icon layui-icon-spread-left"></i>
</a>
</li>
{foreach $menus as $oneMenu}
{foreach $menus as $one}
<li class="layui-nav-item">
<a data-menu-node="m-{$oneMenu.id}" data-open="{$oneMenu.url}">
{notempty name='oneMenu.icon'}<span class='{$oneMenu.icon} padding-right-5'></span>{/notempty}
<span>{$oneMenu.title|default=''}</span>
<a data-menu-node="m-{$one.id}" data-open="{$one.url}">
{notempty name='one.icon'}<span class='{$one.icon} padding-right-5'></span>{/notempty}
<span>{$one.title|default=''}</span>
</a>
</li>
{/foreach}
</ul>
<ul class="layui-nav layui-layout-right">
<li lay-unselect class="layui-nav-item"><a data-reload><i class="layui-icon layui-icon-refresh-3"></i></a></li>
{notempty name='Think.session.admin_user.username'}
{if session('user.username')}
<li class="layui-nav-item">
<dl class="layui-nav-child">
<dd lay-unselect><a data-modal="{:url('admin/index/info',['id'=>session('admin_user.id')])}"><i class="layui-icon layui-icon-set-fill margin-right-5"></i>基本资料</a></dd>
<dd lay-unselect><a data-modal="{:url('admin/index/pass',['id'=>session('admin_user.id')])}"><i class="layui-icon layui-icon-component margin-right-5"></i>安全设置</a></dd>
{if auth('admin/index/buildoptimize')}
<dd lay-unselect><a data-modal="{:url('admin/index/buildOptimize')}"><i class="layui-icon layui-icon-template-1 margin-right-5"></i>压缩发布</a></dd>
{/if}
{if auth('admin/index/clearruntime')}
<dd lay-unselect><a data-modal="{:url('admin/index/clearRuntime')}"><i class="layui-icon layui-icon-fonts-clear margin-right-5"></i>清理缓存</a></dd>
{/if}
{notempty name='GLOBALS.AdminUserRightOption'}{foreach $GLOBALS.AdminUserRightOption as $option}{if auth($option.node)}
<dd lay-unselect><a data-{$option.type}="{$option.action}"><i class="{$option.icon} margin-right-5"></i>{$option.title}</a></dd>
{/if}{/foreach}{/notempty}
<dd lay-unselect><a data-confirm="确定要退出登录吗?" data-load="{:url('admin/login/out')}"><i class="layui-icon layui-icon-release margin-right-5"></i>退出登录</a></dd>
<dd lay-unselect>
<a data-modal="{:url('admin/index/info',['id'=>session('user.id')])}">
<i class="layui-icon layui-icon-set-fill margin-right-5"></i> 基本资料
</a>
</dd>
<dd lay-unselect>
<a data-modal="{:url('admin/index/pass',['id'=>session('user.id')])}">
<i class="layui-icon layui-icon-component margin-right-5"></i> 安全设置
</a>
</dd>
<dd lay-unselect>
<a data-load="{:url('admin/login/out')}" data-confirm="确定要退出登录吗?">
<i class="layui-icon layui-icon-release margin-right-5"></i> 退出登录
</a>
</dd>
</dl>
<a><span><i class="layui-icon layui-icon-username margin-right-5"></i> {:session('admin_user.username')}</span></a>
<a><span><i class="layui-icon layui-icon-username margin-right-5"></i> {:session('user.username')}</span></a>
</li>
{else}
<li class="layui-nav-item">
<a data-href="{:url('@admin/login')}"><i class="layui-icon layui-icon-username"></i> 立即登录</a>
</li>
{/notempty}
{/if}
</ul>
</div>
<!-- 顶部菜单 结束 -->
@ -76,29 +79,29 @@
<div class="layui-side layui-bg-black notselect">
<div class="layui-side-scroll">
{foreach $menus as $oneMenu}
{notempty name='oneMenu.sub'}
<ul class="layui-nav layui-nav-tree layui-hide" data-menu-layout="m-{$oneMenu.id}">
{foreach $oneMenu.sub as $twoMenu}
{empty name='twoMenu.sub'}
{foreach $menus as $one}
{notempty name='one.sub'}
<ul class="layui-nav layui-nav-tree layui-hide" data-menu-layout="m-{$one.id}">
{foreach $one.sub as $two}
{empty name='two.sub'}
<li class="layui-nav-item">
<a data-target-tips="{$twoMenu.title}" data-menu-node="m-{$oneMenu.id}-{$twoMenu.id}" data-open="{$twoMenu.url}">
<span class='{$twoMenu.icon|default="layui-icon layui-icon-link"}'></span>
<span class="nav-text padding-left-5">{$twoMenu.title}</span>
<a data-target-tips="{$two.title}" data-menu-node="m-{$one.id}-{$two.id}" data-open="{$two.url}">
<span class='{$two.icon|default="layui-icon layui-icon-link"}'></span>
<span class="nav-text padding-left-5">{$two.title}</span>
</a>
</li>
{else}
<li class="layui-nav-item" data-submenu-layout='m-{$oneMenu.id}-{$twoMenu.id}'>
<a data-target-tips="{$twoMenu.title}" style="background:#393D49">
<span class='nav-icon layui-hide {$twoMenu.icon|default="layui-icon layui-icon-triangle-d"}'></span>
<span class="nav-text padding-left-5">{$twoMenu.title}</span>
<li class="layui-nav-item" data-submenu-layout='m-{$one.id}-{$two.id}'>
<a data-target-tips="{$two.title}" style="background:#393D49">
<span class='nav-icon layui-hide {$two.icon|default="layui-icon layui-icon-triangle-d"}'></span>
<span class="nav-text padding-left-5">{$two.title}</span>
</a>
<dl class="layui-nav-child">
{foreach $twoMenu.sub as $thrMenu}
{foreach $two.sub as $thr}
<dd>
<a data-target-tips="{$thrMenu.title}" data-open="{$thrMenu.url}" data-menu-node="m-{$oneMenu.id}-{$twoMenu.id}-{$thrMenu.id}">
<span class='nav-icon padding-left-5 {$thrMenu.icon|default="layui-icon layui-icon-link"}'></span>
<span class="nav-text padding-left-5">{$thrMenu.title}</span>
<a data-target-tips="{$thr.title}" data-open="{$thr.url}" data-menu-node="m-{$one.id}-{$two.id}-{$thr.id}">
<span class='nav-icon padding-left-5 {$thr.icon|default="layui-icon layui-icon-link"}'></span>
<span class="nav-text padding-left-5">{$thr.title}</span>
</a>
</dd>
{/foreach}

View File

@ -1,4 +1,4 @@
{extend name="admin@index/index"}
{extend name="index/index"}
{block name="body"}
<div class="login-container" data-supersized="__ROOT__/static/theme/img/login/bg1.jpg,__ROOT__/static/theme/img/login/bg2.jpg">
@ -30,11 +30,10 @@
<i class="layui-icon layui-icon-picture-fine"></i>
<input class="layui-input" required pattern="^\S{4,}$" name="verify" value="{$captcha->getCode()}" maxlength="4" autocomplete="off" placeholder="验证码" title="请输入验证码">
</label>
<img data-refresh-captcha alt="img" src="{$captcha->getData()}">
<img data-captcha alt="img" src="{$captcha->getData()}">
<input type="hidden" name="uniqid" value="{$captcha->getUniqid()}">
</li>
<li class="text-center padding-top-20">
<input type="hidden" name="skey" value="{$loginskey|default=''}">
<button type="submit" class="layui-btn layui-disabled full-width" data-form-loaded="立即登入">正在载入</button>
</li>
</ul>
@ -54,5 +53,6 @@
{/block}
{block name='script'}
<script src="__ROOT__/static/login.js"></script>
<script src="__ROOT__/static/plugs/supersized/supersized.3.2.7.min.js"></script>
{/block}

View File

@ -60,10 +60,10 @@
<a data-dbclick class="layui-btn layui-btn-xs" data-title="编辑菜单" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
{/if}
{if $vo.status eq 1 and auth("forbid")}
<a class="layui-btn layui-btn-warm layui-btn-xs" data-confirm="确定要禁用菜单吗?" data-action="{:url('forbid')}" data-value="id#{$vo.ids};status#0" data-csrf="{:systoken('forbid')}">禁 用</a>
{elseif auth("resume")}
<a class="layui-btn layui-btn-warm layui-btn-xs" data-action="{:url('resume')}" data-value="id#{$vo.ids};status#1" data-csrf="{:systoken('resume')}">启 用</a>
{if $vo.status eq 1 and auth("state")}
<a class="layui-btn layui-btn-warm layui-btn-xs" data-confirm="确定要禁用菜单吗?" data-action="{:url('state')}" data-value="id#{$vo.ids};status#0" data-csrf="{:systoken('state')}">禁 用</a>
{elseif auth("state")}
<a class="layui-btn layui-btn-warm layui-btn-xs" data-action="{:url('state')}" data-value="id#{$vo.ids};status#1" data-csrf="{:systoken('state')}">启 用</a>
{/if}
{if auth("remove")}

View File

@ -7,42 +7,42 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作账号</label>
<div class="layui-input-inline">
<input name="username" value="{$Think.get.username|default=''}" placeholder="请输入操作账号" class="layui-input">
<input name="username" value="{:input('get.username')}" placeholder="请输入操作账号" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作节点</label>
<div class="layui-input-inline">
<input name="node" value="{$Think.get.node|default=''}" placeholder="请输入操作节点" class="layui-input">
<input name="node" value="{:input('get.node')}" placeholder="请输入操作节点" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作行为</label>
<div class="layui-input-inline">
<input name="action" value="{$Think.get.action|default=''}" placeholder="请输入操作行为" class="layui-input">
<input name="action" value="{:input('get.action')}" placeholder="请输入操作行为" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作描述</label>
<div class="layui-input-inline">
<input name="content" value="{$Think.get.content|default=''}" placeholder="请输入操作内容" class="layui-input">
<input name="content" value="{:input('get.content')}" placeholder="请输入操作内容" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">位置地址</label>
<div class="layui-input-inline">
<input name="geoip" value="{$Think.get.geoip|default=''}" placeholder="请输入位置地址" class="layui-input">
<input name="geoip" value="{:input('get.geoip')}" placeholder="请输入位置地址" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择操作时间" class="layui-input">
<input data-date-range name="create_at" value="{:input('get.create_at')}" placeholder="请选择操作时间" class="layui-input">
</div>
</div>

View File

@ -6,12 +6,12 @@
<button data-action='{:url("remove")}' data-confirm="确定要批量删除任务吗?" data-rule="id#{key}" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除任务</button>
{/if}
{if auth("processstart") && $iswin}
<button data-load='{:url("processstart")}' class='layui-btn layui-btn-sm layui-btn-primary'>创建监听进程</button>
{if auth("start") && $iswin}
<button data-load='{:url("start")}' class='layui-btn layui-btn-sm layui-btn-primary'>创建监听进程</button>
{/if}
{if auth("processstop") && $iswin}
<button data-load='{:url("processstop")}' class='layui-btn layui-btn-sm layui-btn-primary'>停止监听进程</button>
{if auth("stop") && $iswin}
<button data-load='{:url("stop")}' class='layui-btn layui-btn-sm layui-btn-primary'>停止监听进程</button>
{/if}
{/block}
@ -40,8 +40,8 @@
<input class="list-check-box" value='{$vo.id}' type='checkbox'>
</td>
<td class='text-left nowrap'>
任务名称:{$vo.title}<br>
<span class="color-desc">任务指令:{$vo.preload}</span>
任务名称:{$vo.title|default=''}<br>
<span class="color-desc">任务指令:{$vo.command|default=''}</span>
</td>
<td class='text-left nowrap'>
创建时间:{$vo.create_at|format_datetime} / {$vo.time|format_datetime}<br>

View File

@ -1,27 +1,32 @@
{if session('admin_user.username') eq 'admin'}
{if session('user.username') eq 'admin'}
<fieldset class="margin-bottom-10">
<legend>进程守护</legend>
<div class="layui-code border-0 margin-top-0">
<p class="color-desc margin-top-10">当前消息队列守护进程运行状态</p>
{$message|raw|default='--'}
<p class="color-desc margin-top-10">配置定时任务来检查并启动进程(建议每分钟执行)</p>
{$cmd|default='--'}
<h4 class="color-desc margin-top-10">运行环境需要开放执行函数</h4>
<span class="layui-badge layui-bg-blue">pclose</span>
<span class="layui-badge layui-bg-blue">popen</span>
<span class="layui-badge layui-bg-blue">shell_exe</span>
<h4 class="color-desc margin-top-10">当前消息队列守护进程运行状态</h4>
<span class="layui-badge layui-bg-blue">{$message|raw|default='--'}</span>
<h4 class="color-desc margin-top-10">配置定时任务来检查并启动进程(建议每分钟执行)</h4>
<span class="layui-badge layui-bg-blue">{$command|default='--'}</span>
</div>
</fieldset>
{/if}
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">任务名称</label>
<div class="layui-input-inline">
<input name="title" value="{$Think.get.title|default=''}" placeholder="请输入任务名称" class="layui-input">
<input name="title" value="{:input('get.title')}" placeholder="请输入任务名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">任务指令</label>
<div class="layui-input-inline">
<input name="preload" value="{$Think.get.preload|default=''}" placeholder="请输入任务指令" class="layui-input">
<input name="command" value="{:input('get.command')}" placeholder="请输入任务指令" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
@ -29,11 +34,11 @@
<div class="layui-input-inline">
<select name="status" class="layui-select">
{foreach [''=>'-- 全部状态 --','1'=>'待处理','2'=>'处理中','3'=>'处理完成','4'=>'处理失败'] as $k=>$v}
<!--{if $Think.get.status eq $k}-->
{if input('get.status') eq $k}
<option selected value="{$k}">{$v}</option>
<!--{else}-->
{else}
<option value="{$k}">{$v}</option>
<!--{/if}-->
{/if}
{/foreach}
</select>
</div>
@ -41,19 +46,19 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择创建时间" class="layui-input">
<input data-date-range name="create_at" value="{:input('get.create_at')}" placeholder="请选择创建时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">开始时间</label>
<div class="layui-input-inline">
<input data-date-range name="start_at" value="{$Think.get.start_at|default=''}" placeholder="请选择开始时间" class="layui-input">
<input data-date-range name="start_at" value="{:input('get.start_at')}" placeholder="请选择开始时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">结束时间</label>
<div class="layui-input-inline">
<input data-date-range name="end_at" value="{$Think.get.end_at|default=''}" placeholder="请选择结束时间" class="layui-input">
<input data-date-range name="end_at" value="{:input('get.end_at')}" placeholder="请选择结束时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">

View File

@ -30,6 +30,7 @@
</div>
{notempty name='authorizes'}
<div class="layui-form-item relative">
<span class="color-green font-w7">角色访问授权</span>
<span class="color-desc margin-left-5">Authorization</span>

View File

@ -54,10 +54,10 @@
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
{/if}
{if $vo.status eq 1 and auth("forbid")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('forbid')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('forbid')}">禁 用</a>
{elseif $vo.status eq 0 and auth("resume")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('resume')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('resume')}">启 用</a>
{if $vo.status eq 1 and auth("state")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
{elseif $vo.status eq 0 and auth("state")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">启 用</a>
{/if}
{if auth("remove")}

View File

@ -7,21 +7,21 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">用户账号</label>
<div class="layui-input-inline">
<input name="username" value="{$Think.get.username|default=''}" placeholder="请输入用户名" class="layui-input">
<input name="username" value="{:input('get.username')}" placeholder="请输入用户名" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">联系手机</label>
<div class="layui-input-inline">
<input name="phone" value="{$Think.get.phone|default=''}" placeholder="请输入联系手机" class="layui-input">
<input name="phone" value="{:input('get.phone')}" placeholder="请输入联系手机" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">联系邮箱</label>
<div class="layui-input-inline">
<input name="mail" value="{$Think.get.mail|default=''}" placeholder="请输入联系邮箱" class="layui-input">
<input name="mail" value="{:input('get.mail')}" placeholder="请输入联系邮箱" class="layui-input">
</div>
</div>
@ -30,11 +30,11 @@
<div class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'-- 全部状态 --','0'=>'已禁用的账号','1'=>'使用中的账号'] as $k=>$v}
{eq name='Think.get.status' value='$k.""'}
{if input('get.status') eq $k.""}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/if}
{/foreach}
</select>
</div>
@ -43,7 +43,7 @@
<div class="layui-form-item layui-inline">
<label class="layui-form-label">登录时间</label>
<div class="layui-input-inline">
<input data-date-range name="login_at" value="{$Think.get.login_at|default=''}" placeholder="请选择登录时间" class="layui-input">
<input data-date-range name="login_at" value="{:input('get.login_at')}" placeholder="请选择登录时间" class="layui-input">
</div>
</div>

View File

@ -0,0 +1,13 @@
<?php
namespace app\index\controller;
use think\admin\Controller;
class Index extends Controller
{
public function index()
{
$this->redirect(url('@admin/login'));
}
}

View File

@ -1,180 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\NodeService;
use library\Controller;
use think\Db;
/**
* 系统权限管理
* Class Auth
* @package app\admin\controller
*/
class Auth extends Controller
{
/**
* 默认数据模型
* @var string
*/
public $table = 'SystemAuth';
/**
* 系统权限管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '系统权限管理';
$query = $this->_query($this->table)->dateBetween('create_at');
$query->like('title,desc')->equal('status')->order('sort desc,id desc')->page();
}
/**
* 权限配置节点
* @auth true
* @throws \ReflectionException
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function apply()
{
$this->title = '权限配置节点';
$auth = $this->request->post('id', '0');
switch (strtolower($this->request->post('action'))) {
case 'get': // 获取权限配置
$checks = Db::name('SystemAuthNode')->where(['auth' => $auth])->column('node');
return $this->success('获取权限节点成功!', NodeService::getAuthTree($checks));
case 'save': // 保存权限配置
list($post, $data) = [$this->request->post(), []];
foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) {
$data[] = ['auth' => $auth, 'node' => $node];
}
Db::name('SystemAuthNode')->where(['auth' => $auth])->delete();
Db::name('SystemAuthNode')->insertAll($data);
NodeService::applyUserAuth();
return $this->success('权限授权更新成功!');
default:
return $this->_form($this->table, 'apply');
}
}
/**
* 添加系统权限
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->applyCsrfToken();
$this->_form($this->table, 'form');
}
/**
* 编辑系统权限
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->applyCsrfToken();
$this->_form($this->table, 'form');
}
/**
* 刷新系统权限
* @auth true
*/
public function refresh()
{
try {
NodeService::applyUserAuth(true);
$this->success('刷新系统授权成功!');
} catch (\think\exception\HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("刷新系统授权失败<br>{$e->getMessage()}");
}
}
/**
* 禁用系统权限
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用系统权限
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '1']);
}
/**
* 删除系统权限
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->applyCsrfToken();
$this->_delete($this->table);
}
/**
* 删除结果处理
* @param boolean $result
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
protected function _remove_delete_result($result)
{
if ($result) {
$map = ['auth' => $this->request->post('id')];
Db::name('SystemAuthNode')->where($map)->delete();
$this->success("权限删除成功!", '');
} else {
$this->error("权限删除失败,请稍候再试!");
}
}
}

View File

@ -1,130 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use library\Controller;
use think\exception\HttpResponseException;
use think\facade\Request;
/**
* 系统参数配置
* Class Config
* @package app\admin\controller
*/
class Config extends Controller
{
/**
* 默认数据模型
* @var string
*/
protected $table = 'SystemConfig';
/**
* 阿里云OSS上传点
* @var array
*/
protected $ossPoints = [
'oss-cn-hangzhou.aliyuncs.com' => '华东 1 杭州',
'oss-cn-shanghai.aliyuncs.com' => '华东 2 上海',
'oss-cn-qingdao.aliyuncs.com' => '华北 1 青岛',
'oss-cn-beijing.aliyuncs.com' => '华北 2 北京',
'oss-cn-zhangjiakou.aliyuncs.com' => '华北 3 张家口',
'oss-cn-huhehaote.aliyuncs.com' => '华北 5 呼和浩特',
'oss-cn-shenzhen.aliyuncs.com' => '华南 1 深圳',
'oss-cn-hongkong.aliyuncs.com' => '香港 1',
'oss-us-west-1.aliyuncs.com' => '美国西部 1 硅谷',
'oss-us-east-1.aliyuncs.com' => '美国东部 1 弗吉尼亚',
'oss-ap-southeast-1.aliyuncs.com' => '亚太东南 1 新加坡',
'oss-ap-southeast-2.aliyuncs.com' => '亚太东南 2 悉尼',
'oss-ap-southeast-3.aliyuncs.com' => '亚太东南 3 吉隆坡',
'oss-ap-southeast-5.aliyuncs.com' => '亚太东南 5 雅加达',
'oss-ap-northeast-1.aliyuncs.com' => '亚太东北 1 日本',
'oss-ap-south-1.aliyuncs.com' => '亚太南部 1 孟买',
'oss-eu-central-1.aliyuncs.com' => '欧洲中部 1 法兰克福',
'oss-eu-west-1.aliyuncs.com' => '英国 1 伦敦',
'oss-me-east-1.aliyuncs.com' => '中东东部 1 迪拜',
];
/**
* 系统参数配置
* @auth true
* @menu true
*/
public function info()
{
$this->title = '系统参数配置';
$this->fetch();
}
/**
* 修改系统能数配置
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function config()
{
$this->applyCsrfToken();
if (Request::isGet()) {
$this->fetch('system-config');
}
foreach (Request::post() as $key => $value) {
sysconf($key, $value);
}
$this->success('系统参数配置成功!');
}
/**
* 文件存储引擎
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function file()
{
$this->applyCsrfToken();
if (Request::isGet()) {
$this->type = input('type', 'local');
$this->fetch("storage-{$this->type}");
}
$post = Request::post();
if (isset($post['storage_type']) && isset($post['storage_local_exts'])) {
$exts = array_unique(explode(',', strtolower($post['storage_local_exts'])));
sort($exts);
if (in_array('php', $exts)) $this->error('禁止上传可执行文件到本地服务器!');
$post['storage_local_exts'] = join(',', $exts);
}
foreach ($post as $key => $value) sysconf($key, $value);
if (isset($post['storage_type']) && $post['storage_type'] === 'oss') {
try {
$local = sysconf('storage_oss_domain');
$bucket = $this->request->post('storage_oss_bucket');
$domain = \library\File::instance('oss')->setBucket($bucket);
if (empty($local) || stripos($local, '.aliyuncs.com') !== false) {
sysconf('storage_oss_domain', $domain);
}
$this->success('阿里云OSS存储配置成功');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("阿里云OSS存储配置失效{$e->getMessage()}");
}
} else {
$this->success('文件存储配置成功!');
}
}
}

View File

@ -1,177 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\NodeService;
use library\Controller;
use library\tools\Data;
use think\Console;
use think\Db;
use think\exception\HttpResponseException;
/**
* 系统公共操作
* Class Index
* @package app\admin\controller
*/
class Index extends Controller
{
/**
* 显示后台首页
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->title = '系统管理后台';
NodeService::applyUserAuth(true);
$this->menus = NodeService::getMenuNodeTree();
if (empty($this->menus) && !NodeService::islogin()) {
$this->redirect('@admin/login');
} else {
$this->fetch();
}
}
/**
* 后台环境信息
*/
public function main()
{
$this->think_ver = \think\App::VERSION;
$this->mysql_ver = Db::query('select version() as ver')[0]['ver'];
$this->fetch();
}
/**
* 修改密码
* @param integer $id
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function pass($id)
{
$this->applyCsrfToken();
if (intval($id) !== intval(session('admin_user.id'))) {
$this->error('只能修改当前用户的密码!');
}
if (!NodeService::islogin()) {
$this->error('需要登录才能操作哦!');
}
if ($this->request->isGet()) {
$this->verify = true;
$this->_form('SystemUser', 'admin@user/pass', 'id', [], ['id' => $id]);
} else {
$data = $this->_input([
'password' => $this->request->post('password'),
'repassword' => $this->request->post('repassword'),
'oldpassword' => $this->request->post('oldpassword'),
], [
'oldpassword' => 'require',
'password' => 'require|min:4',
'repassword' => 'require|confirm:password',
], [
'oldpassword.require' => '旧密码不能为空!',
'password.require' => '登录密码不能为空!',
'password.min' => '登录密码长度不能少于4位有效字符',
'repassword.require' => '重复密码不能为空!',
'repassword.confirm' => '重复密码与登录密码不匹配,请重新输入!',
]);
$user = Db::name('SystemUser')->where(['id' => $id])->find();
if (md5($data['oldpassword']) !== $user['password']) {
$this->error('旧密码验证失败,请重新输入!');
}
$result = NodeService::checkpwd($data['password']);
if (empty($result['code'])) $this->error($result['msg']);
if (Data::save('SystemUser', ['id' => $user['id'], 'password' => md5($data['password'])])) {
$this->success('密码修改成功,下次请使用新密码登录!', '');
} else {
$this->error('密码修改失败,请稍候再试!');
}
}
}
/**
* 修改用户资料
* @param integer $id 会员ID
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function info($id = 0)
{
if (!NodeService::islogin()) {
$this->error('需要登录才能操作哦!');
}
$this->applyCsrfToken();
if (intval($id) === intval(session('admin_user.id'))) {
$this->_form('SystemUser', 'admin@user/form', 'id', [], ['id' => $id]);
} else {
$this->error('只能修改登录用户的资料!');
}
}
/**
* 清理运行缓存
* @auth true
*/
public function clearRuntime()
{
if (!NodeService::islogin()) {
$this->error('需要登录才能操作哦!');
}
try {
Console::call('clear');
Console::call('xclean:session');
$this->success('清理运行缓存成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("清理运行缓存失败,{$e->getMessage()}");
}
}
/**
* 压缩发布系统
* @auth true
*/
public function buildOptimize()
{
if (!NodeService::islogin()) {
$this->error('需要登录才能操作哦!');
}
try {
Console::call('optimize:route');
Console::call('optimize:schema');
Console::call('optimize:autoload');
Console::call('optimize:config');
$this->success('压缩发布成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("压缩发布失败,{$e->getMessage()}");
}
}
}

View File

@ -1,96 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\CaptchaService;
use app\admin\service\NodeService;
use library\Controller;
use think\Db;
use think\facade\Request;
/**
* 用户登录管理
* Class Login
* @package app\admin\controller
*/
class Login extends Controller
{
/**
* 后台登录入口
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
if (Request::isGet()) {
if (NodeService::islogin()) {
$this->redirect('@admin');
} else {
$this->title = '系统登录';
$this->domain = Request::host(true);
if (!($this->loginskey = session('loginskey'))) session('loginskey', $this->loginskey = uniqid());
$this->devmode = in_array($this->domain, ['127.0.0.1', 'localhost']) || is_numeric(stripos($this->domain, 'thinkadmin.top'));
$this->captcha = new CaptchaService();
$this->fetch();
}
} else {
$data = $this->_input([
'username' => input('username'), 'password' => input('password'),
], [
'username' => 'require|min:4', 'password' => 'require|min:4',
], [
'username.require' => '登录账号不能为空!',
'password.require' => '登录密码不能为空!',
'username.min' => '登录账号长度不能少于4位有效字符',
'password.min' => '登录密码长度不能少于4位有效字符',
]);
if (!CaptchaService::check(input('verify'), input('uniqid'))) {
$this->error('图形验证码验证失败,请重新输入!');
}
// 用户信息验证
$map = ['is_deleted' => '0', 'username' => $data['username']];
$user = Db::name('SystemUser')->where($map)->order('id desc')->find();
if (empty($user)) $this->error('登录账号或密码错误,请重新输入!');
if (md5($user['password'] . session('loginskey')) !== $data['password']) {
$this->error('登录账号或密码错误,请重新输入!');
}
if (empty($user['status'])) $this->error('账号已经被禁用,请联系管理员!');
Db::name('SystemUser')->where(['id' => $user['id']])->update([
'login_at' => Db::raw('now()'), 'login_ip' => Request::ip(), 'login_num' => Db::raw('login_num+1'),
]);
session('loginskey', null);
session('admin_user', $user);
NodeService::applyUserAuth(true);
sysoplog('系统管理', '用户登录系统成功');
$this->success('登录成功', url('@admin'));
}
}
/**
* 退出登录
*/
public function out()
{
\think\facade\Session::clear();
\think\facade\Session::destroy();
$this->success('退出登录成功!', url('@admin/login'));
}
}

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* 异步任务基类
* Class Queue
* @package app\admin\queue
*/
abstract class Queue
{
/**
* 当前任务ID
* @var integer
*/
public $jobid = 0;
/**
* 当前任务标题
* @var string
*/
public $title = '';
/**
* 判断是否WIN环境
* @return boolean
*/
protected function isWin()
{
return PATH_SEPARATOR === ';';
}
/**
* 重发异步任务记录
* @param integer $wait 等待时间
* @return boolean
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function redo($wait = 0)
{
if ($this->jobid > 0) {
if ($queue = Db::name('SystemQueue')->where(['id' => $this->jobid])->find()) {
$queue['time'] = time() + $wait;
$queue['title'] .= " - 来自任务{$this->jobid} 重发任务";
unset($queue['id'], $queue['create_at'], $queue['desc']);
return Db::name('SystemQueue')->insert($queue) !== false;
}
}
return false;
}
/**
* 执行异步任务
* @param Input $input 输入对象
* @param Output $output 输出对象
* @param array $data 任务参数
* @return mixed
*/
abstract function execute(Input $input, Output $output, array $data = []);
}

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use Exception;
use library\command\Task;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* 启动监听异步任务守护的主进程
* Class Listen
* @package library\command\task
*/
class Listen extends Task
{
/**
* 配置指定信息
*/
protected function configure()
{
$this->setName('xtask:listen')->setDescription('[监听]常驻异步任务循环监听主进程');
}
/**
* 执行进程守护监听
* @param Input $input
* @param Output $output
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
protected function execute(Input $input, Output $output)
{
Db::name('SystemQueue')->count();
$output->comment('============ 异步任务监听中 ============');
if ($this->isWin() && function_exists('cli_set_process_title')) {
cli_set_process_title("ThinkAdmin {$this->version} 异步任务监听主进程");
}
while (true) {
foreach (Db::name('SystemQueue')->where([['status', 'eq', '1'], ['time', '<=', time()]])->order('time asc')->select() as $item) {
try {
Db::name('SystemQueue')->where(['id' => $item['id']])->update(['status' => '2', 'start_at' => date('Y-m-d H:i:s')]);
$this->cmd = "{$this->bin} xtask:_work {$item['id']} -";
if ($this->isWin()) {
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "ThinkAdmin.exe {$this->cmd}";
}
if ($this->checkProcess()) {
$output->comment("处理任务的子进程已经存在 --> [{$item['id']}] {$item['title']}");
} else {
$this->createProcess();
$output->info("创建处理任务的子进程成功 --> [{$item['id']}] {$item['title']}");
}
} catch (Exception $e) {
Db::name('SystemQueue')->where(['id' => $item['id']])->update(['status' => '4', 'desc' => $e->getMessage()]);
$output->error("创建处理任务的子进程失败 --> [{$item['id']}] {$item['title']}{$e->getMessage()}");
}
}
sleep(2);
}
}
}

View File

@ -1,52 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use library\command\Task;
use think\console\Input;
use think\console\Output;
/**
* 查询正在执行中的进程PID信息
* Class Query
* @package app\admin\queue\task
*/
class Query extends Task
{
/**
* 指令属性配置
*/
protected function configure()
{
$this->setName('xtask:query')->setDescription('[控制]查询正在执行的所有任务进程');
}
/**
* 执行相关进程查询
* @param Input $input
* @param Output $output
* @return int|void|null
*/
protected function execute(Input $input, Output $output)
{
$this->cmd = "{$this->bin} xtask:";
if (count($this->queryProcess()) < 1) {
$output->writeln('没有查询到相关任务进程');
} else foreach ($this->queryProcess() as $item) {
$output->writeln("{$item['pid']}\t{$item['cmd']}");
}
}
}

View File

@ -1,74 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use library\command\Task;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* 检查并创建异步任务监听主进程
* Class Start
* @package app\admin\queue\task
*/
class Start extends Task
{
/**
* 指令属性配置
*/
protected function configure()
{
$this->setName('xtask:start')->setDescription('[控制]创建异步任务守护监听主进程');
}
/**
* 执行启动操作
* @param Input $input
* @param Output $output
*/
protected function execute(Input $input, Output $output)
{
Db::name('SystemQueue')->count();
$this->setBaseProcess();
if (($pid = $this->checkProcess()) > 0) {
$output->info("异步任务监听主进程{$pid}已经启动!");
} else {
$this->setWinProcess();
$this->createProcess();
$this->setBaseProcess();
sleep(1);
if (($pid = $this->checkProcess()) > 0) {
$output->info("异步任务监听主进程{$pid}启动成功!");
} else {
$output->error('异步任务监听主进程创建失败!');
}
}
}
private function setBaseProcess()
{
$this->cmd = "{$this->bin} xtask:listen";
}
private function setWinProcess()
{
if ($this->isWin()) {
$this->cmd = __DIR__ . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "ThinkAdmin.exe {$this->bin} xtask:listen";
}
}
}

View File

@ -1,51 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use library\command\Task;
use think\console\Input;
use think\console\Output;
/**
* 查看异步任务监听的主进程状态
* Class State
* @package app\admin\queue\task
*/
class State extends Task
{
/**
* 指令属性配置
*/
protected function configure()
{
$this->setName('xtask:state')->setDescription('[控制]查看异步任务监听主进程状态');
}
/**
* 指令执行状态
* @param Input $input
* @param Output $output
*/
protected function execute(Input $input, Output $output)
{
$this->cmd = "{$this->bin} xtask:listen";
if (($pid = $this->checkProcess()) > 0) {
$output->info("异步任务监听主进程{$pid}正在运行...");
} else {
$output->error("异步任务监听主进程没有运行哦!");
}
}
}

View File

@ -1,53 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use library\command\Task;
use think\console\Input;
use think\console\Output;
/**
* 平滑停止异步任务守护的主进程
* Class Stop
* @package app\admin\queue\task
*/
class Stop extends Task
{
/**
* 指令属性配置
*/
protected function configure()
{
$this->setName('xtask:stop')->setDescription('[控制]平滑停止所有的异步任务进程');
}
/**
* 停止所有任务执行
* @param Input $input
* @param Output $output
*/
protected function execute(Input $input, Output $output)
{
$this->cmd = "{$this->bin} xtask:";
if (count($processList = $this->queryProcess()) < 1) {
$output->writeln("没有需要结束的任务进程哦!");
} else foreach ($processList as $item) {
$this->closeProcess($item['pid']);
$output->writeln("发送结束任务进程{$item['pid']}指令成功!");
}
}
}

View File

@ -1,111 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\queue\task;
use Exception;
use library\command\Task;
use think\Console;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
use think\Db;
/**
* 启动指定独立执行的任务子进程
* Class Work
* @package library\command\task
*/
class Work extends Task
{
/**
* 当前任务ID
* @var integer
*/
protected $id;
/**
* 绑定数据表
* @var string
*/
protected $table = 'SystemQueue';
/**
* 配置指定信息
*/
protected function configure()
{
// 执行任务配置
$this->setName('xtask:_work')->setDescription('[执行]创建执行单个指定任务的进程');
$this->addArgument('id', Argument::OPTIONAL, '指定任务ID');
$this->addArgument('sp', Argument::OPTIONAL, '指令结束符');
}
/**
* 任务执行
* @param Input $input
* @param Output $output
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
protected function execute(Input $input, Output $output)
{
try {
$this->id = trim($input->getArgument('id')) ?: 0;
if (empty($this->id)) throw new Exception("执行任务需要指定任务编号!");
$queue = Db::name('SystemQueue')->where(['id' => $this->id, 'status' => '2'])->find();
if (empty($queue)) throw new Exception("执行任务{$this->id}的信息或状态异常!");
// 设置进程标题
if ($this->isWin() && function_exists('cli_set_process_title')) {
cli_set_process_title("ThinkAdmin {$this->version} 异步任务执行子进程 - {$queue['title']}");
}
// 执行任务内容
if (class_exists($queue['preload'])) {
if (method_exists($class = new $queue['preload'], 'execute')) {
$data = json_decode($queue['data'], true);
if (isset($class->jobid)) $class->jobid = $this->id;
if (isset($class->title)) $class->title = $queue['title'];
$this->update('3', $class->execute($input, $output, is_array($data) ? $data : []));
} else {
throw new Exception("任务处理类 {$queue['preload']} 未定义 execute 入口!");
}
} else {
$this->update('3', Console::call($queue['preload'], [], 'console'));
}
} catch (Exception $e) {
$this->update('4', $e->getMessage());
}
}
/**
* 修改当前任务状态
* @param integer $status 任务状态
* @param string $message 消息内容
* @return boolean
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
protected function update($status, $message)
{
$result = Db::name('SystemQueue')->where(['id' => $this->id])->update([
'status' => $status, 'end_at' => date('Y-m-d H:i:s'),
'desc' => is_string($message) ? $message : '',
]);
$this->output->writeln(is_string($message) ? $message : '');
return $result !== false;
}
}

View File

@ -1,147 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\service;
use think\facade\Cache;
/**
* 图形验证码服务
* Class CaptchaService
* @package app\data\service
*/
class CaptchaService
{
private $code; // 验证码
private $uniqid; // 唯一序号
private $charset = 'ABCDEFGHKMNPRSTUVWXYZ23456789'; // 随机因子
private $codelen = 4; // 验证码长度
private $width = 130; // 宽度
private $height = 50; // 高度
private $img; // 图形资源句柄
private $font; // 指定的字体
private $fontsize = 20; // 指定字体大小
private $fontcolor; // 指定字体颜色
/**
* 构造方法初始化
* CaptchaService constructor.
* @param array $config
*/
public function __construct($config = [])
{
// 动态配置属性
foreach ($config as $k => $v) if (isset($this->$k)) $this->$k = $v;
// 生成验证码序号
$this->uniqid = uniqid('captcha') . mt_rand(1000, 9999);
// 生成验证码字符串
$length = strlen($this->charset) - 1;
for ($i = 0; $i < $this->codelen; $i++) {
$this->code .= $this->charset[mt_rand(0, $length)];
}
// 缓存验证码字符串
Cache::tag('captcha')->set($this->uniqid, $this->code, 360);
// 设置字体文件路径
$this->font = __DIR__ . '/font/icon.ttf';
}
/**
* 创建验证码图片
* @return string
*/
private function createImage()
{
// 生成背景
$this->img = imagecreatetruecolor($this->width, $this->height);
$color = imagecolorallocate($this->img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
imagefilledrectangle($this->img, 0, $this->height, $this->width, 0, $color);
// 生成线条
for ($i = 0; $i < 6; $i++) {
$color = imagecolorallocate($this->img, mt_rand(0, 50), mt_rand(0, 50), mt_rand(0, 50));
imageline($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color);
}
// 生成雪花
for ($i = 0; $i < 100; $i++) {
$color = imagecolorallocate($this->img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
imagestring($this->img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '*', $color);
}
// 生成文字
$_x = $this->width / $this->codelen;
for ($i = 0; $i < $this->codelen; $i++) {
$this->fontcolor = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156));
imagettftext($this->img, $this->fontsize, mt_rand(-30, 30), $_x * $i + mt_rand(1, 5), $this->height / 1.4, $this->fontcolor, $this->font, $this->code[$i]);
}
ob_start();
imagepng($this->img);
$data = ob_get_contents();
ob_end_clean();
imagedestroy($this->img);
return base64_encode($data);
}
/**
* 获取验证码
* @return array
*/
public function getAttr()
{
return [
'code' => $this->code,
'uniq' => $this->uniqid,
'data' => $this->getData()
];
}
/**
* 获取验证码值
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* 获取图片内容
* @return string
*/
public function getData()
{
return "data:image/png;base64,{$this->createImage()}";
}
/**
* 获取验证码编号
* @return string
*/
public function getUniqid()
{
return $this->uniqid;
}
/**
* 检查验证码是否正确
* @param string $code 需要验证的值
* @param string $uniqid 验证码编号
* @return boolean
*/
public static function check($code, $uniqid = null)
{
$_uni = is_string($uniqid) ? $uniqid : input('uniqid', '-');
$_val = Cache::tag('captcha')->get($_uni);
Cache::tag('captcha')->rm($_uni);
return is_string($_val) && strtolower($_val) === strtolower($code);
}
}

View File

@ -1,343 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\service;
use library\tools\Data;
use library\tools\Node;
use think\Db;
use think\facade\App;
use think\facade\Cache;
use think\facade\Request;
/**
* 功能节点管理服务
* Class NodeService
* @package app\admin\service
*/
class NodeService
{
/**
* 获取标准访问节点
* @param string $node
* @return string
*/
public static function full($node = null)
{
if (empty($node)) return self::current();
if (count(explode('/', $node)) === 1) {
$node = Request::module() . '/' . Request::controller() . '/' . $node;
}
return self::parseString(trim($node, " /"));
}
/**
* 判断是否已经登录
* @return boolean
*/
public static function islogin()
{
return session('admin_user.id') ? true : false;
}
/**
* 获取当前访问节点
* @return string
*/
public static function current()
{
return self::parseString(Request::module() . '/' . Request::controller() . '/' . Request::action());
}
/**
* 检查密码是否合法
* @param string $password
* @return array
*/
public static function checkpwd($password)
{
$password = trim($password);
if (!strlen($password) >= 6) {
return ['code' => 0, 'msg' => '密码必须大于6字符'];
}
if (!preg_match("/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,32}$/", $password)) {
return ['code' => 0, 'msg' => '密码必需包含大小写字母、数字、符号任意两者组合!'];
} else {
return ['code' => 1, 'msg' => '密码复杂度通过验证!'];
}
}
/**
* 获取可选菜单节点
* @return array
* @throws \ReflectionException
*/
public static function getMenuNodeList()
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
foreach (self::getMethodList() as $node => $method) if ($method['menu']) {
$nodes[] = ['node' => $node, 'title' => $method['title']];
}
return $nodes;
}
/**
* 获取系统菜单树数据
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getMenuNodeTree()
{
$list = Db::name('SystemMenu')->where(['status' => '1'])->order('sort desc,id asc')->select();
return self::buildMenuData(Data::arr2tree($list), self::getMethodList());
}
/**
* 后台主菜单权限过滤
* @param array $menus 当前菜单列表
* @param array $nodes 系统权限节点
* @return array
* @throws \ReflectionException
*/
private static function buildMenuData($menus, $nodes)
{
foreach ($menus as $key => &$menu) {
if (!empty($menu['sub'])) $menu['sub'] = self::buildMenuData($menu['sub'], $nodes);
if (!empty($menu['sub'])) $menu['url'] = '#';
elseif (preg_match('/^https?\:/i', $menu['url'])) continue;
elseif ($menu['url'] === '#') unset($menus[$key]);
else {
$node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3));
$menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}");
if (!self::checkAuth($node)) unset($menus[$key]);
}
}
return $menus;
}
/**
* 获取授权节点列表
* @return array
* @throws \ReflectionException
*/
public static function getAuthList()
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
$nodes = Cache::tag('system')->get('NodeAuthList', []);
if (count($nodes) > 0) return $nodes;
foreach (self::getMethodList() as $key => $node) {
if ($node['auth']) $nodes[$key] = $node['title'];
}
Cache::tag('system')->set('NodeAuthList', $nodes);
return $nodes;
}
/**
* 强制验证访问权限
* --- 需要加载控制器解析注释
* @param null|string $node
* @return boolean
* @throws \ReflectionException
*/
public static function forceAuth($node = null)
{
if (session('admin_user.username') === 'admin') return true;
$real = is_null($node) ? self::current() : self::full($node);
list($module, $controller, $action) = explode('/', $real);
if (class_exists($class = App::parseClass($module, 'controller', $controller))) {
$reflection = new \ReflectionClass($class);
if ($reflection->hasMethod($action)) {
$comment = preg_replace("/\s/", '', $reflection->getMethod($action)->getDocComment());
if (stripos($comment, '@authtrue') === false) return true;
return in_array($real, (array)session('admin_user.nodes'));
}
}
return true;
}
/**
* 检查指定节点授权
* --- 需要读取缓存或扫描所有节点
* @param null|string $node
* @return boolean
* @throws \ReflectionException
*/
public static function checkAuth($node = null)
{
if (session('admin_user.username') === 'admin') return true;
$real = is_null($node) ? self::current() : self::full($node);
if (isset(self::getAuthList()[$real])) {
return in_array($real, (array)session('admin_user.nodes'));
} else {
return true;
}
}
/**
* 获取授权节点列表
* @param array $checkeds
* @return array
* @throws \ReflectionException
*/
public static function getAuthTree($checkeds = [])
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
foreach (self::getAuthList() as $node => $title) {
$pnode = substr($node, 0, strripos($node, '/'));
$nodes[$node] = ['node' => $node, 'title' => $title, 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)];
}
foreach (self::getClassList() as $node => $title) foreach (array_keys($nodes) as $key) {
if (stripos($key, "{$node}/") !== false) {
$pnode = substr($node, 0, strripos($node, '/'));
$nodes[$node] = ['node' => $node, 'title' => $title, 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)];
$nodes[$pnode] = ['node' => $pnode, 'title' => ucfirst($pnode), 'checked' => in_array($pnode, $checkeds)];
}
}
return $nodes = Data::arr2tree($nodes, 'node', 'pnode', '_sub_');
}
/**
* 初始化用户权限
* @param boolean $force 是否重置系统权限
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function applyUserAuth($force = false)
{
if ($force) {
Cache::tag('system')->rm('NodeAuthList');
Cache::tag('system')->rm('NodeClassData');
Cache::tag('system')->rm('NodeMethodData');
}
if (($uid = session('admin_user.id'))) {
session('admin_user', Db::name('SystemUser')->where(['id' => $uid])->find());
}
if (($aids = session('admin_user.authorize'))) {
$where = [['status', 'eq', '1'], ['id', 'in', explode(',', $aids)]];
$subsql = Db::name('SystemAuth')->field('id')->where($where)->buildSql();
session('admin_user.nodes', array_unique(Db::name('SystemAuthNode')->whereRaw("auth in {$subsql}")->column('node')));
} else {
session('admin_user.nodes', []);
}
}
/**
* 获取控制器节点列表
* @return array
* @throws \ReflectionException
*/
public static function getClassList()
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
$nodes = Cache::tag('system')->get('NodeClassData', []);
if (count($nodes) > 0) return $nodes;
self::eachController(function (\ReflectionClass $reflection, $prenode) use (&$nodes) {
list($node, $comment) = [trim($prenode, ' / '), $reflection->getDocComment()];
$nodes[$node] = preg_replace('/^\/\*\*\*(.*?)\*.*?$/', '$1', preg_replace("/\s/", '', $comment));
if (stripos($nodes[$node], '@') !== false) $nodes[$node] = '';
});
Cache::tag('system')->set('NodeClassData', $nodes);
return $nodes;
}
/**
* 获取方法节点列表
* @return array
* @throws \ReflectionException
*/
public static function getMethodList()
{
static $nodes = [];
if (count($nodes) > 0) return $nodes;
$nodes = Cache::tag('system')->get('NodeMethodData', []);
if (count($nodes) > 0) return $nodes;
self::eachController(function (\ReflectionClass $reflection, $prenode) use (&$nodes) {
foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$action = strtolower($method->getName());
list($node, $comment) = ["{$prenode}{$action}", preg_replace("/\s/", '', $method->getDocComment())];
$nodes[$node] = [
'auth' => stripos($comment, '@authtrue') !== false,
'menu' => stripos($comment, '@menutrue') !== false,
'title' => preg_replace('/^\/\*\*\*(.*?)\*.*?$/', '$1', $comment),
];
if (stripos($nodes[$node]['title'], '@') !== false) $nodes[$node]['title'] = '';
}
});
Cache::tag('system')->set('NodeMethodData', $nodes);
return $nodes;
}
/**
* 控制器扫描回调
* @param callable $callable
* @throws \ReflectionException
*/
public static function eachController($callable)
{
foreach (self::scanPath(env('app_path') . "*/controller/") as $file) {
if (!preg_match("|/(\w+)/controller/(.+)\.php$|", $file, $matches)) continue;
list($module, $controller) = [$matches[1], strtr($matches[2], '/', '.')];
if (class_exists($class = substr(strtr(env('app_namespace') . $matches[0], '/', '\\'), 0, -4))) {
call_user_func($callable, new \ReflectionClass($class), Node::parseString("{$module}/{$controller}/"));
}
}
}
/**
* 驼峰转下划线规则
* @param string $node 节点名称
* @return string
*/
public static function parseString($node)
{
if (count($nodes = explode('/', $node)) > 1) {
$dots = [];
foreach (explode('.', $nodes[1]) as $dot) {
$dots[] = trim(preg_replace("/[A-Z]/", "_\\0", $dot), "_");
}
$nodes[1] = join('.', $dots);
}
return strtolower(join('/', $nodes));
}
/**
* 获取所有PHP文件列表
* @param string $dirname 扫描目录
* @param array $data 额外数据
* @param string $ext 有文件后缀
* @return array
*/
private static function scanPath($dirname, $data = [], $ext = 'php')
{
foreach (glob("{$dirname}*") as $file) {
if (is_dir($file)) {
$data = array_merge($data, self::scanPath("{$file}/"));
} elseif (is_file($file) && pathinfo($file, 4) === $ext) {
$data[] = str_replace('\\', '/', $file);
}
}
return $data;
}
}

View File

@ -1,54 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\service;
use library\tools\Node;
use think\Db;
use think\facade\Request;
/**
* 系统日志服务管理
* Class LogService
* @package app\admin\service
*/
class OplogService
{
/**
* 写入操作日志
* @param string $action 日志行为
* @param string $content 日志内容
* @return bool
*/
public static function write($action = '行为', $content = "内容描述")
{
return Db::name('SystemLog')->insert([
'node' => Node::current(), 'action' => $action, 'content' => $content,
'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : Request::ip(),
'username' => PHP_SAPI === 'cli' ? 'cli' : (string)session('admin_user.username'),
]);
}
/**
* 清理系统日志
* @return boolean
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public static function clear()
{
return Db::name('SystemLog')->where('1=1')->delete() !== false;
}
}

View File

@ -1,168 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
use app\admin\service\CaptchaService;
use app\admin\service\NodeService;
use app\admin\service\OplogService;
use library\File;
use think\Console;
use think\Db;
use think\facade\Middleware;
use think\facade\Route;
use think\Request;
if (!function_exists('auth')) {
/**
* 节点访问权限检查
* @param string $node 需要检查的节点
* @return boolean
* @throws ReflectionException
*/
function auth($node)
{
return NodeService::checkAuth($node);
}
}
if (!function_exists('sysdata')) {
/**
* JSON 数据读取与存储
* @param string $name 数据名称
* @param array|null $value 数据内容
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
function sysdata($name, array $value = null)
{
if (is_null($value)) {
$data = json_decode(Db::name('SystemData')->where(['name' => $name])->value('value'), true);
return empty($data) ? [] : $data;
} else {
return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, JSON_UNESCAPED_UNICODE)], 'name');
}
}
}
if (!function_exists('sysoplog')) {
/**
* 写入系统日志
* @param string $action 日志行为
* @param string $content 日志内容
* @return boolean
*/
function sysoplog($action, $content)
{
return OplogService::write($action, $content);
}
}
if (!function_exists('sysqueue')) {
/**
* 创建异步处理任务
* @param string $title 任务名称
* @param string $loade 执行内容
* @param integer $later 延时执行时间
* @param array $data 任务附加数据
* @param integer $double 任务多开
* @return boolean
* @throws \think\Exception
*/
function sysqueue($title, $loade, $later = 0, $data = [], $double = 1)
{
$map = [['title', 'eq', $title], ['status', 'in', [1, 2]]];
if (empty($double) && Db::name('SystemQueue')->where($map)->count() > 0) {
throw new \think\Exception('该任务已经创建,请耐心等待处理完成!');
}
$result = Db::name('SystemQueue')->insert([
'title' => $title, 'preload' => $loade,
'data' => json_encode($data, JSON_UNESCAPED_UNICODE),
'time' => $later > 0 ? time() + $later : time(),
'double' => intval($double), 'create_at' => date('Y-m-d H:i:s'),
]);
return $result !== false;
}
}
if (!function_exists('local_image')) {
/**
* 下载远程文件到本地
* @param string $url 远程图片地址
* @param boolean $force 是否强制重新下载
* @param integer $expire 强制本地存储时间
* @return string
*/
function local_image($url, $force = false, $expire = 0)
{
$result = File::down($url, $force, $expire);
if (isset($result['url'])) {
return $result['url'];
} else {
return $url;
}
}
}
if (!function_exists('base64_image')) {
/**
* base64 图片上传接口
* @param string $content 图片base64内容
* @param string $dirname 图片存储目录
* @return string
*/
function base64_image($content, $dirname = 'base64/')
{
try {
if (preg_match('|^data:image/(.*?);base64,|i', $content)) {
list($ext, $base) = explode('|||', preg_replace('|^data:image/(.*?);base64,|i', '$1|||', $content));
$info = File::save($dirname . md5($base) . '.' . (empty($ext) ? 'tmp' : $ext), base64_decode($base));
return $info['url'];
} else {
return $content;
}
} catch (\Exception $e) {
return $content;
}
}
}
// 访问权限检查中间键
Middleware::add(function (Request $request, \Closure $next) {
if (NodeService::forceAuth()) {
return $next($request);
} elseif (NodeService::islogin()) {
return json(['code' => 0, 'msg' => '抱歉,没有访问该操作的权限!']);
} else {
return json(['code' => 0, 'msg' => '抱歉,需要登录获取访问权限!', 'url' => url('@admin/login')]);
}
});
// 注册系统服务指令
Console::addDefaultCommands([
'app\admin\queue\task\Stop',
'app\admin\queue\task\Work',
'app\admin\queue\task\Start',
'app\admin\queue\task\State',
'app\admin\queue\task\Query',
'app\admin\queue\task\Listen',
]);
// ThinkAdmin 图形验证码
Route::get('/think/admin/captcha', function () {
$image = new CaptchaService();
return json(['code' => '1', 'info' => '生成验证码', 'data' => [
'uniqid' => $image->getUniqid(), 'image' => $image->getData()
]]);
});

View File

@ -1,80 +0,0 @@
<form onsubmit="return false;" data-auto="true" action="{:url()}" method="post" class='layui-form layui-card' autocomplete="off">
<div class="layui-card-body">
<div class="color-text margin-left-40 margin-bottom-20 layui-code" style="border-left-width:1px;background:none">
<p class="margin-bottom-5 font-w7">文件将上传到阿里云OSS空间需要配置OSS公开访问及跨域策略</p>
目前已实现自动创建空间及配置访问策略!<a target="_blank" href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=08p1pddw">我要免费申请</a>
</div>
<div class="layui-form-item">
<label class="layui-form-label">AllowExts<br><span class="nowrap color-desc">允许类型</span></label>
<div class="layui-input-block">
<input type="text" name="storage_local_exts" required value="{:sysconf('storage_local_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开。如png,jpg,rar,doc</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">Protocol<br><span class="nowrap color-desc">访问协议</span></label>
<div class="layui-input-block">
{foreach ['http','https','auto'] as $pro}
<label class="think-radio">
{if sysconf('storage_oss_is_https') eq $pro}
<input checked type="radio" name="storage_oss_is_https" value="{$pro}" lay-ignore> {$pro}
{else}
<input type="radio" name="storage_oss_is_https" value="{$pro}" lay-ignore> {$pro}
{/if}
</label>
{/foreach}
<p class="help-block">阿里云对象存储访问协议http、https、auto其中 https 需要配置证书才能使用auto 为相对协议自动根据域名切换http与https。</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">Bucket<br><span class="nowrap color-desc">空间名称</span></label>
<div class="layui-input-block">
<input type="text" name="storage_oss_bucket" required value="{:sysconf('storage_oss_bucket')}" placeholder="请输入OSS Bucket (空间名称)" class="layui-input">
<p class="help-block">填写OSS存储空间名称think-admin-oss需要是全区唯一的值不存在时会自动创建</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">EndPoint<br><span class="nowrap color-desc">数据中心</span></label>
<div class="layui-input-block">
<select required name="storage_oss_endpoint" class="layui-select" lay-search>
{foreach $ossPoints as $k=>$p}
{if sysconf('storage_oss_endpoint') eq $k}
<option selected value="{$k}">{$p} <span class="font-s10 color-desc">({$k})</span></option>
{else}
<option value="{$k}">{$p} <span class="font-s10 color-desc">({$k})</span></option>
{/if}
{/foreach}
</select>
<p class="help-block">请选择OSS数据中心访问节点有效值如oss-cn-shenzhen.aliyuncs.com</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">AccessKey<br><span class="nowrap color-desc">访问密钥</span></label>
<div class="layui-input-block">
<input type="text" name="storage_oss_keyid" required value="{:sysconf('storage_oss_keyid')}" maxlength="16" placeholder="请输入OSS AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到访问密钥。</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">SecretKey<br><span class="nowrap color-desc">安全密钥</span></label>
<div class="layui-input-block">
<input type="text" name="storage_oss_secret" required value="{:sysconf('storage_oss_secret')}" maxlength="30" placeholder="请输入OSS SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到安全密钥。</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">Domain<br><span class="nowrap color-desc">访问域名</span></label>
<div class="layui-input-block">
<input type="text" name="storage_oss_domain" value="{:sysconf('storage_oss_domain')}" placeholder="请输入OSS存储 Domain (访问域名)" class="layui-input">
<p class="help-block">填写OSS存储外部访问域名think-admin-oss.oss-cn-shenzhen.aliyuncs.com正常情况下是自动获取的</p>
</div>
</div>
<div class="hr-line-dashed margin-left-40"></div>
<div class="layui-form-item text-center padding-left-40">
<input type="hidden" name="storage_type" value="oss">
<button class="layui-btn" type="submit">保存配置</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消修改吗?" data-close>取消修改</button>
</div>
</div>
<script>form.render()</script>
</form>

View File

@ -1,103 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* SVN 版本指令
* Class Subversion
* @package app\company\command
*/
class Subversion extends Command
{
/**
* 账号授权文件位置
* @var string
*/
protected $authzFile = 'php://output';
/**
* 账号管理文件位置
* @var string
*/
protected $passwdFile = 'php://output';
/**
* 配置指令配置
*/
protected function configure()
{
$this->setName('xsubversion:config')->setDescription('从数据库的配置同步到SVN配置文件');
}
/**
* @param Input $input
* @param Output $output
* @return int|void|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function execute(Input $input, Output $output)
{
$paths = ['/' => [0]];
$where = ['status' => '1', 'is_deleted' => '0'];
// 取得可用的用户账号
$users = Db::name('CompanyUser')->field('svn_username,svn_password,svn_authorize')->where($where)->select();
$authids = array_unique(explode(',', join(',', array_column($users, 'svn_authorize'))));
// 取得可用的权限配置
$userAuths = Db::name('CompanyUserAuth')->field('id,path')->where($where)->whereIn('id', $authids)->order('sort desc,id desc')->select();
foreach ($userAuths as $item) foreach (explode("\n", preg_replace('/\s+/i', "\n", trim($item['path']))) as $path) {
$paths[$path][] = $item['id'];
}
$this->writeAuth($users, $paths);
}
/**
* 写入 SVN 配置文件
* @param array $users
* @param array $paths
*/
protected function writeAuth($users, $paths)
{
$output = [];
// Passwd 用户账号处理
foreach ($users as $user) $output[] = "{$user['svn_username']}={$user['svn_password']}";
file_put_contents($this->passwdFile, join(PHP_EOL, $output));
// Authz 授权配置处理
$groups = ['_0' => []];
foreach ($users as $user) {
$ids = array_unique(explode(',', $user['svn_authorize']));
foreach ($ids as $id) $groups["_{$id}"][] = $user['svn_username'];
}
$output = [];
$output[] = '[groups]';
foreach ($groups as $key => $group) $output[] = "group{$key}=" . join(',', $group);
$output[] = '';
foreach ($paths as $path => $ids) {
$output[] = "[{$path}]";
$output[] = "* =";
$output[] = '@group_0 = rw';
foreach ($ids as $id) if ($id > 0) $output[] = "@group_{$id} = rw";
$output[] = '';
}
file_put_contents($this->authzFile, join(PHP_EOL, $output));
}
}

View File

@ -1,101 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\controller;
use library\Controller;
/**
* 仓库权限管理
* Class Auth
* @package app\company\controller
*/
class Auth extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'CompanyUserAuth';
/**
* 仓库权限管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '仓库权限管理';
$query = $this->_query($this->table)->like('title,path')->equal('status');
$query->dateBetween('create_at')->where(['is_deleted' => '0'])->page();
}
/**
* 添加SVN权限
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->title = '添加SVN权限';
$this->_form($this->table, 'form');
}
/**
* 编辑SVN权限
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->_form($this->table, 'form');
}
/**
* 修改SVN权限状态
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function state()
{
$this->_save($this->table, ['status' => input('status')]);
}
/**
* 删除SVN权限
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->_delete($this->table);
}
}

View File

@ -1,49 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\controller;
use library\Controller;
/**
* 网络打卡管理
* Class Clock
* @package app\company\controller
*/
class Clock extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'CompanyUserClock';
/**
* 网络打卡管理
* @auth true
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '网络打卡管理';
$this->_query($this->table)->like('name')->equal('date')->order('id asc')->page();
}
}

View File

@ -1,131 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\controller;
use app\company\service\DataService;
use library\Controller;
use think\Db;
/**
* 企业员工管理
* Class User
* @package app\worker\controller
*/
class User extends Controller
{
/**
* 绑定当前数据表
* @var string
*/
protected $table = 'CompanyUser';
/**
* 企业员工管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '仓库权限管理';
$this->_query($this->table)->like('nickname,svn_username')->equal('status')->page();
}
/**
* 添加企业员工
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->_form($this->table, 'form');
}
/**
* 修改企业员工
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->_form($this->table, 'form');
}
/**
* 权限表单数据处理
* @param array $data 表单数据
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function _form_filter(&$data)
{
if ($this->request->isGet()) {
$where = ['status' => '1', 'is_deleted' => '0'];
$this->auths = Db::name('company_user_auth')->where($where)->order('sort desc,id desc')->select();
array_unshift($this->auths, ['id' => '0', 'title' => '所有权限', 'path' => '/']);
$data['svn_authorize'] = isset($data['svn_authorize']) ? explode(',', $data['svn_authorize']) : [];
} else {
if (isset($data['svn_authorize']) && is_array($data['svn_authorize'])) {
$data['svn_authorize'] = join(',', $data['svn_authorize']);
} else {
$data['svn_authorize'] = '';
}
$macs = [];
foreach (explode(PHP_EOL, preg_replace("/\s+/", PHP_EOL, trim($data['mobile_macs']))) as $mac) {
if (DataService::applyMacValue($mac)) $macs[] = $mac;
}
$data['mobile_macs'] = join(PHP_EOL, array_unique($macs));
}
}
/**
* 更改企业员工状态
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function state()
{
$this->_save($this->table, ['status' => input('status', '0')]);
}
/**
* 删除企业员工
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->_delete($this->table);
}
}

View File

@ -1,97 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\controller\api;
use app\company\service\DataService;
use library\Controller;
use think\Db;
/**
* ARP-SAN 推送内容接收
* Class Push
* @package app\company\controller\api
*/
class Push extends Controller
{
/**
* ARP-SAN 推送内容接收
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function index()
{
// 数据输入检查
$content = file_get_contents('php://input');
if (empty($content)) $this->error('没有接收到数据');
// 企业员工检查
$where = ['is_deleted' => '0', 'status' => '1'];
$users = Db::name('CompanyUser')->cache(10)->where($where)->column('id uid,nickname name,mobile_macs mac');
if (empty($users)) $this->error('没有需要打卡的用户');
// 企业员工检查
$macs = [];
foreach ($users as $user) foreach (explode("\n", preg_replace('/\s+/', "\n", $user['mac'])) as $mac) {
if (DataService::applyMacValue($mac)) $macs[$mac] = ['uid' => $user['uid'], 'name' => $user['name']];
}
// 数据内容解析
list($s, $e) = [0, 0];
foreach (explode("\n", $content) as $line) {
list($ip, $mac, $dsc) = explode(' ', preg_replace('/\s+/', ' ', trim($line)) . ' ');
if (preg_match('/^(\d+\.?){4}$/', $ip) && DataService::applyMacValue($mac)) {
if (isset($macs[$mac])) {
$s++;
$this->writeUser($ip, $mac, strtoupper($dsc), $macs);
} else {
$e++;
$this->writeNone($ip, $mac, strtoupper($dsc));
}
}
}
return "接收到{$s}个已知设备推送,{$e}个未知设备推送。" . PHP_EOL . PHP_EOL;
}
/**
* 已知设备打卡记录
* @param string $ip 内网地址
* @param string $mac 设备地址
* @param string $desc 设备描述
* @param array $macs 用户MAC列表
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
private function writeUser($ip, $mac, $desc, $macs)
{
if (isset($macs[$mac])) {
$data = $macs[$mac];
$data['ip'] = $ip;
$data['mac'] = $mac;
$data['desc'] = $desc;
$data['date'] = date('Y-m-d');
$data['end_at'] = date('Y-m-d H:i:s');
data_save('CompanyUserClock', $data, 'uid', ['date' => $data['date']]);
}
}
/**
* 未知设备额外标识
* @param string $ip 内网地址
* @param string $mac 设备地址
* @param string $desc 设备描述
*/
private function writeNone($ip, $mac, $desc)
{
// @todo 记录未匹配成功的设备标识
}
}

View File

@ -1,40 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\company\service;
/**
* 企业数据处理服务
* Class DataService
* @package app\company\service
*/
class DataService
{
/**
* 格式化MAC地址信息
* @param string $mac
* @return string
*/
public static function applyMacValue(&$mac)
{
$mac = strtoupper(str_replace('-', ':', $mac));
if (preg_match('/([A-F0-9]{2}:){5}[A-F0-9]{2}/', $mac)) {
return $mac;
} else {
return false;
}
}
}

View File

@ -1,35 +0,0 @@
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
<div class="layui-card-body">
<div class="layui-form-item">
<label class="layui-form-label label-required">权限名称</label>
<div class="layui-input-block">
<input name="title" value='{$vo.title|default=""}' required placeholder="请输入权限名称" class="layui-input">
<p class="help-block">权限名称将出现在员工SVN授权处请根据需求准确填写权限名称。</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">权限路径</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="path" placeholder="请输入权限路径">{$vo.path|default=''}</textarea>
<p class="help-block">权限路径将配置到SVN权限分组上务必要保证路径与SVN文件路径一致。</p>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">权限描述</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="desc" placeholder="请输入权限描述">{$vo.desc|default=''}</textarea>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
<script>window.form.render();</script>
</form>

View File

@ -1,78 +0,0 @@
{extend name='admin@main'}
{block name="button"}
{if auth("add")}
<button data-modal='{:url("add")}' data-title="添加仓库权限" class='layui-btn layui-btn-sm layui-btn-primary'>添加仓库权限</button>
{/if}
{if auth("remove")}
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些权限吗?" class='layui-btn layui-btn-sm layui-btn-primary'>添加仓库权限</button>
{/if}
{/block}
{block name="content"}
<div class="think-box-shadow">
{include file='auth/index_search'}
<table class="layui-table" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='list-table-check-td think-checkbox'>
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
</th>
<th class='list-table-sort-td'>
<button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
</th>
<th class='text-left nowrap'>权限名称</th>
<th class='text-left nowrap'>权限路径</th>
<th class='text-center nowrap'>使用状态</th>
<th class='text-left nowrap'>登录时间</th>
<th class='text-left nowrap'></th>
</tr>
</thead>
{/notempty}
<tbody>
{foreach $list as $key=>$vo}
<tr data-dbclick>
<td class='list-table-check-td think-checkbox'>
<label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
</td>
<td class='list-table-sort-td'>
<label><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></label>
</td>
<td class='text-left nowrap'>{$vo.title|default=''}</td>
<td class='text-left nowrap'>{$vo.path|nl2br|raw}</td>
<td class='text-center nowrap'>
{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{/eq}
{eq name='vo.status' value='1'}<span class="color-green">使用中</span>{/eq}
</td>
<td class='text-left nowrap'>{$vo.create_at|format_datetime}</td>
<td class='text-left nowrap'>
{if auth("edit")}
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑仓库权限" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
{/if}
{if auth("state") and $vo.status neq 0}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
{elseif auth("state") and $vo.status neq 1 }
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">启 用</a>
{/if}
{if auth("remove")}
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该权限吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删 除</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

View File

@ -1,50 +0,0 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">权限名称</label>
<div class="layui-input-inline">
<input name="title" value="{$Think.get.title|default=''}" placeholder="请输入权限名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">权限路径</label>
<div class="layui-input-inline">
<input name="path" value="{$Think.get.path|default=''}" placeholder="请输入权限路径" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">使用状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'-- 全部状态 --','0'=>'已禁用的权限','1'=>'使用中的权限'] as $k=>$v}
{eq name='Think.get.status' value='$k.""'}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择创建时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>
<script>form.render()</script>

View File

@ -1,41 +0,0 @@
{extend name='admin@main'}
{block name="content"}
<div class="think-box-shadow">
{include file='clock/index_search'}
<table class="layui-table" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='list-table-check-td think-checkbox'>
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
</th>
<th class='text-left nowrap'>员工姓名</th>
<th class='text-left nowrap'>打卡日期</th>
<th class='text-left nowrap'>内网地址</th>
<th class='text-left nowrap'>首次打卡</th>
<th class='text-left nowrap'>最后打卡</th>
</tr>
</thead>
{/notempty}
<tbody>
{foreach $list as $key=>$vo}
<tr data-dbclick>
<td class='list-table-check-td think-checkbox'>
<label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
</td>
<td class='text-left nowrap'>{$vo.name|default=''}</td>
<td class='text-left nowrap'>{$vo.date|default='-'}</td>
<td class='text-left nowrap'>{$vo.ip|default='-'}</td>
<td class='text-left nowrap'>{$vo.start_at|format_datetime}</td>
<td class='text-left nowrap'>{$vo.end_at|format_datetime}</td>
</tr>
{/foreach}
</tbody>
</table>
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

View File

@ -1,28 +0,0 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">员工姓名</label>
<div class="layui-input-inline">
<input name="name" value="{$Think.get.name|default=''}" placeholder="请输入员工姓名" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">打卡日期</label>
<div class="layui-input-inline">
<input data-date-input="date" name="date" value="{$Think.get.date|default=''}" placeholder="请输入打卡日期" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>
<script>form.render()</script>

View File

@ -1,89 +0,0 @@
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
<div class="layui-card-body">
<div class="layui-form-item">
<label class="layui-form-label label-required">员工姓名</label>
<div class="layui-input-block">
<input name="nickname" value='{$vo.nickname|default=""}' required placeholder="请输入公司员工姓名" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">员工身份</label>
<div class="layui-input-block">
<input name="user_type" value='{$vo.user_type|default=""}' required placeholder="请输入公司员工身份" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">仓库账号</label>
<div class="layui-input-block">
<input name="svn_username" value='{$vo.svn_username|default=""}' required placeholder="请输入SVN授权账号" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">仓库密码</label>
<div class="layui-input-block">
<input name="svn_password" value='{$vo.svn_password|default=""}' required placeholder="请输入SVN授权密码" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label label-required">仓库权限</label>
<div class="layui-input-block">
<div class="layui-textarea padding-bottom-10" style="min-height:auto">
{foreach $auths as $auth}
<label class="think-checkbox layui-unselect">
{if isset($vo.svn_authorize) and in_array($auth.id, $vo.svn_authorize)}
<input type="checkbox" name="svn_authorize[]" value="{$auth.id}" checked lay-ignore> {$auth.title}
{else}
<input type="checkbox" name="svn_authorize[]" value="{$auth.id}" lay-ignore> {$auth.title}
{/if}
</label>
{/foreach}
</div>
</div>
</div>
<div class="layui-form-item nowrap">
<label class="layui-form-label">入职日期</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input type="text" data-date-input="date" name="entry_date" value='{$vo.entry_date|default=""}' placeholder="请输入入职日期" class="layui-input">
</div>
<label class="layui-form-label" style="width:auto">转正日期</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input type="text" data-date-input="date" name="become_date" value='{$vo.become_date|default=""}' placeholder="请输入转正日期" class="layui-input">
</div>
<label class="layui-form-label" style="width:auto">离职日期</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input type="text" data-date-input="date" name="leave_date" value='{$vo.leave_date|default=""}' placeholder="请输入离职日期" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">联系QQ</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input type="tel" autocomplete="off" name="contact_qq" value='{$vo.contact_qq|default=""}' pattern="^\d{6,}$" placeholder="请输入联系QQ号码" class="layui-input">
</div>
<label class="layui-form-label" style="width:auto">联系手机</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input type="tel" maxlength="11" autocomplete="off" name="contact_phone" value='{$vo.contact_phone|default=""}' pattern="^1[3-9][0-9]{9}$" placeholder="请输入联系手机" class="layui-input">
</div>
<label class="layui-form-label" style="width:auto">联系邮箱</label>
<div class="layui-input-inline margin-right-0" style="width:164px">
<input name="contact_mail" autocomplete="off" pattern="^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$" value='{$vo.contact_mail|default=""}' placeholder="请输入联系邮箱" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">打卡绑定</label>
<div class="layui-input-block">
<textarea placeholder="请输入绑定手机" class="layui-textarea" name="mobile_macs">{$vo.mobile_macs|default=""}</textarea>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
<script>window.form.render();</script>
</form>

View File

@ -1,83 +0,0 @@
{extend name='admin@main'}
{block name="button"}
{if auth("add")}
<button data-modal='{:url("add")}' data-title="添加企业员工" class='layui-btn layui-btn-sm layui-btn-primary'>添加企业员工</button>
{/if}
{if auth("remove")}
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些员工吗?" class='layui-btn layui-btn-sm layui-btn-primary'>删除企业员工</button>
{/if}
{/block}
{block name="content"}
<div class="think-box-shadow">
{include file='user/index_search'}
<table class="layui-table" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='list-table-check-td think-checkbox'>
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
</th>
<th class='list-table-sort-td'>
<button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
</th>
<th class='text-left nowrap'>员工姓名</th>
<th class='text-left nowrap'>员工身份</th>
<th class='text-left nowrap'>库存账号</th>
<th class='text-center nowrap'>使用状态</th>
<th class='text-left nowrap'>添加时间</th>
<th class='text-left nowrap'></th>
</tr>
</thead>
{/notempty}
<tbody>
{foreach $list as $key=>$vo}
<tr data-dbclick>
<td class='list-table-check-td think-checkbox'>
<label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
</td>
<td class='list-table-sort-td'>
<label><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></label>
</td>
<td class='text-left nowrap'>{$vo.nickname|default=''}</td>
<td class='text-left nowrap'>{$vo.user_type|default='-'}</td>
<td class='text-left nowrap'>{$vo.svn_username|default='-'}</td>
<td class='text-center nowrap'>
{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{/eq}
{eq name='vo.status' value='1'}<span class="color-green">在职中</span>{/eq}
{eq name='vo.status' value='2'}<span class="color-desc">已离职</span>{/eq}
</td>
<td class='text-left nowrap'>
{$vo.create_at|format_datetime}
</td>
<td class='text-left nowrap'>
{if auth("edit")}
<a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑员工信息" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
{/if}
{if auth("state") and $vo.status neq 0}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
{elseif auth("state") and $vo.status neq 1 }
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">启 用</a>
{/if}
{if auth("remove")}
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该员工吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删 除</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

View File

@ -1,50 +0,0 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">员工姓名</label>
<div class="layui-input-inline">
<input name="nickname" value="{$Think.get.nickname|default=''}" placeholder="请输入员工姓名" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">仓库账号</label>
<div class="layui-input-inline">
<input name="svn_username" value="{$Think.get.svn_username|default=''}" placeholder="请输入仓库账号" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">员工状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'-- 全部状态 --','0'=>'禁用的员工','1'=>'正常的员工','2'=>'离职的员工'] as $k=>$v}
{eq name='Think.get.status' value='$k.""'}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">添加时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择添加时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>
<script>form.render()</script>

View File

@ -1,34 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\index\controller;
use library\Controller;
/**
* 应用入口
* Class Index
* @package app\index\controller
*/
class Index extends Controller
{
/**
* 入口跳转链接
*/
public function index()
{
$this->redirect('@admin/login');
}
}

View File

@ -1,63 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\controller;
use library\Controller;
/**
* 开放平台参数配置
* Class Config
* @package app\service\controller
*/
class Config extends Controller
{
/**
* 定义当前操作表名
* @var string
*/
public $table = 'WechatServiceConfig';
/**
* 显示参数配置
* @auth true
* @menu true
*/
public function index()
{
$this->title = '开放平台参数配置';
$this->fetch();
}
/**
* 修改参数配置
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->applyCsrfToken();
if ($this->request->isGet()) {
$this->fetch('form');
} else {
$post = $this->request->post();
foreach ($post as $k => $v) sysconf($k, $v);
$this->success('参数修改成功!');
}
}
}

View File

@ -1,164 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\controller;
use app\service\queue\WechatQueue;
use app\service\service\WechatService;
use library\Controller;
use think\Db;
use think\exception\HttpResponseException;
/**
* 微信粉丝管理
* Class Fans
* @package app\wechat\controller
*/
class Fans extends Controller
{
protected $appid = '';
/**
* 绑定数据表
* @var string
*/
protected $table = 'WechatFans';
/**
* 初始化函数
* Fans constructor.
*/
public function __construct()
{
parent::__construct();
$this->appid = input('appid', session('current_appid'));
if (empty($this->appid)) {
$this->where = ['status' => '1', 'service_type' => '2', 'is_deleted' => '0', 'verify_type' => '0'];
$this->appid = Db::name('WechatServiceConfig')->where($this->where)->value('authorizer_appid');
}
if (empty($this->appid)) {
$this->fetch('/not-auth');
} else {
session('current_appid', $this->appid);
}
if ($this->request->isGet()) {
$this->where = ['status' => '1', 'service_type' => '2', 'is_deleted' => '0', 'verify_type' => '0'];
$this->wechats = Db::name('WechatServiceConfig')->where($this->where)->order('id desc')->column('authorizer_appid,nick_name');
}
}
/**
* 微信粉丝管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '微信粉丝管理';
$query = $this->_query($this->table)->like('nickname')->equal('subscribe,is_black');
$query->dateBetween('subscribe_at')->where(['appid' => $this->appid])->order('subscribe_time desc')->page();
}
/**
* 列表数据处理
* @param array $data
*/
protected function _index_page_filter(array &$data)
{
$tags = Db::name('WechatFansTags')->column('id,name');
foreach ($data as &$user) {
$user['tags'] = [];
foreach (explode(',', $user['tagid_list']) as $tagid) {
if (isset($tags[$tagid])) $user['tags'][] = $tags[$tagid];
}
}
}
/**
* 批量拉黑粉丝
* @auth true
*/
public function setBlack()
{
try {
$this->applyCsrfToken();
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
WechatService::WeChatUser($this->appid)->batchBlackList($openids);
Db::name('WechatFans')->where(['appid' => $this->appid])->whereIn('openid', $openids)->update(['is_black' => '1']);
}
$this->success('拉黑粉丝信息成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
}
}
/**
* 取消拉黑粉丝
* @auth true
*/
public function delBlack()
{
try {
$this->applyCsrfToken();
foreach (array_chunk(explode(',', $this->request->post('openid')), 20) as $openids) {
WechatService::WeChatUser($this->appid)->batchUnblackList($openids);
Db::name('WechatFans')->where(['appid' => $this->appid])->whereIn('openid', $openids)->update(['is_black' => '0']);
}
$this->success('取消拉黑粉丝信息成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("取消拉黑粉丝信息失败,请稍候再试!{$e->getMessage()}");
}
}
/**
* 同步粉丝列表
* @auth true
*/
public function sync()
{
try {
sysoplog('微信管理', "创建微信[{$this->appid}]粉丝同步任务");
sysqueue("同步[{$this->appid}]粉丝列表", WechatQueue::URI, 0, ['appid' => $this->appid], 0);
$this->success('创建同步粉丝任务成功,需要时间来完成。<br>请到 系统管理 > 任务管理 查看执行进度!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("创建同步粉丝任务失败,请稍候再试!<br> {$e->getMessage()}");
}
}
/**
* 删除粉丝信息
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->applyCsrfToken();
$this->_delete($this->table);
}
}

View File

@ -1,166 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\controller;
use app\service\service\BuildService;
use app\service\service\WechatService;
use library\Controller;
use think\Db;
use think\exception\HttpResponseException;
/**
* 公众授权管理
* @package app\service\controller
*/
class Index extends Controller
{
/**
* 绑定数据表
* @var string
*/
public $table = 'WechatServiceConfig';
/**
* 公众授权管理
* @auth true
* @menu true
* @return string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->applyCsrfToken();
$this->title = '公众授权管理';
$query = $this->_query($this->table)->like('authorizer_appid,nick_name,principal_name');
$query = $query->equal('service_type,status')->dateBetween('create_at');
$query->where(['is_deleted' => '0'])->order('id desc')->page();
}
/**
* 清理调用次数
* @auth true
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function clearQuota()
{
$appid = input('appid');
$result = WechatService::WeChatLimit($appid)->clearQuota();
if (empty($result['errcode']) && $result['errmsg'] === 'ok') {
$this->success('接口调用次数清零成功!');
} elseif (isset($result['errmsg'])) {
$this->error('接口调用次数清零失败,请稍候再试!' . $result['errmsg']);
} else {
$this->error('接口调用次数清零失败,请稍候再试!');
}
}
/**
* 同步指定授权公众号
* @auth true
*/
public function sync()
{
try {
$appid = $this->request->get('appid');
$where = ['authorizer_appid' => $appid, 'is_deleted' => '0', 'status' => '1'];
$author = Db::name('WechatServiceConfig')->where($where)->find();
if (empty($author)) $this->error('无效的授权信息,请同步其它公众号!');
$data = BuildService::filter(WechatService::service()->getAuthorizerInfo($appid));
$data['authorizer_appid'] = $appid;
$where = ['authorizer_appid' => $data['authorizer_appid']];
$appkey = Db::name('WechatServiceConfig')->where($where)->value('appkey');
if (empty($appkey)) $data['appkey'] = md5(uniqid('', true));
if (data_save('WechatServiceConfig', $data, 'authorizer_appid')) {
$this->success('更新公众号授权成功!', '');
}
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("获取授权信息失败,请稍候再试!<br>{$e->getMessage()}");
}
}
/**
* 同步所有授权公众号
* @auth true
*/
public function syncall()
{
try {
$wechat = WechatService::service();
$result = $wechat->getAuthorizerList();
foreach ($result['list'] as $item) if (!empty($item['refresh_token']) && !empty($item['auth_time'])) {
$data = BuildService::filter($wechat->getAuthorizerInfo($item['authorizer_appid']));
$data['is_deleted'] = '0';
$data['authorizer_appid'] = $item['authorizer_appid'];
$data['authorizer_refresh_token'] = $item['refresh_token'];
$data['create_at'] = date('Y-m-d H:i:s', $item['auth_time']);
$where = ['authorizer_appid' => $data['authorizer_appid']];
$appkey = Db::name('WechatServiceConfig')->where($where)->value('appkey');
if (empty($appkey)) $data['appkey'] = md5(uniqid('', true));
if (!data_save('WechatServiceConfig', $data, 'authorizer_appid')) {
$this->error('获取授权信息失败,请稍候再试!', '');
}
}
$this->success('同步所有授权信息成功!', '');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $e) {
$this->error("同步授权失败,请稍候再试!<br>{$e->getMessage()}");
}
}
/**
* 删除公众号授权
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->applyCsrfToken();
$this->_delete($this->table);
}
/**
* 禁用公众号授权
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用公众号授权
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->applyCsrfToken();
$this->_save($this->table, ['status' => '1']);
}
}

View File

@ -1,155 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\controller\api;
use app\service\service\WechatService;
use think\Controller;
use think\Db;
/**
* 获取微信SDK实例对象
* Class Instance
* @package app\wechat\controller
*/
class Client extends Controller
{
/**
* 当前配置
* @var string
*/
protected $config = [];
/**
* 当前APPID
* @var string
*/
protected $appid = '';
/**
* 接口实例名称
* @var string
*/
protected $name = '';
/**
* 接口类型
* @var string
*/
protected $type = '';
/**
* 错误消息
* @var string
*/
protected $message = '';
/**
* 启动Yar接口服务
* @param string $param AppName-AppId-AppKey
* @return string
*/
public function yar($param)
{
try {
$instance = $this->create($param);
$service = new \Yar_Server(empty($instance) ? $this : $instance);
$service->handle();
} catch (\Exception $e) {
return $e->getMessage();
}
}
/**
* 启动SOAP接口服务
* @param string $param AppName-AppId-AppKey
* @return string
*/
public function soap($param)
{
try {
$instance = $this->create($param);
$service = new \SoapServer(null, ['uri' => strtolower($this->name)]);
$service->setObject(empty($instance) ? $this : $instance);
$service->handle();
} catch (\Exception $e) {
return $e->getMessage();
}
}
/**
* 创建接口服务
* @param string $token
* @return \WeChat\Oauth|\WeChat\Pay|\WeChat\Receive|\WeChat\Script|\WeChat\User|\WeOpen\Service
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\Exception
*/
private function create($token)
{
if ($this->auth($token)) {
$weminiClassName = 'Account,Basic,Code,Domain,Tester,User,Crypt,Plugs,Poi,Qrcode,Template,Total,Delivery,Image,Logistics,Message,Ocr,Security,Soter';
$wechatClassName = 'Card,Custom,Limit,Media,Menu,Oauth,Pay,Product,Qrcode,Receive,Scan,Script,Shake,Tags,Template,User,Wifi';
if ($this->type === 'wechat' && stripos($wechatClassName, $this->name) !== false) {
$instance = WechatService::instance($this->name, $this->appid, 'WeChat');
} elseif ($this->type === 'wemini' && stripos($weminiClassName, $this->name) !== false) {
$instance = WechatService::instance($this->name, $this->appid, 'WeMini');
} elseif (stripos('Service,MiniApp', $this->name) !== false) {
$instance = WechatService::instance($this->name, $this->appid, 'WeOpen');
} elseif (stripos('Wechat,Config,Handler', $this->name) !== false) {
$className = "\\app\\service\\handler\\WechatHandler";
$instance = new $className($this->config);
}
if (!empty($instance)) return $instance;
}
throw new \think\Exception($this->message);
}
/**
* 加载微信实例对象
* @param string $token 数据格式 name|appid|appkey
* @return bool
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function auth($token = '')
{
list($this->name, $this->appid, $appkey, $this->type) = explode('-', $token . '---');
if (empty($this->name) || empty($this->appid) || empty($appkey)) {
$this->message = '缺少必要的参数AppId或AppKey';
return false;
}
$where = ['authorizer_appid' => $this->appid, 'status' => '1', 'is_deleted' => '0'];
$this->config = Db::name('WechatServiceConfig')->where($where)->find();
if (empty($this->config)) {
$this->message = '无效的微信绑定对象';
return false;
}
if (strtolower($this->config['appkey']) !== strtolower($appkey)) {
$this->message = '授权AppId与AppKey不匹配';
return false;
}
$this->message = '';
$this->name = ucfirst(strtolower($this->name));
$this->type = strtolower(empty($this->type) ? 'WeChat' : $this->type);
Db::name('WechatServiceConfig')->where($where)->setInc('total', 1);
return true;
}
}

View File

@ -1,184 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\controller\api;
use app\service\service\BuildService;
use app\service\service\WechatService;
use library\Controller;
use think\Db;
/**
* 微信推送事件处理
*
* @author Anyon <zoujingli@qq.com>
* @date 2016/10/18 12:38
*/
class Push extends Controller
{
/**
* 微信API推送事件处理
* @param string $appid
* @return string
* @throws \WeChat\Exceptions\InvalidDecryptException
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function notify($appid)
{
if (in_array($appid, ['wx570bc396a51b8ff8', 'wxd101a85aa106f53e'])) {
# 全网发布接口测试
return \app\service\handler\PublishHandler::handler($appid);
} else {
# 接口类正常服务
return \app\service\handler\ReceiveHandler::handler($appid);
}
}
/**
* 一、处理服务推送Ticket
* 二、处理取消公众号授权
* @return string
* @throws \think\Exception
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\exception\PDOException
*/
public function ticket()
{
try {
$server = WechatService::service();
if (!($data = $server->getComonentTicket())) {
return "Ticket event handling failed.";
}
} catch (\Exception $e) {
return "Ticket event handling failed, {$e->getMessage()}";
}
if (!empty($data['AuthorizerAppid']) && isset($data['InfoType'])) {
# 授权成功通知
if ($data['InfoType'] === 'authorized') {
Db::name('WechatServiceConfig')->where(['authorizer_appid' => $data['AuthorizerAppid']])->update(['is_deleted' => '0']);
}
# 接收取消授权服务事件
if ($data['InfoType'] === 'unauthorized') {
Db::name('WechatServiceConfig')->where(['authorizer_appid' => $data['AuthorizerAppid']])->update(['is_deleted' => '1']);
}
# 授权更新通知
if ($data['InfoType'] === 'updateauthorized') {
$_GET['auth_code'] = $data['PreAuthCode'];
$this->applyAuth($server);
}
}
return 'success';
}
/**
* 网页授权
* @throws \think\Exception
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function oauth()
{
list($mode, $appid, $enurl, $sessid) = [
$this->request->get('mode'), $this->request->get('state'),
$this->request->get('enurl'), $this->request->get('sessid'),
];
$service = WechatService::service();
$result = $service->getOauthAccessToken($appid);
if (empty($result['openid'])) throw new \think\Exception('网页授权失败, 无法进一步操作!');
cache("{$appid}_{$sessid}_openid", $result['openid'], 3600);
if (!empty($mode)) {
$wechat = new \WeChat\Oauth($service->getConfig($appid));
$fans = $wechat->getUserInfo($result['access_token'], $result['openid']);
if (empty($fans)) throw new \think\Exception('网页授权信息获取失败, 无法进一步操作!');
cache("{$appid}_{$sessid}_fans", $fans, 3600);
}
redirect(decode($enurl), [], 301)->send();
}
/**
* 跳转到微信服务授权页面
* @param string $redirect
* @return string
* @throws \think\Exception
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\exception\PDOException
*/
public function auth($redirect = '')
{
$fromRedirect = decode($redirect);
if (empty($redirect) || empty($fromRedirect)) {
return '请传入回跳Redirect参数 ( 请使用ENCODE加密 )';
}
# 预授权码不为空,则表示可以进行授权处理
$service = WechatService::service();
if (($auth_code = $this->request->get('auth_code'))) {
return $this->applyAuth($service, $fromRedirect);
}
# 生成微信授权链接,使用刷新跳转到授权网页
$url = url("@service/api.push/auth/{$redirect}", false, true, true);
if (($redirect = $service->getAuthRedirect($url))) {
ob_clean();
header("Refresh:0;url={$redirect}");
return "<script>window.location.href='{$redirect}';</script><a href='{$redirect}'>跳转中...</a>";
}
# 生成微信授权链接失败
return "<h2>Failed to create authorization. Please return to try again.</h2>";
}
/**
* 公众号授权绑定数据处理
* @param \WeOpen\Service $service
* @param string|null $redirect 授权成功回跳地址
* @return string
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
private function applyAuth($service, $redirect = null)
{
// 通过授权code换取公众号信息
$result = $service->getQueryAuthorizerInfo();
if (empty($result['authorizer_appid'])) {
return "接收微信第三方平台授权失败! ";
}
// 重新通过接口查询公众号参数
if (!($update = array_merge($result, $service->getAuthorizerInfo($result['authorizer_appid'])))) {
return '获取授权数据失败, 请稍候再试!';
}
// 生成公众号授权参数
$update = array_merge(BuildService::filter($update), [
'status' => '1', 'is_deleted' => '0', 'expires_in' => time() + 7000, 'create_at' => date('y-m-d H:i:s'),
]);
// 微信接口APPKEY处理与更新
$config = Db::name('WechatServiceConfig')->where(['authorizer_appid' => $result['authorizer_appid']])->find();
$update['appkey'] = empty($config['appkey']) ? md5(uniqid('', true)) : $config['appkey'];
data_save('WechatServiceConfig', $update, 'authorizer_appid');
if (!empty($redirect)) { // 带上appid与appkey跳转到应用
$split = stripos($redirect, '?') > 0 ? '&' : '?';
$realurl = preg_replace(['/appid=\w+/i', '/appkey=\w+/i', '/(\?\&)$/i'], ['', '', ''], $redirect);
return redirect("{$realurl}{$split}appid={$update['authorizer_appid']}&appkey={$update['appkey']}");
}
}
}

View File

@ -1,69 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\handler;
use app\service\service\WechatService;
/**
* 第三方平台测试上线
*
* @author Anyon <zoujingli@qq.com>
* @date 2016/10/27 14:14
*/
class PublishHandler
{
/**
* 当前微信APPID
* @var string
*/
protected static $appid;
/**
* 事件初始化
* @param string $appid
* @return string
* @throws \WeChat\Exceptions\InvalidDecryptException
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public static function handler($appid)
{
try {
$wechat = WechatService::WeChatReceive($appid);
} catch (\Exception $e) {
return "Wechat message handling failed, {$e->getMessage()}";
}
/* 分别执行对应类型的操作 */
switch (strtolower($wechat->getMsgType())) {
case 'text':
$receive = $wechat->getReceive();
if ($receive['Content'] === 'TESTCOMPONENT_MSG_TYPE_TEXT') {
return $wechat->text('TESTCOMPONENT_MSG_TYPE_TEXT_callback')->reply([], true);
} else {
$key = str_replace("QUERY_AUTH_CODE:", '', $receive['Content']);
WechatService::service()->getQueryAuthorizerInfo($key);
return $wechat->text("{$key}_from_api")->reply([], true);
}
case 'event':
$receive = $wechat->getReceive();
return $wechat->text("{$receive['Event']}from_callback")->reply([], true);
default:
return 'success';
}
}
}

View File

@ -1,69 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\handler;
use app\service\service\WechatService;
use think\Db;
/**
* 微信推送消息处理
*
* @author Anyon <zoujingli@qq.com>
* @date 2016/10/27 14:14
*/
class ReceiveHandler
{
/**
* 事件初始化
* @param string $appid
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\Exception
*/
public static function handler($appid)
{
try {
$wechat = WechatService::WeChatReceive($appid);
} catch (\Exception $e) {
return "Wechat message handling failed, {$e->getMessage()}";
}
// 验证微信配置信息
$config = Db::name('WechatServiceConfig')->where(['authorizer_appid' => $appid])->find();
if (empty($config) || empty($config['appuri'])) {
\think\facade\Log::error(($message = "微信{$appid}授权配置验证无效"));
return $message;
}
try {
list($data, $openid) = [$wechat->getReceive(), $wechat->getOpenid()];
if (isset($data['EventKey']) && is_object($data['EventKey'])) $data['EventKey'] = (array)$data['EventKey'];
$input = ['openid' => $openid, 'appid' => $appid, 'receive' => serialize($data), 'encrypt' => intval($wechat->isEncrypt())];
if (is_string($result = http_post($config['appuri'], $input, ['timeout' => 30]))) {
if (is_array($json = json_decode($result, true))) {
return $wechat->reply($json, true, $wechat->isEncrypt());
} else {
return $result;
}
}
} catch (\Exception $e) {
\think\facade\Log::error("微信{$appid}接口调用异常,{$e->getMessage()}");
}
return 'success';
}
}

View File

@ -1,161 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\handler;
use app\service\service\WechatService as WechatLogic;
use think\Db;
/**
* 微信网页授权接口
* Class WechatHandler
* @package app\wechat\handler
* @author Anyon <zoujingli@qq.com>
*/
class WechatHandler
{
/**
* 当前微信APPID
* @var string
*/
protected $appid;
/**
* 当前微信配置
* @var array
*/
protected $config;
/**
* 错误消息
* @var string
*/
protected $message;
/**
* Wechat constructor.
* @param array $config
*/
public function __construct($config = [])
{
$this->config = $config;
$this->appid = isset($config['authorizer_appid']) ? $config['authorizer_appid'] : '';
}
/**
* 检查微信配置服务初始化状态
* @return boolean
* @throws \think\Exception
*/
private function checkInit()
{
if (!empty($this->config)) return true;
throw new \think\Exception('Wechat Please bind Wechat first');
}
/**
* 获取当前公众号配置
* @return array|boolean
* @throws \think\Exception
*/
public function getConfig()
{
$this->checkInit();
$info = Db::name('WechatServiceConfig')->where(['authorizer_appid' => $this->appid])->find();
if (empty($info)) return false;
if (isset($info['id'])) unset($info['id']);
return $info;
}
/**
* 设置微信接口通知URL地址
* @param string $notifyUri 接口通知URL地址
* @return boolean
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function setApiNotifyUri($notifyUri)
{
$this->checkInit();
if (empty($notifyUri)) throw new \think\Exception('请传入微信通知URL');
list($where, $data) = [['authorizer_appid' => $this->appid], ['appuri' => $notifyUri]];
return Db::name('WechatServiceConfig')->where($where)->update($data) !== false;
}
/**
* 更新接口Appkey(成功返回新的Appkey)
* @return bool|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function updateApiAppkey()
{
$this->checkInit();
$data = ['appkey' => md5(uniqid())];
Db::name('WechatServiceConfig')->where(['authorizer_appid' => $this->appid])->update($data);
return $data['appkey'];
}
/**
* 获取公众号的配置参数
* @param string $name 参数名称
* @return array|string
* @throws \think\Exception
*/
public function config($name = null)
{
$this->checkInit();
return WechatLogic::WeChatScript($this->appid)->config->get($name);
}
/**
* 微信网页授权
* @param string $sessid 当前会话id(可用session_id()获取)
* @param string $selfUrl 当前会话URL地址(需包含域名的完整URL地址)
* @param int $fullMode 网页授权模式(0静默模式,1高级授权)
* @return array|bool
* @throws \think\Exception
*/
public function oauth($sessid, $selfUrl, $fullMode = 0)
{
$this->checkInit();
$fans = cache("{$this->appid}_{$sessid}_fans");
$openid = cache("{$this->appid}_{$sessid}_openid");
if (!empty($openid) && (empty($fullMode) || !empty($fans))) {
return ['openid' => $openid, 'fans' => $fans, 'url' => ''];
}
$service = WechatLogic::service();
$mode = empty($fullMode) ? 'snsapi_base' : 'snsapi_userinfo';
$url = url('@service/api.push/oauth', '', true, true);
$params = ['mode' => $fullMode, 'sessid' => $sessid, 'enurl' => encode($selfUrl)];
$authurl = $service->getOauthRedirect($this->appid, $url . '?' . http_build_query($params), $mode);
return ['openid' => $openid, 'fans' => $fans, 'url' => $authurl];
}
/**
* 微信网页JS签名
* @param string $url 当前会话URL地址(需包含域名的完整URL地址)
* @return array|boolean
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\Exception
*/
public function jsSign($url)
{
$this->checkInit();
return WechatLogic::WeChatScript($this->appid)->getJsSign($url);
}
}

View File

@ -1,89 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\queue;
use app\admin\queue\Queue;
use app\service\service\WechatService;
use app\wechat\service\FansService;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* Class Jobs
* @package app\wechat
*/
class WechatQueue extends Queue
{
/**
* 当前类名
* @var string
*/
const URI = self::class;
/**
* 当前操作APPID
* @var string
*/
protected $appid;
/**
* 执行任务
* @param Input $input
* @param Output $output
* @param array $data
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function execute(Input $input, Output $output, array $data = [])
{
$this->appid = $data['appid'];
$wechat = WechatService::WeChatUser($this->appid);
// 获取远程粉丝
list($next, $done) = ['', 0];
$output->writeln('Start synchronizing fans from the Wechat server');
while (!is_null($next) && is_array($result = $wechat->getUserList($next)) && !empty($result['data']['openid'])) {
$done += $result['count'];
foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
if (is_array($list = $wechat->getBatchUserInfo($chunk)) && !empty($list['user_info_list'])) {
foreach ($list['user_info_list'] as $user) FansService::set($user, $this->appid);
}
}
$next = $result['total'] > $done ? $result['next_openid'] : null;
}
// 同步粉丝黑名单
list($next, $done) = ['', 0];
$output->writeln('Start synchronizing black from the Wechat server');
while (!is_null($next) && is_array($result = $wechat->getBlackList($next)) && !empty($result['data']['openid'])) {
$done += $result['count'];
foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
$where = [['is_black', 'eq', '0'], ['openid', 'in', $chunk]];
Db::name('WechatFans')->where($where)->update(['is_black' => '1']);
}
$next = $result['total'] > $done ? $result['next_openid'] : null;
}
// 同步粉丝标签列表
$output->writeln('Start synchronizing tags from the Wechat server');
if (is_array($list = WechatService::WeChatTags($this->appid)->getTags()) && !empty($list['tags'])) {
foreach ($list['tags'] as &$tag) $tag['appid'] = $this->appid;
Db::name('WechatFansTags')->where('1=1')->delete();
Db::name('WechatFansTags')->insertAll($list['tags']);
}
}
}

View File

@ -1,53 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\service;
/**
* 授权数据处理
* Class Build
* @package app\service\service
*/
class BuildService
{
/**
* 授权数据过滤转换处理
* @param array $info
* @return mixed
*/
public static function filter(array $info)
{
if (isset($info['func_info'])) $info['func_info'] = join(',', array_map(function ($tmp) {
return $tmp['funcscope_category']['id'];
}, $info['func_info']));
$info['verify_type_info'] = join(',', $info['verify_type_info']);
$info['service_type_info'] = join(',', $info['service_type_info']);
$info['business_info'] = json_encode($info['business_info'], JSON_UNESCAPED_UNICODE);
// 微信类型: 0 代表订阅号, 2 代表服务号, 3 代表小程序
$info['service_type'] = intval($info['service_type_info']) === 2 ? 2 : 0;
if (!empty($info['MiniProgramInfo'])) {
// 微信类型: 0 代表订阅号, 2 代表服务号, 3 代表小程序
$info['service_type'] = 3;
// 小程序信息
$info['miniprograminfo'] = json_encode($info['MiniProgramInfo'], JSON_UNESCAPED_UNICODE);
}
unset($info['MiniProgramInfo']);
// 微信认证: -1 代表未认证, 0 代表微信认证
$info['verify_type'] = intval($info['verify_type_info']) !== 0 ? -1 : 0;
return $info;
}
}

View File

@ -1,83 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\service;
use library\tools\Http;
use think\Exception;
/**
* 小米消息服务
* Class MichatService
* @package app\service\service
*/
class MichatService
{
const URI = 'https://mimc.chat.xiaomi.net';
const BIZ_TYPE_PING = 'PING';
const BIZ_TYPE_POND = 'PONG';
const BIZ_TYPE_TEXT = 'TEXT';
const BIZ_TYPE_PIC_FILE = 'PIC_FILE';
const BIZ_TYPE_BIN_FILE = 'BIN_FILE';
const BIZ_TYPE_AUDIO_FILE = 'AUDIO_FILE';
const MSG_TYPE_BASE64 = 'base64';
/**
* 给指定账号推送消息内容
* @param string $from 消息来源
* @param string $to 消息目标
* @param string $message 消息内容
* @return bool|string
* @throws Exception
* @throws \think\exception\PDOException
*/
public static function push($from, $to, $message)
{
return self::post('/api/push/p2p/', [
'appId' => sysconf('michat_appid'),
'appKey' => sysconf('michat_appkey'),
'appSecret' => sysconf('michat_appsecert'),
'fromAccount' => $from,
'fromResource' => $from,
'toAccount' => $to,
'msg' => base64_encode($message),
'msgType' => 'base64',
'bizType' => '',
'isStore' => false,
]);
}
/**
* POST提交消息数据
* @param string $api 接口地址
* @param array $data 接口数据
* @return bool|string
* @throws Exception
*/
private static function post($api, array $data)
{
$result = json_decode(Http::request('post', self::URI . $api, [
'data' => json_encode($data, JSON_UNESCAPED_UNICODE),
'headers' => ['Content-Type: application/json'],
]), true);
if (isset($result['code']) && intval($result['code']) === 200) {
return $result['data'];
} else {
throw new Exception($result['message'], $result['code']);
}
}
}

View File

@ -1,158 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\service\service;
use think\Db;
/**
* 微信数据服务
* Class WechatService
* @package app\service\service
* @method \WeChat\Card WeChatCard($appid) static 微信卡券管理
* @method \WeChat\Custom WeChatCustom($appid) static 微信客服消息
* @method \WeChat\Limit WeChatLimit($appid) static 接口调用频次限制
* @method \WeChat\Media WeChatMedia($appid) static 微信素材管理
* @method \WeChat\Menu WeChatMenu($appid) static 微信菜单管理
* @method \WeChat\Oauth WeChatOauth($appid) static 微信网页授权
* @method \WeChat\Pay WeChatPay($appid) static 微信支付商户
* @method \WeChat\Product WeChatProduct($appid) static 微信商店管理
* @method \WeChat\Qrcode WeChatQrcode($appid) static 微信二维码管理
* @method \WeChat\Receive WeChatReceive($appid) static 微信推送管理
* @method \WeChat\Scan WeChatScan($appid) static 微信扫一扫接入管理
* @method \WeChat\Script WeChatScript($appid) static 微信前端支持
* @method \WeChat\Shake WeChatShake($appid) static 微信揺一揺周边
* @method \WeChat\Tags WeChatTags($appid) static 微信用户标签管理
* @method \WeChat\Template WeChatTemplate($appid) static 微信模板消息
* @method \WeChat\User WeChatUser($appid) static 微信粉丝管理
* @method \WeChat\Wifi WeChatWifi($appid) static 微信门店WIFI管理
*
* ----- WeMini -----
* @method \WeMini\Account WeMiniAccount($appid) static 小程序账号管理
* @method \WeMini\Basic WeMiniBasic($appid) static 小程序基础信息设置
* @method \WeMini\Code WeMiniCode($appid) static 小程序代码管理
* @method \WeMini\Domain WeMiniDomain($appid) static 小程序域名管理
* @method \WeMini\Tester WeMinitester($appid) static 小程序成员管理
* @method \WeMini\User WeMiniUser($appid) static 小程序帐号管理
* --------------------
* @method \WeMini\Crypt WeMiniCrypt($options = []) static 小程序数据加密处理
* @method \WeMini\Delivery WeMiniDelivery($options = []) static 小程序即时配送
* @method \WeMini\Image WeMiniImage($options = []) static 小程序图像处理
* @method \WeMini\Logistics WeMiniLogistics($options = []) static 小程序物流助手
* @method \WeMini\Message WeMiniMessage($options = []) static 小程序动态消息
* @method \WeMini\Ocr WeMiniOcr($options = []) static 小程序ORC服务
* @method \WeMini\Plugs WeMiniPlugs($options = []) static 小程序插件管理
* @method \WeMini\Poi WeMiniPoi($options = []) static 小程序地址管理
* @method \WeMini\Qrcode WeMiniQrcode($options = []) static 小程序二维码管理
* @method \WeMini\Security WeMiniSecurity($options = []) static 小程序内容安全
* @method \WeMini\Soter WeMiniSoter($options = []) static 小程序生物认证
* @method \WeMini\Template WeMiniTemplate($options = []) static 小程序模板消息支持
* @method \WeMini\Total WeMiniTotal($options = []) static 小程序数据接口
*
* ----- WePay -----
* @method \WePay\Bill WePayBill($appid) static 微信商户账单及评论
* @method \WePay\Order WePayOrder($appid) static 微信商户订单
* @method \WePay\Refund WePayRefund($appid) static 微信商户退款
* @method \WePay\Coupon WePayCoupon($appid) static 微信商户代金券
* @method \WePay\Redpack WePayRedpack($appid) static 微信红包支持
* @method \WePay\Transfers WePayTransfers($appid) static 微信商户打款到零钱
* @method \WePay\TransfersBank WePayTransfersBank($appid) static 微信商户打款到银行卡
*
* ----- WeOpen -----
* @method \WeOpen\Login login() static 第三方微信登录
* @method \WeOpen\Service service() static 第三方服务
*
* ----- ThinkService -----
* @method mixed wechat() static 第三方微信工具
* @method mixed config() static 第三方配置工具
*/
class WechatService
{
/**
* 接口类型模式
* @var string
*/
private static $type = 'WeChat';
/**
* 实例微信对象
* @param string $name
* @param string $appid 授权公众号APPID
* @param string $type 将要获取SDK类型
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public static function instance($name, $appid = '', $type = null)
{
$config = [
'cache_path' => env('runtime_path') . 'wechat',
'component_appid' => sysconf('component_appid'),
'component_token' => sysconf('component_token'),
'component_appsecret' => sysconf('component_appsecret'),
'component_encodingaeskey' => sysconf('component_encodingaeskey'),
];
// 注册授权公众号 AccessToken 处理
$config['GetAccessTokenCallback'] = function ($authorizerAppid) use ($config) {
$where = ['authorizer_appid' => $authorizerAppid];
if (!($refreshToken = Db::name('WechatServiceConfig')->where($where)->value('authorizer_refresh_token'))) {
throw new \think\Exception('The WeChat information is not configured.', '404');
}
$open = new \WeOpen\MiniApp($config);
$result = $open->refreshAccessToken($authorizerAppid, $refreshToken);
if (empty($result['authorizer_access_token']) || empty($result['authorizer_refresh_token'])) {
throw new \think\Exception($result['errmsg'], '0');
}
Db::name('WechatServiceConfig')->where($where)->update([
'authorizer_access_token' => $result['authorizer_access_token'],
'authorizer_refresh_token' => $result['authorizer_refresh_token'],
]);
return $result['authorizer_access_token'];
};
$app = new \WeOpen\MiniApp($config);
if (in_array(strtolower($name), ['service', 'miniapp'])) {
return $app;
}
if (!in_array($type, ['WeChat', 'WeMini'])) {
$type = self::$type;
}
return $app->instance($name, $appid, $type);
}
/**
* 静态初始化对象
* @param string $name
* @param array $arguments
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public static function __callStatic($name, $arguments)
{
if (substr($name, 0, 6) === 'WeMini') {
self::$type = 'WeMini';
$name = substr($name, 6);
} elseif (substr($name, 0, 6) === 'WeChat') {
self::$type = 'WeChat';
$name = substr($name, 6);
} elseif (substr($name, 0, 5) === 'WePay') {
self::$type = 'WePay';
$name = substr($name, 5);
}
return self::instance($name, isset($arguments[0]) ? $arguments[0] : '', self::$type);
}
}

View File

@ -1,44 +0,0 @@
<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
<div class="layui-card-body padding-left-40">
<div class="layui-form-item">
<label class="relative block">
<span class="color-green font-w7">开放平台服务 AppID</span>
<input name="component_appid" required pattern="^.{18}$" maxlength="18" placeholder="请输入18位开放平台服务AppID" value="{:sysconf('component_appid')}" class="layui-input">
</label>
<p class="help-block">开放平台服务 AppID需要在微信开放平台获取</p>
</div>
<div class="layui-form-item">
<label class="relative block">
<span class="color-green font-w7">开放平台服务 AppSecret</span>
<input name="component_appsecret" required pattern="^.{32}$" maxlength="32" placeholder="请输入32位开放平台服务AppSecret" value="{:sysconf('component_appsecret')}" class="layui-input">
</label>
<p class="help-block">开放平台服务 AppSecret需要在微信开放平台获取</p>
</div>
<div class="layui-form-item">
<label class="relative block">
<span class="color-green font-w7">开放平台消息校验 Token</span>
<input name="component_token" required placeholder="请输入微信消息校验Token" value="{:sysconf('component_token')}" class="layui-input">
</label>
<p class="help-block">开发者在代替微信接收到消息时,用此 Token 来校验消息</p>
</div>
<div class="layui-form-item">
<label class="relative block">
<span class="color-green font-w7">开放平台消息加解密 AesKey</span>
<input name="component_encodingaeskey" required pattern="^.{43}$" maxlength="43" placeholder="请输入43位微信消息加解密Key" value="{:sysconf('component_encodingaeskey')}" class="layui-input">
</label>
<p class="help-block">在代替微信收发消息时使用必须是长度为43位字母和数字组合的字符串</p>
</div>
<div class="hr-line-dashed"></div>
<div class="text-center padding-bottom-15 margin-bottom-20">
<button class="layui-btn" type="submit">保存配置</button>
</div>
</div>
</form>

View File

@ -1,113 +0,0 @@
{extend name="admin@main"}
{block name="button"}
{if auth("edit")}
<button data-modal="{:url('edit')}" class='layui-btn layui-btn-sm layui-btn-primary'>配置平台参数</button>
{/if}
{/block}
{block name="content"}
<div class="relative">
<div class="think-box-shadow border-0 margin-bottom-20">
强烈建议安装 YAR 扩展来实现接口通信SOAP 不能正常显示接口的异常信息
</div>
<div class="think-box-shadow padding-right-40 padding-left-40">
<div class="layui-row layui-col-space18">
<div class="layui-col-md6">
<div class="layui-form-item">
<span class="color-green font-w7">开放平台服务</span>
<span class="color-desc margin-left-5">AppID</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:sysconf('component_appid')}">
<a data-copy="{:sysconf('component_appid')}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">开放平台服务 AppID需要在微信开放平台获取</p>
</div>
<div class="layui-form-item">
<span class="color-green font-w7">开放平台服务</span>
<span class="color-desc margin-left-5">AppSecret</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:sysconf('component_appsecret')}">
<a data-copy="{:sysconf('component_appsecret')}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">开放平台服务 AppSecret需要在微信开放平台获取</p>
</div>
<div class="layui-form-item">
<span class="color-green font-w7">开放平台消息校验</span>
<span class="color-desc margin-left-5">Token</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:sysconf('component_token')}">
<a data-copy="{:sysconf('component_token')}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">开发者在代替微信接收到消息时,用此 Token 来校验消息</p>
</div>
<div class="layui-form-item">
<span class="color-green font-w7">开放平台消息加解密</span>
<span class="color-desc margin-left-5">AesKey</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:sysconf('component_encodingaeskey')}">
<a data-copy="{:sysconf('component_encodingaeskey')}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">在代替微信收发消息时使用必须是长度为43位字母和数字组合的字符串</p>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<p class="color-green font-w7">授权发起页域名</p>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:request()->host()}">
<a data-copy="{:request()->host()}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">从本域名跳转到登录授权页才可以完成登录授权,无需填写域名协议前缀</p>
</div>
<div class="layui-form-item">
<span class="color-green font-w7">授权事件接收地址</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/ticket','',false,true)}">
<a data-copy="{:url('@service/api.push/ticket','',false,true)}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">用于接收取消授权通知、授权成功通知、授权更新通知、接收 TICKET 凭据</p>
</div>
<div class="layui-form-item">
<span class="color-green font-w7">微信消息与事件接收</span>
<label class="relative block">
<input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/notify/\$APPID\$','',false,true)}">
<a data-copy="{:url('@service/api.push/notify/\$APPID\$','',false,true)}" class="fa fa-copy right-btn"></a>
</label>
<p class="help-block">通过该 URL 接收微信消息和事件推送,$APPID$ 将被替换为微信 AppId</p>
</div>
<div class="layui-form-item">
<p class="color-green font-w7">客户端系统 Yar 模块接口</p>
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/yar/PARAM','',false,true)}"></label>
<p class="help-block">客户端 Yar 接口PARAM 规则 AppName-AppId-AppKey-AppType</p>
</div>
<div class="layui-form-item">
<p class="color-green font-w7">客户端系统 Soap 模块接口</p>
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/soap/PARAM','',false,true)}"></label>
<p class="help-block">客户端 Soap 接口PARAM 规则 AppName-AppId-AppKey-AppType</p>
</div>
</div>
</div>
</div>
</div>
{/block}
{block name='style'}
<style>
.right-btn {
top: 0;
right: 0;
width: 38px;
height: 38px;
display: inline-block;
position: absolute;
text-align: center;
line-height: 38px;
}
</style>
{/block}

View File

@ -1,98 +0,0 @@
{extend name='admin@main'}
{block name="button"}
{if auth("service/fans/setblack")}
<button data-action='{:url("setblack")}' data-rule="openid#{key}" data-csrf="{:systoken('service/fans/setblack')}" class='layui-btn layui-btn-sm layui-btn-primary'>批量拉黑</button>
{/if}
{if auth("service/fans/delblack")}
<button data-action='{:url("delblack")}' data-rule="openid#{key}" data-csrf="{:systoken('service/fans/delblack')}" class='layui-btn layui-btn-sm layui-btn-primary'>取消拉黑</button>
{/if}
{if auth("service/fans/sync")}
<button data-load='{:url("sync")}' class='layui-btn layui-btn-sm layui-btn-primary'>同步粉丝</button>
{/if}
{/block}
{block name="content"}
<div class="think-box-shadow">
{include file='fans/index_search'}
<table class="layui-table margin-top-10" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
<th width="180px" class='text-left nowrap'>微信昵称</th>
<th width="180px" class="text-left nowrap">粉丝标签</th>
<th width="150px" class='text-left nowrap'>性别语言</th>
<th width="180px" class='text-left nowrap'>关注时间</th>
<th width="80px"></th>
<th></th>
</tr>
</thead>
{/notempty}
<tbody>
{foreach $list as $key=>$vo}
<tr>
<td class='list-table-check-td think-checkbox'>
<input class="list-check-box" value='{$vo.openid}' type='checkbox'>
</td>
<td class='text-left nowrap relative layui-elip'>
<img src="{$vo.headimgurl|default=''}" onerror="$(this).remove()" data-tips-image class="inline-block" style="width:40px;height:40px;vertical-align:top;margin-right:5px">
<div class="inline-block">
昵称:{$vo.nickname|default='--'}
<br>
区域:{$vo.country|default='--'} {$vo.province} {$vo.city}
</div>
</td>
<td class="text-left padding-0">
<div style="max-height:60px;overflow:auto">{foreach $vo.tags as $t}<p><span class="layui-badge layui-bg-cyan margin-right-5">{$t|default='--'}</span></p>{/foreach}</div>
</td>
<td class='text-left nowrap'>
性别:{switch name='vo.sex'}{case value='1'}男{/case}{case value='2'}女{/case}{default}未知{/switch}
<br>
语言:{$vo.language|raw}
</td>
<td class='text-left nowrap'>
日期:{$vo.subscribe_at|format_datetime|str_replace=' ','<br>时间:',###|raw}
</td>
<td class='text-center nowrap'>
{eq name='vo.subscribe' value='0'}
<span class="layui-badge">未关注</span>
{else}
<span class="layui-badge layui-bg-green">已关注</span>
{/eq}
<br>
{eq name='vo.is_black' value='0'}
<span class="layui-badge layui-bg-green">未拉黑</span>
{else}
<span class="layui-badge">已拉黑</span>
{/eq}
</td>
<td class="nowrap">
{eq name='vo.is_black' value='0'}
<!--{if auth("service/fans/setblack")}-->
<a class="margin-left-10 layui-btn layui-btn-normal layui-btn-sm" data-action="{:url('setblack')}" data-value="openid#{$vo.openid}" data-csrf="{:systoken('service/fans/setblack')}">拉 黑</a>
<!--{/if}-->
{else}
<!--{if auth("service/fans/delblack")}-->
<a class="margin-left-10 layui-btn layui-btn-normal layui-btn-sm" data-action="{:url('delblack')}" data-value="openid#{$vo.openid}" data-csrf="{:systoken('service/fans/delblack')}">拉 白</a>
<!--{/if}-->
{/eq}
{if auth("service/fans/remove")}
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该粉丝吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('service/fans/remove')}">删 除</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

View File

@ -1,76 +0,0 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">当前微信</label>
<div class="layui-input-inline">
<select class="layui-select" name="appid" lay-filter="appid" lay-search>
<!--{foreach $wechats as $k=>$v}-->
<!--{if $k eq $appid}-->
<option selected value="{$k}">{$v}</option>
<!--{else}-->
<option value="{$k}">{$v}</option>
<!--{/if}-->
<!--{/foreach}-->
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">微信昵称</label>
<div class="layui-input-inline">
<input name="nickname" value="{$Think.get.nickname|default=''}" placeholder="请输入微信昵称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">关注状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="subscribe">
{foreach [''=>'-- 全部 --','0'=>'显示未关注的粉丝','1'=>'显示已关注的粉丝'] as $k=>$v}
{eq name='Think.get.subscribe' value='$k.""'}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">拉黑状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="is_black">
{foreach [''=>'-- 全部 --','0'=>'显示未拉黑的粉丝','1'=>'显示已拉黑的粉丝'] as $k=>$v}
{eq name='Think.get.is_black' value='$k.""'}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">关注时间</label>
<div class="layui-input-inline">
<input data-date-range name="subscribe_at" value="{$Think.get.subscribe_at|default=''}" placeholder="请选择关注时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button id="SearchButton" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>
<script>
form.render();
form.on('select(appid)', function () {
$('#SearchButton').trigger('click');
});
</script>

View File

@ -1,84 +0,0 @@
{extend name="admin@main"}
{block name="button"}
{if auth("service/index/syncall")}
<button data-load="{:url('syncall')}" class='layui-btn layui-btn-sm layui-btn-primary'>同步所有授权</button>
{/if}
{/block}
{block name="content"}
<div class="think-box-shadow">
{include file='index/index_search'}
<table class="layui-table margin-top-10" lay-skin="line">
{notempty name='list'}
<thead>
<tr>
<th class='text-left nowrap' style="width:390px">接口信息</th>
<th class='text-left nowrap' style="width:120px">服务号信息</th>
<th class='text-left nowrap'></th>
<th class='text-left nowrap'></th>
</tr>
</thead>
{/notempty}
<tbody>
{foreach $list as $key=>$vo}
<tr>
<td class='text-left nowrap'>
<div class="inline-block text-top margin-right-5">
<img onerror="this.src='__ROOT__/static/theme/img/404_icon.png'" style="width:60px;height:60px" data-tips-text="微信头像" data-tips-image src="{$vo.head_img|default=''}">
</div>
<div class="inline-block">
公众号APPID{$vo.authorizer_appid}&nbsp;&nbsp;&nbsp;&nbsp;调用次数:{$vo.total}<br>
接口授权密钥:{$vo.appkey|default='<span class="color-desc">未生成接口服务密码, 请稍候授权绑定</span>'|raw}<br>
消息推送接口:{$vo.appuri|default='<span class="color-desc">未配置消息推送接口</span>'|raw}
</div>
</td>
<td class='text-left nowrap'>
<div class="inline-block text-top margin-right-5">
<img onerror="this.src='__ROOT__/static/theme/img/404_icon.png'" style="width:60px;height:60px" data-tips-text="微信二维码" data-tips-image src="{$vo.qrcode_url|local_image}">
</div>
<div class="inline-block">
昵称:{$vo.nick_name|default='<span class="color-desc">未获取到公众号昵称</span>'|raw}<br>
公司:{$vo.principal_name|default='<span class="color-desc">未获取到公司名字</span>'|raw}<br>
状态:{if $vo.service_type eq 2}服务号{elseif $vo.service_type eq 3}小程序{else}订阅号{/if} /
{$vo.verify_type == -1 ? '<span class="color-red">未认证</span>' : '<span class="color-green">已认证</span>'} /
{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">使用中</span>{/if}
</div>
</td>
<td class="text-left nowrap">
账号:{$vo.user_name|default='--'}<br>
日期:{$vo.create_at|format_datetime|str_replace=' ','<br>时间:',###|raw}
</td>
<td class='text-left nowrap'>
{if $vo.status eq 1 and auth("servce/index/forbid")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('forbid')}" data-csrf="{:systoken('service/index/forbid')}" data-value="id#{$vo.id};status#0">禁 用</a>
{elseif auth("servce/index/resume")}
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('resume')}" data-csrf="{:systoken('service/index/resume')}" data-value="id#{$vo.id};status#1">启 用</a>
{/if}
{if auth("service/index/sync")}
<a class="layui-btn layui-btn-sm" data-load='{:url("service/index/sync")}?appid={$vo.authorizer_appid}'>同 步</a>
{/if}
{if auth("service/index/remove")}
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该公众号吗?" data-action="{:url('remove')}" data-csrf="{:systoken('service/index/remove')}" data-value="id#{$vo.id}">删 除</a>
{/if}
{if auth("service/index/clearquota")}
<a class="layui-btn layui-btn-sm layui-btn-primary" data-confirm="每个公众号每个月有10次清零机会请谨慎使用" data-load='{:url("service/index/clearquota")}?appid={$vo.authorizer_appid}'>清 零</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

View File

@ -1,76 +0,0 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">微信标识</label>
<div class="layui-input-inline">
<input name="authorizer_appid" value="{$Think.get.authorizer_appid|default=''}" placeholder="请输入微信APPID" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">微信名称</label>
<div class="layui-input-inline">
<input name="nick_name" value="{$Think.get.nick_name|default=''}" placeholder="请输入微信名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">类型过滤</label>
<div class="layui-input-inline">
<select name="service_type" class="layui-select">
<option value="">- 全部 -</option>
{foreach ['0'=>'显示订阅号类型','2'=>'显示服务号类型','3'=>'显示小程序类型'] as $k=>$v}
<!--{if $k.'' eq $Think.get.service_type}-->
<option selected value="{$k}">{$v}</option>
<!--{else}-->
<option value="{$k}">{$v}</option>
<!--{/if}-->
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">使用状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="status">
{foreach [''=>'- 全部 -','0'=>'已禁用的账号','1'=>'使用中的账号'] as $k=>$v}
{eq name='Think.get.status' value='$k.""'}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/eq}
{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">注册公司</label>
<div class="layui-input-inline">
<input name="principal_name" value="{$Think.get.principal_name|default=''}" placeholder="请输入注册公司" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">授权时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{$Think.get.create_at|default=''}" placeholder="请选择授权时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
</fieldset>
<script>
window.form.render();
</script>

View File

@ -1 +0,0 @@
还没有授权,请授权公众号

View File

@ -1,196 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;
use think\exception\PDOException;
use We;
/**
* 商城数据处理指令
* Class AutoRun
* @package app\store\command
*/
class AutoRun extends Command
{
/**
* 配置指令信息
*/
protected function configure()
{
$this->setName('xclean:store')->setDescription('[清理]检查并处理商城任务');
}
/**
* 业务指令执行
* @param Input $input
* @param Output $output
* @throws Exception
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws DbException
* @throws PDOException
*/
protected function execute(Input $input, Output $output)
{
// 自动取消30分钟未支付的订单
$this->autoCancelOrder();
// 清理一天前未支付的订单
$this->autoRemoveOrder();
// 订单自动退款处理
// $this->autoRefundOrder();
// 提现自动打款处理
// $this->autoTransfer();
}
/**
* 自动取消30分钟未支付的订单
* @throws Exception
* @throws PDOException
*/
private function autoCancelOrder()
{
$datetime = $this->getDatetime('store_order_wait_time');
$where = [['status', 'in', ['1', '2']], ['pay_state', 'eq', '0'], ['create_at', '<', $datetime]];
$count = Db::name('StoreOrder')->where($where)->update([
'status' => '0',
'cancel_state' => '1',
'cancel_at' => date('Y-m-d H:i:s'),
'cancel_desc' => '30分钟未完成支付自动取消订单',
]);
if ($count > 0) {
$this->output->info("共计自动取消了30分钟未支付的{$count}笔订单!");
} else {
$this->output->comment('没有需要自动取消30分钟未支付的订单记录');
}
}
/**
* 清理一天前未支付的订单
* @throws Exception
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws DbException
* @throws PDOException
*/
private function autoRemoveOrder()
{
$datetime = $this->getDatetime('store_order_clear_time');
$where = [['status', 'eq', '0'], ['pay_state', 'eq', '0'], ['create_at', '<', $datetime]];
$list = Db::name('StoreOrder')->where($where)->limit(20)->select();
if (count($orderNos = array_unique(array_column($list, 'order_no'))) > 0) {
$this->output->info("自动删除前一天已经取消的订单:" . PHP_EOL . join(',' . PHP_EOL, $orderNos));
Db::name('StoreOrder')->whereIn('order_no', $orderNos)->delete();
Db::name('StoreOrderList')->whereIn('order_no', $orderNos)->delete();
} else {
$this->output->comment('没有需要自动删除前一天已经取消的订单!');
}
}
/**
* 订单自动退款操作
* @throws Exception
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws DbException
* @throws PDOException
*/
private function autoRefundOrder()
{
// 未完成退款的订单,执行微信退款操作
foreach (Db::name('StoreOrder')->where(['refund_state' => '1'])->select() as $order) try {
$this->output->writeln("正在为 {$order['order_no']} 执行退款操作...");
$result = We::WePayRefund(config('wechat.wxpay'))->create([
'transaction_id' => $order['pay_no'],
'out_refund_no' => $order['refund_no'],
'total_fee' => $order['price_total'] * 100,
'refund_fee' => $order['pay_price'] * 100,
'refund_account' => 'REFUND_SOURCE_UNSETTLED_FUNDS',
]);
if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {
Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update([
'refund_state' => '2', 'refund_desc' => '自动退款成功!',
]);
} else {
Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update([
'refund_desc' => isset($result['err_code_des']) ? $result['err_code_des'] : '自动退款失败',
]);
}
} catch (\Exception $e) {
$this->output->writeln("订单 {$order['order_no']} 执行退款失败,{$e->getMessage()}");
Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update(['refund_desc' => $e->getMessage()]);
}
$this->output->writeln('自动检测退款订单执行完成!');
}
/**
* 自动企业打款操作
* @throws Exception
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @throws DbException
* @throws PDOException
*/
private function autoTransfer()
{
# 批量企业打款
foreach (Db::name('StoreProfitUsed')->where(['status' => '1'])->select() as $vo) try {
$wechat = We::WePayTransfers(config('wechat.wxpay'));
$result = $wechat->create([
'partner_trade_no' => $vo['trs_no'],
'openid' => $vo['openid'],
'check_name' => 'NO_CHECK',
'amount' => $vo['pay_price'] * 100,
'desc' => '营销活动拥金提现',
'spbill_create_ip' => '127.0.0.1',
]);
if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {
Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update([
'status' => '2', 'pay_desc' => '拥金提现成功!', 'pay_no' => $result['payment_no'], 'pay_at' => date('Y-m-d H:i:s'),
]);
} else {
Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update([
'pay_desc' => isset($result['err_code_des']) ? $result['err_code_des'] : '自动打款失败', 'last_at' => date('Y-m-d H:i:s'),
]);
}
} catch (\Exception $e) {
$this->output->writeln("订单 {$vo['trs_no']} 执行提现失败,{$e->getMessage()}");
Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update(['pay_desc' => $e->getMessage()]);
}
}
/**
* 获取配置时间
* @param string $code
* @return string
* @throws Exception
* @throws PDOException
*/
private function getDatetime($code)
{
$minutes = intval(sysconf($code) * 60);
return date('Y-m-d H:i:s', strtotime("-{$minutes} minutes"));
}
}

View File

@ -1,60 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use app\store\service\ExtendService;
use library\Controller;
/**
* 商城参数配置
* Class Config
* @package app\store\controller
*/
class Config extends Controller
{
/**
* 商城参数配置
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '商城参数配置';
$this->applyCsrfToken('save');
$this->query = ExtendService::queryChinaSmsBalance();
$this->query2 = ExtendService::queryGlobeSmsBalance();
$this->fetch();
}
/**
* 保存商城参数
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function save()
{
if ($this->request->isPost()) {
$this->applyCsrfToken('save');
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
$this->success('商城短信配置保存成功!');
}
}
}

View File

@ -1,128 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use library\Controller;
use think\Db;
/**
* 快递公司管理
* Class Express
* @package app\store\controller
*/
class ExpressCompany extends Controller
{
/**
* 指定数据表
* @var string
*/
protected $table = 'StoreExpressCompany';
/**
* 快递公司管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '快递公司管理';
$query = $this->_query($this->table)->equal('status')->like('express_title,express_code');
$query->dateBetween('create_at')->order('status desc,sort desc,id desc')->where(['is_deleted' => '0'])->page();
}
/**
* 添加快递公司
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->_form($this->table, 'form');
}
/**
* 编辑快递公司
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->_form($this->table, 'form');
}
/**
* 表单数据处理
* @param array $data
* @auth true
*/
protected function _form_filter(array $data)
{
if ($this->request->isPost()) {
$where = [['express_code', 'eq', $data['express_code']], ['is_deleted', 'eq', '0']];
if (!empty($data['id'])) $where[] = ['id ', 'neq', $data['id']];
if (Db::name($this->table)->where($where)->count() > 0) {
$this->error('该快递编码已经存在,请使用其它编码!');
}
}
}
/**
* 禁用快递公司
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用快递公司
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->_save($this->table, ['status' => '1']);
}
/**
* 删除快递公司
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->_delete($this->table);
}
}

View File

@ -1,85 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use library\Controller;
use think\Db;
/**
* 邮费模板管理
* Class ExpressTemplate
* @package app\store\controller
*/
class ExpressTemplate extends Controller
{
/**
* 指定数据表
* @var string
*/
protected $table = 'StoreExpressTemplate';
/**
* 邮费模板管理
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$this->title = '邮费模板管理';
$filename = env('root_path') . 'public/static/plugs/jquery/area/area.json';
$this->provinces = array_column(json_decode(file_get_contents($filename), true), 'name');
$this->list = Db::name($this->table)->where(['is_default' => '0'])->select();
foreach ($this->list as &$item) $item['rule'] = explode(',', $item['rule']);
$this->default = Db::name($this->table)->where(['is_default' => '1'])->find();
$this->fetch();
}
/**
* 保存邮费模板
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function save()
{
list($list, $idxs, $post) = [[], [], $this->request->post()];
foreach (array_keys($post) as $key) if (stripos($key, 'order_reduction_state_') !== false) {
$idxs[] = str_replace('order_reduction_state_', '', $key);
}
foreach (array_unique($idxs) as $index) if (!empty($post["rule_{$index}"])) $list[] = [
'rule' => join(',', $post["rule_{$index}"]),
// 订单满减配置
'order_reduction_state' => $post["order_reduction_state_{$index}"],
'order_reduction_price' => $post["order_reduction_price_{$index}"],
// 首件邮费配置
'first_number' => $post["first_number_{$index}"],
'first_price' => $post["first_price_{$index}"],
// 首件邮费配置
'next_number' => $post["next_number_{$index}"],
'next_price' => $post["next_price_{$index}"],
// 默认邮费规则
'is_default' => $post["is_default_{$index}"],
];
if (empty($list)) $this->error('请配置有效的邮费规则');
Db::name($this->table)->where('1=1')->delete();
Db::name($this->table)->insertAll($list);
$this->success('邮费规则配置成功!');
}
}

View File

@ -1,215 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use library\Controller;
use library\tools\Data;
use think\Db;
/**
* 商品信息管理
* Class Goods
* @package app\store\controller
*/
class Goods extends Controller
{
/**
* 指定数据表
* @var string
*/
protected $table = 'StoreGoods';
/**
* 商品信息管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '商品信息管理';
$query = $this->_query($this->table)->equal('status,cate_id')->like('title');
$query->where(['is_deleted' => '0'])->order('sort desc,id desc')->page();
}
/**
* 数据列表处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function _index_page_filter(&$data)
{
$this->clist = Db::name('StoreGoodsCate')->where(['is_deleted' => '0', 'status' => '1'])->select();
$list = Db::name('StoreGoodsList')->where('status', '1')->whereIn('goods_id', array_unique(array_column($data, 'id')))->select();
foreach ($data as &$vo) {
list($vo['list'], $vo['cate']) = [[], []];
foreach ($list as $goods) if ($goods['goods_id'] === $vo['id']) array_push($vo['list'], $goods);
foreach ($this->clist as $cate) if ($cate['id'] === $vo['cate_id']) $vo['cate'] = $cate;
}
}
/**
* 商品库存入库
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function stock()
{
if ($this->request->isGet()) {
$GoodsId = $this->request->get('id');
$goods = Db::name('StoreGoods')->where(['id' => $GoodsId])->find();
empty($goods) && $this->error('无效的商品信息,请稍候再试!');
$goods['list'] = Db::name('StoreGoodsList')->where(['goods_id' => $GoodsId])->select();
$this->fetch('', ['vo' => $goods]);
} else {
list($post, $data) = [$this->request->post(), []];
if (isset($post['id']) && isset($post['goods_id']) && is_array($post['goods_id'])) {
foreach (array_keys($post['goods_id']) as $key) if ($post['goods_number'][$key] > 0) array_push($data, [
'goods_id' => $post['goods_id'][$key],
'goods_spec' => $post['goods_spec'][$key],
'number_stock' => $post['goods_number'][$key],
]);
if (!empty($data)) {
Db::name('StoreGoodsStock')->insertAll($data);
\app\store\service\GoodsService::syncStock($post['id']);
$this->success('商品信息入库成功!');
}
}
$this->error('没有需要商品入库的数据!');
}
}
/**
* 添加商品信息
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->title = '添加商品信息';
$this->isAddMode = '1';
$this->_form($this->table, 'form');
}
/**
* 编辑商品信息
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->title = '编辑商品信息';
$this->isAddMode = '0';
$this->_form($this->table, 'form');
}
/**
* 表单数据处理
* @param array $data
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
protected function _form_filter(&$data)
{
// 生成商品ID
if (empty($data['id'])) $data['id'] = Data::uniqidNumberCode(14);
if ($this->request->isGet()) {
$fields = 'goods_spec,goods_id,status,price_market market,price_selling selling,number_virtual `virtual`,number_express express';
$defaultValues = Db::name('StoreGoodsList')->where(['goods_id' => $data['id']])->column($fields);
$this->defaultValues = json_encode($defaultValues, JSON_UNESCAPED_UNICODE);
$this->cates = Db::name('StoreGoodsCate')->where(['is_deleted' => '0', 'status' => '1'])->order('sort desc,id desc')->select();
} elseif ($this->request->isPost()) {
if (empty($data['logo'])) $this->error('商品LOGO不能为空请上传图片');
if (empty($data['image'])) $this->error('商品展示图片不能为空,请上传图片');
Db::name('StoreGoodsList')->where(['goods_id' => $data['id']])->update(['status' => '0']);
foreach (json_decode($data['lists'], true) as $vo) Data::save('StoreGoodsList', [
'goods_id' => $data['id'],
'goods_spec' => $vo[0]['key'],
'price_market' => $vo[0]['market'],
'price_selling' => $vo[0]['selling'],
'number_virtual' => $vo[0]['virtual'],
'number_express' => $vo[0]['express'],
'status' => $vo[0]['status'] ? 1 : 0,
], 'goods_spec', ['goods_id' => $data['id']]);
}
}
/**
* 表单结果处理
* @param boolean $result
*/
protected function _form_result($result)
{
if ($result && $this->request->isPost()) {
$this->success('商品编辑成功!', 'javascript:history.back()');
}
}
/**
* 禁用商品信息
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用商品信息
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->_save($this->table, ['status' => '1']);
}
/**
* 删除商品信息
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->_delete($this->table);
}
}

View File

@ -1,113 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use library\Controller;
/**
* 商品分类管理
* Class GoodsCate
* @package app\store\controller
*/
class GoodsCate extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'StoreGoodsCate';
/**
* 商品分类管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '商品分类管理';
$query = $this->_query($this->table)->like('title')->equal('status');
$query->where(['is_deleted' => '0'])->order('sort desc,id desc')->page();
}
/**
* 添加商品分类
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function add()
{
$this->title = '添加商品分类';
$this->_form($this->table, 'form');
}
/**
* 编辑商品分类
* @auth true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit()
{
$this->title = '编辑商品分类';
$this->_form($this->table, 'form');
}
/**
* 禁用商品分类
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function forbid()
{
$this->_save($this->table, ['status' => '0']);
}
/**
* 启用商品分类
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function resume()
{
$this->_save($this->table, ['status' => '1']);
}
/**
* 删除商品分类
* @auth true
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function remove()
{
$this->_delete($this->table);
}
}

View File

@ -1,50 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\store\controller;
use library\Controller;
/**
* 会员信息管理
* Class Member
* @package app\store\controller
*/
class Member extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'StoreMember';
/**
* 会员信息管理
* @auth true
* @menu true
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
$this->title = '会员信息管理';
$query = $this->_query($this->table)->like('nickname,phone')->equal('vip_level');
$query->dateBetween('create_at')->order('id desc')->page();
}
}

Some files were not shown because too many files have changed in this diff Show More