diff --git a/src/modules/payments/controllers/payments.controller.ts b/src/modules/payments/controllers/payments.controller.ts index 004a38c..5a03d47 100644 --- a/src/modules/payments/controllers/payments.controller.ts +++ b/src/modules/payments/controllers/payments.controller.ts @@ -45,7 +45,7 @@ export class PaymentsController { @ApiOperation({ summary: 'Get all the restaurant payments for user' }) @ApiHeader(API_HEADER_SLUG) findAllByRestaurant(@UserId() userId: string, @RestId() restId: string) { - return this.paymentsService.findAllByRestaurantId(restId, userId); + return this.paymentsService.findAllPaymentsByRestaurantId(restId, userId); } @UseGuards(AuthGuard) diff --git a/src/modules/payments/services/payments.service.ts b/src/modules/payments/services/payments.service.ts index e6a2a48..d5f0e06 100644 --- a/src/modules/payments/services/payments.service.ts +++ b/src/modules/payments/services/payments.service.ts @@ -219,7 +219,7 @@ export class PaymentsService { return payment; } - findAllByRestaurantId(restId: string, userId: string) { + findAllPaymentsByRestaurantId(restId: string, userId: string) { return this.em.find( Payment, { order: { restaurant: { id: restId }, user: { id: userId } } }, diff --git a/src/modules/restaurants/dto/create-restaurant.dto.ts b/src/modules/restaurants/dto/create-restaurant.dto.ts index e6432c7..6117347 100644 --- a/src/modules/restaurants/dto/create-restaurant.dto.ts +++ b/src/modules/restaurants/dto/create-restaurant.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsString, IsOptional, IsNumber } from 'class-validator'; +import { IsString, IsOptional, IsNumber, IsDate } from 'class-validator'; export class CreateRestaurantDto { @ApiProperty({ example: 'کافه ژیوان', description: 'نام رستوران' }) @@ -24,4 +24,12 @@ export class CreateRestaurantDto { @IsString() subscriptionId!: string; + @ApiProperty({ example: '2025-12-26', description: 'تاریخ انقضای اشتراک' }) + @IsDate() + subscriptionEndDate!: Date; + + @ApiProperty({ example: '2025-12-26', description: 'تاریخ شروع اشتراک' }) + @IsDate() + subscriptionStartDate!: Date; + } diff --git a/src/modules/restaurants/entities/restaurant.entity.ts b/src/modules/restaurants/entities/restaurant.entity.ts index a890129..f738be8 100644 --- a/src/modules/restaurants/entities/restaurant.entity.ts +++ b/src/modules/restaurants/entities/restaurant.entity.ts @@ -102,4 +102,11 @@ export class Restaurant extends BaseEntity { @Property({unique: true}) subscriptionId!: string; + + @Property() + subscriptionEndDate!: Date; + + @Property() + subscriptionStartDate!: Date; + } diff --git a/src/modules/restaurants/providers/restaurants.service.ts b/src/modules/restaurants/providers/restaurants.service.ts index b1e65f2..4911c2a 100644 --- a/src/modules/restaurants/providers/restaurants.service.ts +++ b/src/modules/restaurants/providers/restaurants.service.ts @@ -26,6 +26,8 @@ export class RestaurantsService { plan: PlanEnum.Base, domain: `https://dmenu-plus-front.dev.danakcorp.com/${dto.slug}`, subscriptionId: dto.subscriptionId, + subscriptionEndDate: dto.subscriptionEndDate, + subscriptionStartDate: dto.subscriptionStartDate, }); await this.em.persistAndFlush(restaurant); diff --git a/src/seeders/restaurants.seeder.ts b/src/seeders/restaurants.seeder.ts index 467e2ba..c05a6cc 100644 --- a/src/seeders/restaurants.seeder.ts +++ b/src/seeders/restaurants.seeder.ts @@ -9,7 +9,11 @@ export class RestaurantsSeeder { for (const restaurantData of restaurantsData) { let restaurant = await em.findOne(Restaurant, { slug: restaurantData.slug }); if (!restaurant) { - restaurant = em.create(Restaurant, restaurantData); + restaurant = em.create(Restaurant, { + ...restaurantData, + subscriptionEndDate: new Date('2025-12-26'), + subscriptionStartDate: new Date('2026-12-26'), + }); em.persist(restaurant); } restaurantsMap.set(restaurantData.slug, restaurant);