Commit 5c2af8e32d7f22493438538c22ae142fb02769ac
Committed by
Gitee
!1188 商城缺陷修复
Merge pull request !1188 from puhui999/develop
Showing
5 changed files
with
20 additions
and
15 deletions
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java
| ... | ... | @@ -13,23 +13,24 @@ import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum |
| 13 | 13 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; |
| 14 | 14 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; |
| 15 | 15 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; |
| 16 | -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; | |
| 17 | 16 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; |
| 17 | +import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; | |
| 18 | 18 | import io.swagger.v3.oas.annotations.Operation; |
| 19 | 19 | import io.swagger.v3.oas.annotations.Parameter; |
| 20 | 20 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 21 | +import jakarta.annotation.Resource; | |
| 22 | +import jakarta.validation.Valid; | |
| 21 | 23 | import org.springframework.security.access.prepost.PreAuthorize; |
| 22 | 24 | import org.springframework.validation.annotation.Validated; |
| 23 | 25 | import org.springframework.web.bind.annotation.*; |
| 24 | 26 | |
| 25 | -import jakarta.annotation.Resource; | |
| 26 | -import jakarta.validation.Valid; | |
| 27 | 27 | import java.util.Map; |
| 28 | 28 | import java.util.Set; |
| 29 | 29 | |
| 30 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 32 | 32 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 33 | +import static java.util.Arrays.asList; | |
| 33 | 34 | |
| 34 | 35 | @Tag(name = "管理后台 - 分销用户") |
| 35 | 36 | @RestController |
| ... | ... | @@ -110,7 +111,7 @@ public class BrokerageUserController { |
| 110 | 111 | // 合计分佣的提现 |
| 111 | 112 | // TODO @疯狂:如果未来支持了打款这个动作,可能 status 会不对; |
| 112 | 113 | Map<Long, BrokerageWithdrawSummaryRespBO> withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId( |
| 113 | - userIds, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS); | |
| 114 | + userIds, asList(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS)); | |
| 114 | 115 | // 拼接返回 |
| 115 | 116 | return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, |
| 116 | 117 | brokerageOrderSummaryMap, withdrawMap)); | ... | ... |
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; |
| 35 | 35 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 36 | 36 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 37 | 37 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 38 | +import static java.util.Arrays.asList; | |
| 38 | 39 | |
| 39 | 40 | @Tag(name = "用户 APP - 分销用户") |
| 40 | 41 | @RestController |
| ... | ... | @@ -84,7 +85,7 @@ public class AppBrokerageUserController { |
| 84 | 85 | BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime); |
| 85 | 86 | // 统计用户提现的佣金 |
| 86 | 87 | Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(userId), |
| 87 | - BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream() | |
| 88 | + asList(BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, BrokerageWithdrawStatusEnum.WITHDRAW_SUCCESS)).stream() | |
| 88 | 89 | .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0); |
| 89 | 90 | // 统计分销用户数量(一级) |
| 90 | 91 | Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1); | ... | ... |
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<BrokerageWithdrawDO |
| 41 | 41 | .eq(BrokerageWithdrawDO::getStatus, status)); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - default List<BrokerageWithdrawSummaryRespBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, Integer status) { | |
| 44 | + default List<BrokerageWithdrawSummaryRespBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, | |
| 45 | + Collection<Integer> status) { | |
| 45 | 46 | List<Map<String, Object>> list = selectMaps(new MPJLambdaWrapper<BrokerageWithdrawDO>() |
| 46 | 47 | .select(BrokerageWithdrawDO::getUserId) |
| 47 | 48 | .selectCount(BrokerageWithdrawDO::getId, BrokerageWithdrawSummaryRespBO::getCount) |
| 48 | 49 | .selectSum(BrokerageWithdrawDO::getPrice) |
| 49 | 50 | .in(BrokerageWithdrawDO::getUserId, userIds) |
| 50 | - .eq(BrokerageWithdrawDO::getStatus, status) | |
| 51 | + .in(BrokerageWithdrawDO::getStatus, status) | |
| 51 | 52 | .groupBy(BrokerageWithdrawDO::getUserId)); |
| 52 | 53 | return BeanUtil.copyToList(list, BrokerageWithdrawSummaryRespBO.class); |
| 53 | 54 | // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW | ... | ... |
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 { |
| 74 | 74 | * @return 用户提现汇总 List |
| 75 | 75 | */ |
| 76 | 76 | List<BrokerageWithdrawSummaryRespBO> getWithdrawSummaryListByUserId(Collection<Long> userIds, |
| 77 | - BrokerageWithdrawStatusEnum status); | |
| 77 | + Collection<BrokerageWithdrawStatusEnum> status); | |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * 按照 userId,汇总每个用户的提现 |
| ... | ... | @@ -84,7 +84,7 @@ public interface BrokerageWithdrawService { |
| 84 | 84 | * @return 用户提现汇总 Map |
| 85 | 85 | */ |
| 86 | 86 | default Map<Long, BrokerageWithdrawSummaryRespBO> getWithdrawSummaryMapByUserId(Set<Long> userIds, |
| 87 | - BrokerageWithdrawStatusEnum status) { | |
| 87 | + Collection<BrokerageWithdrawStatusEnum> status) { | |
| 88 | 88 | return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId); |
| 89 | 89 | } |
| 90 | 90 | ... | ... |
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; |
| 42 | 42 | import java.util.List; |
| 43 | 43 | |
| 44 | 44 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 45 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 45 | 46 | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; |
| 46 | 47 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 47 | 48 | |
| ... | ... | @@ -98,7 +99,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 98 | 99 | // 3.1 审批通过的后续处理 |
| 99 | 100 | if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { |
| 100 | 101 | auditBrokerageWithdrawSuccess(withdraw); |
| 101 | - // 3.2 审批不通过的后续处理 | |
| 102 | + // 3.2 审批不通过的后续处理 | |
| 102 | 103 | } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { |
| 103 | 104 | brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, |
| 104 | 105 | String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); |
| ... | ... | @@ -114,11 +115,11 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 114 | 115 | .setUserId(withdraw.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) |
| 115 | 116 | .setBizType(PayWalletBizTypeEnum.BROKERAGE_WITHDRAW.getType()).setBizId(withdraw.getId().toString()) |
| 116 | 117 | .setPrice(withdraw.getPrice())); |
| 117 | - // 1.2 微信 API | |
| 118 | + // 1.2 微信 API | |
| 118 | 119 | } else if (BrokerageWithdrawTypeEnum.WECHAT_API.getType().equals(withdraw.getType())) { |
| 119 | 120 | // TODO @luchi:这里,要加个转账单号的记录;另外,调用 API 转账,是立马成功,还是有延迟的哈? |
| 120 | 121 | Long payTransferId = createPayTransfer(withdraw); |
| 121 | - // 1.3 剩余类型,都是手动打款,所以不处理 | |
| 122 | + // 1.3 剩余类型,都是手动打款,所以不处理 | |
| 122 | 123 | } else { |
| 123 | 124 | // TODO 可优化:未来可以考虑,接入支付宝、银联等 API 转账,实现自动打款 |
| 124 | 125 | log.info("[auditBrokerageWithdrawSuccess][withdraw({}) 类型({}) 手动打款,无需处理]", withdraw.getId(), withdraw.getType()); |
| ... | ... | @@ -239,11 +240,12 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 239 | 240 | |
| 240 | 241 | @Override |
| 241 | 242 | public List<BrokerageWithdrawSummaryRespBO> getWithdrawSummaryListByUserId(Collection<Long> userIds, |
| 242 | - BrokerageWithdrawStatusEnum status) { | |
| 243 | - if (CollUtil.isEmpty(userIds)) { | |
| 243 | + Collection<BrokerageWithdrawStatusEnum> status) { | |
| 244 | + if (CollUtil.isEmpty(userIds) || CollUtil.isEmpty(status)) { | |
| 244 | 245 | return Collections.emptyList(); |
| 245 | 246 | } |
| 246 | - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); | |
| 247 | + return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, | |
| 248 | + convertSet(status, BrokerageWithdrawStatusEnum::getStatus)); | |
| 247 | 249 | } |
| 248 | 250 | |
| 249 | 251 | } | ... | ... |