tango-app-api-payment-subscription 3.0.37-dev → 3.0.39-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/controllers/paymentSubscription.controllers.js +88 -56
- package/src/hbs/trialExpiredEmail.hbs +2 -2
- package/src/hbs/trialExtentionEmail.hbs +2 -2
- package/src/hbs/trialInitiateEmail.hbs +2 -2
- package/src/hbs/trialReminderEmail.hbs +2 -2
- package/src/hbs/trialSubscriptionEmail.hbs +1 -1
- package/src/utils/validations/client.validation.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-payment-subscription",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.39-dev",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"pdfmake": "^0.2.10",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
28
|
"tango-api-schema": "^2.0.83",
|
|
29
|
-
"tango-app-api-middleware": "^1.0.
|
|
29
|
+
"tango-app-api-middleware": "^1.0.2-test",
|
|
30
30
|
"winston": "^3.12.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
32
32
|
},
|
|
@@ -16,6 +16,7 @@ import path from 'path';
|
|
|
16
16
|
import { JSDOM } from 'jsdom';
|
|
17
17
|
import pdfMake from 'pdfmake';
|
|
18
18
|
import htmlToPdfmake from 'html-to-pdfmake';
|
|
19
|
+
import axios from 'axios';
|
|
19
20
|
|
|
20
21
|
export const addBilling = async ( req, res ) => {
|
|
21
22
|
try {
|
|
@@ -464,7 +465,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
464
465
|
let userDetails= await userService.findOne( { clientId: requestBody.clientId, role: 'superadmin' } );
|
|
465
466
|
if ( userDetails ) {
|
|
466
467
|
let data = {
|
|
467
|
-
|
|
468
|
+
userName: userDetails.userName,
|
|
468
469
|
};
|
|
469
470
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialSubscriptionEmail.hbs', 'utf8' );
|
|
470
471
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -817,7 +818,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
817
818
|
requestData.status = 'completed';
|
|
818
819
|
requestData.save().then( async () => {
|
|
819
820
|
if ( req.body.type == 'approve' ) {
|
|
820
|
-
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId
|
|
821
|
+
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId }, { planDetails: 1 } );
|
|
821
822
|
if ( clientProducts?.planDetails.subscriptionType == 'free' ) {
|
|
822
823
|
clientProducts.planDetails.subscriptionType = 'premium';
|
|
823
824
|
}
|
|
@@ -848,6 +849,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
848
849
|
let data = {
|
|
849
850
|
userName: userDetails.userName,
|
|
850
851
|
product: firstWord +' '+ secondWord,
|
|
852
|
+
domain: appConfig.url.domain,
|
|
851
853
|
};
|
|
852
854
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
853
855
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -885,7 +887,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
885
887
|
export const trialExtendRequestApproval = async ( req, res ) => {
|
|
886
888
|
try {
|
|
887
889
|
let trialDate;
|
|
888
|
-
let clientDetails = await paymentService.findOne( { clientId: req.body.clientId
|
|
890
|
+
let clientDetails = await paymentService.findOne( { clientId: req.body.clientId }, { planDetails: 1 } );
|
|
889
891
|
if ( !clientDetails ) {
|
|
890
892
|
return res.sendError( 'no data found', 204 );
|
|
891
893
|
}
|
|
@@ -910,6 +912,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
910
912
|
product: firstWord +' '+secondWord,
|
|
911
913
|
days: req.body.days,
|
|
912
914
|
date: dayjs( trialDate ).format( 'YYYY-MM-DD' ),
|
|
915
|
+
domain: appConfig.url.domain,
|
|
913
916
|
};
|
|
914
917
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExtentionEmail.hbs', 'utf8' );
|
|
915
918
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -950,6 +953,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
950
953
|
let data = req.body.product;
|
|
951
954
|
req.body.product = [];
|
|
952
955
|
let subscriptionCount = 0;
|
|
956
|
+
let trialProduct = [];
|
|
953
957
|
data.forEach( ( item ) => {
|
|
954
958
|
if ( item.type != 'cancel' ) {
|
|
955
959
|
let arr = item.name.split( ',' );
|
|
@@ -961,7 +965,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
961
965
|
} );
|
|
962
966
|
}
|
|
963
967
|
} );
|
|
964
|
-
let clientInfo = await paymentService.findOne( { clientId: req.body.clientId
|
|
968
|
+
let clientInfo = await paymentService.findOne( { clientId: req.body.clientId }, { clientId: 1, planDetails: 1 } );
|
|
965
969
|
if ( !clientInfo ) {
|
|
966
970
|
return res.sendError( 'no data found', 204 );
|
|
967
971
|
}
|
|
@@ -970,11 +974,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
970
974
|
let productList = product.map( ( item ) => item.productName );
|
|
971
975
|
for ( let item of req.body.product ) {
|
|
972
976
|
if ( productList.includes( item.name ) && item.type =='unsubscribe' ) {
|
|
973
|
-
// let findIndex = product.findIndex( ( product ) => product.productName );
|
|
974
|
-
// product.splice( findIndex, 1 );
|
|
975
|
-
// let requestDetails = await clientRequestService.findOne({});
|
|
976
977
|
await storeService.addremoveElement( { clientId: clientInfo.clientId, product: { $in: item.name } }, { $pull: { product: item.name } } );
|
|
977
|
-
// status: 'active',
|
|
978
978
|
}
|
|
979
979
|
if ( !productList.includes( item.name ) && [ 'trial', 'subscription' ].includes( item.type ) ) {
|
|
980
980
|
if ( item.type == 'trial' ) {
|
|
@@ -984,6 +984,10 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
984
984
|
trialEndDate: new Date( dayjs().add( 13, 'days' ).format( 'YYYY-MM-DD' ) ),
|
|
985
985
|
status: 'trial',
|
|
986
986
|
} );
|
|
987
|
+
let [ firstWord, secondWord ] = item.name.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
988
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
989
|
+
let productName =firstWord + ' ' +secondWord;
|
|
990
|
+
trialProduct.push( productName );
|
|
987
991
|
} else {
|
|
988
992
|
product.push( {
|
|
989
993
|
productName: item.name,
|
|
@@ -999,29 +1003,20 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
999
1003
|
if ( item.type == 'subscription' ) {
|
|
1000
1004
|
product[productIndex].subscribedDate = new Date();
|
|
1001
1005
|
product[productIndex].status = 'live';
|
|
1006
|
+
subscriptionCount = subscriptionCount + 1;
|
|
1002
1007
|
}
|
|
1003
|
-
subscriptionCount = subscriptionCount + 1;
|
|
1004
1008
|
}
|
|
1005
1009
|
}
|
|
1006
1010
|
}
|
|
1007
1011
|
product = product.filter( ( item ) => !removeProducts.includes( item.productName ) );
|
|
1008
|
-
// req.body = {
|
|
1009
|
-
// 'camaraPerSqft': clientInfo.planDetails.storeSize,
|
|
1010
|
-
// 'storesCount': clientInfo.planDetails.totalStores,
|
|
1011
|
-
// 'planName': clientInfo.planDetails.subscriptionPeriod,
|
|
1012
|
-
// 'products': product.map( ( item ) => item.productName ),
|
|
1013
|
-
// 'currencyType': 'rupees',
|
|
1014
|
-
// };
|
|
1015
|
-
// let pricingDetails = await calculatePricing( req, res );
|
|
1016
|
-
// clientInfo.price = pricingDetails.price;
|
|
1017
1012
|
if ( product.length > 1 ) {
|
|
1018
1013
|
clientInfo.planDetails.subscriptionType = 'premium';
|
|
1019
1014
|
}
|
|
1015
|
+
let userDetails= await userService.findOne( { clientId: clientInfo.clientId, role: 'superadmin' } );
|
|
1020
1016
|
if ( subscriptionCount ) {
|
|
1021
|
-
let userDetails= await userService.findOne( { clientId: clientInfo.clientId, role: 'superadmin' } );
|
|
1022
1017
|
if ( userDetails ) {
|
|
1023
1018
|
let data = {
|
|
1024
|
-
|
|
1019
|
+
userName: userDetails.userName,
|
|
1025
1020
|
};
|
|
1026
1021
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialSubscriptionEmail.hbs', 'utf8' );
|
|
1027
1022
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1036,26 +1031,39 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1036
1031
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1037
1032
|
}
|
|
1038
1033
|
}
|
|
1034
|
+
if ( trialProduct.length ) {
|
|
1035
|
+
let productEmailName = trialProduct.toString();
|
|
1036
|
+
if ( userDetails ) {
|
|
1037
|
+
let data = {
|
|
1038
|
+
userName: userDetails.userName,
|
|
1039
|
+
product: productEmailName,
|
|
1040
|
+
domain: appConfig.url.domain,
|
|
1041
|
+
};
|
|
1042
|
+
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
1043
|
+
const template = Handlebars.compile( templateHtml );
|
|
1044
|
+
const html = template( { data: data } );
|
|
1045
|
+
let params = {
|
|
1046
|
+
toEmail: userDetails.email,
|
|
1047
|
+
mailSubject: 'Trial Initiated - Welcome to Tango Suite!',
|
|
1048
|
+
htmlBody: html,
|
|
1049
|
+
attachment: '',
|
|
1050
|
+
sourceEmail: appConfig.cloud.aws.ses.adminEmail,
|
|
1051
|
+
};
|
|
1052
|
+
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1039
1055
|
clientInfo.planDetails.product = product;
|
|
1040
1056
|
clientInfo.save().then( async () => {
|
|
1057
|
+
let storeProduct = await storeService.find( { clientId: clientInfo.clientId }, { _id: 0, storeId: 1, product: 1 } );
|
|
1058
|
+
storeProduct = storeProduct.map( ( item ) => {
|
|
1059
|
+
return { id: item.storeId, product: item.product };
|
|
1060
|
+
} );
|
|
1061
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProduct, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
1062
|
+
logger.info( 'store Updated Successfully' );
|
|
1063
|
+
} ).catch( ( error ) => {
|
|
1064
|
+
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
1065
|
+
} );
|
|
1041
1066
|
updatePricing( req, res, true );
|
|
1042
|
-
// let userDetails= await userService.findOne( { clientId: clientInfo.clientId, role: 'superadmin' } );
|
|
1043
|
-
// if ( userDetails ) {
|
|
1044
|
-
// let data = {
|
|
1045
|
-
// username: userDetails.userName,
|
|
1046
|
-
// };
|
|
1047
|
-
// const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialSubscriptionEmail.hbs', 'utf8' );
|
|
1048
|
-
// const template = Handlebars.compile( templateHtml );
|
|
1049
|
-
// const html = template( { data: data } );
|
|
1050
|
-
// let params = {
|
|
1051
|
-
// toEmail: userDetails.email,
|
|
1052
|
-
// mailSubject: 'Subscribe - Tango Eye',
|
|
1053
|
-
// htmlBody: html,
|
|
1054
|
-
// attachment: '',
|
|
1055
|
-
// sourceEmail: appConfig.cloud.aws.ses.adminEmail,
|
|
1056
|
-
// };
|
|
1057
|
-
// sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1058
|
-
// }
|
|
1059
1067
|
} );
|
|
1060
1068
|
const logObj = {
|
|
1061
1069
|
clientId: req.body.clientId,
|
|
@@ -1084,7 +1092,7 @@ export const unsubscribeApproval = async ( req, res ) => {
|
|
|
1084
1092
|
requestData.status = 'completed';
|
|
1085
1093
|
requestData.save().then( async () => {
|
|
1086
1094
|
if ( req.body.type == 'unsubscribe' ) {
|
|
1087
|
-
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId
|
|
1095
|
+
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId }, { status: 1 } );
|
|
1088
1096
|
if ( !clientProducts ) {
|
|
1089
1097
|
return res.sendError( 'no data found', 204 );
|
|
1090
1098
|
}
|
|
@@ -1330,12 +1338,13 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1330
1338
|
} );
|
|
1331
1339
|
}
|
|
1332
1340
|
} );
|
|
1333
|
-
let clientInfo = await paymentService.findOne( { clientId: req.body.clientId
|
|
1341
|
+
let clientInfo = await paymentService.findOne( { clientId: req.body.clientId }, { 'planDetails.product': 1 } );
|
|
1334
1342
|
let productList = clientInfo.planDetails.product.map( ( product ) => product.productName );
|
|
1335
1343
|
let clientProduct = [];
|
|
1336
1344
|
let storeProduct = [];
|
|
1337
1345
|
let removedProduct = [];
|
|
1338
1346
|
let subscriptionCount = 0;
|
|
1347
|
+
let trialProduct = [];
|
|
1339
1348
|
clientProduct = clientInfo.planDetails.product;
|
|
1340
1349
|
req.body.product.forEach( ( item ) => {
|
|
1341
1350
|
if ( item.type != 'unsubscribe' ) {
|
|
@@ -1356,12 +1365,17 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1356
1365
|
trialEndDate: new Date( dayjs().add( 13, 'days' ).format( 'YYYY-MM-DD' ) ),
|
|
1357
1366
|
status: 'trial',
|
|
1358
1367
|
};
|
|
1368
|
+
let [ firstWord, secondWord ] = item.name.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1369
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
1370
|
+
let productName =firstWord + ' ' +secondWord;
|
|
1371
|
+
trialProduct.push( productName );
|
|
1359
1372
|
} else {
|
|
1360
1373
|
clientProduct[productExistsIndex] = {
|
|
1361
1374
|
productName: item.name,
|
|
1362
1375
|
subscribedDate: new Date(),
|
|
1363
1376
|
status: 'live',
|
|
1364
1377
|
};
|
|
1378
|
+
subscriptionCount = subscriptionCount + 1;
|
|
1365
1379
|
}
|
|
1366
1380
|
} else {
|
|
1367
1381
|
if ( item.type == 'trial' ) {
|
|
@@ -1371,6 +1385,10 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1371
1385
|
trialEndDate: new Date( dayjs().add( 13, 'days' ).format( 'YYYY-MM-DD' ) ),
|
|
1372
1386
|
status: 'trial',
|
|
1373
1387
|
} );
|
|
1388
|
+
let [ firstWord, secondWord ] = item.name.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1389
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
1390
|
+
let productName =firstWord + ' ' +secondWord;
|
|
1391
|
+
trialProduct.push( productName );
|
|
1374
1392
|
}
|
|
1375
1393
|
if ( item.type == 'subscription' ) {
|
|
1376
1394
|
clientProduct.push( {
|
|
@@ -1384,11 +1402,11 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1384
1402
|
}
|
|
1385
1403
|
},
|
|
1386
1404
|
);
|
|
1405
|
+
let userDetails= await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
|
|
1387
1406
|
if ( subscriptionCount ) {
|
|
1388
|
-
let userDetails= await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
|
|
1389
1407
|
if ( userDetails ) {
|
|
1390
1408
|
let data = {
|
|
1391
|
-
|
|
1409
|
+
userName: userDetails.userName,
|
|
1392
1410
|
};
|
|
1393
1411
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialSubscriptionEmail.hbs', 'utf8' );
|
|
1394
1412
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1403,6 +1421,27 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1403
1421
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1404
1422
|
}
|
|
1405
1423
|
}
|
|
1424
|
+
if ( trialProduct.length ) {
|
|
1425
|
+
let productEmailName = trialProduct.toString();
|
|
1426
|
+
if ( userDetails ) {
|
|
1427
|
+
let data = {
|
|
1428
|
+
userName: userDetails.userName,
|
|
1429
|
+
product: productEmailName,
|
|
1430
|
+
domain: appConfig.url.domain,
|
|
1431
|
+
};
|
|
1432
|
+
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
1433
|
+
const template = Handlebars.compile( templateHtml );
|
|
1434
|
+
const html = template( { data: data } );
|
|
1435
|
+
let params = {
|
|
1436
|
+
toEmail: userDetails.email,
|
|
1437
|
+
mailSubject: 'Trial Initiated - Welcome to Tango Suite!',
|
|
1438
|
+
htmlBody: html,
|
|
1439
|
+
attachment: '',
|
|
1440
|
+
sourceEmail: appConfig.cloud.aws.ses.adminEmail,
|
|
1441
|
+
};
|
|
1442
|
+
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1406
1445
|
clientInfo.planDetails.product = clientProduct;
|
|
1407
1446
|
clientInfo.save();
|
|
1408
1447
|
storeDetails.forEach( async ( item ) => {
|
|
@@ -1591,7 +1630,7 @@ export const priceList = async ( req, res ) => {
|
|
|
1591
1630
|
{
|
|
1592
1631
|
$match: {
|
|
1593
1632
|
clientId: req.body.clientId,
|
|
1594
|
-
|
|
1633
|
+
status: 'active',
|
|
1595
1634
|
},
|
|
1596
1635
|
},
|
|
1597
1636
|
{ $unwind: '$product' },
|
|
@@ -1790,7 +1829,7 @@ async function updatePricing( req, res, update ) {
|
|
|
1790
1829
|
let clientDetails = await paymentService.findOne( { clientId: req.body.clientId } );
|
|
1791
1830
|
if ( clientDetails ) {
|
|
1792
1831
|
let products = clientDetails.planDetails.product.map( ( item ) => item.productName );
|
|
1793
|
-
let
|
|
1832
|
+
let subscriptionProduct = clientDetails.planDetails.product.filter( ( item ) => item.status == 'live' );
|
|
1794
1833
|
let standardList = [];
|
|
1795
1834
|
let stepList = [];
|
|
1796
1835
|
products.forEach( ( product ) => {
|
|
@@ -1848,7 +1887,7 @@ async function updatePricing( req, res, update ) {
|
|
|
1848
1887
|
};
|
|
1849
1888
|
let pricingDetails = await calculatePricing( req, res );
|
|
1850
1889
|
let paymentStatus = clientDetails?.subscriptionType == 'free' ? 'free' : 'trial';
|
|
1851
|
-
if (
|
|
1890
|
+
if ( subscriptionProduct.length ) {
|
|
1852
1891
|
let invoiceCount = await invoiceService.count( { clientId: req.params.clientId, status: 'pending' } );
|
|
1853
1892
|
if ( invoiceCount ) {
|
|
1854
1893
|
paymentStatus ='due';
|
|
@@ -1989,22 +2028,18 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
1989
2028
|
if ( client.planDetails?.product && client.planDetails?.product.length ) {
|
|
1990
2029
|
client.planDetails.product.forEach( async ( item ) => {
|
|
1991
2030
|
if ( item.status == 'trial' && item?.trialEndDate ) {
|
|
1992
|
-
let endDate = dayjs( item.trialEndDate ).startOf( 'day' );
|
|
2031
|
+
let endDate = dayjs( item.trialEndDate ).startOf( 'day' ).add( 1, 'days' );
|
|
1993
2032
|
let date = dayjs().startOf( 'day' );
|
|
1994
2033
|
let leftDays = endDate.diff( date, 'day' );
|
|
1995
|
-
// let date = new Date();
|
|
1996
|
-
// let userTimezoneOffset = item.trialEndDate.getTimezoneOffset() / 60000;
|
|
1997
|
-
// item.trialEndDate = new Date( item.trialEndDate.getTime() - userTimezoneOffset );
|
|
1998
|
-
// item.trialEndDate.setUTCHours( 0, 0, 0, 0 );
|
|
1999
|
-
// const diffTime = parseInt( ( item.trialEndDate - date ) / ( 1000 * 60 * 60 * 24 ), 10 ) + 1;
|
|
2000
2034
|
let userDetails= await userService.findOne( { clientId: client.clientId, role: 'superadmin' } );
|
|
2001
2035
|
if ( userDetails ) {
|
|
2002
2036
|
if ( leftDays == 3 ) {
|
|
2003
2037
|
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
2004
2038
|
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
2005
2039
|
let data = {
|
|
2006
|
-
|
|
2040
|
+
userName: userDetails.userName,
|
|
2007
2041
|
product: firstWord + ' ' + secondWord,
|
|
2042
|
+
domain: appConfig.url.domain,
|
|
2008
2043
|
};
|
|
2009
2044
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialReminderEmail.hbs', 'utf8' );
|
|
2010
2045
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -2067,6 +2102,7 @@ export const getExpiredClientsOld = async ( req, res ) => {
|
|
|
2067
2102
|
let data = {
|
|
2068
2103
|
userName: userDetails.userName,
|
|
2069
2104
|
product: firstWord +' '+secondWord,
|
|
2105
|
+
domain: appConfig.url.domain,
|
|
2070
2106
|
};
|
|
2071
2107
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExpiredEmail.hbs', 'utf8' );
|
|
2072
2108
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -2101,11 +2137,6 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
2101
2137
|
let endDate = dayjs( item.trialEndDate ).startOf( 'day' );
|
|
2102
2138
|
let date = dayjs().startOf( 'day' );
|
|
2103
2139
|
let leftDays = endDate.diff( date, 'day' );
|
|
2104
|
-
// let date = new Date();
|
|
2105
|
-
// let userTimezoneOffset = item.trialEndDate.getTimezoneOffset() / 60000;
|
|
2106
|
-
// item.trialEndDate = new Date( item.trialEndDate.getTime() - userTimezoneOffset );
|
|
2107
|
-
// item.trialEndDate.setUTCHours( 0, 0, 0, 0 );
|
|
2108
|
-
// const diffTime = parseInt( ( item.trialEndDate - date ) / ( 1000 * 60 * 60 * 24 ), 10 ) + 1;
|
|
2109
2140
|
let userDetails= await userService.findOne( { clientId: client.clientId, role: 'superadmin' } );
|
|
2110
2141
|
if ( userDetails ) {
|
|
2111
2142
|
if ( leftDays == -1 ) {
|
|
@@ -2114,6 +2145,7 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
2114
2145
|
let data = {
|
|
2115
2146
|
userName: userDetails.userName,
|
|
2116
2147
|
product: firstWord + ' ' + secondWord,
|
|
2148
|
+
domain: appConfig.url.domain,
|
|
2117
2149
|
};
|
|
2118
2150
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExpiredEmail.hbs', 'utf8' );
|
|
2119
2151
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -242,8 +242,8 @@
|
|
|
242
242
|
<td bgcolor="#ffffff" style="padding: 20px;padding-top:10px;padding-left:30px;">
|
|
243
243
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
244
244
|
<tr>
|
|
245
|
-
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;">
|
|
246
|
-
<a href="
|
|
245
|
+
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;height:50px;">
|
|
246
|
+
<a href="{{data.domain}}" target="_blank"
|
|
247
247
|
style="display: inline-block; padding: 16px 36px; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">Upgrade Now
|
|
248
248
|
</a>
|
|
249
249
|
</td>
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
<td bgcolor="#ffffff" style="padding: 20px;padding-top:30px;padding-left:30px;">
|
|
149
149
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
150
150
|
<tr>
|
|
151
|
-
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;">
|
|
152
|
-
<a href="
|
|
151
|
+
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;height:50px;">
|
|
152
|
+
<a href="{{data.domain}}" target="_blank"
|
|
153
153
|
style="display: inline-block; padding: 16px 36px; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">Upgrade Now
|
|
154
154
|
</a>
|
|
155
155
|
</td>
|
|
@@ -251,8 +251,8 @@
|
|
|
251
251
|
<td bgcolor="#ffffff" style="padding: 20px;padding-top:10px;padding-left:30px;">
|
|
252
252
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
253
253
|
<tr>
|
|
254
|
-
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;">
|
|
255
|
-
<a href="data.
|
|
254
|
+
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;height:50px;">
|
|
255
|
+
<a href="{{data.domain}}" target="_blank"
|
|
256
256
|
style="display: inline-block; padding: 16px 36px; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">View
|
|
257
257
|
Dashboard
|
|
258
258
|
</a>
|
|
@@ -242,8 +242,8 @@
|
|
|
242
242
|
<td bgcolor="#ffffff" style="padding: 20px;padding-top:10px;padding-left:30px;">
|
|
243
243
|
<table border="0" cellpadding="0" cellspacing="0">
|
|
244
244
|
<tr>
|
|
245
|
-
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;">
|
|
246
|
-
<a href="
|
|
245
|
+
<td align="center" bgcolor="#00A3FF" style="border-radius: 6px;height:50px;">
|
|
246
|
+
<a href="{{data.domain}}" target="_blank"
|
|
247
247
|
style="display: inline-block; padding: 16px 36px; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">Upgrade Now
|
|
248
248
|
</a>
|
|
249
249
|
</td>
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
<tr>
|
|
148
148
|
<td align="left" bgcolor="#ffffff"
|
|
149
149
|
style="padding-left: 26px;padding-right: 24px;padding-top:25px; font-size: 16px; line-height: 24px;font-weight:400;color:#384860">
|
|
150
|
-
<p style="margin: 0;">Best, <br>Team Tango
|
|
150
|
+
<p style="margin: 0;">Best, <br>Team Tango
|
|
151
151
|
</p>
|
|
152
152
|
</td>
|
|
153
153
|
</tr>
|
|
@@ -14,7 +14,7 @@ export const validateClient = async ( req, res, next ) => {
|
|
|
14
14
|
if ( req?.params?.clientId ) {
|
|
15
15
|
data = req.params.clientId;
|
|
16
16
|
}
|
|
17
|
-
let clientDetails = await clientPayment.findOne( { clientId: data
|
|
17
|
+
let clientDetails = await clientPayment.findOne( { clientId: data } );
|
|
18
18
|
if ( !clientDetails ) {
|
|
19
19
|
return res.sendError( 'no data found', 204 );
|
|
20
20
|
}
|