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);
|
||||
//
|
||||
} 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;
|
||||
userSupportPlan.status = UserSupportPlanStatus.ACTIVE;
|
||||
|
||||
|
||||
@@ -492,7 +492,7 @@ export class NotificationsService {
|
||||
async createNewCustomerNotification(recipientId: string, data: INewCustomerNotificationData, queryRunner: QueryRunner) {
|
||||
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) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export enum UserSupportPlanStatus {
|
||||
ACTIVE = "ACTIVE",
|
||||
INACTIVE = "INACTIVE",
|
||||
CANCELLED = "CANCELLED",
|
||||
}
|
||||
|
||||
@@ -249,8 +249,8 @@ export class SupportPlansService {
|
||||
upgradePrice.toNumber(),
|
||||
);
|
||||
|
||||
// cancel old support plan
|
||||
currentUserSupportPlan.status = UserSupportPlanStatus.CANCELLED;
|
||||
// inactivate old support plan
|
||||
// currentUserSupportPlan.status = UserSupportPlanStatus.INACTIVE;
|
||||
await queryRunner.manager.save(this.userSupportPlanRepo.target, currentUserSupportPlan);
|
||||
|
||||
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 = {
|
||||
Parameters: [
|
||||
{ name: "fullName", value: fullName },
|
||||
{ name: "mobile", value: mobile },
|
||||
{ name: "mobile", value: newCustomerMobile },
|
||||
],
|
||||
Mobile: mobile,
|
||||
TemplateId: this.smsConfigs.SMS_PATTERN_NEW_CUSTOMER,
|
||||
|
||||
Reference in New Issue
Block a user