feat: 技术支持工单/企微权限/开发版本管理/消息推送等迭代
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* 将 common_product_item.benefit_amount 同步为与 price 相同(全额好客权益)。
|
||||
* 用法:pnpm db:sync-benefit
|
||||
*/
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
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 prisma:seed first.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Syncing benefit_amount = price for ${products.length} product(s)...\n`);
|
||||
|
||||
for (const p of products) {
|
||||
const price = Number(p.price);
|
||||
const before = p.benefitAmount != null ? Number(p.benefitAmount) : null;
|
||||
|
||||
await prisma.commonProductItem.update({
|
||||
where: { id: p.id },
|
||||
data: { benefitAmount: p.price },
|
||||
});
|
||||
|
||||
const beforeLabel = before == null ? 'NULL' : `¥${before}`;
|
||||
console.log(` ${p.skuCode} ${p.name}`);
|
||||
console.log(` benefit: ${beforeLabel} → ¥${price}`);
|
||||
}
|
||||
|
||||
console.log('\nDone.');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user