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