diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java index 3380362ff0..c037c9fa00 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java @@ -30,6 +30,7 @@ import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static java.util.Arrays.asList; @Tag(name = "管理后台 - 分销用户") @RestController @@ -110,7 +111,7 @@ public class BrokerageUserController { // 合计分佣的提现 // TODO @疯狂:如果未来支持了打款这个动作,可能 status 会不对; Map withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId( - userIds, BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS); + userIds, asList(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS)); // 拼接返回 return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, brokerageOrderSummaryMap, withdrawMap)); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java index ed889ef162..9f9dcde371 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java @@ -35,6 +35,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static java.util.Arrays.asList; @Tag(name = "用户 APP - 分销用户") @RestController @@ -84,7 +85,7 @@ public class AppBrokerageUserController { BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime); // 统计用户提现的佣金 Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(userId), - BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS).stream() + asList(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS)).stream() .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0); // 统计分销用户数量(一级) Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java index dc2b009160..1942cc42bb 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java @@ -41,13 +41,14 @@ public interface BrokerageWithdrawMapper extends BaseMapperX selectCountAndSumPriceByUserIdAndStatus(Collection userIds, Integer status) { + default List selectCountAndSumPriceByUserIdAndStatus(Collection userIds, + Collection status) { List> list = selectMaps(new MPJLambdaWrapper() .select(BrokerageWithdrawDO::getUserId) .selectCount(BrokerageWithdrawDO::getId, BrokerageWithdrawSummaryRespBO::getCount) .selectSum(BrokerageWithdrawDO::getPrice) .in(BrokerageWithdrawDO::getUserId, userIds) - .eq(BrokerageWithdrawDO::getStatus, status) + .in(BrokerageWithdrawDO::getStatus, status) .groupBy(BrokerageWithdrawDO::getUserId)); return BeanUtil.copyToList(list, BrokerageWithdrawSummaryRespBO.class); // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java index 386b4c6107..400d68f76f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java @@ -74,7 +74,7 @@ public interface BrokerageWithdrawService { * @return 用户提现汇总 List */ List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status); + Collection status); /** * 按照 userId,汇总每个用户的提现 @@ -84,7 +84,7 @@ public interface BrokerageWithdrawService { * @return 用户提现汇总 Map */ default Map getWithdrawSummaryMapByUserId(Set userIds, - BrokerageWithdrawStatusEnum status) { + Collection status) { return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java index 6e63ae71f3..b095494e55 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java @@ -42,6 +42,7 @@ import java.util.Collections; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; @@ -98,7 +99,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { // 3.1 审批通过的后续处理 if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { auditBrokerageWithdrawSuccess(withdraw); - // 3.2 审批不通过的后续处理 + // 3.2 审批不通过的后续处理 } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); @@ -114,11 +115,11 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { .setUserId(withdraw.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) .setBizType(PayWalletBizTypeEnum.BROKERAGE_WITHDRAW.getType()).setBizId(withdraw.getId().toString()) .setPrice(withdraw.getPrice())); - // 1.2 微信 API + // 1.2 微信 API } else if (BrokerageWithdrawTypeEnum.WECHAT_API.getType().equals(withdraw.getType())) { // TODO @luchi:这里,要加个转账单号的记录;另外,调用 API 转账,是立马成功,还是有延迟的哈? Long payTransferId = createPayTransfer(withdraw); - // 1.3 剩余类型,都是手动打款,所以不处理 + // 1.3 剩余类型,都是手动打款,所以不处理 } else { // TODO 可优化:未来可以考虑,接入支付宝、银联等 API 转账,实现自动打款 log.info("[auditBrokerageWithdrawSuccess][withdraw({}) 类型({}) 手动打款,无需处理]", withdraw.getId(), withdraw.getType()); @@ -239,11 +240,12 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { @Override public List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status) { - if (CollUtil.isEmpty(userIds)) { + Collection status) { + if (CollUtil.isEmpty(userIds) || CollUtil.isEmpty(status)) { return Collections.emptyList(); } - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); + return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, + convertSet(status, BrokerageWithdrawStatusEnum::getStatus)); } }