diff --git a/addons/shopro/controller/user/User.php b/addons/shopro/controller/user/User.php index 9b96b00..268101f 100644 --- a/addons/shopro/controller/user/User.php +++ b/addons/shopro/controller/user/User.php @@ -439,15 +439,60 @@ class User extends Common if (!isset($params['status'])) { $this->error('缺少参数:status'); } - $relation = Relation::get(['user_id' => $this->auth->id, 'target_id' => $params['user_id']]); - if (empty($relation)) { - $relation = new Relation; + $ids = explode(',', $params['user_id']); + if (empty($ids)) { + $this->error('缺少参数:user_id'); } - $relation->allowField(true)->save([ - 'target_id' => $params['user_id'], - 'user_id' => $this->auth->id, - 'status' => $params['status'], - ]); + foreach ($ids as $id) { + if ($id == $this->auth->id) { + $this->error('不能设置与自己的好友关系'); + } + } + Db::startTrans(); + try { + $dbUserId = UserModel::where('id', 'IN', $ids)->column('id'); + if (!empty($diffId = array_diff($ids, $dbUserId))) { + return $this->error('用户不存在:' . implode(',', $diffId)); + } + $res = Relation::where('user_id', $this->auth->id)->where('target_id', 'IN', $ids)->update(['status' => $params['status']]); + if ($res < count($ids)) { + $target = Relation::where('user_id', $this->auth->id)->where('target_id', 'IN', $ids)->column("target_id"); + $_relationModel = new Relation; + foreach ((array_diff($ids, $target)) as $id) { + (clone $_relationModel)->allowField(true)->save([ + 'user_id' => $this->auth->id, + 'target_id' => $id, + 'status' => $params['status'], + ]); + } + } + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + $this->success('Success'); } + + // 获取关系列表 + public function list() + { + $params = $this->request->param(); + $query = Relation::alias('r') + ->join([UserModel::$tableName => 'u'], 'u.id=r.target_id') + ->field('r.*,u.avatar,u.gender,u.nickname') + ->where('user_id', $this->auth->id); + if (isset($params['status'])) { + $query->where('r.status', $params['status']); + } else { + $query->where('r.status', '<>', 0); + } + $list = $query->select(); + foreach ($list as &$l) { + $l['content'] = json_decode($l['content'] ?? '[]', true); + } + + $this->success('Success', $list); + } } diff --git a/addons/shopro/controller/zy/Base.php b/addons/shopro/controller/zy/Base.php index b4ea4ec..89091ff 100644 --- a/addons/shopro/controller/zy/Base.php +++ b/addons/shopro/controller/zy/Base.php @@ -48,7 +48,7 @@ class Base extends Common $this->error($e->getMessage()); } if ($result === false) { - $this->error(__('No rows were inserted')); + $this->error('操作失败'); } $this->success('Success'); } @@ -70,7 +70,7 @@ class Base extends Common $this->error($e->getMessage()); } if ($result === false) { - $this->error(__('No rows were inserted')); + $this->error('操作失败'); } $this->success('Success'); } diff --git a/addons/shopro/controller/zy/Circle.php b/addons/shopro/controller/zy/Circle.php new file mode 100644 index 0000000..830407b --- /dev/null +++ b/addons/shopro/controller/zy/Circle.php @@ -0,0 +1,177 @@ +request->param(); + + $sub = CircleModel::alias('c') + ->join([Likes::$tableName => 'l'], 'c.id = l.circle_id', 'LEFT') + ->field("c.*,JSON_ARRAYAGG(JSON_OBJECT( + 'id', l.id, + 'user_id', l.user_id, + 'nickname', l.nickname, + 'avatar', l.avatar, + 'gender', l.gender + )) AS likes")->group('c.id')->buildSql(); + $query = Comment::alias('m') + ->join([$sub => 'c'], 'c.id = m.circle_id', 'RIGHT') + ->field("c.*, + JSON_ARRAYAGG(JSON_OBJECT( + 'id', m.id, + 'pid', m.pid, + 'puser_id', m.puser_id, + 'pnickname', m.pnickname, + 'user_id', m.user_id, + 'nickname', m.nickname, + 'avatar', m.avatar, + 'gender', m.gender, + 'content', m.content, + 'create_time', m.create_time + )) AS comment")->group('c.id'); + if (isset($params['club_id'])) { + $query->where('c.club_id', $params['club_id']); + } + if (isset($params['user_id'])) { + $query->where('c.user_id', $params['user_id']); + } + if (isset($params['friend'])) { + $friend = Relation::where('user_id', $this->auth->id)->where('status', 'IN', explode(',', $params['friend']))->column('target_id'); + $query->where('c.user_id', 'IN', $friend); + } + $res = $query->select(); + foreach ($res as &$r) { + $r['likes'] = json_decode($r['likes'], true); + if (count($r['likes']) == 1 && empty($r['likes'][0]['id'])) $r['likes'] = []; + $r['comment'] = buildTree(json_decode($r['comment'], true)); + } + + $this->success('Success', $res); + } + + public function view() + { + $model = CircleModel::get($this->request->param('id')); + if (empty($model)) { + $this->error(__('No rows were found')); + } + $this->success('Success', $model); + } + + public function add() + { + $params = $this->request->param(); + if (empty($params['content'])) { + $this->error('内容不能为空'); + } + $user = auth_user(); + $club = Menber::alias('m')->join([Club::$tableName => 'c'], 'm.club_id=c.id') + ->field('c.name') + ->where(['m.club_id' => $params['club_id'], 'm.user_id' => $user['id']]) + ->where('m.role', '>', 0)->find(); + if (empty($club)) { + $this->error('你无权在此俱乐部发布'); + } + $params['user_id'] = $user['id']; + $params['nickname'] = $user['nickname']; + $params['avatar'] = $user['avatar']; + $params['gender'] = $user['gender']; + $params['club_name'] = $club['name']; + $params['status'] = 1; + Db::startTrans(); + try { + $result = (new CircleModel)->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error('操作失败'); + } + $this->success('Success'); + } + + // 点赞 + public function like() + { + $params = $this->request->param(); + $club = CircleModel::get($params['circle_id']); + if (empty($club)) { + $this->error('数据不存在'); + } + $user = auth_user(); + Db::startTrans(); + try { + $like = Likes::get(['circle_id' => $params['circle_id'], 'user_id' => $user['id']]); + if (empty($like)) { // 点赞 + (new Likes)->allowField(true)->save([ + 'circle_id' => $params['circle_id'], + 'user_id' => $user['id'], + 'nickname' => $user['nickname'], + 'avatar' => $user['avatar'], + 'gender' => $user['gender'], + ]); + } else { // 取消点赞 + $like->delete(); + } + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + $this->success('Success'); + } + + // 评论 + public function comment() + { + $params = $this->request->param(); + $club = CircleModel::get($params['circle_id']); + if (empty($club)) { + $this->error('数据不存在'); + } + if (empty($params['content'])) { + $this->error('内容不能为空'); + } + $pcomment = Comment::get($params['pid']); + if (!empty($params['pid']) && empty($pcomment)) { + $this->error('回复的评论不存在'); + } + $user = auth_user(); + Db::startTrans(); + try { + (new Comment)->allowField(true)->save([ + 'circle_id' => $params['circle_id'], + 'pid' => $params['pid'], + 'puser_id' => $pcomment['user_id'] ?? 0, + 'pnickname' => $pcomment['nickname'] ?? '', + 'user_id' => $user['id'], + 'nickname' => $user['nickname'], + 'avatar' => $user['avatar'], + 'gender' => $user['gender'], + 'content' => $params['content'], + ]); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + $this->success('Success'); + } +} diff --git a/addons/shopro/controller/zy/Club.php b/addons/shopro/controller/zy/Club.php index 62bccd9..f41ad77 100644 --- a/addons/shopro/controller/zy/Club.php +++ b/addons/shopro/controller/zy/Club.php @@ -4,11 +4,11 @@ namespace addons\shopro\controller\zy; use think\Db; use think\Exception; -use app\admin\model\User; use app\admin\model\zy\Menber; use think\exception\PDOException; use app\admin\model\zy\link\Apply; use app\admin\model\zy\link\Message; +use app\admin\model\shopro\user\User; use app\admin\model\zy\game\Activity; use think\exception\ValidateException; @@ -27,6 +27,9 @@ class Club extends Base if (isset($params['name'])) { $model->where('name', 'like', '%' . $params['name'] . '%'); } + if (isset($params['gym_id'])) { + $model->where('gym_id', $params['gym_id']); + } $res = $model->select(); $this->success('Success', $res); @@ -52,7 +55,7 @@ class Club extends Base $this->error($e->getMessage()); } if ($result === false) { - $this->error(__('No rows were inserted')); + $this->error('操作失败'); } $this->success('Success', $result); } diff --git a/addons/shopro/controller/zy/Sys.php b/addons/shopro/controller/zy/Sys.php new file mode 100644 index 0000000..44da8b4 --- /dev/null +++ b/addons/shopro/controller/zy/Sys.php @@ -0,0 +1,73 @@ +request->param(); + $model = new Tags(); + if (isset($params['type'])) { + $model->where('type', $params['type']); + } + if (isset($params['group'])) { + $model->where('group', $params['group']); + } + $res = $model->select(); + + $this->success('Success', $res); + } + + // 举报投诉 + public function complain() + { + $params = $this->request->param(); + if ($params['type'] == 3) { //用户举报 + $target = User::get($params['target_id']); + } elseif ($params['type'] == 2) { //影圈举报 + $target = Circle::get($params['target_id']); + } elseif ($params['type'] == 1) { + $target = ['id' => 0]; + $params['target_id'] = 0; + } else { + $this->error('type 类型错误'); + } + if (empty($target)) { + $this->error('举报对象不存在'); + } + if (empty($params['content'])) { + $this->error('举报内容不能为空'); + } + $user = auth_user(); + $res = Complaint::get(['user_id' => $user['id'], 'target_id' => $params['target_id'], 'type' => $params['type'],'status' => 0]); + if ($res) { + $this->error('您已举报过该对象'); + } + $params['status'] = 0; + $params['user_id'] = $user['id']; + $params['username'] = $params['username'] ?? $user['username']; + Db::startTrans(); + try { + $result = (new Complaint)->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error('操作失败'); + } + $this->success('Success'); + } +} diff --git a/addons/shopro/controller/zy/Tags.php b/addons/shopro/controller/zy/Tags.php deleted file mode 100644 index f0612dd..0000000 --- a/addons/shopro/controller/zy/Tags.php +++ /dev/null @@ -1,25 +0,0 @@ -request->param(); - $model = new TagsModel(); - if (isset($params['type'])) { - $model->where('type', $params['type']); - } - if (isset($params['group'])) { - $model->where('group', $params['group']); - } - $res = $model->select(); - - $this->success('Success', $res); - } -} diff --git a/application/admin/model/shopro/user/User.php b/application/admin/model/shopro/user/User.php index 93ea6fd..ae024fc 100644 --- a/application/admin/model/shopro/user/User.php +++ b/application/admin/model/shopro/user/User.php @@ -12,6 +12,7 @@ class User extends Common { use Notifiable; + public static $tableName = 'user'; protected $name = 'user'; protected $type = [ diff --git a/application/admin/model/zy/Club.php b/application/admin/model/zy/Club.php index 508c176..63a88ba 100644 --- a/application/admin/model/zy/Club.php +++ b/application/admin/model/zy/Club.php @@ -13,6 +13,7 @@ class Club extends Model // 表名 + public static $tableName = 'zy_club'; protected $table = 'zy_club'; // 自动写入时间戳字段 diff --git a/application/admin/model/zy/circle/Circle.php b/application/admin/model/zy/circle/Circle.php index 37bd865..e228486 100644 --- a/application/admin/model/zy/circle/Circle.php +++ b/application/admin/model/zy/circle/Circle.php @@ -13,6 +13,7 @@ class Circle extends Model // 表名 + public static $tableName = 'zy_circle'; protected $table = 'zy_circle'; // 自动写入时间戳字段 diff --git a/application/admin/model/zy/circle/Comment.php b/application/admin/model/zy/circle/Comment.php index d0dc948..bb0f4ef 100644 --- a/application/admin/model/zy/circle/Comment.php +++ b/application/admin/model/zy/circle/Comment.php @@ -13,6 +13,7 @@ class Comment extends Model // 表名 + public static $tableName = 'zy_circle_comment'; protected $table = 'zy_circle_comment'; // 自动写入时间戳字段 diff --git a/application/admin/model/zy/circle/Likes.php b/application/admin/model/zy/circle/Likes.php index cfcf9c9..f3918e7 100644 --- a/application/admin/model/zy/circle/Likes.php +++ b/application/admin/model/zy/circle/Likes.php @@ -13,6 +13,7 @@ class Likes extends Model // 表名 + public static $tableName = 'zy_circle_likes'; protected $table = 'zy_circle_likes'; // 自动写入时间戳字段 diff --git a/fast.sql b/fast.sql index c0fe232..6b84c27 100644 --- a/fast.sql +++ b/fast.sql @@ -11,7 +11,7 @@ Target Server Version : 110602 (11.6.2-MariaDB) File Encoding : 65001 - Date: 02/05/2025 14:22:32 + Date: 10/05/2025 19:46:30 */ SET NAMES utf8mb4; @@ -8049,11 +8049,14 @@ CREATE TABLE `user` ( `salt` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '密码盐', `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '电子邮箱', `mobile` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '手机号', + `qq` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'qq号', + `wechat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信', + `years` int(11) NULL DEFAULT NULL COMMENT '球龄', `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像', `level` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '等级', `gender` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '性别', `birthday` date NULL DEFAULT NULL COMMENT '生日', - `bio` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '格言', + `bio` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '格言', `money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '余额', `commission` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '佣金', `score` int(10) NOT NULL DEFAULT 0 COMMENT '积分', @@ -8083,8 +8086,8 @@ CREATE TABLE `user` ( -- ---------------------------- -- Records of user -- ---------------------------- -INSERT INTO `user` VALUES (1, 1, 'admin', 'admin', '3f5100397b25c554fb32c682b1322886', 'ea2e8c', 'admin@163.com', '13000000000', '/assets/img/avatar.png', 0, 0, '2017-04-08', '', 0.00, 0.00, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, 1491635035, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal', '', NULL, 0.00); -INSERT INTO `user` VALUES (2, 1, 'admin11', 'admin111', '1c60ba0f999d224dd9acb63b164108a4', 'ea2e8c', 'admin@163.com', '13000000000', '/assets/img/avatar.png', 0, 0, '2017-04-08', '', 0.00, 0.00, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, 1491635035, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal', '', NULL, 0.00); +INSERT INTO `user` VALUES (1, 1, 'admin', 'admin', '3f5100397b25c554fb32c682b1322886', 'ea2e8c', 'admin@163.com', '13000000000', NULL, NULL, NULL, '/assets/img/avatar.png', 0, 0, '2017-04-08', '', 0.00, 0.00, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, 1491635035, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal', '', NULL, 0.00); +INSERT INTO `user` VALUES (2, 1, 'admin11', 'admin111', '1c60ba0f999d224dd9acb63b164108a4', 'ea2e8c', 'admin@163.com', '13000000000', '11', 'wechat11', 11, '/assets/img/avatar.png', 0, 0, '2017-04-08', '', 0.00, 0.00, 0, 1, 1, 1746841815, 1746863193, '127.0.0.1', 0, 1746170854, '127.0.0.1', 1491635035, 0, 1746863193, '', 'normal', '', NULL, 0.00); -- ---------------------------- -- Table structure for user_group @@ -8192,6 +8195,10 @@ CREATE TABLE `user_token` ( -- ---------------------------- -- Records of user_token -- ---------------------------- +INSERT INTO `user_token` VALUES ('09f76ec0cbabbf153fef66169ba35d370296b877', 2, 1746171052, 1748763052); +INSERT INTO `user_token` VALUES ('1e0a619bc5dc95f5f480570f2228eb0ae17cdcc5', 2, 1746171249, 1748763249); +INSERT INTO `user_token` VALUES ('c029cdbd73c52d9a52f5684df84cfa4510eb7b8c', 2, 1746841815, 1749433815); +INSERT INTO `user_token` VALUES ('c7ae32314812b4c3e46162a400f5873d9c1736f3', 2, 1746863193, 1749455193); -- ---------------------------- -- Table structure for version @@ -8258,8 +8265,8 @@ CREATE TABLE `zy_activity` ( -- ---------------------------- -- Records of zy_activity -- ---------------------------- -INSERT INTO `zy_activity` VALUES (1, 0, 1, 1, '聚点第八届年终团体赛', '泰新路88号', '22', 1, 1, 1, 0, 0, '09:00:00', '12:30:00', '{\"before\":\"2\",\"time\":\"09:00\"}', '{\"before\":\"1\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"08:00\"}', 3.5, '', '{\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 30, '活动介绍', '/assets/img/qrcode.png', '比赛规则', 1, 2, '1', 0, '2025-04-30 10:45:58', '2025-04-30 14:25:28'); -INSERT INTO `zy_activity` VALUES (2, 1, 1, 1, '混双擂台', '泰新路88号', '22', 1, 1, 1, 0, 0, '11:02:00', '11:02:00', 'NULL ', 'NULL ', 'NULL ', 'NULL ', 0.0, NULL, 'NULL ', 0, '聚点第八届年终团体赛,子活动:混双擂台', '', '', 1, 0, '', 0, '2025-04-30 11:23:45', '2025-04-30 14:10:59'); +INSERT INTO `zy_activity` VALUES (1, 0, 1, 1, '聚点第八届年终团体赛', '泰新路88号', '22', 1, 1, 1, 1, 2, '09:00:00', '12:30:00', '{\"before\":\"2\",\"time\":\"09:00\"}', '{\"before\":\"1\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"08:00\"}', 3.5, '', '{\"type\":\"1\",\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 30, '活动介绍', '/assets/img/qrcode.png', '比赛规则', 1, 2, '1,2', 0, '2025-04-30 10:45:58', '2025-05-04 09:08:01'); +INSERT INTO `zy_activity` VALUES (2, 1, 1, 1, '混双擂台', '泰新路88号', '22', 1, 1, 1, 1, 2, '09:00:00', '12:30:00', '{\"before\":\"2\",\"time\":\"09:00\"}', '{\"before\":\"1\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"09:00\"}', '{\"before\":\"0\",\"time\":\"08:00\"}', 3.5, NULL, '{\"type\":\"1\",\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 0, '聚点第八届年终团体赛,子活动:混双擂台', '', '', 1, 0, '2', 0, '2025-04-30 11:23:45', '2025-05-04 09:08:01'); -- ---------------------------- -- Table structure for zy_apply @@ -8294,7 +8301,7 @@ CREATE TABLE `zy_circle` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `club_id` bigint(20) NOT NULL COMMENT '俱乐部id', `user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '用户id', - `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名称', + `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户昵称', `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像', `gender` tinyint(4) NULL DEFAULT NULL COMMENT '性别', `club_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '俱乐部名称', @@ -8304,11 +8311,13 @@ CREATE TABLE `zy_circle` ( `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_circle -- ---------------------------- +INSERT INTO `zy_circle` VALUES (1, 4, 2, 'admin111', '/assets/img/avatar.png', 0, '聚点羽毛球俱乐部', 'content', '/assets/img/avatar.png,/assets/img/avatar.png', 1, '2025-05-10 16:20:23', '2025-05-10 16:20:23'); +INSERT INTO `zy_circle` VALUES (2, 4, 2, 'admin111', '/assets/img/avatar.png', 0, '聚点羽毛球俱乐部', 'contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent', '/assets/img/avatar.png,/assets/img/avatar.png', 1, '2025-05-10 19:23:20', '2025-05-10 19:23:20'); -- ---------------------------- -- Table structure for zy_circle_comment @@ -8318,8 +8327,10 @@ CREATE TABLE `zy_circle_comment` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `circle_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '影圈id', `pid` bigint(20) NOT NULL DEFAULT 0 COMMENT '回复评论id', + `puser_id` bigint(20) NULL DEFAULT NULL COMMENT '回复用户id', + `pnickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '回复用户昵称', `user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '用户id', - `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名称', + `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名称', `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户头像', `gender` tinyint(4) NULL DEFAULT NULL COMMENT '性别', `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评论或回复内容', @@ -8327,11 +8338,15 @@ CREATE TABLE `zy_circle_comment` ( `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈评论/回复' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈评论/回复' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_circle_comment -- ---------------------------- +INSERT INTO `zy_circle_comment` VALUES (1, 1, 0, NULL, NULL, 2, 'admin111', '/assets/img/avatar.png', 0, '带我玩', NULL, '2025-05-10 16:57:39', '2025-05-10 16:57:39'); +INSERT INTO `zy_circle_comment` VALUES (3, 1, 1, 2, 'admin111', 2, 'admin111', '/assets/img/avatar.png', 0, '我带带我自己', NULL, '2025-05-10 16:58:58', '2025-05-10 16:58:58'); +INSERT INTO `zy_circle_comment` VALUES (4, 1, 1, 2, 'admin111', 2, 'admin111', '/assets/img/avatar.png', 0, '我带带我自己', NULL, '2025-05-10 19:38:53', '2025-05-10 19:38:53'); +INSERT INTO `zy_circle_comment` VALUES (5, 1, 3, 2, 'admin111', 2, 'admin111', '/assets/img/avatar.png', 0, '我带带我自己', NULL, '2025-05-10 19:39:47', '2025-05-10 19:39:47'); -- ---------------------------- -- Table structure for zy_circle_likes @@ -8341,17 +8356,19 @@ CREATE TABLE `zy_circle_likes` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `circle_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '影圈id', `user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '用户id', - `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名称', + `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名称', `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户头像', `gender` tinyint(4) NOT NULL COMMENT '性别', `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈点赞' ROW_FORMAT = Dynamic; + PRIMARY KEY (`id`) USING BTREE, + INDEX `circle_id`(`circle_id` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '影圈点赞' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_circle_likes -- ---------------------------- +INSERT INTO `zy_circle_likes` VALUES (4, 1, 2, 'admin111', '/assets/img/avatar.png', 0, '2025-05-10 18:15:26', '2025-05-10 18:15:26'); -- ---------------------------- -- Table structure for zy_club @@ -8374,12 +8391,14 @@ CREATE TABLE `zy_club` ( `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '俱乐部' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '俱乐部' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_club -- ---------------------------- INSERT INTO `zy_club` VALUES (1, 1, '聚点羽毛球俱乐部', '聚点', '/assets/img/qrcode.png', '广东省/东莞市/东城街道', 'NULL 50字简介', 0, '/assets/img/qrcode.png', 1, '', '高手多,不控球,帅哥多', 1, '2025-04-29 16:50:59', '2025-04-29 20:57:24'); +INSERT INTO `zy_club` VALUES (2, 1, '聚点羽毛球俱乐部', '聚点', '/assets/img/qrcode.png', '广东省/东莞市/东城街道', 'NULL 50字简介', 0, '/assets/img/qrcode.png', 2, '2', '高手多,不控球,帅哥多', 1, '2025-05-02 15:43:16', '2025-05-02 15:43:16'); +INSERT INTO `zy_club` VALUES (4, 1, '聚点羽毛球俱乐部', '聚点', '/assets/img/qrcode.png', '广东省/东莞市/东城街道', 'NULL 50字简介', 0, '/assets/img/qrcode.png', 2, '2', '高手多,不控球,帅哥多', 1, '2025-05-02 15:50:15', '2025-05-02 15:50:15'); -- ---------------------------- -- Table structure for zy_complaint @@ -8399,11 +8418,15 @@ CREATE TABLE `zy_complaint` ( `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '投诉举报' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '投诉举报' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_complaint -- ---------------------------- +INSERT INTO `zy_complaint` VALUES (1, 1, 0, '我要投诉', 2, '9527', 18888888888, '/assets/img/avatar.png', '系统太烂', 0, '2025-05-10 15:36:02', '2025-05-10 15:36:02'); +INSERT INTO `zy_complaint` VALUES (2, 3, 2, '我要投诉', 2, '9527', 18888888888, '/assets/img/avatar.png', '系统太烂', 1, '2025-05-10 15:38:44', '2025-05-10 15:42:34'); +INSERT INTO `zy_complaint` VALUES (3, 3, 2, '我要投诉', 2, '9527', 18888888888, '/assets/img/avatar.png', '技术太烂', 0, '2025-05-10 15:42:39', '2025-05-10 15:42:39'); +INSERT INTO `zy_complaint` VALUES (4, 2, 1, '林丹发布的影圈(54842156)', 2, 'admin11', NULL, '/assets/img/avatar.png', '盗图', 0, '2025-05-10 17:03:47', '2025-05-10 17:03:47'); -- ---------------------------- -- Table structure for zy_game @@ -8422,14 +8445,14 @@ CREATE TABLE `zy_game` ( `week` tinyint(4) NULL DEFAULT NULL COMMENT '星期几:0-6分别周日到周六', `start_time` time NULL DEFAULT NULL COMMENT '开始时间', `end_time` time NULL DEFAULT NULL COMMENT '结束时间', - `public_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发布时间(天)', - `join_start_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报名开始时间(时)', - `join_end_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报名截止时间(时)', - `quit_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '免费退坑时间(时)', + `public_time` datetime NULL DEFAULT NULL COMMENT '发布时间(天)', + `join_start_time` datetime NULL DEFAULT NULL COMMENT '报名开始时间(时)', + `join_end_time` datetime NULL DEFAULT NULL COMMENT '报名截止时间(时)', + `quit_time` datetime NULL DEFAULT NULL COMMENT '免费退坑时间(时)', `game_time` decimal(3, 1) NULL DEFAULT NULL COMMENT '比赛时长(时)', `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地点', `field` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '场地号', - `position` point NULL COMMENT '经纬度', + `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经纬度', `cost` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报名费用(收款方式)', `limit_num` int(11) NOT NULL DEFAULT 0 COMMENT '报名限制人数', `join_num` int(11) NOT NULL DEFAULT 0 COMMENT '报名人数', @@ -8444,13 +8467,17 @@ CREATE TABLE `zy_game` ( `referee` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '裁判', `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间', `update_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '赛事' ROW_FORMAT = Dynamic; + PRIMARY KEY (`id`) USING BTREE, + INDEX `public_time`(`public_time` ASC) USING BTREE, + INDEX `act_id`(`act_id` ASC) USING BTREE, + INDEX `club_id`(`club_id` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '赛事' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_game -- ---------------------------- -INSERT INTO `zy_game` VALUES (1, 0, 1, 1, 1, '聚点第八届年终团体赛-', 1, 3, '2025-04-30', 3, '15:30:00', '18:30:00', '2025-04-28 15:00:00', '2025-04-29 15:00:00', '2025-04-30 15:00:00', '2025-04-30 15:00:00', 3.5, '泰新路88号', '22', NULL, '{\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 30, 20, 999, 0, '比赛介绍', '/assets/img/qrcode.png', '比赛规则', 1, 1, 1, '2', '2025-04-30 15:32:44', '2025-04-30 15:32:44'); +INSERT INTO `zy_game` VALUES (1, 0, 1, 1, 1, '聚点第八届年终团体赛', 1, 1, '2025-05-02', 2, '09:00:00', '12:30:00', '2025-05-02 09:00:00', '2025-05-03 09:00:00', '2025-05-04 09:00:00', '2025-05-04 08:00:00', 3.5, '泰新路88号', '22', '', '{\"type\":\"1\",\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 30, 0, 0, 0, '活动介绍', '/assets/img/qrcode.png', '比赛规则', 1, 2, 1, '1,2', '2025-04-30 10:45:58', '2025-05-04 09:08:01'); +INSERT INTO `zy_game` VALUES (2, 1, 1, 1, 1, '混双擂台', 1, 1, '2025-05-02', 2, '09:00:00', '12:30:00', '2025-05-02 09:00:00', '2025-05-03 09:00:00', '2025-05-04 09:00:00', '2025-05-04 08:00:00', 3.5, '泰新路88号', '22', NULL, '{\"type\":\"1\",\"man\":\"84\",\"woman\":\"56\",\"extra\":\"10\",\"server\":\"1\"}', 0, 0, 0, 0, '聚点第八届年终团体赛,子活动:混双擂台', '', '', 1, 0, 1, '2', '2025-04-30 11:23:45', '2025-05-04 09:08:01'); -- ---------------------------- -- Table structure for zy_game_join @@ -8513,7 +8540,7 @@ CREATE TABLE `zy_menber` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `club_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '俱乐部', `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户', - `role` tinyint(4) NOT NULL DEFAULT 1 COMMENT '角色(-1黑名单/0退出/1成员/2管理员/4会长)', + `role` tinyint(4) NOT NULL DEFAULT 1 COMMENT '角色(-1黑名单/0退出/1成员/2管理员/3会长)', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', `activity` int(11) NOT NULL DEFAULT 0 COMMENT '组球次数', `game` int(11) NOT NULL DEFAULT 0 COMMENT '比赛次数', @@ -8524,11 +8551,12 @@ CREATE TABLE `zy_menber` ( PRIMARY KEY (`id`) USING BTREE, INDEX `from`(`club_id` ASC) USING BTREE, INDEX `target`(`user_id` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '俱乐部成员' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '俱乐部成员' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_menber -- ---------------------------- +INSERT INTO `zy_menber` VALUES (1, 4, 2, 3, NULL, 0, 0, 0, NULL, '2025-05-02 15:50:15', '2025-05-10 16:15:45'); -- ---------------------------- -- Table structure for zy_message @@ -8538,6 +8566,8 @@ CREATE TABLE `zy_message` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '消息类型(0系统消息/1通知消息/2用户消息/3俱乐部消息)', `from_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源id', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '发信人名称', + `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '发信人头像', `user_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '目标用户', `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '消息内容', `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态(0未读/1已读)', @@ -8600,11 +8630,12 @@ CREATE TABLE `zy_relation` ( PRIMARY KEY (`id`) USING BTREE, INDEX `from`(`user_id` ASC) USING BTREE, INDEX `target`(`target_id` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '关系' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '关系' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of zy_relation -- ---------------------------- +INSERT INTO `zy_relation` VALUES (1, 2, 1, 2, '{\"phone\":0,\"wechat\":0,\"qq\":0}\r\n', '备注名称', 1, '2025-05-10 09:51:05', '2025-05-10 10:43:29'); -- ---------------------------- -- Table structure for zy_sign diff --git a/thinkphp/helper.php b/thinkphp/helper.php index 12683cf..a43f6be 100644 --- a/thinkphp/helper.php +++ b/thinkphp/helper.php @@ -587,3 +587,62 @@ if (!function_exists('collection')) { } } } +if (!function_exists('dd')) { + /** + * 调试打印 + */ + function dd(...$params) + { + echo '
';
+        foreach ($params as $p) {
+            print_r($p);
+            echo '
+            
'; + } + echo '
'; + die; + } +} + +if (!function_exists('getsql')) { + /** + * 调试打印 + */ + function getsql($query) + { + echo '
';
+        print_r($query->fetchSql()->select());
+        echo '
'; + die; + } +} + +if (!function_exists('buildTree')) { + /** + * 生成树结构 + */ + function buildTree($items): array + { + $refer = []; + foreach ($items as $k => $v) { + if (!isset($v['id']) || !isset($v['pid'])) { + return []; // 缺少id和pid + } + $items[$k]['child'] = []; + $refer[$v['id']] = &$items[$k]; //为每个项目建立引用关系 + } + foreach ($items as $k => $v) { + if (empty($v['pid'])) continue; + $parent = &$refer[$v['pid']]; //获取父项目的引用 + $parent['child'][] = &$items[$k]; //在父项目的child中再添加一个引用成员 + } + // 排除非顶级项目 + $group_ids = array_column($items, 'id'); + foreach ($items as $k => $v) { + if (in_array($v['pid'], $group_ids)) { + unset($items[$k]); + } + } + return array_values($items); + } +}