分销:Review代码修改

This commit is contained in:
owen 2023-09-26 15:11:48 +08:00
parent 9e99b04375
commit a431bccc02
13 changed files with 154 additions and 73 deletions

View File

@ -10,10 +10,10 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -92,20 +92,17 @@ public class BrokerageUserController {
Set<Long> userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId);
// 查询用户信息
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(userIds);
// TODO @疯狂看看下面两个 getBrokerageUserCountByBindUserIdgetWithdrawSummaryByUserId 有没可能一次性出结果不然 n 次有点太花性能了
// 合计分佣订单
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap = convertMap(userIds,
userId -> userId,
userId -> brokerageRecordService.getUserBrokerageSummaryByUserId(userId,
BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus()));
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap = brokerageRecordService.getUserBrokerageSummaryMapByUserId(
userIds, BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus());
// TODO @芋艿看看下面 getBrokerageUserCountByBindUserId 有没可能一次性出结果不然 n 次有点太花性能了
// 合计推广用户数量
Map<Long, Long> brokerageUserCountMap = convertMap(userIds,
userId -> userId,
userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null));
// 合计提现
Map<Long, UserWithdrawSummaryBO> withdrawMap = convertMap(userIds,
userId -> userId,
userId -> brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS));
Map<Long, UserWithdrawSummaryBO> withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId(userIds,
BrokerageWithdrawStatusEnum.AUDIT_SUCCESS);
// 拼接返回
return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap,
userOrderSummaryMap, withdrawMap));

View File

@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
@ -76,23 +77,25 @@ public class AppBrokerageUserController {
@Operation(summary = "获得个人分销统计")
@PreAuthenticated
public CommonResult<AppBrokerageUserMySummaryRespVO> getBrokerageUserSummary() {
Long userId = getLoginUserId();
// TODO @疯狂后面这种要不也改成 convert感觉 controller 这样更容易看到整体核心其实是 868/879/909/91 这阶段
// 统计 yesterdayPricewithdrawPricefirstBrokerageUserCountsecondBrokerageUserCount 字段
// 查询当前登录用户信息
BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId());
// 统计用户昨日的佣金
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
.setWithdrawPrice(Optional.ofNullable(brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS))
.map(UserWithdrawSummaryBO::getPrice).orElse(0))
.setBrokeragePrice(0).setFrozenPrice(0)
.setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
.setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
// 设置 brokeragePricefrozenPrice 字段
Optional.ofNullable(brokerageUserService.getBrokerageUser(userId))
.ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice()));
return success(respVO);
Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(),
BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime);
// 统计用户提现的佣金
Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryByUserId(Collections.singleton(brokerageUser.getId()),
BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream()
.findFirst().map(UserWithdrawSummaryBO::getPrice).orElse(0);
// 统计分销用户数量一级
Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1);
// 统计分销用户数量二级
Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2);
// 拼接返回
return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser));
}
@GetMapping("/rank-page-by-user-count")

View File

@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.trade.convert.brokerage;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserMySummaryRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
@ -71,4 +73,18 @@ public interface BrokerageUserConvert {
void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to);
default AppBrokerageUserMySummaryRespVO convert(Integer yesterdayPrice, Integer withdrawPrice,
Long firstBrokerageUserCount, Long secondBrokerageUserCount,
BrokerageUserDO brokerageUser) {
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
.setYesterdayPrice(ObjUtil.defaultIfNull(yesterdayPrice, 0))
.setWithdrawPrice(ObjUtil.defaultIfNull(withdrawPrice, 0))
.setBrokeragePrice(0).setFrozenPrice(0)
.setFirstBrokerageUserCount(ObjUtil.defaultIfNull(firstBrokerageUserCount, 0L))
.setSecondBrokerageUserCount(ObjUtil.defaultIfNull(secondBrokerageUserCount, 0L));
// 设置 brokeragePricefrozenPrice 字段
Optional.ofNullable(brokerageUser)
.ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice()));
return respVO;
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -9,12 +10,16 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.yulichang.toolkit.LambdaUtils;
import com.github.yulichang.toolkit.MPJWrappers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 佣金记录 Mapper
@ -52,11 +57,27 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
BrokerageRecordDO::getUserId, userId);
}
@Select("SELECT COUNT(1), SUM(price) FROM trade_brokerage_record " +
"WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status} AND deleted = FALSE")
UserBrokerageSummaryBO selectCountAndSumPriceByUserIdAndBizTypeAndStatus(@Param("userId") Long userId,
@Param("bizType") Integer bizType,
@Param("status") Integer status);
default List<UserBrokerageSummaryBO> selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(Collection<Long> userIds,
Integer bizType,
Integer status) {
List<Map<String, Object>> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
.select(BrokerageRecordDO::getUserId)
.selectCount(BrokerageRecordDO::getId, LambdaUtils.getName(UserBrokerageSummaryBO::getCount))
.selectSum(BrokerageRecordDO::getPrice)
.in(BrokerageRecordDO::getUserId, userIds)
.eq(BrokerageRecordDO::getBizId, bizType)
.eq(BrokerageRecordDO::getStatus, status)
.groupBy(BrokerageRecordDO::getUserId));
return BeanUtil.copyToList(list, UserBrokerageSummaryBO.class);
// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
// .select(BrokerageRecordDO::getUserId)
// .selectCount(BrokerageRecordDO::getId, LambdaUtils.getName(UserBrokerageSummaryBO::getCount))
// .selectSum(BrokerageRecordDO::getPrice)
// .in(BrokerageRecordDO::getUserId, userIds)
// .eq(BrokerageRecordDO::getBizId, bizType)
// .eq(BrokerageRecordDO::getStatus, status)
// .groupBy(BrokerageRecordDO::getUserId));
}
@Select("SELECT SUM(price) FROM trade_brokerage_record " +
"WHERE user_id = #{userId} AND biz_type = #{bizType} " +

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -7,9 +8,13 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.Brok
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.yulichang.toolkit.LambdaUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 佣金提现 Mapper
@ -37,9 +42,23 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
.eq(BrokerageWithdrawDO::getStatus, status));
}
@Select("SELECT COUNT(1) AS count, SUM(price) AS price FROM trade_brokerage_withdraw " +
"WHERE user_id = #{userId} AND status = #{status} AND deleted = FALSE")
UserWithdrawSummaryBO selectCountAndSumPriceByUserIdAndStatus(@Param("userId") Long userId,
@Param("status") Integer status);
default List<UserWithdrawSummaryBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, Integer status) {
List<Map<String, Object>> list = selectMaps(new MPJLambdaWrapper<BrokerageWithdrawDO>()
.select(BrokerageWithdrawDO::getUserId)
.selectCount(BrokerageWithdrawDO::getId, LambdaUtils.getName(UserWithdrawSummaryBO::getCount))
.selectSum(BrokerageWithdrawDO::getPrice)
.in(BrokerageWithdrawDO::getUserId, userIds)
.eq(BrokerageWithdrawDO::getStatus, status)
.groupBy(BrokerageWithdrawDO::getUserId));
return BeanUtil.copyToList(list, UserWithdrawSummaryBO.class);
// selectJoinList有BUG会与租户插件冲突解析SQL时发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW
// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper<BrokerageWithdrawDO>()
// .select(BrokerageWithdrawDO::getUserId)
// .selectCount(BrokerageWithdrawDO::getId, LambdaUtils.getName(UserWithdrawSummaryBO::getCount))
// .selectSum(BrokerageWithdrawDO::getPrice)
// .in(BrokerageWithdrawDO::getUserId, userIds)
// .eq(BrokerageWithdrawDO::getStatus, status)
// .groupBy(BrokerageWithdrawDO::getUserId));
}
}

View File

@ -12,7 +12,11 @@ import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* 佣金记录 Service 接口
@ -76,12 +80,24 @@ public interface BrokerageRecordService {
/**
* 汇总用户佣金
*
* @param userId 用户编号
* @param userIds 用户编号
* @param bizType 业务类型
* @param status 佣金状态
* @return 用户佣金汇总
*/
UserBrokerageSummaryBO getUserBrokerageSummaryByUserId(Long userId, Integer bizType, Integer status);
List<UserBrokerageSummaryBO> getUserBrokerageSummaryByUserId(Collection<Long> userIds, Integer bizType, Integer status);
/**
* 汇总用户佣金
*
* @param userIds 用户编号
* @param bizType 业务类型
* @param status 佣金状态
* @return 用户佣金汇总
*/
default Map<Long, UserBrokerageSummaryBO> getUserBrokerageSummaryMapByUserId(Collection<Long> userIds, Integer bizType, Integer status) {
return convertMap(getUserBrokerageSummaryByUserId(userIds, bizType, status), UserBrokerageSummaryBO::getUserId);
}
/**
* 获得用户佣金合计

View File

@ -36,10 +36,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue;
@ -235,9 +232,8 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
}
@Override
public UserBrokerageSummaryBO getUserBrokerageSummaryByUserId(Long userId, Integer bizType, Integer status) {
UserBrokerageSummaryBO summaryBO = brokerageRecordMapper.selectCountAndSumPriceByUserIdAndBizTypeAndStatus(userId, bizType, status);
return summaryBO != null ? summaryBO : new UserBrokerageSummaryBO(0, 0);
public List<UserBrokerageSummaryBO> getUserBrokerageSummaryByUserId(Collection<Long> userIds, Integer bizType, Integer status) {
return brokerageRecordMapper.selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(userIds, bizType, status);
}
@Override
@ -338,7 +334,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
if (BooleanUtil.isTrue(spu.getSubCommissionType())) {
fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice);
fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice);
// 3.2 全局分佣模式根据商品价格比例计算
// 3.2 全局分佣模式根据商品价格比例计算
} else {
spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice);
spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice);

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.trade.service.brokerage;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO;
@ -111,21 +110,7 @@ public interface BrokerageUserService {
* @param registerTime 用户注册时间
* @return 是否绑定
*/
default boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId, @NotNull LocalDateTime registerTime) {
// 注册时间在30秒内的都算新用户
boolean isNewUser = LocalDateTimeUtils.afterNow(registerTime.minusSeconds(30));
return bindBrokerageUser(userId, bindUserId, isNewUser);
}
/**
* 会员绑定推广员
*
* @param userId 用户编号
* @param bindUserId 推广员编号
* @param isNewUser 是否为新用户
* @return 是否绑定
*/
boolean bindBrokerageUser(Long userId, Long bindUserId, Boolean isNewUser);
boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId, @NotNull LocalDateTime registerTime);
/**
* 获取用户是否有分销资格

View File

@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO;
@ -154,7 +155,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
}
@Override
public boolean bindBrokerageUser(Long userId, Long bindUserId, Boolean isNewUser) {
public boolean bindBrokerageUser(Long userId, Long bindUserId, LocalDateTime registerTime) {
// 1. 获得分销用户
boolean isNewBrokerageUser = false;
BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(userId);
@ -164,7 +165,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
}
// 2.1 校验是否能绑定用户
boolean validated = isUserCanBind(brokerageUser, isNewUser);
boolean validated = isUserCanBind(brokerageUser, registerTime);
if (!validated) {
return false;
}
@ -222,7 +223,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
}
private boolean isUserCanBind(BrokerageUserDO user, Boolean isNewUser) {
private boolean isUserCanBind(BrokerageUserDO user, LocalDateTime registerTime) {
// 校验分销功能是否启用
TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig();
if (tradeConfig == null || !BooleanUtil.isTrue(tradeConfig.getBrokerageEnabled())) {
@ -236,8 +237,9 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
// 校验分销关系绑定模式
if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) {
// TODO @疯狂是不是把 isNewUser 挪到这里好点呀
if (!BooleanUtil.isTrue(isNewUser)) {
// 判断是否为新用户注册时间在30秒内的都算新用户
boolean isNotNewUser = LocalDateTimeUtils.beforeNow(registerTime.plusSeconds(30));
if (isNotNewUser) {
throw exception(BROKERAGE_BIND_MODE_REGISTER); // 只有在注册时可以绑定
}
} else if (BrokerageBindModeEnum.ANYTIME.getMode().equals(tradeConfig.getBrokerageBindMode())) {

View File

@ -7,6 +7,13 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawD
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/**
* 佣金提现 Service 接口
*
@ -51,10 +58,20 @@ public interface BrokerageWithdrawService {
/**
* 汇总用户提现
*
* @param userId 用户编号
* @param status 提现状态
* @param userIds 用户编号
* @param status 提现状态
* @return 用户提现汇总
*/
UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status);
List<UserWithdrawSummaryBO> getWithdrawSummaryByUserId(Collection<Long> userIds, BrokerageWithdrawStatusEnum status);
/**
* 汇总用户提现
*
* @param userIds 用户编号
* @param status 提现状态
* @return 用户提现汇总
*/
default Map<Long, UserWithdrawSummaryBO> getWithdrawSummaryMapByUserId(Set<Long> userIds, BrokerageWithdrawStatusEnum status) {
return convertMap(getWithdrawSummaryByUserId(userIds, status), UserWithdrawSummaryBO::getUserId);
}
}

View File

@ -26,6 +26,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -142,9 +144,8 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
}
@Override
public UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status) {
UserWithdrawSummaryBO summaryBO = brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userId, status.getStatus());
return summaryBO != null ? summaryBO : new UserWithdrawSummaryBO(0, 0);
public List<UserWithdrawSummaryBO> getWithdrawSummaryByUserId(Collection<Long> userIds, BrokerageWithdrawStatusEnum status) {
return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus());
}
/**

View File

@ -13,7 +13,10 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class UserBrokerageSummaryBO {
/**
* 用户编号
*/
private Long userId;
/**
* 佣金数量
*/

View File

@ -14,6 +14,11 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class UserWithdrawSummaryBO {
/**
* 用户编号
*/
private Long userId;
/**
* 提现次数
*/