tango-app-api-payment-subscription 3.0.49-dev → 3.0.51-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.51-dev",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
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.
|
|
28
|
+
"tango-api-schema": "^2.0.104",
|
|
29
29
|
"tango-app-api-middleware": "^1.0.72-test",
|
|
30
30
|
"winston": "^3.12.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -462,6 +462,24 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
462
462
|
} else {
|
|
463
463
|
clientProducts[existsIndex].status = 'live';
|
|
464
464
|
clientProducts[existsIndex].subscribedDate = new Date();
|
|
465
|
+
let productObj = {
|
|
466
|
+
userName: req.user?.userName,
|
|
467
|
+
email: req.user?.email,
|
|
468
|
+
clientId: requestBody.clientId,
|
|
469
|
+
clientNotification: false,
|
|
470
|
+
adminNotification: true,
|
|
471
|
+
title: 'Subscription',
|
|
472
|
+
description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
|
|
473
|
+
alertCta: [],
|
|
474
|
+
markasRead: false,
|
|
475
|
+
logType: 'subscription',
|
|
476
|
+
logSubType: 'subscription',
|
|
477
|
+
showPushNotification: true,
|
|
478
|
+
changes: [ `${convertTitleCase( item.name )} subscribed` ],
|
|
479
|
+
eventType: '',
|
|
480
|
+
date: new Date(),
|
|
481
|
+
};
|
|
482
|
+
insertOpenSearchData( appConfig.opensearch.activityLog, productObj );
|
|
465
483
|
}
|
|
466
484
|
subscriptionCount = subscriptionCount + 1;
|
|
467
485
|
}
|
|
@@ -469,17 +487,17 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
469
487
|
|
|
470
488
|
let details = {
|
|
471
489
|
subscriptionType: premiumType,
|
|
472
|
-
subscriptionPeriod: requestBody
|
|
473
|
-
totalCamera: requestBody.totalCamera,
|
|
474
|
-
totalStores: requestBody.totalStores,
|
|
475
|
-
storeSize: requestBody
|
|
490
|
+
subscriptionPeriod: requestBody?.subscriptionPeriod || requestBody?.client?.planDetails?.subscriptionPeriod,
|
|
491
|
+
totalCamera: requestBody.totalCamera || requestBody?.client?.planDetails?.totalCamera,
|
|
492
|
+
totalStores: requestBody.totalStores || requestBody?.client?.planDetails?.totalStores,
|
|
493
|
+
storeSize: requestBody?.storeSize || requestBody?.client?.planDetails?.storeSize,
|
|
476
494
|
product: clientProducts,
|
|
477
495
|
};
|
|
478
496
|
|
|
479
497
|
req.body = {
|
|
480
|
-
'camaraPerSqft':
|
|
481
|
-
'storesCount':
|
|
482
|
-
'planName':
|
|
498
|
+
'camaraPerSqft': details.storeSize,
|
|
499
|
+
'storesCount': details.totalStores,
|
|
500
|
+
'planName': details.subscriptionPeriod,
|
|
483
501
|
'products': clientProducts.map( ( item ) => item.productName ),
|
|
484
502
|
'currencyType': 'rupees',
|
|
485
503
|
};
|
|
@@ -506,7 +524,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
506
524
|
let data = {
|
|
507
525
|
planDetails: details,
|
|
508
526
|
price: pricingDetails.price,
|
|
509
|
-
priceType: requestBody
|
|
527
|
+
priceType: requestBody?.priceType || requestBody?.client?.priceType,
|
|
510
528
|
|
|
511
529
|
};
|
|
512
530
|
|
|
@@ -1022,9 +1040,9 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1022
1040
|
requestData.save();
|
|
1023
1041
|
}
|
|
1024
1042
|
let userDetails = await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
|
|
1043
|
+
let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1044
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
1025
1045
|
if ( userDetails ) {
|
|
1026
|
-
let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1027
|
-
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
1028
1046
|
let data = {
|
|
1029
1047
|
userName: userDetails.userName,
|
|
1030
1048
|
product: firstWord + ' ' + secondWord,
|
|
@@ -1060,7 +1078,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1060
1078
|
logType: 'subscription',
|
|
1061
1079
|
showPushNotification: true,
|
|
1062
1080
|
date: new Date(),
|
|
1063
|
-
changes: [ `${
|
|
1081
|
+
changes: [ `${firstWord + ' ' + secondWord} trial Extended` ],
|
|
1064
1082
|
eventType: '',
|
|
1065
1083
|
};
|
|
1066
1084
|
insertOpenSearchData( appConfig.opensearch.activityLog, notifyObj );
|
|
@@ -2390,10 +2408,10 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
2390
2408
|
clientId: client.clientId,
|
|
2391
2409
|
clientNotification: false,
|
|
2392
2410
|
adminNotification: true,
|
|
2393
|
-
description: 'Subscription - Your Free trial is about to expire in 3 days.
|
|
2411
|
+
description: 'Subscription - Your Free trial is about to expire in 3 days. Please make sure to subscribe to the products',
|
|
2394
2412
|
logSubType: 'trialReminder',
|
|
2395
2413
|
title: 'Subscription',
|
|
2396
|
-
alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: '
|
|
2414
|
+
alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'subscribed', product: item.productName, name: data.product, clientId: client.clientId }, { buttonName: 'Remind me later', redirectionUrl: 'remind' } ],
|
|
2397
2415
|
markasRead: false,
|
|
2398
2416
|
logType: 'subscription',
|
|
2399
2417
|
showPushNotification: true,
|
|
@@ -3077,6 +3095,13 @@ export const invoiceRevised = async ( req, res ) => {
|
|
|
3077
3095
|
export const clientNotificationList = async ( req, res ) => {
|
|
3078
3096
|
try {
|
|
3079
3097
|
let from = ( req.query.offset - 1 ) * req.query.limit;
|
|
3098
|
+
let start = new Date();
|
|
3099
|
+
let userTimezoneOffset = start.getTimezoneOffset() * 60000;
|
|
3100
|
+
start = new Date( start.getTime() - userTimezoneOffset );
|
|
3101
|
+
start.setUTCHours( 0, 0, 0, 0 );
|
|
3102
|
+
let end = new Date();
|
|
3103
|
+
end = new Date( end.getTime() - userTimezoneOffset );
|
|
3104
|
+
end.setUTCHours( 23, 59, 59, 59 );
|
|
3080
3105
|
let query;
|
|
3081
3106
|
if ( req.user.role == 'superadmin' ) {
|
|
3082
3107
|
query = {
|
|
@@ -3089,9 +3114,17 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3089
3114
|
// { match: { logType: 'notification' } },
|
|
3090
3115
|
{ match: { adminNotification: true } },
|
|
3091
3116
|
{ match: { markasRead: false } },
|
|
3117
|
+
{ range: { date: { gte: start, lte: end } } },
|
|
3092
3118
|
],
|
|
3093
3119
|
},
|
|
3094
3120
|
},
|
|
3121
|
+
sort: [
|
|
3122
|
+
{
|
|
3123
|
+
date: {
|
|
3124
|
+
order: 'desc',
|
|
3125
|
+
},
|
|
3126
|
+
},
|
|
3127
|
+
],
|
|
3095
3128
|
_source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
|
|
3096
3129
|
};
|
|
3097
3130
|
} else {
|
|
@@ -3103,9 +3136,17 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3103
3136
|
// { match: { type: 'notification' } },
|
|
3104
3137
|
{ match: { clientNotification: true } },
|
|
3105
3138
|
{ match: { markasRead: false } },
|
|
3139
|
+
{ range: { date: { gte: start, lte: end } } },
|
|
3106
3140
|
],
|
|
3107
3141
|
},
|
|
3108
3142
|
},
|
|
3143
|
+
sort: [
|
|
3144
|
+
{
|
|
3145
|
+
date: {
|
|
3146
|
+
order: 'desc',
|
|
3147
|
+
},
|
|
3148
|
+
},
|
|
3149
|
+
],
|
|
3109
3150
|
_source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
|
|
3110
3151
|
};
|
|
3111
3152
|
}
|
|
@@ -3166,6 +3207,24 @@ export const updatePushNotification = async ( req, res ) => {
|
|
|
3166
3207
|
}
|
|
3167
3208
|
};
|
|
3168
3209
|
|
|
3210
|
+
export const updateRemind = async ( req, res ) => {
|
|
3211
|
+
try {
|
|
3212
|
+
let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
|
|
3213
|
+
if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3214
|
+
let date = new Date( new Date( openSearchDetails.body._source.date ).getTime() + 24 * 60 * 60 * 1000 );
|
|
3215
|
+
openSearchDetails.body._source.date = date;
|
|
3216
|
+
openSearchDetails.body._source.markasRead = false;
|
|
3217
|
+
insertOpenSearchData( appConfig.opensearch.activityLog, openSearchDetails.body._source );
|
|
3218
|
+
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3219
|
+
} else {
|
|
3220
|
+
return res.sendError( 'no data found', 204 );
|
|
3221
|
+
}
|
|
3222
|
+
} catch ( e ) {
|
|
3223
|
+
logger.error( { error: e, function: 'updatePushNotification' } );
|
|
3224
|
+
return res.sendError( e, 500 );
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3169
3228
|
|
|
3170
3229
|
function convertTitleCase( data ) {
|
|
3171
3230
|
let [ firstWord, secondWord ] = data.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
@@ -3173,3 +3232,5 @@ function convertTitleCase( data ) {
|
|
|
3173
3232
|
data = firstWord + ' ' + secondWord;
|
|
3174
3233
|
return data;
|
|
3175
3234
|
}
|
|
3235
|
+
|
|
3236
|
+
|
|
@@ -181,13 +181,13 @@ export const validateStoreProductsParams = {
|
|
|
181
181
|
|
|
182
182
|
export const validateUpdateSubscriptionSchema =joi.object( {
|
|
183
183
|
clientId: joi.string().required(),
|
|
184
|
-
price: joi.number().
|
|
185
|
-
priceType: joi.string().
|
|
186
|
-
subscriptionType: joi.string().
|
|
187
|
-
subscriptionPeriod: joi.string().
|
|
188
|
-
totalCamera: joi.number().
|
|
189
|
-
totalStores: joi.string().
|
|
190
|
-
storeSize: joi.string().
|
|
184
|
+
price: joi.number().optional(),
|
|
185
|
+
priceType: joi.string().optional(),
|
|
186
|
+
subscriptionType: joi.string().optional(),
|
|
187
|
+
subscriptionPeriod: joi.string().optional(),
|
|
188
|
+
totalCamera: joi.number().optional(),
|
|
189
|
+
totalStores: joi.string().optional(),
|
|
190
|
+
storeSize: joi.string().optional(),
|
|
191
191
|
products: joi.array().required(),
|
|
192
192
|
} );
|
|
193
193
|
|
|
@@ -163,4 +163,5 @@ paymentSubscriptionRouter.get( '/invoiceRevised/:invoiceId', validate( validatio
|
|
|
163
163
|
paymentSubscriptionRouter.get( '/notificationList', isAllowedSessionHandler, validate( validationDtos.notificationParams ), paymentController.clientNotificationList );
|
|
164
164
|
paymentSubscriptionRouter.put( '/notification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateNotification );
|
|
165
165
|
paymentSubscriptionRouter.put( '/pushNotification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updatePushNotification );
|
|
166
|
+
paymentSubscriptionRouter.post( '/updateRemind/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateRemind );
|
|
166
167
|
|