feat:【PAY 支付】增加 channelPackageInfo 字段,对接微信新的转账 API(太难了!!!!!!!!!!!!!!!!!!!!)
This commit is contained in:
parent
0e7ce63719
commit
b91a30dd3e
|
@ -75,7 +75,7 @@
|
||||||
<justauth.version>1.16.7</justauth.version>
|
<justauth.version>1.16.7</justauth.version>
|
||||||
<justauth-starter.version>1.4.0</justauth-starter.version>
|
<justauth-starter.version>1.4.0</justauth-starter.version>
|
||||||
<jimureport.version>1.9.4</jimureport.version>
|
<jimureport.version>1.9.4</jimureport.version>
|
||||||
<weixin-java.version>4.7.4.B</weixin-java.version>
|
<weixin-java.version>4.7.5.B</weixin-java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用
|
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BrokerageWithdrawBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436")
|
|
||||||
@NotNull(message = "用户编号不能为空")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
@Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781")
|
|
||||||
@NotNull(message = "提现金额不能为空")
|
|
||||||
private Integer price;
|
|
||||||
|
|
||||||
@Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417")
|
|
||||||
@NotNull(message = "提现手续费不能为空")
|
|
||||||
private Integer feePrice;
|
|
||||||
|
|
||||||
@Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576")
|
|
||||||
@NotNull(message = "当前总佣金不能为空")
|
|
||||||
private Integer totalPrice;
|
|
||||||
|
|
||||||
@Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
@NotNull(message = "提现类型不能为空")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@Schema(description = "真实姓名", example = "赵六")
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
@Schema(description = "收款账号", example = "88677912132")
|
|
||||||
private String userAccount;
|
|
||||||
|
|
||||||
@Schema(description = "银行名称", example = "1")
|
|
||||||
private String bankName;
|
|
||||||
|
|
||||||
@Schema(description = "开户地址", example = "海淀支行")
|
|
||||||
private String bankAddress;
|
|
||||||
|
|
||||||
@Schema(description = "收款码", example = "https://www.iocoder.cn")
|
|
||||||
private String qrCodeUrl;
|
|
||||||
|
|
||||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
@NotNull(message = "状态不能为空")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
@Schema(description = "审核驳回原因", example = "不对")
|
|
||||||
private String auditReason;
|
|
||||||
|
|
||||||
@Schema(description = "审核时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime auditTime;
|
|
||||||
|
|
||||||
@Schema(description = "备注", example = "随便")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,27 +2,68 @@ package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 佣金提现 Response VO")
|
@Schema(description = "管理后台 - 佣金提现 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class BrokerageWithdrawRespVO {
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
private String userNickname;
|
||||||
|
|
||||||
|
@Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781")
|
||||||
|
private Integer price;
|
||||||
|
|
||||||
|
@Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417")
|
||||||
|
private Integer feePrice;
|
||||||
|
|
||||||
|
@Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576")
|
||||||
|
private Integer totalPrice;
|
||||||
|
|
||||||
|
@Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@Schema(description = "真实姓名", example = "赵六")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "收款账号", example = "88677912132")
|
||||||
|
private String userAccount;
|
||||||
|
|
||||||
|
@Schema(description = "银行名称", example = "1")
|
||||||
|
private String bankName;
|
||||||
|
|
||||||
|
@Schema(description = "开户地址", example = "海淀支行")
|
||||||
|
private String bankAddress;
|
||||||
|
|
||||||
|
@Schema(description = "收款码", example = "https://www.iocoder.cn")
|
||||||
|
private String qrCodeUrl;
|
||||||
|
|
||||||
|
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "审核驳回原因", example = "不对")
|
||||||
|
private String auditReason;
|
||||||
|
|
||||||
|
@Schema(description = "审核时间")
|
||||||
|
private LocalDateTime auditTime;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "转账单编号", example = "1024")
|
||||||
|
private Long payTransferId;
|
||||||
|
|
||||||
@Schema(description = "转账错误提示", example = "余额不足")
|
@Schema(description = "转账错误提示", example = "余额不足")
|
||||||
private String transferErrorMsg;
|
private String transferErrorMsg;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
|
||||||
private String userNickname;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,5 +126,12 @@ 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
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;
|
||||||
|
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.api.wallet.PayWalletApi;
|
import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi;
|
||||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO;
|
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletRespDTO;
|
||||||
|
@ -152,11 +153,12 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
||||||
.setUserAccount(userAccount).setUserName(userName).setUserIp(getClientIP())
|
.setUserAccount(userAccount).setUserName(userName).setUserIp(getClientIP())
|
||||||
.setChannelExtras(channelExtras);
|
.setChannelExtras(channelExtras);
|
||||||
// 1.3 发起请求
|
// 1.3 发起请求
|
||||||
Long payTransferId = payTransferApi.createTransfer(transferReqDTO);
|
PayTransferCreateRespDTO transferRespDTO = payTransferApi.createTransfer(transferReqDTO);
|
||||||
|
|
||||||
// 2. 更新提现记录
|
// 2. 更新提现记录
|
||||||
brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId())
|
brokerageWithdrawMapper.updateById(new BrokerageWithdrawDO().setId(withdraw.getId())
|
||||||
.setPayTransferId(payTransferId).setTransferChannelCode(channelCode));
|
.setPayTransferId(transferRespDTO.getId()).setTransferChannelCode(channelCode)
|
||||||
|
.setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) {
|
private BrokerageWithdrawDO validateBrokerageWithdrawExists(Long id) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.pay.api.transfer;
|
package cn.iocoder.yudao.module.pay.api.transfer;
|
||||||
|
|
||||||
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.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ public interface PayTransferApi {
|
||||||
* 创建转账单
|
* 创建转账单
|
||||||
*
|
*
|
||||||
* @param reqDTO 创建请求
|
* @param reqDTO 创建请求
|
||||||
* @return 转账单编号
|
* @return 创建结果
|
||||||
*/
|
*/
|
||||||
Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO);
|
PayTransferCreateRespDTO createTransfer(@Valid PayTransferCreateReqDTO reqDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得转账单
|
* 获得转账单
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cn.iocoder.yudao.module.pay.api.transfer.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账单创建 Response DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PayTransferCreateRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
// ========== 其它字段 ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道 package 信息
|
||||||
|
*
|
||||||
|
* 特殊:目前只有微信转账有这个东西!!!
|
||||||
|
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
|
||||||
|
*/
|
||||||
|
private String channelPackageInfo;
|
||||||
|
|
||||||
|
}
|
|
@ -63,4 +63,12 @@ public class PayTransferRespDTO {
|
||||||
*/
|
*/
|
||||||
private String channelErrorMsg;
|
private String channelErrorMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道 package 信息
|
||||||
|
*
|
||||||
|
* 特殊:目前只有微信转账有这个东西!!!
|
||||||
|
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
|
||||||
|
*/
|
||||||
|
private String channelPackageInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ 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.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.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
||||||
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.transfer.PayTransferService;
|
import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService;
|
||||||
|
@ -22,7 +23,7 @@ public class PayTransferApiImpl implements PayTransferApi {
|
||||||
private PayTransferService payTransferService;
|
private PayTransferService payTransferService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTransfer(PayTransferCreateReqDTO reqDTO) {
|
public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) {
|
||||||
return payTransferService.createTransfer(reqDTO);
|
return payTransferService.createTransfer(reqDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,5 +80,12 @@ 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;
|
||||||
|
|
||||||
}
|
}
|
|
@ -135,4 +135,12 @@ public class PayTransferDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private String channelNotifyData;
|
private String channelNotifyData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道 package 信息
|
||||||
|
*
|
||||||
|
* 特殊:目前只有微信转账有这个东西!!!
|
||||||
|
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
|
||||||
|
*/
|
||||||
|
private String channelPackageInfo;
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
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;
|
||||||
|
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.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.withdraw.PayDemoWithdrawCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoWithdrawDO;
|
||||||
|
@ -83,12 +84,13 @@ public class PayDemoTransferServiceImpl implements PayDemoWithdrawService {
|
||||||
transferReqDTO.setChannelExtras(PayTransferCreateReqDTO.buildWeiXinChannelExtra1000(
|
transferReqDTO.setChannelExtras(PayTransferCreateReqDTO.buildWeiXinChannelExtra1000(
|
||||||
"测试活动", "测试奖励"));
|
"测试活动", "测试奖励"));
|
||||||
}
|
}
|
||||||
Long payTransferId = payTransferApi.createTransfer(transferReqDTO);
|
PayTransferCreateRespDTO transferRespDTO = payTransferApi.createTransfer(transferReqDTO);
|
||||||
|
|
||||||
// 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中
|
// 2.2 更新转账单到 demo 示例提现单,并将状态更新为转账中
|
||||||
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
|
demoTransferMapper.updateByIdAndStatus(withdraw.getId(), withdraw.getStatus(),
|
||||||
new PayDemoWithdrawDO().setPayTransferId(payTransferId));
|
new PayDemoWithdrawDO().setPayTransferId(transferRespDTO.getId())
|
||||||
return payTransferId;
|
.setTransferChannelPackageInfo(transferRespDTO.getChannelPackageInfo()));
|
||||||
|
return transferRespDTO.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PayDemoWithdrawDO validateDemoWithdrawCanTransfer(Long id) {
|
private PayDemoWithdrawDO validateDemoWithdrawCanTransfer(Long id) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pay.service.transfer;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
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.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.controller.admin.transfer.vo.PayTransferPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
@ -20,7 +21,7 @@ public interface PayTransferService {
|
||||||
* @param reqDTO 创建请求
|
* @param reqDTO 创建请求
|
||||||
* @return 转账单编号
|
* @return 转账单编号
|
||||||
*/
|
*/
|
||||||
Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO);
|
PayTransferCreateRespDTO createTransfer(@Valid PayTransferCreateReqDTO reqDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取转账单
|
* 获取转账单
|
||||||
|
|
|
@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifie
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
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.controller.admin.transfer.vo.PayTransferPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
|
@ -62,7 +63,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
private PayNoRedisDAO noRedisDAO;
|
private PayNoRedisDAO noRedisDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTransfer(PayTransferCreateReqDTO reqDTO) {
|
public PayTransferCreateRespDTO createTransfer(PayTransferCreateReqDTO reqDTO) {
|
||||||
// 1.1 校验 App
|
// 1.1 校验 App
|
||||||
PayAppDO payApp = appService.validPayApp(reqDTO.getAppKey());
|
PayAppDO payApp = appService.validPayApp(reqDTO.getAppKey());
|
||||||
// 1.2 校验支付渠道是否有效
|
// 1.2 校验支付渠道是否有效
|
||||||
|
@ -88,12 +89,13 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
transferMapper.updateByIdAndStatus(transfer.getId(), transfer.getStatus(),
|
transferMapper.updateByIdAndStatus(transfer.getId(), transfer.getStatus(),
|
||||||
new PayTransferDO().setStatus(PayTransferStatusEnum.WAITING.getStatus()));
|
new PayTransferDO().setStatus(PayTransferStatusEnum.WAITING.getStatus()));
|
||||||
}
|
}
|
||||||
|
PayTransferRespDTO unifiedTransferResp = null;
|
||||||
try {
|
try {
|
||||||
// 3. 调用三方渠道发起转账
|
// 3. 调用三方渠道发起转账
|
||||||
PayTransferUnifiedReqDTO transferUnifiedReq = BeanUtils.toBean(reqDTO, PayTransferUnifiedReqDTO.class)
|
PayTransferUnifiedReqDTO transferUnifiedReq = BeanUtils.toBean(reqDTO, PayTransferUnifiedReqDTO.class)
|
||||||
.setOutTransferNo(transfer.getNo())
|
.setOutTransferNo(transfer.getNo())
|
||||||
.setNotifyUrl(genChannelTransferNotifyUrl(channel));
|
.setNotifyUrl(genChannelTransferNotifyUrl(channel));
|
||||||
PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq);
|
unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq);
|
||||||
// 4. 通知转账结果
|
// 4. 通知转账结果
|
||||||
getSelf().notifyTransfer(channel, unifiedTransferResp);
|
getSelf().notifyTransfer(channel, unifiedTransferResp);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -102,7 +104,8 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
// 或者,使用相同 no 再次发起转账请求
|
// 或者,使用相同 no 再次发起转账请求
|
||||||
log.error("[createTransfer][转账编号({}) requestDTO({}) 发生异常]", transfer.getId(), reqDTO, e);
|
log.error("[createTransfer][转账编号({}) requestDTO({}) 发生异常]", transfer.getId(), reqDTO, e);
|
||||||
}
|
}
|
||||||
return transfer.getId();
|
return new PayTransferCreateRespDTO().setId(transfer.getId())
|
||||||
|
.setChannelPackageInfo(unifiedTransferResp != null ? unifiedTransferResp.getChannelPackageInfo() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +157,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyTransferProgressing(PayChannelDO channel, PayTransferRespDTO notify) {
|
private void notifyTransferProgressing(PayChannelDO channel, PayTransferRespDTO notify) {
|
||||||
// 1.校验
|
// 1. 校验
|
||||||
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo());
|
PayTransferDO transfer = transferMapper.selectByAppIdAndNo(channel.getAppId(), notify.getOutTransferNo());
|
||||||
if (transfer == null) {
|
if (transfer == null) {
|
||||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||||
|
@ -170,7 +173,8 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
// 2. 更新状态
|
// 2. 更新状态
|
||||||
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()));
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -261,6 +265,9 @@ public class PayTransferServiceImpl implements PayTransferService {
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (PayTransferDO transfer : list) {
|
for (PayTransferDO transfer : list) {
|
||||||
|
if (!transfer.getId().equals(54L)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
count += syncTransfer(transfer) ? 1 : 0;
|
count += syncTransfer(transfer) ? 1 : 0;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -22,7 +22,6 @@ public class PayTransferRespDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外部转账单号
|
* 外部转账单号
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private String outTransferNo;
|
private String outTransferNo;
|
||||||
|
|
||||||
|
@ -50,11 +49,19 @@ public class PayTransferRespDTO {
|
||||||
*/
|
*/
|
||||||
private String channelErrorMsg;
|
private String channelErrorMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道 package 信息
|
||||||
|
*
|
||||||
|
* 特殊:目前只有微信转账有这个东西!!!
|
||||||
|
* @see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012716430">JSAPI 调起用户确认收款</a>
|
||||||
|
*/
|
||||||
|
private String channelPackageInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建【WAITING】状态的转账返回
|
* 创建【WAITING】状态的转账返回
|
||||||
*/
|
*/
|
||||||
public static PayTransferRespDTO waitingOf(String channelTransferNo,
|
public static PayTransferRespDTO waitingOf(String channelTransferNo,
|
||||||
String outTransferNo, Object rawData) {
|
String outTransferNo, Object rawData) {
|
||||||
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
||||||
respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus();
|
respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus();
|
||||||
respDTO.channelTransferNo = channelTransferNo;
|
respDTO.channelTransferNo = channelTransferNo;
|
||||||
|
|
|
@ -482,11 +482,19 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
// 2.1 执行请求
|
// 2.1 执行请求
|
||||||
try {
|
try {
|
||||||
TransferBillsResult response = client.getTransferService().transferBills(request);
|
TransferBillsResult response = client.getTransferService().transferBills(request);
|
||||||
System.out.println(response);
|
|
||||||
|
|
||||||
// 2.2 创建返回结果
|
// 2.2 创建返回结果
|
||||||
// TODO @芋艿:这里要解析下;
|
String state = response.getState();
|
||||||
return PayTransferRespDTO.processingOf(response.getTransferBillNo(), reqDTO.getOutTransferNo(), response);
|
if (ObjectUtils.equalsAny(state, "ACCEPTED", "PROCESSING", "WAIT_USER_CONFIRM", "TRANSFERING")) {
|
||||||
|
return PayTransferRespDTO.processingOf(response.getTransferBillNo(), response.getOutBillNo(), response)
|
||||||
|
.setChannelPackageInfo(response.getPackageInfo()); // 一般情况下,只有 WAIT_USER_CONFIRM 会有!
|
||||||
|
}
|
||||||
|
if (Objects.equals("SUCCESS", state)) {
|
||||||
|
return PayTransferRespDTO.successOf(response.getTransferBillNo(), parseDateV3(response.getCreateTime()),
|
||||||
|
response.getOutBillNo(), response);
|
||||||
|
}
|
||||||
|
return PayTransferRespDTO.closedOf(state, response.getFailReason(),
|
||||||
|
response.getOutBillNo(), response);
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
log.error("[doUnifiedTransfer][转账({}) 发起微信支付异常", reqDTO, e);
|
log.error("[doUnifiedTransfer][转账({}) 发起微信支付异常", reqDTO, e);
|
||||||
String errorCode = getErrorCode(e);
|
String errorCode = getErrorCode(e);
|
||||||
|
@ -499,7 +507,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||||
@Override
|
@Override
|
||||||
protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws WxPayException {
|
protected PayTransferRespDTO doGetTransfer(String outTradeNo) throws WxPayException {
|
||||||
// 1. 执行请求
|
// 1. 执行请求
|
||||||
TransferBillsGetResult response = client.getTransferService().getBillsByTransferBillNo(outTradeNo);
|
TransferBillsGetResult response = client.getTransferService().getBillsByOutBillNo(outTradeNo);
|
||||||
|
|
||||||
// 2. 创建返回结果
|
// 2. 创建返回结果
|
||||||
String state = response.getState();
|
String state = response.getState();
|
||||||
|
|
Loading…
Reference in New Issue