rerfactor user wallet ans user points

This commit is contained in:
2025-12-29 21:31:01 +03:30
parent cfc0366eca
commit 0f1f472adb
17 changed files with 193 additions and 116 deletions
+6 -6
View File
@@ -12,27 +12,27 @@ export const adminsData: AdminData[] = [
firstName: 'مرتضی',
lastName: 'مرتضایی',
roleName: 'مدیر ( پلن ویژه)',
restaurantSlug: 'zhivan',
restaurantSlug: 'boote',
},
{
phone: '09185290775',
firstName: 'حمید',
lastName: 'ضرقامی',
roleName: 'مدیر (پلن پایه)',
roleName: 'مدیر ( پلن ویژه)',
restaurantSlug: 'boote',
},
{
phone: '09129283395',
firstName: 'مهرداد',
lastName: 'مظفری',
roleName: 'superAdmin',
restaurantSlug: null,
roleName: 'مدیر ( پلن ویژه)',
restaurantSlug: 'boote',
},
{
phone: '09184317567',
firstName: 'ادمین',
lastName: 'هنر',
roleName: 'مدیر (پلن پایه)',
restaurantSlug: 'honar',
roleName: 'مدیر ( پلن ویژه)',
restaurantSlug: 'boote',
},
];
+1 -1
View File
@@ -119,7 +119,7 @@ export const restaurantsData: RestaurantData[] = [
marriageDateScore: '2',
referrerScore: '2',
},
plan: PlanEnum.Base,
plan: PlanEnum.Premium,
subscriptionId: 'sub_seed_boote_001',
},
// {
+8 -5
View File
@@ -1,7 +1,8 @@
import type { EntityManager } from '@mikro-orm/core';
import { User } from '../modules/users/entities/user.entity';
import { Restaurant } from '../modules/restaurants/entities/restaurant.entity';
import { UserWallet } from '../modules/users/entities/user-wallet.entity';
import { WalletTransaction } from '../modules/users/entities/wallet-transaction.entity';
import { WalletTransactionReason, WalletTransactionType } from 'src/modules/users/interface/wallet';
export class UserWalletsSeeder {
async run(em: EntityManager): Promise<void> {
@@ -11,17 +12,19 @@ export class UserWalletsSeeder {
for (const user of users) {
for (const restaurant of restaurants) {
// Check if wallet already exists for this user-restaurant combination
const existingWallet = await em.findOne(UserWallet, {
const existingWallet = await em.findOne(WalletTransaction, {
user: { id: user.id },
restaurant: { id: restaurant.id },
});
if (!existingWallet) {
const wallet = em.create(UserWallet, {
const wallet = em.create(WalletTransaction, {
user,
restaurant,
wallet: 150000000,
points: 1250,
balance: 150000000,
amount: 1250,
type: WalletTransactionType.CREDIT,
reason: WalletTransactionReason.DEPOSIT,
});
em.persist(wallet);
}