提交
This commit is contained in:
@@ -248,30 +248,30 @@ class TransferService {
|
||||
|
||||
let whereClause = 'WHERE ';
|
||||
const params = [];
|
||||
whereClause += `transfer_type='${user_type}'`;
|
||||
whereClause += `t.transfer_type='${user_type}'`;
|
||||
// 构建查询条件
|
||||
if (filters.user_id) {
|
||||
whereClause += ' AND (from_user_id = ? OR to_user_id = ?)';
|
||||
whereClause += ' AND (t.from_user_id = ? OR t.to_user_id = ?)';
|
||||
params.push(filters.user_id, filters.user_id);
|
||||
}
|
||||
|
||||
if (filters.status) {
|
||||
whereClause += ' AND status = ?';
|
||||
whereClause += ' AND t.status = ?';
|
||||
params.push(filters.status);
|
||||
}
|
||||
|
||||
if (filters.transfer_type) {
|
||||
whereClause += ' AND transfer_type = ?';
|
||||
whereClause += ' AND t.transfer_type = ?';
|
||||
params.push(filters.transfer_type);
|
||||
}
|
||||
|
||||
if (filters.start_date) {
|
||||
whereClause += ' AND created_at >= ?';
|
||||
whereClause += ' AND t.created_at >= ?';
|
||||
params.push(filters.start_date);
|
||||
}
|
||||
|
||||
if (filters.end_date) {
|
||||
whereClause += ' AND created_at <= ?';
|
||||
whereClause += ' AND t.created_at <= ?';
|
||||
params.push(filters.end_date);
|
||||
}
|
||||
|
||||
@@ -299,28 +299,6 @@ class TransferService {
|
||||
params
|
||||
);
|
||||
const total = countResult[0].total;
|
||||
console.log(`SELECT t.*,
|
||||
fu.username as from_username,
|
||||
fu.real_name as from_real_name,
|
||||
tu.username as to_username,
|
||||
tu.real_name as to_real_name,
|
||||
f_p.name as from_province,
|
||||
f_c.name as from_city,
|
||||
f_d.name as from_district,
|
||||
t_p.name as to_province,
|
||||
t_c.name as to_city,
|
||||
t_d.name as to_district
|
||||
FROM transfers t
|
||||
LEFT JOIN users fu ON t.from_user_id = fu.id
|
||||
LEFT JOIN users tu ON t.to_user_id = tu.id
|
||||
LEFT JOIN china_regions f_p on f_p.code = fu.province
|
||||
LEFT JOIN china_regions f_c on f_c.code = fu.city
|
||||
LEFT JOIN china_regions f_d on f_d.code = fu.district_id
|
||||
LEFT JOIN china_regions t_p on t_p.code = tu.province
|
||||
LEFT JOIN china_regions t_c on t_c.code = tu.city
|
||||
LEFT JOIN china_regions t_d on t_d.code = tu.district_id
|
||||
${whereClause} ${orderClause}
|
||||
LIMIT ${limitNum} OFFSET ${offset}`)
|
||||
// 获取数据
|
||||
const [transfers] = await db.execute(
|
||||
`SELECT t.*,
|
||||
|
||||
Reference in New Issue
Block a user