rwadurian/backend/services/reward-service/prisma/seed.ts

105 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
// ============================================
// 初始化权益定义
// 总计 2199 USDT = 400 + 300 + 9 + 800 + 500 + 15 + 20 + 35 + 40 + 80
// ============================================
const rightDefinitions = [
// === 系统费用类 (1509 USDT) ===
{
rightType: 'COST_FEE',
usdtPerTree: 400,
hashpowerPercent: 0,
payableTo: 'SYSTEM_ACCOUNT',
ruleDescription: '成本费每棵树400 USDT进成本账户(userId=2)',
},
{
rightType: 'OPERATION_FEE',
usdtPerTree: 300,
hashpowerPercent: 0,
payableTo: 'SYSTEM_ACCOUNT',
ruleDescription: '运营费每棵树300 USDT进运营账户(userId=3)',
},
{
rightType: 'HEADQUARTERS_BASE_FEE',
usdtPerTree: 9,
hashpowerPercent: 0,
payableTo: 'HEADQUARTERS',
ruleDescription: '总部社区基础费每棵树9 USDT进总部社区账户(userId=1)',
},
{
rightType: 'RWAD_POOL_INJECTION',
usdtPerTree: 800,
hashpowerPercent: 0,
payableTo: 'SYSTEM_ACCOUNT',
ruleDescription: 'RWAD底池注入每棵树800 USDT注入1号底池(userId=4)',
},
// === 用户权益类 (690 USDT + 算力) ===
{
rightType: 'SHARE_RIGHT',
usdtPerTree: 500,
hashpowerPercent: 0,
payableTo: 'USER_ACCOUNT',
ruleDescription: '分享权益每棵树500 USDT分配给推荐链',
},
{
rightType: 'PROVINCE_AREA_RIGHT',
usdtPerTree: 15,
hashpowerPercent: 1,
payableTo: 'SYSTEM_ACCOUNT',
ruleDescription: '省区域权益每棵树15 USDT + 1%算力,进系统省公司账户',
},
{
rightType: 'PROVINCE_TEAM_RIGHT',
usdtPerTree: 20,
hashpowerPercent: 0,
payableTo: 'USER_ACCOUNT',
ruleDescription: '省团队权益每棵树20 USDT给最近的授权省公司',
},
{
rightType: 'CITY_AREA_RIGHT',
usdtPerTree: 35,
hashpowerPercent: 2,
payableTo: 'SYSTEM_ACCOUNT',
ruleDescription: '市区域权益每棵树35 USDT + 2%算力,进系统市公司账户',
},
{
rightType: 'CITY_TEAM_RIGHT',
usdtPerTree: 40,
hashpowerPercent: 0,
payableTo: 'USER_ACCOUNT',
ruleDescription: '市团队权益每棵树40 USDT给最近的授权市公司',
},
{
rightType: 'COMMUNITY_RIGHT',
usdtPerTree: 80,
hashpowerPercent: 0,
payableTo: 'USER_ACCOUNT',
ruleDescription: '社区权益每棵树80 USDT给最近的社区',
},
];
for (const def of rightDefinitions) {
await prisma.rightDefinition.upsert({
where: { rightType: def.rightType },
update: def,
create: def,
});
}
console.log('Seed completed: Right definitions initialized');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});