From 3ceefe05e264cdae8ef403ba4c3f9bfded042782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 10 Apr 2021 17:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=AE=E4=BF=A1=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQL01-数据表结构.sql | 37 ++- SQL02-数据初始化.sql | 8 +- app/data/controller/total/Portal.php | 26 +- app/data/view/total/portal/index.html | 255 ++++++++++++-------- app/index/controller/Index.php | 6 + app/wechat/command/Auto.php | 135 +++++++++++ app/wechat/controller/Auto.php | 133 +++++++++++ app/wechat/controller/api/Push.php | 3 +- app/wechat/service/AutoService.php | 45 ++++ app/wechat/sys.php | 9 +- app/wechat/view/auto/form.html | 266 +++++++++++++++++++++ app/wechat/view/auto/index.html | 82 +++++++ app/wechat/view/auto/index_search.html | 54 +++++ public/static/plugs/echarts/echarts.min.js | 25 +- 14 files changed, 970 insertions(+), 114 deletions(-) create mode 100644 app/wechat/command/Auto.php create mode 100644 app/wechat/controller/Auto.php create mode 100644 app/wechat/service/AutoService.php create mode 100644 app/wechat/view/auto/form.html create mode 100644 app/wechat/view/auto/index.html create mode 100644 app/wechat/view/auto/index_search.html diff --git a/SQL01-数据表结构.sql b/SQL01-数据表结构.sql index 10d895c21..57451133b 100644 --- a/SQL01-数据表结构.sql +++ b/SQL01-数据表结构.sql @@ -11,7 +11,7 @@ Target Server Version : 80018 File Encoding : 65001 - Date: 08/04/2021 10:07:25 + Date: 10/04/2021 17:27:30 */ SET NAMES utf8mb4; @@ -807,7 +807,7 @@ CREATE TABLE `system_menu` ( `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_system_menu_status`(`status`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 98 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT; +) ENGINE = InnoDB AUTO_INCREMENT = 99 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT; -- ---------------------------- -- Table structure for system_oplog @@ -822,7 +822,7 @@ CREATE TABLE `system_oplog` ( `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作人用户名', `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 202 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-日志' ROW_FORMAT = COMPACT; +) ENGINE = InnoDB AUTO_INCREMENT = 207 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-日志' ROW_FORMAT = COMPACT; -- ---------------------------- -- Table structure for system_queue @@ -881,6 +881,37 @@ CREATE TABLE `system_user` ( INDEX `idx_system_user_deleted`(`is_deleted`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 10001 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-用户' ROW_FORMAT = COMPACT; +-- ---------------------------- +-- Table structure for wechat_auto +-- ---------------------------- +DROP TABLE IF EXISTS `wechat_auto`; +CREATE TABLE `wechat_auto` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '类型(text,image,news)', + `time` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '延迟时间', + `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '消息编号', + `appid` char(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '公众号APPID', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '文本内容', + `image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '图片链接', + `voice_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '语音链接', + `music_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐标题', + `music_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐链接', + `music_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '缩略图片', + `music_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐描述', + `video_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频标题', + `video_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频URL', + `video_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频描述', + `news_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '图文ID', + `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_auto_type`(`type`) USING BTREE, + INDEX `idx_wechat_auto_keys`(`time`) USING BTREE, + INDEX `idx_wechat_auto_code`(`code`) USING BTREE, + INDEX `idx_wechat_auto_appid`(`appid`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '微信-回复' ROW_FORMAT = COMPACT; + -- ---------------------------- -- Table structure for wechat_fans -- ---------------------------- diff --git a/SQL02-数据初始化.sql b/SQL02-数据初始化.sql index dd0dcc018..018323017 100644 --- a/SQL02-数据初始化.sql +++ b/SQL02-数据初始化.sql @@ -11,7 +11,7 @@ Target Server Version : 80018 File Encoding : 65001 - Date: 07/04/2021 14:33:12 + Date: 10/04/2021 17:27:54 */ SET NAMES utf8mb4; @@ -3841,7 +3841,7 @@ CREATE TABLE `system_menu` ( `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_system_menu_status`(`status`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 98 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT; +) ENGINE = InnoDB AUTO_INCREMENT = 99 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT; -- ---------------------------- -- Records of system_menu @@ -3889,6 +3889,8 @@ INSERT INTO `system_menu` VALUES (93, 90, '用户提现管理', 'layui-icon layu INSERT INTO `system_menu` VALUES (94, 68, '页面内容管理', 'layui-icon layui-icon-read', 'data/base.config/pagehome', 'data/base.config/pagehome', '', '_self', 20, 0, '2021-02-24 08:49:16'); INSERT INTO `system_menu` VALUES (95, 68, '邀请二维码设置', 'layui-icon layui-icon-cols', 'data/base.config/cropper', 'data/base.config/cropper', '', '_self', 0, 1, '2021-03-01 09:53:59'); INSERT INTO `system_menu` VALUES (97, 90, '用户返利管理', 'layui-icon layui-icon-transfer', 'data/user.rebate/index', 'data/user.rebate/index', '', '_self', 600, 1, '2021-03-12 10:06:49'); +INSERT INTO `system_menu` VALUES (98, 0, '首 页', '', 'data/total.portal/index', 'data/total.portal/index', '', '_self', 400, 1, '2021-04-10 13:43:19'); +INSERT INTO `system_menu` VALUES (99, 60, '关注自动回复', 'layui-icon layui-icon-release', 'wechat/auto/index', 'wechat/auto/index', '', '_self', 0, 1, '2021-04-10 15:56:54'); -- ---------------------------- -- Table structure for system_user @@ -3921,6 +3923,6 @@ CREATE TABLE `system_user` ( -- ---------------------------- -- Records of system_user -- ---------------------------- -INSERT INTO `system_user` VALUES (10000, 'admin', '21232f297a57a5a743894a0e4a801fc3', '系统管理员', 'https://xhtwxapp.cdn.xiaoding.shop/cf/23526f451784ff137f161b8fe18d5a.png', ',,', '', '', '', '127.0.0.1', '2021-04-07 11:27:31', 141, '', 1, 0, 0, '2015-11-13 15:14:22'); +INSERT INTO `system_user` VALUES (10000, 'admin', '21232f297a57a5a743894a0e4a801fc3', '系统管理员', 'https://xhtwxapp.cdn.xiaoding.shop/cf/23526f451784ff137f161b8fe18d5a.png', ',,', '', '', '', '127.0.0.1', '2021-04-10 13:42:51', 142, '', 1, 0, 0, '2015-11-13 15:14:22'); SET FOREIGN_KEY_CHECKS = 1; diff --git a/app/data/controller/total/Portal.php b/app/data/controller/total/Portal.php index d63b853b2..b841b5916 100644 --- a/app/data/controller/total/Portal.php +++ b/app/data/controller/total/Portal.php @@ -23,17 +23,23 @@ class Portal extends Controller $this->orderTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->count(); $this->amountTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->sum('amount_total'); // 近七天用户及交易趋势 - $this->days = []; - for ($i = 15; $i >= 0; $i--) { - $date = date('Y-m-d', strtotime("-{$i}days")); - $this->days[] = [ - date('m-d', strtotime("-{$i}days")), - $this->app->db->name('DataUser')->cache(true, 60)->whereLike('create_at', "{$date}%")->count(), - $this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->count(), - $this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->sum('amount_total'), - $this->app->db->name('DataUserRebate')->cache(true, 60)->whereLike('create_at', "{$date}%")->sum('amount'), - ]; + $this->days = $this->app->cache->get('portals', []); + if (empty($this->days)) { + for ($i = 15; $i >= 0; $i--) { + $date = date('Y-m-d', strtotime("-{$i}days")); + $this->days[] = [ + '当天日期' => date('m-d', strtotime("-{$i}days")), + '增加用户' => $this->app->db->name('DataUser')->cache(true, 60)->whereLike('create_at', "{$date}%")->count(), + '订单数量' => $this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->count(), + '订单金额' => $this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->sum('amount_total'), + '返利金额' => $this->app->db->name('DataUserRebate')->cache(true, 60)->whereLike('create_at', "{$date}%")->sum('amount'), + '充值余额' => $this->app->db->name('DataUserBalance')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('amount>0 and deleted=0')->sum('amount'), + '消费余额' => $this->app->db->name('DataUserBalance')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('amount<0 and deleted=0')->sum('amount'), + ]; + } + $this->app->cache->set('portals', $this->days, 60); } + // 会员级别分布统计 $levels = $this->app->db->name('BaseUserUpgrade')->where(['status' => 1])->order('number asc')->column('number code,name,0 count', 'number'); foreach ($this->app->db->name('DataUser')->field('count(1) count,vip_code level')->group('vip_code')->cursor() as $vo) { diff --git a/app/data/view/total/portal/index.html b/app/data/view/total/portal/index.html index 1b6a77d98..82db27bb0 100644 --- a/app/data/view/total/portal/index.html +++ b/app/data/view/total/portal/index.html @@ -38,21 +38,38 @@ -
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+