From 341629cdcb6fba056186b7f0b6bbb2eed17a9690 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 11 Dec 2025 18:14:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=A9=BA=E5=9B=BE=E7=89=87=E5=92=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=80=BB=E6=94=B6=E5=85=A5=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/UserSalaryAccountClientApi.java | 9 +++++ .../command/user/UpdateUserProfileCmdExe.java | 28 ++++++++++----- .../user/user/RechargeUserServiceImpl.java | 13 +++---- .../other/app/dto/h5/RechargePageVO.java | 8 ++--- .../impl/UserRunProfileServiceImpl.java | 10 ++++-- .../gateway/user/UserProfileGatewayImpl.java | 22 ++++++++---- .../salary/query/SalaryTotalIncomeQryExe.java | 34 +++++++++++++++++++ .../app/service/SalaryAccountServiceImpl.java | 10 ++++++ .../app/service/SalaryAccountService.java | 13 ++++++- .../UserSalaryAccountClientEndpoint.java | 7 ++++ .../UserSalaryAccountClientService.java | 7 ++++ .../UserSalaryAccountClientServiceImpl.java | 7 ++++ 12 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java index 9ab30721..221be203 100644 --- a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import java.math.BigDecimal; + /** * 工资账户 Client API. */ @@ -44,4 +46,11 @@ public interface UserSalaryAccountClientApi { @PostMapping("/running-water") ResultResponse> queryRunningWater( @RequestBody SalaryRunningWaterQueryInnerCmd cmd); + + /** + * 查询用户累计收入. + */ + @GetMapping("/total-income") + ResultResponse getTotalIncome(@RequestParam("userId") Long userId, @RequestParam("salaryType") String salaryType); + } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UpdateUserProfileCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UpdateUserProfileCmdExe.java index 98b6c680..85939d6b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UpdateUserProfileCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UpdateUserProfileCmdExe.java @@ -81,14 +81,22 @@ public class UpdateUserProfileCmdExe { ResponseAssert.notNull(CommonErrorCode.UPDATE_FAILURE, updateUserProfile); updateUserProfile.setId(userProfile.getId()); - // 处理背景照片 - if (CollectionUtils.isNotEmpty(cmd.getBackgroundPhotos())) { - updateUserProfile.setBackgroundPhotos(userProfileAppConvertor.toPhotoItems(cmd.getBackgroundPhotos())); + // 处理背景照片:如果传入非null,则更新(包括空列表) + if (cmd.getBackgroundPhotos() != null) { + updateUserProfile.setBackgroundPhotos( + CollectionUtils.isNotEmpty(cmd.getBackgroundPhotos()) + ? userProfileAppConvertor.toPhotoItems(cmd.getBackgroundPhotos()) + : CollectionUtils.newArrayList() + ); } - // 处理个人形象照片 - if (CollectionUtils.isNotEmpty(cmd.getPersonalPhotos())) { - updateUserProfile.setPersonalPhotos(userProfileAppConvertor.toPhotoItems(cmd.getPersonalPhotos())); + // 处理个人形象照片:如果传入非null,则更新(包括空列表) + if (cmd.getPersonalPhotos() != null) { + updateUserProfile.setPersonalPhotos( + CollectionUtils.isNotEmpty(cmd.getPersonalPhotos()) + ? userProfileAppConvertor.toPhotoItems(cmd.getPersonalPhotos()) + : CollectionUtils.newArrayList() + ); } updateUserProfile.setUserNickname( @@ -258,10 +266,14 @@ public class UpdateUserProfileCmdExe { } /** - * 处理照片状态:新照片设置为待审核,已存在照片保持原状态. + * 处理照片状态:新照片设置为待审核,已存在照片保持原状态,空列表表示清空照片. */ private void processPhotoStatus(List newPhotos, List originalPhotos) { - if (CollectionUtils.isEmpty(newPhotos)) { + if (newPhotos == null) { + return; + } + + if (newPhotos.isEmpty()) { return; } 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 5e3b2ba0..9f235f73 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 @@ -16,6 +16,7 @@ import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; import com.red.circle.other.infra.database.rds.service.team.AdminRechargeAgentRelationService; import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.red.circle.wallet.inner.endpoint.salary.UserSalaryAccountClient; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -34,6 +35,7 @@ public class RechargeUserServiceImpl implements RechargeUserService { private final UserProfileClient userProfileClient; private final AdministratorService administratorService; private final AdminRechargeAgentRelationService adminRechargeAgentRelationService; + private final UserSalaryAccountClient userSalaryAccountClient; @Override public PageResult getRechargePage(PageUserIdCmd page, AppExtCommand cmd) { @@ -51,18 +53,18 @@ public class RechargeUserServiceImpl implements RechargeUserService { } List collect = pagedRechargeAgency.getRecords().stream().toList(); - Map userMonthlyAmountMap = getThisMonthRechargeAmount(collect); Map userLastMonthAmountMap = getLastMonthRechargeAmount(collect); List list = pagedRechargeAgency.getRecords().stream().map(userId -> { UserProfileDTO body = userProfileClient.getByUserId(userId).getBody(); + BigDecimal totalIncome = userSalaryAccountClient.getTotalIncome(userId, "ADMIN_SALARY").getBody(); return new RechargePageVO() .setUserId(userId) .setAccount(body.getAccount()) .setUserNickname(body.getUserNickname()) .setUserAvatar(body.getUserAvatar()) - .setThisMonth(userMonthlyAmountMap.get(userId)) - .setLastMonth(userLastMonthAmountMap.get(userId)); + .setTotalIncome(totalIncome != null ? totalIncome : BigDecimal.ZERO) + .setThisMonthRecharge(userLastMonthAmountMap.get(userId)); }).toList(); PageResult result = PageResult.newPageResult(list.size()); @@ -88,11 +90,6 @@ public class RechargeUserServiceImpl implements RechargeUserService { return userMonthlyRechargeClient.getMonthlyRechargeSummary(collect).getBody(); } - private Map getThisMonthRechargeAmount(List collect) { - List recharges = userMonthlyRechargeClient.listThisMonthByIds(collect).getBody(); - return getLongBigDecimalMap(recharges); - } - private Map getLastMonthRechargeAmount(List collect) { List recharges = userMonthlyRechargeClient.listLastMonthByIds(collect).getBody(); return getLongBigDecimalMap(recharges); diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/RechargePageVO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/RechargePageVO.java index a1a111ee..79f46127 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/RechargePageVO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/h5/RechargePageVO.java @@ -33,13 +33,13 @@ public class RechargePageVO implements Serializable { private String userNickname; /** - * 这个月金额 + * 累计收入 */ - private BigDecimal thisMonth; + private BigDecimal totalIncome; /** - * 上个月金额 + * 本月收入 */ - private BigDecimal lastMonth; + private BigDecimal thisMonthRecharge; } \ No newline at end of file diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/user/profile/impl/UserRunProfileServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/user/profile/impl/UserRunProfileServiceImpl.java index 3500e4c8..2516749c 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/user/profile/impl/UserRunProfileServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/user/profile/impl/UserRunProfileServiceImpl.java @@ -227,12 +227,16 @@ public class UserRunProfileServiceImpl implements UserRunProfileService { update.set("hobby", userRunProfile.getHobby()); } - if (CollectionUtils.isNotEmpty(userRunProfile.getBackgroundPhotos())) { - update.set("backgroundPhotos", userRunProfile.getBackgroundPhotos()); + if (userRunProfile.getBackgroundPhotos() != null) { + update.set("backgroundPhotos",CollectionUtils.isNotEmpty(userRunProfile.getBackgroundPhotos()) ? + userRunProfile.getBackgroundPhotos() : + CollectionUtils.newArrayList() ); } if (CollectionUtils.isNotEmpty(userRunProfile.getPersonalPhotos())) { - update.set("personalPhotos", userRunProfile.getPersonalPhotos()); + update.set("personalPhotos", CollectionUtils.isNotEmpty(userRunProfile.getPersonalPhotos()) ? + userRunProfile.getPersonalPhotos() : + CollectionUtils.newArrayList() ); } if (CollectionUtils.isNotEmpty(userRunProfile.getCpList())) { diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java index e746ad77..83e87f9e 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/user/UserProfileGatewayImpl.java @@ -275,14 +275,24 @@ public class UserProfileGatewayImpl implements UserProfileGateway { baseInfo.setAccountStatus(userProfile.getCheckStatus()); } - // 转换图片列表为JSON存储到MySQL - if (CollectionUtils.isNotEmpty(userProfile.getBackgroundPhotos())) { - baseInfo.setBackgroundPhoto(JSON.toJSONString(userProfile.getBackgroundPhotos())); + // 处理背景照片:如果传入非null,则更新(包括空列表) + if (userProfile.getBackgroundPhotos() != null) { + baseInfo.setBackgroundPhoto( + CollectionUtils.isNotEmpty(userProfile.getBackgroundPhotos()) + ? JSON.toJSONString(userProfile.getBackgroundPhotos()) + : "[]" + ); } - if (CollectionUtils.isNotEmpty(userProfile.getPersonalPhotos())) { - baseInfo.setPersonalPhoto(JSON.toJSONString(userProfile.getPersonalPhotos())); + + // 处理个人形象照片:如果传入非null,则更新(包括空列表) + if (userProfile.getPersonalPhotos() != null) { + baseInfo.setPersonalPhoto( + CollectionUtils.isNotEmpty(userProfile.getPersonalPhotos() ) + ? JSON.toJSONString(userProfile.getPersonalPhotos()) + : "[]" + ); } - + baseInfoService.updateSelectiveById(baseInfo); userRunProfileService.updateSelectiveById( userProfileInfraConvertor.toUserRunProfile(userProfile)); diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java new file mode 100644 index 00000000..3e9de1aa --- /dev/null +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java @@ -0,0 +1,34 @@ +package com.red.circle.wallet.app.command.salary.query; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.red.circle.wallet.domain.salary.SalaryType; +import com.red.circle.wallet.infra.database.rds.entity.salary.SalaryAccountRunningWater; +import com.red.circle.wallet.infra.database.rds.service.salary.SalaryAccountRunningWaterService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 查询工资账户累计收入. + */ +@Component +@RequiredArgsConstructor +public class SalaryTotalIncomeQryExe { + + private final SalaryAccountRunningWaterService salaryAccountRunningWaterService; + + public BigDecimal execute(Long userId, SalaryType salaryType) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SalaryAccountRunningWater::getUserId, userId) + .eq(SalaryAccountRunningWater::getSalaryType, salaryType.getCode()) + .eq(SalaryAccountRunningWater::getType, 0); + + List records = salaryAccountRunningWaterService.list(wrapper); + + return records.stream() + .map(SalaryAccountRunningWater::getAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } +} diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java index d8b68057..2fe6f312 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java @@ -7,12 +7,16 @@ import com.red.circle.wallet.app.command.salary.SalaryTransferGoldCmdExe; import com.red.circle.wallet.app.command.salary.SalaryWithdrawRefundCmdExe; import com.red.circle.wallet.app.command.salary.query.SalaryAccountBalanceQryExe; import com.red.circle.wallet.app.command.salary.query.SalaryRunningWaterQryExe; +import com.red.circle.wallet.app.command.salary.query.SalaryTotalIncomeQryExe; import com.red.circle.wallet.app.dto.clientobject.*; import com.red.circle.wallet.app.dto.cmd.*; import com.red.circle.wallet.domain.salary.SalaryType; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.util.Objects; + /** * 工资账户服务实现. */ @@ -26,6 +30,7 @@ public class SalaryAccountServiceImpl implements SalaryAccountService { private final SalaryWithdrawRefundCmdExe salaryWithdrawRefundCmdExe; private final SalaryExchangeGoldCmdExe salaryExchangeGoldCmdExe; private final SalaryTransferGoldCmdExe salaryTransferGoldCmdExe; + private final SalaryTotalIncomeQryExe salaryTotalIncomeQryExe; @Override public SalaryAccountBalanceCO getBalance(Long userId, String salaryType) { @@ -56,4 +61,9 @@ public class SalaryAccountServiceImpl implements SalaryAccountService { public UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd) { return salaryExchangeGoldCmdExe.execute(cmd); } + + @Override + public BigDecimal getTotalIncome(Long userId, String salaryType) { + return salaryTotalIncomeQryExe.execute(userId, Objects.requireNonNull(SalaryType.of(salaryType))); + } } diff --git a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java index 644a3b53..c87de516 100644 --- a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java +++ b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java @@ -4,6 +4,8 @@ import com.red.circle.framework.dto.PageResult; import com.red.circle.wallet.app.dto.clientobject.*; import com.red.circle.wallet.app.dto.cmd.*; +import java.math.BigDecimal; + /** * 工资账户服务. */ @@ -43,5 +45,14 @@ public interface SalaryAccountService { UserBankWithdrawResultCO transferGold(SalaryWithdrawCmd cmd); - UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd); + UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd); + + /** + * 查询用户累计收入. + * + * @param userId 用户ID + * @param salaryType 工资类型 + * @return 累计收入 + */ + BigDecimal getTotalIncome(Long userId, String salaryType); } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java index 0f53a03b..6267f269 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java @@ -16,6 +16,8 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; + /** * 工资账户 Client Endpoint. */ @@ -48,4 +50,9 @@ public class UserSalaryAccountClientEndpoint implements UserSalaryAccountClientA SalaryRunningWaterQueryInnerCmd cmd) { return ResultResponse.success(userSalaryAccountClientService.queryRunningWater(cmd)); } + + @Override + public ResultResponse getTotalIncome(Long userId, String salaryType) { + return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType)); + } } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java index 76980eba..0a29701b 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java @@ -8,6 +8,8 @@ import com.red.circle.wallet.inner.model.dto.SalaryAccountBalanceDTO; import com.red.circle.wallet.inner.model.dto.SalaryIssueResultDTO; import com.red.circle.wallet.inner.model.dto.SalaryRunningWaterDTO; +import java.math.BigDecimal; + /** * 工资账户 Inner Service. */ @@ -32,4 +34,9 @@ public interface UserSalaryAccountClientService { * 查询流水. */ PageResult queryRunningWater(SalaryRunningWaterQueryInnerCmd cmd); + + /** + * 查询用户累计收入. + */ + BigDecimal getTotalIncome(Long userId, String salaryType); } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java index 11a809a0..c2c3ff39 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java @@ -17,6 +17,7 @@ import com.red.circle.wallet.inner.model.dto.SalaryIssueResultDTO; import com.red.circle.wallet.inner.model.dto.SalaryRunningWaterDTO; import com.red.circle.wallet.inner.service.salary.UserSalaryAccountClientService; +import java.math.BigDecimal; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -67,4 +68,10 @@ public class UserSalaryAccountClientServiceImpl implements UserSalaryAccountClie return pageResult; } + + @Override + public BigDecimal getTotalIncome(Long userId, String salaryType) { + BigDecimal totalIncome = salaryAccountService.getTotalIncome(userId, salaryType); + return totalIncome != null ? totalIncome : BigDecimal.ZERO; + } }