From a77474d3df6b3b17a91e4f2c37a69bbc98e21dee Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 30 Dec 2025 11:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=85=85=E5=80=BC=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/UserActivityRechargeClient.java | 13 ++++++++ .../api/UserActivityRechargeClientApi.java | 30 +++++++++++++++++++ .../gateway/UserRechargeCountGatewayImpl.java | 4 ++- .../UserActivityRechargeClientController.java | 28 +++++++++++++++++ .../entity/activity/UserActivityRecharge.java | 18 ++++++----- .../impl/UserActivityRechargeServiceImpl.java | 6 ++-- .../other-start/src/test/java/SpringTest.java | 6 +++- 7 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/UserActivityRechargeClient.java create mode 100644 rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/UserActivityRechargeClientApi.java create mode 100644 rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/UserActivityRechargeClientController.java diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/UserActivityRechargeClient.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/UserActivityRechargeClient.java new file mode 100644 index 00000000..bed1e6d9 --- /dev/null +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/UserActivityRechargeClient.java @@ -0,0 +1,13 @@ +package com.red.circle.other.inner.endpoint.activity; + +import com.red.circle.other.inner.endpoint.activity.api.UserActivityRechargeClientApi; +import org.springframework.cloud.openfeign.FeignClient; + +/** + * 用户活动充值服务 + */ +@FeignClient(name = "userActivityRechargeClient", url = "${feign.other.url}" + + UserActivityRechargeClientApi.API_PREFIX) +public interface UserActivityRechargeClient extends UserActivityRechargeClientApi { + +} diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/UserActivityRechargeClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/UserActivityRechargeClientApi.java new file mode 100644 index 00000000..7ec01e1f --- /dev/null +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/activity/api/UserActivityRechargeClientApi.java @@ -0,0 +1,30 @@ +package com.red.circle.other.inner.endpoint.activity.api; + +import com.red.circle.framework.dto.ResultResponse; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; + +/** + * 用户活动充值服务 API + */ +public interface UserActivityRechargeClientApi { + + String API_PREFIX = "/activity-recharge/client"; + + /** + * 记录用户活动充值 + * + * @param userId 用户ID + * @param amount 充值金额 + * @param type 充值类型 + * @return 结果 + */ + @PostMapping("/record") + ResultResponse recordRecharge( + @RequestParam("userId") Long userId, + @RequestParam("amount") BigDecimal amount, + @RequestParam("type") String type + ); +} diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/gateway/UserRechargeCountGatewayImpl.java b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/gateway/UserRechargeCountGatewayImpl.java index 6784306f..0f0e5e9e 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/gateway/UserRechargeCountGatewayImpl.java +++ b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/gateway/UserRechargeCountGatewayImpl.java @@ -5,6 +5,7 @@ import com.red.circle.order.infra.database.rds.service.count.MonthlyRechargeUser import com.red.circle.order.infra.database.rds.service.count.TotalRechargeService; import com.red.circle.order.infra.database.rds.service.count.TotalRechargeUserService; import com.red.circle.order.infra.database.rds.service.count.UserMonthlyRechargeService; +import com.red.circle.other.inner.endpoint.activity.UserActivityRechargeClient; import com.red.circle.order.inner.model.cmd.UserRechargeMonthQryCmd; import com.red.circle.order.inner.model.dto.MonthlyRechargeUserDTO; import com.red.circle.order.inner.model.dto.TotalRechargeUserDTO; @@ -25,6 +26,7 @@ public class UserRechargeCountGatewayImpl implements UserRechargeCountGateway { private final TotalRechargeUserService totalRechargeUserService; private final MonthlyRechargeUserService monthlyRechargeUserService; private final UserMonthlyRechargeService userMonthlyRechargeService; + private final UserActivityRechargeClient userActivityRechargeClient; @Override public List listMonthlyRecharge(UserRechargeMonthQryCmd cmd) { @@ -42,7 +44,7 @@ public class UserRechargeCountGatewayImpl implements UserRechargeCountGateway { totalRechargeService.incrAmount(userId, amount, type); monthlyRechargeUserService.incAmount(userId, amount); totalRechargeUserService.incAmount(userId, amount); - + userActivityRechargeClient.recordRecharge(userId, amount, type.name()); } @Override diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/UserActivityRechargeClientController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/UserActivityRechargeClientController.java new file mode 100644 index 00000000..0d931c5c --- /dev/null +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/activity/UserActivityRechargeClientController.java @@ -0,0 +1,28 @@ +package com.red.circle.other.adapter.app.activity; + +import com.red.circle.framework.dto.ResultResponse; +import com.red.circle.order.inner.model.enums.MonthlyRechargeType; +import com.red.circle.other.infra.database.rds.service.activity.UserActivityRechargeService; +import com.red.circle.other.inner.endpoint.activity.api.UserActivityRechargeClientApi; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; + +/** + * 用户活动充值服务实现 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping(UserActivityRechargeClientApi.API_PREFIX) +public class UserActivityRechargeClientController implements UserActivityRechargeClientApi { + + private final UserActivityRechargeService userActivityRechargeService; + + @Override + public ResultResponse recordRecharge(Long userId, BigDecimal amount, String type) { + userActivityRechargeService.recordRecharge(userId, amount, MonthlyRechargeType.valueOf(type)); + return ResultResponse.success(); + } +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/UserActivityRecharge.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/UserActivityRecharge.java index 2c243e72..efbd590d 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/UserActivityRecharge.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/activity/UserActivityRecharge.java @@ -1,16 +1,13 @@ package com.red.circle.other.infra.database.rds.entity.activity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import java.io.Serial; +import java.io.Serializable; import java.math.BigDecimal; +import java.sql.Timestamp; import java.time.LocalDate; /** @@ -20,9 +17,8 @@ import java.time.LocalDate; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("user_activity_recharge") -public class UserActivityRecharge extends TimestampBaseEntity { +public class UserActivityRecharge implements Serializable { - @Serial private static final long serialVersionUID = 1L; /** @@ -54,4 +50,10 @@ public class UserActivityRecharge extends TimestampBaseEntity { */ @TableField("amount") private BigDecimal amount; + + @TableField("create_time") + private Timestamp createTime; + + @TableField("update_time") + private Timestamp updateTime; } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/UserActivityRechargeServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/UserActivityRechargeServiceImpl.java index cafd8ab4..56d46cd9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/UserActivityRechargeServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/activity/impl/UserActivityRechargeServiceImpl.java @@ -23,7 +23,7 @@ public class UserActivityRechargeServiceImpl implements UserActivityRechargeServ /** * 固定活动ID */ - private static final Long FIXED_ACTIVITY_ID = 1L; + private static final Long FIXED_ACTIVITY_ID = 2005571533988298753L; @Override public void recordRecharge(Long userId, BigDecimal amount, MonthlyRechargeType type) { @@ -37,8 +37,8 @@ public class UserActivityRechargeServiceImpl implements UserActivityRechargeServ type.name(), amount ); - - log.info("记录用户活动充值, userId:{}, amount:{}, type:{}, date:{}, result:{}", + + log.info("记录用户活动充值, userId:{}, amount:{}, type:{}, date:{}, result:{}", userId, amount, type.name(), rechargeDate, result); } 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 f24a8d98..3e24050d 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 @@ -10,6 +10,7 @@ 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.order.inner.model.enums.MonthlyRechargeType; 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; @@ -31,6 +32,7 @@ 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.activity.UserActivityRechargeService; import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; import com.red.circle.other.infra.database.rds.service.user.device.LatestMobileDeviceService; import com.red.circle.other.infra.database.rds.service.user.user.OneTimeTaskService; @@ -90,11 +92,13 @@ public class SpringTest { private LatestMobileDeviceService latestMobileDeviceService; @Autowired private UserRegionGateway userRegionGateway; + @Autowired + private UserActivityRechargeService userActivityRechargeService; @Test public void getDeviceFingerprintByUserId() { - boolean eqRegion = userRegionGateway.checkEqRegion(1989287420580524033L, 1957345312961527809L); + userActivityRechargeService.recordRecharge(1957345312961527809L, new BigDecimal("100"), MonthlyRechargeType.GOOGLE); }