From 8bdbeabb5b67dc87757957c5be4b43a7e5c18a68 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 26 Sep 2025 19:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E4=B8=AD=E5=BF=83re?= =?UTF-8?q?charge=20agency=20=E6=B1=87=E6=80=BB=E5=92=8C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/UserMonthlyRechargeClientApi.java | 4 +- .../rds/dao/count/UserMonthlyRechargeDAO.java | 4 +- .../count/UserMonthlyRechargeService.java | 2 +- .../impl/UserMonthlyRechargeServiceImpl.java | 4 +- .../dao/count/UserMonthlyRechargeDAO.xml | 4 + .../UserMonthlyRechargeClientEndpoint.java | 6 +- .../UserMonthlyRechargeClientService.java | 3 +- .../UserMonthlyRechargeClientServiceImpl.java | 6 +- .../user/user/RechargeUserServiceImpl.java | 102 ++++++++---------- .../dao/team/BusinessDevelopmentTeamDAO.java | 8 ++ .../dao/team/BusinessDevelopmentTeamDAO.xml | 6 ++ 11 files changed, 79 insertions(+), 70 deletions(-) diff --git a/rc-service/rc-inner-api/order-inner/order-inner-api/src/main/java/com/red/circle/order/inner/endpoint/api/UserMonthlyRechargeClientApi.java b/rc-service/rc-inner-api/order-inner/order-inner-api/src/main/java/com/red/circle/order/inner/endpoint/api/UserMonthlyRechargeClientApi.java index 43d7ada6..90ebdf31 100644 --- a/rc-service/rc-inner-api/order-inner/order-inner-api/src/main/java/com/red/circle/order/inner/endpoint/api/UserMonthlyRechargeClientApi.java +++ b/rc-service/rc-inner-api/order-inner/order-inner-api/src/main/java/com/red/circle/order/inner/endpoint/api/UserMonthlyRechargeClientApi.java @@ -7,6 +7,8 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO; import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import java.util.List; import java.util.Map; +import java.util.Set; + import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -59,7 +61,7 @@ public interface UserMonthlyRechargeClientApi { * 获取金币代理本月和上个月的充值汇总. */ @GetMapping("/monthly-summary") - ResultResponse> getMonthlyRechargeSummary(); + ResultResponse> getMonthlyRechargeSummary(@RequestParam("userIds") Set userIds); } diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/dao/count/UserMonthlyRechargeDAO.java b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/dao/count/UserMonthlyRechargeDAO.java index 9fb0f300..98544a2b 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/dao/count/UserMonthlyRechargeDAO.java +++ b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/dao/count/UserMonthlyRechargeDAO.java @@ -3,8 +3,10 @@ package com.red.circle.order.infra.database.rds.dao.count; import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.order.infra.database.rds.entity.count.UserMonthlyRecharge; import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO; +import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Set; /** *

@@ -16,5 +18,5 @@ import java.util.List; */ public interface UserMonthlyRechargeDAO extends BaseDAO { - List getMonthlyTotalRecharge(); + List getMonthlyTotalRecharge(@Param("userIds") Set userIds); } diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/UserMonthlyRechargeService.java b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/UserMonthlyRechargeService.java index 908b8851..f05b6ab8 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/UserMonthlyRechargeService.java +++ b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/UserMonthlyRechargeService.java @@ -72,5 +72,5 @@ public interface UserMonthlyRechargeService extends BaseService getMonthlyRechargeSummary(); + List getMonthlyRechargeSummary(Set userIds); } diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/impl/UserMonthlyRechargeServiceImpl.java b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/impl/UserMonthlyRechargeServiceImpl.java index 36ba87a0..c5431546 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/impl/UserMonthlyRechargeServiceImpl.java +++ b/rc-service/rc-service-order/order-infrastructure/src/main/java/com/red/circle/order/infra/database/rds/service/count/impl/UserMonthlyRechargeServiceImpl.java @@ -184,8 +184,8 @@ public class UserMonthlyRechargeServiceImpl extends } @Override - public List getMonthlyRechargeSummary() { - return userMonthlyRechargeDAO.getMonthlyTotalRecharge(); + public List getMonthlyRechargeSummary(Set userIds) { + return userMonthlyRechargeDAO.getMonthlyTotalRecharge(userIds); } private int nowThisMonth() { diff --git a/rc-service/rc-service-order/order-infrastructure/src/main/resources/dao/count/UserMonthlyRechargeDAO.xml b/rc-service/rc-service-order/order-infrastructure/src/main/resources/dao/count/UserMonthlyRechargeDAO.xml index 87ceaf88..328282a1 100644 --- a/rc-service/rc-service-order/order-infrastructure/src/main/resources/dao/count/UserMonthlyRechargeDAO.xml +++ b/rc-service/rc-service-order/order-infrastructure/src/main/resources/dao/count/UserMonthlyRechargeDAO.xml @@ -14,6 +14,10 @@ FROM user_monthly_recharge_v2 umr INNER JOIN likei_wallet.user_freight_balance ufb ON umr.user_id = ufb.user_id WHERE ufb.is_close = 0 -- 只查询未关闭的货运账户 + AND ufb.user_id IN + + #{userId} + AND umr.recharge_date IN ( DATE_FORMAT(CURDATE(), '%Y%m'), -- 当月 DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y%m') -- 上月 diff --git a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/endpoint/UserMonthlyRechargeClientEndpoint.java b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/endpoint/UserMonthlyRechargeClientEndpoint.java index a7d76271..18812ea5 100644 --- a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/endpoint/UserMonthlyRechargeClientEndpoint.java +++ b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/endpoint/UserMonthlyRechargeClientEndpoint.java @@ -9,6 +9,8 @@ import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import com.red.circle.order.inner.service.UserMonthlyRechargeClientService; import java.util.List; import java.util.Map; +import java.util.Set; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; @@ -68,8 +70,8 @@ public class UserMonthlyRechargeClientEndpoint implements UserMonthlyRechargeCli } @Override - public ResultResponse> getMonthlyRechargeSummary() { - return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary()); + public ResultResponse> getMonthlyRechargeSummary(Set userIds) { + return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary(userIds)); } } diff --git a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/UserMonthlyRechargeClientService.java b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/UserMonthlyRechargeClientService.java index 577e43f8..a4da88a7 100644 --- a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/UserMonthlyRechargeClientService.java +++ b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/UserMonthlyRechargeClientService.java @@ -6,6 +6,7 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO; import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import java.util.List; import java.util.Map; +import java.util.Set; /** * 累计用户每月充值. @@ -43,7 +44,7 @@ public interface UserMonthlyRechargeClientService { /** * 批量获取用户上月充值. */ - List getMonthlyRechargeSummary(); + List getMonthlyRechargeSummary(Set userIds); } diff --git a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/impl/UserMonthlyRechargeClientServiceImpl.java b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/impl/UserMonthlyRechargeClientServiceImpl.java index d91e09c0..ea7e1657 100644 --- a/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/impl/UserMonthlyRechargeClientServiceImpl.java +++ b/rc-service/rc-service-order/order-inner-endpoint/src/main/java/com/red/circle/order/inner/service/impl/UserMonthlyRechargeClientServiceImpl.java @@ -9,6 +9,8 @@ import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import com.red.circle.order.inner.service.UserMonthlyRechargeClientService; import java.util.List; import java.util.Map; +import java.util.Set; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -62,8 +64,8 @@ public class UserMonthlyRechargeClientServiceImpl implements UserMonthlyRecharge } @Override - public List getMonthlyRechargeSummary() { - return userMonthlyRechargeService.getMonthlyRechargeSummary(); + public List getMonthlyRechargeSummary(Set userIds) { + return userMonthlyRechargeService.getMonthlyRechargeSummary(userIds); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java index f45d8a36..8a03575f 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java @@ -1,41 +1,28 @@ package com.red.circle.other.app.service.user.user; -import cn.hutool.core.lang.Assert; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.PageUserIdCmd; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; -import com.red.circle.framework.dto.PageQuery; import com.red.circle.framework.dto.PageResult; -import com.red.circle.framework.dto.ResultResponse; import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient; import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO; import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import com.red.circle.other.app.dto.h5.RechargePageVO; -import com.red.circle.other.app.dto.h5.RechargeVO; import com.red.circle.other.app.service.recharge.RechargeUserService; -import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentBaseInfo; +import com.red.circle.other.infra.database.rds.dao.team.BusinessDevelopmentTeamDAO; import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; -import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService; import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; -import com.red.circle.tool.core.collection.CollectionUtils; -import com.red.circle.tool.core.date.LocalDateUtils; -import com.red.circle.tool.core.text.StringUtils; -import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; -import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; -import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import lombok.RequiredArgsConstructor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; @Service @@ -43,10 +30,9 @@ import java.util.stream.Collectors; public class RechargeUserServiceImpl implements RechargeUserService { private final UserMonthlyRechargeClient userMonthlyRechargeClient; - private final FreightGoldClient freightGoldClient; private final UserProfileClient userProfileClient; private final AdministratorService administratorService; - private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService; + private final BusinessDevelopmentTeamDAO businessDevelopmentTeamDAO; @Override public PageResult getRechargePage(PageUserIdCmd page, AppExtCommand cmd) { @@ -55,54 +41,50 @@ public class RechargeUserServiceImpl implements RechargeUserService { ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE); } - List collect = getBdGoldUserIdList(cmd); - if (collect == null) return null; + Page objectPage = new Page<>(); + objectPage.setCurrent(page.getPageQuery().getCursor()); + objectPage.setSize(page.getPageQuery().getLimit()); + Page pagedRechargeAgency = businessDevelopmentTeamDAO.pageRechargeAgency(cmd.getReqUserId(), objectPage); + if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) { + return null; + } - Map userMonthlyAmountMap = getThisMonthRechargeAmount(collect); - Map userLastMonthAmountMap = getLastMonthRechargeAmount(collect); + List collect = pagedRechargeAgency.getRecords().stream().toList(); + Map userMonthlyAmountMap = getThisMonthRechargeAmount(collect); + Map userLastMonthAmountMap = getLastMonthRechargeAmount(collect); - List list = collect.stream().map(userId -> { - UserProfileDTO body = userProfileClient.getByUserId(userId).getBody(); - return new RechargePageVO() - .setUserId(userId) - .setAccount(body.getAccount()) - .setUserNickname(body.getUserNickname()) - .setUserAvatar(body.getUserAvatar()) - .setThisMonth(userMonthlyAmountMap.get(userId)) - .setLastMonth(userLastMonthAmountMap.get(userId)); - }).toList(); + List list = pagedRechargeAgency.getRecords().stream().map(userId -> { + UserProfileDTO body = userProfileClient.getByUserId(userId).getBody(); + return new RechargePageVO() + .setUserId(userId) + .setAccount(body.getAccount()) + .setUserNickname(body.getUserNickname()) + .setUserAvatar(body.getUserAvatar()) + .setThisMonth(userMonthlyAmountMap.get(userId)) + .setLastMonth(userLastMonthAmountMap.get(userId)); + }).toList(); - PageResult result = PageResult.newPageResult(list.size()); - result.setCurrent(1L); - result.setTotal(list.size()); - result.setRecords(list); - return result; - } - - private List getBdGoldUserIdList(AppExtCommand cmd) { - List bdList = businessDevelopmentBaseInfoService.query() - .eq(BusinessDevelopmentBaseInfo::getSysOrigin, cmd.getReqSysOrigin().getOrigin()) - .eq(BusinessDevelopmentBaseInfo::getBdLeadUserId, cmd.getReqUserId()) - .orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime) - .list(); - if (bdList.isEmpty()) { - return null; - } - - List collect = bdList.stream().map(e -> { - UserFreightBalanceDTO result = freightGoldClient.getByUserId(e.getUserId()).getBody(); - return result != null ? result.getUserId() : null; - }).filter(Objects::nonNull).toList(); - - if (CollectionUtils.isEmpty(collect)) { - return null; - } - return collect; + PageResult result = PageResult.newPageResult(list.size()); + result.setCurrent(pagedRechargeAgency.getCurrent()); + result.setTotal(pagedRechargeAgency.getTotal()); + result.setSize(pagedRechargeAgency.getSize()); + result.setRecords(list); + return result; } @Override public List getRechargeSummary(AppExtCommand cmd) { - return userMonthlyRechargeClient.getMonthlyRechargeSummary().getBody(); + + Page objectPage = new Page<>(); + objectPage.setCurrent(1L); + objectPage.setSize(3000L); + Page pagedRechargeAgency = businessDevelopmentTeamDAO.pageRechargeAgency(cmd.getReqUserId(), objectPage); + if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) { + return null; + } + + Set collect = new HashSet<>(pagedRechargeAgency.getRecords()); + return userMonthlyRechargeClient.getMonthlyRechargeSummary(collect).getBody(); } private Map getThisMonthRechargeAmount(List collect) { diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/BusinessDevelopmentTeamDAO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/BusinessDevelopmentTeamDAO.java index 6b8b5289..93f2a878 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/BusinessDevelopmentTeamDAO.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/BusinessDevelopmentTeamDAO.java @@ -1,8 +1,11 @@ package com.red.circle.other.infra.database.rds.dao.team; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.red.circle.framework.mybatis.dao.BaseDAO; import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam; import java.math.BigDecimal; +import java.util.List; + import org.apache.ibatis.annotations.Param; /** @@ -23,4 +26,9 @@ public interface BusinessDevelopmentTeamDAO extends BaseDAO pageRechargeAgency(@Param("userId") Long userId, @Param("page")Page page); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/team/BusinessDevelopmentTeamDAO.xml b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/team/BusinessDevelopmentTeamDAO.xml index fd6815d5..7c9c3fe8 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/team/BusinessDevelopmentTeamDAO.xml +++ b/rc-service/rc-service-other/other-infrastructure/src/main/resources/dao/team/BusinessDevelopmentTeamDAO.xml @@ -12,4 +12,10 @@ AND rbdt.user_id = #{userId} +