Files
liandong-crm/prisma/schema.prisma
T
luishouandClaude b43f375c86 feat: 生日归属字段贯通全部界面(查看/列表/提醒/导入/导出/模板)
补全 birthdayOwner(1=结算人 2=联系人)在 schema 写入链路之外的所有流转环节:
- 查看弹窗 customer-view:新增"生日归属"行
- 商户列表 page:生日单元格追加归属 badge
- 生日提醒页 birthday:新增"归属"列(Row 类型 / SQL / 表头 / colSpan 6→7 / 单元格)
- 导入 actions.importCustomers:validData 写入 birthdayOwner(结算人或"1"→1,否则→2)
- 导出 export/route + query.EXCEL_COLUMNS:新增"生日归属"列与对应行值
- 导入模板 template/route:表头与示例行同步插入"生日归属"/"联系人"
- 表单 customer-form:CustomerValues 类型补 birthdayOwner(消除 v.birthdayOwner 的 TS 报错,编辑页正确回填)

前置条件:MySQL customers 表需新增 birthday_owner 列(见 PR 说明),否则写入与生日页 SQL 会报 Unknown column。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-12 16:58:52 +08:00

109 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// CRM 新架构 —— 映射测试库 crm_dev(数据已清洗)
// 关键约定:
// - birthday / reportDate 已是 date 类型;原始脏值保留在 *_raw 备份列
// - 物理表名/列名用 @map/@@map 对齐现有库,不改动库结构
// - 废表 users / sms / customers_copy / admin_customer 不建模(视而不见)
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
/// 客户(系统核心,~1.4 万行)
model Customer {
id Int @id @default(autoincrement())
customerName String? @default("") @map("customer_name")
contacts String? // 联系人
balanceUser String? @map("balance_user") // 结算人
phone String?
detail String?
deposit String? // 押金
buy String? // 买断
birthdayType Int? @default(1) @map("birthday_type") // 1阳历 2阴历
birthdayOwner Int? @default(2) @map("birthday_owner") // 1结算人 2联系人
birthday DateTime? @db.Date // 已清洗为 date(阴历行月日为农历,年份占位)
birthdayRaw String? @map("birthday_raw") // 清洗前原始脏值备份
salesman String? // 业务员
reportDate DateTime? @map("report_date") @db.Date // 报单时间,已清洗为 date
reportDateRaw String? @map("report_date_raw") // 清洗前原始脏值备份
remark String?
createdAt DateTime? @map("created_at")
updatedAt DateTime? @map("updated_at")
deletedAt DateTime? @map("deleted_at") // 软删除
@@index([reportDate])
@@index([birthday])
@@index([customerName])
@@map("customers")
}
/// 后台账号(12 个,密码为 Laravel bcrypt,可被 Auth.js 直接校验)
model Admin {
id Int @id @default(autoincrement())
username String @unique
nickname String
face String?
password String
rememberToken String? @map("remember_token")
createdAt DateTime? @map("created_at")
updatedAt DateTime? @map("updated_at")
deletedAt DateTime? @map("deleted_at")
@@map("admins")
}
/// 角色(超级管理员 / 业务员)
model Role {
id Int @id @default(autoincrement())
name String
title String?
remark String?
guardName String? @map("guard_name")
createdAt DateTime? @map("created_at")
updatedAt DateTime? @map("updated_at")
@@map("roles")
}
/// 权限(同时是后台菜单树:pid/sort/isMenu/icon)
model Permission {
id Int @id @default(autoincrement())
pid Int? @default(0)
name String
param String?
title String?
icon String?
sort Int? @default(0)
isMenu Boolean? @default(false) @map("is_menu")
guardName String? @map("guard_name")
createdAt DateTime? @map("created_at")
updatedAt DateTime? @map("updated_at")
@@map("permissions")
}
/// spatie 多态:账号-角色(本阶段照搬,映射即可)
model ModelHasRole {
roleId Int @map("role_id")
modelId Int @map("model_id")
modelType String @map("model_type")
@@id([roleId, modelId, modelType])
@@index([modelId, modelType])
@@map("model_has_roles")
}
/// 角色-权限
model RoleHasPermission {
permissionId Int @map("permission_id")
roleId Int @map("role_id")
@@id([permissionId, roleId])
@@index([roleId])
@@map("role_has_permissions")
}