code review:分销
This commit is contained in:
parent
d874346d42
commit
df4716d5a1
@ -83,7 +83,6 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级");
|
ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级");
|
||||||
ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2");
|
ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2");
|
||||||
|
|
||||||
|
|
||||||
// ========== 分销提现 模块 1-011-008-000 ==========
|
// ========== 分销提现 模块 1-011-008-000 ==========
|
||||||
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在");
|
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在");
|
||||||
ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1_011_008_001, "佣金提现记录状态不是审核中");
|
ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1_011_008_001, "佣金提现记录状态不是审核中");
|
||||||
|
@ -151,10 +151,16 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
|
|||||||
@Param("ids") Collection<Long> ids,
|
@Param("ids") Collection<Long> ids,
|
||||||
@Param("sortingField") SortingField sortingField);
|
@Param("sortingField") SortingField sortingField);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得被 bindUserIds 推广的用户编号数组
|
||||||
|
*
|
||||||
|
* @param bindUserIds 推广员编号数组
|
||||||
|
* @return 用户编号数组
|
||||||
|
*/
|
||||||
default List<Long> selectIdListByBindUserIdIn(Collection<Long> bindUserIds) {
|
default List<Long> selectIdListByBindUserIdIn(Collection<Long> bindUserIds) {
|
||||||
return Convert.toList(Long.class,
|
return Convert.toList(Long.class,
|
||||||
selectObjs(new LambdaQueryWrapperX<BrokerageUserDO>()
|
selectObjs(new LambdaQueryWrapperX<BrokerageUserDO>()
|
||||||
.select(Collections.singletonList(BrokerageUserDO::getId))
|
.select(Collections.singletonList(BrokerageUserDO::getId)) // 只查询 id 字段,加速返回速度
|
||||||
.in(BrokerageUserDO::getBindUserId, bindUserIds)));
|
.in(BrokerageUserDO::getBindUserId, bindUserIds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,6 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
if (CollUtil.isEmpty(childIds)) {
|
if (CollUtil.isEmpty(childIds)) {
|
||||||
return PageResult.empty();
|
return PageResult.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.2 根据昵称过滤下级用户
|
// 1.2 根据昵称过滤下级用户
|
||||||
Map<Long, MemberUserRespDTO> userMap = convertMapByFilter(memberUserApi.getUserList(childIds),
|
Map<Long, MemberUserRespDTO> userMap = convertMapByFilter(memberUserApi.getUserList(childIds),
|
||||||
user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()),
|
user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()),
|
||||||
@ -240,13 +239,13 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
return PageResult.empty();
|
return PageResult.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 分页查询
|
// 2. 分页查询
|
||||||
IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId(
|
IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId(
|
||||||
MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(),
|
MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(),
|
||||||
BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), userMap.keySet(), pageReqVO.getSortingField()
|
BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), userMap.keySet(), pageReqVO.getSortingField()
|
||||||
);
|
);
|
||||||
|
|
||||||
// 3 拼接数据并返回
|
// 3. 拼接数据并返回
|
||||||
BrokerageUserConvert.INSTANCE.copyTo(pageResult.getRecords(), userMap);
|
BrokerageUserConvert.INSTANCE.copyTo(pageResult.getRecords(), userMap);
|
||||||
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.member.service.user;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -28,6 +27,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -78,6 +79,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
|
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
|
||||||
// 用户已经存在
|
// 用户已经存在
|
||||||
MemberUserDO user = memberUserMapper.selectByMobile(mobile);
|
MemberUserDO user = memberUserMapper.selectByMobile(mobile);
|
||||||
@ -85,7 +87,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
// 用户不存在,则进行创建
|
// 用户不存在,则进行创建
|
||||||
return this.createUser(mobile, registerIp);
|
return createUser(mobile, registerIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MemberUserDO createUser(String mobile, String registerIp) {
|
private MemberUserDO createUser(String mobile, String registerIp) {
|
||||||
@ -97,13 +99,17 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||||
user.setPassword(encodePassword(password)); // 加密密码
|
user.setPassword(encodePassword(password)); // 加密密码
|
||||||
user.setRegisterIp(registerIp);
|
user.setRegisterIp(registerIp);
|
||||||
|
memberUserMapper.insert(user);
|
||||||
|
|
||||||
Boolean success = transactionTemplate.execute(status -> memberUserMapper.insert(user) > 0);
|
// 发送 MQ 消息:用户创建
|
||||||
if (BooleanUtil.isTrue(success)) {
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
// 发送 MQ 消息:用户创建
|
|
||||||
registerCouponProducer.sendUserCreateMessage(user.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCommit() {
|
||||||
|
registerCouponProducer.sendUserCreateMessage(user.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user