提交
This commit is contained in:
@@ -724,6 +724,7 @@ class MatchingService {
|
||||
AND u.audit_status = 'approved'
|
||||
AND u.user_type != 'directly_operated'
|
||||
AND u.payment_status = 'paid'
|
||||
AND u.province = ?
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN u.city = ? AND u.district_id = ? THEN 1 -- 相同城市且相同区县排第一
|
||||
@@ -732,7 +733,7 @@ class MatchingService {
|
||||
ELSE 4 -- 其他省份排第四
|
||||
END,
|
||||
u.balance ASC`,
|
||||
[excludeUserId, currentUserCity, currentUserDistrictId, currentUserCity, currentUserProvince]
|
||||
[excludeUserId,currentUserProvince, currentUserCity, currentUserDistrictId, currentUserCity, currentUserProvince]
|
||||
);
|
||||
|
||||
// 处理查询到的负余额用户
|
||||
@@ -795,7 +796,23 @@ class MatchingService {
|
||||
// 所有查询到的用户都是负余额用户,直接添加到可用列表
|
||||
}
|
||||
userBalanceResult = userBalanceResult.filter(user => user.has_active_allocations < -100);
|
||||
userBalanceResult = userBalanceResult.sort((a, b) => a.has_active_allocations - b.has_active_allocations);
|
||||
userBalanceResult = userBalanceResult.sort((a, b) => {
|
||||
const getPriority = (user) => {
|
||||
if (user.district_id === currentUserDistrictId) return 1; // 同区县
|
||||
if (user.city === currentUserCity) return 2; // 同城市
|
||||
return 3; // 其他
|
||||
};
|
||||
|
||||
const priorityA = getPriority(a);
|
||||
const priorityB = getPriority(b);
|
||||
|
||||
if (priorityA !== priorityB) {
|
||||
return priorityA - priorityB; // 优先级小的排前
|
||||
}
|
||||
|
||||
// 同优先级里:越接近0(数值越大)排前 -> 使用降序
|
||||
return b.has_active_allocations - a.has_active_allocations;
|
||||
});
|
||||
for (const user of userBalanceResult) {
|
||||
if (maxTransfers > availableUsers.length + 1) {
|
||||
if (minTransfers === 3 && availableUsers.length < 3) {
|
||||
|
||||
Reference in New Issue
Block a user