From d0c32250112cb03a5b44b60c614b3a62142e4265 Mon Sep 17 00:00:00 2001 From: khanshanawaz10 Date: Tue, 12 Dec 2023 18:12:25 +0530 Subject: [PATCH 1/3] feat - getclientsummary api added --- controller/getInvestmentSumarry.js | 56 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/controller/getInvestmentSumarry.js b/controller/getInvestmentSumarry.js index 3ed6af1..1a71b8c 100644 --- a/controller/getInvestmentSumarry.js +++ b/controller/getInvestmentSumarry.js @@ -49,38 +49,40 @@ const createLiquiloanInvestor = () => { const getUrlAndStore = async (body) => { try { const data = JSON.parse(body) - console.log(data, "KDDODKOKODODKDKO"); - let callsData = data.data; + // console.log(data, "111111111111111111111111111111111111111111"); + let callsData = data; let calls = []; // if (callsData.length) { - // for (let i = 0; i < callsData.length; i++) { - // let record = {}; - // record.sid = callsData[i].Sid; - // record.date_created = callsData[i].DateCreated; - // record.date_updated = callsData[i].DateUpdated; - // record.account_sid = callsData[i].AccountSid; - // record.to = callsData[i].To; - // record.from = callsData[i].From; - // record.phone_number = callsData[i].PhoneNumber; - // record.phone_number_sid = callsData[i].PhoneNumberSid; - // record.status = callsData[i].Status; - // record.start_time = callsData[i].StartTime; - // record.end_time = callsData[i].EndTime; - // record.duration = callsData[i].Duration; - // record.price = callsData[i].Price; - // record.direction = callsData[i].Direction; - // record.recording_url = callsData[i].RecordingUrl; + console.log(callsData.data.past_investments, "LDPDPLDPLDPLLPDPDLDLPDPLDPL"); + for (let i = 0; i < callsData.length; i++) { + let record = {}; - // record.conversation_duration = callsData[i].Details.ConversationDuration; - // record.leg1_status = callsData[i].Details.Leg1Status; - // record.leg2_status = callsData[i].Details.Leg2Status; - // record.created_at = new Date(); + // record.sid = callsData[i].Sid; + // record.date_created = callsData[i].DateCreated; + // record.date_updated = callsData[i].DateUpdated; + // record.account_sid = callsData[i].AccountSid; + // record.to = callsData[i].To; + // record.from = callsData[i].From; + // record.phone_number = callsData[i].PhoneNumber; + // record.phone_number_sid = callsData[i].PhoneNumberSid; + // record.status = callsData[i].Status; + // record.start_time = callsData[i].StartTime; + // record.end_time = callsData[i].EndTime; + // record.duration = callsData[i].Duration; + // record.price = callsData[i].Price; + // record.direction = callsData[i].Direction; + // record.recording_url = callsData[i].RecordingUrl; + // record.conversation_duration = callsData[i].Details.ConversationDuration; + // record.leg1_status = callsData[i].Details.Leg1Status; + // record.leg2_status = callsData[i].Details.Leg2Status; + // record.created_at = new Date(); - // calls.push(record); - // console.log('calls---->', calls.length); - // await db.exotelCalls.bulkCreate(calls); - // } + + // calls.push(record); + // console.log('calls---->', calls.length); + // await db.exotelCalls.bulkCreate(calls); + } } catch (err) { console.log(err); From d885d78e2887f4d21f93f0527b52c18e20ff3dc1 Mon Sep 17 00:00:00 2001 From: khanshanawaz10 Date: Tue, 12 Dec 2023 21:38:25 +0530 Subject: [PATCH 2/3] feat - model added --- controller/getInvestmentSumarry.js | 45 +++++++++++++++++++++++++++-- model/P2P_Liquiloans_Investors.js | 46 ++++++++++++++++++++++++++++++ utils/db_config.js | 1 + 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 model/P2P_Liquiloans_Investors.js diff --git a/controller/getInvestmentSumarry.js b/controller/getInvestmentSumarry.js index 1a71b8c..25a60f5 100644 --- a/controller/getInvestmentSumarry.js +++ b/controller/getInvestmentSumarry.js @@ -53,9 +53,48 @@ const getUrlAndStore = async (body) => { let callsData = data; let calls = []; // if (callsData.length) { - console.log(callsData.data.past_investments, "LDPDPLDPLDPLLPDPDLDLPDPLDPL"); - for (let i = 0; i < callsData.length; i++) { + console.log(callsData.data.past_investments.length, "LDPDPLDPLDPLLPDPDLDLPDPLDPL"); + for (let i = 0; i < callsData.data.past_investments.length; i++) { + console.log(); 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 + + + calls.push(record); + console.log('calls---->', calls); + await db.P2P_Liquiloans_Investors.bulkCreate(calls); // record.sid = callsData[i].Sid; // record.date_created = callsData[i].DateCreated; @@ -86,7 +125,7 @@ const getUrlAndStore = async (body) => { } catch (err) { console.log(err); - winstonLogger.error('getUrlAndStore() error is : ' + err); + // winstonLogger.error('getUrlAndStore() error is : ' + err); } } diff --git a/model/P2P_Liquiloans_Investors.js b/model/P2P_Liquiloans_Investors.js new file mode 100644 index 0000000..9b2e213 --- /dev/null +++ b/model/P2P_Liquiloans_Investors.js @@ -0,0 +1,46 @@ +module.exports = function (sequelize, DataTypes) { + const getInvestorSummary = sequelize.define('P2P_Liquiloans_Investors', { + + transaction_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, + investor_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, + scheme_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, + investment_roi: { type: DataTypes.INTEGER, allowNull: false, unique: 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.STRING, 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.STRING, allowNull: true }, + source: { type: DataTypes.STRING, allowNull: true }, + }, { + //freezeTableName: true, // Model tableName will be the same as the model name + timestamps: false, + //underscored: true + } + ); + + + return getInvestorSummary +}; \ No newline at end of file diff --git a/utils/db_config.js b/utils/db_config.js index 568f010..f020697 100644 --- a/utils/db_config.js +++ b/utils/db_config.js @@ -38,6 +38,7 @@ db.sequelize = sequelize; db.liquiloansInvestors = require('../model/liquiloansInvestors')(sequelize, Sequelize); +db.P2P_Liquiloans_Investors = require('../model/P2P_Liquiloans_Investors')(sequelize, Sequelize); module.exports = db; From 98b0bd8983d144bd34169f3000185450a64bb3af Mon Sep 17 00:00:00 2001 From: khanshanawaz10 Date: Wed, 13 Dec 2023 10:26:04 +0530 Subject: [PATCH 3/3] feat - model added --- controller/getInvestmentSumarry.js | 29 ++----------------- ...tors.js => P2P_Liquiloans_Inv_Summarys.js} | 12 ++++---- utils/db_config.js | 2 +- 3 files changed, 9 insertions(+), 34 deletions(-) rename model/{P2P_Liquiloans_Investors.js => P2P_Liquiloans_Inv_Summarys.js} (84%) diff --git a/controller/getInvestmentSumarry.js b/controller/getInvestmentSumarry.js index 25a60f5..ad62485 100644 --- a/controller/getInvestmentSumarry.js +++ b/controller/getInvestmentSumarry.js @@ -94,37 +94,12 @@ const getUrlAndStore = async (body) => { calls.push(record); console.log('calls---->', calls); - await db.P2P_Liquiloans_Investors.bulkCreate(calls); + await db.P2P_Liquiloans_Inv_Summarys.bulkCreate(calls); - // record.sid = callsData[i].Sid; - // record.date_created = callsData[i].DateCreated; - // record.date_updated = callsData[i].DateUpdated; - // record.account_sid = callsData[i].AccountSid; - // record.to = callsData[i].To; - // record.from = callsData[i].From; - // record.phone_number = callsData[i].PhoneNumber; - // record.phone_number_sid = callsData[i].PhoneNumberSid; - // record.status = callsData[i].Status; - // record.start_time = callsData[i].StartTime; - // record.end_time = callsData[i].EndTime; - // record.duration = callsData[i].Duration; - // record.price = callsData[i].Price; - // record.direction = callsData[i].Direction; - // record.recording_url = callsData[i].RecordingUrl; - - // record.conversation_duration = callsData[i].Details.ConversationDuration; - // record.leg1_status = callsData[i].Details.Leg1Status; - // record.leg2_status = callsData[i].Details.Leg2Status; - // record.created_at = new Date(); - - - // calls.push(record); - // console.log('calls---->', calls.length); - // await db.exotelCalls.bulkCreate(calls); } } catch (err) { - console.log(err); + console.log(err, "KDDODKODKODKODKODKODKO"); // winstonLogger.error('getUrlAndStore() error is : ' + err); } } diff --git a/model/P2P_Liquiloans_Investors.js b/model/P2P_Liquiloans_Inv_Summarys.js similarity index 84% rename from model/P2P_Liquiloans_Investors.js rename to model/P2P_Liquiloans_Inv_Summarys.js index 9b2e213..2c8880c 100644 --- a/model/P2P_Liquiloans_Investors.js +++ b/model/P2P_Liquiloans_Inv_Summarys.js @@ -1,10 +1,10 @@ module.exports = function (sequelize, DataTypes) { - const getInvestorSummary = sequelize.define('P2P_Liquiloans_Investors', { + const getInvestorSummary = sequelize.define('P2P_Liquiloans_Inv_Summarys', { - transaction_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, - investor_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, - scheme_id: { type: DataTypes.INTEGER, allowNull: false, unique: true }, - investment_roi: { type: DataTypes.INTEGER, allowNull: false, unique: true }, + transaction_id: { type: DataTypes.INTEGER, allowNull: true, unique: true }, + investor_id: { type: DataTypes.INTEGER, allowNull: true, unique: true }, + scheme_id: { type: DataTypes.INTEGER, allowNull: true, unique: true }, + investment_roi: { type: DataTypes.INTEGER, allowNull: true, unique: true }, return_type: { type: DataTypes.STRING, allowNull: true }, payout_type: { type: DataTypes.STRING, allowNull: true }, lockin_tenure: { type: DataTypes.INTEGER, allowNull: true }, @@ -32,7 +32,7 @@ module.exports = function (sequelize, DataTypes) { 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.STRING, allowNull: true }, + request_id: { type: DataTypes.INTEGER, allowNull: true }, source: { type: DataTypes.STRING, allowNull: true }, }, { //freezeTableName: true, // Model tableName will be the same as the model name diff --git a/utils/db_config.js b/utils/db_config.js index f020697..2b762e5 100644 --- a/utils/db_config.js +++ b/utils/db_config.js @@ -38,7 +38,7 @@ db.sequelize = sequelize; db.liquiloansInvestors = require('../model/liquiloansInvestors')(sequelize, Sequelize); -db.P2P_Liquiloans_Investors = require('../model/P2P_Liquiloans_Investors')(sequelize, Sequelize); +db.P2P_Liquiloans_Inv_Summarys = require('../model/P2P_Liquiloans_Inv_Summarys')(sequelize, Sequelize); module.exports = db;