From ad98917741e0b22c34f9202dfc7afc077e6252cc Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 13 Nov 2025 17:18:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A2=86=E5=8F=96=E9=81=93?= =?UTF-8?q?=E5=85=B7=E5=88=B8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rocket/RocketRewardClaimCmdExe.java | 31 ++++++++++++++++--- .../infra/common/props/PropsSendCommon.java | 10 +++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/rocket/RocketRewardClaimCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/rocket/RocketRewardClaimCmdExe.java index 3c050fa7..9fe06bdc 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/rocket/RocketRewardClaimCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/rocket/RocketRewardClaimCmdExe.java @@ -15,7 +15,9 @@ import com.red.circle.other.domain.gateway.RocketConfigGateway; import com.red.circle.other.domain.gateway.RocketHistoryGateway; import com.red.circle.other.domain.gateway.RocketRewardLogGateway; import com.red.circle.other.domain.gateway.RocketStatusGateway; +import com.red.circle.other.domain.propcoupon.PropCouponSource; import com.red.circle.other.domain.rocket.*; +import com.red.circle.other.infra.common.props.PropsSendCommon; import com.red.circle.other.infra.database.cache.key.RocketKeys; import com.red.circle.other.inner.endpoint.material.props.BadgeBackpackClient; import com.red.circle.other.inner.endpoint.material.props.PropsBackpackClient; @@ -23,6 +25,7 @@ import com.red.circle.other.inner.enums.material.BadgeBackpackExpireTypeEnum; import com.red.circle.other.inner.enums.sys.SysBadgeConfigTypeEnum; import com.red.circle.other.inner.model.cmd.material.GiveBadgeCmd; import com.red.circle.other.inner.model.cmd.material.GivePropsBackpackCmd; +import com.red.circle.other.inner.model.cmd.material.PrizeDescribe; import com.red.circle.other.inner.model.dto.material.PropsActivityRewardConfigInfoDTO; import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient; import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd; @@ -32,13 +35,11 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; +import java.lang.reflect.Array; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; +import java.util.*; /** * 火箭奖励领取命令执行器 @@ -60,7 +61,7 @@ public class RocketRewardClaimCmdExe { private final PropsBackpackClient propsBackpackClient; private final BadgeBackpackClient badgeBackpackClient; private final RocketHistoryGateway rocketHistoryGateway; - + private final PropsSendCommon propsSendCommon; private final Random random = new Random(); /** @@ -217,6 +218,10 @@ public class RocketRewardClaimCmdExe { Integer quantity = reward.getQuantity() != null ? reward.getQuantity() : 1; grantBadge(userId, badgeId, quantity, bizNo); } + case "PROP_COUPON" -> { + Integer quantity = reward.getQuantity() != null ? reward.getQuantity() : 1; + grantPropCoupon(userId, reward.getContent(), quantity); + } default -> throw new RuntimeException("不支持的奖励类型: " + rewardType); } @@ -252,6 +257,22 @@ public class RocketRewardClaimCmdExe { } } + + /** + * 发放道具 + */ + private void grantPropCoupon(Long userId, String propId, Integer quantity) { + try { + PrizeDescribe prizeDescribe = new PrizeDescribe(); + prizeDescribe.setContent(propId); + prizeDescribe.setQuantity(quantity); + propsSendCommon.sendPropCoupon(userId, PropCouponSource.ACTIVITY, List.of(prizeDescribe)); + } catch (Exception e) { + log.error("道具券发放失败: userId={}, propId={}", userId, propId, e); + throw new RuntimeException("道具券发放失败"); + } + } + /** * 发放道具 */ 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 98cf6dd0..1b309fc5 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 @@ -161,7 +161,7 @@ public class PropsSendCommon { // 发放道具券 List coupons = filterPrize(cmd, PropsActivityRewardEnum.PROP_COUPON); - sendPropCoupon(cmd.getAcceptUserId(), coupons); + sendPropCoupon(cmd.getAcceptUserId(), PropCouponSource.ADMIN_GRANT, coupons); saveSendLog(cmd); } @@ -176,7 +176,7 @@ public class PropsSendCommon { }); } - private void sendPropCoupon(Long acceptUserId, List coupons) { + public void sendPropCoupon(Long acceptUserId, PropCouponSource source, List coupons) { coupons.forEach(prizeDescribe -> { String content = prizeDescribe.getContent(); @@ -191,7 +191,7 @@ public class PropsSendCommon { grantCmd.setCouponType(couponType.getCode()); grantCmd.setValidDays(prizeDescribe.getQuantity()); - List propCoupons = generateCoupons(grantCmd, couponType, Collections.singleton(acceptUserId)); + List propCoupons = generateCoupons(grantCmd, source, couponType, Collections.singleton(acceptUserId)); // 5. 批量插入券记录 propCouponGateway.batchSave(propCoupons); @@ -474,7 +474,7 @@ public class PropsSendCommon { /** * 批量生成券 */ - private List generateCoupons(PropCouponGrantCmd cmd, PropCouponType couponType, Set userIds) { + private List generateCoupons(PropCouponGrantCmd cmd, PropCouponSource source, PropCouponType couponType, Set userIds) { List propCoupons = new ArrayList<>(); LocalDateTime now = LocalDateTime.now(); LocalDateTime expireTime = now.plusDays(cmd.getValidDays()); @@ -491,7 +491,7 @@ public class PropsSendCommon { propCoupon.setPropName(displayPropName); propCoupon.setValidDays(cmd.getValidDays()); propCoupon.setStatus(PropCouponStatus.UNUSED); - propCoupon.setSource(PropCouponSource.ADMIN_GRANT); + propCoupon.setSource(source); propCoupon.setExpireTime(expireTime); propCoupon.setCreateTime(now); propCoupon.setUpdateTime(now);