71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
async function main() {
|
||
// 初始化权益定义
|
||
const rightDefinitions = [
|
||
{
|
||
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();
|
||
});
|