From 95e94cc829c3f48b699d3de61dd45cf725c3789a Mon Sep 17 00:00:00 2001 From: dzl <786316265@qq.com> Date: Mon, 15 Sep 2025 19:18:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=90=8E=E5=8F=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/agent.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/routes/agent.js b/routes/agent.js index 1333f63..30b74c4 100644 --- a/routes/agent.js +++ b/routes/agent.js @@ -66,7 +66,9 @@ router.get('/stats', agentAuth, async (req, res) => { users: userStats[0] || { total_users: 0, today_new_users: 0, - active_users: 0 + active_users: 0, + agent_share_users: 0, + operated_share_users: 0, }, commissions: commissionStats[0] || { total_commission: '0.00', @@ -139,11 +141,32 @@ router.get('/stats_agent_directly', agentAuth, async (req, res) => { //直销人员分享人数 let [agent_share_users] = await getDB().execute(` SELECT id FROM users WHERE inviter=? AND user_type='user' - `) + `, [userId]) let total_share_users = 0 for (const id of agent_share_users) { - + const [userTotal] = await getDB().execute(` + SELECT COUNT(*) as total_users + FROM users + WHERE inviter = ? + `, [id])//????????????????????? + total_share_users += userTotal[0].total_users } + userStats[0].agent_share_users = total_share_users; + //直营商户分享人数 + let [operated_share_users] = await getDB().execute(` + SELECT id FROM users WHERE inviter=? AND user_type='directly_operated' + `, [userId]) + let total_operated_share_users = 0 + for (const id of operated_share_users) { + const [userTotal] = await getDB().execute(` + SELECT COUNT(*) as total_users + FROM users + WHERE inviter = ? + `, [id])//????????????????????? + total_operated_share_users += userTotal[0].total_users + } + userStats[0].operated_share_users = total_operated_share_users; + // 获取佣金统计 const [commissionStats] = await getDB().execute(` SELECT COALESCE(SUM(amount), 0) AS total_commission, @@ -157,6 +180,42 @@ router.get('/stats_agent_directly', agentAuth, async (req, res) => { AND transfer_type = 'user_to_agent' `, [userId]); + // 获取直销商户利润 + // let [directly_agents_income] = await getDB().execute(` + + // `) + commissionStats[0].directly_agents_income = 1 + + // 获取直销商户分享利润 + // let [active_users_income] = await getDB().execute(` + + // `) + commissionStats[0].active_users_income = 2 + + // 获取直营佣金 + // let [operated_commission] = await getDB().execute(` + + // `) + commissionStats[0].operated_commission = 3 + + // 获取已提现佣金 + // let [get_commission] = await getDB().execute(` + + // `) + commissionStats[0].get_commission = 4 + + // 获取待提现佣金 + // let [loading_commission] = await getDB().execute(` + + // `) + commissionStats[0].loading_commission = 5 + + // 获取总收入 + // let [total_commission] = await getDB().execute(` + + // `) + commissionStats[0].total_commission = 12345 + // 获取转账统计 const [transferStats] = await getDB().execute(` SELECT COUNT(*) as total_transfers,