分销:提现统计
This commit is contained in:
parent
0b84c18736
commit
3dca66eefa
@ -9,9 +9,12 @@ import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert;
|
||||
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.bo.UserWithdrawSummaryBO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -38,6 +41,8 @@ public class BrokerageUserController {
|
||||
private BrokerageUserService brokerageUserService;
|
||||
@Resource
|
||||
private BrokerageRecordService brokerageRecordService;
|
||||
@Resource
|
||||
private BrokerageWithdrawService brokerageWithdrawService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
@ -97,9 +102,12 @@ public class BrokerageUserController {
|
||||
userId -> userId,
|
||||
userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null));
|
||||
|
||||
// todo 合计提现
|
||||
// 合计提现
|
||||
Map<Long, UserWithdrawSummaryBO> withdrawMap = convertMap(userIds,
|
||||
userId -> userId,
|
||||
userId -> brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS));
|
||||
|
||||
return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap));
|
||||
return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap, withdrawMap));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum
|
||||
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.UserWithdrawSummaryBO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -82,7 +83,7 @@ public class AppBrokerageUserController {
|
||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
||||
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
|
||||
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
|
||||
.setWithdrawPrice(brokerageWithdrawService.getSummaryPriceByUserIdAndStatus(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()))
|
||||
.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));
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.Brokerag
|
||||
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;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@ -29,13 +30,14 @@ public interface BrokerageUserConvert {
|
||||
|
||||
List<BrokerageUserRespVO> convertList(List<BrokerageUserDO> list);
|
||||
|
||||
PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> page);
|
||||
PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> page, Map<Long, MemberUserRespDTO> userMap, Map<Long, Long> brokerageUserCountMap, Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap);
|
||||
|
||||
default PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> pageResult,
|
||||
Map<Long, MemberUserRespDTO> userMap,
|
||||
Map<Long, Long> brokerageUserCountMap,
|
||||
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap) {
|
||||
PageResult<BrokerageUserRespVO> result = convertPage(pageResult);
|
||||
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap,
|
||||
Map<Long, UserWithdrawSummaryBO> withdrawMap) {
|
||||
PageResult<BrokerageUserRespVO> result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap);
|
||||
for (BrokerageUserRespVO userVO : result.getList()) {
|
||||
// 用户信息
|
||||
copyTo(userMap.get(userVO.getId()), userVO);
|
||||
@ -46,7 +48,10 @@ public interface BrokerageUserConvert {
|
||||
Optional<UserBrokerageSummaryBO> orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId()));
|
||||
userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryBO::getCount).orElse(0))
|
||||
.setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryBO::getPrice).orElse(0));
|
||||
// todo 已提现次数、已提现金额
|
||||
// 已提现次数、已提现金额
|
||||
Optional<UserWithdrawSummaryBO> withdrawSummaryOptional = Optional.ofNullable(withdrawMap.get(userVO.getId()));
|
||||
userVO.setWithdrawCount(withdrawSummaryOptional.map(UserWithdrawSummaryBO::getCount).orElse(0))
|
||||
.setWithdrawPrice(withdrawSummaryOptional.map(UserWithdrawSummaryBO::getPrice).orElse(0));
|
||||
userVO.setWithdrawCount(0).setWithdrawPrice(0);
|
||||
}
|
||||
return result;
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
|
||||
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 org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -36,8 +37,7 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
||||
.eq(BrokerageWithdrawDO::getStatus, status));
|
||||
}
|
||||
|
||||
@Select("SELECT SUM(price) FROM trade_brokerage_withdraw " +
|
||||
@Select("SELECT COUNT(1) AS count, SUM(price) AS price FROM trade_brokerage_withdraw " +
|
||||
"WHERE user_id = #{userId} AND status = #{status}")
|
||||
Integer selectSummaryPriceByUserIdAndStatus(@Param("userId") Long userId, @Param("status") Integer status);
|
||||
|
||||
UserWithdrawSummaryBO selectCountAndSumPriceByUserIdAndStatus(Long userId, Integer status);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.Brok
|
||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||
|
||||
/**
|
||||
* 佣金提现 Service 接口
|
||||
@ -48,12 +49,12 @@ public interface BrokerageWithdrawService {
|
||||
Long createBrokerageWithdraw(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 获得用户已提现金额
|
||||
* 汇总用户提现
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param status 状态
|
||||
* @return 用户已提现金额
|
||||
* @param status 提现状态
|
||||
* @return 用户提现汇总
|
||||
*/
|
||||
Integer getSummaryPriceByUserIdAndStatus(Long userId, Integer status);
|
||||
UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status);
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.service.brokerage;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.math.Money;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
@ -18,6 +17,7 @@ import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -142,8 +142,9 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSummaryPriceByUserIdAndStatus(Long userId, Integer status) {
|
||||
return brokerageWithdrawMapper.selectSummaryPriceByUserIdAndStatus(userId, status);
|
||||
public UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status) {
|
||||
UserWithdrawSummaryBO summaryBO = brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userId, status.getStatus());
|
||||
return summaryBO != null ? summaryBO : new UserWithdrawSummaryBO(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.trade.service.brokerage.bo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 用户佣金提现合计 BO
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserWithdrawSummaryBO {
|
||||
|
||||
/**
|
||||
* 提现次数
|
||||
*/
|
||||
private Integer count;
|
||||
/**
|
||||
* 提现金额
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user