Commit a68691f2d93623404628fce2d7f222c4240cec5d
1 parent
64745027
trade: 增加分销用户表
Showing
17 changed files
with
599 additions
and
43 deletions
sql/mysql/brokerage.sql
| 1 | --- 增加配置 | |
| 1 | +-- 增加配置表 | |
| 2 | 2 | create table trade_config |
| 3 | 3 | ( |
| 4 | - id bigint auto_increment comment '自增主键' | |
| 5 | - primary key, | |
| 4 | + id bigint auto_increment comment '自增主键' primary key, | |
| 6 | 5 | brokerage_enabled bit default 1 not null comment '是否启用分佣', |
| 7 | 6 | brokerage_enabled_condition tinyint default 0 not null comment '分佣模式:0-人人分销 1-指定分销', |
| 8 | 7 | brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模式: 0-没有推广人,1-新用户', |
| ... | ... | @@ -21,22 +20,26 @@ create table trade_config |
| 21 | 20 | tenant_id bigint default 0 not null comment '租户编号' |
| 22 | 21 | ) comment '交易中心配置'; |
| 23 | 22 | |
| 24 | --- 用户表增加分销相关字段 | |
| 25 | -alter table member_user | |
| 26 | - add column brokerage_user_id bigint not null comment '推广员编号'; | |
| 27 | -alter table member_user | |
| 28 | - add column brokerage_bind_time datetime null comment '推广员绑定时间'; | |
| 29 | -alter table member_user | |
| 30 | - add column brokerage_enabled bit default 1 not null comment '是否成为推广员'; | |
| 31 | -alter table member_user | |
| 32 | - add column brokerage_time datetime null comment '成为分销员时间'; | |
| 33 | -alter table member_user | |
| 34 | - add column brokerage_price int default 0 not null comment '可用佣金'; | |
| 35 | -alter table member_user | |
| 36 | - add column frozen_brokerage_price int default 0 not null comment '冻结佣金'; | |
| 37 | - | |
| 38 | -create index idx_invite_user_id on member_user (brokerage_user_id) comment '推广员编号'; | |
| 39 | -create index idx_agent on member_user (brokerage_enabled) comment '是否成为推广员'; | |
| 23 | +-- 增加分销用户扩展表 | |
| 24 | +create table trade_brokerage_user | |
| 25 | +( | |
| 26 | + id bigint auto_increment comment '用户编号' primary key, | |
| 27 | + brokerage_user_id bigint not null comment '推广员编号', | |
| 28 | + brokerage_bind_time datetime null comment '推广员绑定时间', | |
| 29 | + brokerage_enabled bit default 1 not null comment '是否成为推广员', | |
| 30 | + brokerage_time datetime null comment '成为分销员时间', | |
| 31 | + brokerage_price int default 0 not null comment '可用佣金', | |
| 32 | + frozen_brokerage_price int default 0 not null comment '冻结佣金', | |
| 33 | + creator varchar(64) collate utf8mb4_unicode_ci default '' null comment '创建者', | |
| 34 | + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 35 | + updater varchar(64) collate utf8mb4_unicode_ci default '' null comment '更新者', | |
| 36 | + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间', | |
| 37 | + deleted bit default b'0' not null comment '是否删除', | |
| 38 | + tenant_id bigint default 0 not null comment '租户编号' | |
| 39 | +) comment '分销用户'; | |
| 40 | + | |
| 41 | +create index idx_invite_user_id on trade_brokerage_user (brokerage_user_id) comment '推广员编号'; | |
| 42 | +create index idx_agent on trade_brokerage_user (brokerage_enabled) comment '是否成为推广员'; | |
| 40 | 43 | |
| 41 | 44 | |
| 42 | 45 | create table member_brokerage_record |
| ... | ... | @@ -150,55 +153,65 @@ values ('brokerage_bank_name', '工商银行', 0, 0), |
| 150 | 153 | ('brokerage_bank_name', '交通银行', 4, 4), |
| 151 | 154 | ('brokerage_bank_name', '招商银行', 5, 5); |
| 152 | 155 | |
| 153 | --- 增加菜单:分销员管理 | |
| 156 | + | |
| 157 | +-- 交易中心配置:菜单 SQL | |
| 154 | 158 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) |
| 155 | -VALUES ('分销员', '', 2, 7, 2262, 'brokerage', 'user', 'member/brokerage/user/index', 0, 'MemberBrokerageUser'); | |
| 159 | +VALUES ('交易中心配置', '', 2, 0, 2072, 'config', 'ep:setting', 'trade/config/index', 0, 'TradeConfig'); | |
| 156 | 160 | -- 按钮父菜单ID |
| 161 | +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 | |
| 157 | 162 | SELECT @parentId := LAST_INSERT_ID(); |
| 158 | 163 | -- 按钮 SQL |
| 159 | 164 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 160 | -VALUES ('分销员查询', 'member:brokerage-user:query', 3, 1, @parentId, '', '', '', 0); | |
| 161 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 162 | -VALUES ('分销员创建', 'member:brokerage-user:create', 3, 2, @parentId, '', '', '', 0); | |
| 163 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 164 | -VALUES ('分销员更新', 'member:brokerage-user:update', 3, 3, @parentId, '', '', '', 0); | |
| 165 | +VALUES ('交易中心配置查询', 'trade:config:query', 3, 1, @parentId, '', '', '', 0); | |
| 165 | 166 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 166 | -VALUES ('分销员删除', 'member:brokerage-user:delete', 3, 4, @parentId, '', '', '', 0); | |
| 167 | +VALUES ('交易中心配置保存', 'trade:config:save', 3, 2, @parentId, '', '', '', 0); | |
| 167 | 168 | |
| 168 | --- 增加菜单:佣金记录 | |
| 169 | + | |
| 170 | +-- 增加菜单:分销 | |
| 171 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 172 | +VALUES ('分销', '', 1, 5, 2072, 'brokerage', 'fa-solid:project-diagram', '', 0, ''); | |
| 173 | +-- 按钮父菜单ID | |
| 174 | +SELECT @brokerageMenuId := LAST_INSERT_ID(); | |
| 175 | + | |
| 176 | +-- 增加菜单:分销员 | |
| 177 | +-- 菜单 SQL | |
| 169 | 178 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) |
| 170 | -VALUES ('佣金记录', '', 2, 8, 2262, 'brokerage-record', 'list', 'member/brokerage/record/index', 0, | |
| 171 | - 'MemberBrokerageRecord'); | |
| 179 | +VALUES ('分销用户', '', 2, 0, @brokerageMenuId, 'brokerage-user', 'fa-solid:user-tie', 'trade/brokerage/user/index', 0, | |
| 180 | + 'TradeBrokerageUser'); | |
| 172 | 181 | -- 按钮父菜单ID |
| 173 | 182 | -- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 |
| 174 | 183 | SELECT @parentId := LAST_INSERT_ID(); |
| 175 | 184 | -- 按钮 SQL |
| 176 | 185 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 177 | -VALUES ('佣金记录查询', 'member:member-brokerage-record:query', 3, 1, @parentId, '', 'table', '', 0); | |
| 186 | +VALUES ('分销用户查询', 'trade:brokerage-user:query', 3, 1, @parentId, '', '', '', 0); | |
| 187 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 188 | +VALUES ('分销用户修改推广员', 'trade:brokerage-user:update-brokerage-user', 3, 2, @parentId, '', '', '', 0); | |
| 189 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 190 | +VALUES ('分销用户清除推广员', 'trade:brokerage-user:clear-brokerage-user', 3, 3, @parentId, '', '', '', 0); | |
| 191 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) | |
| 192 | +VALUES ('分销用户修改推广资格', 'trade:brokerage-user:update-brokerage-enable', 3, 4, @parentId, '', '', '', 0); | |
| 178 | 193 | |
| 179 | --- 增加菜单:佣金提现 | |
| 180 | -INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 181 | -VALUES ('佣金提现', '', 2, 9, 2262, 'brokerage-withdraw', '', 'member/brokerage/withdraw/index', 0, | |
| 182 | - 'MemberBrokerageWithdraw'); | |
| 183 | 194 | |
| 195 | +-- 增加菜单:佣金记录 | |
| 196 | +INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) | |
| 197 | +VALUES ('佣金记录', '', 2, 1, @brokerageMenuId, 'brokerage-record', 'fa:money', 'trade/brokerage/record/index', 0, | |
| 198 | + 'TradeBrokerageRecord'); | |
| 184 | 199 | -- 按钮父菜单ID |
| 185 | 200 | -- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 |
| 186 | 201 | SELECT @parentId := LAST_INSERT_ID(); |
| 187 | - | |
| 188 | 202 | -- 按钮 SQL |
| 189 | 203 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 190 | -VALUES ('佣金提现查询', 'member:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); | |
| 204 | +VALUES ('佣金记录查询', 'trade:brokerage-record:query', 3, 1, @parentId, '', '', '', 0); | |
| 191 | 205 | |
| 192 | --- 交易中心配置:菜单 SQL | |
| 206 | +-- 增加菜单:佣金提现 | |
| 193 | 207 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status, component_name) |
| 194 | -VALUES ('交易中心配置', '', 2, 0, 2072, 'config', '', 'trade/config/index', 0, 'TradeConfig'); | |
| 195 | - | |
| 208 | +VALUES ('佣金提现', '', 2, 2, @brokerageMenuId, 'brokerage-withdraw', 'fa:credit-card', | |
| 209 | + 'trade/brokerage/withdraw/index', 0, 'TradeBrokerageWithdraw'); | |
| 196 | 210 | -- 按钮父菜单ID |
| 197 | 211 | -- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 |
| 198 | 212 | SELECT @parentId := LAST_INSERT_ID(); |
| 199 | - | |
| 200 | 213 | -- 按钮 SQL |
| 201 | 214 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 202 | -VALUES ('交易中心配置查询', 'trade:config:query', 3, 1, @parentId, '', '', '', 0); | |
| 215 | +VALUES ('佣金提现查询', 'trade:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); | |
| 203 | 216 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 204 | -VALUES ('交易中心配置保存', 'trade:config:save', 3, 2, @parentId, '', '', '', 0); | |
| 205 | 217 | \ No newline at end of file |
| 218 | +VALUES ('佣金提现审核', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); | |
| 206 | 219 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -74,4 +74,8 @@ public interface ErrorCodeConstants { |
| 74 | 74 | // ========== 物流 PICK_UP 模块 1011006000 ========== |
| 75 | 75 | ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1011006000, "自提门店不存在"); |
| 76 | 76 | |
| 77 | + | |
| 78 | + // ========== 分销 分销用户 模块 1011007000 ========== | |
| 79 | + ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1011007000, "分销用户不存在"); | |
| 80 | + | |
| 77 | 81 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/TradeBrokerageUserController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.trade.convert.brokerage.user.TradeBrokerageUserConvert; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 8 | +import cn.iocoder.yudao.module.trade.service.brokerage.user.TradeBrokerageUserService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.*; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import javax.validation.Valid; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 20 | + | |
| 21 | +@Tag(name = "管理后台 - 分销用户") | |
| 22 | +@RestController | |
| 23 | +@RequestMapping("/trade/brokerage-user") | |
| 24 | +@Validated | |
| 25 | +public class TradeBrokerageUserController { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private TradeBrokerageUserService brokerageUserService; | |
| 29 | + | |
| 30 | + @PutMapping("/update-brokerage-user") | |
| 31 | + @Operation(summary = "修改推广员") | |
| 32 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-user')") | |
| 33 | + public CommonResult<Boolean> updateBrokerageUser(@Valid @RequestBody TradeBrokerageUserUpdateBrokerageUserReqVO updateReqVO) { | |
| 34 | + brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), updateReqVO.getBrokerageUserId()); | |
| 35 | + return success(true); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @PutMapping("/clear-brokerage-user") | |
| 39 | + @Operation(summary = "清除推广员") | |
| 40 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:clear-brokerage-user')") | |
| 41 | + public CommonResult<Boolean> clearBrokerageUser(@Valid @RequestBody TradeBrokerageUserClearBrokerageUserReqVO updateReqVO) { | |
| 42 | + brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), null); | |
| 43 | + return success(true); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @PutMapping("/update-brokerage-enable") | |
| 47 | + @Operation(summary = "修改推广资格") | |
| 48 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-enable')") | |
| 49 | + public CommonResult<Boolean> updateBrokerageEnabled(@Valid @RequestBody TradeBrokerageUserUpdateBrokerageEnabledReqVO updateReqVO) { | |
| 50 | + brokerageUserService.updateBrokerageEnabled(updateReqVO.getId(), updateReqVO.getBrokerageEnabled()); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @GetMapping("/get") | |
| 55 | + @Operation(summary = "获得分销用户") | |
| 56 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 57 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") | |
| 58 | + public CommonResult<TradeBrokerageUserRespVO> getBrokerageUser(@RequestParam("id") Long id) { | |
| 59 | + TradeBrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id); | |
| 60 | + return success(TradeBrokerageUserConvert.INSTANCE.convert(brokerageUser)); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/page") | |
| 64 | + @Operation(summary = "获得分销用户分页") | |
| 65 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") | |
| 66 | + public CommonResult<PageResult<TradeBrokerageUserRespVO>> getBrokerageUserPage(@Valid TradeBrokerageUserPageReqVO pageVO) { | |
| 67 | + PageResult<TradeBrokerageUserDO> pageResult = brokerageUserService.getBrokerageUserPage(pageVO); | |
| 68 | + return success(TradeBrokerageUserConvert.INSTANCE.convertPage(pageResult)); | |
| 69 | + } | |
| 70 | + | |
| 71 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 分销用户 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 14 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +public class TradeBrokerageUserBaseVO { | |
| 18 | + | |
| 19 | + @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") | |
| 20 | + @NotNull(message = "推广员编号不能为空") | |
| 21 | + private Long brokerageUserId; | |
| 22 | + | |
| 23 | + @Schema(description = "推广员绑定时间") | |
| 24 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 25 | + private LocalDateTime brokerageBindTime; | |
| 26 | + | |
| 27 | + @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + @NotNull(message = "推广资格不能为空") | |
| 29 | + private Boolean brokerageEnabled; | |
| 30 | + | |
| 31 | + @Schema(description = "成为分销员时间") | |
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 33 | + private LocalDateTime brokerageTime; | |
| 34 | + | |
| 35 | + @Schema(description = "可用佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "11089") | |
| 36 | + @NotNull(message = "可用佣金不能为空") | |
| 37 | + private Integer brokeragePrice; | |
| 38 | + | |
| 39 | + @Schema(description = "冻结佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "30916") | |
| 40 | + @NotNull(message = "冻结佣金不能为空") | |
| 41 | + private Integer frozenBrokeragePrice; | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserClearBrokerageUserReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") | |
| 10 | +@Data | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class TradeBrokerageUserClearBrokerageUserReqVO { | |
| 13 | + | |
| 14 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") | |
| 15 | + @NotNull(message = "用户编号不能为空") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 分销用户分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class TradeBrokerageUserPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "推广员编号", example = "4587") | |
| 21 | + private Long brokerageUserId; | |
| 22 | + | |
| 23 | + @Schema(description = "推广资格") | |
| 24 | + private Boolean brokerageEnabled; | |
| 25 | + | |
| 26 | + @Schema(description = "创建时间") | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + private LocalDateTime[] createTime; | |
| 29 | + | |
| 30 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 分销用户 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class TradeBrokerageUserRespVO extends TradeBrokerageUserBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") | |
| 17 | + private Long id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageEnabledReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") | |
| 10 | +@Data | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class TradeBrokerageUserUpdateBrokerageEnabledReqVO { | |
| 13 | + | |
| 14 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") | |
| 15 | + @NotNull(message = "用户编号不能为空") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 19 | + @NotNull(message = "推广资格不能为空") | |
| 20 | + private Boolean brokerageEnabled; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/TradeBrokerageUserUpdateBrokerageUserReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") | |
| 10 | +@Data | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class TradeBrokerageUserUpdateBrokerageUserReqVO { | |
| 13 | + | |
| 14 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") | |
| 15 | + @NotNull(message = "用户编号不能为空") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") | |
| 19 | + @NotNull(message = "推广员编号不能为空") | |
| 20 | + private Long brokerageUserId; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/TradeBrokerageUserConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.convert.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserRespVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 6 | +import org.mapstruct.Mapper; | |
| 7 | +import org.mapstruct.factory.Mappers; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 分销用户 Convert | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface TradeBrokerageUserConvert { | |
| 18 | + | |
| 19 | + TradeBrokerageUserConvert INSTANCE = Mappers.getMapper(TradeBrokerageUserConvert.class); | |
| 20 | + | |
| 21 | + TradeBrokerageUserRespVO convert(TradeBrokerageUserDO bean); | |
| 22 | + | |
| 23 | + List<TradeBrokerageUserRespVO> convertList(List<TradeBrokerageUserDO> list); | |
| 24 | + | |
| 25 | + PageResult<TradeBrokerageUserRespVO> convertPage(PageResult<TradeBrokerageUserDO> page); | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/TradeBrokerageUserDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 分销用户 DO | |
| 13 | + * | |
| 14 | + * @author owen | |
| 15 | + */ | |
| 16 | +@TableName("trade_brokerage_user") | |
| 17 | +@KeySequence("trade_brokerage_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +@Builder | |
| 22 | +@NoArgsConstructor | |
| 23 | +@AllArgsConstructor | |
| 24 | +public class TradeBrokerageUserDO extends BaseDO { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 用户编号 | |
| 28 | + */ | |
| 29 | + @TableId | |
| 30 | + private Long id; | |
| 31 | + /** | |
| 32 | + * 推广员编号 | |
| 33 | + */ | |
| 34 | + private Long brokerageUserId; | |
| 35 | + /** | |
| 36 | + * 推广员绑定时间 | |
| 37 | + */ | |
| 38 | + private LocalDateTime brokerageBindTime; | |
| 39 | + /** | |
| 40 | + * 推广资格 | |
| 41 | + */ | |
| 42 | + private Boolean brokerageEnabled; | |
| 43 | + /** | |
| 44 | + * 成为分销员时间 | |
| 45 | + */ | |
| 46 | + private LocalDateTime brokerageTime; | |
| 47 | + /** | |
| 48 | + * 可用佣金 | |
| 49 | + */ | |
| 50 | + private Integer brokeragePrice; | |
| 51 | + /** | |
| 52 | + * 冻结佣金 | |
| 53 | + */ | |
| 54 | + private Integer frozenBrokeragePrice; | |
| 55 | + | |
| 56 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/TradeBrokerageUserMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 分销用户 Mapper | |
| 12 | + * | |
| 13 | + * @author owen | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface TradeBrokerageUserMapper extends BaseMapperX<TradeBrokerageUserDO> { | |
| 17 | + | |
| 18 | + default PageResult<TradeBrokerageUserDO> selectPage(TradeBrokerageUserPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<TradeBrokerageUserDO>() | |
| 20 | + .eqIfPresent(TradeBrokerageUserDO::getBrokerageUserId, reqVO.getBrokerageUserId()) | |
| 21 | + .eqIfPresent(TradeBrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) | |
| 22 | + .betweenIfPresent(TradeBrokerageUserDO::getCreateTime, reqVO.getCreateTime()) | |
| 23 | + .orderByDesc(TradeBrokerageUserDO::getId)); | |
| 24 | + } | |
| 25 | + | |
| 26 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 6 | + | |
| 7 | +import java.util.Collection; | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 分销用户 Service 接口 | |
| 12 | + * | |
| 13 | + * @author owen | |
| 14 | + */ | |
| 15 | +public interface TradeBrokerageUserService { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 获得分销用户 | |
| 19 | + * | |
| 20 | + * @param id 编号 | |
| 21 | + * @return 分销用户 | |
| 22 | + */ | |
| 23 | + TradeBrokerageUserDO getBrokerageUser(Long id); | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 获得分销用户列表 | |
| 27 | + * | |
| 28 | + * @param ids 编号 | |
| 29 | + * @return 分销用户列表 | |
| 30 | + */ | |
| 31 | + List<TradeBrokerageUserDO> getBrokerageUserList(Collection<Long> ids); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 获得分销用户分页 | |
| 35 | + * | |
| 36 | + * @param pageReqVO 分页查询 | |
| 37 | + * @return 分销用户分页 | |
| 38 | + */ | |
| 39 | + PageResult<TradeBrokerageUserDO> getBrokerageUserPage(TradeBrokerageUserPageReqVO pageReqVO); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 修改推广员编号 | |
| 43 | + * | |
| 44 | + * @param id 用户编号 | |
| 45 | + * @param brokerageUserId 推广员编号 | |
| 46 | + */ | |
| 47 | + void updateBrokerageUserId(Long id, Long brokerageUserId); | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 修改推广资格 | |
| 51 | + * | |
| 52 | + * @param id 用户编号 | |
| 53 | + * @param brokerageEnabled 推广资格 | |
| 54 | + */ | |
| 55 | + void updateBrokerageEnabled(Long id, Boolean brokerageEnabled); | |
| 56 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 6 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user.TradeBrokerageUserMapper; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | +import org.springframework.validation.annotation.Validated; | |
| 9 | + | |
| 10 | +import javax.annotation.Resource; | |
| 11 | +import java.util.Collection; | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 15 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_USER_NOT_EXISTS; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 分销用户 Service 实现类 | |
| 19 | + * | |
| 20 | + * @author owen | |
| 21 | + */ | |
| 22 | +@Service | |
| 23 | +@Validated | |
| 24 | +public class TradeBrokerageUserServiceImpl implements TradeBrokerageUserService { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private TradeBrokerageUserMapper brokerageUserMapper; | |
| 28 | + | |
| 29 | + private void validateBrokerageUserExists(Long id) { | |
| 30 | + if (brokerageUserMapper.selectById(id) == null) { | |
| 31 | + throw exception(BROKERAGE_USER_NOT_EXISTS); | |
| 32 | + } | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public TradeBrokerageUserDO getBrokerageUser(Long id) { | |
| 37 | + return brokerageUserMapper.selectById(id); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public List<TradeBrokerageUserDO> getBrokerageUserList(Collection<Long> ids) { | |
| 42 | + return brokerageUserMapper.selectBatchIds(ids); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public PageResult<TradeBrokerageUserDO> getBrokerageUserPage(TradeBrokerageUserPageReqVO pageReqVO) { | |
| 47 | + return brokerageUserMapper.selectPage(pageReqVO); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public void updateBrokerageUserId(Long id, Long brokerageUserId) { | |
| 52 | + // 校验存在 | |
| 53 | + validateBrokerageUserExists(id); | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public void updateBrokerageEnabled(Long id, Boolean brokerageEnabled) { | |
| 59 | + // 校验存在 | |
| 60 | + validateBrokerageUserExists(id); | |
| 61 | + } | |
| 62 | + | |
| 63 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/brokerage/user/TradeBrokerageUserServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.TradeBrokerageUserPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.TradeBrokerageUserDO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user.TradeBrokerageUserMapper; | |
| 8 | +import org.junit.jupiter.api.Disabled; | |
| 9 | +import org.junit.jupiter.api.Test; | |
| 10 | +import org.springframework.context.annotation.Import; | |
| 11 | + | |
| 12 | +import javax.annotation.Resource; | |
| 13 | + | |
| 14 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 18 | +import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * {@link TradeBrokerageUserServiceImpl} 的单元测试类 | |
| 22 | + * | |
| 23 | + * @author owen | |
| 24 | + */ | |
| 25 | +@Import(TradeBrokerageUserServiceImpl.class) | |
| 26 | +public class TradeBrokerageUserServiceImplTest extends BaseDbUnitTest { | |
| 27 | + | |
| 28 | + @Resource | |
| 29 | + private TradeBrokerageUserServiceImpl brokerageUserService; | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private TradeBrokerageUserMapper brokerageUserMapper; | |
| 33 | + | |
| 34 | + @Test | |
| 35 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 36 | + public void testGetBrokerageUserPage() { | |
| 37 | + // mock 数据 | |
| 38 | + TradeBrokerageUserDO dbBrokerageUser = randomPojo(TradeBrokerageUserDO.class, o -> { // 等会查询到 | |
| 39 | + o.setBrokerageUserId(null); | |
| 40 | + o.setBrokerageEnabled(null); | |
| 41 | + o.setCreateTime(null); | |
| 42 | + }); | |
| 43 | + brokerageUserMapper.insert(dbBrokerageUser); | |
| 44 | + // 测试 brokerageUserId 不匹配 | |
| 45 | + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageUserId(null))); | |
| 46 | + // 测试 brokerageEnabled 不匹配 | |
| 47 | + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setBrokerageEnabled(null))); | |
| 48 | + // 测试 createTime 不匹配 | |
| 49 | + brokerageUserMapper.insert(cloneIgnoreId(dbBrokerageUser, o -> o.setCreateTime(null))); | |
| 50 | + // 准备参数 | |
| 51 | + TradeBrokerageUserPageReqVO reqVO = new TradeBrokerageUserPageReqVO(); | |
| 52 | + reqVO.setBrokerageUserId(null); | |
| 53 | + reqVO.setBrokerageEnabled(null); | |
| 54 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 55 | + | |
| 56 | + // 调用 | |
| 57 | + PageResult<TradeBrokerageUserDO> pageResult = brokerageUserService.getBrokerageUserPage(reqVO); | |
| 58 | + // 断言 | |
| 59 | + assertEquals(1, pageResult.getTotal()); | |
| 60 | + assertEquals(1, pageResult.getList().size()); | |
| 61 | + assertPojoEquals(dbBrokerageUser, pageResult.getList().get(0)); | |
| 62 | + } | |
| 63 | + | |
| 64 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql
yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -125,3 +125,21 @@ CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( |
| 125 | 125 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 126 | 126 | PRIMARY KEY ("id") |
| 127 | 127 | ) COMMENT '交易售后日志'; |
| 128 | + | |
| 129 | +CREATE TABLE IF NOT EXISTS "trade_brokerage_user" | |
| 130 | +( | |
| 131 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 132 | + "brokerage_user_id" bigint NOT NULL, | |
| 133 | + "brokerage_bind_time" varchar, | |
| 134 | + "brokerage_enabled" bit NOT NULL, | |
| 135 | + "brokerage_time" varchar, | |
| 136 | + "brokerage_price" int NOT NULL, | |
| 137 | + "frozen_brokerage_price" int NOT NULL, | |
| 138 | + "creator" varchar DEFAULT '', | |
| 139 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 140 | + "updater" varchar DEFAULT '', | |
| 141 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 142 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 143 | + "tenant_id" bigint NOT NULL DEFAULT '0', | |
| 144 | + PRIMARY KEY ("id") | |
| 145 | +) COMMENT '分销用户'; | |
| 128 | 146 | \ No newline at end of file | ... | ... |