|
@ -1,7 +1,6 @@ |
|
|
'use strict' |
|
|
'use strict' |
|
|
|
|
|
|
|
|
const request = require("request"); |
|
|
const request = require("request"); |
|
|
const constants = require('../utils/consts'); |
|
|
|
|
|
const db = require('../utils/db_config'); |
|
|
const db = require('../utils/db_config'); |
|
|
const crypto = require('crypto'); |
|
|
const crypto = require('crypto'); |
|
|
const { getCurrentDateTime } = require("./helper"); |
|
|
const { getCurrentDateTime } = require("./helper"); |
|
@ -11,10 +10,9 @@ function generateHMACSHA256(input, key) { |
|
|
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
|
|
|
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
|
|
|
return hmac.digest('hex'); |
|
|
return hmac.digest('hex'); |
|
|
} |
|
|
} |
|
|
let arrayGetList = ["2509295", "2509", "2820644", "437290"] |
|
|
|
|
|
|
|
|
|
|
|
function getHashCode(req) { |
|
|
function getHashCode(req) { |
|
|
// console.log(`368907||${getCurrentDateTime()}`, "DKDDODKOODDOK");
|
|
|
|
|
|
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); |
|
@ -22,92 +20,99 @@ function getHashCode(req) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fetchAllInvestorId = async (sendId) => { |
|
|
|
|
|
let data =JSON.parse(sendId) |
|
|
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
|
|
await createLiquiloanInvestor(data[i].investor_id) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getAllInvestorId = async () => { |
|
|
|
|
|
let allInvestorId = await db.liquiloansInvestors.findAll({ |
|
|
|
|
|
attributes: ['investor_id'] |
|
|
|
|
|
}); |
|
|
|
|
|
let sendId = JSON.stringify(allInvestorId, null, 2) |
|
|
|
|
|
fetchAllInvestorId(sendId); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = () => { |
|
|
|
|
|
for (let i = 0; i < arrayGetList.length; i++) { |
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = (investor_id) => { |
|
|
|
|
|
|
|
|
var options = { |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary', |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
|
'Cookie': 'AWSALB=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW; AWSALBCORS=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW' |
|
|
|
|
|
}, |
|
|
|
|
|
body: JSON.stringify({ |
|
|
|
|
|
"investor_id": arrayGetList[i], |
|
|
|
|
|
"timestamp": getCurrentDateTime(), |
|
|
|
|
|
"checksum": getHashCode(arrayGetList[i]), |
|
|
|
|
|
"mid": "M00201" |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
var options = { |
|
|
|
|
|
method: 'POST', |
|
|
|
|
|
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary', |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
|
'Cookie': 'AWSALB=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW; AWSALBCORS=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW' |
|
|
|
|
|
}, |
|
|
|
|
|
body: JSON.stringify({ |
|
|
|
|
|
"investor_id": investor_id, |
|
|
|
|
|
"timestamp": getCurrentDateTime(), |
|
|
|
|
|
"checksum": getHashCode(investor_id), |
|
|
|
|
|
"mid": "M00201" |
|
|
|
|
|
}) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
request(options, function (error, response) { |
|
|
|
|
|
if (error) throw new Error(error); |
|
|
|
|
|
getUrlAndStore(response.body) |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
request(options, function (error, response) { |
|
|
|
|
|
if (error) throw new Error(error); |
|
|
|
|
|
const data = JSON.parse(response.body); |
|
|
|
|
|
let callsData = data?.data.past_investments; |
|
|
|
|
|
if (callsData) { |
|
|
|
|
|
getUrlAndStore(callsData); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
const getUrlAndStore = async (body) => { |
|
|
|
|
|
|
|
|
const getUrlAndStore = async (callsData) => { |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const data = JSON.parse(body) |
|
|
|
|
|
let callsData = data; |
|
|
|
|
|
let summary = [] |
|
|
let summary = [] |
|
|
// if (callsData.length) {
|
|
|
|
|
|
//console.log(callsData.data.past_investments.length, "LDPDPLDPLDPLLPDPDLDLPDPLDPL");
|
|
|
|
|
|
for (let i = 0; i < callsData.data.past_investments.length; i++) { |
|
|
|
|
|
|
|
|
for (let i = 0; i < callsData.length; i++) { |
|
|
let record = {}; |
|
|
let record = {}; |
|
|
record.transaction_id = callsData.data.past_investments[i].transaction_id, |
|
|
|
|
|
record.investor_id = callsData.data.past_investments[i].investor_id, |
|
|
|
|
|
record.scheme_id = callsData.data.past_investments[i].scheme_id, |
|
|
|
|
|
record.investment_roi = callsData.data.past_investments[i].investment_roi, |
|
|
|
|
|
record.return_type = callsData.data.past_investments[i].return_type, |
|
|
|
|
|
record.payout_type = callsData.data.past_investments[i].payout_type, |
|
|
|
|
|
record.lockin_tenure = callsData.data.past_investments[i].lockin_tenure, |
|
|
|
|
|
record.lockin_break = callsData.data.past_investments[i].lockin_break, |
|
|
|
|
|
record.last_withdrawal_at = callsData.data.past_investments[i].last_withdrawal_at, |
|
|
|
|
|
record.transaction_sub_type = callsData.data.past_investments[i].transaction_sub_type, |
|
|
|
|
|
record.investment_status = callsData.data.past_investments[i].investment_status, |
|
|
|
|
|
record.parent_investment_id = callsData.data.past_investments[i].parent_investment_id, |
|
|
|
|
|
record.master_parent_investment_id = callsData.data.past_investments[i].master_parent_investment_id, |
|
|
|
|
|
record.quality_name = callsData.data.past_investments[i].quality_name, |
|
|
|
|
|
record.name = callsData.data.past_investments[i].name, |
|
|
|
|
|
record.transaction_date = callsData.data.past_investments[i].transaction_date, |
|
|
|
|
|
record.invested_amount = callsData.data.past_investments[i].invested_amount, |
|
|
|
|
|
record.scheme_name = callsData.data.past_investments[i].scheme_name, |
|
|
|
|
|
record.lockin_type = callsData.data.past_investments[i].lockin_type, |
|
|
|
|
|
record.display_scheme = callsData.data.past_investments[i].display_scheme, |
|
|
|
|
|
record.scheme_details = callsData.data.past_investments[i].scheme_details, |
|
|
|
|
|
record.lockin_end_date = callsData.data.past_investments[i].lockin_end_date, |
|
|
|
|
|
record.redeemed_principal = callsData.data.past_investments[i].redeemed_principal, |
|
|
|
|
|
record.redeemed_erest = callsData.data.past_investments[i].redeemed_erest, |
|
|
|
|
|
record.redeemed_erest_with_request = callsData.data.past_investments[i].redeemed_erest_with_request, |
|
|
|
|
|
record.total_redemption = callsData.data.past_investments[i].total_redemption, |
|
|
|
|
|
record.net_principal_investment = callsData.data.past_investments[i].net_principal_investment, |
|
|
|
|
|
record.interest_amount = callsData.data.past_investments[i].interest_amount, |
|
|
|
|
|
record.accrued_value = callsData.data.past_investments[i].accrued_value, |
|
|
|
|
|
record.withdrawable_balance = callsData.data.past_investments[i].withdrawable_balance, |
|
|
|
|
|
record.scheme_closed_date = callsData.data.past_investments[i].scheme_closed_date, |
|
|
|
|
|
record.request_id = callsData.data.past_investments[i].request_id, |
|
|
|
|
|
record.source = callsData.data.past_investments[i].source, |
|
|
|
|
|
|
|
|
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.created_at = new Date() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
summary.push(record); |
|
|
summary.push(record); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log('calls---->', summary); |
|
|
|
|
|
await db.investorSummary.bulkCreate(summary); |
|
|
await db.investorSummary.bulkCreate(summary); |
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (err) { |
|
|
catch (err) { |
|
|
console.log(err, "KDDODKODKODKODKODKODKO"); |
|
|
|
|
|
// winstonLogger.error('getUrlAndStore() error is : ' + err);
|
|
|
|
|
|
|
|
|
console.log(err, "ERROR........."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
createLiquiloanInvestor |
|
|
|
|
|
|
|
|
getAllInvestorId |
|
|
} |
|
|
} |
|
|
|
|
|
|