Browse Source

Merge pull request 'feat/addCornJob' (#1) from feat/addCornJob into master

Reviewed-on: https://git.nivesh.com:443/akhilesh.chandak/P2P_Liquiloan_Script/pulls/1
master
akhilesh.chandak 1 year ago
parent
commit
3ca1ee1ade
20 changed files with 2591 additions and 63 deletions
  1. +5
    -1
      app.js
  2. +13
    -0
      controller/Errorlog/index.js
  3. +0
    -16
      controller/fetchInvestorData.js
  4. +101
    -0
      controller/getAllInvestor/index.js
  5. +16
    -0
      controller/getAllInvestor/query.js
  6. +33
    -0
      controller/getHashvalue.js
  7. +156
    -0
      controller/getInvestmentSummary/index.js
  8. +16
    -0
      controller/getInvestmentSummary/query.js
  9. +141
    -0
      controller/getTransactionById/index.js
  10. +16
    -0
      controller/getTransactionById/query.js
  11. +17
    -0
      controller/helper.js
  12. +48
    -0
      model/investorSummary.js
  13. +2
    -1
      model/liquiloansInvestors.js
  14. +38
    -0
      model/transactionById.js
  15. +1936
    -4
      package-lock.json
  16. +7
    -1
      package.json
  17. +15
    -1
      routes/script.js
  18. +5
    -4
      utils/consts.js
  19. +2
    -30
      utils/db_config.js
  20. +24
    -5
      utils/scheduler.js

+ 5
- 1
app.js View File

@ -12,6 +12,8 @@ const rfs = require('rotating-file-stream');
const logDirectory = path.join(__dirname, 'log') const logDirectory = path.join(__dirname, 'log')
const port = process.env.PORT || 5000; const port = process.env.PORT || 5000;
// view engine setup // view engine setup
app.engine('pug', require('pug').__express)
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug'); app.set('view engine', 'pug');
@ -35,7 +37,9 @@ app.use('/script', scriptRouter);
/* SCHEDULER */ /* SCHEDULER */
//scheduler.routineFetchInvestors();
scheduler.routineFetchAllInvestors();
scheduler.routineGetInvestmentSummary();
scheduler.routineGetTransactionById();
// catch 404 and forward to error handler // catch 404 and forward to error handler


+ 13
- 0
controller/Errorlog/index.js View File

@ -0,0 +1,13 @@
const db = require("../../utils/db_config");
const { getCurrentDateTime } = require("../helper");
function errorLogStatus(error = null, funName = null) {
let query = `INSERT INTO providentialadvisory.dbo.User_log
(client_code, request, status, response, created_date, created_by, api_name, Open_Close_Status, IPAddress, DeviceId, [Source], Header)
VALUES('', '${error}','', '', '${getCurrentDateTime()}', '', '${funName}', '', '', '', '', '')`;
return db.sequelize.query(query, { type: db.sequelize.QueryTypes.INSERT });
}
module.exports = {
errorLogStatus
}

+ 0
- 16
controller/fetchInvestorData.js View File

@ -1,16 +0,0 @@
'use strict'
const request = require("request");
const constants = require('../utils/consts');
const db = require('../utils/db_config');
const createLiquiloanInvestor = (req, res) => {
res.send("in process");
}
module.exports = {
createLiquiloanInvestor
}

+ 101
- 0
controller/getAllInvestor/index.js View File

@ -0,0 +1,101 @@
'use strict'
const request = require('request');
const db = require('../../utils/db_config');
const { getCurrentDateTime } = require("../helper");
const { getAllInvestorId } = require('../getInvestmentSummary')
const crypto = require('crypto');
const { HASH_KEY } = require('../../utils/consts');
const { getInvestorIdQuery } = require('./query');
const { errorLogStatus } = require('../Errorlog');
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8');
return hmac.digest('hex');
}
function getHashCode(req) {
const inputString_GetInvestorDashboard = `||${getCurrentDateTime()}`;
const key = HASH_KEY;
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
return hash_GetInvestorDashboard
}
const fetchInvestorDetails = ((req, res) => {
getAllInvstorData();
res.send("in procress");
})
const getAllInvstorData = async () => {
var options = {
method: 'POST',
url: 'https://supply-integration.liquiloans.com/api/v2/GetAllInvestors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mid: "M00201",
checksum: getHashCode(),
timestamp: getCurrentDateTime(),
filter_on: "",
filter_data: []
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
getAllInvstorDataStore(response.body);
});
}
const getAllInvstorDataStore = async (body) => {
try {
const records = JSON.parse(body)
let item = records?.data
let storeData = [];
if (item.length) {
for (let i = 0; i < item?.length; i++) {
let log = await getInvestorIdQuery(item[i].investor_id);
if (log == 0) {
let data = {};
data.investor_id = item[i].investor_id,
data.name = item[i].name,
data.entity_type = item[i].entity_type,
data.pan = item[i].pan,
data.email = item[i].email,
data.contact_number = item[i].contact_number,
data.ifa_id = item[i].ifa_id,
data.created_at = item[i].created_at,
data.rm_name = item[i].rm_name,
data.last_updatedAt = new Date
storeData.push(data);
}
}
await db.liquiloansInvestors.bulkCreate(storeData);
}
} catch (err) {
errorLogStatus(err, "nodeJs_liquiloan_getAllInvstorDataStore")
}
}
// const isInvestorPresent = async (id) => {
// try {
// await getInvestorIdQuery(id)
// } catch (err) {
// // console.log("isInvestorPresent", err.message)
// errorLogStatus(err, "nodeJs_liquiloan_isInvestorPresent")
// }
// }
module.exports = {
fetchInvestorDetails
}

+ 16
- 0
controller/getAllInvestor/query.js View File

@ -0,0 +1,16 @@
const db = require("../../utils/db_config");
const { errorLogStatus } = require("../Errorlog");
async function getInvestorIdQuery(id) {
try {
let query = `select * from dbo.P2P_Liquiloans_Investors where investor_id= '${id}'`;
return await db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
} catch (error) {
// console.log("isInvestorPresent", err.message)
errorLogStatus(error, "nodeJs_liquiloan_isInvestorPresent")
}
}
module.exports = {
getInvestorIdQuery
}

+ 33
- 0
controller/getHashvalue.js View File

@ -0,0 +1,33 @@
const crypto = require('crypto');
const { HASH_KEY } = require('../utils/consts');
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
return hmac.digest('hex');
}
function getHashCode(type) {
const inputString = "||2023-11-22 14:57:38";
const inputString_GetInvestorDashboard = "368907||2023-11-22 14:57:38";
const inputString_GetTransactionById = "5151974||368907||2023-11-22 14:57:38";
const key = HASH_KEY;
const hash = generateHMACSHA256(inputString, key);
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
const hash_GetTransactionById = generateHMACSHA256(inputString_GetTransactionById, key);
if (type === 1) {
return hash
}
if (type === 2) {
return hash_GetInvestorDashboard
}
if (type === 3) {
return hash_GetTransactionById
}
}
module.exports = {
getHashCode
}

+ 156
- 0
controller/getInvestmentSummary/index.js View File

@ -0,0 +1,156 @@
'use strict'
const request = require("request");
const db = require('../../utils/db_config');
const crypto = require('crypto');
const { getReqAndInvId } = require('../getTransactionById')
const { getCurrentDateTime } = require("../helper");
const { HASH_KEY } = require("../../utils/consts");
const { getInvSummaryIdQuery } = require("./query");
const { errorLogStatus } = require("../Errorlog");
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
return hmac.digest('hex');
}
function getHashCode(req) {
const inputString_GetInvestorDashboard = `${req}||${getCurrentDateTime()}`;
const key = HASH_KEY;
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
return hash_GetInvestorDashboard
}
const fetchAllInvestorId = async (sendId) => {
let data = JSON.parse(sendId)
for (let i = 0; i < data?.length; i++) {
await createLiquiloanInvestor(data[i].investor_id, i)
}
}
const getAllInvestorId = ((req, res) => {
getAllInvestorIdFun();
res.send("in procress");
})
const getAllInvestorIdFun = async () => {
let allInvestorId = await db.liquiloansInvestors.findAll({
attributes: ['investor_id']
});
let sendId = JSON.stringify(allInvestorId, null, 2)
fetchAllInvestorId(sendId);
};
const createLiquiloanInvestor = (investor_id, index) => {
var options = {
method: 'POST',
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"investor_id": investor_id,
"timestamp": getCurrentDateTime(),
"checksum": getHashCode(investor_id),
"mid": "M00201"
})
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
const data = JSON.parse(body);
let pastData = data?.data.past_investments;
if (pastData) {
getUrlAndStore(pastData);
}
let currentData = data?.data.current_investments;
if (currentData) {
getUrlAndStore(currentData);
}
});
}
const getUrlAndStore = async (callsData) => {
try {
let summary = []
for (let i = 0; i < callsData?.length; i++) {
let checkTrnId = await getInvSummaryIdQuery(callsData[i].request_id);
if (checkTrnId == 0) {
let record = {};
record.transaction_id = callsData[i].transaction_id,
record.investor_id = callsData[i].investor_id,
record.scheme_id = callsData[i].scheme_id,
record.investment_roi = callsData[i].investment_roi,
record.return_type = callsData[i].return_type,
record.payout_type = callsData[i].payout_type,
record.lockin_tenure = callsData[i].lockin_tenure,
record.lockin_break = callsData[i].lockin_break,
record.last_withdrawal_at = callsData[i].last_withdrawal_at,
record.transaction_sub_type = callsData[i].transaction_sub_type,
record.investment_status = callsData[i].investment_status,
record.parent_investment_id = callsData[i].parent_investment_id,
record.master_parent_investment_id = callsData[i].master_parent_investment_id,
record.quality_name = callsData[i].quality_name,
record.name = callsData[i].name,
record.transaction_date = callsData[i].transaction_date,
record.invested_amount = callsData[i].invested_amount,
record.scheme_name = callsData[i].scheme_name,
record.lockin_type = callsData[i].lockin_type,
record.display_scheme = callsData[i].display_scheme,
record.scheme_details = callsData[i].scheme_details,
record.lockin_end_date = callsData[i].lockin_end_date,
record.redeemed_principal = callsData[i].redeemed_principal,
record.redeemed_erest = callsData[i].redeemed_erest,
record.redeemed_erest_with_request = callsData[i].redeemed_erest_with_request,
record.total_redemption = callsData[i].total_redemption,
record.net_principal_investment = callsData[i].net_principal_investment,
record.interest_amount = callsData[i].interest_amount,
record.accrued_value = callsData[i].accrued_value,
record.withdrawable_balance = callsData[i].withdrawable_balance,
record.scheme_closed_date = callsData[i].scheme_closed_date,
record.request_id = callsData[i].request_id,
record.source = callsData[i].source,
record.created_at = getCurrentDateTime()
record.last_updatedAt = getCurrentDateTime()
summary.push(record);
} else {
let record = {
...callsData[i],
last_updatedAt: getCurrentDateTime()
}
await db.investorSummary.update(record, {
where: {
request_id: record.request_id
}
});
}
}
if (summary?.length) {
await db.investorSummary.bulkCreate(summary);
}
}
catch (err) {
errorLogStatus(err, "nodeJs_liquiloan_getUrlAndStore")
}
}
// check is transaction id is present
// const isRequestIdPresent = async (id) => {
// try {
// getInvSummaryIdQuery(id)
// } catch (err) {
// errorLogStatus(err, "nodeJs_liquiloan_isRequestIdPresent")
// }
// }
module.exports = {
getAllInvestorId
}

+ 16
- 0
controller/getInvestmentSummary/query.js View File

@ -0,0 +1,16 @@
const db = require("../../utils/db_config");
const { errorLogStatus } = require("../Errorlog");
async function getInvSummaryIdQuery(id) {
try {
let query = `select * from dbo.P2P_Liquiloans_Inv_Summarys where request_id= '${id}'`;
return await db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
} catch (error) {
errorLogStatus(error, "nodeJs_liquiloan_isRequestIdPresent")
}
}
module.exports = {
getInvSummaryIdQuery
}

+ 141
- 0
controller/getTransactionById/index.js View File

@ -0,0 +1,141 @@
const request = require('request');
const db = require('../../utils/db_config');
const { getCurrentDateTime } = require("../helper");
const crypto = require('crypto');
const { HASH_KEY } = require('../../utils/consts');
const { getInvTransIdQuery } = require('./query');
const { errorLogStatus } = require('../Errorlog');
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8');
return hmac.digest('hex');
}
function getHashCode(investor_id, request_id) {
const inputString_GetInvestorDashboard = `${request_id}||${investor_id}||${getCurrentDateTime()}`;
const key = HASH_KEY;
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
return hash_GetInvestorDashboard
}
const getReqAndInvId = ((req, res) => {
getReqAndInvIdFun();
res.send("in procress");
})
//get Request_Id and Investor_Id....
const getReqAndInvIdFun = async () => {
let allInvestorId = await db.investorSummary.findAll({
attributes: ['investor_id', 'request_id']
});
let sendId = JSON.stringify(allInvestorId, null, 2)
fetchReqAndInvId(sendId);
}
// Send Request_Id and Investor_Id to the getTransactionById fun
const fetchReqAndInvId = async (sendId) => {
let data = JSON.parse(sendId)
for (let i = 0; i < data.length; i++) {
let checkInvestorId = data[i].investor_id;
let checkRequestId = data[i].request_id;
if (checkInvestorId && checkRequestId) {
// setTimeout(() => {
await getTransactionById(checkInvestorId, checkRequestId)
// }, 10);
}
}
}
const getTransactionById = (checkInvestorId, checkRequestId) => {
try {
var options = {
method: 'POST',
url: 'https://supply-integration.liquiloans.com/api/v2/GetTransactionById',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
mid: "M00201",
checksum: getHashCode(checkInvestorId, checkRequestId),
timestamp: getCurrentDateTime(),
investor_id: checkInvestorId.toString(),
request_id: checkRequestId.toString()
})
};
request(options, async function (error, response) {
if (error) throw new Error(error);
if (response.body) {
// setTimeout(() => {
await fetchTransactionId(response.body);
// }, 10);
}
});
} catch (err) {
errorLogStatus(err, "nodeJs_liquiloan_getTransactionById")
}
}
const fetchTransactionId = async (data) => {
try {
let idDetails = JSON.parse(data);
let trnId = idDetails.data;
let item = {};
item.request_id = trnId.id,
item.investor_id = trnId.investor_id,
item.amount = trnId.amount,
item.transaction_type = trnId.transaction_type,
item.transaction_sub_type = trnId.transaction_sub_type,
item.withdrawal_method = trnId.withdrawal_method,
item.manual_parameters = trnId.manual_parameters,
item.old_investment_id = trnId.old_investment_id,
item.scheme_id = trnId.scheme_id,
item.mode = trnId.mode,
item.transaction_id = trnId.transaction_id,
item.order_id = trnId.order_id,
item.settlement_utr = trnId.settlement_utr,
item.transaction_source = trnId.transaction_source,
item.approval_status = trnId.approval_status,
item.transaction_status = trnId.transaction_status,
item.created_at = trnId.created_at,
item.authenticated_at = trnId.authenticated_at,
item.banking_date = trnId.banking_date,
item.execution_date = trnId.execution_date,
item.transaction_date = trnId.transaction_date,
item.ext_transaction_date = trnId.ext_transaction_date,
item.source_payment = trnId.source_payment,
item.last_updatedAt = getCurrentDateTime()
let isRecordPresent = await getInvTransIdQuery(item.request_id);
if (isRecordPresent.length) {
await db.transactionById.update(item, {
where: {
request_id: item.request_id
}
});
} else {
await db.transactionById.create(item);
}
console.log("done--------->")
} catch (err) {
errorLogStatus(err, "nodeJs_liquiloan_fetchTransactionId")
}
}
// const handleRecordPresent = async (item) => {
// let id = item.request_id;
// try {
// getInvTransIdQuery(id)
// } catch (err) {
// errorLogStatus(err, "nodeJs_liquiloan_handleRecordPresent")
// }
// }
module.exports = {
getReqAndInvId
}

+ 16
- 0
controller/getTransactionById/query.js View File

@ -0,0 +1,16 @@
const db = require("../../utils/db_config");
const { errorLogStatus } = require("../Errorlog");
async function getInvTransIdQuery(id) {
try {
let query = `select * from dbo.P2P_Liquiloans_Inv_Transactions where request_id= '${id}'`;
return await db.sequelize.query(query, { type: db.sequelize.QueryTypes.SELECT });
} catch (error) {
errorLogStatus(error, "nodeJs_liquiloan_handleRecordPresent")
}
}
module.exports = {
getInvTransIdQuery
}

+ 17
- 0
controller/helper.js View File

@ -0,0 +1,17 @@
const db = require("../utils/db_config");
function getCurrentDateTime() {
var date = new Date();
var dateStr =
date.getFullYear() + "-" +
("00" + (date.getMonth() + 1)).slice(-2) + "-" +
date.getDate() + " " +
("00" + date.getHours()).slice(-2) + ":" +
("00" + date.getMinutes()).slice(-2) + ":" +
("00" + date.getSeconds()).slice(-2);
return dateStr
}
module.exports = {
getCurrentDateTime,
}

+ 48
- 0
model/investorSummary.js View File

@ -0,0 +1,48 @@
module.exports = function (sequelize, DataTypes) {
const getInvestorSummary = sequelize.define('P2P_Liquiloans_Inv_Summarys', {
transaction_id: { type: DataTypes.INTEGER, allowNull: false, unique: true },
investor_id: { type: DataTypes.INTEGER, allowNull: true },
scheme_id: { type: DataTypes.INTEGER, allowNull: true },
investment_roi: { type: DataTypes.INTEGER, allowNull: true },
return_type: { type: DataTypes.STRING, allowNull: true },
payout_type: { type: DataTypes.STRING, allowNull: true },
lockin_tenure: { type: DataTypes.INTEGER, allowNull: true },
lockin_break: { type: DataTypes.STRING, allowNull: true },
last_withdrawal_at: { type: DataTypes.STRING, allowNull: true },
transaction_sub_type: { type: DataTypes.STRING, allowNull: true },
investment_status: { type: DataTypes.STRING, allowNull: true },
parent_investment_id: { type: DataTypes.STRING, allowNull: true },
master_parent_investment_id: { type: DataTypes.INTEGER, allowNull: true },
quality_name: { type: DataTypes.STRING, allowNull: true },
name: { type: DataTypes.STRING, allowNull: true },
transaction_date: { type: DataTypes.STRING, allowNull: true },
invested_amount: { type: DataTypes.INTEGER, allowNull: true },
scheme_name: { type: DataTypes.INTEGER, allowNull: true },
lockin_type: { type: DataTypes.STRING, allowNull: true },
display_scheme: { type: DataTypes.STRING, allowNull: true },
scheme_details: { type: DataTypes.STRING, allowNull: true },
lockin_end_date: { type: DataTypes.STRING, allowNull: true },
redeemed_principal: { type: DataTypes.INTEGER, allowNull: true },
redeemed_interest: { type: DataTypes.INTEGER, allowNull: true },
redeemed_interest_with_request: { type: DataTypes.INTEGER, allowNull: true },
total_redemption: { type: DataTypes.INTEGER, allowNull: true },
net_principal_investment: { type: DataTypes.INTEGER, allowNull: true },
interest_amount: { type: DataTypes.INTEGER, allowNull: true },
accrued_value: { type: DataTypes.INTEGER, allowNull: true },
withdrawable_balance: { type: DataTypes.INTEGER, allowNull: true },
scheme_closed_date: { type: DataTypes.STRING, allowNull: true },
request_id: { type: DataTypes.INTEGER, allowNull: true },
source: { type: DataTypes.STRING, allowNull: true },
created_at: { type: DataTypes.STRING, allowNull: true },
last_updatedAt: { type: DataTypes.STRING, allowNull: true },
}, {
//freezeTableName: true, // Model tableName will be the same as the model name
timestamps: false,
//underscored: true
}
);
return getInvestorSummary
};

+ 2
- 1
model/liquiloansInvestors.js View File

@ -1,5 +1,5 @@
module.exports = function (sequelize, DataTypes) { module.exports = function (sequelize, DataTypes) {
const LiquiloansInvestorsTbl = sequelize.define('P2P_Liquiloans_Investor', {
const LiquiloansInvestorsTbl = sequelize.define('P2P_Liquiloans_Investors', {
investor_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, investor_id: { type: DataTypes.INTEGER, allowNull: false, unique: true },
name: { type: DataTypes.STRING, allowNull: true }, name: { type: DataTypes.STRING, allowNull: true },
@ -10,6 +10,7 @@ module.exports = function (sequelize, DataTypes) {
ifa_id: { type: DataTypes.STRING, allowNull: true }, ifa_id: { type: DataTypes.STRING, allowNull: true },
created_at: { type: DataTypes.STRING, allowNull: true }, created_at: { type: DataTypes.STRING, allowNull: true },
rm_name: { type: DataTypes.STRING, allowNull: true }, rm_name: { type: DataTypes.STRING, allowNull: true },
last_updatedAt: { type: DataTypes.STRING, allowNull: true },
}, { }, {
//freezeTableName: true, // Model tableName will be the same as the model name //freezeTableName: true, // Model tableName will be the same as the model name
timestamps: false, timestamps: false,


+ 38
- 0
model/transactionById.js View File

@ -0,0 +1,38 @@
// P2P_Liquiloans_Inv_Transaction
module.exports = function (sequelize, DataTypes) {
const liquiloansTransaction = sequelize.define('P2P_Liquiloans_Inv_Transactions', {
request_id: { type: DataTypes.INTEGER, allowNull: false, unique: true },
investor_id: { type: DataTypes.INTEGER, allowNull: true },
amount: { type: DataTypes.INTEGER, allowNull: true },
transaction_type: { type: DataTypes.STRING, allowNull: true },
transaction_sub_type: { type: DataTypes.STRING, allowNull: true },
withdrawal_method: { type: DataTypes.STRING, allowNull: true },
manual_parameters: { type: DataTypes.STRING, allowNull: true },
old_investment_id: { type: DataTypes.STRING, allowNull: true },
scheme_id: { type: DataTypes.INTEGER, allowNull: true },
mode: { type: DataTypes.STRING, allowNull: true },
transaction_id: { type: DataTypes.STRING, allowNull: true },
order_id: { type: DataTypes.STRING, allowNull: true },
settlement_utr: { type: DataTypes.STRING, allowNull: true },
transaction_source: { type: DataTypes.STRING, allowNull: true },
approval_status: { type: DataTypes.STRING, allowNull: true },
transaction_status: { type: DataTypes.STRING, allowNull: true },
created_at: { type: DataTypes.STRING, allowNull: true },
authenticated_at: { type: DataTypes.STRING, allowNull: true },
banking_date: { type: DataTypes.STRING, allowNull: true },
execution_date: { type: DataTypes.STRING, allowNull: true },
transaction_date: { type: DataTypes.STRING, allowNull: true },
ext_transaction_date: { type: DataTypes.STRING, allowNull: true },
source_payment: { type: DataTypes.STRING, allowNull: true },
last_updatedAt: { type: DataTypes.STRING, allowNull: true },
}, {
timestamps: false,
}
);
return liquiloansTransaction
}

+ 1936
- 4
package-lock.json
File diff suppressed because it is too large
View File


+ 7
- 1
package.json View File

@ -4,7 +4,8 @@
"description": "", "description": "",
"main": "app.js", "main": "app.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -13,11 +14,16 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"axios": "^1.6.2",
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"crypto": "^1.0.1",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"node-cron": "^3.0.3", "node-cron": "^3.0.3",
"nodemon": "^3.0.2",
"pug": "^3.0.2",
"request": "^2.88.2",
"rotating-file-stream": "^3.1.1", "rotating-file-stream": "^3.1.1",
"sequelize": "^6.35.1", "sequelize": "^6.35.1",
"tedious": "^16.6.1" "tedious": "^16.6.1"


+ 15
- 1
routes/script.js View File

@ -1,7 +1,21 @@
const express = require('express'); const express = require('express');
const { route } = require("express/lib/application");
const { getAllInvestorId } = require('../controller/getInvestmentSummary');
const { fetchInvestorDetails } = require('../controller/getAllInvestor');
const { getReqAndInvId } = require('../controller/getTransactionById');
const router = express.Router(); const router = express.Router();
router.get("/allInvestor", (req, res) => {
fetchInvestorDetails()
})
router.get("/getInvestmentSummary", (req, res) => {
getAllInvestorId()
})
/* GET users listing. */
router.get("/getTransactionId", (req, res) => {
getReqAndInvId()
})
module.exports = router; module.exports = router;

+ 5
- 4
utils/consts.js View File

@ -12,16 +12,16 @@ const ERROR_MESSAGE = "Oops,something went wrong";
const BUCKET_NAME_NIVESH = "nivesh-call-logs/recording"; const BUCKET_NAME_NIVESH = "nivesh-call-logs/recording";
const S3_BUCKET_NIVESH_CALL_URL= "https://nivesh-call-logs.s3.ap-south-1.amazonaws.com/recording/";
const S3_BUCKET_NIVESH_CALL_URL = "https://nivesh-call-logs.s3.ap-south-1.amazonaws.com/recording/";
const BUCKET_NAME_SOA_REPORTS = "client-soa-reports/ELSS"; const BUCKET_NAME_SOA_REPORTS = "client-soa-reports/ELSS";
const S3_BUCKET_SOA_REPORTS_URL= "https://client-soa-reports.s3.ap-south-1.amazonaws.com/ELSS/";
const S3_BUCKET_SOA_REPORTS_URL = "https://client-soa-reports.s3.ap-south-1.amazonaws.com/ELSS/";
const AWS_ACCESS_KEY_ID_TEST = "AKIA2C5JCOWXUXB4T3MV"; const AWS_ACCESS_KEY_ID_TEST = "AKIA2C5JCOWXUXB4T3MV";
const AWS_SECRET_KEY_TEST = "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"; const AWS_SECRET_KEY_TEST = "RzobMkAESwzvX/DBtxvBa5Go2dRz2VWH7pwCxuoq";
const EXOTEL_AUTHTOKEN = "Basic NWE0NjY1ZDU0MGViNzk5NjQxMGQ1NWJhYzllZmI5MTVhOTgyYWU2MmRmYWFkZmM0OmU0YTgzNjEwNjI1NWM5ZDllY2QxMDNiOWQwZGFmYWQ3ZTA1YjNjNTU1NDJhZjU3NQ==" const EXOTEL_AUTHTOKEN = "Basic NWE0NjY1ZDU0MGViNzk5NjQxMGQ1NWJhYzllZmI5MTVhOTgyYWU2MmRmYWFkZmM0OmU0YTgzNjEwNjI1NWM5ZDllY2QxMDNiOWQwZGFmYWQ3ZTA1YjNjNTU1NDJhZjU3NQ=="
const HASH_KEY = "27E6A91CEE689";
s3://kwikfoods/2020/ s3://kwikfoods/2020/
module.exports = { module.exports = {
ERROR_500, ERROR_500,
@ -39,5 +39,6 @@ module.exports = {
S3_BUCKET_SOA_REPORTS_URL, S3_BUCKET_SOA_REPORTS_URL,
AWS_ACCESS_KEY_ID_TEST, AWS_ACCESS_KEY_ID_TEST,
AWS_SECRET_KEY_TEST, AWS_SECRET_KEY_TEST,
EXOTEL_AUTHTOKEN
EXOTEL_AUTHTOKEN,
HASH_KEY
}; };

+ 2
- 30
utils/db_config.js View File

@ -38,38 +38,10 @@ db.sequelize = sequelize;
db.liquiloansInvestors = require('../model/liquiloansInvestors')(sequelize, Sequelize); db.liquiloansInvestors = require('../model/liquiloansInvestors')(sequelize, Sequelize);
db.investorSummary = require('../model/investorSummary')(sequelize, Sequelize);
db.transactionById = require('../model/transactionById')(sequelize, Sequelize);
module.exports = db; module.exports = db;
/*
const sql = require('mssql')
const sqlConfig = {
user: 'BSeMF',
password: 'nivesh2017',
database: 'providentialadvisory',
server: 'ec2-13-235-204-185.ap-south-1.compute.amazonaws.com',
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
options: {
encrypt: true, // for azure
trustServerCertificate: true // change to true for local dev / self-signed certs
}
}
const connection = async () => {
try {
console.log('ajksfkgjsafkksafkkfskf')
let con = await sql.connect(sqlConfig)
console.log('connection',con);
} catch (err) {
console.log(err);
}
};
connection();
*/

+ 24
- 5
utils/scheduler.js View File

@ -1,17 +1,36 @@
'use strict'; 'use strict';
const cron = require('node-cron'); const cron = require('node-cron');
const { fetchInvestorDetails } = require('../controller/getAllInvestor');
const { getAllInvestorId } = require('../controller/getInvestmentSummary');
const { getReqAndInvId } = require('../controller/getTransactionById');
const routineFetchInvestors = () => {
cron.schedule(process.env.SCHEDULER_RULE_EXOTEL_CALL, () => {
console.log("running scheduler");
// recordingController.callExotelRecording();
const routineFetchAllInvestors = () => {
cron.schedule(process.env.SCHEDULER_RULE_FETCH_ALL_INVESTOR, () => {
console.log("running scheduler routineFetchAllInvestors");
fetchInvestorDetails()
})
};
const routineGetInvestmentSummary = () => {
cron.schedule(process.env.SCHEDULER_RULE_INVESTMENT_SUMMARY, () => {
console.log("running scheduler routineGetInvestmentSummary");
getAllInvestorId()
})
};
const routineGetTransactionById = () => {
cron.schedule(process.env.SCHEDULER_RULE_TRANS_ID, () => {
console.log("running scheduler routineGetTransactionById");
getReqAndInvId()
}) })
}; };
module.exports = { module.exports = {
routineFetchInvestors,
routineFetchAllInvestors,
routineGetInvestmentSummary,
routineGetTransactionById
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.