feat(store): separate login phone from public contactPhone

Store.phone stays login/boss; contactPhone is C-end dial. Public store APIs keep phone compat via publicDial mapping.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-09 07:50:40 +08:00
parent a598d1cd30
commit 07630c9046
11 changed files with 265 additions and 67 deletions
@@ -44,11 +44,36 @@ export function mapOrderCompat<T extends OrderLike & {
};
}
export function mapStoreCompat<T extends { coverResource?: { url?: string } | null }>(store: T) {
return {
/** 对外联系电话;未单独配置时回退登录手机号 */
export function resolveStoreContactPhone(store: {
phone?: string | null;
contactPhone?: string | null;
}): string {
const contact = String(store.contactPhone ?? '').trim();
if (contact) return contact;
return String(store.phone ?? '').trim();
}
export function mapStoreCompat<
T extends {
coverResource?: { url?: string } | null;
phone?: string | null;
contactPhone?: string | null;
},
>(store: T, opts?: { /** C 端:phone 字段对外可拨打号码 */ publicDial?: boolean }) {
const contactPhone = resolveStoreContactPhone(store) || null;
const mapped = {
...store,
coverUrl: store.coverResource?.url ?? null,
contactPhone,
};
if (opts?.publicDial) {
return {
...mapped,
phone: contactPhone || store.phone || null,
};
}
return mapped;
}
export function mapStatusLogCompat(events: CommonEvent[]) {