门店账户多账号

This commit is contained in:
2026-07-12 12:24:34 +08:00
parent 06b1cb22e0
commit 54a15d6da7
39 changed files with 1962 additions and 311 deletions
+13 -4
View File
@@ -36,17 +36,26 @@ export async function checkNeedsWechatAuth(profile: ShopAccountProfile | null):
export function sessionFromWechatLogin(result: WechatLoginResult): ShopSessionPayload | null {
if (!result.accessToken || !result.refreshToken) return null;
const store = result.store;
const store = result.store as Record<string, unknown> | undefined;
const stores = Array.isArray((result as { stores?: unknown }).stores)
? ((result as { stores: ShopSessionPayload['stores'] }).stores)
: undefined;
const account = (result as { account?: ShopSessionPayload['account'] }).account;
return {
accessToken: result.accessToken,
refreshToken: result.refreshToken,
stores,
account,
selectedStoreId: (result as { selectedStoreId?: string }).selectedStoreId,
store: store
? {
id: String(store.id ?? ''),
id: String(store.id ?? account?.id ?? ''),
storeId: String(store.storeId ?? ''),
name: String(store.name ?? ''),
phone: String(store.phone ?? ''),
name: String(store.name ?? account?.name ?? ''),
phone: String(store.phone ?? account?.phone ?? ''),
storeName: String(store.storeName ?? store.name ?? ''),
isPrimary: account?.isPrimary,
stores,
}
: undefined,
};