代理后台接口对接

This commit is contained in:
dzl
2025-09-15 19:18:43 +08:00
parent 318e6f56a9
commit 95e94cc829

View File

@@ -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,