清空图片和管理员总收入字段处理
This commit is contained in:
parent
dbcd7b1c84
commit
341629cdcb
@ -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<PageResult<SalaryRunningWaterDTO>> queryRunningWater(
|
||||
@RequestBody SalaryRunningWaterQueryInnerCmd cmd);
|
||||
|
||||
/**
|
||||
* 查询用户累计收入.
|
||||
*/
|
||||
@GetMapping("/total-income")
|
||||
ResultResponse<BigDecimal> getTotalIncome(@RequestParam("userId") Long userId, @RequestParam("salaryType") String salaryType);
|
||||
|
||||
}
|
||||
|
||||
@ -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<PhotoItem> newPhotos, List<PhotoItem> originalPhotos) {
|
||||
if (CollectionUtils.isEmpty(newPhotos)) {
|
||||
if (newPhotos == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPhotos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -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<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
||||
@ -51,18 +53,18 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
}
|
||||
|
||||
List<Long> collect = pagedRechargeAgency.getRecords().stream().toList();
|
||||
Map<Long, BigDecimal> userMonthlyAmountMap = getThisMonthRechargeAmount(collect);
|
||||
Map<Long, BigDecimal> userLastMonthAmountMap = getLastMonthRechargeAmount(collect);
|
||||
|
||||
List<RechargePageVO> 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<RechargePageVO> result = PageResult.newPageResult(list.size());
|
||||
@ -88,11 +90,6 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
return userMonthlyRechargeClient.getMonthlyRechargeSummary(collect).getBody();
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getThisMonthRechargeAmount(List<Long> collect) {
|
||||
List<UserMonthlyRechargeDTO> recharges = userMonthlyRechargeClient.listThisMonthByIds(collect).getBody();
|
||||
return getLongBigDecimalMap(recharges);
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getLastMonthRechargeAmount(List<Long> collect) {
|
||||
List<UserMonthlyRechargeDTO> recharges = userMonthlyRechargeClient.listLastMonthByIds(collect).getBody();
|
||||
return getLongBigDecimalMap(recharges);
|
||||
|
||||
@ -33,13 +33,13 @@ public class RechargePageVO implements Serializable {
|
||||
private String userNickname;
|
||||
|
||||
/**
|
||||
* 这个月金额
|
||||
* 累计收入
|
||||
*/
|
||||
private BigDecimal thisMonth;
|
||||
private BigDecimal totalIncome;
|
||||
|
||||
/**
|
||||
* 上个月金额
|
||||
* 本月收入
|
||||
*/
|
||||
private BigDecimal lastMonth;
|
||||
private BigDecimal thisMonthRecharge;
|
||||
|
||||
}
|
||||
@ -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())) {
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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<SalaryAccountRunningWater> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SalaryAccountRunningWater::getUserId, userId)
|
||||
.eq(SalaryAccountRunningWater::getSalaryType, salaryType.getCode())
|
||||
.eq(SalaryAccountRunningWater::getType, 0);
|
||||
|
||||
List<SalaryAccountRunningWater> records = salaryAccountRunningWaterService.list(wrapper);
|
||||
|
||||
return records.stream()
|
||||
.map(SalaryAccountRunningWater::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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<BigDecimal> getTotalIncome(Long userId, String salaryType) {
|
||||
return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<SalaryRunningWaterDTO> queryRunningWater(SalaryRunningWaterQueryInnerCmd cmd);
|
||||
|
||||
/**
|
||||
* 查询用户累计收入.
|
||||
*/
|
||||
BigDecimal getTotalIncome(Long userId, String salaryType);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user