文件
huaqiapp/server/application/admin/library/ManageConfig.php
linda 3baa52e95a feat(consult): 咨询改为在线预约表单 + 新增 SDS/SAS/16PF 付费心理测评
一、心理咨询(M9)
- 前端不再选咨询师时段,改为「分类 + 表单」:11 类(婚恋/青少年/职场人际/情绪疏导/
  人生卡点/成长迷茫/脱单指导/分手挽回/社恐咨询/抑郁焦虑/情绪压力)
- 表单字段:称呼、手机号(11 位校验)、方便联系时间、困扰描述(≥5 字),提交后由咨询助理联系
- 支持查看/取消我的预约;同一用户 10 分钟内防重复提交
- 新增表 fa_consult_booking(含跟进状态与备注),后台可跟进

二、心理测评(付费)
- 新增三个付费量表:抑郁自评 SDS(20 题,1-4 级 + 10 道反向题,标准分=粗分×1.25 取整)、
  焦虑自评 SAS(20 题,5 道反向题)、卡特尔 16PF 简版(48 题 / 16 维度,三选项)
- 华东:测评需付费,未付费拦截并返回 need_pay;新增 fa_assessment_order 订单表与下单接口
- 计分:标准分分级(正常/轻度/中度/重度)+ 16PF 维度剖面(1-10 分、高/中/低解读)
- 风险识别:SDS 自伤条目高分或重度 → risk_flag + 危机热线
- 结果页新增 16PF 16 维条形剖面与「预约咨询师解读」入口

三、管理端
- 新增后台模块:心理预约(分类/状态/备注跟进)、测评订单(支付状态可改)
- ManageConfig 增加对应字段配置;菜单脚本 db/06_consult_assessment.sql(可重复执行)
- fa_assessment 增加 price 字段;测评列表/详情接口返回价格与购买状态

四、验证(全绿)
- 咨询+测评专项:54 项断言(分类、表单校验、防重复、脱敏、取消、题库、付费拦截、
  下单、付费后 SDS=62/轻度、SAS=56/轻度、16PF 16 维满分、危机干预)
- 前台接口 78 项、后台自检 33 项(28 模块)、契约 0 偏差、Vue 20/20、SCSS 19/19、无 emoji
2026-11-06 16:00:52 +08:00

531 行
33 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace app\admin\library;
/**
* 运营后台业务模块注册表
*
* 与前端 M1–M9 功能模块一一对应,统一由 Manage 控制器提供列表/新增/编辑/删除能力。
* 字段定义支持:type(text/textarea/number/decimal/date/datetime/select/bool/json/user)、
* label、options、search、readonly、form(是否出现在表单)。
*/
class ManageConfig
{
/** 常用枚举 */
public static $enums = [
'status' => ['normal' => '正常', 'hidden' => '隐藏'],
'access' => ['free' => '免费', 'member' => '会员', 'pay' => '付费'],
'verify' => ['pending' => '待审核', 'passed' => '已通过', 'rejected' => '已驳回'],
'pay_status' => ['unpaid' => '待支付', 'paid' => '已支付', 'refunded' => '已退款'],
'scope' => ['prepare' => '备孕任务', 'family' => '家庭共育', 'relation' => '双人任务', 'parenting' => '育儿任务'],
'mood' => ['happy' => '开心', 'calm' => '平静', 'anxious' => '焦虑', 'low' => '低落', 'angry' => '烦躁'],
'mode' => ['cycle' => '经期模式', 'prepare' => '备孕模式', 'pregnant' => '孕期模式'],
'source' => ['user' => '用户记录', 'algorithm' => '算法生成'],
'result' => ['negative' => '阴性', 'weak' => '弱阳', 'positive' => '阳性', 'strong' => '强阳', 'unknown' => '未识别'],
'level' => ['basic' => '基础版', 'pro' => '专业版'],
'repeat_rule' => ['daily' => '每天', 'once' => '单次', 'weekly' => '每周'],
'app_lock' => ['none' => '关闭', 'password' => '数字密码', 'biometric' => '生物识别'],
'cert_verify' => ['pending' => '待审核', 'passed' => '已认证', 'expired' => '已过期'],
'consult_status' => ['pending' => '待开始', 'ongoing' => '进行中', 'finished' => '已完成', 'canceled' => '已取消'],
'onoff' => ['on' => '上架', 'off' => '下架'],
'relation' => ['partner' => '伴侣', 'parent' => '父母', 'friend' => '朋友'],
'test_type' => ['lh' => '排卵试纸', 'hcg' => '早孕试纸'],
'type_content' => [
'jijing' => '每日心语', 'mood' => '情绪科普', 'knowledge' => '知识库', 'advice' => '健康建议',
'meditation' => '正念冥想', 'care' => '暖心话术', 'card' => '沟通引导卡', 'conflict' => '冲突工具',
'firstaid' => '情绪急救包', 'guide' => '同房指导', 'course' => '系列课程', 'activity' => '亲子活动',
'emotion' => '育儿情绪',
],
'category_type' => [
'jijing' => '心语', 'mood' => '情绪科普', 'knowledge' => '知识库', 'advice' => '健康建议',
'meditation' => '冥想', 'care' => '话术', 'card' => '引导卡', 'conflict' => '冲突工具',
'firstaid' => '急救包', 'guide' => '同房指导', 'course' => '课程', 'activity' => '亲子活动', 'emotion' => '育儿情绪',
],
'action' => ['care_daily' => '每日关怀', 'prepare_task' => '备孕任务', 'exchange' => '积分兑换'],
'category' => ['check' => '检查', 'folic' => '叶酸', 'nutrition' => '营养', 'partner' => '伴侣', 'daily' => '日常', 'care' => '照护'],
'memory_type' => ['anniversary' => '纪念日', 'milestone' => '里程碑', 'daily' => '日常记录'],
'vaccine_type' => ['vaccine' => '疫苗', 'checkup' => '儿保体检'],
'gender' => ['0' => '未知', '1' => '男', '2' => '女'],
'consult_category' => [
'love' => '婚恋咨询', 'teen' => '青少年心理', 'career' => '职场人际', 'emotion' => '情绪疏导',
'life' => '人生卡点', 'growth' => '成长迷茫', 'single' => '脱单指导', 'breakup' => '分手挽回',
'social' => '社恐咨询', 'depress' => '抑郁焦虑', 'pressure' => '情绪压力',
],
'booking_status' => ['pending' => '待联系', 'contacted' => '已联系', 'finished' => '已完成', 'canceled' => '已取消'],
];
/**
* 所有受管业务表
*/
public static function all()
{
return [
/* ================= M1 周期管理 ================= */
'fa_cycle' => [
'title' => '周期档案',
'group' => '周期管理',
'sort' => 'start_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'start_date' => ['label' => '经期开始日', 'type' => 'date', 'search' => true],
'end_date' => ['label' => '经期结束日', 'type' => 'date'],
'period_length' => ['label' => '经期天数', 'type' => 'number'],
'cycle_length' => ['label' => '周期天数', 'type' => 'number'],
'ovulation_date' => ['label' => '排卵日', 'type' => 'date'],
'mode' => ['label' => '模式', 'type' => 'select', 'options' => 'mode'],
'source' => ['label' => '来源', 'type' => 'select', 'options' => 'source'],
],
],
'fa_cycle_log' => [
'title' => '每日症状记录',
'group' => '周期管理',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'flow' => ['label' => '经血量', 'type' => 'select', 'options' => ['0' => '无', '1' => '少', '2' => '中', '3' => '多']],
'pain_level' => ['label' => '痛经程度', 'type' => 'select', 'options' => ['0' => '无', '1' => '轻微', '2' => '可忍', '3' => '明显', '4' => '较重', '5' => '难忍']],
'symptom_ids' => ['label' => '症状标签ID', 'type' => 'text'],
'mood' => ['label' => '情绪分值', 'type' => 'number'],
'sleep_hours' => ['label' => '睡眠(小时)', 'type' => 'decimal'],
'sex' => ['label' => '性生活', 'type' => 'select', 'options' => ['0' => '无', '1' => '有保护', '2' => '无保护']],
'note' => ['label' => '备注', 'type' => 'textarea'],
],
],
'fa_symptom_tag' => [
'title' => '症状标签',
'group' => '周期管理',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '标签名', 'type' => 'text', 'search' => true],
'icon' => ['label' => '图标', 'type' => 'text'],
'category' => ['label' => '分类', 'type' => 'select', 'options' => ['body' => '身体', 'mood' => '情绪', 'flow' => '经血']],
'is_preset' => ['label' => '预设标签', 'type' => 'bool'],
'user_id' => ['label' => '归属用户', 'type' => 'user'],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_reminder' => [
'title' => '智能提醒',
'group' => '周期管理',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'title' => ['label' => '提醒内容', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => ['period' => '经期', 'ovulation' => '排卵', 'record' => '记录', 'medication' => '用药', 'custom' => '自定义']],
'remind_time' => ['label' => '提醒时间', 'type' => 'text'],
'repeat_rule' => ['label' => '重复', 'type' => 'select', 'options' => 'repeat_rule'],
'remind_date' => ['label' => '提醒日期', 'type' => 'date'],
'enabled' => ['label' => '启用', 'type' => 'bool'],
],
],
/* ================= M2 情绪疗愈 ================= */
'fa_mood_log' => [
'title' => '情绪日记',
'group' => '情绪疗愈',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'mood' => ['label' => '情绪', 'type' => 'select', 'options' => 'mood'],
'intensity' => ['label' => '强度', 'type' => 'number'],
'triggers' => ['label' => '触发事件', 'type' => 'text'],
'content' => ['label' => '内容', 'type' => 'textarea'],
],
],
/* ================= 内容中心 ================= */
'fa_content' => [
'title' => '内容库',
'group' => '内容中心',
'sort' => 'weigh desc, id desc',
'fields' => [
'type' => ['label' => '内容类型', 'type' => 'select', 'options' => 'type_content', 'search' => true],
'category_id' => ['label' => '分类ID', 'type' => 'number'],
'title' => ['label' => '标题', 'type' => 'text', 'search' => true],
'summary' => ['label' => '摘要', 'type' => 'text'],
'body' => ['label' => '正文', 'type' => 'textarea'],
'cover_emoji' => ['label' => '图标字符', 'type' => 'text'],
'media_type' => ['label' => '媒体类型', 'type' => 'select', 'options' => ['text' => '图文', 'audio' => '音频', 'video' => '视频']],
'duration' => ['label' => '时长(秒)', 'type' => 'number'],
'phase' => ['label' => '适用阶段', 'type' => 'text'],
'mood_tag' => ['label' => '适用情绪', 'type' => 'text'],
'extra' => ['label' => '扩展信息', 'type' => 'textarea'],
'access' => ['label' => '访问权限', 'type' => 'select', 'options' => 'access', 'search' => true],
'verify' => ['label' => '审核状态', 'type' => 'select', 'options' => 'verify', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status', 'search' => true],
],
],
'fa_content_category' => [
'title' => '内容分类',
'group' => '内容中心',
'sort' => 'weigh desc, id asc',
'fields' => [
'pid' => ['label' => '父级ID', 'type' => 'number'],
'name' => ['label' => '分类名', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'category_type', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
/* ================= M3 科学备孕 ================= */
'fa_bbt_record' => [
'title' => '基础体温',
'group' => '科学备孕',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'temperature' => ['label' => '体温(℃)', 'type' => 'decimal'],
'measure_time' => ['label' => '测量时间', 'type' => 'text'],
'device' => ['label' => '设备来源', 'type' => 'select', 'options' => ['manual' => '手动', 'bluetooth' => '蓝牙']],
],
],
'fa_lh_test' => [
'title' => '试纸识别记录',
'group' => '科学备孕',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'test_type' => ['label' => '试纸类型', 'type' => 'select', 'options' => 'test_type'],
'log_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'result' => ['label' => '识别结果', 'type' => 'select', 'options' => 'result'],
'confidence' => ['label' => '置信度', 'type' => 'decimal'],
'algo' => ['label' => '算法', 'type' => 'select', 'options' => ['rule' => '规则引擎', 'cnn' => 'CNN 模型']],
'image' => ['label' => '试纸图片', 'type' => 'text'],
],
],
'fa_task' => [
'title' => '任务(备孕/双人/共育)',
'group' => '科学备孕',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'scope' => ['label' => '归属模块', 'type' => 'select', 'options' => 'scope', 'search' => true],
'title' => ['label' => '任务内容', 'type' => 'text', 'search' => true],
'category' => ['label' => '分类', 'type' => 'select', 'options' => 'category'],
'due_date' => ['label' => '截止日期', 'type' => 'date'],
'done' => ['label' => '已完成', 'type' => 'bool'],
'share_partner' => ['label' => '同步伴侣', 'type' => 'bool'],
],
],
/* ================= M4 家人共护 ================= */
'fa_family_bind' => [
'title' => '家人绑定',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '主账号', 'type' => 'user', 'search' => true],
'member_user_id' => ['label' => '家人账号', 'type' => 'user'],
'member_name' => ['label' => '家人称呼', 'type' => 'text', 'search' => true],
'relation' => ['label' => '关系', 'type' => 'select', 'options' => 'relation'],
'scope' => ['label' => '可见范围', 'type' => 'text'],
'invite_code' => ['label' => '邀请码', 'type' => 'text', 'search' => true],
'status' => ['label' => '状态', 'type' => 'select', 'options' => ['pending' => '待接受', 'normal' => '已绑定', 'removed' => '已解绑'], 'search' => true],
],
],
'fa_care_message' => [
'title' => '沟通空间留言',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'bind_id' => ['label' => '绑定ID', 'type' => 'number', 'search' => true],
'user_id' => ['label' => '发送人', 'type' => 'user', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => ['text' => '文字', 'voice' => '语音', 'gift' => '礼物']],
'content' => ['label' => '留言内容', 'type' => 'textarea'],
],
],
'fa_point_log' => [
'title' => '爱心积分流水',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'action' => ['label' => '积分动作', 'type' => 'select', 'options' => 'action', 'search' => true],
'point' => ['label' => '积分', 'type' => 'number'],
'ref_id' => ['label' => '关联ID', 'type' => 'number'],
'remark' => ['label' => '备注', 'type' => 'text'],
],
],
/* ================= M7 两性关系 ================= */
'fa_memory' => [
'title' => '纪念日与回忆',
'group' => '两性关系',
'sort' => 'memory_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'title' => ['label' => '标题', 'type' => 'text', 'search' => true],
'memory_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'memory_type'],
'content' => ['label' => '内容', 'type' => 'textarea'],
'remind' => ['label' => '提醒', 'type' => 'bool'],
],
],
'fa_course_order' => [
'title' => '课程订单',
'group' => '两性关系',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'content_id' => ['label' => '课程ID', 'type' => 'number'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
],
],
/* ================= M8 亲子教育 ================= */
'fa_baby' => [
'title' => '宝宝档案',
'group' => '亲子教育',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'nickname' => ['label' => '小名', 'type' => 'text', 'search' => true],
'gender' => ['label' => '性别', 'type' => 'select', 'options' => ['0' => '未知', '1' => '男', '2' => '女']],
'birthday' => ['label' => '生日', 'type' => 'date'],
'due_date' => ['label' => '预产期', 'type' => 'date'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_growth_record' => [
'title' => '成长记录',
'group' => '亲子教育',
'sort' => 'record_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'baby_id' => ['label' => '宝宝ID', 'type' => 'number'],
'record_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'height' => ['label' => '身高(cm)', 'type' => 'decimal'],
'weight' => ['label' => '体重(kg)', 'type' => 'decimal'],
'milestone' => ['label' => '里程碑', 'type' => 'text'],
'note' => ['label' => '备注', 'type' => 'textarea'],
],
],
'fa_vaccine' => [
'title' => '疫苗与儿保',
'group' => '亲子教育',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '项目名称', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'vaccine_type', 'search' => true],
'month_from' => ['label' => '起始月龄', 'type' => 'number'],
'month_to' => ['label' => '结束月龄', 'type' => 'number'],
'note' => ['label' => '说明', 'type' => 'text'],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
/* ================= M9 心理服务 ================= */
'fa_counselor' => [
'title' => '咨询师',
'group' => '心理服务',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '姓名', 'type' => 'text', 'search' => true],
'avatar_emoji' => ['label' => '头像图标', 'type' => 'text'],
'title' => ['label' => '职称', 'type' => 'text'],
'cert_no' => ['label' => '资质编号', 'type' => 'text', 'search' => true],
'cert_verify' => ['label' => '资质审核', 'type' => 'select', 'options' => 'cert_verify', 'search' => true],
'price_text' => ['label' => '文字咨询价', 'type' => 'decimal'],
'price_voice' => ['label' => '语音咨询价', 'type' => 'decimal'],
'price_video' => ['label' => '视频咨询价', 'type' => 'decimal'],
'rate' => ['label' => '平台分成', 'type' => 'decimal'],
'intro' => ['label' => '简介', 'type' => 'textarea'],
'tags' => ['label' => '擅长标签', 'type' => 'text'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'onoff', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
'fa_consult_order' => [
'title' => '咨询订单',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'counselor_id' => ['label' => '咨询师ID', 'type' => 'number'],
'mode' => ['label' => '方式', 'type' => 'select', 'options' => ['text' => '文字', 'voice' => '语音', 'video' => '视频']],
'start_time' => ['label' => '预约时间', 'type' => 'datetime'],
'duration' => ['label' => '时长(分钟)', 'type' => 'number'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
'consult_status' => ['label' => '咨询状态', 'type' => 'select', 'options' => 'consult_status', 'search' => true],
'rate_amount' => ['label' => '分成金额', 'type' => 'decimal'],
],
],
'fa_assessment' => [
'title' => '量表管理',
'group' => '心理服务',
'sort' => 'weigh desc, id asc',
'fields' => [
'code' => ['label' => '量表编码', 'type' => 'text', 'search' => true],
'title' => ['label' => '量表名称', 'type' => 'text', 'search' => true],
'intro' => ['label' => '引导语', 'type' => 'textarea'],
'questions' => ['label' => '题目(JSON数组)', 'type' => 'textarea'],
'scoring' => ['label' => '分级规则(JSON)', 'type' => 'textarea'],
'level' => ['label' => '版本', 'type' => 'select', 'options' => 'level'],
'scope' => ['label' => '归属', 'type' => 'select', 'options' => ['mood' => '情绪', 'relation' => '关系', 'parenting' => '育儿']],
'access' => ['label' => '访问权限', 'type' => 'select', 'options' => 'access', 'search' => true],
'price' => ['label' => '测评价格', 'type' => 'decimal'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
'fa_consult_booking' => [
'title' => '心理预约',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'name' => ['label' => '称呼', 'type' => 'text', 'search' => true],
'mobile' => ['label' => '联系电话', 'type' => 'text', 'search' => true],
'category' => ['label' => '咨询分类', 'type' => 'select', 'options' => 'consult_category', 'search' => true],
'prefer_time' => ['label' => '方便时间', 'type' => 'text'],
'description' => ['label' => '困扰描述', 'type' => 'textarea'],
'status' => ['label' => '跟进状态', 'type' => 'select', 'options' => 'booking_status', 'search' => true],
'admin_remark' => ['label' => '跟进备注', 'type' => 'textarea'],
],
],
'fa_assessment_order' => [
'title' => '测评订单',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'assessment_id' => ['label' => '量表ID', 'type' => 'number', 'search' => true],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
'pay_time' => ['label' => '支付时间', 'type' => 'datetime'],
],
],
'fa_assessment_record' => [
'title' => '测评记录',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'assessment_id' => ['label' => '量表ID', 'type' => 'number', 'search' => true],
'score' => ['label' => '得分', 'type' => 'decimal'],
'result' => ['label' => '结果分级', 'type' => 'text'],
'risk_flag' => ['label' => '风险标记', 'type' => 'bool'],
'answers' => ['label' => '作答(JSON)', 'type' => 'textarea', 'readonly' => true],
'report' => ['label' => '解读', 'type' => 'textarea', 'readonly' => true],
],
],
/* ================= M6 会员与用户 ================= */
'fa_member_plan' => [
'title' => '会员套餐',
'group' => '会员中心',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '套餐名', 'type' => 'text', 'search' => true],
'code' => ['label' => '编码', 'type' => 'text', 'search' => true],
'subtitle' => ['label' => '副标题', 'type' => 'text'],
'price' => ['label' => '售价', 'type' => 'decimal'],
'origin_price' => ['label' => '原价', 'type' => 'decimal'],
'duration_days' => ['label' => '有效天数', 'type' => 'number'],
'benefits' => ['label' => '权益(JSON)', 'type' => 'textarea'],
'badge' => ['label' => '角标', 'type' => 'text'],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_member_order' => [
'title' => '会员订单',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'plan_code' => ['label' => '套餐编码', 'type' => 'text'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_type' => ['label' => '支付方式', 'type' => 'select', 'options' => ['wechat' => '微信', 'alipay' => '支付宝']],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
'trade_no' => ['label' => '第三方流水', 'type' => 'text'],
'start_time' => ['label' => '生效时间', 'type' => 'datetime'],
'expire_time' => ['label' => '到期时间', 'type' => 'datetime'],
],
],
'fa_user_setting' => [
'title' => '隐私与提醒设置',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'app_lock' => ['label' => '应用锁', 'type' => 'select', 'options' => 'app_lock'],
'local_only' => ['label' => '仅本地存储', 'type' => 'bool'],
'remind_json' => ['label' => '提醒配置(JSON)', 'type' => 'textarea'],
],
],
'fa_user_backup' => [
'title' => '数据备份',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'name' => ['label' => '备份名称', 'type' => 'text'],
'size' => ['label' => '大小(字节)', 'type' => 'number', 'readonly' => true],
'payload' => ['label' => '备份内容', 'type' => 'textarea', 'readonly' => true],
],
],
'fa_user' => [
'title' => '会员用户',
'group' => '会员中心',
'sort' => 'id desc',
'readonly_table' => true,
'fields' => [
'username' => ['label' => '账号', 'type' => 'text', 'search' => true],
'nickname' => ['label' => '昵称', 'type' => 'text', 'search' => true],
'mobile' => ['label' => '手机号', 'type' => 'text', 'search' => true],
'gender' => ['label' => '性别', 'type' => 'select', 'options' => ['0' => '未知', '1' => '男', '2' => '女']],
'birthday' => ['label' => '生日', 'type' => 'date'],
'bio' => ['label' => '签名', 'type' => 'text'],
'score' => ['label' => '积分', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => ['normal' => '正常', 'hidden' => '禁用']],
],
],
];
}
/**
* 取单个表的配置,并补齐通用字段
*/
public static function get($table)
{
$all = self::all();
if (!isset($all[$table])) {
return null;
}
$config = $all[$table];
if (!isset($config['fields']['createtime'])) {
$config['fields']['createtime'] = ['label' => '创建时间', 'type' => 'datetime', 'readonly' => true];
}
if (!isset($config['fields']['updatetime'])) {
$config['fields']['updatetime'] = ['label' => '更新时间', 'type' => 'datetime', 'readonly' => true];
}
if (!isset($config['fields']['deletetime'])) {
$config['fields']['deletetime'] = ['label' => '删除时间', 'type' => 'datetime', 'readonly' => true, 'form' => false];
}
return $config;
}
/** 分组(用于菜单生成与文档) */
public static function groups()
{
$groups = [];
foreach (self::all() as $table => $config) {
$groups[$config['group']][] = ['table' => $table, 'title' => $config['title']];
}
return $groups;
}
}