tango-app-api-payment-subscription 3.0.58-dev → 3.0.60-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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-payment-subscription",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.60-dev",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"mongodb": "^6.4.0",
|
|
26
26
|
"nodemon": "^3.1.0",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
-
"tango-api-schema": "^2.0.
|
|
29
|
-
"tango-app-api-middleware": "^1.
|
|
28
|
+
"tango-api-schema": "^2.0.115",
|
|
29
|
+
"tango-app-api-middleware": "^3.1.19",
|
|
30
30
|
"winston": "^3.12.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
32
32
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/* eslint-disable new-cap */
|
|
3
|
-
import { logger, download, sendEmailWithSES,
|
|
3
|
+
import { logger, download, sendEmailWithSES, insertOpenSearchData, getOpenSearchData, updateOpenSearchData, getOpenSearchById } from 'tango-app-api-middleware';
|
|
4
4
|
import * as paymentService from '../services/clientPayment.services.js';
|
|
5
5
|
import * as basePriceService from '../services/basePrice.service.js';
|
|
6
6
|
import * as storeService from '../services/store.service.js';
|
|
@@ -49,7 +49,7 @@ export const addBilling = async ( req, res ) => {
|
|
|
49
49
|
eventType: 'update',
|
|
50
50
|
showTo: [ 'client', 'tango' ],
|
|
51
51
|
};
|
|
52
|
-
insertOpenSearchData(
|
|
52
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
53
53
|
return res.sendSuccess( { message: 'Billing Details Added Successfully', data: resultData } );
|
|
54
54
|
} else {
|
|
55
55
|
logger.error( 'Error Occurs WHile updating billing Details' );
|
|
@@ -444,7 +444,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
444
444
|
showTo: [ 'client', 'tango' ],
|
|
445
445
|
csmDetails: requestBody?.csm || [],
|
|
446
446
|
};
|
|
447
|
-
insertOpenSearchData(
|
|
447
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
if ( item.type == 'subscription' ) {
|
|
@@ -476,7 +476,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
476
476
|
showTo: [ 'client', 'tango' ],
|
|
477
477
|
csmDetails: requestBody?.csm || [],
|
|
478
478
|
};
|
|
479
|
-
insertOpenSearchData(
|
|
479
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, productObj );
|
|
480
480
|
} else {
|
|
481
481
|
clientProducts[existsIndex].status = 'live';
|
|
482
482
|
clientProducts[existsIndex].subscribedDate = new Date();
|
|
@@ -502,11 +502,11 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
502
502
|
showTo: [ 'client', 'tango' ],
|
|
503
503
|
csmDetails: requestBody?.csm || [],
|
|
504
504
|
};
|
|
505
|
-
insertOpenSearchData(
|
|
505
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, productObj );
|
|
506
506
|
// productObj.adminNotification = false;
|
|
507
507
|
// productObj.tangoNotification = true;
|
|
508
508
|
productObj.showNotificationTo = 'tango',
|
|
509
|
-
insertOpenSearchData(
|
|
509
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, productObj );
|
|
510
510
|
}
|
|
511
511
|
subscriptionCount = subscriptionCount + 1;
|
|
512
512
|
}
|
|
@@ -543,7 +543,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
543
543
|
mailSubject: 'Subscribe - Tango Eye',
|
|
544
544
|
htmlBody: html,
|
|
545
545
|
attachment: '',
|
|
546
|
-
sourceEmail:
|
|
546
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
547
547
|
};
|
|
548
548
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
549
549
|
}
|
|
@@ -566,7 +566,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
566
566
|
// changes: [ 'Plan Details', 'Price', 'Price Type' ],
|
|
567
567
|
// eventType: 'update',
|
|
568
568
|
// };
|
|
569
|
-
// insertOpenSearchData(
|
|
569
|
+
// insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
570
570
|
let storeProduct = clientProducts.map( ( item ) => item.productName );
|
|
571
571
|
await storeService.updateMany( { clientId: req.params.clientId }, { product: storeProduct } );
|
|
572
572
|
|
|
@@ -577,7 +577,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
577
577
|
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
578
578
|
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
579
579
|
} );
|
|
580
|
-
await axios.get( `${
|
|
580
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandGet/${req.params.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
581
581
|
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
582
582
|
existsProducts.forEach( ( item ) => {
|
|
583
583
|
if ( products.includes( item ) ) {
|
|
@@ -591,7 +591,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
591
591
|
response.data.data.subscribed_features[item] = true;
|
|
592
592
|
}
|
|
593
593
|
} );
|
|
594
|
-
await axios.post( `${
|
|
594
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
595
595
|
logger.info( result.data );
|
|
596
596
|
} ).catch( ( error ) => {
|
|
597
597
|
logger.error( { error: error, function: 'old Product update' } );
|
|
@@ -603,7 +603,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
603
603
|
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
604
604
|
return { id: item.storeId, product: item.product };
|
|
605
605
|
} );
|
|
606
|
-
await axios.post( `${
|
|
606
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
607
607
|
logger.info( 'store Updated Successfully' );
|
|
608
608
|
} ).catch( ( error ) => {
|
|
609
609
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
@@ -699,7 +699,7 @@ export const unsubscribeProduct = async ( req, res ) => {
|
|
|
699
699
|
showPushNotification: true,
|
|
700
700
|
csmDetails: requestBody?.csm || [],
|
|
701
701
|
};
|
|
702
|
-
insertOpenSearchData(
|
|
702
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
703
703
|
|
|
704
704
|
return res.sendSuccess( 'Request Send Successfully' );
|
|
705
705
|
} catch ( e ) {
|
|
@@ -745,7 +745,7 @@ export const trialExtendRequest = async ( req, res ) => {
|
|
|
745
745
|
showPushNotification: true,
|
|
746
746
|
csmDetails: req.body?.csm || [],
|
|
747
747
|
};
|
|
748
|
-
insertOpenSearchData(
|
|
748
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
749
749
|
|
|
750
750
|
return res.sendSuccess( 'Request Send Successfully' );
|
|
751
751
|
} catch ( e ) {
|
|
@@ -792,7 +792,7 @@ export const trialRequest = async ( req, res ) => {
|
|
|
792
792
|
showTo: [ 'client', 'tango' ],
|
|
793
793
|
csmDetails: requestBody?.csm || [],
|
|
794
794
|
};
|
|
795
|
-
insertOpenSearchData(
|
|
795
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
796
796
|
|
|
797
797
|
return res.sendSuccess( 'Request Send Successfully' );
|
|
798
798
|
} catch ( e ) {
|
|
@@ -864,7 +864,7 @@ export const updateInvoiceDetails = async ( req, res ) => {
|
|
|
864
864
|
eventType: 'update',
|
|
865
865
|
showTo: [ 'client', 'tango' ],
|
|
866
866
|
};
|
|
867
|
-
insertOpenSearchData(
|
|
867
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
868
868
|
return res.sendSuccess( 'Invoice Updated Successfully' );
|
|
869
869
|
} ).catch( ( e ) => {
|
|
870
870
|
return res.sendError( e, 500 );
|
|
@@ -985,7 +985,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
985
985
|
showTo: [ 'client', 'tango' ],
|
|
986
986
|
csmDetails: req.body?.csm || [],
|
|
987
987
|
};
|
|
988
|
-
insertOpenSearchData(
|
|
988
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
989
989
|
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId }, { planDetails: 1 } );
|
|
990
990
|
if ( clientProducts?.planDetails.subscriptionType == 'free' ) {
|
|
991
991
|
clientProducts.planDetails.subscriptionType = 'premium';
|
|
@@ -1017,7 +1017,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1017
1017
|
let data = {
|
|
1018
1018
|
userName: userDetails.userName,
|
|
1019
1019
|
product: firstWord + ' ' + secondWord,
|
|
1020
|
-
domain:
|
|
1020
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
1021
1021
|
};
|
|
1022
1022
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
1023
1023
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1027,7 +1027,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1027
1027
|
mailSubject: 'Trial Initiated - Welcome to Tango Suite!',
|
|
1028
1028
|
htmlBody: html,
|
|
1029
1029
|
attachment: '',
|
|
1030
|
-
sourceEmail:
|
|
1030
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1031
1031
|
};
|
|
1032
1032
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1033
1033
|
}
|
|
@@ -1035,7 +1035,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1035
1035
|
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1036
1036
|
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1037
1037
|
} );
|
|
1038
|
-
await axios.get( `${
|
|
1038
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandGet/${requestData.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1039
1039
|
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1040
1040
|
existsProducts.forEach( ( item ) => {
|
|
1041
1041
|
if ( products.includes( item ) ) {
|
|
@@ -1049,7 +1049,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1049
1049
|
response.data.data.subscribed_features[item] = true;
|
|
1050
1050
|
}
|
|
1051
1051
|
} );
|
|
1052
|
-
await axios.post( `${
|
|
1052
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1053
1053
|
logger.info( result.data );
|
|
1054
1054
|
} ).catch( ( error ) => {
|
|
1055
1055
|
logger.error( { error: error, function: 'old Product update' } );
|
|
@@ -1061,7 +1061,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1061
1061
|
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
1062
1062
|
return { id: item.storeId, product: item.product };
|
|
1063
1063
|
} );
|
|
1064
|
-
await axios.post( `${
|
|
1064
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
1065
1065
|
logger.info( 'store Updated Successfully' );
|
|
1066
1066
|
} ).catch( ( error ) => {
|
|
1067
1067
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
@@ -1077,7 +1077,7 @@ export const trialApproval = async ( req, res ) => {
|
|
|
1077
1077
|
// changes: [ 'status' ],
|
|
1078
1078
|
// eventType: 'update',
|
|
1079
1079
|
// };
|
|
1080
|
-
// insertOpenSearchData(
|
|
1080
|
+
// insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1081
1081
|
return res.sendSuccess( 'updated Successfully' );
|
|
1082
1082
|
} );
|
|
1083
1083
|
} catch ( e ) {
|
|
@@ -1115,7 +1115,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1115
1115
|
product: firstWord + ' ' + secondWord,
|
|
1116
1116
|
days: req.body.days,
|
|
1117
1117
|
date: dayjs( trialDate ).format( 'YYYY-MM-DD' ),
|
|
1118
|
-
domain:
|
|
1118
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
1119
1119
|
};
|
|
1120
1120
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExtentionEmail.hbs', 'utf8' );
|
|
1121
1121
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1125,7 +1125,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1125
1125
|
mailSubject: 'TangoEye | Trial Extended - Enjoy More Time with Tango',
|
|
1126
1126
|
htmlBody: html,
|
|
1127
1127
|
attachment: '',
|
|
1128
|
-
sourceEmail:
|
|
1128
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1129
1129
|
};
|
|
1130
1130
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1131
1131
|
}
|
|
@@ -1152,7 +1152,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1152
1152
|
showTo: [ 'client', 'tango' ],
|
|
1153
1153
|
csmDetails: req?.body?.csm || [],
|
|
1154
1154
|
};
|
|
1155
|
-
insertOpenSearchData(
|
|
1155
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, notifyObj );
|
|
1156
1156
|
// const logObj = {
|
|
1157
1157
|
// clientId: req.body.clientId,
|
|
1158
1158
|
// userName: req.user?.userName,
|
|
@@ -1163,7 +1163,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1163
1163
|
// changes: [ 'status' ],
|
|
1164
1164
|
// eventType: 'update',
|
|
1165
1165
|
// };
|
|
1166
|
-
// insertOpenSearchData(
|
|
1166
|
+
// insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1167
1167
|
return res.sendSuccess( 'Trial Extended Successfully' );
|
|
1168
1168
|
} ).catch( ( e ) => {
|
|
1169
1169
|
logger.error( { error: e, function: 'trialExtendRequestApproval' } );
|
|
@@ -1214,7 +1214,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1214
1214
|
timestamp: new Date(),
|
|
1215
1215
|
showTo: [ 'client', 'tango' ],
|
|
1216
1216
|
};
|
|
1217
|
-
insertOpenSearchData(
|
|
1217
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1218
1218
|
await storeService.addremoveElement( { clientId: clientInfo.clientId, product: { $in: item.name } }, { $pull: { product: item.name } } );
|
|
1219
1219
|
await clientRequestService.deleteOne( { clientId: clientInfo.clientId, status: 'pending', name: item.name } );
|
|
1220
1220
|
}
|
|
@@ -1244,9 +1244,9 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1244
1244
|
showTo: [ 'client', 'tango' ],
|
|
1245
1245
|
csmDetails: req.body?.csm || [],
|
|
1246
1246
|
};
|
|
1247
|
-
insertOpenSearchData(
|
|
1247
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1248
1248
|
logObj.showNotificationTo = 'tango';
|
|
1249
|
-
insertOpenSearchData(
|
|
1249
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1250
1250
|
product.push( {
|
|
1251
1251
|
productName: item.name,
|
|
1252
1252
|
trialStartDate: new Date(),
|
|
@@ -1282,9 +1282,9 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1282
1282
|
showTo: [ 'client', 'tango' ],
|
|
1283
1283
|
csmDetails: req.body?.csm || [],
|
|
1284
1284
|
};
|
|
1285
|
-
insertOpenSearchData(
|
|
1285
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1286
1286
|
logObj.showNotificationTo = 'tango';
|
|
1287
|
-
insertOpenSearchData(
|
|
1287
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1288
1288
|
product.push( {
|
|
1289
1289
|
productName: item.name,
|
|
1290
1290
|
subscribedDate: new Date(),
|
|
@@ -1321,9 +1321,9 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1321
1321
|
showTo: [ 'client', 'tango' ],
|
|
1322
1322
|
csmDetails: req.body?.csm || [],
|
|
1323
1323
|
};
|
|
1324
|
-
insertOpenSearchData(
|
|
1324
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1325
1325
|
logObj.showNotificationTo = 'tango';
|
|
1326
|
-
insertOpenSearchData(
|
|
1326
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1327
1327
|
product[productIndex].subscribedDate = new Date();
|
|
1328
1328
|
product[productIndex].status = 'live';
|
|
1329
1329
|
subscriptionCount = subscriptionCount + 1;
|
|
@@ -1349,7 +1349,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1349
1349
|
mailSubject: 'Subscribe - Tango Eye',
|
|
1350
1350
|
htmlBody: html,
|
|
1351
1351
|
attachment: '',
|
|
1352
|
-
sourceEmail:
|
|
1352
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1353
1353
|
};
|
|
1354
1354
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1355
1355
|
}
|
|
@@ -1360,7 +1360,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1360
1360
|
let data = {
|
|
1361
1361
|
userName: userDetails.userName,
|
|
1362
1362
|
product: productEmailName,
|
|
1363
|
-
domain:
|
|
1363
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
1364
1364
|
};
|
|
1365
1365
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
1366
1366
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1370,7 +1370,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1370
1370
|
mailSubject: 'Trial Initiated - Welcome to Tango Suite!',
|
|
1371
1371
|
htmlBody: html,
|
|
1372
1372
|
attachment: '',
|
|
1373
|
-
sourceEmail:
|
|
1373
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1374
1374
|
};
|
|
1375
1375
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1376
1376
|
}
|
|
@@ -1382,7 +1382,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1382
1382
|
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1383
1383
|
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1384
1384
|
} );
|
|
1385
|
-
await axios.get( `${
|
|
1385
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandGet/${clientInfo.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1386
1386
|
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1387
1387
|
existsProducts.forEach( ( item ) => {
|
|
1388
1388
|
if ( products.includes( item ) ) {
|
|
@@ -1396,7 +1396,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1396
1396
|
response.data.data.subscribed_features[item] = true;
|
|
1397
1397
|
}
|
|
1398
1398
|
} );
|
|
1399
|
-
await axios.post( `${
|
|
1399
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1400
1400
|
logger.info( result.data );
|
|
1401
1401
|
} ).catch( ( error ) => {
|
|
1402
1402
|
logger.error( { error: error, function: 'old Product update' } );
|
|
@@ -1408,7 +1408,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1408
1408
|
storeProduct = storeProduct.map( ( item ) => {
|
|
1409
1409
|
return { id: item.storeId, product: item.product };
|
|
1410
1410
|
} );
|
|
1411
|
-
await axios.post( `${
|
|
1411
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBulkStoreUpdate`, storeProduct, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
1412
1412
|
logger.info( 'store Updated Successfully' );
|
|
1413
1413
|
} ).catch( ( error ) => {
|
|
1414
1414
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
@@ -1424,7 +1424,7 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1424
1424
|
// changes: [ 'Plan Details' ],
|
|
1425
1425
|
// eventType: 'update',
|
|
1426
1426
|
// };
|
|
1427
|
-
// insertOpenSearchData(
|
|
1427
|
+
// insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1428
1428
|
return res.sendSuccess( 'Product Subscribed Successfully' );
|
|
1429
1429
|
} catch ( e ) {
|
|
1430
1430
|
logger.error( { error: e, function: 'updateProductSubscribe' } );
|
|
@@ -1460,7 +1460,7 @@ export const unsubscribeApproval = async ( req, res ) => {
|
|
|
1460
1460
|
mailSubject: 'unSubscribe - Tango Eye',
|
|
1461
1461
|
htmlBody: html,
|
|
1462
1462
|
attachment: '',
|
|
1463
|
-
sourceEmail:
|
|
1463
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1464
1464
|
};
|
|
1465
1465
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1466
1466
|
}
|
|
@@ -1476,7 +1476,7 @@ export const unsubscribeApproval = async ( req, res ) => {
|
|
|
1476
1476
|
eventType: '',
|
|
1477
1477
|
showTo: [ 'client', 'tango' ],
|
|
1478
1478
|
};
|
|
1479
|
-
insertOpenSearchData(
|
|
1479
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1480
1480
|
return res.sendSuccess( 'updated Successfully' );
|
|
1481
1481
|
} );
|
|
1482
1482
|
} catch ( e ) {
|
|
@@ -1715,7 +1715,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1715
1715
|
showTo: [ 'client', 'tango' ],
|
|
1716
1716
|
|
|
1717
1717
|
};
|
|
1718
|
-
insertOpenSearchData(
|
|
1718
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1719
1719
|
removedProduct.push( item.name );
|
|
1720
1720
|
}
|
|
1721
1721
|
if ( !productList.includes( item.name ) ) {
|
|
@@ -1776,7 +1776,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1776
1776
|
csmDetails: req.body?.csm || [],
|
|
1777
1777
|
|
|
1778
1778
|
};
|
|
1779
|
-
insertOpenSearchData(
|
|
1779
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1780
1780
|
}
|
|
1781
1781
|
if ( item.type == 'subscription' ) {
|
|
1782
1782
|
clientProduct.push( {
|
|
@@ -1807,10 +1807,10 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1807
1807
|
showTo: [ 'client', 'tango' ],
|
|
1808
1808
|
csmDetails: req.body?.csm || [],
|
|
1809
1809
|
};
|
|
1810
|
-
insertOpenSearchData(
|
|
1810
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1811
1811
|
logObj.showNotificationTo = 'tango';
|
|
1812
1812
|
// logObj.tangoNotification = true;
|
|
1813
|
-
insertOpenSearchData(
|
|
1813
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1814
1814
|
}
|
|
1815
1815
|
}
|
|
1816
1816
|
}
|
|
@@ -1830,7 +1830,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1830
1830
|
mailSubject: 'Subscribe - Tango Eye',
|
|
1831
1831
|
htmlBody: html,
|
|
1832
1832
|
attachment: '',
|
|
1833
|
-
sourceEmail:
|
|
1833
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1834
1834
|
};
|
|
1835
1835
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1836
1836
|
}
|
|
@@ -1841,7 +1841,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1841
1841
|
let data = {
|
|
1842
1842
|
userName: userDetails.userName,
|
|
1843
1843
|
product: productEmailName,
|
|
1844
|
-
domain:
|
|
1844
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
1845
1845
|
};
|
|
1846
1846
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
|
|
1847
1847
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -1851,7 +1851,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1851
1851
|
mailSubject: 'Trial Initiated - Welcome to Tango Suite!',
|
|
1852
1852
|
htmlBody: html,
|
|
1853
1853
|
attachment: '',
|
|
1854
|
-
sourceEmail:
|
|
1854
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1855
1855
|
};
|
|
1856
1856
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1857
1857
|
}
|
|
@@ -1888,12 +1888,12 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1888
1888
|
// changes: [ 'product' ],
|
|
1889
1889
|
// eventType: 'update',
|
|
1890
1890
|
// };
|
|
1891
|
-
// insertOpenSearchData(
|
|
1891
|
+
// insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
1892
1892
|
let products = clientInfo.planDetails.product.map( ( item ) => {
|
|
1893
1893
|
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1894
1894
|
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1895
1895
|
} );
|
|
1896
|
-
await axios.get( `${
|
|
1896
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandGet/${clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1897
1897
|
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1898
1898
|
existsProducts.forEach( ( item ) => {
|
|
1899
1899
|
if ( products.includes( item ) ) {
|
|
@@ -1907,7 +1907,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1907
1907
|
response.data.data.subscribed_features[item] = true;
|
|
1908
1908
|
}
|
|
1909
1909
|
} );
|
|
1910
|
-
await axios.post( `${
|
|
1910
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1911
1911
|
logger.info( result.data );
|
|
1912
1912
|
} ).catch( ( error ) => {
|
|
1913
1913
|
logger.error( { error: error, function: 'old Product update' } );
|
|
@@ -1919,7 +1919,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1919
1919
|
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
1920
1920
|
return { id: item.storeId, product: item.product };
|
|
1921
1921
|
} );
|
|
1922
|
-
await axios.post( `${
|
|
1922
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
1923
1923
|
logger.info( 'store Updated Successfully' );
|
|
1924
1924
|
} ).catch( ( error ) => {
|
|
1925
1925
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
@@ -2265,7 +2265,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
2265
2265
|
mailSubject: 'Invoice Revised',
|
|
2266
2266
|
htmlBody: html,
|
|
2267
2267
|
attachment: '',
|
|
2268
|
-
sourceEmail:
|
|
2268
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
2269
2269
|
};
|
|
2270
2270
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
2271
2271
|
} );
|
|
@@ -2288,7 +2288,7 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
2288
2288
|
eventType: 'update',
|
|
2289
2289
|
showTo: [ 'client', 'tango' ],
|
|
2290
2290
|
};
|
|
2291
|
-
insertOpenSearchData(
|
|
2291
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2292
2292
|
return res.sendSuccess( 'Pricig Updated Successfully' );
|
|
2293
2293
|
} );
|
|
2294
2294
|
} catch ( e ) {
|
|
@@ -2447,7 +2447,7 @@ export const updatedRevisedPrice = async ( req, res ) => {
|
|
|
2447
2447
|
mailSubject: 'Credit Note',
|
|
2448
2448
|
htmlBody: html,
|
|
2449
2449
|
attachment: '',
|
|
2450
|
-
sourceEmail:
|
|
2450
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
2451
2451
|
};
|
|
2452
2452
|
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
2453
2453
|
} );
|
|
@@ -2463,7 +2463,7 @@ export const updatedRevisedPrice = async ( req, res ) => {
|
|
|
2463
2463
|
eventType: 'update',
|
|
2464
2464
|
showTo: [ 'client', 'tango' ],
|
|
2465
2465
|
};
|
|
2466
|
-
insertOpenSearchData(
|
|
2466
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2467
2467
|
return res.sendSuccess( 'Credit notes Updated Successfully' );
|
|
2468
2468
|
} );
|
|
2469
2469
|
} catch ( e ) {
|
|
@@ -2533,7 +2533,7 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
2533
2533
|
let data = {
|
|
2534
2534
|
userName: userDetails.userName,
|
|
2535
2535
|
product: firstWord + ' ' + secondWord,
|
|
2536
|
-
domain:
|
|
2536
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
2537
2537
|
};
|
|
2538
2538
|
let logObj = {
|
|
2539
2539
|
clientId: client.clientId,
|
|
@@ -2554,10 +2554,10 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
2554
2554
|
showTo: [ 'client', 'tango' ],
|
|
2555
2555
|
csmDetails: csmDetails.map( ( item ) => item.userEmail ),
|
|
2556
2556
|
};
|
|
2557
|
-
insertOpenSearchData(
|
|
2557
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2558
2558
|
logObj.showNotificationTo = 'tango';
|
|
2559
2559
|
logObj.alertCta = [];
|
|
2560
|
-
insertOpenSearchData(
|
|
2560
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2561
2561
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialReminderEmail.hbs', 'utf8' );
|
|
2562
2562
|
const template = Handlebars.compile( templateHtml );
|
|
2563
2563
|
const html = template( { data: data } );
|
|
@@ -2566,7 +2566,7 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
2566
2566
|
mailSubject: 'TangoEye | Trial Ending Soon',
|
|
2567
2567
|
htmlBody: html,
|
|
2568
2568
|
attachment: '',
|
|
2569
|
-
sourceEmail:
|
|
2569
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
2570
2570
|
};
|
|
2571
2571
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
2572
2572
|
}
|
|
@@ -2619,7 +2619,7 @@ export const getExpiredClientsOld = async ( req, res ) => {
|
|
|
2619
2619
|
let data = {
|
|
2620
2620
|
userName: userDetails.userName,
|
|
2621
2621
|
product: firstWord + ' ' + secondWord,
|
|
2622
|
-
domain:
|
|
2622
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
2623
2623
|
};
|
|
2624
2624
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExpiredEmail.hbs', 'utf8' );
|
|
2625
2625
|
const template = Handlebars.compile( templateHtml );
|
|
@@ -2629,7 +2629,7 @@ export const getExpiredClientsOld = async ( req, res ) => {
|
|
|
2629
2629
|
mailSubject: 'TangoEye | Trial Expired - Upgrade to Continue',
|
|
2630
2630
|
htmlBody: html,
|
|
2631
2631
|
attachment: '',
|
|
2632
|
-
sourceEmail:
|
|
2632
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
2633
2633
|
};
|
|
2634
2634
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
2635
2635
|
}
|
|
@@ -2663,7 +2663,7 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
2663
2663
|
let data = {
|
|
2664
2664
|
userName: userDetails.userName,
|
|
2665
2665
|
product: firstWord + ' ' + secondWord,
|
|
2666
|
-
domain:
|
|
2666
|
+
domain: JSON.parse( process.env.URL ).domain,
|
|
2667
2667
|
};
|
|
2668
2668
|
let logObj = {
|
|
2669
2669
|
clientId: client.clientId,
|
|
@@ -2687,10 +2687,10 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
2687
2687
|
showTo: [ 'client', 'tango' ],
|
|
2688
2688
|
csmDetails: csmDetails.map( ( item ) => item.userEmail ),
|
|
2689
2689
|
};
|
|
2690
|
-
insertOpenSearchData(
|
|
2690
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2691
2691
|
logObj.showNotificationTo = 'tango';
|
|
2692
2692
|
logObj.alertCta = [];
|
|
2693
|
-
insertOpenSearchData(
|
|
2693
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2694
2694
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExpiredEmail.hbs', 'utf8' );
|
|
2695
2695
|
const template = Handlebars.compile( templateHtml );
|
|
2696
2696
|
const html = template( { data: data } );
|
|
@@ -2699,7 +2699,7 @@ export const getExpiredClients = async ( req, res ) => {
|
|
|
2699
2699
|
mailSubject: 'TangoEye | Trial Expired - Upgrade to Continue',
|
|
2700
2700
|
htmlBody: html,
|
|
2701
2701
|
attachment: '',
|
|
2702
|
-
sourceEmail:
|
|
2702
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
2703
2703
|
};
|
|
2704
2704
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
2705
2705
|
}
|
|
@@ -2895,7 +2895,7 @@ export const updateInvoiceStatus = async ( req, res ) => {
|
|
|
2895
2895
|
eventType: 'update',
|
|
2896
2896
|
showTo: [ 'client', 'tango' ],
|
|
2897
2897
|
};
|
|
2898
|
-
insertOpenSearchData(
|
|
2898
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
2899
2899
|
return res.sendSuccess( 'Invoice updated Successfully' );
|
|
2900
2900
|
} );
|
|
2901
2901
|
} catch ( e ) {
|
|
@@ -3035,6 +3035,10 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3035
3035
|
requestClient.push( ...requestData.clientId );
|
|
3036
3036
|
}
|
|
3037
3037
|
|
|
3038
|
+
if ( !requestData?.date ) {
|
|
3039
|
+
requestData.date = dayjs().format( 'YYYY-MM-DD' );
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3038
3042
|
if ( requestData.clientId && requestClient.length > 0 ) {
|
|
3039
3043
|
for ( let clientIndex = 0; clientIndex < requestClient.length; clientIndex++ ) {
|
|
3040
3044
|
let getClient = await paymentService.findOne( { clientId: requestClient[clientIndex] } );
|
|
@@ -3077,7 +3081,7 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3077
3081
|
}
|
|
3078
3082
|
}
|
|
3079
3083
|
|
|
3080
|
-
await axios.get( `${
|
|
3084
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/processedDayData/getDailyData?clientId=${requestClient[clientIndex]}&storeId=${getStore[storeIndex].storeId}&date=${requestData.date}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
3081
3085
|
let processedFileDate = response.data?.data?.firstFileDate || null;
|
|
3082
3086
|
let query = [
|
|
3083
3087
|
{
|
|
@@ -3154,6 +3158,153 @@ export const dailyPricingInsert = async ( req, res ) => {
|
|
|
3154
3158
|
}
|
|
3155
3159
|
};
|
|
3156
3160
|
|
|
3161
|
+
export const dailyPricingInsertV1 = async ( req, res ) => {
|
|
3162
|
+
try {
|
|
3163
|
+
let requestData = req.body;
|
|
3164
|
+
let clientlist;
|
|
3165
|
+
let requestClient = [];
|
|
3166
|
+
if ( !requestData?.clientId || !requestData?.clientId?.length ) {
|
|
3167
|
+
clientlist = await paymentService.find( { 'status': 'active' } );
|
|
3168
|
+
for ( let client of clientlist ) {
|
|
3169
|
+
requestClient.push( client.clientId );
|
|
3170
|
+
}
|
|
3171
|
+
} else {
|
|
3172
|
+
requestClient.push( ...requestData.clientId );
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
if ( !requestData?.date ) {
|
|
3176
|
+
requestData.date = dayjs().format( 'YYYY-MM-DD' );
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
let dayList = [ requestData.date ];
|
|
3180
|
+
|
|
3181
|
+
for ( let i=1; i<requestData.days; i++ ) {
|
|
3182
|
+
dayList.push( dayjs( requestData.date ).add( i, 'day' ).format( 'YYYY-MM-DD' ) );
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
if ( requestData.clientId && requestClient.length > 0 ) {
|
|
3186
|
+
for ( let i=0; i<dayList.length; i++ ) {
|
|
3187
|
+
requestData.date = dayList[i];
|
|
3188
|
+
for ( let clientIndex = 0; clientIndex < requestClient.length; clientIndex++ ) {
|
|
3189
|
+
let getClient = await paymentService.findOne( { clientId: requestClient[clientIndex] } );
|
|
3190
|
+
if ( getClient ) {
|
|
3191
|
+
let getBaseprice = await basePriceService.findOne( { clientId: requestClient[clientIndex] } );
|
|
3192
|
+
let getStore = await storeService.find( { clientId: requestClient[clientIndex] } );
|
|
3193
|
+
if ( getStore.length ) {
|
|
3194
|
+
let storeList = [];
|
|
3195
|
+
for ( let storeIndex = 0; storeIndex < getStore.length; storeIndex++ ) {
|
|
3196
|
+
let productList = [];
|
|
3197
|
+
if ( getBaseprice ) {
|
|
3198
|
+
let priceDetails = getClient.priceType == 'standard' ? getBaseprice.standard : getBaseprice.step;
|
|
3199
|
+
for ( let storeProductIndex = 0; storeProductIndex < getStore[storeIndex].product.length; storeProductIndex++ ) {
|
|
3200
|
+
let productDetails;
|
|
3201
|
+
if ( getClient.priceType == 'standard' ) {
|
|
3202
|
+
productDetails = priceDetails.find( ( item ) => item.productName == getStore[storeIndex].product[storeProductIndex] );
|
|
3203
|
+
} else {
|
|
3204
|
+
productDetails = priceDetails.find( ( item ) => {
|
|
3205
|
+
let range = item.storeRange.split( '-' );
|
|
3206
|
+
if ( parseInt( range[0] ) <= ( storeIndex + 1 ) && parseInt( range[1] ) >= ( storeIndex + 1 ) ) {
|
|
3207
|
+
return ( item.productName == getStore[storeIndex].product[storeProductIndex] && parseInt( range[0] ) <= ( storeIndex + 1 ) && parseInt( range[1] ) >= ( storeIndex + 1 ) );
|
|
3208
|
+
}
|
|
3209
|
+
} );
|
|
3210
|
+
if ( !productDetails ) {
|
|
3211
|
+
let stepProductDetails = priceDetails.filter( ( item ) => item.productName == getStore[storeIndex].product[storeProductIndex] );
|
|
3212
|
+
productDetails = stepProductDetails[stepProductDetails.length - 1];
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
// let productStatus = getClient.planDetails.product.find( ( item ) => item.productName == getStore[storeIndex].product[storeProductIndex] );
|
|
3216
|
+
if ( productDetails ) {
|
|
3217
|
+
let newObject = {
|
|
3218
|
+
productName: productDetails.productName,
|
|
3219
|
+
// status: productStatus ? productStatus.status : '',
|
|
3220
|
+
// price: productStatus ? [ 'trial', 'free' ].includes( productStatus.status ) ? 0 : productDetails.negotiatePrice : 0,
|
|
3221
|
+
// featureStoreCount: storeIndex + 1,
|
|
3222
|
+
// basePrice: productDetails.negotiatePrice,
|
|
3223
|
+
...( getClient.priceType == 'step' ? { storeRange: productDetails.storeRange } : { storeRange: 'standard' } ),
|
|
3224
|
+
};
|
|
3225
|
+
productList.push( newObject );
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
await axios.get( `${JSON.parse( process.env.URL ).oldapidomain}/processedDayData/getDailyData?clientId=${requestClient[clientIndex]}&storeId=${getStore[storeIndex].storeId}&date=${requestData.date}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
3230
|
+
let processedFileDate = response.data?.data?.firstFileDate || null;
|
|
3231
|
+
let query = [
|
|
3232
|
+
{
|
|
3233
|
+
$match: {
|
|
3234
|
+
clientId: requestClient[clientIndex],
|
|
3235
|
+
},
|
|
3236
|
+
},
|
|
3237
|
+
{ $unwind: '$stores' },
|
|
3238
|
+
{
|
|
3239
|
+
$match: {
|
|
3240
|
+
'stores.storeId': getStore[storeIndex].storeId,
|
|
3241
|
+
},
|
|
3242
|
+
},
|
|
3243
|
+
{
|
|
3244
|
+
$project: {
|
|
3245
|
+
'stores.daysDifference': 1,
|
|
3246
|
+
'dateString': 1,
|
|
3247
|
+
},
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
$sort: {
|
|
3251
|
+
_id: -1,
|
|
3252
|
+
},
|
|
3253
|
+
},
|
|
3254
|
+
{ $limit: 1 },
|
|
3255
|
+
];
|
|
3256
|
+
let dailyData = await dailyPriceService.aggregate( query );
|
|
3257
|
+
let cameraDetails = await cameraService.find( { storeId: getStore[storeIndex].storeId, clientId: requestClient[clientIndex], isActivated: true, isUp: true }, { streamName: 1 } );
|
|
3258
|
+
let firstDate = dayjs( getStore[storeIndex]?.edge?.firstFileDate ).format( 'YYYY-MM-DD' );
|
|
3259
|
+
storeList.push(
|
|
3260
|
+
{
|
|
3261
|
+
storeId: getStore[storeIndex].storeId,
|
|
3262
|
+
store: getStore[storeIndex]._id,
|
|
3263
|
+
storeName: getStore[storeIndex].storeName,
|
|
3264
|
+
status: getStore[storeIndex]?.status,
|
|
3265
|
+
firstFile: getStore[storeIndex]?.edge?.firstFile || false,
|
|
3266
|
+
edgefirstFileDate: getStore[storeIndex]?.edge?.firstFileDate || null,
|
|
3267
|
+
date: new Date( requestData.date ),
|
|
3268
|
+
processfirstFileDate: processedFileDate?.date_iso || null,
|
|
3269
|
+
daysDifference: ( firstDate < requestData.date && getStore[storeIndex]?.status == 'active' && dailyData[0]?.dateString != dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) ) ? ( dailyData.length && dailyData[0]?.stores?.daysDifference ) ? ( dailyData[0]?.stores?.daysDifference + 1 ) : 1 : dailyData[0]?.stores?.daysDifference ? dailyData[0]?.stores?.daysDifference : 0,
|
|
3270
|
+
products: productList,
|
|
3271
|
+
camera: cameraDetails.map( ( item ) => item.streamName ),
|
|
3272
|
+
cameraCount: cameraDetails.length,
|
|
3273
|
+
},
|
|
3274
|
+
);
|
|
3275
|
+
if ( storeIndex == getStore.length - 1 ) {
|
|
3276
|
+
let params = {
|
|
3277
|
+
clientId: requestClient[clientIndex],
|
|
3278
|
+
stores: storeList,
|
|
3279
|
+
dateISO: new Date( requestData.date ),
|
|
3280
|
+
accountType: getClient?.planDetails?.subscriptionType,
|
|
3281
|
+
status: getClient?.status,
|
|
3282
|
+
activeStores: getStore?.length,
|
|
3283
|
+
brandName: getClient?.clientName,
|
|
3284
|
+
proRate: getClient?.paymentInvoice?.proRate,
|
|
3285
|
+
dateString: dayjs( requestData.date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ),
|
|
3286
|
+
};
|
|
3287
|
+
await dailyPriceService.updateOne( { clientId: requestClient[clientIndex], dateString: params.dateString }, params, { upsert: true } );
|
|
3288
|
+
}
|
|
3289
|
+
} ).catch( ( error ) => {
|
|
3290
|
+
logger.error( { error: error, function: 'old processedDayData' } );
|
|
3291
|
+
} );
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
if ( i == dayList.length - 1 ) {
|
|
3297
|
+
return res.sendSuccess( 'Price Details Inserted Successfully' );
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
} catch ( e ) {
|
|
3303
|
+
logger.error( { error: e, function: 'invoiceCreate' } );
|
|
3304
|
+
return res.sendError( e, 500 );
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
|
|
3157
3308
|
export const invoiceGenerate = async ( req, res ) => {
|
|
3158
3309
|
try {
|
|
3159
3310
|
// let requestData = req.body;
|
|
@@ -3379,7 +3530,7 @@ export const invoiceRevised = async ( req, res ) => {
|
|
|
3379
3530
|
mailSubject: 'Invoice Revised Successfully',
|
|
3380
3531
|
htmlBody: html,
|
|
3381
3532
|
attachment: '',
|
|
3382
|
-
sourceEmail:
|
|
3533
|
+
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
3383
3534
|
};
|
|
3384
3535
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
3385
3536
|
return res.sendSuccess( 'Invoice Revised Successfully' );
|
|
@@ -3432,7 +3583,7 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3432
3583
|
],
|
|
3433
3584
|
// _source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
|
|
3434
3585
|
};
|
|
3435
|
-
let result = await getOpenSearchData(
|
|
3586
|
+
let result = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, query );
|
|
3436
3587
|
if ( !result || !result.body.hits.hits.length ) {
|
|
3437
3588
|
return res.sendError( 'no data found', 204 );
|
|
3438
3589
|
}
|
|
@@ -3445,14 +3596,14 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3445
3596
|
|
|
3446
3597
|
export const updateNotification = async ( req, res ) => {
|
|
3447
3598
|
try {
|
|
3448
|
-
let openSearchDetails = await getOpenSearchById(
|
|
3599
|
+
let openSearchDetails = await getOpenSearchById( JSON.parse( process.env.OPENSEARCH ).activityLog, req.params.notificationId );
|
|
3449
3600
|
if ( openSearchDetails && openSearchDetails?.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3450
3601
|
const document = {
|
|
3451
3602
|
doc: {
|
|
3452
3603
|
markasRead: true,
|
|
3453
3604
|
},
|
|
3454
3605
|
};
|
|
3455
|
-
let updateResult = await updateOpenSearchData(
|
|
3606
|
+
let updateResult = await updateOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, req.params.notificationId, document );
|
|
3456
3607
|
if ( updateResult?.statusCode == 200 && updateResult?.body?.result == 'updated' ) {
|
|
3457
3608
|
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3458
3609
|
}
|
|
@@ -3468,14 +3619,14 @@ export const updateNotification = async ( req, res ) => {
|
|
|
3468
3619
|
|
|
3469
3620
|
export const updatePushNotification = async ( req, res ) => {
|
|
3470
3621
|
try {
|
|
3471
|
-
let openSearchDetails = await getOpenSearchById(
|
|
3622
|
+
let openSearchDetails = await getOpenSearchById( JSON.parse( process.env.OPENSEARCH ).activityLog, req.params.notificationId );
|
|
3472
3623
|
if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3473
3624
|
const document = {
|
|
3474
3625
|
doc: {
|
|
3475
3626
|
showPushNotification: false,
|
|
3476
3627
|
},
|
|
3477
3628
|
};
|
|
3478
|
-
let updateResult = await updateOpenSearchData(
|
|
3629
|
+
let updateResult = await updateOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, req.params.notificationId, document );
|
|
3479
3630
|
if ( updateResult?.statusCode == 200 ) {
|
|
3480
3631
|
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3481
3632
|
}
|
|
@@ -3491,12 +3642,12 @@ export const updatePushNotification = async ( req, res ) => {
|
|
|
3491
3642
|
|
|
3492
3643
|
export const updateRemind = async ( req, res ) => {
|
|
3493
3644
|
try {
|
|
3494
|
-
let openSearchDetails = await getOpenSearchById(
|
|
3645
|
+
let openSearchDetails = await getOpenSearchById( JSON.parse( process.env.OPENSEARCH ).activityLog, req.params.notificationId );
|
|
3495
3646
|
if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3496
3647
|
let date = new Date( new Date( openSearchDetails.body._source.date ).getTime() + 24 * 60 * 60 * 1000 );
|
|
3497
3648
|
openSearchDetails.body._source.date = date;
|
|
3498
3649
|
openSearchDetails.body._source.markasRead = false;
|
|
3499
|
-
insertOpenSearchData(
|
|
3650
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, openSearchDetails.body._source );
|
|
3500
3651
|
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3501
3652
|
} else {
|
|
3502
3653
|
return res.sendError( 'no data found', 204 );
|
|
@@ -196,8 +196,8 @@ export const validateUpdateSubscriptionParams = {
|
|
|
196
196
|
};
|
|
197
197
|
|
|
198
198
|
export const dailyPricingSchema = joi.object( {
|
|
199
|
-
clientId: joi.array().
|
|
200
|
-
date: joi.string().
|
|
199
|
+
clientId: joi.array().optional(),
|
|
200
|
+
date: joi.string().optional(),
|
|
201
201
|
} );
|
|
202
202
|
|
|
203
203
|
export const dailyPricingParams = {
|
|
@@ -159,6 +159,7 @@ paymentSubscriptionRouter.post( '/invoiceStatusUpdate/:invoiceId', validate( val
|
|
|
159
159
|
paymentSubscriptionRouter.post( '/invoice/create', validateClient, paymentController.invoiceCreate );
|
|
160
160
|
paymentSubscriptionRouter.post( '/invoiceGenerate', paymentController.invoiceGenerate );
|
|
161
161
|
paymentSubscriptionRouter.post( '/dailyPricing/insert', validate( validationDtos.dailyPricingParams ), paymentController.dailyPricingInsert );
|
|
162
|
+
paymentSubscriptionRouter.post( '/dailyPricing/insertOld', paymentController.dailyPricingInsertV1 );
|
|
162
163
|
paymentSubscriptionRouter.get( '/invoiceRevised/:invoiceId', validate( validationDtos.invoiceRevisedParams ), paymentController.invoiceRevised );
|
|
163
164
|
paymentSubscriptionRouter.get( '/notificationList', isAllowedSessionHandler, validate( validationDtos.notificationParams ), paymentController.clientNotificationList );
|
|
164
165
|
paymentSubscriptionRouter.put( '/notification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateNotification );
|