feat: expose store status on props resources

This commit is contained in:
hy001 2026-05-17 01:02:17 +08:00
parent d17f75e42d
commit 3fc5d4a4ff
6 changed files with 148 additions and 84 deletions

View File

@ -4,6 +4,8 @@ import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse; import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import java.util.Map;
import java.util.Set;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -28,6 +30,14 @@ public interface PropsCommodityStoreClientApi {
@RequestParam("sourceId") Long sourceId @RequestParam("sourceId") Long sourceId
); );
/**
* 批量获取资源对应商品.
*/
@PostMapping("/mapBySourceIds")
ResultResponse<Map<Long, PropsCommodityStoreDTO>> mapBySourceIds(
@RequestParam("sysOrigin") String sysOrigin,
@RequestBody Set<Long> sourceIds);
/** /**
* 商店分页列表. * 商店分页列表.
*/ */

View File

@ -5,16 +5,19 @@ import com.red.circle.console.app.dto.clienobject.props.PropsResourcesOpsCO;
import com.red.circle.console.app.dto.cmd.app.props.PropsSourceRecordSaveOrUpdateCmd; import com.red.circle.console.app.dto.cmd.app.props.PropsSourceRecordSaveOrUpdateCmd;
import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.inner.endpoint.material.props.PropsCommodityStoreClient;
import com.red.circle.other.inner.endpoint.material.props.PropsRedPacketSkinClient; import com.red.circle.other.inner.endpoint.material.props.PropsRedPacketSkinClient;
import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient; import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient;
import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum; import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum;
import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.other.inner.model.dto.material.PropsRedPacketSkinDTO; import com.red.circle.other.inner.model.dto.material.PropsRedPacketSkinDTO;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO;
import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@ -36,6 +39,7 @@ public class PropsSourceServiceImpl implements PropsSourceService {
private final PropsAppConvertor propsAppConvertor; private final PropsAppConvertor propsAppConvertor;
private final PropsSourceClient propsSourceClient; private final PropsSourceClient propsSourceClient;
private final PropsRedPacketSkinClient propsRedPacketSkinClient; private final PropsRedPacketSkinClient propsRedPacketSkinClient;
private final PropsCommodityStoreClient propsCommodityStoreClient;
@Override @Override
public List<PropsResourcesDTO> listSysOrigin(String sysOrigin, String type) { public List<PropsResourcesDTO> listSysOrigin(String sysOrigin, String type) {
@ -62,10 +66,12 @@ public class PropsSourceServiceImpl implements PropsSourceService {
if (CollectionUtils.isEmpty(pageResult.getRecords())) { if (CollectionUtils.isEmpty(pageResult.getRecords())) {
return pageResult.emptyRecords(); return pageResult.emptyRecords();
} }
Set<Long> sourceIds = pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect(
Collectors.toSet());
Map<Long, PropsRedPacketSkinDTO> redPacketSkinMap = ResponseAssert.requiredSuccess( Map<Long, PropsRedPacketSkinDTO> redPacketSkinMap = ResponseAssert.requiredSuccess(
propsRedPacketSkinClient.mapRedPacketSkinByIds( propsRedPacketSkinClient.mapRedPacketSkinByIds(sourceIds));
pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect( Map<Long, PropsCommodityStoreDTO> storeCommodityMap = ResponseAssert.requiredSuccess(
Collectors.toSet()))); propsCommodityStoreClient.mapBySourceIds(qryCmd.getSysOrigin(), sourceIds));
return pageResult.convert(propsResources -> { return pageResult.convert(propsResources -> {
PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources); PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources);
@ -80,6 +86,7 @@ public class PropsSourceServiceImpl implements PropsSourceService {
propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl()); propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl());
propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo()); propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo());
} }
propsResourcesOpsCO.setStoreCommodity(storeCommodityMap.get(propsResources.getId()));
propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType())); propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType()));
return propsResourcesOpsCO; return propsResourcesOpsCO;
} }

View File

@ -3,6 +3,7 @@ package com.red.circle.console.app.dto.clienobject.props;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.framework.dto.ClientObject; import com.red.circle.framework.dto.ClientObject;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -68,6 +69,11 @@ public class PropsResourcesOpsCO extends ClientObject {
*/ */
private BigDecimal amount; private BigDecimal amount;
/**
* 对应道具商店商品.
*/
private PropsCommodityStoreDTO storeCommodity;
/** /**
* 0.未删除 1.已删除. * 0.未删除 1.已删除.
*/ */

View File

@ -6,6 +6,8 @@ import com.red.circle.other.app.inner.service.material.props.PropsCommodityStore
import com.red.circle.other.inner.endpoint.material.props.api.PropsCommodityStoreClientApi; import com.red.circle.other.inner.endpoint.material.props.api.PropsCommodityStoreClientApi;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -32,6 +34,13 @@ public class PropsCommodityStoreClientEndpoint implements PropsCommodityStoreCli
propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId)); propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId));
} }
@Override
public ResultResponse<Map<Long, PropsCommodityStoreDTO>> mapBySourceIds(String sysOrigin,
Set<Long> sourceIds) {
return ResultResponse.success(
propsCommodityStoreClientService.mapBySourceIds(sysOrigin, sourceIds));
}
@Override @Override
public ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps( public ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps(
PropsCommodityStoreQryCmd qryCmd) { PropsCommodityStoreQryCmd qryCmd) {

View File

@ -3,6 +3,8 @@ package com.red.circle.other.app.inner.service.material.props;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import java.util.Map;
import java.util.Set;
/** /**
* 道具商店. * 道具商店.
@ -16,6 +18,11 @@ public interface PropsCommodityStoreClientService {
*/ */
PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId); PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId);
/**
* 批量获取资源对应商品.
*/
Map<Long, PropsCommodityStoreDTO> mapBySourceIds(String sysOrigin, Set<Long> sourceIds);
/** /**
* 商店分页列表. * 商店分页列表.
*/ */

View File

@ -8,8 +8,14 @@ import com.red.circle.other.infra.database.rds.entity.props.PropsCommodityStore;
import com.red.circle.other.infra.database.rds.service.props.PropsCommodityStoreService; import com.red.circle.other.infra.database.rds.service.props.PropsCommodityStoreService;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.text.StringUtils; import com.red.circle.tool.core.text.StringUtils;
import java.util.Collections;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,6 +38,25 @@ public class PropsCommodityStoreClientServiceImpl implements PropsCommodityStore
); );
} }
@Override
public Map<Long, PropsCommodityStoreDTO> mapBySourceIds(String sysOrigin, Set<Long> sourceIds) {
if (StringUtils.isBlank(sysOrigin) || CollectionUtils.isEmpty(sourceIds)) {
return Collections.emptyMap();
}
return propsCommodityStoreService.query()
.eq(PropsCommodityStore::getSysOrigin, sysOrigin)
.in(PropsCommodityStore::getSourceId, sourceIds)
.eq(PropsCommodityStore::getDel, Boolean.FALSE)
.orderByDesc(PropsCommodityStore::getUpdateTime)
.list()
.stream()
.map(propsCommodityStoreInnerConvertor::toPropsCommodityStoreDTO)
.collect(Collectors.toMap(
PropsCommodityStoreDTO::getSourceId,
Function.identity(),
(first, ignored) -> first));
}
@Override @Override
public PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd) { public PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd) {
return propsCommodityStoreInnerConvertor.toPagePropsCommodityStoreDTO( return propsCommodityStoreInnerConvertor.toPagePropsCommodityStoreDTO(