From 8867d27f709a1341b2c78aeff7a185b991427e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=A0=E7=9A=84=E5=90=8D=E5=AD=97?= <你的邮箱> Date: Thu, 26 Feb 2026 19:45:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=AB=E9=80=9F=E6=B4=BE=E5=8D=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=86=E7=A6=BB=20&=20=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=20&=20?= =?UTF-8?q?=E8=80=83=E8=AF=95=E5=8A=9F=E8=83=BD=E9=85=8D=E7=BD=AE=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/peidu/config/MyBatisPlusConfig.java | 127 + .../peidu/controller/InitDataController.java | 3713 +++++++++++++++++ peidu/uniapp/pages.json | 1078 +++++ .../pages/manager/quick-assign.vue | 23 + peidu/uniapp/src/pages.json | 1466 +++++++ .../booking/components/ManagerBooking.vue | 513 +++ .../src/pages/booking/quick-booking.vue | 154 + .../pages/index/components/ManagerHome.vue | 1218 ++++++ 8 files changed, 8292 insertions(+) create mode 100644 peidu/backend/src/main/java/com/peidu/config/MyBatisPlusConfig.java create mode 100644 peidu/backend/src/main/java/com/peidu/controller/InitDataController.java create mode 100644 peidu/uniapp/pages.json create mode 100644 peidu/uniapp/src/manager-package/pages/manager/quick-assign.vue create mode 100644 peidu/uniapp/src/pages.json create mode 100644 peidu/uniapp/src/pages/booking/components/ManagerBooking.vue create mode 100644 peidu/uniapp/src/pages/booking/quick-booking.vue create mode 100644 peidu/uniapp/src/pages/index/components/ManagerHome.vue diff --git a/peidu/backend/src/main/java/com/peidu/config/MyBatisPlusConfig.java b/peidu/backend/src/main/java/com/peidu/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..9296816 --- /dev/null +++ b/peidu/backend/src/main/java/com/peidu/config/MyBatisPlusConfig.java @@ -0,0 +1,127 @@ +package com.peidu.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import com.peidu.context.TenantContext; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.LongValue; +import net.sf.jsqlparser.expression.NullValue; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Arrays; +import java.util.List; + +/** + * MyBatis Plus配置 + */ +@Configuration +public class MyBatisPlusConfig { + + /** + * 租户插件 + 分页插件 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + + // 1. 租户插件(必须在分页插件之前) + interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new TenantLineHandler() { + @Override + public Expression getTenantId() { + Long tenantId = TenantContext.getTenantId(); + // 如果租户ID为null,返回默认租户ID 1 + // 避免生成 WHERE tenant_id = NULL 的错误SQL + if (tenantId == null) { + return new LongValue(1L); + } + return new LongValue(tenantId); + } + + @Override + public String getTenantIdColumn() { + return "tenant_id"; + } + + @Override + public boolean ignoreTable(String tableName) { + // 忽略不需要租户过滤的表 + List ignoreTables = Arrays.asList( + // 系统管理表 + "admin", "role", "permission", "role_permission", "admin_role", + "system_config", "operation_log", + + // 租户管理表 + "tenant", "tenant_admin", "tenant_config", "tenant_package", + "tenant_order", "tenant_statistics", + + // 加盟管理表 + "franchise_application", "franchise_follow_record", + "franchise_policy", "franchise_contract", "franchise_payment", + + // 全局数据表(所有租户共享) + "banner", "service_category", "announcement", + "parent_academy_course", "summer_camp", "growth_planning_service", + "tutoring_service", "study_tour", "special_course", + "interest_course", "online_supervision", "assessment_service", + + // 用户相关表(测试环境忽略租户过滤) + "user", "parent", "student", "teacher", "teacher_schedule", + "manager", "provider", "schedule", "checkin_record", + + // 服务和订单相关表(测试环境忽略租户过滤) + "service", "training_course", "`order`", "order", "payment_record", + "check_in_record", "learning_record", "review", + "work_order", "growth_record", + + // 营销和活动相关表(测试环境忽略租户过滤) + "coupon", "user_coupon", "marketing_activity", "activity", "group_buying", + "group_buying_team", "group_buying_member", + + // 时卡和套餐相关表(测试环境忽略租户过滤) + "time_card", "time_card_usage", "package", "user_package", + + // 积分和钱包相关表(测试环境忽略租户过滤) + "points_record", "wallet", "wallet_record", "withdraw_record", + "wallet_transaction", + + // 通知和反馈相关表(测试环境忽略租户过滤) + "notification", "feedback", "sms_record", "announcement", + + // 提醒管理表(测试环境忽略租户过滤) + "reminder", + + // 提现相关表 + "withdraw", + + "teacher_video", + + // 陪伴员等级/考核相关表(避免缺少 tenant_id 时出现 SQL 异常) + "teacher_level", + "exam_question", + "exam_record", + "exam_answer", + + // 协议和物资相关表 + "agreement", "material", + + // 客服相关表 + "customer_service_staff", "customer_service_record", + + // 分销相关表(测试环境忽略租户过滤) + "distributor", "distributor_commission", "distributor_withdraw" + ); + + return ignoreTables.contains(tableName.toLowerCase()); + } + })); + + // 2. 分页插件 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + + return interceptor; + } +} diff --git a/peidu/backend/src/main/java/com/peidu/controller/InitDataController.java b/peidu/backend/src/main/java/com/peidu/controller/InitDataController.java new file mode 100644 index 0000000..605984f --- /dev/null +++ b/peidu/backend/src/main/java/com/peidu/controller/InitDataController.java @@ -0,0 +1,3713 @@ +package com.peidu.controller; + +import com.peidu.common.Result; +import com.peidu.util.PasswordUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * 初始化测试数据接口 + * 注意:此接口仅在开发环境可用 + */ +@RestController +@RequestMapping("/api/init") +public class InitDataController { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Value("${spring.profiles.active:dev}") + private String activeProfile; + + /** + * 检查是否为开发环境 + */ + private void checkDevEnvironment() { + if (!"dev".equals(activeProfile) && !"test".equals(activeProfile)) { + throw new RuntimeException("此接口仅在开发/测试环境可用"); + } + } + + /** + * 初始化所有测试数据 + */ + @PostMapping("/all") + public Result initAllData() { + checkDevEnvironment(); + Map result = new HashMap<>(); + + try { + // 1. 初始化管理员 + initAdmin(); + result.put("admin", "success"); + + // 2. 初始化用户 + initUsers(); + result.put("users", "success"); + + // 3. 初始化服务分类 + initCategories(); + result.put("categories", "success"); + + // 4. 初始化服务 + initServices(); + result.put("services", "success"); + + // 5. 初始化时卡 + initTimeCards(); + result.put("timeCards", "success"); + + // 6. 初始化优惠券 + initCoupons(); + result.put("coupons", "success"); + + return Result.success(result); + } catch (Exception e) { + return Result.error("初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化管理员 + */ + @PostMapping("/admin") + public Result initAdmin() { + checkDevEnvironment(); + try { + // 检查是否已存在 + Integer count = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM admin WHERE username = 'admin'", Integer.class); + + if (count == null || count == 0) { + jdbcTemplate.update( + "INSERT INTO admin (username, password, name, phone, status, create_time) VALUES (?, ?, ?, ?, ?, NOW())", + "admin", "$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHsM8lE9lBOsl7iKt6Z5EH", "超级管理员", "13800000000", 1 + ); + } + return Result.success("管理员初始化成功"); + } catch (Exception e) { + return Result.error("管理员初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化用户数据 + */ + @PostMapping("/users") + public Result initUsers() { + checkDevEnvironment(); + try { + String encodedPassword = PasswordUtil.encode("123456"); + String[] sqls = { + "INSERT IGNORE INTO user (id, tenant_id, phone, nickname, avatar, role, status, create_time) VALUES (1, 1, '13800138001', '测试家长', '/static/avatar.png', 'parent', 1, NOW())", + "INSERT IGNORE INTO user (id, tenant_id, phone, nickname, avatar, role, status, create_time) VALUES (2, 1, '13800138002', '张老师', '/static/avatar.png', 'teacher', 1, NOW())", + "INSERT IGNORE INTO user (id, tenant_id, phone, nickname, avatar, role, status, create_time) VALUES (3, 1, '13800138003', '李老师', '/static/avatar.png', 'teacher', 1, NOW())" + }; + for (String sql : sqls) { + try { jdbcTemplate.update(sql); } catch (Exception ignored) {} + } + + String[] testPhones = {"13800138001", "13800138002", "13800138003"}; + for (String phone : testPhones) { + jdbcTemplate.update("UPDATE user SET password = ? WHERE phone = ?", encodedPassword, phone); + } + return Result.success("用户初始化成功"); + } catch (Exception e) { + return Result.error("用户初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化服务分类 + */ + @PostMapping("/categories") + public Result initCategories() { + checkDevEnvironment(); + try { + String[] names = {"基准式陪伴", "暖心式陪伴", "伙伴式陪伴", "管家式陪伴", "叠加式陪伴", "专项陪伴", "天赋测评", "成长规划"}; + for (int i = 0; i < names.length; i++) { + try { + jdbcTemplate.update( + "INSERT INTO service_category (name, icon, sort, status, create_time) VALUES (?, ?, ?, 1, NOW())", + names[i], "/static/icons/cat" + (i+1) + ".png", i+1 + ); + } catch (Exception ignored) {} + } + return Result.success("分类初始化成功"); + } catch (Exception e) { + return Result.error("分类初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化服务 + */ + @PostMapping("/services") + public Result initServices() { + checkDevEnvironment(); + try { + Object[][] services = { + {1, "基准式陪伴-普通老师", "入户陪伴,专业陪伴员一对一服务", 99.00, 199.00, "basic"}, + {1, "基准式陪伴-金牌老师", "金牌陪伴员入户服务", 199.00, 299.00, "basic_gold"}, + {2, "暖心式陪伴", "温暖陪伴,关注心理健康", 159.00, 259.00, "warm"}, + {3, "伙伴式陪伴", "像朋友一样陪伴成长", 129.00, 229.00, "partner"}, + {6, "语文专项辅导", "小学语文专项提升", 149.00, 249.00, "special"}, + {6, "数学专项辅导", "小学数学专项提升", 149.00, 249.00, "special"}, + {7, "天赋测评服务", "发现孩子的天赋潜能", 299.00, 499.00, "assessment"}, + {8, "成长规划咨询", "专业规划师一对一咨询", 399.00, 599.00, "planning"} + }; + for (Object[] s : services) { + try { + jdbcTemplate.update( + "INSERT INTO service (tenant_id, category_id, name, description, cover_image, price, original_price, service_type, status, create_time) VALUES (1, ?, ?, ?, '/static/service.png', ?, ?, ?, 1, NOW())", + s[0], s[1], s[2], s[3], s[4], s[5] + ); + } catch (Exception ignored) {} + } + return Result.success("服务初始化成功"); + } catch (Exception e) { + return Result.error("服务初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化时卡 + */ + @PostMapping("/timecards") + public Result initTimeCards() { + checkDevEnvironment(); + try { + Object[][] cards = { + {1, "TC202601060001", "体验卡", "basic", 2.00, 0.00, 2.00, 99.00, 1}, + {1, "TC202601060002", "月卡", "basic", 20.00, 5.00, 15.00, 1599.00, 1}, + {2, "TC202601060003", "季卡", "warm", 60.00, 10.00, 50.00, 4299.00, 1} + }; + for (Object[] c : cards) { + try { + jdbcTemplate.update( + "INSERT INTO time_card (tenant_id, user_id, card_no, card_name, card_type, total_hours, used_hours, remaining_hours, price, status, create_time) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8] + ); + } catch (Exception ignored) {} + } + return Result.success("时卡初始化成功"); + } catch (Exception e) { + return Result.error("时卡初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化优惠券 + */ + @PostMapping("/coupons") + public Result initCoupons() { + checkDevEnvironment(); + try { + Object[][] coupons = { + {"新用户专享券", "amount", 50.00, 100.00, 1000, 0}, + {"满200减30", "amount", 30.00, 200.00, 500, 50}, + {"9折优惠券", "discount", 0.90, 0.00, 200, 20} + }; + for (Object[] c : coupons) { + try { + jdbcTemplate.update( + "INSERT INTO coupon (tenant_id, name, type, value, min_amount, total_count, used_count, start_time, end_time, status, create_time) VALUES (1, ?, ?, ?, ?, ?, ?, NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY), 1, NOW())", + c[0], c[1], c[2], c[3], c[4], c[5] + ); + } catch (Exception ignored) {} + } + return Result.success("优惠券初始化成功"); + } catch (Exception e) { + return Result.error("优惠券初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化套餐包 + */ + @PostMapping("/packages") + public Result initPackages() { + checkDevEnvironment(); + try { + // 先创建 package 表(如果不存在) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS package (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "package_name VARCHAR(100)," + + "package_type VARCHAR(50)," + + "total_hours DECIMAL(10,2)," + + "service_count INT," + + "price DECIMAL(10,2)," + + "original_price DECIMAL(10,2)," + + "valid_days INT," + + "service_types VARCHAR(500)," + + "description TEXT," + + "features TEXT," + + "status INT DEFAULT 1," + + "sort_order INT DEFAULT 0," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + } catch (Exception ignored) {} + + // 插入套餐数据 + Object[][] packages = { + {"暖心式陪伴200小时", "warm", 200.00, 0, 24900.00, 49800.00, 365, "warm", "200小时 · 有效期365天", "专业陪伴员,心理辅导,学习规划", 1}, + {"基准式陪伴100小时", "basic", 100.00, 0, 12900.00, 25800.00, 365, "basic", "100小时 · 有效期365天", "专业陪伴员,作业辅导,习惯培养", 2} + }; + + int count = 0; + for (Object[] p : packages) { + try { + jdbcTemplate.update( + "INSERT INTO package (tenant_id, package_name, package_type, total_hours, service_count, price, original_price, valid_days, service_types, description, features, sort_order, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10] + ); + count++; + } catch (Exception ignored) {} + } + return Result.success("套餐包初始化成功,共添加 " + count + " 个套餐"); + } catch (Exception e) { + return Result.error("套餐包初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化学生 + */ + @PostMapping("/students") + public Result initStudents() { + checkDevEnvironment(); + try { + Object[][] students = { + {1, "小明", 1, 8, "三年级", "实验小学"}, + {1, "小红", 0, 10, "五年级", "实验小学"} + }; + for (Object[] s : students) { + try { + jdbcTemplate.update( + "INSERT INTO student (tenant_id, user_id, name, gender, age, grade, school, create_time) VALUES (1, ?, ?, ?, ?, ?, ?, NOW())", + s[0], s[1], s[2], s[3], s[4], s[5] + ); + } catch (Exception ignored) {} + } + return Result.success("学生初始化成功"); + } catch (Exception e) { + return Result.error("学生初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化陪伴员 + */ + @PostMapping("/teachers") + public Result initTeachers() { + checkDevEnvironment(); + try { + Object[][] teachers = { + {2, "张老师", "13800138002", 1, "本科", "教育学", 3, "语文,数学", 1, 80.00}, + {3, "李老师", "13800138003", 0, "研究生", "心理学", 5, "英语,心理", 0, 60.00} + }; + for (Object[] t : teachers) { + try { + jdbcTemplate.update( + "INSERT INTO teacher (tenant_id, user_id, name, phone, gender, education, major, experience, subjects, is_gold, hourly_rate, status, create_time) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, NOW())", + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] + ); + } catch (Exception ignored) {} + } + return Result.success("陪伴员初始化成功"); + } catch (Exception e) { + return Result.error("陪伴员初始化失败: " + e.getMessage()); + } + } + + /** + * 修复数据库表结构 - 添加缺失字段 + */ + @RequestMapping(value = "/fix-tables", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixTables() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 修复 withdraw 表 + String[] withdrawColumns = { + "ALTER TABLE withdraw ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE withdraw ADD COLUMN user_id BIGINT", + "ALTER TABLE withdraw ADD COLUMN audit_time DATETIME", + "ALTER TABLE withdraw ADD COLUMN withdraw_no VARCHAR(50)", + "ALTER TABLE withdraw ADD COLUMN fee DECIMAL(10,2) DEFAULT 0", + "ALTER TABLE withdraw ADD COLUMN actual_amount DECIMAL(10,2)", + "ALTER TABLE withdraw ADD COLUMN account_type VARCHAR(20)", + "ALTER TABLE withdraw ADD COLUMN account_no VARCHAR(100)", + "ALTER TABLE withdraw ADD COLUMN account_name VARCHAR(50)", + "ALTER TABLE withdraw ADD COLUMN apply_time DATETIME", + "ALTER TABLE withdraw ADD COLUMN approve_time DATETIME", + "ALTER TABLE withdraw ADD COLUMN complete_time DATETIME", + "ALTER TABLE withdraw ADD COLUMN approver_id BIGINT", + "ALTER TABLE withdraw ADD COLUMN reject_reason VARCHAR(500)", + "ALTER TABLE withdraw ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : withdrawColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("withdraw", "fixed"); + + // 修复 banner 表 + String[] bannerColumns = { + "ALTER TABLE banner ADD COLUMN sort INT DEFAULT 0", + "ALTER TABLE banner ADD COLUMN link_type VARCHAR(20) DEFAULT 'page'", + "ALTER TABLE banner ADD COLUMN link_value VARCHAR(500)", + "ALTER TABLE banner ADD COLUMN start_time DATETIME", + "ALTER TABLE banner ADD COLUMN end_time DATETIME", + "ALTER TABLE banner ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : bannerColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("banner", "fixed"); + + // 修复 announcement 表 + String[] announcementColumns = { + "ALTER TABLE announcement ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE announcement ADD COLUMN start_time DATETIME", + "ALTER TABLE announcement ADD COLUMN end_time DATETIME", + "ALTER TABLE announcement ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : announcementColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("announcement", "fixed"); + + // 修复 coupon 表 + String[] couponColumns = { + "ALTER TABLE coupon ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE coupon ADD COLUMN deleted INT DEFAULT 0", + "ALTER TABLE coupon ADD COLUMN name VARCHAR(100)", + "ALTER TABLE coupon ADD COLUMN type VARCHAR(20)", + "ALTER TABLE coupon ADD COLUMN amount DECIMAL(10,2)", + "ALTER TABLE coupon ADD COLUMN received_count INT DEFAULT 0", + "ALTER TABLE coupon ADD COLUMN used_count INT DEFAULT 0" + }; + for (String sql : couponColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + // 用 coupon_name 填充 name 字段 + try { + jdbcTemplate.execute("UPDATE coupon SET name = coupon_name WHERE name IS NULL OR name = ''"); + } catch (Exception ignored) {} + // 用 discount_value 填充 amount 字段 + try { + jdbcTemplate.execute("UPDATE coupon SET amount = discount_value WHERE amount IS NULL"); + } catch (Exception ignored) {} + // 用 coupon_type 填充 type 字段 + try { + jdbcTemplate.execute("UPDATE coupon SET type = CASE WHEN coupon_type = 1 THEN 'amount' ELSE 'discount' END WHERE type IS NULL OR type = ''"); + } catch (Exception ignored) {} + // 用 receive_count 填充 received_count + try { + jdbcTemplate.execute("UPDATE coupon SET received_count = receive_count WHERE received_count IS NULL OR received_count = 0"); + } catch (Exception ignored) {} + // 用 use_count 填充 used_count + try { + jdbcTemplate.execute("UPDATE coupon SET used_count = use_count WHERE used_count IS NULL OR used_count = 0"); + } catch (Exception ignored) {} + results.put("coupon", "fixed"); + + // 修复 service 表 + String[] serviceColumns = { + "ALTER TABLE service ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE service ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : serviceColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("service", "fixed"); + + // 修复 franchise_policy 表 + String[] franchisePolicyColumns = { + "ALTER TABLE franchise_policy ADD COLUMN sort_order INT DEFAULT 0", + "ALTER TABLE franchise_policy ADD COLUMN policy_type VARCHAR(50)", + "ALTER TABLE franchise_policy ADD COLUMN icon VARCHAR(255)", + "ALTER TABLE franchise_policy ADD COLUMN status INT DEFAULT 1" + }; + for (String sql : franchisePolicyColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("franchise_policy", "fixed"); + + // 修复 assessment_service 表 + String[] assessmentServiceColumns = { + "ALTER TABLE assessment_service ADD COLUMN sort_order INT DEFAULT 0", + "ALTER TABLE assessment_service ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE assessment_service ADD COLUMN appointment_count INT DEFAULT 0", + "ALTER TABLE assessment_service ADD COLUMN view_count INT DEFAULT 0", + "ALTER TABLE assessment_service ADD COLUMN rating DECIMAL(3,2) DEFAULT 5.0", + "ALTER TABLE assessment_service ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : assessmentServiceColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("assessment_service", "fixed"); + + // 修复 service_category 表 + String[] serviceCategoryColumns = { + "ALTER TABLE service_category ADD COLUMN sort INT DEFAULT 0", + "ALTER TABLE service_category ADD COLUMN sort_order INT DEFAULT 0", + "ALTER TABLE service_category ADD COLUMN category_name VARCHAR(100)" + }; + for (String sql : serviceCategoryColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("service_category", "fixed"); + + // 修复 time_card 表 + String[] timeCardColumns = { + "ALTER TABLE time_card ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE time_card ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : timeCardColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("time_card", "fixed"); + + String[] teacherVideoColumns = { + "ALTER TABLE teacher_video ADD COLUMN tenant_id BIGINT DEFAULT 1" + }; + for (String sql : teacherVideoColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("teacher_video", "fixed"); + + // 创建 agreement 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS agreement (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "title VARCHAR(200)," + + "type VARCHAR(50)," + + "version VARCHAR(20)," + + "content TEXT," + + "status INT DEFAULT 1," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + results.put("agreement", "created"); + } catch (Exception e) { + results.put("agreement", "exists or error: " + e.getMessage()); + } + + // 创建 material 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS material (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(200)," + + "category VARCHAR(50)," + + "unit VARCHAR(20)," + + "stock INT DEFAULT 0," + + "price DECIMAL(10,2) DEFAULT 0," + + "remark VARCHAR(500)," + + "status INT DEFAULT 1," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + results.put("material", "created"); + } catch (Exception e) { + results.put("material", "exists or error: " + e.getMessage()); + } + + // 修复 teacher 表 - 给 user_id 添加默认值 + try { + jdbcTemplate.execute("ALTER TABLE teacher MODIFY COLUMN user_id BIGINT DEFAULT 0"); + results.put("teacher_user_id", "fixed"); + } catch (Exception e) { + results.put("teacher_user_id", "error: " + e.getMessage()); + } + + // 修复 work_order 表 + String[] workOrderColumns = { + "ALTER TABLE work_order ADD COLUMN work_order_no VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE work_order ADD COLUMN order_id BIGINT", + "ALTER TABLE work_order ADD COLUMN student_id BIGINT", + "ALTER TABLE work_order ADD COLUMN student_name VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN teacher_id BIGINT", + "ALTER TABLE work_order ADD COLUMN teacher_name VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN service_type VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN service_date DATE", + "ALTER TABLE work_order ADD COLUMN time_slot VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN address VARCHAR(500)", + "ALTER TABLE work_order ADD COLUMN status INT DEFAULT 0", + "ALTER TABLE work_order ADD COLUMN create_time DATETIME DEFAULT CURRENT_TIMESTAMP", + "ALTER TABLE work_order ADD COLUMN update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + }; + for (String sql : workOrderColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("work_order", "fixed"); + + return Result.success(results); + } + + /** + * 初始化协议数据 + */ + @PostMapping("/agreements") + public Result initAgreements() { + checkDevEnvironment(); + try { + // 先创建表 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS agreement (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "title VARCHAR(200)," + + "type VARCHAR(50)," + + "version VARCHAR(20)," + + "content TEXT," + + "status INT DEFAULT 1," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + Object[][] agreements = { + {"用户服务协议", "user", "v1.0", "欢迎使用陪读管理系统。本协议是您与平台之间关于使用平台服务的法律协议..."}, + {"隐私政策", "privacy", "v1.0", "我们重视您的隐私保护。本隐私政策说明了我们如何收集、使用和保护您的个人信息..."}, + {"陪伴员服务协议", "teacher", "v1.0", "本协议是陪伴员与平台之间关于提供陪伴服务的法律协议..."} + }; + for (Object[] a : agreements) { + try { + jdbcTemplate.update( + "INSERT INTO agreement (title, type, version, content, status, create_time) VALUES (?, ?, ?, ?, 1, NOW())", + a[0], a[1], a[2], a[3] + ); + } catch (Exception ignored) {} + } + return Result.success("协议初始化成功"); + } catch (Exception e) { + return Result.error("协议初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化客服相关表 + */ + @PostMapping("/customer-service") + public Result initCustomerService() { + checkDevEnvironment(); + try { + // 创建客服人员表 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS customer_service_staff (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "type VARCHAR(20)," + + "status INT DEFAULT 1," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + // 创建客服咨询记录表 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS customer_service_record (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "user_id BIGINT," + + "user_name VARCHAR(50)," + + "phone VARCHAR(20)," + + "type VARCHAR(20)," + + "content TEXT," + + "staff_id BIGINT," + + "staff_name VARCHAR(50)," + + "reply_content TEXT," + + "status INT DEFAULT 0," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + // 插入测试数据 + jdbcTemplate.update("INSERT IGNORE INTO customer_service_staff (id, name, phone, type, status) VALUES (1, '张客服', '13800001111', 'online', 1)"); + jdbcTemplate.update("INSERT IGNORE INTO customer_service_staff (id, name, phone, type, status) VALUES (2, '李客服', '13800002222', 'hotline', 1)"); + + return Result.success("客服模块初始化成功"); + } catch (Exception e) { + return Result.error("客服模块初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化水印打卡表 + */ + @PostMapping("/checkin") + public Result initCheckIn() { + checkDevEnvironment(); + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS checkin_record (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "work_order_id BIGINT," + + "work_order_no VARCHAR(50)," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "teacher_phone VARCHAR(20)," + + "type VARCHAR(20)," + + "check_time DATETIME," + + "location VARCHAR(500)," + + "gps VARCHAR(100)," + + "photo VARCHAR(500)," + + "status VARCHAR(20) DEFAULT 'normal'," + + "remark VARCHAR(500)," + + "audit_result VARCHAR(20)," + + "audit_remark VARCHAR(500)," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + return Result.success("水印打卡表初始化成功"); + } catch (Exception e) { + return Result.error("水印打卡表初始化失败: " + e.getMessage()); + } + } + + /** + * 初始化物资数据 + */ + @PostMapping("/materials") + public Result initMaterials() { + checkDevEnvironment(); + try { + // 先创建表 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS material (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(200)," + + "category VARCHAR(50)," + + "unit VARCHAR(20)," + + "stock INT DEFAULT 0," + + "price DECIMAL(10,2) DEFAULT 0," + + "remark VARCHAR(500)," + + "status INT DEFAULT 1," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + Object[][] materials = { + {"教学白板", "teaching", "块", 50, 299.00}, + {"学习资料包", "teaching", "套", 200, 49.90}, + {"宣传海报", "promotion", "张", 500, 5.00}, + {"办公文具套装", "office", "套", 30, 89.00} + }; + for (Object[] m : materials) { + try { + jdbcTemplate.update( + "INSERT INTO material (name, category, unit, stock, price, status, create_time) VALUES (?, ?, ?, ?, ?, 1, NOW())", + m[0], m[1], m[2], m[3], m[4] + ); + } catch (Exception ignored) {} + } + return Result.success("物资初始化成功"); + } catch (Exception e) { + return Result.error("物资初始化失败: " + e.getMessage()); + } + } + + /** + * 修复学生表中的家长信息 + */ + @RequestMapping(value = "/fix-student-parent", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixStudentParent() { + checkDevEnvironment(); + try { + // 1. 通过关联 user 表更新家长信息 + int updated1 = jdbcTemplate.update( + "UPDATE student s " + + "LEFT JOIN user u ON s.user_id = u.id " + + "SET s.parent_name = COALESCE(u.real_name, u.nickname, CONCAT('家长', s.id)), " + + " s.parent_phone = COALESCE(u.phone, '13800000000') " + + "WHERE s.parent_name IS NULL OR s.parent_name = '' OR s.parent_phone IS NULL OR s.parent_phone = ''" + ); + + // 2. 对于没有关联用户的学生,设置默认值 + int updated2 = jdbcTemplate.update( + "UPDATE student SET parent_name = CONCAT('家长', id) WHERE parent_name IS NULL OR parent_name = ''" + ); + + int updated3 = jdbcTemplate.update( + "UPDATE student SET parent_phone = '13800000000' WHERE parent_phone IS NULL OR parent_phone = ''" + ); + + Map result = new HashMap<>(); + result.put("updatedByUser", updated1); + result.put("updatedParentName", updated2); + result.put("updatedParentPhone", updated3); + result.put("message", "学生家长信息修复完成"); + + return Result.success(result); + } catch (Exception e) { + return Result.error("修复失败: " + e.getMessage()); + } + } + + /** + * 创建缺失的数据库表 + */ + @RequestMapping(value = "/create-missing-tables", method = {RequestMethod.GET, RequestMethod.POST}) + public Result createMissingTables() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 创建 manager 表(管理师) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS manager (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "user_id BIGINT," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "gender TINYINT DEFAULT 0," + + "avatar VARCHAR(255)," + + "id_card VARCHAR(20)," + + "education VARCHAR(50)," + + "experience INT DEFAULT 0," + + "service_area VARCHAR(200)," + + "manage_count INT DEFAULT 0," + + "audit_status TINYINT DEFAULT 0 COMMENT '0待审核 1已通过 2未通过'," + + "status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("manager", "created"); + } catch (Exception e) { results.put("manager", "error: " + e.getMessage()); } + + // 创建 distributor 表(分销员) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "user_id BIGINT," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "type VARCHAR(20) DEFAULT 'parttime' COMMENT 'fulltime专职 parttime兼职'," + + "area VARCHAR(200)," + + "id_card VARCHAR(20)," + + "order_count INT DEFAULT 0," + + "total_commission DECIMAL(10,2) DEFAULT 0," + + "audit_status TINYINT DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("distributor", "created"); + } catch (Exception e) { results.put("distributor", "error: " + e.getMessage()); } + + // 创建 provider 表(专业服务商) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS provider (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "user_id BIGINT," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "service_type VARCHAR(50)," + + "qualification VARCHAR(500)," + + "business_license VARCHAR(500)," + + "description VARCHAR(500)," + + "experience VARCHAR(100)," + + "service_area VARCHAR(200)," + + "introduction TEXT," + + "audit_status TINYINT DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("provider", "created"); + } catch (Exception e) { results.put("provider", "error: " + e.getMessage()); } + + // 创建 growth_record 表(成长记录) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS growth_record (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "student_id BIGINT," + + "student_name VARCHAR(50)," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "order_id BIGINT," + + "record_date DATE," + + "record_type VARCHAR(20) DEFAULT 'daily'," + + "content TEXT," + + "images TEXT," + + "videos TEXT," + + "study_duration INT DEFAULT 0," + + "subjects VARCHAR(200)," + + "performance_score INT," + + "focus_score INT," + + "homework_status VARCHAR(100)," + + "highlights TEXT," + + "improvements TEXT," + + "suggestions TEXT," + + "attachments TEXT," + + "status TINYINT DEFAULT 0," + + "parent_read TINYINT DEFAULT 0," + + "parent_read_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("growth_record", "created"); + } catch (Exception e) { results.put("growth_record", "error: " + e.getMessage()); } + + // 创建 review 表(评价) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS review (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "order_id BIGINT," + + "user_id BIGINT," + + "service_id BIGINT," + + "teacher_id BIGINT," + + "rating INT DEFAULT 5," + + "content TEXT," + + "images TEXT," + + "anonymous TINYINT DEFAULT 0," + + "reply TEXT," + + "reply_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("review", "created"); + } catch (Exception e) { results.put("review", "error: " + e.getMessage()); } + + // 创建 work_order 表(工单) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS work_order (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "work_order_no VARCHAR(50)," + + "order_id BIGINT," + + "student_id BIGINT," + + "student_name VARCHAR(50)," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "service_type VARCHAR(50)," + + "service_date DATE," + + "time_slot VARCHAR(50)," + + "address VARCHAR(500)," + + "status TINYINT DEFAULT 0," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("work_order", "created"); + } catch (Exception e) { results.put("work_order", "error: " + e.getMessage()); } + + // 创建 banner 表(轮播图) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS banner (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "title VARCHAR(100)," + + "image VARCHAR(500)," + + "link_type VARCHAR(20) DEFAULT 'page'," + + "link_value VARCHAR(500)," + + "sort INT DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "start_time DATETIME," + + "end_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("banner", "created"); + } catch (Exception e) { results.put("banner", "error: " + e.getMessage()); } + + // 创建 announcement 表(公告) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS announcement (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "title VARCHAR(200)," + + "content TEXT," + + "status TINYINT DEFAULT 1," + + "start_time DATETIME," + + "end_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("announcement", "created"); + } catch (Exception e) { results.put("announcement", "error: " + e.getMessage()); } + + // 创建 franchise_application 表(加盟申请) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS franchise_application (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "city VARCHAR(100)," + + "remark TEXT," + + "status TINYINT DEFAULT 0 COMMENT '0待处理 1已通过 2已拒绝'," + + "follow_count INT DEFAULT 0," + + "last_follow_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ")" + ); + results.put("franchise_application", "created"); + } catch (Exception e) { results.put("franchise_application", "error: " + e.getMessage()); } + + // 创建 coupon 表(优惠券) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS coupon (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "name VARCHAR(100)," + + "type VARCHAR(20) COMMENT 'amount-满减 discount-折扣'," + + "value DECIMAL(10,2)," + + "min_amount DECIMAL(10,2) DEFAULT 0," + + "total_count INT DEFAULT 0," + + "used_count INT DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "start_time DATETIME," + + "end_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("coupon", "created"); + } catch (Exception e) { results.put("coupon", "error: " + e.getMessage()); } + + // 创建 withdraw 表(提现记录) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS withdraw (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "user_id BIGINT," + + "teacher_id BIGINT," + + "withdraw_no VARCHAR(50)," + + "amount DECIMAL(10,2)," + + "fee DECIMAL(10,2) DEFAULT 0," + + "actual_amount DECIMAL(10,2)," + + "account_type VARCHAR(20)," + + "account_no VARCHAR(100)," + + "account_name VARCHAR(50)," + + "status VARCHAR(20) DEFAULT '0'," + + "remark VARCHAR(500)," + + "reject_reason VARCHAR(500)," + + "apply_time DATETIME," + + "audit_time DATETIME," + + "approve_time DATETIME," + + "complete_time DATETIME," + + "approver_id BIGINT," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("withdraw", "created"); + } catch (Exception e) { results.put("withdraw", "error: " + e.getMessage()); } + + // 创建 tenant 表(租户) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS tenant (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_code VARCHAR(50) UNIQUE," + + "tenant_name VARCHAR(100)," + + "tenant_type VARCHAR(20) COMMENT 'headquarters-总部 branch-分部 franchise-加盟商'," + + "level INT DEFAULT 1," + + "path VARCHAR(500)," + + "contact_name VARCHAR(50)," + + "contact_phone VARCHAR(20)," + + "contact_email VARCHAR(100)," + + "address VARCHAR(500)," + + "description TEXT," + + "account_balance DECIMAL(10,2) DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "expire_time DATETIME," + + "teacher_count INT DEFAULT 0," + + "student_count INT DEFAULT 0," + + "service_count INT DEFAULT 0," + + "order_count INT DEFAULT 0," + + "total_sales DECIMAL(12,2) DEFAULT 0," + + "audit_status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ")" + ); + results.put("tenant", "created"); + } catch (Exception e) { results.put("tenant", "error: " + e.getMessage()); } + + return Result.success(results); + } + + /** + * 添加服务商测试数据 + */ + @RequestMapping(value = "/add-provider-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result addProviderData() { + checkDevEnvironment(); + try { + // 先确保表存在且字段正确 + try { + jdbcTemplate.execute("ALTER TABLE provider ADD COLUMN business_license VARCHAR(500)"); + } catch (Exception ignored) {} + try { + jdbcTemplate.execute("ALTER TABLE provider ADD COLUMN description VARCHAR(500)"); + } catch (Exception ignored) {} + try { + jdbcTemplate.execute("ALTER TABLE provider ADD COLUMN deleted INT DEFAULT 0"); + } catch (Exception ignored) {} + + Object[][] providers = { + {"王老师", "13900001001", "书法教学", "书法家协会会员证书", 1}, + {"李老师", "13900001002", "英语教学", "英语专业八级证书", 1}, + {"张老师", "13900001003", "音乐教学", "音乐学院钢琴十级", 0}, + {"刘老师", "13900001004", "美术教学", "美术学院毕业证书", 1}, + {"陈老师", "13900001005", "舞蹈教学", "舞蹈家协会证书", 0} + }; + + int count = 0; + for (Object[] p : providers) { + try { + jdbcTemplate.update( + "INSERT INTO provider (tenant_id, name, phone, description, business_license, status, deleted, create_time, update_time) " + + "VALUES (1, ?, ?, ?, ?, ?, 0, NOW(), NOW())", + p[0], p[1], p[2], p[3], p[4] + ); + count++; + } catch (Exception e) { + // 如果插入失败,记录错误但继续 + System.out.println("Insert provider error: " + e.getMessage()); + } + } + + Map result = new HashMap<>(); + result.put("inserted", count); + result.put("message", "服务商测试数据添加完成"); + return Result.success(result); + } catch (Exception e) { + return Result.error("添加失败: " + e.getMessage()); + } + } + + /** + * 一次性添加管理师、分销员、服务商测试数据 + */ + @RequestMapping(value = "/add-all-role-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result addAllRoleData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 添加管理师数据 (字段: name, phone, service_area, manage_count, audit_status, status) + try { + Object[][] managers = { + {"赵管理", "13800010001", "城东区", 8, 1, 1}, + {"钱管理", "13800010002", "城西区", 12, 1, 1}, + {"孙管理", "13800010003", "城南区", 5, 0, 1}, + {"李管理", "13800010004", "城北区", 10, 1, 1}, + {"周管理", "13800010005", "全市", 20, 0, 1} + }; + int managerCount = 0; + for (Object[] m : managers) { + try { + jdbcTemplate.update( + "INSERT INTO manager (tenant_id, name, phone, service_area, manage_count, audit_status, status, create_time, update_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, NOW(), NOW())", + m[0], m[1], m[2], m[3], m[4], m[5] + ); + managerCount++; + } catch (Exception e) { + System.out.println("Insert manager error: " + e.getMessage()); + } + } + results.put("manager", managerCount); + } catch (Exception e) { + results.put("manager_error", e.getMessage()); + } + + // 2. 添加分销员数据 (字段: name, phone, type, area, order_count, total_commission, audit_status, status) + try { + Object[][] distributors = { + {"吴分销", "13800020001", "fulltime", "城东区", 25, 3500.00, 1, 1}, + {"郑分销", "13800020002", "parttime", "城西区", 12, 1800.00, 1, 1}, + {"王分销", "13800020003", "fulltime", "城南区", 30, 4200.00, 0, 1}, + {"冯分销", "13800020004", "parttime", "城北区", 8, 1200.00, 1, 1}, + {"陈分销", "13800020005", "fulltime", "全市", 45, 6500.00, 0, 1} + }; + int distributorCount = 0; + for (Object[] d : distributors) { + try { + jdbcTemplate.update( + "INSERT INTO distributor (tenant_id, name, phone, type, area, order_count, total_commission, audit_status, status, create_time, update_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())", + d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7] + ); + distributorCount++; + } catch (Exception e) { + System.out.println("Insert distributor error: " + e.getMessage()); + } + } + results.put("distributor", distributorCount); + } catch (Exception e) { + results.put("distributor_error", e.getMessage()); + } + + // 3. 添加服务商数据 (字段: name, phone, description, business_license, status) + try { + Object[][] providers = { + {"王老师", "13800030001", "书法教学", "书法家协会会员证书", 1}, + {"李老师", "13800030002", "英语教学", "英语专业八级证书", 1}, + {"张老师", "13800030003", "音乐教学", "音乐学院钢琴十级", 0}, + {"刘老师", "13800030004", "美术教学", "美术学院毕业证书", 1}, + {"陈老师", "13800030005", "舞蹈教学", "舞蹈家协会证书", 0} + }; + int providerCount = 0; + for (Object[] p : providers) { + try { + jdbcTemplate.update( + "INSERT INTO provider (tenant_id, name, phone, description, business_license, status, create_time, update_time) " + + "VALUES (1, ?, ?, ?, ?, ?, NOW(), NOW())", + p[0], p[1], p[2], p[3], p[4] + ); + providerCount++; + } catch (Exception e) { + System.out.println("Insert provider error: " + e.getMessage()); + } + } + results.put("provider", providerCount); + } catch (Exception e) { + results.put("provider_error", e.getMessage()); + } + + results.put("message", "角色数据添加完成"); + return Result.success(results); + } + + /** + * 创建排课表和其他缺失的表 + */ + @RequestMapping(value = "/create-schedule-table", method = {RequestMethod.GET, RequestMethod.POST}) + public Result createScheduleTable() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 创建 schedule 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS schedule (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "student_id BIGINT," + + "student_name VARCHAR(50)," + + "service_type VARCHAR(50)," + + "schedule_date DATE," + + "start_time TIME," + + "end_time TIME," + + "duration INT DEFAULT 60," + + "status TINYINT DEFAULT 0 COMMENT '0待确认 1已确认 -1已取消'," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ")" + ); + results.put("schedule", "created"); + } catch (Exception e) { + results.put("schedule", "error: " + e.getMessage()); + } + + // 创建 checkin_record 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS checkin_record (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "order_id BIGINT," + + "work_order_id BIGINT," + + "work_order_no VARCHAR(50)," + + "user_id BIGINT," + + "student_id BIGINT," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "teacher_phone VARCHAR(20)," + + "type VARCHAR(20) COMMENT 'checkin-签到 checkout-签退'," + + "check_type VARCHAR(20) COMMENT 'in-签到 out-签退'," + + "check_in_time DATETIME," + + "check_time DATETIME," + + "location VARCHAR(500)," + + "gps VARCHAR(100)," + + "photo VARCHAR(500)," + + "status VARCHAR(20) DEFAULT 'normal' COMMENT 'normal late early abnormal'," + + "remark VARCHAR(500)," + + "audit_result VARCHAR(20)," + + "audit_remark VARCHAR(500)," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted TINYINT DEFAULT 0" + + ")" + ); + results.put("checkin_record", "created"); + } catch (Exception e) { + results.put("checkin_record", "error: " + e.getMessage()); + } + + return Result.success(results); + } + + /** + * 一次性添加所有管理页面需要的测试数据 + */ + @RequestMapping(value = "/add-all-test-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result addAllTestData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 添加排课数据 + try { + Object[][] schedules = { + {1, "张老师", 1, "小明", "基准式陪伴", "2026-01-06", "09:00:00", "11:00:00", 120, 1}, + {2, "李老师", 2, "小红", "暖心式陪伴", "2026-01-06", "14:00:00", "16:00:00", 120, 1}, + {1, "张老师", 3, "小刚", "伙伴式陪伴", "2026-01-07", "09:00:00", "11:00:00", 120, 0}, + {2, "李老师", 1, "小明", "专项陪伴", "2026-01-07", "14:00:00", "16:00:00", 120, 0}, + {3, "王老师", 2, "小红", "基准式陪伴", "2026-01-08", "09:00:00", "11:00:00", 120, 0} + }; + int count = 0; + for (Object[] s : schedules) { + try { + jdbcTemplate.update( + "INSERT INTO schedule (tenant_id, teacher_id, teacher_name, student_id, student_name, service_type, schedule_date, start_time, end_time, duration, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9] + ); + count++; + } catch (Exception ignored) {} + } + results.put("schedule", count); + } catch (Exception e) { + results.put("schedule_error", e.getMessage()); + } + + // 2. 添加工单数据 + try { + Object[][] workOrders = { + {"WO202601060001", 1, "小明", 1, "张老师", "基准式陪伴", "2026-01-06", "09:00-11:00", "杭州市西湖区xxx小区", 2}, + {"WO202601060002", 2, "小红", 2, "李老师", "暖心式陪伴", "2026-01-06", "14:00-16:00", "杭州市滨江区xxx花园", 1}, + {"WO202601070001", 3, "小刚", 1, "张老师", "伙伴式陪伴", "2026-01-07", "09:00-11:00", "杭州市余杭区xxx公寓", 0}, + {"WO202601070002", 1, "小明", 2, "李老师", "专项陪伴", "2026-01-07", "14:00-16:00", "杭州市西湖区xxx小区", 0}, + {"WO202601080001", 2, "小红", 3, "王老师", "基准式陪伴", "2026-01-08", "09:00-11:00", "杭州市滨江区xxx花园", 0} + }; + int count = 0; + for (Object[] w : workOrders) { + try { + jdbcTemplate.update( + "INSERT INTO work_order (tenant_id, work_order_no, student_id, student_name, teacher_id, teacher_name, service_type, service_date, time_slot, address, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8], w[9] + ); + count++; + } catch (Exception ignored) {} + } + results.put("work_order", count); + } catch (Exception e) { + results.put("work_order_error", e.getMessage()); + } + + // 3. 添加打卡记录数据 + try { + Object[][] checkins = { + {"WO202601060001", 1, "张老师", "13800138001", "checkin", "2026-01-06 09:00:15", "杭州市西湖区xxx小区3号楼", "normal"}, + {"WO202601060001", 1, "张老师", "13800138001", "checkout", "2026-01-06 11:05:30", "杭州市西湖区xxx小区3号楼", "normal"}, + {"WO202601060002", 2, "李老师", "13800138002", "checkin", "2026-01-06 14:15:00", "杭州市滨江区xxx花园5栋", "late"}, + {"WO202601060002", 2, "李老师", "13800138002", "checkout", "2026-01-06 16:00:00", "杭州市滨江区xxx花园5栋", "normal"} + }; + int count = 0; + for (Object[] c : checkins) { + try { + jdbcTemplate.update( + "INSERT INTO checkin_record (tenant_id, work_order_no, teacher_id, teacher_name, teacher_phone, type, check_time, location, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7] + ); + count++; + } catch (Exception ignored) {} + } + results.put("checkin_record", count); + } catch (Exception e) { + results.put("checkin_record_error", e.getMessage()); + } + + // 4. 添加成长记录数据 + try { + Object[][] growthRecords = { + {1, "小明", 1, "张老师", "daily", "今天小明表现很好,完成了所有作业,数学进步明显", 1, "2026-01-05"}, + {2, "小红", 2, "李老师", "daily", "小红今天学习了英语口语,发音有进步", 1, "2026-01-05"}, + {1, "小明", 1, "张老师", "weekly", "本周小明整体表现优秀,学习态度积极", 1, "2026-01-04"}, + {3, "小刚", 3, "王老师", "daily", "小刚今天完成了语文阅读理解练习", 1, "2026-01-06"}, + {2, "小红", 2, "李老师", "daily", "今天复习了数学公式,做了10道练习题", 0, "2026-01-06"} + }; + int count = 0; + for (Object[] g : growthRecords) { + try { + jdbcTemplate.update( + "INSERT INTO growth_record (tenant_id, student_id, student_name, teacher_id, teacher_name, record_type, content, status, record_date, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7] + ); + count++; + } catch (Exception ignored) {} + } + results.put("growth_record", count); + } catch (Exception e) { + results.put("growth_record_error", e.getMessage()); + } + + // 5. 添加评价数据 + try { + Object[][] reviews = { + {1, 1, 1, 5, "老师很负责,孩子进步很大"}, + {2, 2, 2, 4, "整体不错,希望能更多互动"}, + {1, 1, 1, 5, "非常满意,会继续选择"}, + {3, 3, 3, 5, "老师很有耐心"}, + {2, 2, 2, 4, "孩子喜欢这位老师"} + }; + int count = 0; + for (Object[] r : reviews) { + try { + jdbcTemplate.update( + "INSERT INTO review (tenant_id, user_id, order_id, teacher_id, rating, content, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, 1, NOW())", + r[0], r[1], r[2], r[3], r[4] + ); + count++; + } catch (Exception ignored) {} + } + results.put("review", count); + } catch (Exception e) { + results.put("review_error", e.getMessage()); + } + + // 6. 添加订单数据 + try { + Object[][] orders = { + {"ORD202601050001", 1, 1, 1, "基准式陪伴", 199.00, 2}, + {"ORD202601050002", 2, 2, 2, "暖心式陪伴", 259.00, 2}, + {"ORD202601060001", 1, 1, 1, "专项陪伴", 149.00, 1}, + {"ORD202601060002", 3, 3, 3, "伙伴式陪伴", 229.00, 1}, + {"ORD202601070001", 2, 2, 2, "基准式陪伴", 199.00, 0} + }; + int count = 0; + for (Object[] o : orders) { + try { + jdbcTemplate.update( + "INSERT INTO `order` (tenant_id, order_no, user_id, student_id, teacher_id, service_type, pay_amount, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, NOW())", + o[0], o[1], o[2], o[3], o[4], o[5], o[6] + ); + count++; + } catch (Exception ignored) {} + } + results.put("order", count); + } catch (Exception e) { + results.put("order_error", e.getMessage()); + } + + // 7. 添加时卡数据 + try { + Object[][] timeCards = { + {1, "TC202601050001", "体验卡", "basic", 2.00, 1.00, 1.00, 99.00, 1}, + {2, "TC202601050002", "月卡", "basic", 20.00, 5.00, 15.00, 1599.00, 1}, + {1, "TC202601060001", "季卡", "warm", 60.00, 10.00, 50.00, 4299.00, 1}, + {3, "TC202601060002", "体验卡", "basic", 2.00, 0.00, 2.00, 99.00, 1} + }; + int count = 0; + for (Object[] t : timeCards) { + try { + jdbcTemplate.update( + "INSERT INTO time_card (tenant_id, user_id, card_no, card_name, card_type, total_hours, used_hours, remaining_hours, price, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8] + ); + count++; + } catch (Exception ignored) {} + } + results.put("time_card", count); + } catch (Exception e) { + results.put("time_card_error", e.getMessage()); + } + + results.put("message", "所有测试数据添加完成"); + return Result.success(results); + } + + /** + * 添加更多管理页面需要的测试数据 + */ + @RequestMapping(value = "/add-more-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result addMoreData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 添加公告数据 + try { + Object[][] announcements = { + {"系统升级通知", "系统将于本周六凌晨2点进行升级维护,届时服务将暂停约2小时", 1}, + {"新功能上线", "成长记录功能已上线,陪伴员可以每日记录学生学习情况", 1}, + {"节假日安排", "春节期间服务时间调整通知", 0} + }; + int count = 0; + for (Object[] a : announcements) { + try { + jdbcTemplate.update( + "INSERT INTO announcement (tenant_id, title, content, status, create_time) VALUES (1, ?, ?, ?, NOW())", + a[0], a[1], a[2] + ); + count++; + } catch (Exception ignored) {} + } + results.put("announcement", count); + } catch (Exception e) { + results.put("announcement_error", e.getMessage()); + } + + // 2. 添加轮播图数据 + try { + Object[][] banners = { + {"首页轮播1", "/static/banner1.jpg", "page", "/pages/service/list", 1, 1}, + {"首页轮播2", "/static/banner2.jpg", "page", "/pages/activity/list", 2, 1}, + {"首页轮播3", "/static/banner3.jpg", "url", "https://example.com", 3, 1} + }; + int count = 0; + for (Object[] b : banners) { + try { + jdbcTemplate.update( + "INSERT INTO banner (title, image, link_type, link_value, sort, status, create_time) VALUES (?, ?, ?, ?, ?, ?, NOW())", + b[0], b[1], b[2], b[3], b[4], b[5] + ); + count++; + } catch (Exception ignored) {} + } + results.put("banner", count); + } catch (Exception e) { + results.put("banner_error", e.getMessage()); + } + + // 3. 添加优惠券数据 + try { + Object[][] coupons = { + {"新用户专享券", "amount", 50.00, 100.00, 1000, 50, 1}, + {"满200减30", "amount", 30.00, 200.00, 500, 100, 1}, + {"9折优惠券", "discount", 0.90, 0.00, 200, 30, 1}, + {"体验券", "amount", 20.00, 50.00, 2000, 500, 1} + }; + int count = 0; + for (Object[] c : coupons) { + try { + jdbcTemplate.update( + "INSERT INTO coupon (tenant_id, name, type, value, min_amount, total_count, used_count, status, start_time, end_time, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY), NOW())", + c[0], c[1], c[2], c[3], c[4], c[5], c[6] + ); + count++; + } catch (Exception ignored) {} + } + results.put("coupon", count); + } catch (Exception e) { + results.put("coupon_error", e.getMessage()); + } + + // 4. 添加学生数据 + try { + Object[][] students = { + {1, "小明", 1, 8, "三年级", "实验小学", "张爸爸", "13800001001"}, + {1, "小红", 0, 10, "五年级", "实验小学", "李妈妈", "13800001002"}, + {2, "小刚", 1, 9, "四年级", "第一小学", "王爸爸", "13800001003"}, + {2, "小美", 0, 7, "二年级", "第二小学", "赵妈妈", "13800001004"}, + {3, "小强", 1, 11, "六年级", "实验小学", "刘爸爸", "13800001005"} + }; + int count = 0; + for (Object[] s : students) { + try { + jdbcTemplate.update( + "INSERT INTO student (tenant_id, user_id, name, gender, age, grade, school, parent_name, parent_phone, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7] + ); + count++; + } catch (Exception ignored) {} + } + results.put("student", count); + } catch (Exception e) { + results.put("student_error", e.getMessage()); + } + + // 5. 添加陪伴员(教师)数据 + try { + Object[][] teachers = { + {1, "张老师", "13800138001", 1, "本科", "教育学", 3, "语文,数学", 1, 80.00, 1}, + {2, "李老师", "13800138002", 0, "研究生", "心理学", 5, "英语,心理", 0, 60.00, 1}, + {3, "王老师", "13800138003", 1, "本科", "数学", 4, "数学,物理", 1, 90.00, 1}, + {4, "赵老师", "13800138004", 0, "本科", "英语", 2, "英语", 0, 50.00, 1}, + {5, "陈老师", "13800138005", 1, "研究生", "计算机", 6, "编程,数学", 1, 100.00, 1} + }; + int count = 0; + for (Object[] t : teachers) { + try { + jdbcTemplate.update( + "INSERT INTO teacher (tenant_id, user_id, name, teacher_name, phone, gender, education, major, experience, subjects, is_gold, hourly_rate, status, audit_status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, NOW())", + t[0], t[1], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10] + ); + count++; + } catch (Exception ignored) {} + } + results.put("teacher", count); + } catch (Exception e) { + results.put("teacher_error", e.getMessage()); + } + + // 6. 添加服务分类数据 + try { + Object[][] categories = { + {"基准式陪伴", "/static/icons/cat1.png", 1, 1}, + {"暖心式陪伴", "/static/icons/cat2.png", 2, 1}, + {"伙伴式陪伴", "/static/icons/cat3.png", 3, 1}, + {"管家式陪伴", "/static/icons/cat4.png", 4, 1}, + {"叠加式陪伴", "/static/icons/cat5.png", 5, 1}, + {"专项陪伴", "/static/icons/cat6.png", 6, 1}, + {"天赋测评", "/static/icons/cat7.png", 7, 1}, + {"成长规划", "/static/icons/cat8.png", 8, 1} + }; + int count = 0; + for (Object[] c : categories) { + try { + jdbcTemplate.update( + "INSERT INTO service_category (name, icon, sort, status, create_time) VALUES (?, ?, ?, ?, NOW())", + c[0], c[1], c[2], c[3] + ); + count++; + } catch (Exception ignored) {} + } + results.put("service_category", count); + } catch (Exception e) { + results.put("service_category_error", e.getMessage()); + } + + // 7. 添加服务数据 + try { + Object[][] services = { + {1, "基准式陪伴-普通老师", "入户陪伴,专业陪伴员一对一服务", 99.00, 199.00, "basic", 1}, + {1, "基准式陪伴-金牌老师", "金牌陪伴员入户服务", 199.00, 299.00, "basic_gold", 1}, + {2, "暖心式陪伴", "温暖陪伴,关注心理健康", 159.00, 259.00, "warm", 1}, + {3, "伙伴式陪伴", "像朋友一样陪伴成长", 129.00, 229.00, "partner", 1}, + {6, "语文专项辅导", "小学语文专项提升", 149.00, 249.00, "special", 1}, + {6, "数学专项辅导", "小学数学专项提升", 149.00, 249.00, "special", 1}, + {7, "天赋测评服务", "发现孩子的天赋潜能", 299.00, 499.00, "assessment", 1}, + {8, "成长规划咨询", "专业规划师一对一咨询", 399.00, 599.00, "planning", 1} + }; + int count = 0; + for (Object[] s : services) { + try { + jdbcTemplate.update( + "INSERT INTO service (tenant_id, category_id, name, description, cover_image, price, original_price, service_type, status, create_time) " + + "VALUES (1, ?, ?, ?, '/static/service.png', ?, ?, ?, ?, NOW())", + s[0], s[1], s[2], s[3], s[4], s[5], s[6] + ); + count++; + } catch (Exception ignored) {} + } + results.put("service", count); + } catch (Exception e) { + results.put("service_error", e.getMessage()); + } + + // 8. 添加租户数据 + try { + Object[][] tenants = { + {"HQ001", "总部", "headquarters", "张总", "13900000001", "admin@peidu.com", "杭州市西湖区", 1}, + {"BR001", "杭州分部", "branch", "李经理", "13900000002", "hz@peidu.com", "杭州市滨江区", 1}, + {"BR002", "上海分部", "branch", "王经理", "13900000003", "sh@peidu.com", "上海市浦东新区", 1}, + {"FR001", "加盟商A", "franchise", "赵老板", "13900000004", "fra@peidu.com", "南京市鼓楼区", 1}, + {"FR002", "加盟商B", "franchise", "钱老板", "13900000005", "frb@peidu.com", "苏州市工业园区", 0} + }; + int count = 0; + for (Object[] t : tenants) { + try { + jdbcTemplate.update( + "INSERT INTO tenant (tenant_code, tenant_name, tenant_type, contact_name, contact_phone, contact_email, address, status, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())", + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7] + ); + count++; + } catch (Exception ignored) {} + } + results.put("tenant", count); + } catch (Exception e) { + results.put("tenant_error", e.getMessage()); + } + + // 9. 添加提现记录数据 + try { + Object[][] withdraws = { + {1, "WD202601050001", 500.00, 5.00, 495.00, "alipay", "138****0001", "张*", "2"}, + {2, "WD202601050002", 800.00, 8.00, 792.00, "wechat", "138****0002", "李*", "1"}, + {3, "WD202601060001", 1000.00, 10.00, 990.00, "bank", "6222****1234", "王*", "0"} + }; + int count = 0; + for (Object[] w : withdraws) { + try { + jdbcTemplate.update( + "INSERT INTO withdraw (tenant_id, user_id, withdraw_no, amount, fee, actual_amount, account_type, account_no, account_name, status, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8] + ); + count++; + } catch (Exception ignored) {} + } + results.put("withdraw", count); + } catch (Exception e) { + results.put("withdraw_error", e.getMessage()); + } + + // 10. 添加加盟申请数据 + try { + Object[][] franchises = { + {"孙先生", "13900001111", "南京市", "有3年教育行业经验", 0}, + {"周女士", "13900002222", "苏州市", "有自己的培训机构", 1}, + {"吴先生", "13900003333", "无锡市", "想转型做教育", 0}, + {"郑女士", "13900004444", "常州市", "有丰富的管理经验", 2} + }; + int count = 0; + for (Object[] f : franchises) { + try { + jdbcTemplate.update( + "INSERT INTO franchise_application (name, phone, city, remark, status, create_time) VALUES (?, ?, ?, ?, ?, NOW())", + f[0], f[1], f[2], f[3], f[4] + ); + count++; + } catch (Exception ignored) {} + } + results.put("franchise_application", count); + } catch (Exception e) { + results.put("franchise_application_error", e.getMessage()); + } + + // 11. 添加协议数据 + try { + Object[][] agreements = { + {"用户服务协议", "user", "v1.0", "欢迎使用陪读管理系统。本协议是您与平台之间关于使用平台服务的法律协议...", 1}, + {"隐私政策", "privacy", "v1.0", "我们重视您的隐私保护。本隐私政策说明了我们如何收集、使用和保护您的个人信息...", 1}, + {"陪伴员服务协议", "teacher", "v1.0", "本协议是陪伴员与平台之间关于提供陪伴服务的法律协议...", 1} + }; + int count = 0; + for (Object[] a : agreements) { + try { + jdbcTemplate.update( + "INSERT INTO agreement (title, type, version, content, status, create_time) VALUES (?, ?, ?, ?, ?, NOW())", + a[0], a[1], a[2], a[3], a[4] + ); + count++; + } catch (Exception ignored) {} + } + results.put("agreement", count); + } catch (Exception e) { + results.put("agreement_error", e.getMessage()); + } + + // 12. 添加物资数据 + try { + Object[][] materials = { + {"教学白板", "teaching", "块", 50, 299.00, 1}, + {"学习资料包", "teaching", "套", 200, 49.90, 1}, + {"宣传海报", "promotion", "张", 500, 5.00, 1}, + {"办公文具套装", "office", "套", 30, 89.00, 1}, + {"工作服", "uniform", "件", 100, 150.00, 1} + }; + int count = 0; + for (Object[] m : materials) { + try { + jdbcTemplate.update( + "INSERT INTO material (name, category, unit, stock, price, status, create_time) VALUES (?, ?, ?, ?, ?, ?, NOW())", + m[0], m[1], m[2], m[3], m[4], m[5] + ); + count++; + } catch (Exception ignored) {} + } + results.put("material", count); + } catch (Exception e) { + results.put("material_error", e.getMessage()); + } + + // 13. 添加客服人员数据 + try { + Object[][] staffs = { + {"张客服", "13800001111", "online", 1}, + {"李客服", "13800002222", "hotline", 1}, + {"王客服", "13800003333", "online", 1} + }; + int count = 0; + for (Object[] s : staffs) { + try { + jdbcTemplate.update( + "INSERT INTO customer_service_staff (name, phone, type, status, create_time) VALUES (?, ?, ?, ?, NOW())", + s[0], s[1], s[2], s[3] + ); + count++; + } catch (Exception ignored) {} + } + results.put("customer_service_staff", count); + } catch (Exception e) { + results.put("customer_service_staff_error", e.getMessage()); + } + + // 14. 添加用户(家长)数据 + try { + Object[][] users = { + {"13800001001", "张爸爸", "张三", "/static/avatar1.png", "parent", 1}, + {"13800001002", "李妈妈", "李四", "/static/avatar2.png", "parent", 1}, + {"13800001003", "王爸爸", "王五", "/static/avatar3.png", "parent", 1}, + {"13800001004", "赵妈妈", "赵六", "/static/avatar4.png", "parent", 1}, + {"13800001005", "刘爸爸", "刘七", "/static/avatar5.png", "parent", 1} + }; + int count = 0; + for (Object[] u : users) { + try { + jdbcTemplate.update( + "INSERT INTO user (tenant_id, phone, nickname, real_name, avatar, role, status, create_time) VALUES (1, ?, ?, ?, ?, ?, ?, NOW())", + u[0], u[1], u[2], u[3], u[4], u[5] + ); + count++; + } catch (Exception ignored) {} + } + results.put("user", count); + } catch (Exception e) { + results.put("user_error", e.getMessage()); + } + + results.put("message", "更多测试数据添加完成"); + return Result.success(results); + } + + /** + * 一键初始化所有内容(创建表 + 添加数据) + * 访问: http://localhost:8080/api/init/everything + */ + @RequestMapping(value = "/everything", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initEverything() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 创建缺失的表 + try { + createMissingTables(); + results.put("step1_create_tables", "success"); + } catch (Exception e) { + results.put("step1_create_tables_error", e.getMessage()); + } + + // 2. 创建排课表和打卡表 + try { + createScheduleTable(); + results.put("step2_schedule_tables", "success"); + } catch (Exception e) { + results.put("step2_schedule_tables_error", e.getMessage()); + } + + // 3. 修复表结构 + try { + fixTables(); + results.put("step3_fix_tables", "success"); + } catch (Exception e) { + results.put("step3_fix_tables_error", e.getMessage()); + } + + // 4. 添加角色数据(管理师、分销员、服务商) + try { + addAllRoleData(); + results.put("step4_role_data", "success"); + } catch (Exception e) { + results.put("step4_role_data_error", e.getMessage()); + } + + // 5. 添加所有测试数据 + try { + addAllTestData(); + results.put("step5_test_data", "success"); + } catch (Exception e) { + results.put("step5_test_data_error", e.getMessage()); + } + + // 6. 修复学生家长数据 + try { + fixStudentParent(); + results.put("step6_fix_student_parent", "success"); + } catch (Exception e) { + results.put("step6_fix_student_parent_error", e.getMessage()); + } + + // 7. 添加更多测试数据 + try { + addMoreData(); + results.put("step7_more_data", "success"); + } catch (Exception e) { + results.put("step7_more_data_error", e.getMessage()); + } + + // 8. 修复数据字段 + try { + fixDataFields(); + results.put("step8_fix_fields", "success"); + } catch (Exception e) { + results.put("step8_fix_fields_error", e.getMessage()); + } + + // 9. 修复头像和图片路径 + try { + fixAvatars(); + results.put("step9_fix_avatars", "success"); + } catch (Exception e) { + results.put("step9_fix_avatars_error", e.getMessage()); + } + + // 10. 初始化协议和物资数据 + try { + initAgreements(); + results.put("step10_agreements", "success"); + } catch (Exception e) { + results.put("step10_agreements_error", e.getMessage()); + } + + try { + initMaterials(); + results.put("step11_materials", "success"); + } catch (Exception e) { + results.put("step11_materials_error", e.getMessage()); + } + + results.put("message", "一键初始化完成!请刷新管理页面查看数据"); + return Result.success(results); + } + + /** + * 修复数据字段(将name复制到teacher_name等) + * 访问: http://localhost:8080/api/init/fix-data-fields + */ + @RequestMapping(value = "/fix-data-fields", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixDataFields() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 修复 teacher 表的 teacher_name 字段 + try { + int updated = jdbcTemplate.update( + "UPDATE teacher SET teacher_name = name WHERE teacher_name IS NULL OR teacher_name = ''" + ); + results.put("teacher_name_fixed", updated); + } catch (Exception e) { + results.put("teacher_name_error", e.getMessage()); + } + + // 2. 修复 teacher 表的 real_name 字段 + try { + int updated = jdbcTemplate.update( + "UPDATE teacher SET real_name = name WHERE real_name IS NULL OR real_name = ''" + ); + results.put("teacher_real_name_fixed", updated); + } catch (Exception e) { + results.put("teacher_real_name_error", e.getMessage()); + } + + // 3. 修复 growth_record 表的 student_name 和 teacher_name 字段 + try { + // 添加字段(如果不存在) + try { jdbcTemplate.execute("ALTER TABLE growth_record ADD COLUMN student_name VARCHAR(50)"); } catch (Exception ignored) {} + try { jdbcTemplate.execute("ALTER TABLE growth_record ADD COLUMN teacher_name VARCHAR(50)"); } catch (Exception ignored) {} + results.put("growth_record_columns", "added"); + } catch (Exception e) { + results.put("growth_record_columns_error", e.getMessage()); + } + + // 4. 修复 work_order 表的 student_name 和 teacher_name 字段 + try { + // 添加字段(如果不存在) + try { jdbcTemplate.execute("ALTER TABLE work_order ADD COLUMN student_name VARCHAR(50)"); } catch (Exception ignored) {} + try { jdbcTemplate.execute("ALTER TABLE work_order ADD COLUMN teacher_name VARCHAR(50)"); } catch (Exception ignored) {} + results.put("work_order_columns", "added"); + } catch (Exception e) { + results.put("work_order_columns_error", e.getMessage()); + } + + // 5. 修复 schedule 表的 student_name 和 teacher_name 字段 + try { + // 添加字段(如果不存在) + try { jdbcTemplate.execute("ALTER TABLE schedule ADD COLUMN student_name VARCHAR(50)"); } catch (Exception ignored) {} + try { jdbcTemplate.execute("ALTER TABLE schedule ADD COLUMN teacher_name VARCHAR(50)"); } catch (Exception ignored) {} + results.put("schedule_columns", "added"); + } catch (Exception e) { + results.put("schedule_columns_error", e.getMessage()); + } + + // 6. 修复 checkin_record 表的 teacher_name 字段 + try { + try { jdbcTemplate.execute("ALTER TABLE checkin_record ADD COLUMN teacher_name VARCHAR(50)"); } catch (Exception ignored) {} + try { jdbcTemplate.execute("ALTER TABLE checkin_record ADD COLUMN teacher_phone VARCHAR(20)"); } catch (Exception ignored) {} + results.put("checkin_record_columns", "added"); + } catch (Exception e) { + results.put("checkin_record_columns_error", e.getMessage()); + } + + results.put("message", "数据字段修复完成"); + return Result.success(results); + } + + /** + * 修复工单表结构 + * 访问: http://localhost:8080/api/init/fix-workorder + */ + @RequestMapping(value = "/fix-workorder", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixWorkOrder() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 根据实际数据库表结构,修复所有NOT NULL字段的默认值 + // 原表结构中 order_id, manager_id, user_id, work_type, title 是 NOT NULL + String[] fixDefaults = { + // 修改NOT NULL字段为允许NULL或添加默认值 + "ALTER TABLE work_order MODIFY COLUMN order_id BIGINT DEFAULT 0", + "ALTER TABLE work_order MODIFY COLUMN manager_id BIGINT DEFAULT 0", + "ALTER TABLE work_order MODIFY COLUMN user_id BIGINT DEFAULT 0", + "ALTER TABLE work_order MODIFY COLUMN work_type VARCHAR(50) DEFAULT 'assign'", + "ALTER TABLE work_order MODIFY COLUMN title VARCHAR(200) DEFAULT '陪伴服务工单'" + }; + + int fixed = 0; + for (String sql : fixDefaults) { + try { + jdbcTemplate.execute(sql); + fixed++; + } catch (Exception e) { + results.put("error_" + fixed, e.getMessage()); + } + } + + // 添加前端需要但表中可能没有的字段 + String[] addColumns = { + "ALTER TABLE work_order ADD COLUMN work_order_no VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN student_name VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN teacher_name VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN service_type VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN service_date DATE", + "ALTER TABLE work_order ADD COLUMN time_slot VARCHAR(50)", + "ALTER TABLE work_order ADD COLUMN address VARCHAR(500)" + }; + + int added = 0; + for (String sql : addColumns) { + try { + jdbcTemplate.execute(sql); + added++; + } catch (Exception ignored) {} + } + + results.put("defaults_fixed", fixed); + results.put("columns_added", added); + results.put("message", "工单表修复完成"); + + return Result.success(results); + } + + /** + * 修复评价表结构并添加测试数据 + * 访问: http://localhost:8080/api/init/fix-review + */ + @RequestMapping(value = "/fix-review", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixReview() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 添加缺失的字段 + String[] addColumns = { + "ALTER TABLE review ADD COLUMN rating INT DEFAULT 5", + "ALTER TABLE review ADD COLUMN review_content TEXT", + "ALTER TABLE review ADD COLUMN reply TEXT", + "ALTER TABLE review ADD COLUMN reply_time DATETIME", + "ALTER TABLE review ADD COLUMN deleted INT DEFAULT 0" + }; + + int added = 0; + for (String sql : addColumns) { + try { + jdbcTemplate.execute(sql); + added++; + } catch (Exception ignored) {} + } + results.put("columns_added", added); + + // 2. 用 overall_score 更新 rating 字段 + try { + jdbcTemplate.execute("UPDATE review SET rating = ROUND(overall_score) WHERE rating IS NULL OR rating = 0"); + results.put("rating_updated", "success"); + } catch (Exception e) { + results.put("rating_updated", "error: " + e.getMessage()); + } + + // 3. 修复NOT NULL字段的默认值 + String[] fixDefaults = { + "ALTER TABLE review MODIFY COLUMN order_id BIGINT DEFAULT 0", + "ALTER TABLE review MODIFY COLUMN user_id BIGINT DEFAULT 0", + "ALTER TABLE review MODIFY COLUMN teacher_id BIGINT DEFAULT 0", + "ALTER TABLE review MODIFY COLUMN service_id BIGINT DEFAULT 0" + }; + + int fixed = 0; + for (String sql : fixDefaults) { + try { + jdbcTemplate.execute(sql); + fixed++; + } catch (Exception ignored) {} + } + results.put("defaults_fixed", fixed); + + // 4. 检查是否有数据,没有则插入测试数据 + Integer count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM review", Integer.class); + if (count == null || count == 0) { + String[] insertSqls = { + "INSERT INTO review (tenant_id, order_id, user_id, teacher_id, service_id, rating, content, status, create_time) VALUES (1, 1, 1, 1, 1, 5, '陈老师非常耐心,孩子很喜欢,成绩有明显提升!', 1, NOW())", + "INSERT INTO review (tenant_id, order_id, user_id, teacher_id, service_id, rating, content, status, create_time) VALUES (1, 2, 2, 2, 2, 5, '刘老师数学讲得很好,孩子说听懂了很多以前不会的题目。', 1, NOW())", + "INSERT INTO review (tenant_id, order_id, user_id, teacher_id, service_id, rating, content, status, create_time) VALUES (1, 3, 1, 3, 3, 4, '赵老师的英语发音很标准,孩子的口语进步很大。', 1, NOW())", + "INSERT INTO review (tenant_id, order_id, user_id, teacher_id, service_id, rating, content, status, create_time) VALUES (1, 4, 2, 1, 1, 5, '非常满意的一次服务,老师很专业!', 1, NOW())", + "INSERT INTO review (tenant_id, order_id, user_id, teacher_id, service_id, rating, content, status, create_time) VALUES (1, 5, 3, 2, 2, 4, '老师很认真负责,孩子学到了很多。', 1, NOW())" + }; + + int inserted = 0; + for (String sql : insertSqls) { + try { + jdbcTemplate.execute(sql); + inserted++; + } catch (Exception ignored) {} + } + results.put("data_inserted", inserted); + } else { + results.put("existing_data", count); + } + + results.put("message", "评价表修复完成"); + return Result.success(results); + } + + /** + * 修复头像和图片路径(使用网络可用的默认图片) + * 访问: http://localhost:8080/api/init/fix-avatars + */ + @RequestMapping(value = "/fix-avatars", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixAvatars() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 默认头像URL(使用网络可用的占位图) + String defaultAvatar = "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"; + String defaultTeacherAvatar = "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"; + String defaultStudentAvatar = "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"; + String defaultServiceImage = "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"; + String defaultBannerImage = "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg"; + + // 1. 修复 user 表头像 + try { + int updated = jdbcTemplate.update( + "UPDATE user SET avatar = ? WHERE avatar IS NULL OR avatar = '' OR avatar LIKE '/static/%'", + defaultAvatar + ); + results.put("user_avatar_fixed", updated); + } catch (Exception e) { + results.put("user_avatar_error", e.getMessage()); + } + + // 2. 修复 teacher 表头像 + try { + int updated = jdbcTemplate.update( + "UPDATE teacher SET avatar = ? WHERE avatar IS NULL OR avatar = '' OR avatar LIKE '/static/%'", + defaultTeacherAvatar + ); + results.put("teacher_avatar_fixed", updated); + } catch (Exception e) { + results.put("teacher_avatar_error", e.getMessage()); + } + + // 3. 修复 student 表头像 + try { + int updated = jdbcTemplate.update( + "UPDATE student SET avatar = ? WHERE avatar IS NULL OR avatar = '' OR avatar LIKE '/static/%'", + defaultStudentAvatar + ); + results.put("student_avatar_fixed", updated); + } catch (Exception e) { + results.put("student_avatar_error", e.getMessage()); + } + + // 4. 修复 admin 表头像 + try { + int updated = jdbcTemplate.update( + "UPDATE admin SET avatar = ? WHERE avatar IS NULL OR avatar = '' OR avatar LIKE '/static/%'", + defaultAvatar + ); + results.put("admin_avatar_fixed", updated); + } catch (Exception e) { + results.put("admin_avatar_error", e.getMessage()); + } + + // 5. 修复 service 表封面图 + try { + int updated = jdbcTemplate.update( + "UPDATE service SET cover_image = ? WHERE cover_image IS NULL OR cover_image = '' OR cover_image LIKE '/static/%'", + defaultServiceImage + ); + results.put("service_cover_fixed", updated); + } catch (Exception e) { + results.put("service_cover_error", e.getMessage()); + } + + // 6. 修复 banner 表图片 + try { + int updated = jdbcTemplate.update( + "UPDATE banner SET image_url = ? WHERE image_url IS NULL OR image_url = '' OR image_url LIKE '/static/%'", + defaultBannerImage + ); + results.put("banner_image_fixed", updated); + } catch (Exception e) { + results.put("banner_image_error", e.getMessage()); + } + + // 7. 修复 service_category 表图标 + try { + int updated = jdbcTemplate.update( + "UPDATE service_category SET icon = ? WHERE icon IS NULL OR icon = '' OR icon LIKE '/static/%'", + "https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png" + ); + results.put("category_icon_fixed", updated); + } catch (Exception e) { + results.put("category_icon_error", e.getMessage()); + } + + // 8. 修复 training_course 表封面图 + try { + int updated = jdbcTemplate.update( + "UPDATE training_course SET cover_image = ? WHERE cover_image IS NULL OR cover_image = '' OR cover_image LIKE '/static/%'", + defaultServiceImage + ); + results.put("course_cover_fixed", updated); + } catch (Exception e) { + results.put("course_cover_error", e.getMessage()); + } + + results.put("message", "头像和图片路径修复完成"); + return Result.success(results); + } + + /** + * 创建角色和权限表 + * 访问: http://localhost:8080/api/init/create-role-permission-tables + */ + @RequestMapping(value = "/create-role-permission-tables", method = {RequestMethod.GET, RequestMethod.POST}) + public Result createRolePermissionTables() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 创建 role 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS role (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(50) NOT NULL," + + "code VARCHAR(50)," + + "description VARCHAR(200)," + + "status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ")" + ); + results.put("role", "created"); + } catch (Exception e) { + results.put("role_error", e.getMessage()); + } + + // 创建 permission 表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS permission (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(50) NOT NULL," + + "code VARCHAR(100)," + + "type VARCHAR(20) COMMENT 'menu-菜单 button-按钮'," + + "parent_id BIGINT DEFAULT 0," + + "path VARCHAR(200)," + + "icon VARCHAR(100)," + + "sort INT DEFAULT 0," + + "status TINYINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ")" + ); + results.put("permission", "created"); + } catch (Exception e) { + results.put("permission_error", e.getMessage()); + } + + // 创建 role_permission 关联表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS role_permission (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "role_id BIGINT NOT NULL," + + "permission_id BIGINT NOT NULL," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP" + + ")" + ); + results.put("role_permission", "created"); + } catch (Exception e) { + results.put("role_permission_error", e.getMessage()); + } + + // 创建 admin_role 关联表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS admin_role (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "admin_id BIGINT NOT NULL," + + "role_id BIGINT NOT NULL," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP" + + ")" + ); + results.put("admin_role", "created"); + } catch (Exception e) { + results.put("admin_role_error", e.getMessage()); + } + + // 添加默认角色数据 + try { + Object[][] roles = { + {"超级管理员", "super_admin", "拥有所有权限"}, + {"运营管理员", "operator", "负责日常运营管理"}, + {"财务管理员", "finance", "负责财务相关操作"}, + {"客服", "customer_service", "负责客户服务"} + }; + int count = 0; + for (Object[] r : roles) { + try { + jdbcTemplate.update( + "INSERT INTO role (name, code, description, status, create_time) VALUES (?, ?, ?, 1, NOW())", + r[0], r[1], r[2] + ); + count++; + } catch (Exception ignored) {} + } + results.put("role_data", count + " records"); + } catch (Exception e) { + results.put("role_data_error", e.getMessage()); + } + + // 添加默认权限数据 + try { + Object[][] permissions = { + {"系统管理", "system", "menu", 0, "/system", "Setting", 1}, + {"用户管理", "user", "menu", 0, "/user", "User", 2}, + {"订单管理", "order", "menu", 0, "/order", "Document", 3}, + {"服务管理", "service", "menu", 0, "/service", "Goods", 4}, + {"财务管理", "finance", "menu", 0, "/finance", "Money", 5}, + {"营销管理", "marketing", "menu", 0, "/marketing", "Present", 6}, + {"租户管理", "tenant", "menu", 0, "/tenant", "OfficeBuilding", 7}, + {"统计分析", "statistics", "menu", 0, "/statistics", "DataAnalysis", 8} + }; + int count = 0; + for (Object[] p : permissions) { + try { + jdbcTemplate.update( + "INSERT INTO permission (name, code, type, parent_id, path, icon, sort, status, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, 1, NOW())", + p[0], p[1], p[2], p[3], p[4], p[5], p[6] + ); + count++; + } catch (Exception ignored) {} + } + results.put("permission_data", count + " records"); + } catch (Exception e) { + results.put("permission_data_error", e.getMessage()); + } + + results.put("message", "角色权限表创建完成"); + return Result.success(results); + } + + /** + * 创建营销相关表 + */ + @RequestMapping(value = "/create-marketing-tables", method = {RequestMethod.GET, RequestMethod.POST}) + public Result createMarketingTables() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 创建 activity 表(营销活动) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS activity (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "name VARCHAR(100) NOT NULL COMMENT '活动名称'," + + "type VARCHAR(50) NOT NULL COMMENT '活动类型:full_reduction-满减,discount-折扣,gift_coupon-赠券,new_user-新人,referral-推荐'," + + "start_time DATETIME COMMENT '开始时间'," + + "end_time DATETIME COMMENT '结束时间'," + + "`condition` DECIMAL(10,2) COMMENT '满减条件金额'," + + "discount DECIMAL(10,2) COMMENT '优惠金额'," + + "discount_rate DECIMAL(3,2) COMMENT '折扣比例'," + + "description TEXT COMMENT '活动描述'," + + "participant_count INT DEFAULT 0 COMMENT '参与人数'," + + "order_amount DECIMAL(12,2) DEFAULT 0 COMMENT '订单金额'," + + "status TINYINT DEFAULT 1 COMMENT '状态:0-禁用,1-启用'," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='营销活动表'" + ); + results.put("activity", "created"); + } catch (Exception e) { + results.put("activity", "error: " + e.getMessage()); + } + + // 创建 group_buying 表(拼团活动) + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS group_buying (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "title VARCHAR(200) NOT NULL COMMENT '活动标题'," + + "service_id BIGINT COMMENT '关联服务ID'," + + "original_price DECIMAL(10,2) NOT NULL COMMENT '原价'," + + "group_price DECIMAL(10,2) NOT NULL COMMENT '拼团价'," + + "required_people INT NOT NULL DEFAULT 3 COMMENT '成团人数'," + + "stock INT NOT NULL DEFAULT 100 COMMENT '库存'," + + "sold_count INT DEFAULT 0 COMMENT '已售数量'," + + "start_time DATETIME COMMENT '开始时间'," + + "end_time DATETIME COMMENT '结束时间'," + + "time_limit INT DEFAULT 24 COMMENT '成团时限(小时)'," + + "description TEXT COMMENT '活动描述'," + + "status TINYINT DEFAULT 1 COMMENT '状态:0-已下架,1-进行中,2-已结束'," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='拼团活动表'" + ); + results.put("group_buying", "created"); + } catch (Exception e) { + results.put("group_buying", "error: " + e.getMessage()); + } + + // 插入测试数据 + try { + jdbcTemplate.update( + "INSERT IGNORE INTO activity (id, name, type, start_time, end_time, `condition`, discount, description, status) VALUES " + + "(1, '新年满减活动', 'full_reduction', '2026-01-01 00:00:00', '2026-01-31 23:59:59', 200.00, 50.00, '满200减50,新年特惠', 1)," + + "(2, '新人专享8折', 'discount', '2026-01-01 00:00:00', '2026-12-31 23:59:59', NULL, NULL, '新用户首单享8折优惠', 1)," + + "(3, '推荐有礼', 'referral', '2026-01-01 00:00:00', '2026-06-30 23:59:59', NULL, 100.00, '推荐好友注册,双方各得100元优惠券', 1)" + ); + results.put("activity_data", "inserted"); + } catch (Exception e) { + results.put("activity_data", "error: " + e.getMessage()); + } + + try { + jdbcTemplate.update( + "INSERT IGNORE INTO group_buying (id, title, service_id, original_price, group_price, required_people, stock, start_time, end_time, description, status) VALUES " + + "(1, '10小时陪伴套餐拼团', 1, 999.00, 799.00, 3, 100, '2026-01-01 00:00:00', '2026-02-28 23:59:59', '3人成团,享受超值优惠', 1)," + + "(2, '20小时陪伴套餐拼团', 2, 1899.00, 1499.00, 5, 50, '2026-01-01 00:00:00', '2026-02-28 23:59:59', '5人成团,更多优惠', 1)" + ); + results.put("group_buying_data", "inserted"); + } catch (Exception e) { + results.put("group_buying_data", "error: " + e.getMessage()); + } + + return Result.success(results); + } + + /** + * 修复营销表 - 添加 tenant_id 字段 + */ + @RequestMapping(value = "/fix-marketing-tables", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixMarketingTables() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 修复 activity 表 + String[] activityColumns = { + "ALTER TABLE activity ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE activity ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : activityColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("activity", "fixed"); + + // 修复 group_buying 表 + String[] groupBuyingColumns = { + "ALTER TABLE group_buying ADD COLUMN tenant_id BIGINT DEFAULT 1", + "ALTER TABLE group_buying ADD COLUMN deleted INT DEFAULT 0" + }; + for (String sql : groupBuyingColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + results.put("group_buying", "fixed"); + + return Result.success(results); + } + + /** + * 补充所有管理页面的测试数据 + * 访问: http://localhost:8080/api/init/supplement-data + */ + @RequestMapping(value = "/supplement-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result supplementData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 0. 补充订单数据(使用数据库实际字段) + try { + // 先检查表结构,添加缺失字段 + String[] orderColumns = { + "ALTER TABLE `order` ADD COLUMN service_name VARCHAR(100)", + "ALTER TABLE `order` ADD COLUMN service_date DATE", + "ALTER TABLE `order` ADD COLUMN time_slot VARCHAR(50)", + "ALTER TABLE `order` ADD COLUMN pay_status INT DEFAULT 0" + }; + for (String sql : orderColumns) { + try { jdbcTemplate.execute(sql); } catch (Exception ignored) {} + } + + // 使用 price 字段,包含 student_id 和 service_type + jdbcTemplate.update( + "INSERT IGNORE INTO `order` (id, tenant_id, order_no, user_id, student_id, service_id, teacher_id, price, pay_amount, status, service_name, service_type, service_date, time_slot, pay_status, create_time) VALUES " + + "(101, 1, 'PD20260107001', 1, 1, 1, 1, 99.00, 99.00, 0, '基准式陪伴-普通', 'basic', '2026-01-10', '09:00-11:00', 0, NOW())," + + "(102, 1, 'PD20260107002', 2, 2, 2, 2, 199.00, 199.00, 1, '基准式陪伴-金牌', 'basic_gold', '2026-01-11', '14:00-16:00', 1, NOW())," + + "(103, 1, 'PD20260107003', 1, 1, 3, 1, 159.00, 159.00, 2, '暖心式陪伴', 'warm', '2026-01-08', '10:00-12:00', 1, NOW())," + + "(104, 1, 'PD20260107004', 3, 3, 1, 3, 99.00, 99.00, 3, '基准式陪伴-普通', 'basic', '2026-01-05', '15:00-17:00', 1, NOW())," + + "(105, 1, 'PD20260107005', 2, 2, 4, 2, 299.00, 299.00, -1, '天赋测评服务', 'assessment', '2026-01-12', '09:00-10:00', 0, NOW())" + ); + results.put("order", "success"); + } catch (Exception e) { results.put("order", e.getMessage()); } + + // 1. 补充交易流水 + try { + jdbcTemplate.update( + "INSERT IGNORE INTO transaction (id, tenant_id, transaction_no, user_id, type, amount, balance, description, status, create_time) VALUES " + + "(101, 1, 'TXN20260107001', 1, 'pay', 99.00, 0.00, '购买体验套餐', 1, NOW())," + + "(102, 1, 'TXN20260107002', 2, 'pay', 199.00, 0.00, '购买基准式陪伴服务', 1, NOW())," + + "(103, 1, 'TXN20260107003', 1, 'income', 80.00, 80.00, '陪伴服务收入', 1, NOW())" + ); + results.put("transaction", "success"); + } catch (Exception e) { results.put("transaction", e.getMessage()); } + + // 2. 补充佣金记录 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS commission (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, order_id BIGINT, amount DECIMAL(10,2), rate DECIMAL(5,4), status INT DEFAULT 0, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO commission (id, tenant_id, user_id, order_id, amount, rate, status, create_time) VALUES (101, 1, 1, 1, 9.90, 0.10, 1, NOW()), (102, 1, 2, 2, 29.85, 0.15, 1, NOW())"); + results.put("commission", "success"); + } catch (Exception e) { results.put("commission", e.getMessage()); } + + // 3. 补充薪资记录 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS salary (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, teacher_id BIGINT, teacher_name VARCHAR(50), month VARCHAR(10), base_salary DECIMAL(10,2), bonus DECIMAL(10,2), deduction DECIMAL(10,2), total DECIMAL(10,2), status INT DEFAULT 0, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO salary (id, tenant_id, teacher_id, teacher_name, month, base_salary, bonus, deduction, total, status, create_time) VALUES (101, 1, 1, '陈老师', '2026-01', 5000.00, 500.00, 0.00, 5500.00, 1, NOW()), (102, 1, 2, '刘老师', '2026-01', 4500.00, 300.00, 0.00, 4800.00, 0, NOW())"); + results.put("salary", "success"); + } catch (Exception e) { results.put("salary", e.getMessage()); } + + // 4. 补充弹窗广告 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS popup (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, title VARCHAR(100), image VARCHAR(255), link_type VARCHAR(20), link_value VARCHAR(255), start_time DATETIME, end_time DATETIME, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO popup (id, tenant_id, title, image, link_type, link_value, start_time, end_time, status, create_time) VALUES (101, 1, '新年活动', '/static/popup/newyear.png', 'page', '/pages/activity/detail?id=1', NOW(), DATE_ADD(NOW(), INTERVAL 15 DAY), 1, NOW())"); + results.put("popup", "success"); + } catch (Exception e) { results.put("popup", e.getMessage()); } + + // 5. 补充文章分类 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS article_category (id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), sort INT DEFAULT 0, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO article_category (id, name, sort, status, create_time) VALUES (101, '育儿知识', 1, 1, NOW()), (102, '学习方法', 2, 1, NOW()), (103, '心理健康', 3, 1, NOW())"); + results.put("article_category", "success"); + } catch (Exception e) { results.put("article_category", e.getMessage()); } + + // 6. 补充文章 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS article (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, category_id BIGINT, title VARCHAR(200), content TEXT, cover_image VARCHAR(255), view_count INT DEFAULT 0, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO article (id, tenant_id, category_id, title, content, cover_image, view_count, status, create_time) VALUES (101, 1, 101, '如何培养孩子的学习兴趣', '培养孩子学习兴趣的方法有很多...', '/static/article/article1.png', 1520, 1, NOW()), (102, 1, 102, '高效学习的5个技巧', '想要提高学习效率,可以尝试以下方法...', '/static/article/article2.png', 2340, 1, NOW())"); + results.put("article", "success"); + } catch (Exception e) { results.put("article", e.getMessage()); } + + // 7. 补充用户反馈 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS feedback (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, type VARCHAR(20), content TEXT, contact VARCHAR(50), reply TEXT, status INT DEFAULT 0, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO feedback (id, tenant_id, user_id, type, content, contact, status, create_time) VALUES (101, 1, 1, 'suggestion', '希望增加更多课程类型', '13900001001', 0, NOW()), (102, 1, 2, 'complaint', '预约时间不够灵活', '13900001002', 1, NOW())"); + results.put("feedback", "success"); + } catch (Exception e) { results.put("feedback", e.getMessage()); } + + // 8. 补充加盟跟进记录 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS franchise_follow (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, application_id BIGINT, content TEXT, follow_time DATETIME, next_follow_time DATETIME, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO franchise_follow (id, tenant_id, application_id, content, follow_time, next_follow_time, create_time) VALUES (101, 1, 1, '初次电话沟通,客户有意向', NOW(), DATE_ADD(NOW(), INTERVAL 3 DAY), NOW()), (102, 1, 2, '已发送加盟资料,等待反馈', NOW(), DATE_ADD(NOW(), INTERVAL 5 DAY), NOW())"); + results.put("franchise_follow", "success"); + } catch (Exception e) { results.put("franchise_follow", e.getMessage()); } + + // 9. 补充培训课程 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS training_course (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, title VARCHAR(200), description TEXT, duration INT, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO training_course (id, tenant_id, title, description, duration, status, create_time) VALUES (101, 1, '新员工入职培训', '公司文化、规章制度、服务流程', 120, 1, NOW()), (102, 1, '服务技能提升', '沟通技巧、问题处理、客户服务', 90, 1, NOW())"); + results.put("training_course", "success"); + } catch (Exception e) { results.put("training_course", e.getMessage()); } + + // 10. 补充考试题目 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS exam_question (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, course_id BIGINT, question TEXT, options TEXT, answer VARCHAR(10), score INT DEFAULT 10, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO exam_question (id, tenant_id, course_id, question, options, answer, score, create_time) VALUES (101, 1, 101, '公司的服务理念是什么?', 'A.用心陪伴|B.快速服务|C.低价优先|D.数量第一', 'A', 10, NOW()), (102, 1, 101, '服务过程中遇到问题应该怎么处理?', 'A.忽略|B.及时上报|C.自行解决|D.推卸责任', 'B', 10, NOW())"); + results.put("exam_question", "success"); + } catch (Exception e) { results.put("exam_question", e.getMessage()); } + + // 11. 补充测评记录 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS assessment_record (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, student_id BIGINT, service_id BIGINT, result TEXT, score INT, suggestion TEXT, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO assessment_record (id, tenant_id, user_id, student_id, service_id, result, score, suggestion, status, create_time) VALUES (101, 1, 1, 1, 1, '学习能力良好,逻辑思维较强', 85, '建议加强阅读理解训练', 1, NOW()), (102, 1, 2, 2, 2, '艺术天赋突出,创造力强', 90, '建议培养艺术特长', 1, NOW())"); + results.put("assessment_record", "success"); + } catch (Exception e) { results.put("assessment_record", e.getMessage()); } + + // 12. 补充辅导预约 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS tutoring_appointment (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, student_id BIGINT, service_id BIGINT, teacher_id BIGINT, appointment_date DATE, time_slot VARCHAR(50), status INT DEFAULT 0, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO tutoring_appointment (id, tenant_id, user_id, student_id, service_id, teacher_id, appointment_date, time_slot, status, create_time) VALUES (101, 1, 1, 1, 1, 1, '2026-01-10', '14:00-15:00', 1, NOW()), (102, 1, 2, 2, 2, 2, '2026-01-11', '10:00-11:00', 0, NOW())"); + results.put("tutoring_appointment", "success"); + } catch (Exception e) { results.put("tutoring_appointment", e.getMessage()); } + + // 13. 补充聊天会话 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS chat_session (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, teacher_id BIGINT, last_message TEXT, last_time DATETIME, unread_count INT DEFAULT 0, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO chat_session (id, tenant_id, user_id, teacher_id, last_message, last_time, unread_count, status, create_time) VALUES (101, 1, 1, 1, '好的,明天见', NOW(), 0, 1, NOW()), (102, 1, 2, 2, '请问什么时候方便?', NOW(), 1, 1, NOW())"); + results.put("chat_session", "success"); + } catch (Exception e) { results.put("chat_session", e.getMessage()); } + + // 14. 补充通知消息 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS notification (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, title VARCHAR(200), content TEXT, type VARCHAR(20), is_read INT DEFAULT 0, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO notification (id, tenant_id, user_id, title, content, type, is_read, create_time) VALUES (101, 1, 1, '订单确认', '您的订单已确认,请等待服务安排', 'order', 1, NOW()), (102, 1, 2, '服务提醒', '您预约的服务将于明天10:00开始', 'service', 0, NOW())"); + results.put("notification", "success"); + } catch (Exception e) { results.put("notification", e.getMessage()); } + + // 15. 补充学习记录 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS learning_record (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, student_id BIGINT, teacher_id BIGINT, work_order_id BIGINT, subject VARCHAR(50), content TEXT, homework TEXT, performance TEXT, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO learning_record (id, tenant_id, student_id, teacher_id, work_order_id, subject, content, homework, performance, create_time) VALUES (101, 1, 1, 1, 1, '数学', '学习了乘法口诀', '完成练习册第10页', '表现良好', NOW()), (102, 1, 2, 2, 2, '英语', '学习了20个新单词', '背诵单词并造句', '认真听讲', NOW())"); + results.put("learning_record", "success"); + } catch (Exception e) { results.put("learning_record", e.getMessage()); } + + // 16. 补充定时任务 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS scheduled_task (id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), cron VARCHAR(50), class_name VARCHAR(200), method_name VARCHAR(100), params TEXT, status INT DEFAULT 1, last_run_time DATETIME, next_run_time DATETIME, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO scheduled_task (id, name, cron, class_name, method_name, status, create_time) VALUES (101, '订单超时取消', '0 */5 * * * ?', 'OrderTask', 'cancelTimeoutOrders', 1, NOW()), (102, '数据备份', '0 0 2 * * ?', 'BackupTask', 'backupDatabase', 1, NOW())"); + results.put("scheduled_task", "success"); + } catch (Exception e) { results.put("scheduled_task", e.getMessage()); } + + // 17. 补充错误日志 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS error_log (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, user_id BIGINT, url VARCHAR(500), method VARCHAR(10), params TEXT, error_message TEXT, stack_trace TEXT, ip VARCHAR(50), create_time DATETIME)"); + jdbcTemplate.update("INSERT IGNORE INTO error_log (id, tenant_id, user_id, url, method, error_message, ip, create_time) VALUES (101, 1, 1, '/api/order/create', 'POST', '库存不足', '127.0.0.1', NOW()), (102, 1, 2, '/api/user/update', 'PUT', '参数校验失败', '127.0.0.1', NOW())"); + results.put("error_log", "success"); + } catch (Exception e) { results.put("error_log", e.getMessage()); } + + // 18. 补充用户标签 + try { + jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS user_tag (id BIGINT AUTO_INCREMENT PRIMARY KEY, tenant_id BIGINT DEFAULT 1, name VARCHAR(50), color VARCHAR(20), description VARCHAR(200), user_count INT DEFAULT 0, status INT DEFAULT 1, create_time DATETIME, deleted INT DEFAULT 0)"); + jdbcTemplate.update("INSERT IGNORE INTO user_tag (id, tenant_id, name, color, description, user_count, status, create_time) VALUES (101, 1, 'VIP用户', '#FFD700', '高价值用户', 50, 1, NOW()), (102, 1, '新用户', '#87CEEB', '注册30天内', 200, 1, NOW()), (103, 1, '活跃用户', '#90EE90', '月活跃用户', 150, 1, NOW())"); + results.put("user_tag", "success"); + } catch (Exception e) { results.put("user_tag", e.getMessage()); } + + return Result.success(results); + } + + /** + * 专门修复订单表并插入测试数据 + * 访问: http://localhost:8080/api/init/fix-order + */ + @RequestMapping(value = "/fix-order", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixOrderAndInsertData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 检查 order 表结构 + try { + String tableInfo = ""; + try { + tableInfo = jdbcTemplate.queryForObject("SHOW CREATE TABLE `order`", String.class); + } catch (Exception e) { + tableInfo = "无法获取表结构: " + e.getMessage(); + } + results.put("table_structure", tableInfo); + } catch (Exception e) { + results.put("table_structure_error", e.getMessage()); + } + + // 2. 添加缺失的字段(不包括 amount,使用 price) + String[] alterSqls = { + "ALTER TABLE `order` ADD COLUMN service_name VARCHAR(100)", + "ALTER TABLE `order` ADD COLUMN service_date DATE", + "ALTER TABLE `order` ADD COLUMN time_slot VARCHAR(50)", + "ALTER TABLE `order` ADD COLUMN pay_status INT DEFAULT 0", + "ALTER TABLE `order` ADD COLUMN pay_amount DECIMAL(10,2)", + "ALTER TABLE `order` ADD COLUMN status INT DEFAULT 0" + }; + + StringBuilder alterResults = new StringBuilder(); + for (String sql : alterSqls) { + try { + jdbcTemplate.execute(sql); + alterResults.append("OK: ").append(sql.substring(0, Math.min(50, sql.length()))).append("...\n"); + } catch (Exception e) { + alterResults.append("SKIP: ").append(e.getMessage()).append("\n"); + } + } + results.put("alter_results", alterResults.toString()); + + // 3. 清空旧的测试数据 + try { + jdbcTemplate.update("DELETE FROM `order` WHERE id >= 101 AND id <= 110"); + results.put("delete_old", "success"); + } catch (Exception e) { + results.put("delete_old", e.getMessage()); + } + + // 4. 插入测试数据(包含 student_id 和 service_type) + int successCount = 0; + // id, order_no, user_id, student_id, service_id, teacher_id, price, pay_amount, status, service_name, service_type, service_date, time_slot, pay_status + String[][] orders = { + {"101", "PD20260107001", "1", "1", "1", "1", "99.00", "99.00", "0", "基准式陪伴-普通", "basic", "2026-01-10", "09:00-11:00", "0"}, + {"102", "PD20260107002", "2", "2", "2", "2", "199.00", "199.00", "1", "基准式陪伴-金牌", "basic_gold", "2026-01-11", "14:00-16:00", "1"}, + {"103", "PD20260107003", "1", "1", "3", "1", "159.00", "159.00", "2", "暖心式陪伴", "warm", "2026-01-08", "10:00-12:00", "1"}, + {"104", "PD20260107004", "3", "3", "1", "3", "99.00", "99.00", "3", "基准式陪伴-普通", "basic", "2026-01-05", "15:00-17:00", "1"}, + {"105", "PD20260107005", "2", "2", "4", "2", "299.00", "299.00", "-1", "天赋测评服务", "assessment", "2026-01-12", "09:00-10:00", "0"} + }; + + StringBuilder insertResults = new StringBuilder(); + for (String[] order : orders) { + try { + String sql = "INSERT INTO `order` (id, tenant_id, order_no, user_id, student_id, service_id, teacher_id, price, pay_amount, status, service_name, service_type, service_date, time_slot, pay_status, create_time) " + + "VALUES (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"; + jdbcTemplate.update(sql, + Long.parseLong(order[0]), order[1], Long.parseLong(order[2]), Long.parseLong(order[3]), Long.parseLong(order[4]), Long.parseLong(order[5]), + Double.parseDouble(order[6]), Double.parseDouble(order[7]), Integer.parseInt(order[8]), order[9], order[10], order[11], order[12], Integer.parseInt(order[13])); + successCount++; + insertResults.append("OK: ").append(order[1]).append("\n"); + } catch (Exception e) { + insertResults.append("FAIL: ").append(order[1]).append(" - ").append(e.getMessage()).append("\n"); + } + } + results.put("insert_results", insertResults.toString()); + results.put("success_count", successCount); + + // 5. 查询当前订单数量 + try { + Integer count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM `order`", Integer.class); + results.put("total_orders", count); + } catch (Exception e) { + results.put("total_orders_error", e.getMessage()); + } + + return Result.success(results); + } + + /** + * 插入交易流水和提现审核测试数据 + * 访问: http://localhost:8080/api/init/finance-data + */ + @RequestMapping(value = "/finance-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initFinanceData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + // 1. 插入钱包交易流水数据 + try { + // 先查询表结构 + try { + java.util.List> columns = jdbcTemplate.queryForList("SHOW COLUMNS FROM wallet_transaction"); + StringBuilder colNames = new StringBuilder(); + for (java.util.Map col : columns) { + colNames.append(col.get("Field")).append("(").append(col.get("Type")).append("), "); + } + results.put("wallet_transaction_columns", colNames.toString()); + } catch (Exception e) { + results.put("wallet_transaction_columns_error", e.getMessage()); + } + + // 删除旧测试数据 + try { + jdbcTemplate.update("DELETE FROM wallet_transaction WHERE id >= 101 AND id <= 120"); + } catch (Exception ignored) {} + + // 插入交易流水测试数据 + // type: income-收入, expense-支出, withdraw-提现, refund-退款 + int txnCount = 0; + Object[][] transactions = { + {101L, 1L, 1L, 1L, "TXN20260108001", "income", 500.00, 0.00, 500.00, 101L, "陪伴服务收入"}, + {102L, 1L, 1L, 1L, "TXN20260108002", "income", 300.00, 500.00, 800.00, 102L, "陪伴服务收入"}, + {103L, 1L, 1L, 1L, "TXN20260108003", "withdraw", 200.00, 800.00, 600.00, 0L, "提现申请"}, + {104L, 1L, 2L, 2L, "TXN20260108004", "income", 450.00, 0.00, 450.00, 103L, "陪伴服务收入"}, + {105L, 1L, 2L, 2L, "TXN20260108005", "income", 50.00, 450.00, 500.00, 0L, "推荐奖励"}, + {106L, 1L, 3L, 3L, "TXN20260108006", "income", 380.00, 0.00, 380.00, 104L, "陪伴服务收入"}, + {107L, 1L, 1L, 1L, "TXN20260108007", "refund", 99.00, 600.00, 699.00, 105L, "订单退款"}, + {108L, 1L, 2L, 2L, "TXN20260108008", "withdraw", 300.00, 500.00, 200.00, 0L, "提现申请"} + }; + + StringBuilder txnErrors = new StringBuilder(); + for (Object[] txn : transactions) { + try { + jdbcTemplate.update( + "INSERT INTO wallet_transaction (id, tenant_id, user_id, wallet_id, transaction_no, type, amount, balance_before, balance_after, order_id, remark, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + txn[0], txn[1], txn[2], txn[3], txn[4], txn[5], txn[6], txn[7], txn[8], txn[9], txn[10] + ); + txnCount++; + } catch (Exception e) { + txnErrors.append(txn[4]).append(": ").append(e.getMessage()).append("\n"); + } + } + results.put("wallet_transaction", "success: " + txnCount + " records"); + if (txnErrors.length() > 0) { + results.put("wallet_transaction_errors", txnErrors.toString()); + } + } catch (Exception e) { + results.put("wallet_transaction", "error: " + e.getMessage()); + } + + // 2. 插入提现审核数据 + try { + // 删除旧测试数据 + jdbcTemplate.update("DELETE FROM withdraw WHERE id >= 101 AND id <= 120"); + + // 插入提现测试数据 + // status: pending-待审核, approved-已通过, rejected-已拒绝, completed-已完成 + Object[][] withdraws = { + {101L, 1L, 1L, "WD20260108001", 200.00, 1.20, 198.80, "alipay", "138****1234", "张三", "pending"}, + {102L, 2L, 2L, "WD20260108002", 300.00, 1.80, 298.20, "wechat", "wx_openid_xxx", "李四", "pending"}, + {103L, 1L, 1L, "WD20260108003", 150.00, 0.90, 149.10, "bank", "6222****5678", "张三", "approved"}, + {104L, 3L, 3L, "WD20260108004", 500.00, 3.00, 497.00, "alipay", "139****5678", "王五", "completed"}, + {105L, 2L, 2L, "WD20260108005", 100.00, 0.60, 99.40, "wechat", "wx_openid_yyy", "李四", "rejected"} + }; + + int wdCount = 0; + for (Object[] wd : withdraws) { + try { + jdbcTemplate.update( + "INSERT INTO withdraw (id, tenant_id, teacher_id, user_id, withdraw_no, amount, fee, actual_amount, account_type, account_no, account_name, status, apply_time, create_time, deleted) " + + "VALUES (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW(), 0)", + wd[0], wd[1], wd[2], wd[3], wd[4], wd[5], wd[6], wd[7], wd[8], wd[9], wd[10] + ); + wdCount++; + } catch (Exception ignored) {} + } + results.put("withdraw", "success: " + wdCount + " records"); + } catch (Exception e) { + results.put("withdraw", "error: " + e.getMessage()); + } + + // 3. 查询当前数据量 + try { + Integer txnTotal = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM wallet_transaction", Integer.class); + results.put("total_transactions", txnTotal); + } catch (Exception e) { + results.put("total_transactions", "error: " + e.getMessage()); + } + + try { + Integer wdTotal = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM withdraw", Integer.class); + results.put("total_withdraws", wdTotal); + } catch (Exception e) { + results.put("total_withdraws", "error: " + e.getMessage()); + } + + return Result.success(results); + } + + /** + * 初始化客服咨询记录测试数据 + */ + @RequestMapping(value = "/customer-service-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initCustomerServiceData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + try { + // 1. 确保表存在 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS customer_service_record (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "user_id BIGINT," + + "user_name VARCHAR(50)," + + "phone VARCHAR(20)," + + "type VARCHAR(20)," + + "content TEXT," + + "staff_id BIGINT," + + "staff_name VARCHAR(50)," + + "reply_content TEXT," + + "status INT DEFAULT 0," + + "tenant_id BIGINT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + results.put("table_created", "customer_service_record"); + + // 2. 删除旧测试数据 + jdbcTemplate.update("DELETE FROM customer_service_record WHERE id >= 101 AND id <= 120"); + results.put("delete_old", "success"); + + // 3. 插入客服咨询记录测试数据 + // type: presale-售前咨询, aftersale-售后咨询, complaint-投诉建议 + // status: 0-待处理, 1-处理中, 2-已完成 + Object[][] records = { + // 售前咨询 + {101L, 1L, "张妈妈", "13800138001", "presale", "请问基准式陪伴服务包含哪些内容?价格是多少?", 1L, "张客服", "您好!基准式陪伴服务包含入户陪伴、作业辅导、习惯培养等内容,普通老师99元/小时,金牌老师199元/小时。", 2}, + {102L, 2L, "李爸爸", "13800138002", "presale", "想了解一下暖心式陪伴和基准式陪伴有什么区别?", 1L, "张客服", "您好!暖心式陪伴更注重孩子的心理健康和情感陪伴,会有专业的心理辅导内容。基准式陪伴侧重于学习辅导和习惯培养。", 2}, + {103L, 3L, "王女士", "13800138003", "presale", "你们的陪伴员都有什么资质?", null, null, null, 0}, + {104L, 4L, "赵先生", "13800138004", "presale", "请问可以先试听一次吗?", 2L, "李客服", null, 1}, + + // 售后咨询 + {105L, 1L, "张妈妈", "13800138001", "aftersale", "上次预约的老师临时有事,能换一位老师吗?", 1L, "张客服", "非常抱歉给您带来不便!我们已经为您安排了另一位金牌老师,服务时间不变。", 2}, + {106L, 2L, "李爸爸", "13800138002", "aftersale", "订单已经支付但是显示未支付,怎么回事?", 2L, "李客服", "您好,经核实您的订单支付已成功,系统显示延迟,现已更新。给您带来不便深表歉意!", 2}, + {107L, 5L, "陈妈妈", "13800138005", "aftersale", "想申请退款,孩子临时有事不能上课了", null, null, null, 0}, + {108L, 6L, "刘先生", "13800138006", "aftersale", "能否更改服务时间?", 1L, "张客服", null, 1}, + + // 投诉建议 + {109L, 3L, "王女士", "13800138003", "complaint", "老师迟到了15分钟,希望能加强管理", 1L, "张客服", "非常抱歉给您带来不好的体验!我们已经对该老师进行了提醒,并为您延长15分钟服务时间作为补偿。", 2}, + {110L, 7L, "孙先生", "13800138007", "complaint", "建议增加周末的服务时段", 2L, "李客服", "感谢您的宝贵建议!我们已经记录并反馈给运营团队,后续会考虑增加周末时段。", 2}, + {111L, 8L, "周妈妈", "13800138008", "complaint", "APP有时候会闪退,希望能优化一下", null, null, null, 0}, + {112L, 9L, "吴先生", "13800138009", "complaint", "希望能增加更多的课程种类", 1L, "张客服", null, 1}, + + // 更多测试数据 + {113L, 10L, "郑妈妈", "13800138010", "presale", "请问有针对初中生的服务吗?", null, null, null, 0}, + {114L, 1L, "张妈妈", "13800138001", "presale", "时卡和次卡有什么区别?哪个更划算?", 2L, "李客服", "您好!时卡按小时计费,次卡按次数计费。如果您每周固定使用,建议购买月卡更划算。", 2}, + {115L, 2L, "李爸爸", "13800138002", "aftersale", "上次的成长报告什么时候能发?", 1L, "张客服", "您好,成长报告一般在服务结束后24小时内发送,请您稍等。", 2} + }; + + int successCount = 0; + StringBuilder errors = new StringBuilder(); + for (Object[] record : records) { + try { + jdbcTemplate.update( + "INSERT INTO customer_service_record (id, user_id, user_name, phone, type, content, staff_id, staff_name, reply_content, status, tenant_id, create_time, deleted) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 7) DAY), 0)", + record[0], record[1], record[2], record[3], record[4], record[5], record[6], record[7], record[8], record[9] + ); + successCount++; + } catch (Exception e) { + errors.append(record[0]).append(": ").append(e.getMessage()).append("\n"); + } + } + results.put("success_count", successCount); + if (errors.length() > 0) { + results.put("errors", errors.toString()); + } + + // 4. 查询当前数据量 + Integer total = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM customer_service_record WHERE deleted = 0", Integer.class); + results.put("total_records", total); + + // 5. 统计各状态数量 + Integer pending = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM customer_service_record WHERE status = 0 AND deleted = 0", Integer.class); + Integer processing = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM customer_service_record WHERE status = 1 AND deleted = 0", Integer.class); + Integer completed = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM customer_service_record WHERE status = 2 AND deleted = 0", Integer.class); + results.put("status_pending", pending); + results.put("status_processing", processing); + results.put("status_completed", completed); + + return Result.success(results); + } catch (Exception e) { + return Result.error("初始化客服咨询记录失败: " + e.getMessage()); + } + } + + /** + * 初始化财务测试数据 + * 更新订单为已支付状态,并插入测试订单数据 + */ + @RequestMapping(value = "/financial-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initFinancialData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + try { + // 1. 更新现有订单为已支付状态 + int updatedOrders = jdbcTemplate.update( + "UPDATE `order` SET pay_status = 1, pay_time = COALESCE(pay_time, create_time) WHERE pay_status = 0 OR pay_status IS NULL" + ); + results.put("updated_orders_to_paid", updatedOrders); + + // 2. 检查order表是否有数据,如果没有则插入测试订单 + Integer orderCount = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM `order`", Integer.class); + results.put("existing_order_count", orderCount); + + if (orderCount == null || orderCount < 10) { + // 插入测试订单数据(已支付状态) + Object[][] orders = { + // order_no, user_id, service_id, service_name, pay_amount, pay_status, status, days_ago + {"ORD202601080001", 1L, 1L, "基准式陪伴-普通老师", 99.00, 1, 2, 0}, + {"ORD202601080002", 2L, 2L, "基准式陪伴-金牌老师", 199.00, 1, 2, 0}, + {"ORD202601070001", 1L, 3L, "暖心式陪伴", 159.00, 1, 2, 1}, + {"ORD202601070002", 3L, 4L, "伙伴式陪伴", 129.00, 1, 2, 1}, + {"ORD202601060001", 2L, 5L, "语文专项辅导", 149.00, 1, 2, 2}, + {"ORD202601060002", 1L, 6L, "数学专项辅导", 149.00, 1, 2, 2}, + {"ORD202601050001", 3L, 7L, "天赋测评服务", 299.00, 1, 2, 3}, + {"ORD202601050002", 2L, 8L, "成长规划咨询", 399.00, 1, 2, 3}, + {"ORD202601040001", 1L, 1L, "基准式陪伴-普通老师", 99.00, 1, 2, 4}, + {"ORD202601040002", 2L, 2L, "基准式陪伴-金牌老师", 199.00, 1, 2, 4}, + {"ORD202601030001", 3L, 3L, "暖心式陪伴", 159.00, 1, 2, 5}, + {"ORD202601030002", 1L, 4L, "伙伴式陪伴", 129.00, 1, 2, 5}, + {"ORD202601020001", 2L, 5L, "语文专项辅导", 149.00, 1, 2, 6}, + {"ORD202601020002", 3L, 6L, "数学专项辅导", 149.00, 1, 2, 6}, + {"ORD202601010001", 1L, 7L, "天赋测评服务", 299.00, 1, 2, 7}, + // 本周更多订单 + {"ORD202601080003", 3L, 1L, "基准式陪伴-普通老师", 198.00, 1, 2, 0}, + {"ORD202601080004", 1L, 3L, "暖心式陪伴", 318.00, 1, 2, 0}, + {"ORD202601070003", 2L, 2L, "基准式陪伴-金牌老师", 398.00, 1, 2, 1}, + {"ORD202601070004", 3L, 8L, "成长规划咨询", 399.00, 1, 2, 1}, + {"ORD202601060003", 1L, 7L, "天赋测评服务", 299.00, 1, 2, 2} + }; + + int insertedOrders = 0; + for (Object[] order : orders) { + try { + jdbcTemplate.update( + "INSERT INTO `order` (order_no, tenant_id, user_id, service_id, service_name, pay_amount, pay_status, status, pay_time, create_time) " + + "VALUES (?, 1, ?, ?, ?, ?, ?, ?, DATE_SUB(NOW(), INTERVAL ? DAY), DATE_SUB(NOW(), INTERVAL ? DAY))", + order[0], order[1], order[2], order[3], order[4], order[5], order[6], order[7], order[7] + ); + insertedOrders++; + } catch (Exception e) { + // 忽略重复插入错误 + } + } + results.put("inserted_orders", insertedOrders); + } + + // 3. 插入教师薪资支出数据(用于支出统计) + try { + // 先检查teacher_salary表是否存在 + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS teacher_salary (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "teacher_id BIGINT," + + "teacher_name VARCHAR(50)," + + "amount DECIMAL(10,2)," + + "salary_month VARCHAR(10)," + + "status INT DEFAULT 0," + + "pay_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0" + + ")" + ); + + Object[][] salaries = { + {1L, "张老师", 3200.00, "2026-01", 1}, + {2L, "李老师", 2800.00, "2026-01", 1}, + {3L, "王老师", 3500.00, "2026-01", 0}, + {1L, "张老师", 3000.00, "2025-12", 1}, + {2L, "李老师", 2600.00, "2025-12", 1} + }; + + int insertedSalaries = 0; + for (Object[] salary : salaries) { + try { + jdbcTemplate.update( + "INSERT INTO teacher_salary (tenant_id, teacher_id, teacher_name, amount, salary_month, status, pay_time, create_time) " + + "VALUES (1, ?, ?, ?, ?, ?, NOW(), NOW())", + salary[0], salary[1], salary[2], salary[3], salary[4] + ); + insertedSalaries++; + } catch (Exception e) { + // 忽略重复插入错误 + } + } + results.put("inserted_salaries", insertedSalaries); + } catch (Exception e) { + results.put("salary_error", e.getMessage()); + } + + // 4. 统计财务数据 + try { + java.math.BigDecimal totalIncome = jdbcTemplate.queryForObject( + "SELECT COALESCE(SUM(pay_amount), 0) FROM `order` WHERE pay_status = 1", + java.math.BigDecimal.class + ); + results.put("total_income", totalIncome); + + Integer paidOrderCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM `order` WHERE pay_status = 1", + Integer.class + ); + results.put("paid_order_count", paidOrderCount); + + // 今日收入 + java.math.BigDecimal todayIncome = jdbcTemplate.queryForObject( + "SELECT COALESCE(SUM(pay_amount), 0) FROM `order` WHERE pay_status = 1 AND DATE(create_time) = CURDATE()", + java.math.BigDecimal.class + ); + results.put("today_income", todayIncome); + + // 本周收入 + java.math.BigDecimal weekIncome = jdbcTemplate.queryForObject( + "SELECT COALESCE(SUM(pay_amount), 0) FROM `order` WHERE pay_status = 1 AND YEARWEEK(create_time) = YEARWEEK(NOW())", + java.math.BigDecimal.class + ); + results.put("week_income", weekIncome); + + // 本月收入 + java.math.BigDecimal monthIncome = jdbcTemplate.queryForObject( + "SELECT COALESCE(SUM(pay_amount), 0) FROM `order` WHERE pay_status = 1 AND YEAR(create_time) = YEAR(NOW()) AND MONTH(create_time) = MONTH(NOW())", + java.math.BigDecimal.class + ); + results.put("month_income", monthIncome); + + } catch (Exception e) { + results.put("stats_error", e.getMessage()); + } + + return Result.success(results); + } catch (Exception e) { + return Result.error("初始化财务数据失败: " + e.getMessage()); + } + } + + /** + * 初始化服务图片 + */ + @RequestMapping(value = "/service-images", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initServiceImages() { + checkDevEnvironment(); + try { + Map results = new HashMap<>(); + int updated = 0; + + // 为不同类型的服务设置图片 + String[][] imageMapping = { + {"辅导", "https://images.unsplash.com/photo-1503676260728-1c00da094a0b?w=400"}, + {"规划", "https://images.unsplash.com/photo-1434030216411-0b793f4b4173?w=400"}, + {"督学", "https://images.unsplash.com/photo-1516534775068-ba3e7458af70?w=400"}, + {"兴趣", "https://images.unsplash.com/photo-1513364776144-60967b0f800f?w=400"}, + {"突破", "https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?w=400"}, + {"研学", "https://images.unsplash.com/photo-1523050854058-8df90110c9f1?w=400"}, + {"暑假", "https://images.unsplash.com/photo-1533854775446-95c4609da544?w=400"}, + {"夏令营", "https://images.unsplash.com/photo-1533854775446-95c4609da544?w=400"}, + {"陪伴", "https://images.unsplash.com/photo-1491438590914-bc09fcaaf77a?w=400"}, + {"测评", "https://images.unsplash.com/photo-1434030216411-0b793f4b4173?w=400"} + }; + + for (String[] mapping : imageMapping) { + try { + int count = jdbcTemplate.update( + "UPDATE service SET cover = ? WHERE name LIKE ? AND (cover IS NULL OR cover = '' OR cover = '/static/service.png')", + mapping[1], "%" + mapping[0] + "%" + ); + updated += count; + results.put(mapping[0], count + " records updated"); + } catch (Exception e) { + results.put(mapping[0] + "_error", e.getMessage()); + } + } + + // 为所有没有图片的服务设置默认图片 + try { + int defaultCount = jdbcTemplate.update( + "UPDATE service SET cover = ? WHERE cover IS NULL OR cover = '' OR cover = '/static/service.png'", + "https://images.unsplash.com/photo-1497633762265-9d179a990aa6?w=400" + ); + updated += defaultCount; + results.put("default", defaultCount + " records updated"); + } catch (Exception e) { + results.put("default_error", e.getMessage()); + } + + results.put("total_updated", updated); + results.put("message", "服务图片初始化完成,共更新 " + updated + " 条记录"); + + return Result.success(results); + } catch (Exception e) { + return Result.error("初始化服务图片失败: " + e.getMessage()); + } + } + + /** + * 同步服务图片字段(从cover到cover_image) + */ + @RequestMapping(value = "/sync-service-cover", method = {RequestMethod.GET, RequestMethod.POST}) + public Result syncServiceCover() { + checkDevEnvironment(); + try { + // 1. 检查cover_image字段是否存在 + try { + jdbcTemplate.execute("ALTER TABLE service ADD COLUMN cover_image VARCHAR(500)"); + } catch (Exception e) { + // 字段已存在,忽略错误 + } + + // 2. 将cover字段的值复制到cover_image + int updated = jdbcTemplate.update( + "UPDATE service SET cover_image = cover WHERE cover IS NOT NULL AND cover != ''" + ); + + // 3. 如果cover_image为空但cover不为空,也复制过去 + int updated2 = jdbcTemplate.update( + "UPDATE service SET cover_image = cover WHERE (cover_image IS NULL OR cover_image = '') AND cover IS NOT NULL AND cover != ''" + ); + + Map result = new HashMap<>(); + result.put("updated", updated); + result.put("updated2", updated2); + result.put("total", updated + updated2); + result.put("message", "服务图片字段同步完成"); + + return Result.success(result); + } catch (Exception e) { + return Result.error("同步服务图片字段失败: " + e.getMessage()); + } + } + + /** + * 初始化测试通知数据 + */ + @RequestMapping(value = "/notifications", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initNotifications() { + checkDevEnvironment(); + try { + Map results = new HashMap<>(); + int inserted = 0; + + // 创建测试通知数据 + Object[][] notifications = { + {1L, "order", "新订单通知", "您有一个新的订单待处理", 1L, 0}, + {1L, "order", "订单支付成功", "订单已支付,请及时处理", 2L, 0}, + {1L, "system", "系统通知", "欢迎使用陪读管理系统", null, 0}, + {1L, "order", "订单已完成", "订单服务已完成,请查看", 3L, 1}, + {1L, "system", "功能更新", "系统新增了消息通知功能", null, 0}, + {2L, "order", "新订单通知", "您有一个新的订单待接单", 4L, 0}, + {2L, "order", "订单提醒", "您有订单即将开始服务", 5L, 0}, + {2L, "system", "系统维护通知", "系统将于今晚进行维护", null, 1} + }; + + for (Object[] notif : notifications) { + try { + jdbcTemplate.update( + "INSERT INTO notification (user_id, type, title, content, related_id, is_read, create_time, update_time) " + + "VALUES (?, ?, ?, ?, ?, ?, NOW(), NOW())", + notif[0], notif[1], notif[2], notif[3], notif[4], notif[5] + ); + inserted++; + } catch (Exception e) { + // 忽略重复插入错误 + } + } + + results.put("inserted", inserted); + results.put("message", "通知数据初始化完成,共插入 " + inserted + " 条记录"); + + return Result.success(results); + } catch (Exception e) { + return Result.error("初始化通知数据失败: " + e.getMessage()); + } + } + + /** + * 修复Order表缺失字段 + */ + @RequestMapping(value = "/fix-order-table", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixOrderTable() { + checkDevEnvironment(); + try { + Map results = new HashMap<>(); + + // 添加缺失的字段 + String[] alterSqls = { + "ALTER TABLE `order` ADD COLUMN service_start_time DATETIME COMMENT '服务开始时间'", + "ALTER TABLE `order` ADD COLUMN service_end_time DATETIME COMMENT '服务结束时间'", + "ALTER TABLE `order` ADD COLUMN actual_duration INT COMMENT '实际服务时长(分钟)'" + }; + + for (String sql : alterSqls) { + try { + jdbcTemplate.execute(sql); + results.put(sql.substring(sql.indexOf("ADD COLUMN") + 11, sql.indexOf(" ", sql.indexOf("ADD COLUMN") + 12)), "added"); + } catch (Exception e) { + // 字段已存在,忽略错误 + results.put(sql.substring(sql.indexOf("ADD COLUMN") + 11, sql.indexOf(" ", sql.indexOf("ADD COLUMN") + 12)), "exists"); + } + } + + results.put("message", "Order表字段修复完成"); + return Result.success(results); + } catch (Exception e) { + return Result.error("修复Order表失败: " + e.getMessage()); + } + } + + /** + * 修复Order表的tenant_id字段 + */ + @RequestMapping(value = "/fix-order-tenant-id", method = {RequestMethod.GET, RequestMethod.POST}) + public Result fixOrderTenantId() { + checkDevEnvironment(); + try { + Map results = new HashMap<>(); + + // 1. 检查当前tenant_id为NULL的订单数量 + Integer nullCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM `order` WHERE tenant_id IS NULL", + Integer.class + ); + results.put("null_tenant_id_count", nullCount); + + // 2. 更新所有tenant_id为NULL的订单 + int updated = jdbcTemplate.update( + "UPDATE `order` SET tenant_id = 1 WHERE tenant_id IS NULL" + ); + results.put("updated_count", updated); + + // 3. 检查更新后的状态 + Integer totalCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM `order`", + Integer.class + ); + results.put("total_orders", totalCount); + + Integer tenant1Count = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM `order` WHERE tenant_id = 1", + Integer.class + ); + results.put("tenant_1_count", tenant1Count); + + results.put("message", "tenant_id修复完成"); + return Result.success(results); + } catch (Exception e) { + return Result.error("修复tenant_id失败: " + e.getMessage()); + } + } + + /** + * 初始化分销员测试数据 + * 访问: http://localhost:8080/api/init/distributor-data + */ + @RequestMapping(value = "/distributor-data", method = {RequestMethod.GET, RequestMethod.POST}) + public Result initDistributorData() { + checkDevEnvironment(); + Map results = new HashMap<>(); + + try { + // 1. 创建分销员表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "user_id BIGINT NOT NULL," + + "distributor_code VARCHAR(50) UNIQUE," + + "name VARCHAR(50)," + + "phone VARCHAR(20)," + + "id_card VARCHAR(50)," + + "invite_code VARCHAR(50)," + + "parent_id BIGINT," + + "level INT DEFAULT 1," + + "status INT DEFAULT 1," + + "total_commission DECIMAL(10,2) DEFAULT 0," + + "available_commission DECIMAL(10,2) DEFAULT 0," + + "frozen_commission DECIMAL(10,2) DEFAULT 0," + + "withdrawn_commission DECIMAL(10,2) DEFAULT 0," + + "total_orders INT DEFAULT 0," + + "total_members INT DEFAULT 0," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0," + + "INDEX idx_user_id (user_id)," + + "INDEX idx_distributor_code (distributor_code)," + + "INDEX idx_parent_id (parent_id)" + + ")" + ); + results.put("distributor_table", "created"); + } catch (Exception e) { + results.put("distributor_table", "exists"); + } + + // 2. 创建分销订单表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor_order (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "distributor_id BIGINT NOT NULL," + + "order_id BIGINT NOT NULL," + + "order_no VARCHAR(50)," + + "user_id BIGINT," + + "service_name VARCHAR(100)," + + "order_amount DECIMAL(10,2)," + + "commission_rate DECIMAL(5,2)," + + "commission_amount DECIMAL(10,2)," + + "status INT DEFAULT 0," + + "settle_time DATETIME," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0," + + "INDEX idx_distributor_id (distributor_id)," + + "INDEX idx_order_id (order_id)" + + ")" + ); + results.put("distributor_order_table", "created"); + } catch (Exception e) { + results.put("distributor_order_table", "exists"); + } + + // 3. 创建分销佣金记录表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor_commission (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "distributor_id BIGINT NOT NULL," + + "order_id BIGINT," + + "type VARCHAR(20)," + + "amount DECIMAL(10,2)," + + "status INT DEFAULT 0," + + "remark VARCHAR(500)," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0," + + "INDEX idx_distributor_id (distributor_id)" + + ")" + ); + results.put("distributor_commission_table", "created"); + } catch (Exception e) { + results.put("distributor_commission_table", "exists"); + } + + // 4. 创建分销团队关系表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor_team (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "distributor_id BIGINT NOT NULL," + + "member_id BIGINT NOT NULL," + + "level INT DEFAULT 1," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0," + + "INDEX idx_distributor_id (distributor_id)," + + "INDEX idx_member_id (member_id)" + + ")" + ); + results.put("distributor_team_table", "created"); + } catch (Exception e) { + results.put("distributor_team_table", "exists"); + } + + // 5. 创建分销提现记录表 + try { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS distributor_withdraw (" + + "id BIGINT AUTO_INCREMENT PRIMARY KEY," + + "tenant_id BIGINT DEFAULT 1," + + "distributor_id BIGINT NOT NULL," + + "withdraw_no VARCHAR(50) UNIQUE," + + "amount DECIMAL(10,2)," + + "fee DECIMAL(10,2) DEFAULT 0," + + "actual_amount DECIMAL(10,2)," + + "account_type VARCHAR(20)," + + "account_no VARCHAR(100)," + + "account_name VARCHAR(50)," + + "status INT DEFAULT 0," + + "apply_time DATETIME," + + "approve_time DATETIME," + + "complete_time DATETIME," + + "reject_reason VARCHAR(500)," + + "create_time DATETIME DEFAULT CURRENT_TIMESTAMP," + + "update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + + "deleted INT DEFAULT 0," + + "INDEX idx_distributor_id (distributor_id)," + + "INDEX idx_withdraw_no (withdraw_no)" + + ")" + ); + results.put("distributor_withdraw_table", "created"); + } catch (Exception e) { + results.put("distributor_withdraw_table", "exists"); + } + + // 6. 插入分销员测试数据 + int distributorCount = 0; + Object[][] distributors = { + {1L, 3L, "DIST1001", "张三", "13800138003", "110101199001011001", null, null, 1, 1, 3850.00, 1200.00, 350.00, 2300.00, 128, 12}, + {1L, 4L, "DIST1002", "李四", "13800138004", "110101199002022002", "DIST1001", 1L, 1, 1, 2150.00, 800.00, 150.00, 1200.00, 85, 8}, + {1L, 5L, "DIST1003", "王五", "13800138005", "110101199003033003", "DIST1001", 1L, 1, 1, 1680.00, 600.00, 80.00, 1000.00, 56, 5} + }; + + for (Object[] d : distributors) { + try { + jdbcTemplate.update( + "INSERT INTO distributor (tenant_id, user_id, distributor_code, name, phone, id_card, invite_code, parent_id, level, status, " + + "total_commission, available_commission, frozen_commission, withdrawn_commission, total_orders, total_members, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15] + ); + distributorCount++; + } catch (Exception ignored) {} + } + results.put("distributor_inserted", distributorCount); + + // 7. 插入分销订单测试数据 + int orderCount = 0; + Object[][] orders = { + {1L, 1L, 101L, "PD20260111001", 1L, "基准式陪伴-普通老师", 99.00, 10.00, 9.90, 2, "2026-01-10 10:00:00"}, + {1L, 1L, 102L, "PD20260111002", 2L, "基准式陪伴-金牌老师", 199.00, 10.00, 19.90, 2, "2026-01-10 11:00:00"}, + {1L, 1L, 103L, "PD20260111003", 3L, "暖心式陪伴", 159.00, 10.00, 15.90, 2, "2026-01-10 12:00:00"}, + {1L, 1L, 104L, "PD20260111004", 4L, "伙伴式陪伴", 129.00, 10.00, 12.90, 1, null}, + {1L, 1L, 105L, "PD20260111005", 5L, "天赋测评服务", 299.00, 10.00, 29.90, 0, null}, + {1L, 2L, 106L, "PD20260111006", 6L, "成长规划咨询", 399.00, 10.00, 39.90, 2, "2026-01-10 14:00:00"}, + {1L, 2L, 107L, "PD20260111007", 7L, "语文专项辅导", 149.00, 10.00, 14.90, 2, "2026-01-10 15:00:00"}, + {1L, 3L, 108L, "PD20260111008", 8L, "数学专项辅导", 149.00, 10.00, 14.90, 2, "2026-01-10 16:00:00"} + }; + + for (Object[] o : orders) { + try { + jdbcTemplate.update( + "INSERT INTO distributor_order (tenant_id, distributor_id, order_id, order_no, user_id, service_name, " + + "order_amount, commission_rate, commission_amount, status, settle_time, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + o[0], o[1], o[2], o[3], o[4], o[5], o[6], o[7], o[8], o[9], o[10] + ); + orderCount++; + } catch (Exception ignored) {} + } + results.put("distributor_order_inserted", orderCount); + + // 8. 插入佣金记录测试数据 + int commissionCount = 0; + Object[][] commissions = { + {1L, 1L, 101L, "order", 9.90, 2, "订单佣金"}, + {1L, 1L, 102L, "order", 19.90, 2, "订单佣金"}, + {1L, 1L, 103L, "order", 15.90, 2, "订单佣金"}, + {1L, 1L, 104L, "order", 12.90, 1, "订单佣金"}, + {1L, 1L, 105L, "order", 29.90, 0, "订单佣金"}, + {1L, 1L, null, "bonus", 50.00, 2, "推荐奖励"}, + {1L, 2L, 106L, "order", 39.90, 2, "订单佣金"}, + {1L, 2L, 107L, "order", 14.90, 2, "订单佣金"}, + {1L, 3L, 108L, "order", 14.90, 2, "订单佣金"} + }; + + for (Object[] c : commissions) { + try { + jdbcTemplate.update( + "INSERT INTO distributor_commission (tenant_id, distributor_id, order_id, type, amount, status, remark, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, NOW())", + c[0], c[1], c[2], c[3], c[4], c[5], c[6] + ); + commissionCount++; + } catch (Exception ignored) {} + } + results.put("distributor_commission_inserted", commissionCount); + + // 9. 插入团队关系测试数据 + int teamCount = 0; + Object[][] teams = { + {1L, 1L, 2L, 1}, + {1L, 1L, 3L, 1}, + {1L, 1L, 4L, 2}, + {1L, 1L, 5L, 2}, + {1L, 2L, 4L, 1}, + {1L, 2L, 5L, 1} + }; + + for (Object[] t : teams) { + try { + jdbcTemplate.update( + "INSERT INTO distributor_team (tenant_id, distributor_id, member_id, level, create_time) " + + "VALUES (?, ?, ?, ?, NOW())", + t[0], t[1], t[2], t[3] + ); + teamCount++; + } catch (Exception ignored) {} + } + results.put("distributor_team_inserted", teamCount); + + // 10. 插入提现记录测试数据 + int withdrawCount = 0; + Object[][] withdraws = { + {1L, 1L, "DW20260111001", 500.00, 5.00, 495.00, "alipay", "13800138003", "张三", 2, "2026-01-10 09:00:00", "2026-01-10 10:00:00", "2026-01-10 11:00:00", null}, + {1L, 1L, "DW20260111002", 1000.00, 10.00, 990.00, "wechat", "13800138003", "张三", 2, "2026-01-09 09:00:00", "2026-01-09 10:00:00", "2026-01-09 11:00:00", null}, + {1L, 1L, "DW20260111003", 800.00, 8.00, 792.00, "bank", "6222021234567890", "张三", 2, "2026-01-08 09:00:00", "2026-01-08 10:00:00", "2026-01-08 11:00:00", null}, + {1L, 2L, "DW20260111004", 600.00, 6.00, 594.00, "alipay", "13800138004", "李四", 1, "2026-01-10 14:00:00", "2026-01-10 15:00:00", null, null}, + {1L, 2L, "DW20260111005", 300.00, 3.00, 297.00, "wechat", "13800138004", "李四", 0, "2026-01-11 09:00:00", null, null, null} + }; + + for (Object[] w : withdraws) { + try { + jdbcTemplate.update( + "INSERT INTO distributor_withdraw (tenant_id, distributor_id, withdraw_no, amount, fee, actual_amount, " + + "account_type, account_no, account_name, status, apply_time, approve_time, complete_time, reject_reason, create_time) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", + w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7], w[8], w[9], w[10], w[11], w[12], w[13] + ); + withdrawCount++; + } catch (Exception ignored) {} + } + results.put("distributor_withdraw_inserted", withdrawCount); + + results.put("message", "分销员测试数据初始化完成"); + return Result.success(results); + + } catch (Exception e) { + return Result.error("初始化分销员数据失败: " + e.getMessage()); + } + } + + /** + * 初始化服务商测试数据 + * 为当前登录用户创建服务商记录、学生和课程 + */ + @PostMapping("/provider-data") + public Result initProviderData(@RequestParam(required = false, defaultValue = "1") Long userId) { + checkDevEnvironment(); + Map result = new HashMap<>(); + + try { + // 1. 创建服务商记录 + Integer providerCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM provider WHERE user_id = ?", Integer.class, userId); + + if (providerCount == null || providerCount == 0) { + jdbcTemplate.update( + "INSERT INTO provider (user_id, name, phone, business_license, description, status, create_time, update_time, deleted) " + + "VALUES (?, '测试服务商', '13800138000', 'LICENSE123456', '提供各类教育培训服务', 1, NOW(), NOW(), 0)", + userId + ); + result.put("provider", "created"); + } else { + result.put("provider", "already exists"); + } + + // 获取服务商ID + Long providerId = jdbcTemplate.queryForObject( + "SELECT id FROM provider WHERE user_id = ? LIMIT 1", Long.class, userId); + result.put("providerId", providerId); + + // 2. 创建测试学生 + String[] studentNames = {"张小明", "李小红", "王小刚"}; + String[] grades = {"三年级", "四年级", "五年级"}; + String[] schools = {"实验小学", "实验小学", "育才小学"}; + int[] genders = {1, 2, 1}; + + for (int i = 0; i < studentNames.length; i++) { + try { + jdbcTemplate.update( + "INSERT INTO student (user_id, student_name, gender, grade, school, avatar, is_default, create_time, update_time, deleted) " + + "VALUES (?, ?, ?, ?, ?, '/static/avatar-default.jpg', ?, NOW(), NOW(), 0)", + userId, studentNames[i], genders[i], grades[i], schools[i], (i == 0 ? 1 : 0) + ); + } catch (Exception ignored) {} + } + result.put("students", "created"); + + // 3. 创建测试课程订单 + String[] courseNames = {"数学辅导", "语文辅导", "英语辅导"}; + String[] courseTypes = {"math", "chinese", "english"}; + String[] timeSlots = {"14:00-16:00", "16:00-18:00", "10:00-12:00"}; + String[] addresses = {"实验小学A101", "实验小学B202", "育才小学C303"}; + double[] prices = {200.00, 180.00, 220.00}; + + for (int i = 0; i < courseNames.length; i++) { + try { + // 获取学生ID + Long studentId = jdbcTemplate.queryForObject( + "SELECT id FROM student WHERE user_id = ? AND name = ? LIMIT 1", + Long.class, userId, studentNames[i] + ); + + String orderNo = "ORD" + System.currentTimeMillis() + String.format("%03d", i + 1); + + jdbcTemplate.update( + "INSERT INTO `order` (order_no, user_id, student_id, service_id, teacher_id, service_name, service_type, " + + "service_date, time_slot, duration, service_address, price, pay_amount, status, pay_status, pay_type, " + + "pay_time, create_time, update_time, deleted) " + + "VALUES (?, ?, ?, 1, ?, ?, ?, CURDATE(), ?, 120, ?, ?, ?, 1, 1, 'balance', NOW(), NOW(), NOW(), 0)", + orderNo, userId, studentId, providerId, courseNames[i], courseTypes[i], + timeSlots[i], addresses[i], prices[i], prices[i] + ); + } catch (Exception e) { + System.err.println("创建订单失败: " + e.getMessage()); + } + } + result.put("courses", "created"); + + // 4. 统计结果 + Integer studentCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM student WHERE user_id = ?", Integer.class, userId); + Integer courseCount = jdbcTemplate.queryForObject( + "SELECT COUNT(*) FROM `order` WHERE teacher_id = ?", Integer.class, providerId); + + result.put("totalStudents", studentCount); + result.put("totalCourses", courseCount); + result.put("message", "服务商测试数据创建成功!"); + + return Result.success(result); + } catch (Exception e) { + e.printStackTrace(); + return Result.error("创建失败: " + e.getMessage()); + } + } + +} diff --git a/peidu/uniapp/pages.json b/peidu/uniapp/pages.json new file mode 100644 index 0000000..232c6ec --- /dev/null +++ b/peidu/uniapp/pages.json @@ -0,0 +1,1078 @@ +{ + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "首页", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/search/index", + "style": { + "navigationBarTitleText": "搜索", + "navigationBarBackgroundColor": "#ffffff" + } + }, + { + "path": "pages/service/list", + "style": { + "navigationBarTitleText": "服务列表", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/booking/quick-booking", + "style": { + "navigationBarTitleText": "快速预约" + } + }, + { + "path": "pages/order/list", + "style": { + "navigationBarTitleText": "服务日历", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/order/calendar", + "style": { + "navigationBarTitleText": "服务日历" + } + }, + { + "path": "pages/user/index", + "style": { + "navigationBarTitleText": "个人中心" + } + }, + { + "path": "pages/service/detail", + "style": { + "navigationBarTitleText": "服务详情" + } + }, + { + "path": "pages/teacher/detail", + "style": { + "navigationBarTitleText": "教师详情" + } + }, + { + "path": "pages/teacher/list", + "style": { + "navigationBarTitleText": "选择陪伴员" + } + }, + { + "path": "pages/auth/role-select", + "style": { + "navigationBarTitleText": "选择身份" + } + }, + { + "path": "pages/auth/parent-register", + "style": { + "navigationBarTitleText": "家长注册" + } + }, + { + "path": "pages/auth/parent-quick-register", + "style": { + "navigationBarTitleText": "家长快速注册" + } + }, + { + "path": "pages/auth/bind-phone", + "style": { + "navigationBarTitleText": "绑定手机号" + } + }, + { + "path": "pages/agreement/user", + "style": { + "navigationBarTitleText": "用户协议" + } + }, + { + "path": "pages/agreement/privacy", + "style": { + "navigationBarTitleText": "隐私政策" + } + } + ], + "subPackages": [ + { + "root": "src/order-package", + "name": "order", + "pages": [ + { + "path": "pages/order/create", + "style": { + "navigationBarTitleText": "确认订单" + } + }, + { + "path": "pages/order/detail", + "style": { + "navigationBarTitleText": "订单详情" + } + }, + { + "path": "pages/order/my-orders", + "style": { + "navigationBarTitleText": "我的预约", + "enablePullDownRefresh": true + } + } + ] + }, + { + "root": "user-package", + "name": "user", + "pages": [ + { + "path": "pages/user/profile", + "style": { + "navigationBarTitleText": "个人资料" + } + }, + { + "path": "pages/user/student", + "style": { + "navigationBarTitleText": "学生管理" + } + }, + { + "path": "pages/user/coupon", + "style": { + "navigationBarTitleText": "我的优惠券" + } + }, + { + "path": "pages/user/learning-record", + "style": { + "navigationBarTitleText": "学习记录" + } + }, + { + "path": "pages/user/timecard", + "style": { + "navigationBarTitleText": "我的时卡" + } + }, + { + "path": "pages/user/wallet", + "style": { + "navigationBarTitleText": "我的钱包" + } + }, + { + "path": "pages/user/points", + "style": { + "navigationBarTitleText": "我的积分" + } + }, + { + "path": "pages/user/package", + "style": { + "navigationBarTitleText": "我的套餐" + } + }, + { + "path": "pages/timecard/detail", + "style": { + "navigationBarTitleText": "时卡详情" + } + }, + { + "path": "pages/timecard/usage", + "style": { + "navigationBarTitleText": "使用记录" + } + }, + { + "path": "pages/timecard/purchase", + "style": { + "navigationBarTitleText": "购买时卡" + } + }, + { + "path": "pages/wallet/recharge", + "style": { + "navigationBarTitleText": "充值" + } + }, + { + "path": "pages/wallet/withdraw", + "style": { + "navigationBarTitleText": "余额提现" + } + }, + { + "path": "pages/wallet/transaction", + "style": { + "navigationBarTitleText": "交易记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/points/exchange", + "style": { + "navigationBarTitleText": "积分兑换" + } + }, + { + "path": "pages/points/record", + "style": { + "navigationBarTitleText": "积分记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/coupon/center", + "style": { + "navigationBarTitleText": "领券中心", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/package/list", + "style": { + "navigationBarTitleText": "套餐列表" + } + }, + { + "path": "pages/package/detail", + "style": { + "navigationBarTitleText": "套餐详情" + } + }, + { + "path": "pages/feedback/list", + "style": { + "navigationBarTitleText": "服务反馈", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/course/my-courses", + "style": { + "navigationBarTitleText": "我的课程", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/course/player", + "style": { + "navigationBarTitleText": "课程学习" + } + }, + { + "path": "pages/growth/list", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/growth/detail", + "style": { + "navigationBarTitleText": "记录详情" + } + }, + { + "path": "pages/review/list", + "style": { + "navigationBarTitleText": "我的评价", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/review/submit", + "style": { + "navigationBarTitleText": "提交评价" + } + }, + { + "path": "pages/message/center", + "style": { + "navigationBarTitleText": "消息中心", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/teacher/detail", + "style": { + "navigationBarTitleText": "陪伴员详情", + "enablePullDownRefresh": false + } + } + ] + }, + { + "root": "src/teacher-package", + "name": "teacher", + "pages": [ + { + "path": "pages/teacher/index", + "style": { + "navigationBarTitleText": "教师中心" + } + }, + { + "path": "pages/teacher/orders", + "style": { + "navigationBarTitleText": "订单管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/schedule", + "style": { + "navigationBarTitleText": "时间管理" + } + }, + { + "path": "pages/teacher/earnings", + "style": { + "navigationBarTitleText": "收益管理" + } + }, + { + "path": "pages/teacher/verify", + "style": { + "navigationBarTitleText": "扫码核销" + } + }, + { + "path": "pages/teacher/checkin", + "style": { + "navigationBarTitleText": "签到签退" + } + }, + { + "path": "pages/teacher/simple-checkin", + "style": { + "navigationBarTitleText": "陪伴员打卡" + } + }, + { + "path": "pages/teacher/apply", + "style": { + "navigationBarTitleText": "陪伴员注册" + } + }, + { + "path": "pages/teacher/training", + "style": { + "navigationBarTitleText": "线上培训" + } + }, + { + "path": "pages/teacher/exam-test", + "style": { + "navigationBarTitleText": "考核测试" + } + }, + { + "path": "pages/auth/teacher-quick-register", + "style": { + "navigationBarTitleText": "陪伴员注册申请" + } + }, + { + "path": "pages/teacher/watermark-checkin", + "style": { + "navigationBarTitleText": "水印打卡" + } + }, + { + "path": "pages/teacher/checkout", + "style": { + "navigationBarTitleText": "签退打卡", + "navigationBarBackgroundColor": "#fa8c16", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/video/upload", + "style": { + "navigationBarTitleText": "上传教学视频" + } + }, + { + "path": "pages/level/index", + "style": { + "navigationBarTitleText": "我的等级" + } + } + ] + }, + { + "root": "manager-package", + "name": "manager", + "pages": [ + { + "path": "pages/manager/index", + "style": { + "navigationBarTitleText": "管理师中心" + } + }, + { + "path": "pages/manager/apply", + "style": { + "navigationBarTitleText": "管理师注册" + } + }, + { + "path": "pages/manager/work-orders", + "style": { + "navigationBarTitleText": "工单管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/work-order-detail", + "style": { + "navigationBarTitleText": "工单详情" + } + }, + { + "path": "pages/manager/assign", + "style": { + "navigationBarTitleText": "派单" + } + }, + { + "path": "pages/manager/quick-assign", + "style": { + "navigationBarTitleText": "快速派单", + "navigationStyle": "custom" + } + }, + { + "path": "pages/manager/dispatch-list", + "style": { + "navigationBarTitleText": "派单管理", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/application-list", + "style": { + "navigationBarTitleText": "申请管理", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/application-detail", + "style": { + "navigationBarTitleText": "申请详情", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/teachers", + "style": { + "navigationBarTitleText": "陪伴员管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/teacher-detail", + "style": { + "navigationBarTitleText": "陪伴员详情", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/check-records", + "style": { + "navigationBarTitleText": "签到记录", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/teacher-reviews", + "style": { + "navigationBarTitleText": "评价管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/calendar", + "style": { + "navigationBarTitleText": "排课日历", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/hours", + "style": { + "navigationBarTitleText": "课时管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/course-hours", + "style": { + "navigationBarTitleText": "课时管理(旧版)", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/parents", + "style": { + "navigationBarTitleText": "家长管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/parent-detail", + "style": { + "navigationBarTitleText": "家长详情", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/parent-orders", + "style": { + "navigationBarTitleText": "家长订单", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/reports", + "style": { + "navigationBarTitleText": "汇总报告", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/statistics", + "style": { + "navigationBarTitleText": "数据统计", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/feedback", + "style": { + "navigationBarTitleText": "反馈管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/feedback-detail", + "style": { + "navigationBarTitleText": "反馈详情", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/reminders", + "style": { + "navigationBarTitleText": "提醒管理", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/reminder-edit", + "style": { + "navigationBarTitleText": "提醒编辑", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/operation-logs", + "style": { + "navigationBarTitleText": "操作日志", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/operation-log-detail", + "style": { + "navigationBarTitleText": "日志详情", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/message-center", + "style": { + "navigationBarTitleText": "消息中心", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/settings", + "style": { + "navigationBarTitleText": "系统设置", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/profile", + "style": { + "navigationBarTitleText": "个人资料", + "navigationBarBackgroundColor": "#667eea", + "navigationBarTextStyle": "white" + } + } + ] + }, + { + "root": "src/distributor-package", + "name": "distributor", + "pages": [ + { + "path": "pages/distributor/index", + "style": { + "navigationBarTitleText": "分销员中心" + } + }, + { + "path": "pages/distributor/promotion-code", + "style": { + "navigationBarTitleText": "推广码管理" + } + }, + { + "path": "pages/distributor/course-list", + "style": { + "navigationBarTitleText": "可分销课程" + } + }, + { + "path": "pages/distributor/order-list", + "style": { + "navigationBarTitleText": "成交记录" + } + }, + { + "path": "pages/distributor/commission", + "style": { + "navigationBarTitleText": "佣金管理" + } + }, + { + "path": "pages/distributor/team", + "style": { + "navigationBarTitleText": "我的团队" + } + }, + { + "path": "pages/distributor/apply", + "style": { + "navigationBarTitleText": "分销员注册" + } + }, + { + "path": "pages/distributor/withdraw", + "style": { + "navigationBarTitleText": "佣金提现" + } + } + ] + }, + { + "root": "src/provider-package", + "name": "provider", + "pages": [ + { + "path": "pages/provider/index", + "style": { + "navigationBarTitleText": "服务商中心" + } + }, + { + "path": "pages/provider/course-manage", + "style": { + "navigationBarTitleText": "课程管理" + } + }, + { + "path": "pages/provider/checkin", + "style": { + "navigationBarTitleText": "签到核销" + } + }, + { + "path": "pages/provider/earnings", + "style": { + "navigationBarTitleText": "收益查看" + } + }, + { + "path": "pages/provider/course-list", + "style": { + "navigationBarTitleText": "课程列表" + } + }, + { + "path": "pages/provider/course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/provider/course-start", + "style": { + "navigationBarTitleText": "开始上课" + } + }, + { + "path": "pages/provider/schedule", + "style": { + "navigationBarTitleText": "课程安排" + } + }, + { + "path": "pages/provider/withdraw", + "style": { + "navigationBarTitleText": "提取收益" + } + }, + { + "path": "pages/service-provider/apply", + "style": { + "navigationBarTitleText": "专业服务商注册" + } + }, + { + "path": "pages/service-provider/services", + "style": { + "navigationBarTitleText": "服务管理" + } + } + ] + }, + { + "root": "src/training-package", + "name": "training", + "pages": [ + { + "path": "pages/training/course-list", + "style": { + "navigationBarTitleText": "培训课程" + } + }, + { + "path": "pages/training/course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/training/exam", + "style": { + "navigationBarTitleText": "在线考试" + } + }, + { + "path": "pages/training/certificate", + "style": { + "navigationBarTitleText": "我的证书" + } + }, + { + "path": "pages/franchise/index", + "style": { + "navigationBarTitleText": "加盟合作" + } + }, + { + "path": "pages/franchise/apply", + "style": { + "navigationBarTitleText": "加盟申请" + } + } + ] + }, + { + "root": "activity-package", + "name": "activity", + "pages": [ + { + "path": "pages/growth/daily-record", + "style": { + "navigationBarTitleText": "每日反馈" + } + }, + { + "path": "pages/growth/weekly-report", + "style": { + "navigationBarTitleText": "周反馈" + } + }, + { + "path": "pages/growth/monthly-report", + "style": { + "navigationBarTitleText": "月反馈" + } + }, + { + "path": "pages/growth/record-list", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/academy/index", + "style": { + "navigationBarTitleText": "家长学院" + } + }, + { + "path": "pages/academy/course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/supervision/index", + "style": { + "navigationBarTitleText": "线上督学" + } + }, + { + "path": "pages/supervision/session", + "style": { + "navigationBarTitleText": "督学会话" + } + }, + { + "path": "pages/activity/study-tour", + "style": { + "navigationBarTitleText": "研学活动" + } + }, + { + "path": "pages/activity/science", + "style": { + "navigationBarTitleText": "科学小达人" + } + }, + { + "path": "pages/activity/interest-class", + "style": { + "navigationBarTitleText": "兴趣班" + } + }, + { + "path": "pages/activity/detail", + "style": { + "navigationBarTitleText": "活动详情" + } + }, + { + "path": "pages/camp/list", + "style": { + "navigationBarTitleText": "暑假营" + } + }, + { + "path": "pages/study-tour/list", + "style": { + "navigationBarTitleText": "研学活动" + } + }, + { + "path": "pages/group-buy/index", + "style": { + "navigationBarTitleText": "拼团活动" + } + }, + { + "path": "pages/group-buy/detail", + "style": { + "navigationBarTitleText": "拼团详情" + } + } + ] + }, + { + "root": "src/service-package", + "name": "service", + "pages": [ + { + "path": "pages/assessment/index", + "style": { + "navigationBarTitleText": "测评师" + } + }, + { + "path": "pages/planning/index", + "style": { + "navigationBarTitleText": "成长规划师" + } + }, + { + "path": "pages/tutoring/index", + "style": { + "navigationBarTitleText": "一对一辅导" + } + }, + { + "path": "pages/special/list", + "style": { + "navigationBarTitleText": "专项突破" + } + }, + { + "path": "pages/interest/list", + "style": { + "navigationBarTitleText": "兴趣培养" + } + }, + { + "path": "pages/online/index", + "style": { + "navigationBarTitleText": "线上督学" + } + }, + { + "path": "pages/resource/library", + "style": { + "navigationBarTitleText": "资源库" + } + }, + { + "path": "pages/resource/detail", + "style": { + "navigationBarTitleText": "资源详情" + } + }, + { + "path": "pages/booking/parent-booking", + "style": { + "navigationBarTitleText": "家长预约" + } + }, + { + "path": "pages/booking/teacher-apply", + "style": { + "navigationBarTitleText": "教师申请" + } + } + ] + }, + { + "root": "src/common-package", + "name": "common", + "pages": [ + { + "path": "pages/notification/list", + "style": { + "navigationBarTitleText": "消息通知" + } + }, + { + "path": "pages/feedback/create", + "style": { + "navigationBarTitleText": "意见反馈" + } + }, + { + "path": "pages/feedback/list", + "style": { + "navigationBarTitleText": "我的反馈" + } + }, + { + "path": "pages/auth/application-status", + "style": { + "navigationBarTitleText": "审核状态" + } + } + ] + } + ], + "preloadRule": { + "pages/index/index": { + "network": "all", + "packages": [ + "user", + "order" + ] + }, + "pages/user/index": { + "network": "all", + "packages": [ + "user" + ] + } + }, + "tabBar": { + "color": "rgba(255, 255, 255, 0.7)", + "selectedColor": "#ffffff", + "backgroundColor": "#2d9687", + "borderStyle": "white", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页" + }, + { + "pagePath": "pages/service/list", + "text": "服务" + }, + { + "pagePath": "pages/booking/quick-booking", + "text": "快速预约" + }, + { + "pagePath": "pages/order/list", + "text": "日历" + }, + { + "pagePath": "pages/user/index", + "text": "我的" + } + ] + }, + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "习正陪伴", + "navigationBarBackgroundColor": "#ffffff", + "backgroundColor": "#f0f9f7" + }, + "uniIdRouter": {} +} \ No newline at end of file diff --git a/peidu/uniapp/src/manager-package/pages/manager/quick-assign.vue b/peidu/uniapp/src/manager-package/pages/manager/quick-assign.vue new file mode 100644 index 0000000..36e94d2 --- /dev/null +++ b/peidu/uniapp/src/manager-package/pages/manager/quick-assign.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/peidu/uniapp/src/pages.json b/peidu/uniapp/src/pages.json new file mode 100644 index 0000000..6ceb33b --- /dev/null +++ b/peidu/uniapp/src/pages.json @@ -0,0 +1,1466 @@ +{ + "easycom": { + "autoscan": true, + "custom": { + "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue" + } + }, + "pages": [ + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "首页", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/service/list", + "style": { + "navigationBarTitleText": "服务列表", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/search/index", + "style": { + "navigationBarTitleText": "搜索", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/search/result", + "style": { + "navigationBarTitleText": "搜索结果", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/booking/quick-booking", + "style": { + "navigationBarTitleText": "快速预约" + } + }, + { + "path": "pages/booking/teacher-booking", + "style": { + "navigationBarTitleText": "预约陪伴员" + } + }, + { + "path": "pages/order/list", + "style": { + "navigationBarTitleText": "服务日历", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/user/index", + "style": { + "navigationBarTitleText": "个人中心" + } + }, + { + "path": "pages/service/detail", + "style": { + "navigationBarTitleText": "服务详情" + } + }, + { + "path": "pages/teacher/detail", + "style": { + "navigationBarTitleText": "教师详情" + } + }, + { + "path": "pages/teacher/list", + "style": { + "navigationBarTitleText": "选择陪伴员" + } + }, + { + "path": "pages/login/index", + "style": { + "navigationBarTitleText": "登录" + } + }, + { + "path": "pages/register/role-select", + "style": { + "navigationBarTitleText": "选择身份" + } + }, + { + "path": "pages/register/index", + "style": { + "navigationBarTitleText": "注册" + } + }, + { + "path": "pages/auth/role-select", + "style": { + "navigationBarTitleText": "选择身份" + } + }, + { + "path": "pages/auth/parent-register", + "style": { + "navigationBarTitleText": "家长注册" + } + }, + { + "path": "pages/auth/parent-quick-register", + "style": { + "navigationBarTitleText": "家长快速注册" + } + }, + { + "path": "pages/auth/bind-phone", + "style": { + "navigationBarTitleText": "绑定手机号" + } + } + ], + "subPackages": [ + { + "root": "order-package", + "name": "order", + "pages": [ + { + "path": "pages/order/create", + "style": { + "navigationBarTitleText": "确认订单" + } + }, + { + "path": "pages/order/detail", + "style": { + "navigationBarTitleText": "订单详情" + } + }, + { + "path": "pages/order/my-orders", + "style": { + "navigationBarTitleText": "我的预约", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/payment/index", + "style": { + "navigationBarTitleText": "订单支付" + } + } + ] + }, + { + "root": "user-package", + "name": "user", + "pages": [ + { + "path": "pages/user/profile", + "style": { + "navigationBarTitleText": "个人资料" + } + }, + { + "path": "pages/user/setting", + "style": { + "navigationBarTitleText": "设置" + } + }, + { + "path": "pages/user/verification", + "style": { + "navigationBarTitleText": "实名认证" + } + }, + { + "path": "pages/user/student", + "style": { + "navigationBarTitleText": "学生管理" + } + }, + { + "path": "pages/student/add", + "style": { + "navigationBarTitleText": "添加学生" + } + }, + { + "path": "pages/student/edit", + "style": { + "navigationBarTitleText": "编辑学生" + } + }, + { + "path": "pages/student/detail", + "style": { + "navigationBarTitleText": "学生详情" + } + }, + { + "path": "pages/user/coupon", + "style": { + "navigationBarTitleText": "我的优惠券" + } + }, + { + "path": "pages/user/learning-record", + "style": { + "navigationBarTitleText": "学习记录" + } + }, + { + "path": "pages/user/timecard", + "style": { + "navigationBarTitleText": "我的时卡" + } + }, + { + "path": "pages/user/wallet", + "style": { + "navigationBarTitleText": "我的钱包" + } + }, + { + "path": "pages/user/points", + "style": { + "navigationBarTitleText": "我的积分" + } + }, + { + "path": "pages/user/package", + "style": { + "navigationBarTitleText": "我的套餐" + } + }, + { + "path": "pages/timecard/detail", + "style": { + "navigationBarTitleText": "时卡详情" + } + }, + { + "path": "pages/timecard/usage", + "style": { + "navigationBarTitleText": "使用记录" + } + }, + { + "path": "pages/timecard/purchase", + "style": { + "navigationBarTitleText": "购买时卡" + } + }, + { + "path": "pages/wallet/recharge", + "style": { + "navigationBarTitleText": "充值" + } + }, + { + "path": "pages/wallet/withdraw", + "style": { + "navigationBarTitleText": "余额提现" + } + }, + { + "path": "pages/wallet/transaction", + "style": { + "navigationBarTitleText": "交易记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/points/exchange", + "style": { + "navigationBarTitleText": "积分兑换" + } + }, + { + "path": "pages/points/record", + "style": { + "navigationBarTitleText": "积分记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/coupon/center", + "style": { + "navigationBarTitleText": "领券中心", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/coupon/select", + "style": { + "navigationBarTitleText": "选择优惠券" + } + }, + { + "path": "pages/package/list", + "style": { + "navigationBarTitleText": "套餐列表" + } + }, + { + "path": "pages/package/detail", + "style": { + "navigationBarTitleText": "套餐详情" + } + }, + { + "path": "pages/course/my-courses", + "style": { + "navigationBarTitleText": "我的课程" + } + }, + { + "path": "pages/course/course-selector", + "style": { + "navigationBarTitleText": "选择课程", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white", + "backgroundColor": "#f5f7fa" + } + }, + { + "path": "pages/course/player", + "style": { + "navigationBarTitleText": "课程学习" + } + }, + { + "path": "pages/growth/list", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/growth/detail", + "style": { + "navigationBarTitleText": "记录详情" + } + }, + { + "path": "pages/address/list", + "style": { + "navigationBarTitleText": "地址管理" + } + }, + { + "path": "pages/address/edit", + "style": { + "navigationBarTitleText": "编辑地址" + } + }, + { + "path": "pages/user/change-password", + "style": { + "navigationBarTitleText": "修改密码" + } + }, + { + "path": "pages/feedback/list", + "style": { + "navigationBarTitleText": "服务反馈", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/review/submit", + "style": { + "navigationBarTitleText": "评价服务" + } + }, + { + "path": "pages/review/list", + "style": { + "navigationBarTitleText": "我的评价", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/checkin/records", + "style": { + "navigationBarTitleText": "服务记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/checkin/checkin-detail", + "style": { + "navigationBarTitleText": "签到记录详情", + "enablePullDownRefresh": false + } + } + ] + }, + { + "root": "teacher-package", + "name": "teacher", + "pages": [ + { + "path": "pages/teacher/index", + "style": { + "navigationBarTitleText": "教师中心" + } + }, + { + "path": "pages/teacher/orders", + "style": { + "navigationBarTitleText": "订单管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/pending-orders", + "style": { + "navigationBarTitleText": "待接单", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/debug-orders", + "style": { + "navigationBarTitleText": "订单调试" + } + }, + { + "path": "pages/order/detail", + "style": { + "navigationBarTitleText": "订单详情" + } + }, + { + "path": "pages/order/available-list", + "style": { + "navigationBarTitleText": "可接订单", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/schedule", + "style": { + "navigationBarTitleText": "时间管理" + } + }, + { + "path": "pages/teacher/earnings", + "style": { + "navigationBarTitleText": "收益管理" + } + }, + { + "path": "pages/teacher/verify", + "style": { + "navigationBarTitleText": "扫码核销" + } + }, + { + "path": "pages/teacher/checkin", + "style": { + "navigationBarTitleText": "签到签退" + } + }, + { + "path": "pages/teacher/apply", + "style": { + "navigationBarTitleText": "陪伴员注册" + } + }, + { + "path": "pages/teacher/training", + "style": { + "navigationBarTitleText": "线上培训" + } + }, + { + "path": "pages/teacher/exam-test", + "style": { + "navigationBarTitleText": "考核测试" + } + }, + { + "path": "pages/auth/teacher-quick-register", + "style": { + "navigationBarTitleText": "陪伴员注册申请" + } + }, + { + "path": "pages/level/index", + "style": { + "navigationBarTitleText": "我的等级" + } + }, + { + "path": "pages/exam/test", + "style": { + "navigationBarTitleText": "在线考核", + "disableScroll": true + } + }, + { + "path": "pages/exam/result", + "style": { + "navigationBarTitleText": "考核结果" + } + }, + { + "path": "pages/teacher/reviews", + "style": { + "navigationBarTitleText": "学生评价", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/review-statistics", + "style": { + "navigationBarTitleText": "评价统计" + } + }, + { + "path": "pages/teacher/review-detail", + "style": { + "navigationBarTitleText": "评价详情" + } + }, + { + "path": "pages/teacher/withdraw", + "style": { + "navigationBarTitleText": "提现" + } + }, + { + "path": "pages/teacher/withdraw-records", + "style": { + "navigationBarTitleText": "提现记录" + } + }, + { + "path": "pages/teacher/profile", + "style": { + "navigationBarTitleText": "个人资料" + } + }, + { + "path": "pages/teacher/settings", + "style": { + "navigationBarTitleText": "系统设置" + } + }, + { + "path": "pages/teacher/growth-record", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/teacher/feedback-edit", + "style": { + "navigationBarTitleText": "编辑反馈" + } + }, + { + "path": "pages/growth-record/list", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/growth-record/daily-create", + "style": { + "navigationBarTitleText": "创建每日反馈" + } + }, + { + "path": "pages/growth-record/daily-detail", + "style": { + "navigationBarTitleText": "反馈详情" + } + }, + { + "path": "pages/growth-record/weekly", + "style": { + "navigationBarTitleText": "生成周反馈" + } + }, + { + "path": "pages/growth-record/monthly", + "style": { + "navigationBarTitleText": "生成月反馈" + } + }, + { + "path": "pages/growth-record/summary", + "style": { + "navigationBarTitleText": "反馈汇总" + } + }, + { + "path": "pages/reminder/index", + "style": { + "navigationBarTitleText": "我的提醒", + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark" + } + }, + { + "path": "pages/calendar/index", + "style": { + "navigationBarTitleText": "服务日历", + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark" + } + }, + { + "path": "pages/calendar/daily-list", + "style": { + "navigationBarTitleText": "每日课程", + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark" + } + }, + { + "path": "pages/teacher/checkout", + "style": { + "navigationBarTitleText": "签退打卡", + "navigationBarBackgroundColor": "#fa8c16", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/video/upload", + "style": { + "navigationBarTitleText": "上传教学视频" + } + } + ] + }, + { + "root": "manager-package", + "name": "manager", + "pages": [ + { + "path": "pages/manager/index", + "style": { + "navigationBarTitleText": "管理师中心" + } + }, + { + "path": "pages/manager/apply", + "style": { + "navigationBarTitleText": "管理师注册" + } + }, + { + "path": "pages/manager/work-orders", + "style": { + "navigationBarTitleText": "工单管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/work-order-detail", + "style": { + "navigationBarTitleText": "工单详情" + } + }, + { + "path": "pages/manager/assign", + "style": { + "navigationBarTitleText": "派单" + } + }, + { + "path": "pages/manager/quick-assign", + "style": { + "navigationBarTitleText": "快速派单", + "navigationStyle": "custom" + } + }, + { + "path": "pages/manager/statistics", + "style": { + "navigationBarTitleText": "数据统计" + } + }, + { + "path": "pages/manager/teachers", + "style": { + "navigationBarTitleText": "陪伴员管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/teacher-detail", + "style": { + "navigationBarTitleText": "陪伴员详情" + } + }, + { + "path": "pages/manager/teacher-reviews", + "style": { + "navigationBarTitleText": "陪伴员评价" + } + }, + { + "path": "pages/manager/check-records", + "style": { + "navigationBarTitleText": "签到记录" + } + }, + { + "path": "pages/manager/parents", + "style": { + "navigationBarTitleText": "家长管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/parent-detail", + "style": { + "navigationBarTitleText": "家长详情" + } + }, + { + "path": "pages/manager/parent-orders", + "style": { + "navigationBarTitleText": "家长订单", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/course-hours", + "style": { + "navigationBarTitleText": "课时管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/feedback", + "style": { + "navigationBarTitleText": "反馈管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/feedback-detail", + "style": { + "navigationBarTitleText": "反馈详情" + } + }, + { + "path": "pages/manager/reports", + "style": { + "navigationBarTitleText": "汇总报告" + } + }, + { + "path": "pages/manager/reminders", + "style": { + "navigationBarTitleText": "提醒管理", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/reminder-edit", + "style": { + "navigationBarTitleText": "编辑提醒" + } + }, + { + "path": "pages/manager/calendar", + "style": { + "navigationBarTitleText": "排课日历" + } + }, + { + "path": "pages/manager/profile", + "style": { + "navigationBarTitleText": "我的" + } + }, + { + "path": "pages/manager/settings", + "style": { + "navigationBarTitleText": "系统设置" + } + }, + { + "path": "pages/manager/application-list", + "style": { + "navigationBarTitleText": "申请管理", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/manager/application-detail", + "style": { + "navigationBarTitleText": "申请详情", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/manager/dispatch-list", + "style": { + "navigationBarTitleText": "派单管理", + "navigationBarBackgroundColor": "#2d9687", + "navigationBarTextStyle": "white", + "enablePullDownRefresh": true + } + } + ] + }, + { + "root": "distributor-package", + "name": "distributor", + "pages": [ + { + "path": "pages/distributor/index", + "style": { + "navigationBarTitleText": "分销员中心" + } + }, + { + "path": "pages/distributor/promotion-code", + "style": { + "navigationBarTitleText": "推广码管理" + } + }, + { + "path": "pages/distributor/poster", + "style": { + "navigationBarTitleText": "推广海报" + } + }, + { + "path": "pages/distributor/course-list", + "style": { + "navigationBarTitleText": "可分销课程" + } + }, + { + "path": "pages/distributor/order-list", + "style": { + "navigationBarTitleText": "成交记录" + } + }, + { + "path": "pages/distributor/commission", + "style": { + "navigationBarTitleText": "佣金管理" + } + }, + { + "path": "pages/distributor/team", + "style": { + "navigationBarTitleText": "我的团队" + } + }, + { + "path": "pages/distributor/apply", + "style": { + "navigationBarTitleText": "分销员注册" + } + }, + { + "path": "pages/distributor/withdraw", + "style": { + "navigationBarTitleText": "佣金提现" + } + } + ] + }, + { + "root": "provider-package", + "name": "provider", + "pages": [ + { + "path": "pages/provider/index", + "style": { + "navigationBarTitleText": "服务商中心" + } + }, + { + "path": "pages/provider/profile", + "style": { + "navigationBarTitleText": "机构资料" + } + }, + { + "path": "pages/provider/course-manage", + "style": { + "navigationBarTitleText": "课程管理" + } + }, + { + "path": "pages/provider/student-manage", + "style": { + "navigationBarTitleText": "学生管理" + } + }, + { + "path": "pages/provider/checkin", + "style": { + "navigationBarTitleText": "签到核销" + } + }, + { + "path": "pages/provider/checkin-history", + "style": { + "navigationBarTitleText": "签到历史", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/provider/earnings", + "style": { + "navigationBarTitleText": "收益查看" + } + }, + { + "path": "pages/provider/category-courses", + "style": { + "navigationBarTitleText": "课程列表", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/provider/course-publish", + "style": { + "navigationBarTitleText": "发布课程" + } + }, + { + "path": "pages/provider/course-list", + "style": { + "navigationBarTitleText": "课程列表" + } + }, + { + "path": "pages/provider/course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/provider/course-start", + "style": { + "navigationBarTitleText": "开始上课" + } + }, + { + "path": "pages/provider/course-edit", + "style": { + "navigationBarTitleText": "编辑课程" + } + }, + { + "path": "pages/provider/schedule", + "style": { + "navigationBarTitleText": "课程安排" + } + }, + { + "path": "pages/provider/order-list", + "style": { + "navigationBarTitleText": "订单管理" + } + }, + { + "path": "pages/provider/order-detail", + "style": { + "navigationBarTitleText": "订单详情" + } + }, + { + "path": "pages/provider/student-detail", + "style": { + "navigationBarTitleText": "学生详情" + } + }, + { + "path": "pages/provider/setting", + "style": { + "navigationBarTitleText": "设置" + } + }, + { + "path": "pages/provider/withdraw", + "style": { + "navigationBarTitleText": "提取收益" + } + }, + { + "path": "pages/provider/special-course-list", + "style": { + "navigationBarTitleText": "专项课程" + } + }, + { + "path": "pages/provider/special-course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/provider/special-course-publish", + "style": { + "navigationBarTitleText": "发布专项课程" + } + }, + { + "path": "pages/service-provider/apply", + "style": { + "navigationBarTitleText": "专业服务商注册" + } + }, + { + "path": "pages/service-provider/services", + "style": { + "navigationBarTitleText": "服务管理" + } + } + ] + }, + { + "root": "training-package", + "name": "training", + "pages": [ + { + "path": "pages/training/course-list", + "style": { + "navigationBarTitleText": "培训课程" + } + }, + { + "path": "pages/training/course-detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/training/exam", + "style": { + "navigationBarTitleText": "在线考试" + } + }, + { + "path": "pages/training/certificate", + "style": { + "navigationBarTitleText": "我的证书" + } + }, + { + "path": "pages/franchise/index", + "style": { + "navigationBarTitleText": "加盟合作" + } + }, + { + "path": "pages/franchise/apply", + "style": { + "navigationBarTitleText": "加盟申请" + } + }, + { + "path": "pages/franchise/policy", + "style": { + "navigationBarTitleText": "加盟政策" + } + }, + { + "path": "pages/franchise/progress", + "style": { + "navigationBarTitleText": "加盟进度" + } + }, + { + "path": "pages/franchise/select-tenant", + "style": { + "navigationBarTitleText": "选择租户" + } + }, + { + "path": "pages/franchise/my-tenant", + "style": { + "navigationBarTitleText": "我的租户" + } + } + ] + }, + { + "root": "activity-package", + "name": "activity", + "pages": [ + { + "path": "pages/growth/daily-record", + "style": { + "navigationBarTitleText": "每日反馈" + } + }, + { + "path": "pages/growth/weekly-report", + "style": { + "navigationBarTitleText": "周反馈" + } + }, + { + "path": "pages/growth/monthly-report", + "style": { + "navigationBarTitleText": "月反馈" + } + }, + { + "path": "pages/growth/record-list", + "style": { + "navigationBarTitleText": "成长记录", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/academy/index", + "style": { + "navigationBarTitleText": "家长学院" + } + }, + { + "path": "pages/academy/detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/supervision/index", + "style": { + "navigationBarTitleText": "线上督学" + } + }, + { + "path": "pages/supervision/category", + "style": { + "navigationBarTitleText": "线上督学分类" + } + }, + { + "path": "pages/supervision/list", + "style": { + "navigationBarTitleText": "督学列表" + } + }, + { + "path": "pages/supervision/detail", + "style": { + "navigationBarTitleText": "督学详情" + } + }, + { + "path": "pages/supervision/session", + "style": { + "navigationBarTitleText": "督学会话" + } + }, + { + "path": "pages/study-tour/category", + "style": { + "navigationBarTitleText": "研学活动分类" + } + }, + { + "path": "pages/study-tour/list", + "style": { + "navigationBarTitleText": "研学活动列表" + } + }, + { + "path": "pages/study-tour/detail", + "style": { + "navigationBarTitleText": "研学活动详情" + } + }, + { + "path": "pages/interest/category", + "style": { + "navigationBarTitleText": "兴趣培养分类" + } + }, + { + "path": "pages/interest/list", + "style": { + "navigationBarTitleText": "兴趣课程列表" + } + }, + { + "path": "pages/interest/detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/activity/study-tour", + "style": { + "navigationBarTitleText": "研学活动" + } + }, + { + "path": "pages/activity/science", + "style": { + "navigationBarTitleText": "科学小达人" + } + }, + { + "path": "pages/activity/interest-class", + "style": { + "navigationBarTitleText": "兴趣班" + } + }, + { + "path": "pages/activity/detail", + "style": { + "navigationBarTitleText": "活动详情" + } + }, + { + "path": "pages/camp/list", + "style": { + "navigationBarTitleText": "暑假营" + } + }, + { + "path": "pages/camp/detail", + "style": { + "navigationBarTitleText": "暑假营详情" + } + }, + { + "path": "pages/group-buy/index", + "style": { + "navigationBarTitleText": "拼团活动" + } + }, + { + "path": "pages/group-buy/list", + "style": { + "navigationBarTitleText": "拼团列表" + } + }, + { + "path": "pages/group-buy/activity-detail", + "style": { + "navigationBarTitleText": "拼团活动详情" + } + }, + { + "path": "pages/group-buy/team-detail", + "style": { + "navigationBarTitleText": "拼团详情" + } + }, + { + "path": "pages/group-buy/detail", + "style": { + "navigationBarTitleText": "拼团详情" + } + } + ] + }, + { + "root": "service-package", + "name": "service", + "pages": [ + { + "path": "pages/assessment/index", + "style": { + "navigationBarTitleText": "测评师" + } + }, + { + "path": "pages/assessment/list", + "style": { + "navigationBarTitleText": "测评服务", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/assessment/detail", + "style": { + "navigationBarTitleText": "测评详情" + } + }, + { + "path": "pages/planning/index", + "style": { + "navigationBarTitleText": "成长规划师" + } + }, + { + "path": "pages/planning/category-list", + "style": { + "navigationBarTitleText": "规划师列表" + } + }, + { + "path": "pages/planning/list", + "style": { + "navigationBarTitleText": "成长规划服务", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/planning/detail", + "style": { + "navigationBarTitleText": "规划详情" + } + }, + { + "path": "pages/tutoring/index", + "style": { + "navigationBarTitleText": "一对一辅导" + } + }, + { + "path": "pages/special/index", + "style": { + "navigationBarTitleText": "专项突破" + } + }, + { + "path": "pages/special/category-list", + "style": { + "navigationBarTitleText": "课程列表" + } + }, + { + "path": "pages/special/list", + "style": { + "navigationBarTitleText": "专项突破" + } + }, + { + "path": "pages/special/detail", + "style": { + "navigationBarTitleText": "课程详情" + } + }, + { + "path": "pages/interest/list", + "style": { + "navigationBarTitleText": "兴趣培养" + } + }, + { + "path": "pages/online/index", + "style": { + "navigationBarTitleText": "线上督学" + } + }, + { + "path": "pages/resource/library", + "style": { + "navigationBarTitleText": "资源库" + } + }, + { + "path": "pages/resource/detail", + "style": { + "navigationBarTitleText": "资源详情" + } + }, + { + "path": "pages/booking/parent-booking", + "style": { + "navigationBarTitleText": "家长预约" + } + }, + { + "path": "pages/booking/teacher-apply", + "style": { + "navigationBarTitleText": "教师申请" + } + } + ] + }, + { + "root": "common-package", + "name": "common", + "pages": [ + { + "path": "pages/notification/list", + "style": { + "navigationBarTitleText": "消息通知" + } + }, + { + "path": "pages/feedback/create", + "style": { + "navigationBarTitleText": "意见反馈" + } + }, + { + "path": "pages/feedback/list", + "style": { + "navigationBarTitleText": "我的反馈" + } + }, + { + "path": "pages/auth/application-status", + "style": { + "navigationBarTitleText": "审核状态" + } + } + ] + } + ], + "preloadRule": { + "pages/index/index": { + "network": "all", + "packages": ["user", "order"] + }, + "pages/user/index": { + "network": "all", + "packages": ["user"] + } + }, + "tabBar": { + "color": "rgba(255, 255, 255, 0.7)", + "selectedColor": "#ffffff", + "backgroundColor": "#2d9687", + "borderStyle": "white", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页" + }, + { + "pagePath": "pages/service/list", + "text": "服务" + }, + { + "pagePath": "pages/booking/quick-booking", + "text": "快速预约" + }, + { + "pagePath": "pages/order/list", + "text": "日历" + }, + { + "pagePath": "pages/user/index", + "text": "我的" + } + ] + }, + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "习正陪伴", + "navigationBarBackgroundColor": "#ffffff", + "backgroundColor": "#f0f9f7" + }, + "uniIdRouter": {} +} diff --git a/peidu/uniapp/src/pages/booking/components/ManagerBooking.vue b/peidu/uniapp/src/pages/booking/components/ManagerBooking.vue new file mode 100644 index 0000000..cb51346 --- /dev/null +++ b/peidu/uniapp/src/pages/booking/components/ManagerBooking.vue @@ -0,0 +1,513 @@ + + + + + diff --git a/peidu/uniapp/src/pages/booking/quick-booking.vue b/peidu/uniapp/src/pages/booking/quick-booking.vue new file mode 100644 index 0000000..20d29bb --- /dev/null +++ b/peidu/uniapp/src/pages/booking/quick-booking.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/peidu/uniapp/src/pages/index/components/ManagerHome.vue b/peidu/uniapp/src/pages/index/components/ManagerHome.vue new file mode 100644 index 0000000..56d1dcb --- /dev/null +++ b/peidu/uniapp/src/pages/index/components/ManagerHome.vue @@ -0,0 +1,1218 @@ + + + + +