feat(assoc): v4.0.1 合伙人关联码、分佣账单与 H5 用户管理

订单佣金只认关联用户;合伙人备注写入独立表;H5 增加用户管理与首页统计。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-30 14:35:39 +08:00
parent 3b669f7e38
commit 9c8d5f2cad
125 changed files with 6355 additions and 1436 deletions
+53
View File
@@ -0,0 +1,53 @@
export type StoreCategoryLike = {
id?: string;
name?: string;
parentId?: string | null;
parent?: { name?: string } | null;
};
export type StoreCategoryTreeNode = {
id: string;
name: string;
children?: { id: string; name: string }[];
};
export function storeStarCount(rating?: number | string | null): number {
const n = Number(rating);
if (!Number.isFinite(n) || n <= 0) return 5;
return Math.min(5, Math.max(1, Math.round(n)));
}
export function storeCategoryTags(
store: {
tags?: unknown;
categoryId?: string | null;
category?: StoreCategoryLike | null;
},
tree: StoreCategoryTreeNode[] = [],
): string[] {
const fromJson = Array.isArray(store.tags)
? store.tags.map((t) => String(t).trim()).filter(Boolean)
: [];
if (fromJson.length) return fromJson;
const names: string[] = [];
const childName = String(store.category?.name || '').trim();
const parentName = String(store.category?.parent?.name || '').trim();
if (parentName) names.push(parentName);
if (childName && childName !== parentName) names.push(childName);
const storeCatId = String(store.categoryId || store.category?.id || '');
const storeParentId = String(store.category?.parentId || '');
for (const root of tree) {
if (root.id === storeParentId || root.id === storeCatId) {
if (root.name && !names.includes(root.name)) names.unshift(root.name);
}
for (const child of root.children ?? []) {
if (child.id === storeCatId) {
if (root.name && !names.includes(root.name)) names.unshift(root.name);
if (child.name && !names.includes(child.name)) names.push(child.name);
}
}
}
return names;
}