From e3e3a625b42aee1130ecd81598d65cd1354010e9 Mon Sep 17 00:00:00 2001 From: cst61 Date: Fri, 22 May 2026 18:32:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E8=AE=A2=E8=B4=A7=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E6=97=B6=E6=98=AF=E5=85=B3=E8=81=94=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E7=89=B9=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rj/entity/LbPurchaseApply.java | 8 ++ .../impl/LbPurchaseApplyServiceImpl.java | 82 +++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/src/main/java/com/rj/entity/LbPurchaseApply.java b/src/main/java/com/rj/entity/LbPurchaseApply.java index 9852016..f81e76d 100644 --- a/src/main/java/com/rj/entity/LbPurchaseApply.java +++ b/src/main/java/com/rj/entity/LbPurchaseApply.java @@ -75,4 +75,12 @@ public class LbPurchaseApply implements Serializable { @TableField("update_time") @Schema(description = "更新时间") private LocalDateTime updateTime; + + @TableField(exist = false) + @Schema(description = "申请人用户信息(非数据库字段)") + private LbUser applicantUser; + + @TableField(exist = false) + @Schema(description = "推荐人用户信息(非数据库字段)") + private LbUser referrerUser; } diff --git a/src/main/java/com/rj/service/impl/LbPurchaseApplyServiceImpl.java b/src/main/java/com/rj/service/impl/LbPurchaseApplyServiceImpl.java index d3b1f78..75733f7 100644 --- a/src/main/java/com/rj/service/impl/LbPurchaseApplyServiceImpl.java +++ b/src/main/java/com/rj/service/impl/LbPurchaseApplyServiceImpl.java @@ -15,10 +15,12 @@ import com.rj.dto.hxr.HxrUserRow; import com.rj.entity.LbDailyUserTrade; import com.rj.entity.LbDailyUserTradeReport; import com.rj.entity.LbPurchaseApply; +import com.rj.entity.LbUser; import com.rj.util.IsoWorkdayUtils; import com.rj.mapper.LbDailyUserTradeMapper; import com.rj.mapper.LbDailyUserTradeReportMapper; import com.rj.mapper.LbPurchaseApplyMapper; +import com.rj.mapper.LbUserMapper; import com.rj.service.HxrAdminUserService; import com.rj.service.ILbPurchaseApplyService; import jakarta.servlet.ServletOutputStream; @@ -66,6 +68,9 @@ public class LbPurchaseApplyServiceImpl @Autowired private HxrAdminUserService hxrAdminUserService; + @Autowired + private LbUserMapper lbUserMapper; + @Autowired private ObjectMapper objectMapper; @@ -441,6 +446,7 @@ public class LbPurchaseApplyServiceImpl .orderByDesc(LbPurchaseApply::getCreateTime); Page page = this.page(new Page<>(current, size), queryWrapper); + fillLinkedLbUsers(page.getRecords()); result.put("success", true); result.put("message", "查询成功"); result.put("data", page.getRecords()); @@ -456,6 +462,82 @@ public class LbPurchaseApplyServiceImpl } } + /** + * 按租户 + 手机号关联 {@link LbUser}:申请人 {@code applyPhone}、推荐人 {@code colleaguePhone} 分别对应 + * {@link LbPurchaseApply#applicantUser}、{@link LbPurchaseApply#referrerUser}(仅返回脱敏后的用户字段)。 + */ + private void fillLinkedLbUsers(List records) { + if (records == null || records.isEmpty()) { + return; + } + Set mobiles = new HashSet<>(); + for (LbPurchaseApply record : records) { + String applyPhone = trimToNull(record.getApplyPhone()); + if (applyPhone != null) { + mobiles.add(applyPhone); + } + String colleaguePhone = trimToNull(record.getColleaguePhone()); + if (colleaguePhone != null) { + mobiles.add(colleaguePhone); + } + } + if (mobiles.isEmpty()) { + return; + } + LambdaQueryWrapper userQuery = new LambdaQueryWrapper<>(); + userQuery.in(LbUser::getMobile, mobiles); + List lbUsers = lbUserMapper.selectList(userQuery); + Map userByTenantMobile = new HashMap<>(); + for (LbUser user : lbUsers) { + String mobile = trimToNull(user.getMobile()); + if (mobile == null) { + continue; + } + userByTenantMobile.put(buildTenantMobileKey(user.getTenantId(), mobile), toPublicUserView(user)); + } + for (LbPurchaseApply record : records) { + String applyPhone = trimToNull(record.getApplyPhone()); + if (applyPhone != null) { + record.setApplicantUser(userByTenantMobile.get(buildTenantMobileKey(record.getTenantId(), applyPhone))); + } + String colleaguePhone = trimToNull(record.getColleaguePhone()); + if (colleaguePhone != null) { + record.setReferrerUser(userByTenantMobile.get(buildTenantMobileKey(record.getTenantId(), colleaguePhone))); + } + } + } + + /** + * 分页关联用户时仅暴露业务所需字段,其余置空或 0,避免泄露手机号、密码等隐私。 + */ + private static LbUser toPublicUserView(LbUser source) { + if (source == null) { + return null; + } + LbUser view = new LbUser(); + view.setId(source.getId()); + view.setViptime(source.getViptime()); + view.setIsVip(source.getIsVip()); + view.setTodayBuyTotal(source.getTodayBuyTotal()); + view.setTodaySellTotal(source.getTodaySellTotal()); + view.setJoinTime(source.getJoinTime()); + return view; + } + + private static String buildTenantMobileKey(String tenantId, String mobile) { + String tenantPart = tenantId == null ? "" : tenantId.trim(); + String mobilePart = mobile == null ? "" : mobile.trim(); + return tenantPart + "#" + mobilePart; + } + + private static String trimToNull(String value) { + if (value == null) { + return null; + } + String trimmed = value.trim(); + return trimmed.isEmpty() ? null : trimmed; + } + @Override public Map listNeedPrivilegeRecommenders(LocalDate startDate, LocalDate endDate) { Map result = new HashMap<>();