Commit 32e1fc66ce2979055982178ea8146d32e05ef278
1 parent
f998d43e
trade: 分销业务 - 佣金提现后台管理
Showing
14 changed files
with
690 additions
and
7 deletions
sql/mysql/brokerage.sql
| ... | ... | @@ -148,12 +148,12 @@ values ('brokerage_record_status', '待结算', 0, 0), |
| 148 | 148 | |
| 149 | 149 | insert into system_dict_type(type, name) |
| 150 | 150 | values ('brokerage_withdraw_status', '佣金提现状态'); |
| 151 | -insert into system_dict_data(dict_type, label, value, sort) | |
| 152 | -values ('brokerage_withdraw_status', '审核中', 0, 0), | |
| 153 | - ('brokerage_withdraw_status', '审核通过', 10, 10), | |
| 154 | - ('brokerage_withdraw_status', '提现成功', 11, 11), | |
| 155 | - ('brokerage_withdraw_status', '审核不通过', 20, 20), | |
| 156 | - ('brokerage_withdraw_status', '提现失败', 21, 21); | |
| 151 | +insert into system_dict_data(dict_type, label, value, sort, color_type) | |
| 152 | +values ('brokerage_withdraw_status', '审核中', 0, 0, ''), | |
| 153 | + ('brokerage_withdraw_status', '审核通过', 10, 10, 'success'), | |
| 154 | + ('brokerage_withdraw_status', '提现成功', 11, 11, 'success'), | |
| 155 | + ('brokerage_withdraw_status', '审核不通过', 20, 20, 'danger'), | |
| 156 | + ('brokerage_withdraw_status', '提现失败', 21, 21, 'danger'); | |
| 157 | 157 | |
| 158 | 158 | insert into system_dict_type(type, name) |
| 159 | 159 | values ('brokerage_bank_name', '佣金提现银行'); |
| ... | ... | @@ -229,4 +229,10 @@ SELECT @parentId := LAST_INSERT_ID(); |
| 229 | 229 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 230 | 230 | VALUES ('佣金提现查询', 'trade:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); |
| 231 | 231 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 232 | -VALUES ('佣金提现审核', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); | |
| 233 | 232 | \ No newline at end of file |
| 233 | +VALUES ('佣金提现审核', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); | |
| 234 | + | |
| 235 | +-- 站内信模板 | |
| 236 | +INSERT INTO `ruoyi-vue-pro`.system_notify_template (name, code, nickname, content, type, params, status) | |
| 237 | +VALUES | |
| 238 | + ('佣金提现(审核通过)', 'brokerage_withdraw_audit_approve', 'system', '您在{createTime}提现¥{price}元的申请已通过审核', 2, '["createTime","price"]', 0), | |
| 239 | + ('佣金提现(审核不通过)', 'brokerage_withdraw_audit_reject', 'system', '您在{createTime}提现¥{price}元的申请未通过审核,原因:{reason}', 2, '["createTime","price","reason"]', 0); | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -88,4 +88,9 @@ public interface ErrorCodeConstants { |
| 88 | 88 | ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1011007006, "已绑定了推广人"); |
| 89 | 89 | ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1011007007, "下级不能绑定自己的上级"); |
| 90 | 90 | |
| 91 | + | |
| 92 | + // ========== 分销提现 模块 1011008000 ========== | |
| 93 | + ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1011008000, "佣金提现记录不存在"); | |
| 94 | + ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1011008001, "佣金提现记录状态不是审核中"); | |
| 95 | + | |
| 91 | 96 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
| ... | ... | @@ -10,4 +10,7 @@ public interface MessageTemplateConstants { |
| 10 | 10 | |
| 11 | 11 | String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 |
| 12 | 12 | |
| 13 | + String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) | |
| 14 | + String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) | |
| 15 | + | |
| 13 | 16 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/BrokerageWithdrawController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw; | |
| 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.member.api.user.MemberUserApi; | |
| 6 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawAuditReqVO; | |
| 8 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO; | |
| 10 | +import cn.iocoder.yudao.module.trade.convert.brokerage.withdraw.BrokerageWithdrawConvert; | |
| 11 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 12 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 13 | +import cn.iocoder.yudao.module.trade.service.brokerage.withdraw.BrokerageWithdrawService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | +import org.springframework.validation.annotation.Validated; | |
| 19 | +import org.springframework.web.bind.annotation.*; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import javax.validation.Valid; | |
| 23 | + | |
| 24 | +import java.util.Map; | |
| 25 | +import java.util.Set; | |
| 26 | + | |
| 27 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 28 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 29 | + | |
| 30 | +@Tag(name = "管理后台 - 佣金提现") | |
| 31 | +@RestController | |
| 32 | +@RequestMapping("/trade/brokerage-withdraw") | |
| 33 | +@Validated | |
| 34 | +public class BrokerageWithdrawController { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private BrokerageWithdrawService brokerageWithdrawService; | |
| 38 | + | |
| 39 | + @Resource | |
| 40 | + private MemberUserApi memberUserApi; | |
| 41 | + | |
| 42 | + @PutMapping("/approve") | |
| 43 | + @Operation(summary = "佣金提现 - 通过申请") | |
| 44 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") | |
| 45 | + public CommonResult<Boolean> approveBrokerageWithdraw(@RequestParam("id") Integer id) { | |
| 46 | + brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); | |
| 47 | + return success(true); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @PutMapping("/reject") | |
| 51 | + @Operation(summary = "审核佣金提现 - 驳回申请") | |
| 52 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") | |
| 53 | + public CommonResult<Boolean> rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawAuditReqVO reqVO) { | |
| 54 | + brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); | |
| 55 | + return success(true); | |
| 56 | + } | |
| 57 | + | |
| 58 | + @GetMapping("/get") | |
| 59 | + @Operation(summary = "获得佣金提现") | |
| 60 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 61 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") | |
| 62 | + public CommonResult<BrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Integer id) { | |
| 63 | + BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); | |
| 64 | + return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @GetMapping("/page") | |
| 68 | + @Operation(summary = "获得佣金提现分页") | |
| 69 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") | |
| 70 | + public CommonResult<PageResult<BrokerageWithdrawRespVO>> getBrokerageWithdrawPage(@Valid BrokerageWithdrawPageReqVO pageVO) { | |
| 71 | + // 分页查询 | |
| 72 | + PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(pageVO); | |
| 73 | + | |
| 74 | + // 涉及到的用户 | |
| 75 | + Set<Long> userIds = convertSet(pageResult.getList(), BrokerageWithdrawDO::getUserId); | |
| 76 | + // 查询用户信息 | |
| 77 | + Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(userIds); | |
| 78 | + | |
| 79 | + return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); | |
| 80 | + } | |
| 81 | + | |
| 82 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawAuditReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.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.NotEmpty; | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 佣金提现审核 Request VO") | |
| 11 | +@Data | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class BrokerageWithdrawAuditReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") | |
| 16 | + @NotNull(message = "编号不能为空") | |
| 17 | + private Integer id; | |
| 18 | + | |
| 19 | + @Schema(description = "审核驳回原因", example = "不对") | |
| 20 | + @NotEmpty(message = "审核驳回原因不能为空") | |
| 21 | + private String auditReason; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.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 BrokerageWithdrawBaseVO { | |
| 18 | + | |
| 19 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") | |
| 20 | + @NotNull(message = "用户编号不能为空") | |
| 21 | + private Long userId; | |
| 22 | + | |
| 23 | + @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") | |
| 24 | + @NotNull(message = "提现金额不能为空") | |
| 25 | + private Integer price; | |
| 26 | + | |
| 27 | + @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") | |
| 28 | + @NotNull(message = "提现手续费不能为空") | |
| 29 | + private Integer feePrice; | |
| 30 | + | |
| 31 | + @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") | |
| 32 | + @NotNull(message = "当前总佣金不能为空") | |
| 33 | + private Integer totalPrice; | |
| 34 | + | |
| 35 | + @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 36 | + @NotNull(message = "提现类型不能为空") | |
| 37 | + private Integer type; | |
| 38 | + | |
| 39 | + @Schema(description = "真实姓名", example = "赵六") | |
| 40 | + private String name; | |
| 41 | + | |
| 42 | + @Schema(description = "账号") | |
| 43 | + private String accountNo; | |
| 44 | + | |
| 45 | + @Schema(description = "银行名称", example = "1") | |
| 46 | + private String bankName; | |
| 47 | + | |
| 48 | + @Schema(description = "开户地址", example = "海淀支行") | |
| 49 | + private String bankAddress; | |
| 50 | + | |
| 51 | + @Schema(description = "收款码", example = "https://www.iocoder.cn") | |
| 52 | + private String accountQrCodeUrl; | |
| 53 | + | |
| 54 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 55 | + @NotNull(message = "状态不能为空") | |
| 56 | + private Integer status; | |
| 57 | + | |
| 58 | + @Schema(description = "审核驳回原因", example = "不对") | |
| 59 | + private String auditReason; | |
| 60 | + | |
| 61 | + @Schema(description = "审核时间") | |
| 62 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 63 | + private LocalDateTime auditTime; | |
| 64 | + | |
| 65 | + @Schema(description = "备注", example = "随便") | |
| 66 | + private String remark; | |
| 67 | + | |
| 68 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 7 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | +import lombok.ToString; | |
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 12 | + | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 16 | + | |
| 17 | +@Schema(description = "管理后台 - 佣金提现分页 Request VO") | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +public class BrokerageWithdrawPageReqVO extends PageParam { | |
| 22 | + | |
| 23 | + @Schema(description = "用户编号", example = "11436") | |
| 24 | + private Long userId; | |
| 25 | + | |
| 26 | + @Schema(description = "提现类型", example = "1") | |
| 27 | + @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现类型必须是 {value}") | |
| 28 | + private Integer type; | |
| 29 | + | |
| 30 | + @Schema(description = "真实姓名", example = "赵六") | |
| 31 | + private String name; | |
| 32 | + | |
| 33 | + @Schema(description = "账号") | |
| 34 | + private String accountNo; | |
| 35 | + | |
| 36 | + @Schema(description = "银行名称", example = "1") | |
| 37 | + private String bankName; | |
| 38 | + | |
| 39 | + @Schema(description = "状态", example = "1") | |
| 40 | + @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") | |
| 41 | + private Integer status; | |
| 42 | + | |
| 43 | + @Schema(description = "创建时间") | |
| 44 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 45 | + private LocalDateTime[] createTime; | |
| 46 | + | |
| 47 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.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 BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") | |
| 17 | + private Integer id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | + @Schema(description = "用户昵称") | |
| 23 | + private String userNickname; | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/withdraw/BrokerageWithdrawConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.convert.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawAuditReqVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 8 | +import org.mapstruct.Mapper; | |
| 9 | +import org.mapstruct.factory.Mappers; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | +import java.util.Optional; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 佣金提现 Convert | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@Mapper | |
| 21 | +public interface BrokerageWithdrawConvert { | |
| 22 | + | |
| 23 | + BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); | |
| 24 | + | |
| 25 | + BrokerageWithdrawDO convert(BrokerageWithdrawAuditReqVO bean); | |
| 26 | + | |
| 27 | + BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); | |
| 28 | + | |
| 29 | + List<BrokerageWithdrawRespVO> convertList(List<BrokerageWithdrawDO> list); | |
| 30 | + | |
| 31 | + PageResult<BrokerageWithdrawRespVO> convertPage(PageResult<BrokerageWithdrawDO> page); | |
| 32 | + | |
| 33 | + default PageResult<BrokerageWithdrawRespVO> convertPage(PageResult<BrokerageWithdrawDO> pageResult, Map<Long, MemberUserRespDTO> userMap) { | |
| 34 | + PageResult<BrokerageWithdrawRespVO> result = convertPage(pageResult); | |
| 35 | + for (BrokerageWithdrawRespVO vo : result.getList()) { | |
| 36 | + vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse("")); | |
| 37 | + } | |
| 38 | + return result; | |
| 39 | + } | |
| 40 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/withdraw/BrokerageWithdrawDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 佣金提现 DO | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("trade_brokerage_withdraw") | |
| 19 | +@KeySequence("trade_brokerage_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class BrokerageWithdrawDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Integer id; | |
| 33 | + /** | |
| 34 | + * 用户编号 | |
| 35 | + */ | |
| 36 | + private Long userId; | |
| 37 | + /** | |
| 38 | + * 提现金额 | |
| 39 | + */ | |
| 40 | + private Integer price; | |
| 41 | + /** | |
| 42 | + * 提现手续费 | |
| 43 | + */ | |
| 44 | + private Integer feePrice; | |
| 45 | + /** | |
| 46 | + * 当前总佣金 | |
| 47 | + */ | |
| 48 | + private Integer totalPrice; | |
| 49 | + /** | |
| 50 | + * 提现类型 | |
| 51 | + * <p> | |
| 52 | + * 枚举 {@link BrokerageWithdrawTypeEnum} | |
| 53 | + */ | |
| 54 | + private Integer type; | |
| 55 | + /** | |
| 56 | + * 真实姓名 | |
| 57 | + */ | |
| 58 | + private String name; | |
| 59 | + /** | |
| 60 | + * 账号 | |
| 61 | + */ | |
| 62 | + private String accountNo; | |
| 63 | + /** | |
| 64 | + * 银行名称 | |
| 65 | + */ | |
| 66 | + private String bankName; | |
| 67 | + /** | |
| 68 | + * 开户地址 | |
| 69 | + */ | |
| 70 | + private String bankAddress; | |
| 71 | + /** | |
| 72 | + * 收款码 | |
| 73 | + */ | |
| 74 | + private String accountQrCodeUrl; | |
| 75 | + /** | |
| 76 | + * 状态 | |
| 77 | + * <p> | |
| 78 | + * 枚举 {@link BrokerageWithdrawStatusEnum} | |
| 79 | + */ | |
| 80 | + private Integer status; | |
| 81 | + /** | |
| 82 | + * 审核驳回原因 | |
| 83 | + */ | |
| 84 | + private String auditReason; | |
| 85 | + /** | |
| 86 | + * 审核时间 | |
| 87 | + */ | |
| 88 | + private LocalDateTime auditTime; | |
| 89 | + /** | |
| 90 | + * 备注 | |
| 91 | + */ | |
| 92 | + private String remark; | |
| 93 | + | |
| 94 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/withdraw/BrokerageWithdrawMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw; | |
| 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.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 8 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 佣金提现 Mapper | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO> { | |
| 18 | + | |
| 19 | + default PageResult<BrokerageWithdrawDO> selectPage(BrokerageWithdrawPageReqVO reqVO) { | |
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageWithdrawDO>() | |
| 21 | + .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) | |
| 22 | + .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) | |
| 23 | + .likeIfPresent(BrokerageWithdrawDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(BrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo()) | |
| 25 | + .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) | |
| 26 | + .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) | |
| 27 | + .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) | |
| 28 | + .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId)); | |
| 29 | + } | |
| 30 | + | |
| 31 | + default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) { | |
| 32 | + return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>() | |
| 33 | + .eq(BrokerageWithdrawDO::getId, id) | |
| 34 | + .eq(BrokerageWithdrawDO::getStatus, status)); | |
| 35 | + } | |
| 36 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/withdraw/BrokerageWithdrawService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 7 | + | |
| 8 | +import java.util.Collection; | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 佣金提现 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +public interface BrokerageWithdrawService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 审核佣金提现 | |
| 20 | + * | |
| 21 | + * @param id 佣金编号 | |
| 22 | + * @param status 审核状态 | |
| 23 | + * @param auditReason 驳回原因 | |
| 24 | + */ | |
| 25 | + | |
| 26 | + void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 获得佣金提现 | |
| 30 | + * | |
| 31 | + * @param id 编号 | |
| 32 | + * @return 佣金提现 | |
| 33 | + */ | |
| 34 | + BrokerageWithdrawDO getBrokerageWithdraw(Integer id); | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 获得佣金提现列表 | |
| 38 | + * | |
| 39 | + * @param ids 编号 | |
| 40 | + * @return 佣金提现列表 | |
| 41 | + */ | |
| 42 | + List<BrokerageWithdrawDO> getBrokerageWithdrawList(Collection<Integer> ids); | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 获得佣金提现分页 | |
| 46 | + * | |
| 47 | + * @param pageReqVO 分页查询 | |
| 48 | + * @return 佣金提现分页 | |
| 49 | + */ | |
| 50 | + PageResult<BrokerageWithdrawDO> getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO); | |
| 51 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/withdraw/BrokerageWithdrawServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.collection.ListUtil; | |
| 5 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 6 | +import cn.hutool.core.map.MapUtil; | |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | +import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; | |
| 9 | +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; | |
| 10 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 11 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 12 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw.BrokerageWithdrawMapper; | |
| 13 | +import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; | |
| 14 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 15 | +import cn.iocoder.yudao.module.trade.service.brokerage.record.BrokerageRecordService; | |
| 16 | +import org.springframework.stereotype.Service; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import org.springframework.validation.annotation.Validated; | |
| 19 | + | |
| 20 | +import javax.annotation.Resource; | |
| 21 | +import java.time.LocalDateTime; | |
| 22 | +import java.util.Collection; | |
| 23 | +import java.util.List; | |
| 24 | +import java.util.Map; | |
| 25 | + | |
| 26 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 27 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_NOT_EXISTS; | |
| 28 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * 佣金提现 Service 实现类 | |
| 32 | + * | |
| 33 | + * @author 芋道源码 | |
| 34 | + */ | |
| 35 | +@Service | |
| 36 | +@Validated | |
| 37 | +public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { | |
| 38 | + | |
| 39 | + @Resource | |
| 40 | + private BrokerageWithdrawMapper brokerageWithdrawMapper; | |
| 41 | + | |
| 42 | + @Resource | |
| 43 | + private BrokerageRecordService brokerageRecordService; | |
| 44 | + | |
| 45 | + @Resource | |
| 46 | + private NotifyMessageSendApi notifyMessageSendApi; | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + @Transactional(rollbackFor = Exception.class) | |
| 50 | + public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { | |
| 51 | + | |
| 52 | + // 校验存在 | |
| 53 | + BrokerageWithdrawDO withdrawDO = validateBrokerageWithdrawExists(id); | |
| 54 | + // 校验状态为审核中 | |
| 55 | + if (!BrokerageWithdrawStatusEnum.AUDITING.getStatus().equals(withdrawDO.getStatus())) { | |
| 56 | + throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); | |
| 57 | + } | |
| 58 | + | |
| 59 | + // 更新 | |
| 60 | + BrokerageWithdrawDO updateObj = new BrokerageWithdrawDO() | |
| 61 | + .setStatus(status.getStatus()) | |
| 62 | + .setAuditReason(auditReason) | |
| 63 | + .setAuditTime(LocalDateTime.now()); | |
| 64 | + int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), updateObj); | |
| 65 | + if (rows == 0) { | |
| 66 | + throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); | |
| 67 | + } | |
| 68 | + | |
| 69 | + // 驳回时需要退还用户佣金 | |
| 70 | + String templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; | |
| 71 | + if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { | |
| 72 | + templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; | |
| 73 | + | |
| 74 | + // todo @owen | |
| 75 | +// brokerageRecordService.addBrokerage(withdrawDO.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW, withdrawDO.getPrice(), ""); | |
| 76 | + } | |
| 77 | + | |
| 78 | + // 通知用户 | |
| 79 | + Map<String, Object> templateParams = MapUtil.<String, Object>builder() | |
| 80 | + .put("createTime", LocalDateTimeUtil.formatNormal(withdrawDO.getCreateTime())) | |
| 81 | + .put("price", String.format("%.2f", withdrawDO.getPrice() / 100d)) | |
| 82 | + .put("reason", withdrawDO.getAuditReason()) | |
| 83 | + .build(); | |
| 84 | + NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO() | |
| 85 | + .setUserId(withdrawDO.getUserId()) | |
| 86 | + .setTemplateCode(templateCode).setTemplateParams(templateParams); | |
| 87 | + notifyMessageSendApi.sendSingleMessageToMember(reqDTO); | |
| 88 | + } | |
| 89 | + | |
| 90 | + private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { | |
| 91 | + BrokerageWithdrawDO withdrawDO = brokerageWithdrawMapper.selectById(id); | |
| 92 | + if (withdrawDO == null) { | |
| 93 | + throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); | |
| 94 | + } | |
| 95 | + return withdrawDO; | |
| 96 | + } | |
| 97 | + | |
| 98 | + @Override | |
| 99 | + public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { | |
| 100 | + return brokerageWithdrawMapper.selectById(id); | |
| 101 | + } | |
| 102 | + | |
| 103 | + @Override | |
| 104 | + public List<BrokerageWithdrawDO> getBrokerageWithdrawList(Collection<Integer> ids) { | |
| 105 | + if (CollUtil.isEmpty(ids)) { | |
| 106 | + return ListUtil.empty(); | |
| 107 | + } | |
| 108 | + return brokerageWithdrawMapper.selectBatchIds(ids); | |
| 109 | + } | |
| 110 | + | |
| 111 | + @Override | |
| 112 | + public PageResult<BrokerageWithdrawDO> getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO) { | |
| 113 | + return brokerageWithdrawMapper.selectPage(pageReqVO); | |
| 114 | + } | |
| 115 | + | |
| 116 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/withdraw/BrokerageWithdrawServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.withdraw; | |
| 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.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw.BrokerageWithdrawMapper; | |
| 8 | +import cn.iocoder.yudao.module.trade.service.brokerage.withdraw.BrokerageWithdrawServiceImpl; | |
| 9 | +import org.junit.jupiter.api.Disabled; | |
| 10 | +import org.junit.jupiter.api.Test; | |
| 11 | +import org.springframework.context.annotation.Import; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 19 | +import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * {@link BrokerageWithdrawServiceImpl} 的单元测试类 | |
| 23 | + * | |
| 24 | + * @author 芋道源码 | |
| 25 | + */ | |
| 26 | +@Import(BrokerageWithdrawServiceImpl.class) | |
| 27 | +public class BrokerageWithdrawServiceImplTest extends BaseDbUnitTest { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private BrokerageWithdrawServiceImpl brokerageWithdrawService; | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + private BrokerageWithdrawMapper brokerageWithdrawMapper; | |
| 34 | + | |
| 35 | + @Test | |
| 36 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 37 | + public void testGetBrokerageWithdrawPage() { | |
| 38 | + // mock 数据 | |
| 39 | + BrokerageWithdrawDO dbBrokerageWithdraw = randomPojo(BrokerageWithdrawDO.class, o -> { // 等会查询到 | |
| 40 | + o.setUserId(null); | |
| 41 | + o.setType(null); | |
| 42 | + o.setName(null); | |
| 43 | + o.setAccountNo(null); | |
| 44 | + o.setBankName(null); | |
| 45 | + o.setStatus(null); | |
| 46 | + o.setCreateTime(null); | |
| 47 | + }); | |
| 48 | + brokerageWithdrawMapper.insert(dbBrokerageWithdraw); | |
| 49 | + // 测试 userId 不匹配 | |
| 50 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setUserId(null))); | |
| 51 | + // 测试 type 不匹配 | |
| 52 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setType(null))); | |
| 53 | + // 测试 name 不匹配 | |
| 54 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setName(null))); | |
| 55 | + // 测试 accountNo 不匹配 | |
| 56 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAccountNo(null))); | |
| 57 | + // 测试 bankName 不匹配 | |
| 58 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setBankName(null))); | |
| 59 | + // 测试 status 不匹配 | |
| 60 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setStatus(null))); | |
| 61 | + // 测试 auditReason 不匹配 | |
| 62 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditReason(null))); | |
| 63 | + // 测试 auditTime 不匹配 | |
| 64 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditTime(null))); | |
| 65 | + // 测试 remark 不匹配 | |
| 66 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setRemark(null))); | |
| 67 | + // 测试 createTime 不匹配 | |
| 68 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setCreateTime(null))); | |
| 69 | + // 准备参数 | |
| 70 | + BrokerageWithdrawPageReqVO reqVO = new BrokerageWithdrawPageReqVO(); | |
| 71 | + reqVO.setUserId(null); | |
| 72 | + reqVO.setType(null); | |
| 73 | + reqVO.setName(null); | |
| 74 | + reqVO.setAccountNo(null); | |
| 75 | + reqVO.setBankName(null); | |
| 76 | + reqVO.setStatus(null); | |
| 77 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 78 | + | |
| 79 | + // 调用 | |
| 80 | + PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(reqVO); | |
| 81 | + // 断言 | |
| 82 | + assertEquals(1, pageResult.getTotal()); | |
| 83 | + assertEquals(1, pageResult.getList().size()); | |
| 84 | + assertPojoEquals(dbBrokerageWithdraw, pageResult.getList().get(0)); | |
| 85 | + } | |
| 86 | + | |
| 87 | +} | ... | ... |