From 4bb1da87e4015c5125c40aba028c46abf483e99d Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 20 Nov 2025 18:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=93=E5=85=B7=E5=88=B8=E9=81=93=E5=85=B7?= =?UTF-8?q?=E5=A4=A9=E6=95=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmd/material/PropCouponGrantCmd.java | 9 ++++-- .../propcoupon/PropCouponGrantCmdExe.java | 31 +++++++++++++------ .../propcoupon/PropCouponUseCmdExe.java | 2 +- .../infra/common/props/PropsSendCommon.java | 4 ++- .../rds/entity/props/PropCouponDO.java | 5 +++ .../infra/gateway/PropCouponGatewayImpl.java | 2 ++ 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/material/PropCouponGrantCmd.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/material/PropCouponGrantCmd.java index d8cb8803..2ef6d0ee 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/material/PropCouponGrantCmd.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/model/cmd/material/PropCouponGrantCmd.java @@ -38,8 +38,13 @@ public class PropCouponGrantCmd extends Command { /** * 有效天数 */ - @NotNull(message = "有效天数不能为空") - private Integer validDays; + private Integer validDays = 30; + + /** + * 道具天数 + */ + @NotNull(message = "道具天数不能为空") + private Integer propDays; /** * 接收用户ID列表 diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponGrantCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponGrantCmdExe.java index 70b02ac9..6b4b192d 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponGrantCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponGrantCmdExe.java @@ -4,6 +4,8 @@ import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateCustomizeCmd; import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.inner.model.cmd.material.PropCouponGrantCmd; import com.red.circle.other.domain.gateway.PropCouponGateway; import com.red.circle.other.domain.propcoupon.PropCoupon; @@ -37,9 +39,9 @@ import java.util.stream.Collectors; public class PropCouponGrantCmdExe { private final PropCouponGateway propCouponGateway; - private final UserProfileClient userProfileClient; private final OfficialNoticeClient officialNoticeClient; private final PropsSourceClient propsSourceClient; + private final UserProfileGateway userProfileGateway; /** * 执行后台赠送道具券 @@ -52,7 +54,7 @@ public class PropCouponGrantCmdExe { // 2. 校验用户是否存在 Set userIds = cmd.getUserIds().stream().map(Long::parseLong).collect(Collectors.toSet()); - Map userMap = validateUsers(userIds); + Map userMap = validateUsers(userIds); PropsResourcesDTO propsResourcesDTO = ResponseAssert.requiredSuccess( propsSourceClient.getById(Long.parseLong(cmd.getPropId()))); @@ -93,10 +95,20 @@ public class PropCouponGrantCmdExe { /** * 校验用户是否存在 */ - private Map validateUsers(Set userIds) { - Map userMap = ResponseAssert.requiredSuccess( - userProfileClient.mapByUserIds(userIds) - ); + private Map validateUsers(Set userIds) { + Map userMap = userProfileGateway.mapByUserIds(userIds); + + if (userMap.isEmpty()) { + Map map = new HashMap<>(); + userIds.forEach(userId -> { + List userProfiles = userProfileGateway.getByAccount(String.valueOf(userId)); + if (!userProfiles.isEmpty()) { + UserProfile userProfile = userProfiles.get(0); + map.put(userProfile.getId(), userProfile); + } + }); + return map; + } // 校验所有用户都存在 ResponseAssert.isTrue(OtherErrorCode.PROP_COUPON_RECEIVER_NOT_FOUND, @@ -124,6 +136,7 @@ public class PropCouponGrantCmdExe { propCoupon.setPropIcon(cmd.getPropIcon()); propCoupon.setPropName(displayPropName); propCoupon.setValidDays(cmd.getValidDays()); + propCoupon.setPropDays(cmd.getPropDays()); propCoupon.setStatus(PropCouponStatus.UNUSED); propCoupon.setSource(PropCouponSource.ADMIN_GRANT); propCoupon.setExpireTime(expireTime); @@ -178,10 +191,10 @@ public class PropCouponGrantCmdExe { /** * 发送系统消息通知用户 */ - private void sendNotifications(List propCoupons, Map userMap, PropCouponType couponType) { + private void sendNotifications(List propCoupons, Map userMap, PropCouponType couponType) { for (PropCoupon propCoupon : propCoupons) { try { - UserProfileDTO user = userMap.get(propCoupon.getUserId()); + UserProfile user = userMap.get(propCoupon.getUserId()); if (user != null) { sendNotification(propCoupon, user, couponType); } @@ -195,7 +208,7 @@ public class PropCouponGrantCmdExe { /** * 发送单个通知 */ - private void sendNotification(PropCoupon propCoupon, UserProfileDTO user, PropCouponType couponType) { + private void sendNotification(PropCoupon propCoupon, UserProfile user, PropCouponType couponType) { officialNoticeClient.send( NoticeExtTemplateCustomizeCmd.builder() .toAccount(user.getId()) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponUseCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponUseCmdExe.java index 3e4e0463..db47404b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponUseCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/PropCouponUseCmdExe.java @@ -110,7 +110,7 @@ public class PropCouponUseCmdExe { private void givePropsToUser(PropCoupon propCoupon, Long userId) { PropCouponType couponType = propCoupon.getCouponType(); Long propId = propCoupon.getPropId(); - Integer validDays = propCoupon.getValidDays(); + Integer validDays = propCoupon.getPropDays(); switch (couponType) { case AVATAR_FRAME: diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java index 1b309fc5..139e792e 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java @@ -189,7 +189,8 @@ public class PropsSendCommon { grantCmd.setPropIcon(propsSourceRecord.getCover()); grantCmd.setPropName(propsSourceRecord.getName()); grantCmd.setCouponType(couponType.getCode()); - grantCmd.setValidDays(prizeDescribe.getQuantity()); + grantCmd.setValidDays(30); + grantCmd.setPropDays(prizeDescribe.getQuantity()); List propCoupons = generateCoupons(grantCmd, source, couponType, Collections.singleton(acceptUserId)); // 5. 批量插入券记录 @@ -490,6 +491,7 @@ public class PropsSendCommon { propCoupon.setPropIcon(cmd.getPropIcon()); propCoupon.setPropName(displayPropName); propCoupon.setValidDays(cmd.getValidDays()); + propCoupon.setPropDays(cmd.getPropDays()); propCoupon.setStatus(PropCouponStatus.UNUSED); propCoupon.setSource(source); propCoupon.setExpireTime(expireTime); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/props/PropCouponDO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/props/PropCouponDO.java index ac103c54..dbf28781 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/props/PropCouponDO.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/props/PropCouponDO.java @@ -58,6 +58,11 @@ public class PropCouponDO { */ private Integer validDays; + /** + * 道具天数 + */ + private Integer propDays; + /** * 券状态(0未使用 1已使用 2已过期 3已赠送) */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java index ebd1b622..93a02af6 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java @@ -139,6 +139,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway { propCoupon.setPropIcon(propCouponDO.getPropIcon()); propCoupon.setPropName(propCouponDO.getPropName()); propCoupon.setValidDays(propCouponDO.getValidDays()); + propCoupon.setPropDays(propCouponDO.getPropDays()); propCoupon.setStatus(PropCouponStatus.getByCode(propCouponDO.getStatus())); propCoupon.setSource(PropCouponSource.getByCode(propCouponDO.getSource())); propCoupon.setExpireTime(propCouponDO.getExpireTime()); @@ -164,6 +165,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway { propCouponDO.setPropIcon(propCoupon.getPropIcon()); propCouponDO.setPropName(propCoupon.getPropName()); propCouponDO.setValidDays(propCoupon.getValidDays()); + propCouponDO.setPropDays(propCoupon.getPropDays()); propCouponDO.setStatus(propCoupon.getStatus() != null ? propCoupon.getStatus().getCode() : null); propCouponDO.setSource(propCoupon.getSource() != null ? propCoupon.getSource().getCode() : null); propCouponDO.setExpireTime(propCoupon.getExpireTime());