查看订货申请时是关联用户的特权
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<LbPurchaseApply> 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<LbPurchaseApply> records) {
|
||||
if (records == null || records.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Set<String> 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<LbUser> userQuery = new LambdaQueryWrapper<>();
|
||||
userQuery.in(LbUser::getMobile, mobiles);
|
||||
List<LbUser> lbUsers = lbUserMapper.selectList(userQuery);
|
||||
Map<String, LbUser> 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<String, Object> listNeedPrivilegeRecommenders(LocalDate startDate, LocalDate endDate) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user