feat: dont inactive the old suport plan and after pay the invoice make it inactive
This commit is contained in:
@@ -552,6 +552,14 @@ export class InvoicesService {
|
|||||||
await this.addNotifyAdminForSubscriptionPaymentToQueue(invoice);
|
await this.addNotifyAdminForSubscriptionPaymentToQueue(invoice);
|
||||||
//
|
//
|
||||||
} else if (invoice.items[0]?.supportPlan) {
|
} else if (invoice.items[0]?.supportPlan) {
|
||||||
|
const oldUserSupportPlan = await queryRunner.manager.findOne(UserSupportPlan, {
|
||||||
|
where: { user: { id: user.id }, status: UserSupportPlanStatus.ACTIVE },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (oldUserSupportPlan) {
|
||||||
|
await queryRunner.manager.update(UserSupportPlan, oldUserSupportPlan.id, { status: UserSupportPlanStatus.INACTIVE });
|
||||||
|
}
|
||||||
|
|
||||||
const userSupportPlan = invoice.items[0].supportPlan;
|
const userSupportPlan = invoice.items[0].supportPlan;
|
||||||
userSupportPlan.status = UserSupportPlanStatus.ACTIVE;
|
userSupportPlan.status = UserSupportPlanStatus.ACTIVE;
|
||||||
|
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ export class NotificationsService {
|
|||||||
async createNewCustomerNotification(recipientId: string, data: INewCustomerNotificationData, queryRunner: QueryRunner) {
|
async createNewCustomerNotification(recipientId: string, data: INewCustomerNotificationData, queryRunner: QueryRunner) {
|
||||||
const message = NotificationMessage.NEW_CUSTOMER_MESSAGE.replace("[fullName]", data.fullName);
|
const message = NotificationMessage.NEW_CUSTOMER_MESSAGE.replace("[fullName]", data.fullName);
|
||||||
|
|
||||||
await this.smsService.sendNewCustomerSms(data.userPhone, data.fullName);
|
await this.smsService.sendNewCustomerSms(data.userPhone, data.mobile, data.fullName);
|
||||||
if (data.userEmail) {
|
if (data.userEmail) {
|
||||||
await this.emailService.sendAdminNotificationEmail({
|
await this.emailService.sendAdminNotificationEmail({
|
||||||
userEmail: data.userEmail,
|
userEmail: data.userEmail,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export enum UserSupportPlanStatus {
|
export enum UserSupportPlanStatus {
|
||||||
ACTIVE = "ACTIVE",
|
ACTIVE = "ACTIVE",
|
||||||
INACTIVE = "INACTIVE",
|
INACTIVE = "INACTIVE",
|
||||||
CANCELLED = "CANCELLED",
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,8 +249,8 @@ export class SupportPlansService {
|
|||||||
upgradePrice.toNumber(),
|
upgradePrice.toNumber(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// cancel old support plan
|
// inactivate old support plan
|
||||||
currentUserSupportPlan.status = UserSupportPlanStatus.CANCELLED;
|
// currentUserSupportPlan.status = UserSupportPlanStatus.INACTIVE;
|
||||||
await queryRunner.manager.save(this.userSupportPlanRepo.target, currentUserSupportPlan);
|
await queryRunner.manager.save(this.userSupportPlanRepo.target, currentUserSupportPlan);
|
||||||
|
|
||||||
if (newSupportPlan.isFree) {
|
if (newSupportPlan.isFree) {
|
||||||
|
|||||||
@@ -666,11 +666,11 @@ export class SmsService {
|
|||||||
}
|
}
|
||||||
//************************************************* */
|
//************************************************* */
|
||||||
|
|
||||||
async sendNewCustomerSms(mobile: string, fullName: string) {
|
async sendNewCustomerSms(mobile: string, newCustomerMobile: string, fullName: string) {
|
||||||
const smsData: ISmsVerifyBody = {
|
const smsData: ISmsVerifyBody = {
|
||||||
Parameters: [
|
Parameters: [
|
||||||
{ name: "fullName", value: fullName },
|
{ name: "fullName", value: fullName },
|
||||||
{ name: "mobile", value: mobile },
|
{ name: "mobile", value: newCustomerMobile },
|
||||||
],
|
],
|
||||||
Mobile: mobile,
|
Mobile: mobile,
|
||||||
TemplateId: this.smsConfigs.SMS_PATTERN_NEW_CUSTOMER,
|
TemplateId: this.smsConfigs.SMS_PATTERN_NEW_CUSTOMER,
|
||||||
|
|||||||
Reference in New Issue
Block a user