v3数据表更改

This commit is contained in:
2026-07-01 14:36:50 +08:00
parent 638898b71e
commit aeb4ecfc84
46 changed files with 4553 additions and 918 deletions
@@ -1,5 +1,5 @@
/**
* 将 products.benefit_amount 同步为与 price 相同(全额好客权益)。
* 将 common_product_item.benefit_amount 同步为与 price 相同(全额好客权益)。
* 用法:pnpm db:sync-benefit
*/
import { PrismaClient } from '@prisma/client';
@@ -7,13 +7,13 @@ import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const products = await prisma.product.findMany({
const products = await prisma.commonProductItem.findMany({
select: { id: true, skuCode: true, name: true, price: true, benefitAmount: true },
orderBy: { sortOrder: 'asc' },
});
if (products.length === 0) {
console.log('No products found. Run pnpm db:seed first.');
console.log('No products found. Run pnpm prisma:seed first.');
return;
}
@@ -23,7 +23,7 @@ async function main() {
const price = Number(p.price);
const before = p.benefitAmount != null ? Number(p.benefitAmount) : null;
await prisma.product.update({
await prisma.commonProductItem.update({
where: { id: p.id },
data: { benefitAmount: p.price },
});