feat(customers): 增加商户编号并补齐生日提醒信息
录入、列表和导入导出带上商户编号。生日提醒展示与录入一致的商户资料,旧阴历生日仍按农历提醒。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import type { NextAuthConfig, DefaultSession } from "next-auth";
|
||||
|
||||
// 本地 `next dev` 忽略 .env 里的生产 AUTH_URL,避免 localhost 被跳到公网机。
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
delete process.env.AUTH_URL;
|
||||
}
|
||||
|
||||
// Edge 安全的基础配置:不引入 Prisma / bcrypt,供 middleware 使用。
|
||||
// 真正带数据库校验的 Credentials provider 在 auth.ts 里注入。
|
||||
|
||||
|
||||
+19
-1
@@ -1,4 +1,4 @@
|
||||
import { Solar } from "lunar-typescript";
|
||||
import { Lunar, Solar } from "lunar-typescript";
|
||||
|
||||
function pad2(n: number): string {
|
||||
return String(Math.abs(n)).padStart(2, "0");
|
||||
@@ -39,3 +39,21 @@ export function birthdayMatchLists(
|
||||
|
||||
return { solar: [...solar], lunar: [...lunar] };
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史阴历生日存的是农历月日(年份占位)。换成今年对应的公历日期,供提醒页对照。
|
||||
* 闰月等无法换算时返回 null,不猜日期。
|
||||
*/
|
||||
export function lunarBirthdaySolarThisYear(
|
||||
isoDate: string,
|
||||
year = new Date().getFullYear()
|
||||
): string | null {
|
||||
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(isoDate);
|
||||
if (!m) return null;
|
||||
try {
|
||||
const solar = Lunar.fromYmd(year, Number(m[2]), Number(m[3])).getSolar();
|
||||
return `${solar.getYear()}-${pad2(solar.getMonth())}-${pad2(solar.getDay())}`;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user