This commit is contained in:
2025-09-15 17:27:13 +08:00
parent d50290e8fe
commit 14a3c39f9d
27 changed files with 3571 additions and 31198 deletions

View File

@@ -110,10 +110,11 @@ router.post('/login', async (req, res) => {
// 先查询用户和代理信息(包含密码用于验证)
const [agents] = await getDB().execute(
`SELECT ra.*, u.id as user_id, u.username, u.phone, u.real_name, u.password, u.role, zr.city_name, zr.district_name
`SELECT ra.*, u.id as user_id, u.username, u.phone, u.real_name, u.password, u.role, zr.name as city_name, d.name as district_name
FROM regional_agents ra
JOIN users u ON ra.user_id = u.id
JOIN zhejiang_regions zr ON ra.region_id = zr.id
JOIN china_regions d ON d.code = u.district_id
JOIN china_regions zr ON ra.region_id = zr.code
WHERE u.phone = ? AND ra.status = "active"`,
[phone]
);
@@ -682,13 +683,14 @@ router.get('/merchants/:agent_id/transfers', async (req, res) => {
*/
router.get('/distribution', auth, async (req, res) => {
try {
const { id } = req.user;
const { page = 1, size = 10 } = req.query;
const { page = 1, size = 10,user_id } = req.query;
const { id } = user_id || req.user;
const pageNum = parseInt(page) || 1;
const limitNum = parseInt(size) || 10;
const offset = (page - 1) * size;
const [result] = await getDB().execute(
`SELECT real_name,phone,username,avatar,created_at FROM users WHERE inviter = ? ORDER BY created_at DESC
`SELECT real_name,phone,username,avatar,created_at,id as user_id FROM users WHERE inviter = ? ORDER BY created_at DESC
LIMIT ${size} OFFSET ${offset}`,
[parseInt(id)]
);
@@ -715,5 +717,4 @@ router.get('/distribution', auth, async (req, res) => {
}
});
module.exports = router;