diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsGiveServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsGiveServiceImpl.java index 8c2519f6..6c9266b0 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsGiveServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsGiveServiceImpl.java @@ -10,6 +10,7 @@ import com.red.circle.console.app.service.admin.UserAccountService; import com.red.circle.console.inner.error.ConsoleErrorCode; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.other.inner.endpoint.live.RoomManagerClient; +import com.red.circle.other.inner.endpoint.material.gift.GiftBackpackClient; import com.red.circle.other.inner.endpoint.material.props.*; import com.red.circle.other.inner.endpoint.user.user.SysUserProfileClient; import com.red.circle.other.inner.enums.material.BadgeBackpackExpireTypeEnum; @@ -69,6 +70,7 @@ public class PropsGiveServiceImpl implements PropsGiveService { private final PropsNobleVipClient propsNobleVipClient; private final RoomThemeBackpackClient roomThemeBackpackClient; private final PropsCommodityStoreClient propsCommodityStoreClient; + private final GiftBackpackClient giftBackpackClient; private final UserAccountService userAccountService; private final PropCouponClient propCouponClient; @@ -109,6 +111,7 @@ public class PropsGiveServiceImpl implements PropsGiveService { .setType(cmd.getType()) .setSecondaryType(cmd.getSecondaryType()) .setContent(cmd.getContent()) + .setQuantity(cmd.getQuantity()) .setSysOrigin(cmd.getSysOrigin()) .setReceiverAccounts(cmd.getReceiverAccounts()) .setVipOrigin(cmd.getVipOrigin()) @@ -127,7 +130,7 @@ public class PropsGiveServiceImpl implements PropsGiveService { ResponseAssert.isFalse(UserErrorCode.USER_INFO_NOT_FOUND, StringUtils.isBlank(sysOrigin)); // 后台赠送道具校验权限 - if (!"BADGE".equals(cmd.getType())) { + if (!"BADGE".equals(cmd.getType()) && !"GIFT".equals(cmd.getType())) { checkUserAccountAlias(cmd); } @@ -165,6 +168,10 @@ public class PropsGiveServiceImpl implements PropsGiveService { propsBackpackClient.givePropsNotify(cmd.getReceiverId(),cmd.getSecondaryType(),cmd.getExchangeDays(), Long.valueOf(cmd.getContent())); return; } + if (Objects.equals(cmd.getType(), PropsActivityRewardEnum.GIFT.name())) { + handleGift(cmd); + return; + } if (Objects.equals(cmd.getType(), PropsActivityRewardEnum.GOLD.name())) { handleGold(cmd); return; @@ -388,6 +395,21 @@ public class PropsGiveServiceImpl implements PropsGiveService { } + private void handleGift(PropsGiveUserCmd cmd) { + Long giftId = DataTypeUtils.toLong(cmd.getContent()); + ResponseAssert.isFalse(ConsoleErrorCode.RESOURCES_SHELF_NOT_EXISTENT, + Objects.isNull(giftId) || Objects.equals(giftId, 0L)); + + Integer quantity = Objects.nonNull(cmd.getQuantity()) + ? cmd.getQuantity() + : cmd.getExchangeDays(); + ResponseAssert.isFalse(ConsoleErrorCode.NUMBER_VIOLATION_ERROR, + Objects.isNull(quantity) || quantity <= 0); + + ResponseAssert.requiredSuccess( + giftBackpackClient.incrGift(cmd.getReceiverId(), giftId, quantity)); + } + private void isUserNormal(Long userId) { UserProfileDTO userProfile = ResponseAssert.requiredSuccess( userProfileClient.getByUserId(userId)); diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/cmd/app/props/PropsGiveUserCmd.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/cmd/app/props/PropsGiveUserCmd.java index ab0c28ac..2cc94051 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/cmd/app/props/PropsGiveUserCmd.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/cmd/app/props/PropsGiveUserCmd.java @@ -41,6 +41,11 @@ public class PropsGiveUserCmd extends Command { @NotNull(message = "exchangeDays required.") private Integer exchangeDays; + /** + * 礼物数量. + */ + private Integer quantity; + /** * 道具类型. */