|
@ -3,6 +3,7 @@ |
|
|
const request = require("request"); |
|
|
const request = require("request"); |
|
|
const db = require('../utils/db_config'); |
|
|
const db = require('../utils/db_config'); |
|
|
const crypto = require('crypto'); |
|
|
const crypto = require('crypto'); |
|
|
|
|
|
const {getReqAndInvId} = require('./getTransactionById') |
|
|
const { getCurrentDateTime } = require("./helper"); |
|
|
const { getCurrentDateTime } = require("./helper"); |
|
|
|
|
|
|
|
|
function generateHMACSHA256(input, key) { |
|
|
function generateHMACSHA256(input, key) { |
|
@ -12,7 +13,7 @@ function generateHMACSHA256(input, key) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getHashCode(req) { |
|
|
function getHashCode(req) { |
|
|
const inputString_GetInvestorDashboard = `${req} || ${getCurrentDateTime()}`; |
|
|
|
|
|
|
|
|
const inputString_GetInvestorDashboard = `${req}||${getCurrentDateTime()}`; |
|
|
const key = "27E6A91CEE689"; |
|
|
const key = "27E6A91CEE689"; |
|
|
|
|
|
|
|
|
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key); |
|
|
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key); |
|
@ -21,9 +22,9 @@ function getHashCode(req) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const fetchAllInvestorId = async (sendId) => { |
|
|
const fetchAllInvestorId = async (sendId) => { |
|
|
let data =JSON.parse(sendId) |
|
|
|
|
|
|
|
|
let data = JSON.parse(sendId) |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
await createLiquiloanInvestor(data[i].investor_id) |
|
|
|
|
|
|
|
|
await createLiquiloanInvestor(data[i].investor_id,i) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -36,14 +37,13 @@ const getAllInvestorId = async () => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = (investor_id) => { |
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = (investor_id,index) => { |
|
|
|
|
|
|
|
|
var options = { |
|
|
var options = { |
|
|
method: 'POST', |
|
|
method: 'POST', |
|
|
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary', |
|
|
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary', |
|
|
headers: { |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
|
|
|
'Cookie': 'AWSALB=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW; AWSALBCORS=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW' |
|
|
|
|
|
|
|
|
'Content-Type': 'application/json' |
|
|
}, |
|
|
}, |
|
|
body: JSON.stringify({ |
|
|
body: JSON.stringify({ |
|
|
"investor_id": investor_id, |
|
|
"investor_id": investor_id, |
|
@ -53,65 +53,90 @@ const createLiquiloanInvestor = (investor_id) => { |
|
|
}) |
|
|
}) |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
request(options, function (error, response) { |
|
|
|
|
|
|
|
|
request(options, function (error, response,body) { |
|
|
if (error) throw new Error(error); |
|
|
if (error) throw new Error(error); |
|
|
const data = JSON.parse(response.body); |
|
|
|
|
|
let callsData = data?.data.past_investments; |
|
|
|
|
|
if (callsData) { |
|
|
|
|
|
getUrlAndStore(callsData); |
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
console.log(index,"investor_id-->",investor_id,"currentData-->",currentData.length,"pastData-->",pastData.length) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
const getUrlAndStore = async (callsData) => { |
|
|
const getUrlAndStore = async (callsData) => { |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let summary = [] |
|
|
let summary = [] |
|
|
for (let i = 0; i < callsData.length; i++) { |
|
|
for (let i = 0; i < callsData.length; i++) { |
|
|
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 = new Date() |
|
|
|
|
|
|
|
|
|
|
|
summary.push(record); |
|
|
|
|
|
|
|
|
let checkTrnId = await isRequestIdPresent(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 = new Date() |
|
|
|
|
|
record.last_updatedAt = new Date() |
|
|
|
|
|
|
|
|
|
|
|
summary.push(record); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(summary.length){ |
|
|
|
|
|
await db.investorSummary.bulkCreate(summary); |
|
|
} |
|
|
} |
|
|
await db.investorSummary.bulkCreate(summary); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
catch (err) { |
|
|
console.log(err, "ERROR........."); |
|
|
console.log(err, "ERROR........."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check is transaction id is present
|
|
|
|
|
|
const isRequestIdPresent = async (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 (err) { |
|
|
|
|
|
console.log("isIransactionId", err.message) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
getAllInvestorId |
|
|
getAllInvestorId |
|
|
} |
|
|
} |
|
|