fix : free plan
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user