rerfactor user wallet ans user points
This commit is contained in:
@@ -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',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -119,7 +119,7 @@ export const restaurantsData: RestaurantData[] = [
|
||||
marriageDateScore: '2',
|
||||
referrerScore: '2',
|
||||
},
|
||||
plan: PlanEnum.Base,
|
||||
plan: PlanEnum.Premium,
|
||||
subscriptionId: 'sub_seed_boote_001',
|
||||
},
|
||||
// {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user