feat:【MALL 商城】商城分佣提现,初步对接成功微信支付

This commit is contained in:
YunaiV 2025-05-11 08:12:42 +08:00
parent b91a30dd3e
commit 4d25e810e3
22 changed files with 162 additions and 225 deletions

View File

@ -7,6 +7,9 @@ package cn.iocoder.yudao.module.trade.enums;
*/ */
public interface DictTypeConstants { public interface DictTypeConstants {
String BROKERAGE_RECORD_STATUS = "brokerage_record_status"; // 佣金记录状态
String BROKERAGE_WITHDRAW_TYPE = "brokerage_withdraw_type"; // 佣金提现类型
String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态
} }

View File

@ -6,7 +6,6 @@ import lombok.Getter;
import java.util.Arrays; import java.util.Arrays;
// TODO 芋艿提现的打通在纠结下
/** /**
* 佣金提现状态枚举 * 佣金提现状态枚举
* *

View File

@ -3,11 +3,13 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import cn.iocoder.yudao.module.trade.enums.DictTypeConstants;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -36,8 +38,9 @@ public class AppBrokerageRecordController {
@Operation(summary = "获得分销记录分页") @Operation(summary = "获得分销记录分页")
public CommonResult<PageResult<AppBrokerageRecordRespVO>> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) { public CommonResult<PageResult<AppBrokerageRecordRespVO>> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) {
PageResult<BrokerageRecordDO> pageResult = brokerageRecordService.getBrokerageRecordPage( PageResult<BrokerageRecordDO> pageResult = brokerageRecordService.getBrokerageRecordPage(
BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); BeanUtils.toBean(pageReqVO, BrokerageRecordPageReqVO.class).setUserId(getLoginUserId()));
return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class)); return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class, recordVO ->
recordVO.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_RECORD_STATUS, recordVO.getStatus()))));
} }
@GetMapping("/get-product-brokerage-price") @GetMapping("/get-product-brokerage-price")

View File

@ -1,14 +1,23 @@
package cn.iocoder.yudao.module.trade.controller.app.brokerage; package cn.iocoder.yudao.module.trade.controller.app.brokerage;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
import cn.iocoder.yudao.module.trade.enums.DictTypeConstants;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@ -16,6 +25,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Objects;
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.web.core.util.WebFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
@ -29,12 +40,39 @@ public class AppBrokerageWithdrawController {
@Resource @Resource
private BrokerageWithdrawService brokerageWithdrawService; private BrokerageWithdrawService brokerageWithdrawService;
@Resource
private PayTransferApi payTransferApi;
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得分销提现分页") @Operation(summary = "获得分销提现分页")
public CommonResult<PageResult<AppBrokerageWithdrawRespVO>> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) { public CommonResult<PageResult<AppBrokerageWithdrawRespVO>> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) {
PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); BeanUtils.toBean(pageReqVO, BrokerageWithdrawPageReqVO.class).setUserId(getLoginUserId()));
return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); return success(BeanUtils.toBean(pageResult, AppBrokerageWithdrawRespVO.class, withdrawVO ->
withdrawVO.setTypeName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_TYPE, withdrawVO.getType()))
.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, withdrawVO.getStatus()))));
}
@GetMapping("/get")
@Operation(summary = "获得佣金提现")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<AppBrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Long id) {
BrokerageWithdrawDO withdraw = brokerageWithdrawService.getBrokerageWithdraw(id);
if (withdraw == null || ObjUtil.notEqual(withdraw.getUserId(), getLoginUserId())) {
return success(null);
}
// 审核中转账中并且是微信转账需要返回 mchId 用于确认收款
AppBrokerageWithdrawRespVO withdrawVO = BeanUtils.toBean(withdraw, AppBrokerageWithdrawRespVO.class);
if (Objects.equals(withdraw.getStatus(), BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus())
&& Objects.equals(withdraw.getType(), BrokerageWithdrawTypeEnum.WECHAT_API.getType())
&& withdraw.getPayTransferId() != null) {
PayTransferRespDTO transfer = payTransferApi.getTransfer(withdraw.getPayTransferId());
if (transfer != null) {
withdrawVO.setTransferChannelPackageInfo(transfer.getChannelPackageInfo())
.setTransferChannelMchId(transfer.getChannelMchId());
}
}
return success(withdrawVO);
} }
@PostMapping("/create") @PostMapping("/create")

View File

@ -20,11 +20,11 @@ public class AppBrokerageRecordPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "业务类型", example = "1")
@InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}") @InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}")
private Integer bizType; private Integer bizType;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态", example = "1")
@InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}") @InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}")
private Integer status; private Integer status;

View File

@ -24,6 +24,9 @@ public class AppBrokerageRecordRespVO {
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status; private Integer status;
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "待结算")
private String statusName;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime; private LocalDateTime createTime;

View File

@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.URL; import org.hibernate.validator.constraints.URL;
@ -22,6 +24,7 @@ public class AppBrokerageWithdrawCreateReqVO {
@Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
@PositiveOrZero(message = "提现金额不能小于 0") @PositiveOrZero(message = "提现金额不能小于 0")
@Min(value = 30, message = "微信提现金额不能小于 0.3", groups = {WechatApi.class})
@NotNull(message = "提现金额不能为空") @NotNull(message = "提现金额不能为空")
private Integer price; private Integer price;
@ -43,6 +46,11 @@ public class AppBrokerageWithdrawCreateReqVO {
@Schema(description = "开户地址", example = "海淀支行") @Schema(description = "开户地址", example = "海淀支行")
private String bankAddress; private String bankAddress;
@Schema(description = "转账渠道", example = "wx_lite")
@NotNull(message = "转账渠道不能为空", groups = {WechatApi.class})
@InEnum(PayChannelEnum.class)
private String transferChannelCode;
public interface Wallet { public interface Wallet {
} }

View File

@ -1,22 +1,22 @@
package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "应用 App - 分销提现分页 Request VO") @Schema(description = "应用 App - 分销提现分页 Request VO")
@Data @Data
public class AppBrokerageWithdrawPageReqVO extends PageParam { public class AppBrokerageWithdrawPageReqVO extends PageParam {
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "创建时间")
@InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Integer type; private LocalDateTime[] createTime;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}")
private Integer status;
} }

View File

@ -12,6 +12,12 @@ public class AppBrokerageWithdrawRespVO {
@Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") @Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Long id; private Long id;
@Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer type;
@Schema(description = "提现类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "微信")
private String typeName;
@Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") @Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer status; private Integer status;
@ -24,4 +30,15 @@ public class AppBrokerageWithdrawRespVO {
@Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime; private LocalDateTime createTime;
// ========== 微信转账专属 ==========
@Schema(description = "转账单编号", example = "1024")
private Long payTransferId;
@Schema(description = "渠道 package 信息")
private String transferChannelPackageInfo;
@Schema(description = "渠道商户号")
private String transferChannelMchId;
} }

View File

@ -1,15 +1,11 @@
package cn.iocoder.yudao.module.trade.convert.brokerage; package cn.iocoder.yudao.module.trade.convert.brokerage;
import cn.hutool.core.math.Money;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
@ -68,8 +64,6 @@ public interface BrokerageRecordConvert {
return result; return result;
} }
BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId);
default PageResult<AppBrokerageUserRankByPriceRespVO> convertPage03(PageResult<AppBrokerageUserRankByPriceRespVO> pageResult, Map<Long, MemberUserRespDTO> userMap) { default PageResult<AppBrokerageUserRankByPriceRespVO> convertPage03(PageResult<AppBrokerageUserRankByPriceRespVO> pageResult, Map<Long, MemberUserRespDTO> userMap) {
for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) { for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) {
copyTo(userMap.get(vo.getId()), vo); copyTo(userMap.get(vo.getId()), vo);

View File

@ -1,15 +1,9 @@
package cn.iocoder.yudao.module.trade.convert.brokerage; package cn.iocoder.yudao.module.trade.convert.brokerage;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
import cn.iocoder.yudao.module.trade.enums.DictTypeConstants;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -27,8 +21,6 @@ public interface BrokerageWithdrawConvert {
BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class);
BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice);
BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean);
List<BrokerageWithdrawRespVO> convertList(List<BrokerageWithdrawDO> list); List<BrokerageWithdrawRespVO> convertList(List<BrokerageWithdrawDO> list);
@ -43,15 +35,4 @@ public interface BrokerageWithdrawConvert {
return result; return result;
} }
PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult);
default PageResult<AppBrokerageWithdrawRespVO> convertPage03(PageResult<BrokerageWithdrawDO> pageResult) {
PageResult<AppBrokerageWithdrawRespVO> result = convertPage02(pageResult);
for (AppBrokerageWithdrawRespVO vo : result.getList()) {
vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus()));
}
return result;
}
BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId);
} }

View File

@ -126,12 +126,5 @@ public class BrokerageWithdrawDO extends BaseDO {
* 转账错误提示 * 转账错误提示
*/ */
private String transferErrorMsg; private String transferErrorMsg;
/**
* 渠道 package 信息
*
* 特殊目前只有微信转账有这个东西
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
*/
private String transferChannelPackageInfo;
} }

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi; import cn.iocoder.yudao.module.pay.api.transfer.PayTransferApi;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
@ -18,7 +19,6 @@ import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper;
@ -157,8 +157,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
// 2. 更新提现记录 // 2. 更新提现记录
brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId()) brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId())
.setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode) .setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode));
.setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo()));
} }
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) { private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) {
@ -190,7 +189,8 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
// 2.1 计算手续费 // 2.1 计算手续费
Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent());
// 2.2 创建佣金提现记录 // 2.2 创建佣金提现记录
BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); BrokerageWithdrawDO withdraw = BeanUtils.toBean(createReqVO, BrokerageWithdrawDO.class)
.setUserId(userId).setFeePrice(feePrice);
brokerageWithdrawMapper.insert(withdraw); brokerageWithdrawMapper.insert(withdraw);
// 3. 创建用户佣金记录 // 3. 创建用户佣金记录

View File

@ -70,5 +70,12 @@ public class PayTransferRespDTO {
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a> * @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
*/ */
private String channelPackageInfo; private String channelPackageInfo;
/**
* 渠道商户号
*
* 特殊目前只有微信转账有这个东西
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
*/
private String channelMchId;
} }

View File

@ -1,10 +1,13 @@
package cn.iocoder.yudao.module.pay.api.transfer; package cn.iocoder.yudao.module.pay.api.transfer;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO; import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
import cn.iocoder.yudao.module.pay.service.channel.PayChannelService;
import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -21,6 +24,8 @@ public class PayTransferApiImpl implements PayTransferApi {
@Resource @Resource
private PayTransferService payTransferService; private PayTransferService payTransferService;
@Resource
private PayChannelService payChannelService;
@Override @Override
public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) { public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) {
@ -30,7 +35,15 @@ public class PayTransferApiImpl implements PayTransferApi {
@Override @Override
public PayTransferRespDTO getTransfer(Long id) { public PayTransferRespDTO getTransfer(Long id) {
PayTransferDO transfer = payTransferService.getTransfer(id); PayTransferDO transfer = payTransferService.getTransfer(id);
return BeanUtils.toBean(transfer, PayTransferRespDTO.class); if (transfer == null) {
return null;
}
PayChannelDO channel = payChannelService.getChannel(transfer.getChannelId());
String mchId = null;
if (channel != null && channel.getConfig() instanceof WxPayClientConfig) {
mchId = ((WxPayClientConfig) channel.getConfig()).getMchId();
}
return BeanUtils.toBean(transfer, PayTransferRespDTO.class).setChannelMchId(mchId);
} }
} }

View File

@ -80,12 +80,5 @@ public class PayDemoWithdrawDO extends BaseDO {
* 转账错误提示 * 转账错误提示
*/ */
private String transferErrorMsg; private String transferErrorMsg;
/**
* 渠道 package 信息
*
* 特殊目前只有微信转账有这个东西
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
*/
private String transferChannelPackageInfo;
} }

View File

@ -88,8 +88,7 @@ public class PayDemoTransferServiceImpl implements PayDemoWithdrawService {
// 2.2 更新转账单到 demo 示例提现单并将状态更新为转账中 // 2.2 更新转账单到 demo 示例提现单并将状态更新为转账中
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(), demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()) new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId()));
.setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo()));
return transferRespDTO.getId(); return transferRespDTO.getId();
} }

View File

@ -174,7 +174,7 @@ public class PayTransferServiceImpl implements PayTransferService {
int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(),
PayTransferStatusEnum.WAITING.getStatus(), PayTransferStatusEnum.WAITING.getStatus(),
new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus()) new PayTransferDO().setStatus(PayTransferStatusEnum.PROCESSING.getStatus())
.setChannelPackageInfo(transfer.getChannelPackageInfo())); .setChannelPackageInfo(notify.getChannelPackageInfo()));
if (updateCounts == 0) { if (updateCounts == 0) {
throw exception(PAY_TRANSFER_NOTIFY_FAIL_STATUS_IS_NOT_WAITING); throw exception(PAY_TRANSFER_NOTIFY_FAIL_STATUS_IS_NOT_WAITING);
} }

View File

@ -14,7 +14,7 @@ import java.util.Map;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
public interface PayClient { public interface PayClient<Config> {
/** /**
* 获得渠道编号 * 获得渠道编号
@ -23,6 +23,13 @@ public interface PayClient {
*/ */
Long getId(); Long getId();
/**
* 获得渠道配置
*
* @return 渠道配置
*/
Config getConfig();
// ============ 支付相关 ========== // ============ 支付相关 ==========
/** /**

View File

@ -1,129 +0,0 @@
package cn.iocoder.yudao.framework.pay.core.client.dto.transfer;
import com.github.binarywang.wxpay.bean.notify.OriginNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayBaseNotifyV3Result;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
// TODO @luchi这个可以复用 wxjava 里的类么
@NoArgsConstructor
public class WxPayTransferPartnerNotifyV3Result implements Serializable, WxPayBaseNotifyV3Result<WxPayTransferPartnerNotifyV3Result.TransferNotifyResult> {
private static final long serialVersionUID = -1L;
/**
* 源数据
*/
private OriginNotifyResponse rawData;
/**
* 解密后的数据
*/
private TransferNotifyResult result;
@Override
public void setRawData(OriginNotifyResponse rawData) {
this.rawData = rawData;
}
@Override
public void setResult(TransferNotifyResult data) {
this.result = data;
}
public TransferNotifyResult getResult() {
return result;
}
public OriginNotifyResponse getRawData() {
return rawData;
}
@Data
@NoArgsConstructor
public static class TransferNotifyResult implements Serializable {
private static final long serialVersionUID = 1L;
/*********************** 公共字段 ********************
/**
* 商家批次单号
*/
@SerializedName(value = "out_batch_no")
protected String outBatchNo;
/**
* 微信批次单号
*/
@SerializedName(value = "batch_id")
protected String batchId;
/**
* 批次状态
*/
@SerializedName(value = "batch_status")
protected String batchStatus;
/**
* 批次总笔数
*/
@SerializedName(value = "total_num")
protected Integer totalNum;
/**
* 批次总金额
*/
@SerializedName(value = "total_amount")
protected Integer totalAmount;
/**
* 批次更新时间
*/
@SerializedName(value = "update_time")
private String updateTime;
/*********************** FINISHED ********************
/**
* 转账成功金额
*/
@SerializedName(value = "success_amount")
protected Integer successAmount;
/**
* 转账成功笔数
*/
@SerializedName(value = "success_num")
protected Integer successNum;
/**
* 转账失败金额
*/
@SerializedName(value = "fail_amount")
protected Integer failAmount;
/**
* 转账失败笔数
*/
@SerializedName(value = "fail_num")
protected Integer failNum;
/*********************** CLOSED ********************
/**
* 商户号
*/
@SerializedName(value = "mchid")
protected String mchId;
/**
* 批次关闭原因
*/
@SerializedName(value = "close_reason")
protected String closeReason;
}
}

View File

@ -23,7 +23,7 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString
* @author 芋道源码 * @author 芋道源码
*/ */
@Slf4j @Slf4j
public abstract class AbstractPayClient<Config extends PayClientConfig> implements PayClient { public abstract class AbstractPayClient<Config extends PayClientConfig> implements PayClient<Config> {
/** /**
* 渠道编号 * 渠道编号
@ -74,6 +74,11 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen
return channelId; return channelId;
} }
@Override
public Config getConfig() {
return config;
}
// ============ 支付相关 ========== // ============ 支付相关 ==========
@Override @Override

View File

@ -15,13 +15,13 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.WxPayTransferPartnerNotifyV3Result;
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
import com.github.binarywang.wxpay.bean.notify.*; import com.github.binarywang.wxpay.bean.notify.*;
import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsGetResult; import com.github.binarywang.wxpay.bean.transfer.TransferBillsGetResult;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsNotifyResult;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsRequest; import com.github.binarywang.wxpay.bean.transfer.TransferBillsRequest;
import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult; import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.config.WxPayConfig;
@ -354,34 +354,6 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response);
} }
@Override
public PayTransferRespDTO doParseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) throws WxPayException {
switch (config.getApiVersion()) {
case API_VERSION_V3:
return parseTransferNotifyV3(body, headers);
case API_VERSION_V2:
throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本");
default:
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
}
}
private PayTransferRespDTO parseTransferNotifyV3(String body, Map<String, String> headers) throws WxPayException {
// 1. 解析回调
SignatureHeader signatureHeader = getRequestHeader(headers);
// TODO @luchi这个可以复用 wxjava 里的类么
WxPayTransferPartnerNotifyV3Result response = client.baseParseOrderNotifyV3Result(body, signatureHeader, WxPayTransferPartnerNotifyV3Result.class, WxPayTransferPartnerNotifyV3Result.TransferNotifyResult.class);
WxPayTransferPartnerNotifyV3Result.TransferNotifyResult result = response.getResult();
// 2. 构建结果
if (Objects.equals("FINISHED", result.getBatchStatus())) {
if (result.getFailNum() <= 0) {
return PayTransferRespDTO.successOf(result.getBatchId(), parseDateV3(result.getUpdateTime()),
result.getOutBatchNo(), response);
}
}
return PayTransferRespDTO.closedOf(result.getBatchStatus(), result.getCloseReason(), result.getOutBatchNo(), response);
}
@Override @Override
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException {
try { try {
@ -522,6 +494,37 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
response.getOutBillNo(), response); response.getOutBillNo(), response);
} }
@Override
public PayTransferRespDTO doParseTransferNotify(Map<String, String> params, String body, Map<String, String> headers) throws WxPayException {
switch (config.getApiVersion()) {
case API_VERSION_V3:
return parseTransferNotifyV3(body, headers);
case API_VERSION_V2:
throw new UnsupportedOperationException("V2 版本暂不支持,建议使用 V3 版本");
default:
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
}
}
private PayTransferRespDTO parseTransferNotifyV3(String body, Map<String, String> headers) throws WxPayException {
// 1. 解析回调
SignatureHeader signatureHeader = getRequestHeader(headers);
TransferBillsNotifyResult response = client.getTransferService().parseTransferBillsNotifyResult(body, signatureHeader);
TransferBillsNotifyResult.DecryptNotifyResult result = response.getResult();
// 2. 创建返回结果
String state = result.getState();
if (ObjectUtils.equalsAny(state, "ACCEPTED", "PROCESSING", "WAIT_USER_CONFIRM", "TRANSFERING")) {
return PayTransferRespDTO.processingOf(result.getTransferBillNo(), result.getOutBillNo(), response);
}
if (Objects.equals("SUCCESS", state)) {
return PayTransferRespDTO.successOf(result.getTransferBillNo(), parseDateV3(result.getUpdateTime()),
result.getOutBillNo(), response);
}
return PayTransferRespDTO.closedOf(state, result.getFailReason(),
result.getOutBillNo(), response);
}
// ========== 各种工具方法 ========== // ========== 各种工具方法 ==========
/** /**