管理员工资页面处理
This commit is contained in:
parent
341629cdcb
commit
4f1e0b8be1
@ -146,4 +146,14 @@ public interface FreightGoldClientApi {
|
||||
*/
|
||||
@PostMapping("/mapTransactionCountByUserIds")
|
||||
ResultResponse<Map<Long, Long>> mapTransactionCountByUserIds(@RequestBody Set<Long> userIds);
|
||||
|
||||
/**
|
||||
* 查询用户指定时间和类型的总金额.
|
||||
*/
|
||||
@GetMapping("/getTotalAmountByCondition")
|
||||
ResultResponse<BigDecimal> getTotalAmountByCondition(
|
||||
@RequestParam("userId") Long userId,
|
||||
@RequestParam("startTime") String startTime,
|
||||
@RequestParam(value = "endTime", required = false) String endTime,
|
||||
@RequestParam(value = "rechargeType", required = false) String rechargeType);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.other.app.dto.cmd.material.PropsStoreTypeQryCmd;
|
||||
import com.red.circle.other.app.dto.h5.MemberActiveDTO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
import com.red.circle.other.app.dto.h5.RechargeSummaryVO;
|
||||
import com.red.circle.other.app.dto.h5.UserIdentityVO;
|
||||
import com.red.circle.other.app.service.h5.MemberActiveService;
|
||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||
@ -71,7 +72,7 @@ public class MemberActiveController extends BaseController {
|
||||
* 货运代理充值月度汇总(当月,上月)
|
||||
*/
|
||||
@GetMapping("/recharge-summary")
|
||||
public List<MonthlyRechargeSummaryVO> rechargeSummary(AppExtCommand cmd) {
|
||||
public RechargeSummaryVO rechargeSummary(AppExtCommand cmd) {
|
||||
return rechargeUserService.getRechargeSummary(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.BdTeamMemberCO;
|
||||
import com.red.circle.other.app.dto.clientobject.BdTeamSummaryCO;
|
||||
import com.red.circle.other.app.dto.h5.RechargeSummaryVO;
|
||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.infra.database.mongo.dto.team.TeamBillMemberTarget;
|
||||
@ -295,26 +296,16 @@ public class BdTeamSummaryQryExe {
|
||||
cmd.setReqUserId(userId);
|
||||
|
||||
// 获取充值汇总数据
|
||||
List<MonthlyRechargeSummaryVO> rechargeSummaryList = rechargeUserService.getRechargeSummary(cmd);
|
||||
RechargeSummaryVO rechargeSummary = rechargeUserService.getRechargeSummary(cmd);
|
||||
|
||||
if (CollectionUtils.isEmpty(rechargeSummaryList)) {
|
||||
if (rechargeSummary == null) {
|
||||
item.setCount(0);
|
||||
item.setTotalIncome(BigDecimal.ZERO);
|
||||
return item;
|
||||
}
|
||||
|
||||
// 计算累积的用户数量(去重)
|
||||
long totalUserCount = rechargeSummaryList.stream()
|
||||
.mapToLong(MonthlyRechargeSummaryVO::getUserCount)
|
||||
.sum();
|
||||
|
||||
// 计算累积的总充值金额
|
||||
BigDecimal totalAmount = rechargeSummaryList.stream()
|
||||
.map(MonthlyRechargeSummaryVO::getTotalAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
item.setCount((int) totalUserCount);
|
||||
item.setTotalIncome(totalAmount);
|
||||
item.setCount(rechargeSummary.getCount());
|
||||
item.setTotalIncome(rechargeSummary.getCurrentMonthRecharge());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.red.circle.other.app.service.user.user;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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;
|
||||
@ -7,24 +8,27 @@ import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
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.RechargeSummaryVO;
|
||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||
import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation;
|
||||
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.freight.FreightGoldClient;
|
||||
import com.red.circle.wallet.inner.endpoint.salary.UserSalaryAccountClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -36,6 +40,8 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
private final AdministratorService administratorService;
|
||||
private final AdminRechargeAgentRelationService adminRechargeAgentRelationService;
|
||||
private final UserSalaryAccountClient userSalaryAccountClient;
|
||||
private final FreightGoldClient freightGoldClient;
|
||||
private final static String RECHARGE_TYPE = "USDT-进货";
|
||||
|
||||
@Override
|
||||
public PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
||||
@ -47,24 +53,31 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
Page<AdminRechargeAgentRelation> objectPage = new Page<>();
|
||||
objectPage.setCurrent(page.getPageQuery().getCursor());
|
||||
objectPage.setSize(page.getPageQuery().getLimit());
|
||||
Page<Long> pagedRechargeAgency = adminRechargeAgentRelationService.pageRechargeAgentByAdmin(cmd.getReqUserId(), objectPage);
|
||||
IPage<AdminRechargeAgentRelation> pagedRechargeAgency = adminRechargeAgentRelationService.pageRechargeAgentByAdmin(cmd.getReqUserId(), objectPage);
|
||||
if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Long> collect = pagedRechargeAgency.getRecords().stream().toList();
|
||||
Map<Long, BigDecimal> userLastMonthAmountMap = getLastMonthRechargeAmount(collect);
|
||||
List<AdminRechargeAgentRelation> relations = pagedRechargeAgency.getRecords();
|
||||
|
||||
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())
|
||||
.setTotalIncome(totalIncome != null ? totalIncome : BigDecimal.ZERO)
|
||||
.setThisMonthRecharge(userLastMonthAmountMap.get(userId));
|
||||
List<RechargePageVO> list = relations.stream().map(relation -> {
|
||||
Long userId = relation.getUserId();
|
||||
LocalDateTime bindTime = relation.getCreateTime();
|
||||
|
||||
UserProfileDTO body = userProfileClient.getByUserId(userId).getBody();
|
||||
|
||||
// 计算绑定日期到当前的总充值(当月)
|
||||
String bindTimeStr = bindTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String endTimeStr = YearMonth.now().atEndOfMonth().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
BigDecimal thisMonth = freightGoldClient.getTotalAmountByCondition(userId, bindTimeStr, endTimeStr, RECHARGE_TYPE).getBody();
|
||||
|
||||
return new RechargePageVO()
|
||||
.setUserId(userId)
|
||||
.setAccount(body.getAccount())
|
||||
.setUserNickname(body.getUserNickname())
|
||||
.setUserAvatar(body.getUserAvatar())
|
||||
.setThisMonth(thisMonth != null ? thisMonth : BigDecimal.ZERO)
|
||||
.setLastMonth(BigDecimal.ZERO);
|
||||
}).toList();
|
||||
|
||||
PageResult<RechargePageVO> result = PageResult.newPageResult(list.size());
|
||||
@ -76,18 +89,33 @@ public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd) {
|
||||
|
||||
public RechargeSummaryVO getRechargeSummary(AppExtCommand cmd) {
|
||||
Page<AdminRechargeAgentRelation> objectPage = new Page<>();
|
||||
objectPage.setCurrent(1L);
|
||||
objectPage.setSize(3000L);
|
||||
Page<Long> pagedRechargeAgency = adminRechargeAgentRelationService.pageRechargeAgentByAdmin(cmd.getReqUserId(), objectPage);
|
||||
IPage<AdminRechargeAgentRelation> pagedRechargeAgency = adminRechargeAgentRelationService.pageRechargeAgentByAdmin(cmd.getReqUserId(), objectPage);
|
||||
if (pagedRechargeAgency == null || pagedRechargeAgency.getRecords().isEmpty()) {
|
||||
return null;
|
||||
return new RechargeSummaryVO()
|
||||
.setTotalIncome(BigDecimal.ZERO)
|
||||
.setCurrentMonthRecharge(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
Set<Long> collect = new HashSet<>(pagedRechargeAgency.getRecords());
|
||||
return userMonthlyRechargeClient.getMonthlyRechargeSummary(collect).getBody();
|
||||
List<AdminRechargeAgentRelation> relations = pagedRechargeAgency.getRecords();
|
||||
|
||||
|
||||
BigDecimal currentMonthRecharge = BigDecimal.ZERO;
|
||||
for (AdminRechargeAgentRelation relation : relations) {
|
||||
String monthStart = relation.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String monthEnd = YearMonth.now().atEndOfMonth().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
BigDecimal monthRecharge = freightGoldClient.getTotalAmountByCondition(relation.getUserId(), monthStart, monthEnd, RECHARGE_TYPE).getBody();
|
||||
currentMonthRecharge = currentMonthRecharge.add(monthRecharge != null ? monthRecharge : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
return new RechargeSummaryVO()
|
||||
.setTotalIncome(userSalaryAccountClient.getTotalIncome(cmd.getReqUserId(), "ADMIN_SALARY").getBody())
|
||||
.setCurrentMonthRecharge(currentMonthRecharge)
|
||||
.setCount(pagedRechargeAgency.getRecords().size());
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getLastMonthRechargeAmount(List<Long> collect) {
|
||||
|
||||
@ -33,13 +33,13 @@ public class RechargePageVO implements Serializable {
|
||||
private String userNickname;
|
||||
|
||||
/**
|
||||
* 累计收入
|
||||
* 这个月金额
|
||||
*/
|
||||
private BigDecimal totalIncome;
|
||||
private BigDecimal thisMonth;
|
||||
|
||||
/**
|
||||
* 本月收入
|
||||
* 上个月金额
|
||||
*/
|
||||
private BigDecimal thisMonthRecharge;
|
||||
private BigDecimal lastMonth;
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.red.circle.other.app.dto.h5;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 充值汇总VO.
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RechargeSummaryVO {
|
||||
|
||||
/**
|
||||
* 总收入.
|
||||
*/
|
||||
private BigDecimal totalIncome;
|
||||
|
||||
/**
|
||||
* 当月总充值.
|
||||
*/
|
||||
private BigDecimal currentMonthRecharge;
|
||||
|
||||
private Integer count;
|
||||
}
|
||||
@ -3,10 +3,8 @@ package com.red.circle.other.app.service.recharge;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
|
||||
import java.util.List;
|
||||
import com.red.circle.other.app.dto.h5.RechargeSummaryVO;
|
||||
|
||||
public interface RechargeUserService {
|
||||
|
||||
@ -15,5 +13,5 @@ public interface RechargeUserService {
|
||||
*/
|
||||
PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd);
|
||||
|
||||
List<MonthlyRechargeSummaryVO> getRechargeSummary(AppExtCommand cmd);
|
||||
RechargeSummaryVO getRechargeSummary(AppExtCommand cmd);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.red.circle.other.infra.database.rds.service.team;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.red.circle.framework.mybatis.service.BaseService;
|
||||
import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation;
|
||||
@ -41,6 +42,6 @@ public interface AdminRechargeAgentRelationService extends BaseService<AdminRech
|
||||
* @param page 分页对象
|
||||
* @return 分页结果
|
||||
*/
|
||||
Page<Long> pageRechargeAgentByAdmin(Long adminUserId, Page<AdminRechargeAgentRelation> page);
|
||||
IPage<AdminRechargeAgentRelation> pageRechargeAgentByAdmin(Long adminUserId, Page<AdminRechargeAgentRelation> page);
|
||||
|
||||
}
|
||||
|
||||
@ -38,19 +38,10 @@ public class AdminRechargeAgentRelationServiceImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Long> pageRechargeAgentByAdmin(Long adminUserId, Page<AdminRechargeAgentRelation> page) {
|
||||
IPage<AdminRechargeAgentRelation> relationPage = page(page, new LambdaQueryWrapper<AdminRechargeAgentRelation>()
|
||||
.eq(AdminRechargeAgentRelation::getAdminUserId, adminUserId)
|
||||
.orderByDesc(AdminRechargeAgentRelation::getCreateTime));
|
||||
|
||||
Page<Long> result = new Page<>();
|
||||
result.setCurrent(relationPage.getCurrent());
|
||||
result.setSize(relationPage.getSize());
|
||||
result.setTotal(relationPage.getTotal());
|
||||
result.setRecords(relationPage.getRecords().stream()
|
||||
.map(AdminRechargeAgentRelation::getUserId)
|
||||
.toList());
|
||||
return result;
|
||||
public IPage<AdminRechargeAgentRelation> pageRechargeAgentByAdmin(Long adminUserId, Page<AdminRechargeAgentRelation> page) {
|
||||
return page(page, new LambdaQueryWrapper<AdminRechargeAgentRelation>()
|
||||
.eq(AdminRechargeAgentRelation::getAdminUserId, adminUserId)
|
||||
.orderByDesc(AdminRechargeAgentRelation::getCreateTime));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalanceRun
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -71,4 +72,15 @@ public interface FreightBalanceRunningWaterService extends BaseService<FreightBa
|
||||
* @return 用户ID -> 交易次数
|
||||
*/
|
||||
Map<Long, Long> countTransactionsByUserIds(Set<Long> userIds);
|
||||
|
||||
/**
|
||||
* 查询用户指定时间和类型的总金额.
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param rechargeType 充值类型
|
||||
* @return 总金额
|
||||
*/
|
||||
BigDecimal sumAmountByCondition(Long userId, String startTime, String endTime, String rechargeType);
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceRu
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -152,4 +154,20 @@ public class FreightBalanceRunningWaterServiceImpl extends
|
||||
.list();
|
||||
return list.stream().collect(Collectors.groupingBy(FreightBalanceRunningWater::getUserId, Collectors.counting()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal sumAmountByCondition(Long userId, String startTime, String endTime, String rechargeType) {
|
||||
List<FreightBalanceRunningWater> list = query()
|
||||
.select(FreightBalanceRunningWater::getAmount)
|
||||
.eq(FreightBalanceRunningWater::getUserId, userId)
|
||||
.eq(Objects.nonNull(rechargeType), FreightBalanceRunningWater::getRechargeType, rechargeType)
|
||||
.apply(StringUtils.isNotBlank(startTime), "create_time >= {0}", startTime)
|
||||
.apply(StringUtils.isNotBlank(endTime), "create_time <= {0}", endTime)
|
||||
.list();
|
||||
|
||||
return list.stream()
|
||||
.map(FreightBalanceRunningWater::getAmount)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,4 +189,9 @@ public class FreightGoldClientEndpoint implements FreightGoldClientApi {
|
||||
public ResultResponse<Map<Long, Long>> mapTransactionCountByUserIds(Set<Long> userIds) {
|
||||
return ResultResponse.success(freightGoldClientService.mapTransactionCountByUserIds(userIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<BigDecimal> getTotalAmountByCondition(Long userId, String startTime, String endTime, String rechargeType) {
|
||||
return ResultResponse.success(freightGoldClientService.getTotalAmountByCondition(userId, startTime, endTime, rechargeType));
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,4 +116,9 @@ public interface FreightGoldClientService {
|
||||
* 批量查询用户交易次数(type=1的记录数).
|
||||
*/
|
||||
Map<Long, Long> mapTransactionCountByUserIds(Set<Long> userIds);
|
||||
|
||||
/**
|
||||
* 查询用户指定时间和类型的总金额.
|
||||
*/
|
||||
BigDecimal getTotalAmountByCondition(Long userId, String startTime, String endTime, String rechargeType);
|
||||
}
|
||||
|
||||
@ -260,4 +260,10 @@ public class FreightGoldClientServiceImpl implements FreightGoldClientService {
|
||||
public Map<Long, Long> mapTransactionCountByUserIds(Set<Long> userIds) {
|
||||
return freightBalanceRunningWaterService.countTransactionsByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalAmountByCondition(Long userId, String startTime, String endTime, String rechargeType) {
|
||||
BigDecimal total = freightBalanceRunningWaterService.sumAmountByCondition(userId, startTime, endTime, rechargeType);
|
||||
return total != null ? total : BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user