chore(seed): seed deterministic points products

Add five published points products, idempotent by English name, so the live
mall has a redeemable catalog. Spendable demo points are credited by the API
through the account ledger rather than here.
This commit is contained in:
2026-09-18 12:43:00 +00:00
parent 68317c2040
commit f70d1e506a
+26
View File
@@ -342,6 +342,32 @@ for (const p of products) {
}
console.log(`products ready: ${products.length} across ${SHOPS.length} shops`);
// 6. points mall products (idempotent by English name). The demo customer's
// spendable points are credited by the API through the account ledger.
const POINTS_PRODUCTS = [
{ name: { en: "Insulated Mug", zh: "保温杯" }, image: "/mock/product-9.svg", points_price: 1200, stock: 300 },
{ name: { en: "Canvas Tote", zh: "帆布手提袋" }, image: "/mock/product-15.svg", points_price: 600, stock: 500 },
{ name: { en: "Phone Stand", zh: "手机支架" }, image: "/mock/product-7.svg", points_price: 400, stock: 800 },
{ name: { en: "Cable Organizer Set", zh: "数据线收纳套装" }, image: "/mock/product-3.svg", points_price: 300, stock: 1000 },
{ name: { en: "Notebook A5", zh: "A5 笔记本" }, image: "/mock/product-14.svg", points_price: 250, stock: 1200 },
];
{
const listed = await call("GET", "/admin/points/products", { token: admin });
if (listed.status !== 200) fail("list points products", listed);
const known = new Set(listed.data.map((p) => p.name.en));
let created = 0;
for (const [index, product] of POINTS_PRODUCTS.entries()) {
if (known.has(product.name.en)) continue;
const res = await call("POST", "/admin/points/products", {
token: admin,
body: { ...product, position: index, published: true, recommend: index < 2 },
});
if (res.status !== 201) fail(`seed points product ${product.name.en}`, res);
created += 1;
}
console.log(`points products ready: ${POINTS_PRODUCTS.length} (${created} new)`);
}
console.log("\nDemo data seeded.");
console.log(" platform admin : admin@vmall.local / admin1234 (apps/admin :3002)");
console.log(" shop owner : shop@vmall.local / shop12345 (apps/shop-admin :3001)");