fix : free plan

This commit is contained in:
morteza-mortezai
2025-11-13 11:00:08 +03:30
parent bec0ba472e
commit 88349e3b7d
2 changed files with 3 additions and 15 deletions
+1
View File
@@ -520,6 +520,7 @@ export const enum SubscriptionMessage {
SLUG_LENGTH = "اسلاگ باید بین ۴ تا ۲۵۰ کاراکتر باشد",
SLUG_EXISTS = "این اسلاگ قبلا ثبت شده است",
FREE_PLAN_LIMIT_EXCEEDED = "شما در یک ماه گذشته از پلن رایگان استفاده کرده‌اید و نمی‌توانید مجدداً استفاده کنید",
FREE_PLAN_NOT_ALLOWED = "انتخاب پلن رایگان در تمدید سرویس امکان پدیر نیست",
USER_DOES_NOT_HAVE_ACCESS = "شما دسترسی به این سرویس ندارید",
}
@@ -323,25 +323,12 @@ export class SubscriptionsService {
const plan = await queryRunner.manager.findOne(SubscriptionPlan, {
where: { id: dto.planId, service: { id: dto.serviceId } },
relations: { service: true, directDiscount: true, }
relations: { service: true, directDiscount: true },
});
if (!plan) throw new BadRequestException(SubscriptionMessage.NOT_FOUND);
if (plan.isFree) {
isFree = true;
const existingFreePlanSubscription = await queryRunner.manager.findOne(UserSubscription, {
where: {
user: { id: userId },
plan: { isFree: true },
},
relations: {
plan: true,
},
});
if (existingFreePlanSubscription) {
throw new BadRequestException(SubscriptionMessage.FREE_PLAN_LIMIT_EXCEEDED);
}
throw new BadRequestException(SubscriptionMessage.FREE_PLAN_NOT_ALLOWED);
}
const startDate =