From bfb6350d3a13aea1c4c6b53d04a513c17e2a2c29 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 4 Dec 2025 19:08:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E5=85=85=E5=A5=96=E5=8A=B1=E5=85=85?= =?UTF-8?q?=E5=80=BC=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/app/common/InAppPurchaseCommon.java | 49 ++++++++++- .../app/listener/BuySuccessListener.java | 85 ++++++------------- .../UserRunProfileTransportGatewayImpl.java | 12 +-- .../other-start/src/test/java/SpringTest.java | 46 ++++++++++ .../bank/UserBankExchangeGoldCmdExe.java | 39 +++++++++ .../freight/DealerToUserShipCmdExe.java | 43 +++++++++- .../freight/SendFreightShipCmdExe.java | 43 +++++++++- .../salary/SalaryExchangeGoldCmdExe.java | 42 ++++++++- 8 files changed, 288 insertions(+), 71 deletions(-) diff --git a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/InAppPurchaseCommon.java b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/InAppPurchaseCommon.java index 1894178f..0a85f0aa 100644 --- a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/InAppPurchaseCommon.java +++ b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/InAppPurchaseCommon.java @@ -3,9 +3,12 @@ package com.red.circle.order.app.common; import com.red.circle.common.business.core.enums.ReceiptType; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.enums.SendPropsOrigin; +import com.red.circle.component.mq.MessageEventProcess; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.framework.dto.ResultResponse; import com.red.circle.framework.web.props.EnvProperties; +import com.red.circle.mq.business.model.event.pay.BuySuccessEvent; import com.red.circle.order.app.command.pay.web.strategy.PayEnv; import com.red.circle.order.domain.gateway.UserRechargeCountGateway; import com.red.circle.order.infra.database.mongo.order.InAppPurchaseCollectionReceiptService; @@ -20,23 +23,29 @@ import com.red.circle.order.inner.model.enums.PayApplicationCommodityType; import com.red.circle.order.inner.model.enums.inapp.InAppPurchaseStatus; import com.red.circle.other.inner.endpoint.activity.AppRankCountClient; import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient; +import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; import com.red.circle.other.inner.endpoint.material.props.PropsToolClient; -import com.red.circle.other.inner.endpoint.user.user.UserLevelClient; +import com.red.circle.other.inner.endpoint.sys.EnumConfigClient; +import com.red.circle.other.inner.endpoint.user.user.*; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; import com.red.circle.other.inner.model.cmd.material.PrizeDescribe; import com.red.circle.other.inner.model.cmd.material.PrizeDescribeRewardCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.text.StringUtils; -import com.red.circle.other.inner.endpoint.user.user.InviteUserClient; -import com.red.circle.other.inner.endpoint.user.user.UserSvipClient; import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; +import com.red.circle.wallet.inner.endpoint.wallet.WalletDiamondClient; import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient; import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd; import com.red.circle.wallet.inner.model.enums.FreightBalanceOrigin; import com.red.circle.wallet.inner.model.enums.GoldOrigin; import java.math.BigDecimal; +import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -64,6 +73,9 @@ public class InAppPurchaseCommon { private final OrderPurchaseHistoryService orderPurchaseHistoryService; private final InAppPurchaseCollectionReceiptService inAppPurchaseCollectionReceiptService; private final UserLevelClient userLevelClient; + private final PropsActivityClient propsActivityClient; + private final UserOneTimeTaskClient userOneTimeTaskClient; + private final UserProfileClient userProfileClient; public void inAppPurchaseReceipt(InAppPurchaseDetails order) { @@ -159,6 +171,9 @@ public class InAppPurchaseCommon { order.getAcceptUserId(), order.getAmountUsd().doubleValue()); + // 发送首充奖励 + completedFirstCharge(order.getAcceptUserId(), order.getSysOrigin()); + // SVip积分累计. userSvipClient.incrIntegral(order.getAcceptUserId(), amount.longValue()); @@ -169,6 +184,34 @@ public class InAppPurchaseCommon { } + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess()) { + if (response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + + userProfileClient.removeCacheAll(userId); + } + } + } + + } + private OrderPurchaseHistory saveOrderPurchaseHistory( InAppPurchaseDetails receipt) { diff --git a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/listener/BuySuccessListener.java b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/listener/BuySuccessListener.java index 219211ab..e97ca890 100644 --- a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/listener/BuySuccessListener.java +++ b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/listener/BuySuccessListener.java @@ -11,6 +11,7 @@ import com.red.circle.component.mq.config.RocketMqMessageListener; import com.red.circle.component.mq.service.Action; import com.red.circle.component.mq.service.ConsumerMessage; import com.red.circle.component.mq.service.MessageListener; +import com.red.circle.framework.dto.ResultResponse; import com.red.circle.mq.business.model.event.pay.BuySuccessEvent; import com.red.circle.mq.business.model.event.pay.PurchaseProductEvent; import com.red.circle.mq.rocket.business.streams.BuySuccessSink; @@ -21,6 +22,7 @@ import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils; @@ -82,7 +84,7 @@ public class BuySuccessListener implements MessageListener { handleVoiceSystemRechargeRewards(eventBody); - completedFirstCharge(eventBody); + completedFirstCharge(eventBody.getUserId(), eventBody.getSysOrigin()); userExpandClient.updatePurchasingToTrue(eventBody.getUserId()); userProfileClient.removeCache(eventBody.getUserId()); @@ -101,14 +103,30 @@ public class BuySuccessListener implements MessageListener { } } - private void completedFirstCharge(BuySuccessEvent cmd) { - if (!Objects.equals(userExpandClient.checkPurchasing(cmd.getUserId()).getBody(), - Boolean.TRUE)) { - // 完成首充任务 - userOneTimeTaskClient.completedFirstCharge(cmd.getUserId(), cmd.getSysOrigin()); - // 如果首充任务为指定内购产品套餐则赠送奖励 - sendFirstChargeReward(cmd.getProductConfig(), cmd.getUserId()); - } + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess()) { + if (response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + userProfileClient.removeCacheAll(userId); + } + } + } } private void handleVoiceSystemRechargeRewards(BuySuccessEvent cmd) { @@ -194,53 +212,4 @@ public class BuySuccessListener implements MessageListener { return cmd; } - - public void sendFirstChargeReward(PurchaseProductEvent productConfig, Long userId) { - - if (Objects.isNull(productConfig) || StringUtils.isBlank(productConfig.getProductId())) { - return; - } - - List ruleConfigs = getRuleConfigs(productConfig); - if (CollectionUtils.isEmpty(ruleConfigs)) { - return; - } - - ActivityPropsRule ruleConfig = getPropsActivityRuleConfig(productConfig, ruleConfigs); - if (Objects.isNull(ruleConfig)) { - return; - } - - propsActivityClient.sendActivityReward( - new SendActivityRewardCmd() - .setTrackId(ruleConfig.getId()) - .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) - .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) - .setSourceGroupId(ruleConfig.getResourceGroupId()) - .setAcceptUserId(userId) - ); - - } - - private ActivityPropsRule getPropsActivityRuleConfig(PurchaseProductEvent productConfig, - List ruleConfigs) { - - for (ActivityPropsRule ruleConfig : ruleConfigs) { - if (StringUtils.isBlank(ruleConfig.getJsonData())) { - continue; - } - if (ruleConfig.getJsonData().contains(productConfig.getProductId())) { - return ruleConfig; - } - } - return null; - } - - private List getRuleConfigs(PurchaseProductEvent productConfig) { - return propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(productConfig.getSysOrigin()), - PropsActivityTypeEnum.FIRST_CHARGE_REWARD) - .getBody(); - } - - } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java index 35f899eb..91598501 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserRunProfileTransportGatewayImpl.java @@ -21,6 +21,7 @@ import com.red.circle.other.infra.database.mongo.service.user.profile.UserRunPro import com.red.circle.other.infra.database.mongo.service.user.profile.UserSpecialIdService; import com.red.circle.other.infra.database.rds.entity.props.PropsBackpack; import com.red.circle.other.infra.database.rds.entity.user.user.BaseInfo; +import com.red.circle.other.infra.database.rds.entity.user.user.OneTimeTask; import com.red.circle.other.infra.database.rds.service.badge.BadgeConfigService; import com.red.circle.other.infra.database.rds.service.badge.BadgePictureConfigService; import com.red.circle.other.infra.database.rds.service.props.PropsBackpackService; @@ -28,6 +29,7 @@ import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordSe import com.red.circle.other.infra.database.rds.service.props.RoomThemeUserBackpackService; import com.red.circle.other.infra.database.rds.service.props.RoomThemeUserCustomizeService; import com.red.circle.other.infra.database.rds.service.user.user.BaseInfoService; +import com.red.circle.other.infra.database.rds.service.user.user.OneTimeTaskService; import com.red.circle.other.infra.utils.ZonedDateTimeUtils; import com.red.circle.other.inner.enums.material.BadgeBackpackExpireType; import com.red.circle.other.inner.enums.material.BadgeConfigTypeEnum; @@ -42,6 +44,7 @@ import com.red.circle.other.inner.model.dto.material.RoomThemeUserCustomizeDTO; import com.red.circle.other.inner.model.dto.material.UseBadgeDTO; import com.red.circle.other.inner.model.dto.material.UsePropsDTO; import com.red.circle.other.inner.model.dto.material.props.PropsNobleVipAbilityDTO; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.DateUtils; import com.red.circle.tool.core.date.TimestampUtils; @@ -88,7 +91,7 @@ public class UserRunProfileTransportGatewayImpl implements UserRunProfileTranspo private final RoomThemeUserBackpackService roomThemeUserBackpackService; private final PropsResourcesInfraConvertor propsResourcesInfraConvertor; private final RoomThemeUserCustomizeService roomThemeUserCustomizeService; - private final TotalRechargeClient totalRechargeClient; + private final OneTimeTaskService oneTimeTaskService; @Override public UserProfile getByUserId(Long userId) { @@ -259,10 +262,9 @@ public class UserRunProfileTransportGatewayImpl implements UserRunProfileTranspo LocalDateTime createTime = newUserRunProfile.getCreateTime().toLocalDateTime(); Duration duration = Duration.between(createTime, LocalDateTime.now()); if (duration.toDays() < 7) { - ResultResponse>> response = totalRechargeClient.mapGroup(Set.of(newUserRunProfile.getId())); - if (response.getStatus()) { - List dtos = response.getBody().get(newUserRunProfile.getId()); - newUserRunProfile.setFirstRecharge(CollectionUtils.isEmpty(dtos)); + OneTimeTask response = oneTimeTaskService.queryCompletedFirstCharge(newUserRunProfile.getId(), newUserRunProfile.getOriginSys()); + if (response == null) { + newUserRunProfile.setFirstRecharge(true); newUserRunProfile.setFirstRechargeEndTime(ZonedDateTimeUtils.toTimestamp(createTime.plusDays(7))); } diff --git a/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java b/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java index bc28e252..52f586e8 100644 --- a/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java +++ b/rc-service/rc-service-other/other-start/src/test/java/SpringTest.java @@ -1,6 +1,7 @@ import com.red.circle.OtherServiceApplication; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.enums.ConsoleAccountStatusEnum; +import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.external.inner.endpoint.message.ImGroupClient; import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd; @@ -8,11 +9,14 @@ import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExt import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum; import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.dto.ReqSysOrigin; +import com.red.circle.framework.dto.ResultResponse; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.cmd.activity.RankingDataUpdateCmd; import com.red.circle.other.app.enums.violation.GameOriginEnum; +import com.red.circle.other.app.inner.service.material.props.PropsActivityClientService; import com.red.circle.other.app.service.activity.RankingActivityService; import com.red.circle.other.app.service.user.user.AppUserDataViolationService; +import com.red.circle.other.app.service.user.user.UserProfileService; import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.game.GameRankingIncrementCmd; import com.red.circle.other.domain.gateway.PropCouponGateway; @@ -25,8 +29,14 @@ import com.red.circle.other.domain.ranking.RankingCycleType; import com.red.circle.other.domain.ranking.RankingDimension; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig; +import com.red.circle.other.infra.database.rds.entity.user.user.OneTimeTask; import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; +import com.red.circle.other.infra.database.rds.service.user.user.OneTimeTaskService; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; import com.red.circle.other.inner.model.cmd.user.ApprovalAccountCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.parse.DataTypeUtils; import org.junit.Test; @@ -37,6 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -66,6 +77,41 @@ public class SpringTest { private RankingActivityService rankingActivityService; @Autowired private GameRankingGateway gameRankingGateway; + @Autowired + private UserProfileGateway userprofileGateway; + @Autowired + private OneTimeTaskService oneTimeTaskService; + @Autowired + private PropsActivityClientService propsActivityClientService; + + @Test + public void testCompletedFirstCharge() { + completedFirstCharge(1957345312961527809L, "LIKEI"); + } + + private void completedFirstCharge(Long userId, String sysOrigin) { + OneTimeTask oneTimeTask = oneTimeTaskService.queryCompletedFirstCharge(userId, sysOrigin); + if (oneTimeTask == null) { + oneTimeTaskService.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClientService.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClientService.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + userprofileGateway.removeCacheAll(userId); + } + } + } @Test public void testGameRanking() { diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankExchangeGoldCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankExchangeGoldCmdExe.java index 5aaf71a4..76fc90f6 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankExchangeGoldCmdExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/bank/UserBankExchangeGoldCmdExe.java @@ -3,6 +3,7 @@ package com.red.circle.wallet.app.command.bank; import com.red.circle.common.business.core.enums.OpUserType; import com.red.circle.common.business.core.enums.ReceiptType; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.component.redis.service.RedisService; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; @@ -11,9 +12,16 @@ import com.red.circle.framework.dto.ResultResponse; import com.red.circle.order.inner.endpoint.UserFreightRechargeRecordClient; import com.red.circle.order.inner.endpoint.UserRechargeCountClient; import com.red.circle.order.inner.model.enums.MonthlyRechargeType; +import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; import com.red.circle.other.inner.endpoint.team.target.UserBillDiamondBalanceClient; +import com.red.circle.other.inner.endpoint.user.user.UserOneTimeTaskClient; +import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; import com.red.circle.other.inner.endpoint.user.user.UserSvipClient; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; import com.red.circle.other.inner.model.dto.agency.agency.BillDiamondBalanceDTO; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils; @@ -78,6 +86,9 @@ public class UserBankExchangeGoldCmdExe { private final SalaryDiamondRunningWaterService salaryDiamondRunningWaterService; private final UserRechargeCountClient userRechargeCountClient; private final UserSvipClient userSvipClient; + private final PropsActivityClient propsActivityClient; + private final UserOneTimeTaskClient userOneTimeTaskClient; + private final UserProfileClient userProfileClient; public UserBankExchangeGoldResultCO execute(UserBankExchangeGoldCmd cmd) { ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, @@ -153,6 +164,8 @@ public class UserBankExchangeGoldCmdExe { MonthlyRechargeType.SHIPPING_AGENT ); + completedFirstCharge(cmd.getReqUserId(), cmd.getReqSysOrigin().getOrigin()); + // SVip积分累计. userSvipClient.incrIntegral(cmd.getReqUserId(), goldQuantity.longValue()); redisService.unlock(key); @@ -161,6 +174,32 @@ public class UserBankExchangeGoldCmdExe { .setExchangeGold(Objects.toString(goldRatio)); } + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess()) { + if (response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + userProfileClient.removeCacheAll(userId); + } + } + } + } + @Transactional(rollbackFor = Exception.class) diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/DealerToUserShipCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/DealerToUserShipCmdExe.java index a8532da2..18024cad 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/DealerToUserShipCmdExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/DealerToUserShipCmdExe.java @@ -2,14 +2,24 @@ package com.red.circle.wallet.app.command.freight; import com.red.circle.common.business.core.enums.OpUserType; import com.red.circle.common.business.core.enums.ReceiptType; +import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.enums.IncomeExpenditureEnum; +import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.component.redis.service.RedisService; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.framework.dto.ResultResponse; import com.red.circle.order.inner.endpoint.UserRechargeCountClient; import com.red.circle.order.inner.model.enums.MonthlyRechargeType; import com.red.circle.other.inner.endpoint.activity.AppRankCountClient; import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient; +import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; +import com.red.circle.other.inner.endpoint.user.user.UserOneTimeTaskClient; +import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.tuple.PennyAmount; @@ -64,6 +74,9 @@ public class DealerToUserShipCmdExe { private final UserRechargeCountClient userRechargeCountClient; private final CumulativeRechargeClient cumulativeRechargeClient; private final FreightBalanceRunningWaterService freightBalanceRunningWaterService; + private final PropsActivityClient propsActivityClient; + private final UserOneTimeTaskClient userOneTimeTaskClient; + private final UserProfileClient userProfileClient; public BigDecimal execute(FreightDealerToUserShipCmd cmd) { controlSwitch.execute(cmd.requireReqSysOriginChildEnum()); @@ -150,6 +163,8 @@ public class DealerToUserShipCmdExe { // 累计充值 incrRechargeQuantity(cmd); + completedFirstCharge(cmd.getReqUserId(), cmd.getReqSysOrigin().getOrigin()); + //累计今日充值,每日累计充值抽奖活动 cumulativeRechargeClient.incrTodayRechargeScore(cmd.getAcceptUserId(), getGoldToSUD(cmd).doubleValue()); @@ -193,7 +208,33 @@ public class DealerToUserShipCmdExe { } } - private void incrRechargeQuantity(FreightDealerToUserShipCmd cmd) { + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess() && response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + + userProfileClient.removeCacheAll(userId); + } + } + } + + + private void incrRechargeQuantity(FreightDealerToUserShipCmd cmd) { userRechargeCountClient.count(cmd.getAcceptUserId(), getGoldToSUD(cmd), MonthlyRechargeType.SELLER_AGENT diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java index 000761d9..b6b9022e 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/freight/SendFreightShipCmdExe.java @@ -4,6 +4,8 @@ import com.red.circle.common.business.core.enums.OpUserType; import com.red.circle.common.business.core.enums.ReceiptType; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.enums.IncomeExpenditureEnum; +import com.red.circle.common.business.enums.SendPropsOrigin; +import com.red.circle.component.mq.MessageEventProcess; import com.red.circle.component.redis.service.RedisService; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; @@ -14,15 +16,19 @@ import com.red.circle.order.inner.endpoint.UserRechargeCountClient; import com.red.circle.order.inner.model.enums.MonthlyRechargeType; import com.red.circle.other.inner.endpoint.activity.AppRankCountClient; import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient; -import com.red.circle.other.inner.endpoint.user.user.UserLevelClient; +import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; +import com.red.circle.other.inner.endpoint.sys.EnumConfigClient; +import com.red.circle.other.inner.endpoint.user.user.*; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.tool.core.date.LocalDateTimeUtils; import com.red.circle.tool.core.json.JacksonUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.tuple.PennyAmount; import com.red.circle.other.inner.asserts.user.UserErrorCode; -import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; -import com.red.circle.other.inner.endpoint.user.user.UserSvipClient; import com.red.circle.wallet.app.dto.cmd.FreightShipSendCmd; import com.red.circle.wallet.domain.gateway.FreightShipGateway; import com.red.circle.wallet.domain.gateway.WalletGoldGateway; @@ -39,6 +45,7 @@ import com.red.circle.wallet.inner.model.enums.FreightBalanceOrigin; import com.red.circle.wallet.inner.model.enums.GoldOrigin; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.List; import java.util.Objects; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -69,6 +76,8 @@ public class SendFreightShipCmdExe { private final FreightBalanceRunningWaterService freightBalanceRunningWaterService; private final TaskMqMessage taskMqMessage; private final UserLevelClient userLevelClient; + private final PropsActivityClient propsActivityClient; + private final UserOneTimeTaskClient userOneTimeTaskClient; public BigDecimal execute(FreightShipSendCmd cmd) { @@ -137,6 +146,8 @@ public class SendFreightShipCmdExe { // SVip积分累计. userSvipClient.incrIntegral(cmd.getAcceptUserId(), cmd.getQuantity().longValue()); + completedFirstCharge(cmd.getAcceptUserId(), cmd.getReqSysOrigin().getOrigin()); + //完成任务 钩子 9 充值 币商 /*taskMqMessage.sendTask(TaskApprovalEvent.builder() .taskId(9) @@ -152,6 +163,32 @@ public class SendFreightShipCmdExe { } } + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess()) { + if (response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + userProfileClient.removeCacheAll(userId); + } + } + } + } + private void incrRechargeQuantity(FreightShipSendCmd cmd) { userRechargeCountClient.count(cmd.getAcceptUserId(), diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/SalaryExchangeGoldCmdExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/SalaryExchangeGoldCmdExe.java index e30e13fb..e6f4dece 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/SalaryExchangeGoldCmdExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/SalaryExchangeGoldCmdExe.java @@ -3,6 +3,8 @@ package com.red.circle.wallet.app.command.salary; import com.red.circle.common.business.core.enums.OpUserType; import com.red.circle.common.business.core.enums.ReceiptType; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; +import com.red.circle.common.business.enums.SendPropsOrigin; +import com.red.circle.component.mq.MessageEventProcess; import com.red.circle.component.redis.service.RedisService; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; @@ -11,11 +13,18 @@ import com.red.circle.framework.dto.ResultResponse; import com.red.circle.order.inner.endpoint.UserFreightRechargeRecordClient; import com.red.circle.order.inner.endpoint.UserRechargeCountClient; import com.red.circle.order.inner.model.enums.MonthlyRechargeType; +import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient; +import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; +import com.red.circle.other.inner.endpoint.sys.EnumConfigClient; import com.red.circle.other.inner.endpoint.team.target.UserBillDiamondBalanceClient; import com.red.circle.other.inner.endpoint.user.region.UserRegionClient; -import com.red.circle.other.inner.endpoint.user.user.UserSvipClient; +import com.red.circle.other.inner.endpoint.user.user.*; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; +import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; +import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule; import com.red.circle.other.inner.model.dto.agency.agency.BillDiamondBalanceDTO; import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO; +import com.red.circle.other.inner.model.dto.user.UserOneTimeTaskDTO; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils; @@ -80,6 +89,9 @@ public class SalaryExchangeGoldCmdExe { private final UserRechargeCountClient userRechargeCountClient; private final SalaryAccountGateway salaryAccountGateway; private final SalaryAccountConvertor salaryAccountConvertor; + private final PropsActivityClient propsActivityClient; + private final UserOneTimeTaskClient userOneTimeTaskClient; + private final UserProfileClient userProfileClient; public UserBankExchangeGoldResultCO execute(SalaryWithdrawCmd cmd) { ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, @@ -137,6 +149,8 @@ public class SalaryExchangeGoldCmdExe { MonthlyRechargeType.SHIPPING_AGENT ); + completedFirstCharge(cmd.getReqUserId(), cmd.getReqSysOrigin().getOrigin()); + redisService.unlock(key); return new UserBankExchangeGoldResultCO() .setBankBalance(salaryReceiptRes.getAvailableBalance().getDollarAmount()) @@ -150,6 +164,32 @@ public class SalaryExchangeGoldCmdExe { ); } + private void completedFirstCharge(Long userId, String sysOrigin) { + ResultResponse response = userOneTimeTaskClient.queryCompletedFirstCharge(userId, sysOrigin); + if (response.checkSuccess()) { + if (response.getBody() == null) { + userOneTimeTaskClient.completedFirstCharge(userId, sysOrigin); + + // 发送首充奖励 + List body = propsActivityClient.listRule(SysOriginPlatformEnum.valueOf(sysOrigin), + PropsActivityTypeEnum.FIRST_CHARGE_REWARD).getBody(); + if (body != null) { + ActivityPropsRule ruleConfig = body.get(0); + + propsActivityClient.sendActivityReward( + new SendActivityRewardCmd() + .setTrackId(ruleConfig.getId()) + .setOrigin(SendPropsOrigin.FIRST_CHARGE_REWARD) + .setSysOrigin(SysOriginPlatformEnum.valueOf(ruleConfig.getSysOrigin())) + .setSourceGroupId(ruleConfig.getResourceGroupId()) + .setAcceptUserId(userId) + ); + userProfileClient.removeCacheAll(userId); + } + } + } + } + /** * 获得1$兑换多少金币比例, 基于区域+用户输入的美元. *