From f1fb151d7e8e03d10027f837f0b14d42e409d381 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 18 Mar 2026 17:44:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E4=BB=BB=E5=8A=A1=E9=A2=86?= =?UTF-8?q?=E5=8F=96=E5=A5=96=E5=8A=B1=E5=A2=9E=E5=8A=A0VIP=E9=A2=9D?= =?UTF-8?q?=E5=A4=96=E5=A5=96=E5=8A=B1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/service/task/TaskServiceImpl.java | 69 ++++++++++++++++++- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java index 1ab5fe69..6de4ed26 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java @@ -9,24 +9,34 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.component.redis.service.RedisService; import com.red.circle.other.app.dto.task.TaskDTO; +import com.red.circle.other.domain.enums.VipBenefitType; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.rds.dao.task.TaskConfigDAO; import com.red.circle.other.infra.database.rds.dao.task.UserTaskProgressDAO; +import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig; +import com.red.circle.other.infra.database.rds.entity.props.PropsSourceRecord; import com.red.circle.other.infra.database.rds.entity.task.TaskConfig; import com.red.circle.other.infra.database.rds.entity.task.UserTaskProgress; -import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService; -import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService; +import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRewardConfigService; +import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService; +import com.red.circle.other.infra.database.rds.service.user.user.ConsumptionLevelService; import com.red.circle.other.inner.endpoint.activity.PropsActivityClient; import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd; import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsGroup; import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardProps; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils; +import com.red.circle.tool.core.tuple.PennyAmount; +import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient; +import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd; +import com.red.circle.wallet.inner.model.enums.GoldOrigin; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -42,6 +52,11 @@ public class TaskServiceImpl implements TaskService { private final UserTaskProgressDAO userTaskProgressDao; private final PropsActivityClient propsActivityCnfClient; private final RedisService redisService; + private final PropsActivityRewardConfigService propsActivityRewardConfigService; + private final PropsSourceRecordService propsSourceRecordService; + private final ConsumptionLevelService consumptionLevelService; + private final WalletGoldClient walletGoldClient; + private final UserProfileGateway userProfileGateway; /** * 获取任务列表 @@ -318,14 +333,18 @@ public class TaskServiceImpl implements TaskService { UserTaskProgress userTaskProgress = userTaskProgresses.get(0); // 发送道具 + Long sourceGroupId = taskConfigs.get(0).getRewardId(); propsActivityCnfClient.sendActivityReward(new SendActivityRewardCmd() .setTrackId(IdWorkerUtils.getId()) .setSysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin())) .setAcceptUserId(cmd.getReqUserId()) - .setSourceGroupId(taskConfigs.get(0).getRewardId()) + .setSourceGroupId(sourceGroupId) .setOrigin(SendPropsOrigin.DAILY_TASK_REWARD) ); + //如果是VIP 发送额外金额和经验值 + sendVipExtraReward(sourceGroupId, cmd); + userTaskProgress.setIsRewardCollected(1); userTaskProgress.setCompletedTime(TimestampUtils.now()); userTaskProgressDao.updateById(userTaskProgress); @@ -337,6 +356,50 @@ public class TaskServiceImpl implements TaskService { return true; } + private void sendVipExtraReward(Long sourceGroupId, AppExtCommand cmd) { + Long acceptUserId = cmd.getReqUserId(); + List configs = propsActivityRewardConfigService.listByGroupId(sourceGroupId); + if (configs.isEmpty()) { + return; + } + + BigDecimal benefit = userProfileGateway.getUserVipBenefit(acceptUserId, VipBenefitType.XP_RATE); + + for (PropsActivityRewardConfig rewardConfig : configs) { + if ("GOLD".equalsIgnoreCase(rewardConfig.getType())) { + long baseGold = Long.parseLong(rewardConfig.getContent()); + long extraGold = new BigDecimal(baseGold).multiply(benefit) + .setScale(0, RoundingMode.DOWN).longValue() - baseGold; + + if (extraGold <= 0) { + continue; + } + walletGoldClient.changeBalance(GoldReceiptCmd.builder() + .appIncome() + .userId(acceptUserId) + .eventId(acceptUserId + "_vip_extra") + .sysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin())) + .origin(GoldOrigin.CP_REWARD) + .originDescribe(SendPropsOrigin.DAILY_TASK_REWARD.getDesc()) + .amount(PennyAmount.ofPenny(extraGold)) + .build()); + + } else if ("CUSTOMIZE".equalsIgnoreCase(rewardConfig.getType())) { + long baseExp = rewardConfig.getQuantity(); + long extraExp = new BigDecimal(baseExp).multiply(benefit) + .setScale(0, RoundingMode.DOWN).longValue() - baseExp; + + if (extraExp <= 0) { + continue; + } + PropsSourceRecord props = propsSourceRecordService.getPropsById(Long.parseLong(rewardConfig.getContent())); + if (Objects.nonNull(props) && "EXP".equalsIgnoreCase(props.getCode())) { + consumptionLevelService.incrConsumptionDiamond(acceptUserId, BigDecimal.valueOf(extraExp)); + } + } + } + } + /** * 获取任务列表V2(优化版) */