mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
trade: 优化分销用户绑定用户编号、绑定时间字段名称
This commit is contained in:
parent
f36a6c5d6c
commit
4b43304c76
@ -24,8 +24,8 @@ create table trade_config
|
||||
create table trade_brokerage_user
|
||||
(
|
||||
id bigint auto_increment comment '用户编号' primary key,
|
||||
brokerage_user_id bigint null comment '推广员编号',
|
||||
brokerage_bind_time datetime null comment '推广员绑定时间',
|
||||
bind_user_id bigint null comment '推广员编号',
|
||||
bind_user_time datetime null comment '推广员绑定时间',
|
||||
brokerage_enabled bit default 1 not null comment '是否成为推广员',
|
||||
brokerage_time datetime null comment '成为分销员时间',
|
||||
brokerage_price int default 0 not null comment '可用佣金',
|
||||
@ -38,7 +38,7 @@ create table trade_brokerage_user
|
||||
tenant_id bigint default 0 not null comment '租户编号'
|
||||
) comment '分销用户';
|
||||
|
||||
create index idx_invite_user_id on trade_brokerage_user (brokerage_user_id) comment '推广员编号';
|
||||
create index idx_invite_user_id on trade_brokerage_user (bind_user_id) comment '推广员编号';
|
||||
create index idx_agent on trade_brokerage_user (brokerage_enabled) comment '是否成为推广员';
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class BrokerageUserController {
|
||||
// 合计推广用户数量
|
||||
Map<Long, Long> brokerageUserCountMap = convertMap(userIds,
|
||||
userId -> userId,
|
||||
userId -> brokerageUserService.getCountByBrokerageUserId(userId));
|
||||
userId -> brokerageUserService.getCountByBindUserId(userId));
|
||||
|
||||
// todo 合计提现
|
||||
|
||||
|
@ -18,11 +18,11 @@ public class BrokerageUserBaseVO {
|
||||
|
||||
@Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587")
|
||||
@NotNull(message = "推广员编号不能为空")
|
||||
private Long brokerageUserId;
|
||||
private Long bindUserId;
|
||||
|
||||
@Schema(description = "推广员绑定时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime brokerageBindTime;
|
||||
private LocalDateTime bindUserTime;
|
||||
|
||||
@Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "推广资格不能为空")
|
||||
|
@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class BrokerageUserPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "推广员编号", example = "4587")
|
||||
private Long brokerageUserId;
|
||||
private Long bindUserId;
|
||||
|
||||
@Schema(description = "推广资格")
|
||||
private Boolean brokerageEnabled;
|
||||
|
@ -26,21 +26,22 @@ public class BrokerageUserDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
* <p>
|
||||
* 对应 MemberUserDO 的 id 字段
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
// TODO @疯狂:貌似改成 bindUserId,更明确?
|
||||
/**
|
||||
* 推广员编号
|
||||
*
|
||||
* <p>
|
||||
* 关联 MemberUserDO 的 id 字段
|
||||
*/
|
||||
private Long brokerageUserId;
|
||||
private Long bindUserId;
|
||||
/**
|
||||
* 推广员绑定时间
|
||||
*/
|
||||
private LocalDateTime brokerageBindTime;
|
||||
private LocalDateTime bindUserTime;
|
||||
|
||||
/**
|
||||
* 推广资格
|
||||
|
@ -19,7 +19,7 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
|
||||
|
||||
default PageResult<BrokerageUserDO> selectPage(BrokerageUserPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageUserDO>()
|
||||
.eqIfPresent(BrokerageUserDO::getBrokerageUserId, reqVO.getBrokerageUserId())
|
||||
.eqIfPresent(BrokerageUserDO::getBindUserId, reqVO.getBindUserId())
|
||||
.eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled())
|
||||
.betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BrokerageUserDO::getId));
|
||||
|
@ -75,10 +75,10 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
||||
addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), BrokerageAddReqBO::getFirstBrokeragePrice, bizType);
|
||||
|
||||
// 2.1 获得二级推广员
|
||||
if (firstUser.getBrokerageUserId() == null) {
|
||||
if (firstUser.getBindUserId() == null) {
|
||||
return;
|
||||
}
|
||||
BrokerageUserDO secondUser = brokerageUserService.getBrokerageUser(firstUser.getBrokerageUserId());
|
||||
BrokerageUserDO secondUser = brokerageUserService.getBrokerageUser(firstUser.getBindUserId());
|
||||
if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public interface BrokerageUserService {
|
||||
/**
|
||||
* 获得推广用户数量(一级)
|
||||
*
|
||||
* @param brokerageUserId 推广员编号
|
||||
* @param bindUserId 绑定的推广员编号
|
||||
* @return 推广用户数量
|
||||
*/
|
||||
Long getCountByBrokerageUserId(Long brokerageUserId);
|
||||
Long getCountByBindUserId(Long bindUserId);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
||||
public BrokerageUserDO getBindBrokerageUser(Long id) {
|
||||
return Optional.ofNullable(id)
|
||||
.map(this::getBrokerageUser)
|
||||
.map(BrokerageUserDO::getBrokerageUserId)
|
||||
.map(BrokerageUserDO::getBindUserId)
|
||||
.map(this::getBrokerageUser)
|
||||
.orElse(null);
|
||||
}
|
||||
@ -101,8 +101,8 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCountByBrokerageUserId(Long brokerageUserId) {
|
||||
return brokerageUserMapper.selectCount(BrokerageUserDO::getBrokerageUserId, brokerageUserId);
|
||||
public Long getCountByBindUserId(Long bindUserId) {
|
||||
return brokerageUserMapper.selectCount(BrokerageUserDO::getBindUserId, bindUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,20 +37,20 @@ public class BrokerageUserServiceImplTest extends BaseDbUnitTest {
|
||||
public void testGetBrokerageUserPage() {
|
||||
// mock 数据
|
||||
BrokerageUserDO dbBrokerageUser = randomPojo(BrokerageUserDO.class, o -> { // 等会查询到
|
||||
o.setBrokerageUserId(null);
|
||||
o.setBindUserId(null);
|
||||
o.setBrokerageEnabled(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
brokerageUserMapper.insert(dbBrokerageUser);
|
||||
// 测试 brokerageUserId 不匹配
|
||||
brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageUserId(null)));
|
||||
brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBindUserId(null)));
|
||||
// 测试 brokerageEnabled 不匹配
|
||||
brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageEnabled(null)));
|
||||
// 测试 createTime 不匹配
|
||||
brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
BrokerageUserPageReqVO reqVO = new BrokerageUserPageReqVO();
|
||||
reqVO.setBrokerageUserId(null);
|
||||
reqVO.setBindUserId(null);
|
||||
reqVO.setBrokerageEnabled(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
|
@ -129,8 +129,8 @@ CREATE TABLE IF NOT EXISTS "trade_after_sale_log" (
|
||||
CREATE TABLE IF NOT EXISTS "trade_brokerage_user"
|
||||
(
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"brokerage_user_id" bigint NOT NULL,
|
||||
"brokerage_bind_time" varchar,
|
||||
"bind_user_id" bigint NOT NULL,
|
||||
"bind_user_time" varchar,
|
||||
"brokerage_enabled" bit NOT NULL,
|
||||
"brokerage_time" varchar,
|
||||
"brokerage_price" int NOT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user