subscription start and end date

This commit is contained in:
2025-12-26 19:32:06 +03:30
parent a85ebaada4
commit 2b1f8df6b9
6 changed files with 25 additions and 4 deletions
@@ -45,7 +45,7 @@ export class PaymentsController {
@ApiOperation({ summary: 'Get all the restaurant payments for user' }) @ApiOperation({ summary: 'Get all the restaurant payments for user' })
@ApiHeader(API_HEADER_SLUG) @ApiHeader(API_HEADER_SLUG)
findAllByRestaurant(@UserId() userId: string, @RestId() restId: string) { findAllByRestaurant(@UserId() userId: string, @RestId() restId: string) {
return this.paymentsService.findAllByRestaurantId(restId, userId); return this.paymentsService.findAllPaymentsByRestaurantId(restId, userId);
} }
@UseGuards(AuthGuard) @UseGuards(AuthGuard)
@@ -219,7 +219,7 @@ export class PaymentsService {
return payment; return payment;
} }
findAllByRestaurantId(restId: string, userId: string) { findAllPaymentsByRestaurantId(restId: string, userId: string) {
return this.em.find( return this.em.find(
Payment, Payment,
{ order: { restaurant: { id: restId }, user: { id: userId } } }, { order: { restaurant: { id: restId }, user: { id: userId } } },
@@ -1,5 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, IsNumber } from 'class-validator'; import { IsString, IsOptional, IsNumber, IsDate } from 'class-validator';
export class CreateRestaurantDto { export class CreateRestaurantDto {
@ApiProperty({ example: 'کافه ژیوان', description: 'نام رستوران' }) @ApiProperty({ example: 'کافه ژیوان', description: 'نام رستوران' })
@@ -24,4 +24,12 @@ export class CreateRestaurantDto {
@IsString() @IsString()
subscriptionId!: string; subscriptionId!: string;
@ApiProperty({ example: '2025-12-26', description: 'تاریخ انقضای اشتراک' })
@IsDate()
subscriptionEndDate!: Date;
@ApiProperty({ example: '2025-12-26', description: 'تاریخ شروع اشتراک' })
@IsDate()
subscriptionStartDate!: Date;
} }
@@ -102,4 +102,11 @@ export class Restaurant extends BaseEntity {
@Property({unique: true}) @Property({unique: true})
subscriptionId!: string; subscriptionId!: string;
@Property()
subscriptionEndDate!: Date;
@Property()
subscriptionStartDate!: Date;
} }
@@ -26,6 +26,8 @@ export class RestaurantsService {
plan: PlanEnum.Base, plan: PlanEnum.Base,
domain: `https://dmenu-plus-front.dev.danakcorp.com/${dto.slug}`, domain: `https://dmenu-plus-front.dev.danakcorp.com/${dto.slug}`,
subscriptionId: dto.subscriptionId, subscriptionId: dto.subscriptionId,
subscriptionEndDate: dto.subscriptionEndDate,
subscriptionStartDate: dto.subscriptionStartDate,
}); });
await this.em.persistAndFlush(restaurant); await this.em.persistAndFlush(restaurant);
+5 -1
View File
@@ -9,7 +9,11 @@ export class RestaurantsSeeder {
for (const restaurantData of restaurantsData) { for (const restaurantData of restaurantsData) {
let restaurant = await em.findOne(Restaurant, { slug: restaurantData.slug }); let restaurant = await em.findOne(Restaurant, { slug: restaurantData.slug });
if (!restaurant) { 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); em.persist(restaurant);
} }
restaurantsMap.set(restaurantData.slug, restaurant); restaurantsMap.set(restaurantData.slug, restaurant);