feat: 联动支付 CRM 后台(Next.js + TS + Prisma 重构)
从旧 Laravel 5.7 重构为现代技术栈,对接现有 MySQL。 - 技术栈: Next.js 15 App Router + TypeScript + Prisma + Auth.js + Tailwind v4 - 认证: 复用旧库 admins 的 bcrypt 密码,Auth.js Credentials - 客户管理: 列表(搜索/报单区间/分页)、增改删、Excel 导入导出 - 生日提醒: 阴阳历(lunar-typescript),口径对齐旧 overtrue 库 - RBAC: 管理员/角色/权限(菜单树) 完整 CRUD + 分配 - 控制台: 统计卡 + 月度新增报单柱状图 - 个人中心: 改昵称/改密码 - 现代 CMS 界面 + 联动支付品牌(logo/登录/底部/icon) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
// 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阴历
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user