红包领取记录增加account

This commit is contained in:
tianfeng 2025-11-26 15:52:00 +08:00
parent 433730cb02
commit 457db418eb
2 changed files with 19 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package com.red.circle.other.app.command.redpacket.query;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.app.convertor.RoomRedPacketAppConvertor;
import com.red.circle.other.app.dto.clientobject.RoomRedPacketDetailCO;
import com.red.circle.other.app.dto.clientobject.RoomRedPacketRecordCO;
import com.red.circle.other.app.dto.cmd.QueryRoomRedPacketDetailCmd;
import com.red.circle.other.domain.gateway.RoomRedPacketGateway;
import com.red.circle.other.domain.gateway.RoomRedPacketRecordGateway;
@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 查询红包详情执行器
@ -52,8 +54,11 @@ public class QueryRoomRedPacketDetailQryExe {
boolean grabbed = roomRedPacketCacheService.hasUserGrabbed(packetId, userId);
detailCO.setGrabbed(grabbed);
Map<Long, UserProfile> profileMap = userProfileGateway.mapByUserIds(Set.of(detailCO.getUserId()));
UserProfile userProfile = profileMap.get(userId);
Set<Long> userIdSet = detailCO.getRecords().stream().map(RoomRedPacketRecordCO::getUserId).collect(Collectors.toSet());
userIdSet.add(detailCO.getUserId());
Map<Long, UserProfile> profileMap = userProfileGateway.mapByUserIds(userIdSet);
UserProfile userProfile = profileMap.get(detailCO.getUserId());
if (userProfile != null) {
detailCO.setUserId(userProfile.getId());
detailCO.setAccount(userProfile.getAccount());
@ -61,6 +66,16 @@ public class QueryRoomRedPacketDetailQryExe {
detailCO.setUserAvatar(userProfile.getUserAvatar());
}
detailCO.getRecords().forEach(roomRedPacketRecord -> {
UserProfile profile = profileMap.get(roomRedPacketRecord.getUserId());
if (profile != null) {
roomRedPacketRecord.setUserId(profile.getId());
roomRedPacketRecord.setAccount(profile.getAccount());
roomRedPacketRecord.setUserName(profile.getUserNickname());
roomRedPacketRecord.setUserAvatar(profile.getUserAvatar());
};
});
// 5. 如果当前用户已领取设置领取金额
if (grabbed) {
Optional<RoomRedPacketRecord> myRecord = records.stream()

View File

@ -20,6 +20,8 @@ public class RoomRedPacketRecordCO {
*/
private Long userId;
private String account;
/**
* 领取人昵称
*/