mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-08 13:37:35 +00:00
feat 转账接口功能完善, 上下文对象进行优化精简
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
## 单商户
|
## 单商户
|
||||||
2.0.8: 转账/撤销接口和系统优化
|
2.0.8: 转账/撤销接口和系统优化
|
||||||
- [x] 支持撤销接口
|
- [x] 支持撤销接口
|
||||||
- [ ] 增加转账接口功能
|
- [x] 增加转账接口功能
|
||||||
- [ ] 细分各种支付异常类和编码(部分)
|
- [ ] 细分各种支付异常类和编码(部分)
|
||||||
- [ ] 增加分账回调处理(支付宝)
|
- [ ] 增加分账回调处理(支付宝)
|
||||||
- [ ] 增加分账修复功能
|
- [ ] 增加分账修复功能
|
||||||
- [ ] DEMO增加获取微信OpenID和支付宝OpenId功能
|
- [ ] DEMO增加获取微信OpenID和支付宝OpenId功能
|
||||||
- [ ] 支付宝微信等消息通知地址支持一键生成
|
- [ ] DEMO增加转账演示功能
|
||||||
|
- [x] 支付宝微信等消息通知地址支持一键生成
|
||||||
- [ ] 管理端界面支持扫码绑定对账接收方功能
|
- [ ] 管理端界面支持扫码绑定对账接收方功能
|
||||||
|
- [ ] 上下文对象进行优化精简
|
||||||
- [x] 请求IP参数增加正则校验
|
- [x] 请求IP参数增加正则校验
|
||||||
- [x] 支付接口公共参数添加随机数字段, 预防重放问题
|
- [x] 支付接口公共参数添加随机数字段, 预防重放问题
|
||||||
- [x] 请求接口增加有效期校验, 超时后失效
|
- [x] 请求接口增加有效期校验, 超时后失效
|
||||||
|
@@ -53,4 +53,16 @@ public class AlipayConfigController {
|
|||||||
public ResResult<String> readPem(MultipartFile file){
|
public ResResult<String> readPem(MultipartFile file){
|
||||||
return Res.ok(new String(file.getBytes(), StandardCharsets.UTF_8));
|
return Res.ok(new String(file.getBytes(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成异步通知地址")
|
||||||
|
@GetMapping("/generateNotifyUrl")
|
||||||
|
public ResResult<String> generateNotifyUrl() {
|
||||||
|
return Res.ok(alipayConfigService.generateNotifyUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成同步通知地址")
|
||||||
|
@GetMapping("/generateReturnUrl")
|
||||||
|
public ResResult<String> generateReturnUrl() {
|
||||||
|
return Res.ok(alipayConfigService.generateReturnUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,4 +54,16 @@ public class UnionPayConfigController {
|
|||||||
public ResResult<String> toBase64(MultipartFile file){
|
public ResResult<String> toBase64(MultipartFile file){
|
||||||
return Res.ok(Base64.encode(file.getBytes()));
|
return Res.ok(Base64.encode(file.getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成异步通知地址")
|
||||||
|
@GetMapping("/generateNotifyUrl")
|
||||||
|
public ResResult<String> generateNotifyUrl() {
|
||||||
|
return Res.ok(unionPayConfigService.generateNotifyUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成同步通知地址")
|
||||||
|
@GetMapping("/generateReturnUrl")
|
||||||
|
public ResResult<String> generateReturnUrl() {
|
||||||
|
return Res.ok(unionPayConfigService.generateReturnUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,9 +39,10 @@ public class WalletConfigController {
|
|||||||
return Res.ok();
|
return Res.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "支付宝支持支付方式")
|
@Operation(summary = "钱包支持支付方式")
|
||||||
@GetMapping("/findPayWays")
|
@GetMapping("/findPayWays")
|
||||||
public ResResult<List<LabelValue>> findPayWays() {
|
public ResResult<List<LabelValue>> findPayWays() {
|
||||||
return Res.ok(service.findPayWays());
|
return Res.ok(service.findPayWays());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -52,4 +52,16 @@ public class WeChatPayConfigController {
|
|||||||
public ResResult<String> toBase64(MultipartFile file){
|
public ResResult<String> toBase64(MultipartFile file){
|
||||||
return Res.ok(Base64.encode(file.getBytes()));
|
return Res.ok(Base64.encode(file.getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成异步通知地址")
|
||||||
|
@GetMapping("/generateNotifyUrl")
|
||||||
|
public ResResult<String> generateNotifyUrl() {
|
||||||
|
return Res.ok(weChatPayConfigService.generateNotifyUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "生成同步通知地址")
|
||||||
|
@GetMapping("/generateReturnUrl")
|
||||||
|
public ResResult<String> generateReturnUrl() {
|
||||||
|
return Res.ok(weChatPayConfigService.generateReturnUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,8 +12,6 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum TransferStatusEnum {
|
public enum TransferStatusEnum {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TRANSFERRING("transferring", "转账中"),
|
TRANSFERRING("transferring", "转账中"),
|
||||||
SUCCESS("success", "转账成功"),
|
SUCCESS("success", "转账成功"),
|
||||||
FAIL("fail", "转账失败"),
|
FAIL("fail", "转账失败"),
|
||||||
|
@@ -33,13 +33,13 @@ public class PayReturnController {
|
|||||||
return new ModelAndView("redirect:" + url);
|
return new ModelAndView("redirect:" + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "微信同步通知")
|
@Operation(summary = "微信同步跳转连接")
|
||||||
@GetMapping("/wechat")
|
@GetMapping("/wechat")
|
||||||
public ModelAndView wechat(){
|
public ModelAndView wechat(){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "云闪付同步通知")
|
@Operation(summary = "云闪付同步跳转连接")
|
||||||
@PostMapping("/union")
|
@PostMapping("/union")
|
||||||
public ModelAndView union(UnionPayReturnParam param){
|
public ModelAndView union(UnionPayReturnParam param){
|
||||||
String url = payReturnService.union(param);
|
String url = payReturnService.union(param);
|
||||||
|
@@ -27,7 +27,7 @@ public class CallbackLocal {
|
|||||||
private String tradeNo;
|
private String tradeNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方支付平台交易号
|
* 通道交易号
|
||||||
*/
|
*/
|
||||||
private String outTradeNo;
|
private String outTradeNo;
|
||||||
|
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
package cn.daxpay.single.service.common.context;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/6/14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ErrorInfoLocal {
|
||||||
|
|
||||||
|
/** 错误码 */
|
||||||
|
private String errorCode;
|
||||||
|
|
||||||
|
/** 错误内容 */
|
||||||
|
private String errorMsg;
|
||||||
|
}
|
@@ -30,7 +30,4 @@ public class PayLocal {
|
|||||||
/** 支付参数体(通常用于发起支付的参数) */
|
/** 支付参数体(通常用于发起支付的参数) */
|
||||||
private String payBody;
|
private String payBody;
|
||||||
|
|
||||||
/** 订单超时时间, */
|
|
||||||
private LocalDateTime expiredTime;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,9 @@ public class PaymentContext {
|
|||||||
/** 请求终端信息 */
|
/** 请求终端信息 */
|
||||||
private final ClientLocal clientInfo = new ClientLocal();
|
private final ClientLocal clientInfo = new ClientLocal();
|
||||||
|
|
||||||
|
/** 错误信息 */
|
||||||
|
private final ErrorInfoLocal errorInfo = new ErrorInfoLocal();
|
||||||
|
|
||||||
/** 支付相关信息 */
|
/** 支付相关信息 */
|
||||||
private final PayLocal payInfo = new PayLocal();
|
private final PayLocal payInfo = new PayLocal();
|
||||||
|
|
||||||
@@ -36,4 +39,7 @@ public class PaymentContext {
|
|||||||
/** 分账相关信息 */
|
/** 分账相关信息 */
|
||||||
private final AllocationLocal allocationInfo = new AllocationLocal();
|
private final AllocationLocal allocationInfo = new AllocationLocal();
|
||||||
|
|
||||||
|
/** 转账相关信息 */
|
||||||
|
private final TransferLocal transferInfo = new TransferLocal();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package cn.daxpay.single.service.common.context;
|
package cn.daxpay.single.service.common.context;
|
||||||
|
|
||||||
import cn.daxpay.single.code.RefundStatusEnum;
|
import cn.daxpay.single.code.RefundStatusEnum;
|
||||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@@ -26,15 +25,6 @@ public class RefundLocal {
|
|||||||
*/
|
*/
|
||||||
private RefundStatusEnum status = RefundStatusEnum.SUCCESS;
|
private RefundStatusEnum status = RefundStatusEnum.SUCCESS;
|
||||||
|
|
||||||
/** 错误码 */
|
|
||||||
private String errorCode;
|
|
||||||
|
|
||||||
/** 错误内容 */
|
|
||||||
private String errorMsg;
|
|
||||||
|
|
||||||
/** 退款订单 */
|
|
||||||
private RefundOrder refundOrder;
|
|
||||||
|
|
||||||
/** 退款完成时间 */
|
/** 退款完成时间 */
|
||||||
private LocalDateTime finishTime;
|
private LocalDateTime finishTime;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ public class RepairLocal {
|
|||||||
*/
|
*/
|
||||||
private PayRepairSourceEnum source;
|
private PayRepairSourceEnum source;
|
||||||
|
|
||||||
/** 支付完成/退款时间 */
|
/** 完成/退款时间 */
|
||||||
private LocalDateTime finishTime;
|
private LocalDateTime finishTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.daxpay.single.service.common.context;
|
||||||
|
|
||||||
|
import cn.daxpay.single.code.TransferStatusEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账相关信息
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/6/14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class TransferLocal {
|
||||||
|
|
||||||
|
/** 通道转账订单号 */
|
||||||
|
private String outTransferNo;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
private TransferStatusEnum status = TransferStatusEnum.SUCCESS;
|
||||||
|
|
||||||
|
/** 完成时间 */
|
||||||
|
private LocalDateTime finishTime;
|
||||||
|
}
|
||||||
|
|
@@ -9,6 +9,7 @@ import cn.daxpay.single.service.code.AliPayWay;
|
|||||||
import cn.daxpay.single.service.core.channel.alipay.dao.AliPayConfigManager;
|
import cn.daxpay.single.service.core.channel.alipay.dao.AliPayConfigManager;
|
||||||
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
||||||
import cn.daxpay.single.service.core.system.config.service.PayChannelConfigService;
|
import cn.daxpay.single.service.core.system.config.service.PayChannelConfigService;
|
||||||
|
import cn.daxpay.single.service.core.system.config.service.PlatformConfigService;
|
||||||
import cn.daxpay.single.service.param.channel.alipay.AliPayConfigParam;
|
import cn.daxpay.single.service.param.channel.alipay.AliPayConfigParam;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
@@ -39,6 +40,7 @@ public class AliPayConfigService {
|
|||||||
private final static Long ID = 0L;
|
private final static Long ID = 0L;
|
||||||
private final AliPayConfigManager alipayConfigManager;
|
private final AliPayConfigManager alipayConfigManager;
|
||||||
private final PayChannelConfigService payChannelConfigService;
|
private final PayChannelConfigService payChannelConfigService;
|
||||||
|
private final PlatformConfigService platformConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
@@ -78,6 +80,19 @@ public class AliPayConfigService {
|
|||||||
return alipayConfig;
|
return alipayConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成通知地址
|
||||||
|
*/
|
||||||
|
public String generateNotifyUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/callback/pay/alipay";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成同步跳转地址
|
||||||
|
*/
|
||||||
|
public String generateReturnUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/return/pay/alipay";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化IJPay服务
|
* 初始化IJPay服务
|
||||||
|
@@ -3,6 +3,7 @@ package cn.daxpay.single.service.core.channel.alipay.service;
|
|||||||
import cn.daxpay.single.code.RefundStatusEnum;
|
import cn.daxpay.single.code.RefundStatusEnum;
|
||||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
import cn.daxpay.single.service.code.AliPayCode;
|
import cn.daxpay.single.service.code.AliPayCode;
|
||||||
|
import cn.daxpay.single.service.common.context.ErrorInfoLocal;
|
||||||
import cn.daxpay.single.service.common.context.RefundLocal;
|
import cn.daxpay.single.service.common.context.RefundLocal;
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||||
@@ -33,6 +34,7 @@ public class AliPayRefundService {
|
|||||||
*/
|
*/
|
||||||
public void refund(RefundOrder refundOrder) {
|
public void refund(RefundOrder refundOrder) {
|
||||||
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
||||||
|
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||||
AlipayTradeRefundModel refundModel = new AlipayTradeRefundModel();
|
AlipayTradeRefundModel refundModel = new AlipayTradeRefundModel();
|
||||||
refundModel.setOutTradeNo(refundOrder.getOrderNo());
|
refundModel.setOutTradeNo(refundOrder.getOrderNo());
|
||||||
refundModel.setOutRequestNo(refundOrder.getRefundNo());
|
refundModel.setOutRequestNo(refundOrder.getRefundNo());
|
||||||
@@ -44,8 +46,8 @@ public class AliPayRefundService {
|
|||||||
try {
|
try {
|
||||||
AlipayTradeRefundResponse response = AliPayApi.tradeRefundToResponse(refundModel);
|
AlipayTradeRefundResponse response = AliPayApi.tradeRefundToResponse(refundModel);
|
||||||
if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) {
|
if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) {
|
||||||
refundInfo.setErrorMsg(response.getSubMsg());
|
errorInfo.setErrorMsg(response.getSubMsg());
|
||||||
refundInfo.setErrorCode(response.getCode());
|
errorInfo.setErrorCode(response.getCode());
|
||||||
log.error("网关返回退款失败: {}", response.getSubMsg());
|
log.error("网关返回退款失败: {}", response.getSubMsg());
|
||||||
throw new PayFailureException(response.getSubMsg());
|
throw new PayFailureException(response.getSubMsg());
|
||||||
}
|
}
|
||||||
@@ -61,8 +63,8 @@ public class AliPayRefundService {
|
|||||||
}
|
}
|
||||||
catch (AlipayApiException e) {
|
catch (AlipayApiException e) {
|
||||||
log.error("订单退款失败:", e);
|
log.error("订单退款失败:", e);
|
||||||
refundInfo.setErrorMsg(e.getErrMsg());
|
errorInfo.setErrorMsg(e.getErrMsg());
|
||||||
refundInfo.setErrorCode(e.getErrCode());
|
errorInfo.setErrorCode(e.getErrCode());
|
||||||
throw new PayFailureException("订单退款失败");
|
throw new PayFailureException("订单退款失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.daxpay.single.service.core.channel.alipay.service;
|
package cn.daxpay.single.service.core.channel.alipay.service;
|
||||||
|
|
||||||
|
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||||
import cn.daxpay.single.code.PayMethodEnum;
|
import cn.daxpay.single.code.PayMethodEnum;
|
||||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
import cn.daxpay.single.param.channel.AliPayParam;
|
import cn.daxpay.single.param.channel.AliPayParam;
|
||||||
@@ -25,6 +26,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -252,11 +254,12 @@ public class AliPayService {
|
|||||||
model.setTotalAmount(amount);
|
model.setTotalAmount(amount);
|
||||||
try {
|
try {
|
||||||
AlipayTradePayResponse response = AliPayApi.tradePayToResponse(model, alipayConfig.getNotifyUrl());
|
AlipayTradePayResponse response = AliPayApi.tradePayToResponse(model, alipayConfig.getNotifyUrl());
|
||||||
|
|
||||||
// 支付成功处理 金额2000以下免密支付, 记录支付完成相关信息
|
// 支付成功处理 金额2000以下免密支付, 记录支付完成相关信息
|
||||||
if (Objects.equals(response.getCode(), AliPayCode.SUCCESS)) {
|
if (Objects.equals(response.getCode(), AliPayCode.SUCCESS)) {
|
||||||
|
Date gmtPayment = response.getGmtPayment();
|
||||||
payInfo.setOutOrderNo(response.getTradeNo())
|
payInfo.setOutOrderNo(response.getTradeNo())
|
||||||
.setComplete(true);
|
.setComplete(true)
|
||||||
|
.setCompleteTime(LocalDateTimeUtil.of(gmtPayment));
|
||||||
}
|
}
|
||||||
// 非支付中响应码, 进行错误处理
|
// 非支付中响应码, 进行错误处理
|
||||||
if (!Objects.equals(response.getCode(), AliPayCode.INPROCESS)) {
|
if (!Objects.equals(response.getCode(), AliPayCode.INPROCESS)) {
|
||||||
|
@@ -1,8 +1,17 @@
|
|||||||
package cn.daxpay.single.service.core.channel.alipay.service;
|
package cn.daxpay.single.service.core.channel.alipay.service;
|
||||||
|
|
||||||
|
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||||
|
import cn.daxpay.single.code.TransferStatusEnum;
|
||||||
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
|
import cn.daxpay.single.service.code.AliPayCode;
|
||||||
|
import cn.daxpay.single.service.common.context.TransferLocal;
|
||||||
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
||||||
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.daxpay.single.util.OrderNoGenerateUtil;
|
||||||
|
import cn.daxpay.single.util.PayUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alipay.api.domain.AlipayFundAccountQueryModel;
|
import com.alipay.api.domain.AlipayFundAccountQueryModel;
|
||||||
import com.alipay.api.domain.AlipayFundTransToaccountTransferModel;
|
import com.alipay.api.domain.AlipayFundTransToaccountTransferModel;
|
||||||
import com.alipay.api.response.AlipayFundAccountQueryResponse;
|
import com.alipay.api.response.AlipayFundAccountQueryResponse;
|
||||||
@@ -13,6 +22,9 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.daxpay.single.service.code.AliPayCode.QUERY_ACCOUNT_TYPE;
|
import static cn.daxpay.single.service.code.AliPayCode.QUERY_ACCOUNT_TYPE;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -20,8 +32,6 @@ import static cn.daxpay.single.service.code.AliPayCode.QUERY_ACCOUNT_TYPE;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AliPayTransferService {
|
public class AliPayTransferService {
|
||||||
|
|
||||||
private final AliPayConfigService payConfigService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额查询接口
|
* 余额查询接口
|
||||||
*/
|
*/
|
||||||
@@ -40,15 +50,28 @@ public class AliPayTransferService {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void transfer(TransferOrder order) {
|
public void transfer(TransferOrder order) {
|
||||||
AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel();
|
AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel();
|
||||||
// model.setAmount(PayUtil.conversionAmount(order.getAmount()).toString());
|
model.setAmount(PayUtil.conversionAmount(order.getAmount()).toString());
|
||||||
model.setAmount("1.00");
|
model.setOutBizNo(OrderNoGenerateUtil.transfer());
|
||||||
model.setOutBizNo(IdUtil.getSnowflakeNextIdStr());
|
model.setPayeeType(order.getPayeeType());
|
||||||
model.setPayeeType("ALIPAY_USERID");
|
model.setPayeeAccount(order.getPayeeAccount());
|
||||||
model.setPayeeAccount("2088722032251651");
|
model.setPayerShowName(order.getPayerShowName());
|
||||||
model.setPayerShowName("易杯光年");
|
// 标题
|
||||||
model.setExtParam("{order_title: '订单标题'}");
|
model.setExtParam(StrUtil.format("{order_title: '{}'}", order.getTitle()));
|
||||||
model.setRemark("易杯光年的备注");
|
model.setRemark(order.getReason());
|
||||||
AlipayFundTransToaccountTransferResponse response = AliPayApi.transferToResponse(model);
|
AlipayFundTransToaccountTransferResponse response = AliPayApi.transferToResponse(model);
|
||||||
System.out.println(response);
|
if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) {
|
||||||
|
log.error("网关返回退款失败: {}", response.getSubMsg());
|
||||||
|
throw new PayFailureException(response.getSubMsg());
|
||||||
|
}
|
||||||
|
TransferLocal transferInfo = PaymentContextLocal.get().getTransferInfo();
|
||||||
|
// 通道转账号
|
||||||
|
transferInfo.setOutTransferNo(response.getOrderId());
|
||||||
|
// 有完成时间代表处理完成
|
||||||
|
String payDate = response.getPayDate();
|
||||||
|
if (StrUtil.isNotBlank(payDate)){
|
||||||
|
LocalDateTime time = LocalDateTimeUtil.parse(payDate, DatePattern.NORM_DATETIME_PATTERN);
|
||||||
|
transferInfo.setFinishTime(time)
|
||||||
|
.setStatus(TransferStatusEnum.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ import cn.daxpay.single.exception.pay.PayFailureException;
|
|||||||
import cn.daxpay.single.service.code.UnionPayWay;
|
import cn.daxpay.single.service.code.UnionPayWay;
|
||||||
import cn.daxpay.single.service.core.channel.union.dao.UnionPayConfigManager;
|
import cn.daxpay.single.service.core.channel.union.dao.UnionPayConfigManager;
|
||||||
import cn.daxpay.single.service.core.channel.union.entity.UnionPayConfig;
|
import cn.daxpay.single.service.core.channel.union.entity.UnionPayConfig;
|
||||||
import cn.daxpay.single.service.core.system.config.service.PayChannelConfigService;
|
import cn.daxpay.single.service.core.system.config.service.PlatformConfigService;
|
||||||
import cn.daxpay.single.service.param.channel.union.UnionPayConfigParam;
|
import cn.daxpay.single.service.param.channel.union.UnionPayConfigParam;
|
||||||
import cn.daxpay.single.service.sdk.union.api.UnionPayKit;
|
import cn.daxpay.single.service.sdk.union.api.UnionPayKit;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
@@ -37,7 +37,7 @@ public class UnionPayConfigService {
|
|||||||
/** 默认云闪付配置的主键ID */
|
/** 默认云闪付配置的主键ID */
|
||||||
private final static Long ID = 0L;
|
private final static Long ID = 0L;
|
||||||
private final UnionPayConfigManager unionPayConfigManager;
|
private final UnionPayConfigManager unionPayConfigManager;
|
||||||
private final PayChannelConfigService payChannelConfigService;
|
private final PlatformConfigService platformConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
@@ -77,6 +77,20 @@ public class UnionPayConfigService {
|
|||||||
return unionPayConfig;
|
return unionPayConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成通知地址
|
||||||
|
*/
|
||||||
|
public String generateNotifyUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/callback/pay/union";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成同步跳转地址
|
||||||
|
*/
|
||||||
|
public String generateReturnUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/return/pay/union";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成云闪付支付服务
|
* 生成云闪付支付服务
|
||||||
|
@@ -6,7 +6,7 @@ import cn.daxpay.single.exception.pay.PayFailureException;
|
|||||||
import cn.daxpay.single.service.code.WeChatPayWay;
|
import cn.daxpay.single.service.code.WeChatPayWay;
|
||||||
import cn.daxpay.single.service.core.channel.wechat.dao.WeChatPayConfigManager;
|
import cn.daxpay.single.service.core.channel.wechat.dao.WeChatPayConfigManager;
|
||||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||||
import cn.daxpay.single.service.core.system.config.service.PayChannelConfigService;
|
import cn.daxpay.single.service.core.system.config.service.PlatformConfigService;
|
||||||
import cn.daxpay.single.service.param.channel.wechat.WeChatPayConfigParam;
|
import cn.daxpay.single.service.param.channel.wechat.WeChatPayConfigParam;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
@@ -31,7 +31,8 @@ public class WeChatPayConfigService {
|
|||||||
/** 默认微信支付配置的主键ID */
|
/** 默认微信支付配置的主键ID */
|
||||||
private final static Long ID = 0L;
|
private final static Long ID = 0L;
|
||||||
private final WeChatPayConfigManager weChatPayConfigManager;
|
private final WeChatPayConfigManager weChatPayConfigManager;
|
||||||
private final PayChannelConfigService payChannelConfigService;
|
|
||||||
|
private final PlatformConfigService platformConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
@@ -73,4 +74,18 @@ public class WeChatPayConfigService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成微信通知地址
|
||||||
|
*/
|
||||||
|
public String generateNotifyUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/callback/pay/wechat";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成同步跳转地址
|
||||||
|
*/
|
||||||
|
public String generateReturnUrl(){
|
||||||
|
return platformConfigService.getConfig().getWebsiteUrl() + "/return/pay/wechat";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -210,7 +210,11 @@ public class WeChatPayService {
|
|||||||
String errCode = result.get(WeChatPayCode.ERR_CODE);
|
String errCode = result.get(WeChatPayCode.ERR_CODE);
|
||||||
// 支付成功处理,
|
// 支付成功处理,
|
||||||
if (Objects.equals(resultCode, WeChatPayCode.PAY_SUCCESS)) {
|
if (Objects.equals(resultCode, WeChatPayCode.PAY_SUCCESS)) {
|
||||||
payInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID)).setComplete(true);
|
String timeEnd = result.get(WeChatPayCode.TIME_END);
|
||||||
|
LocalDateTime time = LocalDateTimeUtil.parse(timeEnd, DatePattern.PURE_DATETIME_PATTERN);
|
||||||
|
payInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID))
|
||||||
|
.setCompleteTime(time)
|
||||||
|
.setComplete(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 支付中, 发起轮训同步
|
// 支付中, 发起轮训同步
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.daxpay.single.service.core.channel.wechat.service;
|
||||||
|
|
||||||
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
|
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||||
|
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信转账到零钱
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/6/14
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WeChatPayTransferService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账接口
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
public void transfer(TransferOrder order, WeChatPayConfig config) {
|
||||||
|
throw new PayFailureException("微信转账暂未实现");
|
||||||
|
}
|
||||||
|
}
|
@@ -2,6 +2,7 @@ package cn.daxpay.single.service.core.channel.wechat.service;
|
|||||||
|
|
||||||
import cn.daxpay.single.code.RefundStatusEnum;
|
import cn.daxpay.single.code.RefundStatusEnum;
|
||||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
|
import cn.daxpay.single.service.common.context.ErrorInfoLocal;
|
||||||
import cn.daxpay.single.service.common.context.RefundLocal;
|
import cn.daxpay.single.service.common.context.RefundLocal;
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||||
@@ -41,6 +42,7 @@ public class WechatPayRefundService {
|
|||||||
String totalFee = String.valueOf(refundOrder.getAmount());
|
String totalFee = String.valueOf(refundOrder.getAmount());
|
||||||
// 设置退款信息
|
// 设置退款信息
|
||||||
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
||||||
|
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||||
Map<String, String> params = RefundModel.builder()
|
Map<String, String> params = RefundModel.builder()
|
||||||
.appid(weChatPayConfig.getWxAppId())
|
.appid(weChatPayConfig.getWxAppId())
|
||||||
.mch_id(weChatPayConfig.getWxMchId())
|
.mch_id(weChatPayConfig.getWxMchId())
|
||||||
@@ -55,8 +57,8 @@ public class WechatPayRefundService {
|
|||||||
// 获取证书文件
|
// 获取证书文件
|
||||||
if (StrUtil.isBlank(weChatPayConfig.getP12())){
|
if (StrUtil.isBlank(weChatPayConfig.getP12())){
|
||||||
String errorMsg = "微信p.12证书未配置,无法进行退款";
|
String errorMsg = "微信p.12证书未配置,无法进行退款";
|
||||||
refundInfo.setErrorMsg(errorMsg);
|
errorInfo.setErrorMsg(errorMsg);
|
||||||
refundInfo.setErrorCode(RefundStatusEnum.FAIL.getCode());
|
errorInfo.setErrorCode(RefundStatusEnum.FAIL.getCode());
|
||||||
throw new PayFailureException(errorMsg);
|
throw new PayFailureException(errorMsg);
|
||||||
}
|
}
|
||||||
byte[] fileBytes = Base64.decode(weChatPayConfig.getP12());
|
byte[] fileBytes = Base64.decode(weChatPayConfig.getP12());
|
||||||
@@ -82,9 +84,9 @@ public class WechatPayRefundService {
|
|||||||
errorMsg = result.get(RETURN_MSG);
|
errorMsg = result.get(RETURN_MSG);
|
||||||
}
|
}
|
||||||
log.error("订单退款失败 {}", errorMsg);
|
log.error("订单退款失败 {}", errorMsg);
|
||||||
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||||
refundInfo.setErrorMsg(errorMsg);
|
errorInfo.setErrorMsg(errorMsg);
|
||||||
refundInfo.setErrorCode(Optional.ofNullable(resultCode).orElse(returnCode));
|
errorInfo.setErrorCode(Optional.ofNullable(resultCode).orElse(returnCode));
|
||||||
throw new PayFailureException(errorMsg);
|
throw new PayFailureException(errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
package cn.daxpay.single.service.core.order.pay.builder;
|
|
||||||
|
|
||||||
import cn.daxpay.single.code.PayOrderAllocStatusEnum;
|
|
||||||
import cn.daxpay.single.code.PayOrderRefundStatusEnum;
|
|
||||||
import cn.daxpay.single.code.PayStatusEnum;
|
|
||||||
import cn.daxpay.single.param.payment.pay.PayParam;
|
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
|
||||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
|
||||||
import cn.daxpay.single.util.OrderNoGenerateUtil;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付对象构建器
|
|
||||||
*
|
|
||||||
* @author xxm
|
|
||||||
* @since 2021/2/25
|
|
||||||
*/
|
|
||||||
@UtilityClass
|
|
||||||
public class PayBuilder {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建支付订单
|
|
||||||
*/
|
|
||||||
public PayOrder buildPayOrder(PayParam payParam) {
|
|
||||||
// 订单超时时间
|
|
||||||
LocalDateTime expiredTime = PaymentContextLocal.get()
|
|
||||||
.getPayInfo()
|
|
||||||
.getExpiredTime();
|
|
||||||
// 构建支付订单对象
|
|
||||||
PayOrder payOrder = new PayOrder()
|
|
||||||
.setBizOrderNo(payParam.getBizOrderNo())
|
|
||||||
.setOrderNo(OrderNoGenerateUtil.pay())
|
|
||||||
.setTitle(payParam.getTitle())
|
|
||||||
.setDescription(payParam.getDescription())
|
|
||||||
.setStatus(PayStatusEnum.PROGRESS.getCode())
|
|
||||||
.setRefundStatus(PayOrderRefundStatusEnum.NO_REFUND.getCode())
|
|
||||||
.setAllocation(payParam.getAllocation())
|
|
||||||
.setAmount(payParam.getAmount())
|
|
||||||
.setChannel(payParam.getChannel())
|
|
||||||
.setMethod(payParam.getMethod())
|
|
||||||
.setExpiredTime(expiredTime)
|
|
||||||
.setRefundableBalance(payParam.getAmount())
|
|
||||||
.setClientIp(payParam.getClientIp())
|
|
||||||
.setNotifyUrl(payParam.getNotifyUrl())
|
|
||||||
.setReturnUrl(payParam.getReturnUrl())
|
|
||||||
.setAttach(payParam.getAttach())
|
|
||||||
.setReqTime(payParam.getReqTime());
|
|
||||||
// 如果支持分账, 设置分账状态为代分账
|
|
||||||
if (payOrder.getAllocation()) {
|
|
||||||
payOrder.setAllocStatus(PayOrderAllocStatusEnum.WAITING.getCode());
|
|
||||||
}
|
|
||||||
return payOrder;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +1,7 @@
|
|||||||
package cn.daxpay.single.service.core.order.transfer.convert;
|
package cn.daxpay.single.service.core.order.transfer.convert;
|
||||||
|
|
||||||
|
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
||||||
|
import cn.daxpay.single.service.dto.order.transfer.TransferOrderDto;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@@ -12,4 +14,5 @@ import org.mapstruct.factory.Mappers;
|
|||||||
public interface TransferOrderConvert {
|
public interface TransferOrderConvert {
|
||||||
TransferOrderConvert CONVERT = Mappers.getMapper(TransferOrderConvert.class);
|
TransferOrderConvert CONVERT = Mappers.getMapper(TransferOrderConvert.class);
|
||||||
|
|
||||||
|
TransferOrderDto convert(TransferOrder in);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package cn.daxpay.single.service.core.order.transfer.entity;
|
package cn.daxpay.single.service.core.order.transfer.entity;
|
||||||
|
|
||||||
|
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||||
import cn.bootx.table.modify.annotation.DbColumn;
|
import cn.bootx.table.modify.annotation.DbColumn;
|
||||||
import cn.bootx.table.modify.annotation.DbTable;
|
import cn.bootx.table.modify.annotation.DbTable;
|
||||||
@@ -7,6 +8,8 @@ import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;
|
|||||||
import cn.daxpay.single.code.PayChannelEnum;
|
import cn.daxpay.single.code.PayChannelEnum;
|
||||||
import cn.daxpay.single.code.TransferPayeeTypeEnum;
|
import cn.daxpay.single.code.TransferPayeeTypeEnum;
|
||||||
import cn.daxpay.single.code.TransferTypeEnum;
|
import cn.daxpay.single.code.TransferTypeEnum;
|
||||||
|
import cn.daxpay.single.service.core.order.transfer.convert.TransferOrderConvert;
|
||||||
|
import cn.daxpay.single.service.dto.order.transfer.TransferOrderDto;
|
||||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
@@ -26,7 +29,7 @@ import java.time.LocalDateTime;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@DbTable(comment = "转账订单")
|
@DbTable(comment = "转账订单")
|
||||||
@TableName("pay_transfer_order")
|
@TableName("pay_transfer_order")
|
||||||
public class TransferOrder extends MpBaseEntity {
|
public class TransferOrder extends MpBaseEntity implements EntityBaseFunction<TransferOrderDto> {
|
||||||
|
|
||||||
/** 商户转账号 */
|
/** 商户转账号 */
|
||||||
@DbMySqlIndex(comment = "商户转账号索引")
|
@DbMySqlIndex(comment = "商户转账号索引")
|
||||||
@@ -129,4 +132,8 @@ public class TransferOrder extends MpBaseEntity {
|
|||||||
@DbColumn(comment = "错误信息", length = 150)
|
@DbColumn(comment = "错误信息", length = 150)
|
||||||
private String errorMsg;
|
private String errorMsg;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TransferOrderDto toDto() {
|
||||||
|
return TransferOrderConvert.CONVERT.convert(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,18 +3,20 @@ package cn.daxpay.single.service.core.payment.pay.service;
|
|||||||
import cn.bootx.platform.common.core.util.CollUtil;
|
import cn.bootx.platform.common.core.util.CollUtil;
|
||||||
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||||
import cn.daxpay.single.code.PayChannelEnum;
|
import cn.daxpay.single.code.PayChannelEnum;
|
||||||
|
import cn.daxpay.single.code.PayOrderAllocStatusEnum;
|
||||||
import cn.daxpay.single.code.PayOrderRefundStatusEnum;
|
import cn.daxpay.single.code.PayOrderRefundStatusEnum;
|
||||||
|
import cn.daxpay.single.code.PayStatusEnum;
|
||||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
import cn.daxpay.single.param.payment.pay.PayParam;
|
import cn.daxpay.single.param.payment.pay.PayParam;
|
||||||
import cn.daxpay.single.result.pay.PayResult;
|
import cn.daxpay.single.result.pay.PayResult;
|
||||||
import cn.daxpay.single.service.common.context.PayLocal;
|
import cn.daxpay.single.service.common.context.PayLocal;
|
||||||
import cn.daxpay.single.service.common.context.PlatformLocal;
|
import cn.daxpay.single.service.common.context.PlatformLocal;
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
import cn.daxpay.single.service.core.order.pay.builder.PayBuilder;
|
|
||||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||||
import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService;
|
import cn.daxpay.single.service.core.order.pay.service.PayOrderQueryService;
|
||||||
import cn.daxpay.single.service.core.order.pay.service.PayOrderService;
|
import cn.daxpay.single.service.core.order.pay.service.PayOrderService;
|
||||||
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
|
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
|
||||||
|
import cn.daxpay.single.util.OrderNoGenerateUtil;
|
||||||
import cn.daxpay.single.util.PayUtil;
|
import cn.daxpay.single.util.PayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -46,54 +48,37 @@ public class PayAssistService {
|
|||||||
|
|
||||||
private final PayOrderQueryService payOrderQueryService;
|
private final PayOrderQueryService payOrderQueryService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化支付相关上下文
|
|
||||||
*/
|
|
||||||
public void initPayContext(PayOrder order, PayParam payParam) {
|
|
||||||
// 初始化支付订单超时时间
|
|
||||||
this.initExpiredTime(order, payParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化支付订单超时时间
|
|
||||||
* 1. 如果支付记录为空, 超时时间读取顺序 PayParam -> 平台设置
|
|
||||||
* 2. 如果支付记录不为空, 超时时间通过支付记录进行反推
|
|
||||||
*/
|
|
||||||
public void initExpiredTime(PayOrder order, PayParam payParam) {
|
|
||||||
// 钱包没有超时时间
|
|
||||||
if (PayChannelEnum.WALLET.getCode()
|
|
||||||
.equals(payParam.getChannel())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PayLocal payInfo = PaymentContextLocal.get()
|
|
||||||
.getPayInfo();
|
|
||||||
PlatformLocal platform = PaymentContextLocal.get()
|
|
||||||
.getPlatformInfo();
|
|
||||||
// 支付订单是非为空
|
|
||||||
if (Objects.nonNull(order)) {
|
|
||||||
payInfo.setExpiredTime(order.getExpiredTime());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 支付参数传入
|
|
||||||
if (Objects.nonNull(payParam.getExpiredTime())) {
|
|
||||||
payInfo.setExpiredTime(payParam.getExpiredTime());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 读取本地时间
|
|
||||||
LocalDateTime paymentExpiredTime = PayUtil.getPaymentExpiredTime(platform.getOrderTimeout());
|
|
||||||
payInfo.setExpiredTime(paymentExpiredTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建支付订单并保存, 返回支付订单
|
* 创建支付订单并保存, 返回支付订单
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public PayOrder createPayOrder(PayParam payParam) {
|
public PayOrder createPayOrder(PayParam payParam) {
|
||||||
PayLocal payInfo = PaymentContextLocal.get()
|
// 订单超时时间
|
||||||
.getPayInfo();
|
LocalDateTime expiredTime = this.getExpiredTime(payParam);
|
||||||
// 构建支付订单并保存
|
// 构建支付订单对象
|
||||||
PayOrder order = PayBuilder.buildPayOrder(payParam);
|
PayOrder order = new PayOrder()
|
||||||
|
.setBizOrderNo(payParam.getBizOrderNo())
|
||||||
|
.setOrderNo(OrderNoGenerateUtil.pay())
|
||||||
|
.setTitle(payParam.getTitle())
|
||||||
|
.setDescription(payParam.getDescription())
|
||||||
|
.setStatus(PayStatusEnum.PROGRESS.getCode())
|
||||||
|
.setRefundStatus(PayOrderRefundStatusEnum.NO_REFUND.getCode())
|
||||||
|
.setAllocation(payParam.getAllocation())
|
||||||
|
.setAmount(payParam.getAmount())
|
||||||
|
.setChannel(payParam.getChannel())
|
||||||
|
.setMethod(payParam.getMethod())
|
||||||
|
.setExpiredTime(expiredTime)
|
||||||
|
.setRefundableBalance(payParam.getAmount())
|
||||||
|
.setClientIp(payParam.getClientIp())
|
||||||
|
.setNotifyUrl(payParam.getNotifyUrl())
|
||||||
|
.setReturnUrl(payParam.getReturnUrl())
|
||||||
|
.setAttach(payParam.getAttach())
|
||||||
|
.setReqTime(payParam.getReqTime());
|
||||||
|
// 如果支持分账, 设置分账状态为待分账
|
||||||
|
if (order.getAllocation()) {
|
||||||
|
order.setAllocStatus(PayOrderAllocStatusEnum.WAITING.getCode());
|
||||||
|
}
|
||||||
payOrderService.save(order);
|
payOrderService.save(order);
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@@ -187,12 +172,28 @@ public class PayAssistService {
|
|||||||
payResult.setStatus(payOrder.getStatus());
|
payResult.setStatus(payOrder.getStatus());
|
||||||
|
|
||||||
// 设置支付参数
|
// 设置支付参数
|
||||||
PayLocal payInfo = PaymentContextLocal.get()
|
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();
|
||||||
.getPayInfo();
|
|
||||||
if (StrUtil.isNotBlank(payInfo.getPayBody())) {
|
if (StrUtil.isNotBlank(payInfo.getPayBody())) {
|
||||||
payResult.setPayBody(payInfo.getPayBody());
|
payResult.setPayBody(payInfo.getPayBody());
|
||||||
}
|
}
|
||||||
// 签名
|
|
||||||
return payResult;
|
return payResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取支付订单超时时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime getExpiredTime(PayParam payParam) {
|
||||||
|
// 钱包没有超时时间
|
||||||
|
if (PayChannelEnum.WALLET.getCode()
|
||||||
|
.equals(payParam.getChannel())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PlatformLocal platform = PaymentContextLocal.get().getPlatformInfo();
|
||||||
|
// 支付参数传入
|
||||||
|
if (Objects.nonNull(payParam.getExpiredTime())) {
|
||||||
|
return payParam.getExpiredTime();
|
||||||
|
}
|
||||||
|
// 根据平台配置计算出
|
||||||
|
return PayUtil.getPaymentExpiredTime(platform.getOrderTimeout());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService;
|
|||||||
import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService;
|
import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService;
|
||||||
import cn.daxpay.single.service.func.AbsPayStrategy;
|
import cn.daxpay.single.service.func.AbsPayStrategy;
|
||||||
import cn.daxpay.single.service.util.PayStrategyFactory;
|
import cn.daxpay.single.service.util.PayStrategyFactory;
|
||||||
import cn.daxpay.single.util.PayUtil;
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.baomidou.lock.LockInfo;
|
import com.baomidou.lock.LockInfo;
|
||||||
import com.baomidou.lock.LockTemplate;
|
import com.baomidou.lock.LockTemplate;
|
||||||
@@ -66,8 +65,6 @@ public class PayService {
|
|||||||
try {
|
try {
|
||||||
// 查询并检查订单
|
// 查询并检查订单
|
||||||
PayOrder payOrder = payAssistService.getOrderAndCheck(payParam.getBizOrderNo());
|
PayOrder payOrder = payAssistService.getOrderAndCheck(payParam.getBizOrderNo());
|
||||||
// 初始化支付上下文
|
|
||||||
payAssistService.initPayContext(payOrder, payParam);
|
|
||||||
// 走首次下单逻辑还是重复下档逻辑
|
// 走首次下单逻辑还是重复下档逻辑
|
||||||
if (Objects.isNull(payOrder)){
|
if (Objects.isNull(payOrder)){
|
||||||
return this.firstPay(payParam);
|
return this.firstPay(payParam);
|
||||||
|
@@ -7,6 +7,7 @@ import cn.daxpay.single.code.RefundStatusEnum;
|
|||||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
import cn.daxpay.single.param.payment.refund.RefundParam;
|
import cn.daxpay.single.param.payment.refund.RefundParam;
|
||||||
import cn.daxpay.single.result.pay.RefundResult;
|
import cn.daxpay.single.result.pay.RefundResult;
|
||||||
|
import cn.daxpay.single.service.common.context.ErrorInfoLocal;
|
||||||
import cn.daxpay.single.service.common.context.PlatformLocal;
|
import cn.daxpay.single.service.common.context.PlatformLocal;
|
||||||
import cn.daxpay.single.service.common.context.RefundLocal;
|
import cn.daxpay.single.service.common.context.RefundLocal;
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
@@ -117,8 +118,9 @@ public class RefundAssistService {
|
|||||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||||
public void updateOrderByError(RefundOrder refundOrder){
|
public void updateOrderByError(RefundOrder refundOrder){
|
||||||
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
|
||||||
refundOrder.setErrorCode(refundInfo.getErrorCode());
|
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||||
refundOrder.setErrorMsg(refundInfo.getErrorMsg());
|
refundOrder.setErrorCode(errorInfo.getErrorCode());
|
||||||
|
refundOrder.setErrorMsg(errorInfo.getErrorMsg());
|
||||||
refundOrder.setStatus(refundInfo.getStatus().getCode());
|
refundOrder.setStatus(refundInfo.getStatus().getCode());
|
||||||
refundOrderManager.updateById(refundOrder);
|
refundOrderManager.updateById(refundOrder);
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,8 @@ package cn.daxpay.single.service.core.payment.transfer.service;
|
|||||||
import cn.daxpay.single.code.TransferStatusEnum;
|
import cn.daxpay.single.code.TransferStatusEnum;
|
||||||
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
||||||
import cn.daxpay.single.result.transfer.TransferResult;
|
import cn.daxpay.single.result.transfer.TransferResult;
|
||||||
|
import cn.daxpay.single.service.common.context.ErrorInfoLocal;
|
||||||
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
import cn.daxpay.single.service.core.order.transfer.dao.TransferOrderManager;
|
import cn.daxpay.single.service.core.order.transfer.dao.TransferOrderManager;
|
||||||
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
||||||
import cn.daxpay.single.util.OrderNoGenerateUtil;
|
import cn.daxpay.single.util.OrderNoGenerateUtil;
|
||||||
@@ -52,8 +54,11 @@ public class TransferAssistService {
|
|||||||
* 更新转账订单错误信息
|
* 更新转账订单错误信息
|
||||||
*/
|
*/
|
||||||
public void updateOrderByError(TransferOrder order) {
|
public void updateOrderByError(TransferOrder order) {
|
||||||
order.setErrorMsg("")
|
ErrorInfoLocal errorInfo = PaymentContextLocal.get().getErrorInfo();
|
||||||
.setErrorCode("");
|
order.setStatus(TransferStatusEnum.FAIL.getCode())
|
||||||
|
.setErrorMsg(errorInfo.getErrorMsg())
|
||||||
|
.setErrorCode(errorInfo.getErrorCode());
|
||||||
|
transferOrderManager.updateById(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -4,6 +4,7 @@ import cn.daxpay.single.code.RefundStatusEnum;
|
|||||||
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
||||||
import cn.daxpay.single.result.transfer.TransferResult;
|
import cn.daxpay.single.result.transfer.TransferResult;
|
||||||
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
import cn.daxpay.single.service.common.local.PaymentContextLocal;
|
||||||
|
import cn.daxpay.single.service.core.order.transfer.dao.TransferOrderManager;
|
||||||
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
|
||||||
import cn.daxpay.single.service.func.AbsTransferStrategy;
|
import cn.daxpay.single.service.func.AbsTransferStrategy;
|
||||||
import cn.daxpay.single.service.util.PayStrategyFactory;
|
import cn.daxpay.single.service.util.PayStrategyFactory;
|
||||||
@@ -11,6 +12,8 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转账服务
|
* 转账服务
|
||||||
@@ -24,6 +27,8 @@ public class TransferService {
|
|||||||
|
|
||||||
private final TransferAssistService transferAssistService;
|
private final TransferAssistService transferAssistService;
|
||||||
|
|
||||||
|
private final TransferOrderManager transferOrderManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转账
|
* 转账
|
||||||
*/
|
*/
|
||||||
@@ -56,8 +61,9 @@ public class TransferService {
|
|||||||
/**
|
/**
|
||||||
* 成功处理
|
* 成功处理
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||||
public void successHandler(TransferOrder order){
|
public void successHandler(TransferOrder order){
|
||||||
|
order.setStatus(RefundStatusEnum.SUCCESS.getCode());
|
||||||
|
transferOrderManager.updateById(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
package cn.daxpay.single.service.core.payment.transfer.strategy;
|
package cn.daxpay.single.service.core.payment.transfer.strategy;
|
||||||
|
|
||||||
import cn.daxpay.single.code.PayChannelEnum;
|
import cn.daxpay.single.code.PayChannelEnum;
|
||||||
import cn.daxpay.single.service.core.channel.alipay.entity.AliPayConfig;
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
|
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
||||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService;
|
import cn.daxpay.single.service.core.channel.alipay.service.AliPayConfigService;
|
||||||
import cn.daxpay.single.service.core.channel.alipay.service.AliPayTransferService;
|
import cn.daxpay.single.service.core.channel.alipay.service.AliPayTransferService;
|
||||||
import cn.daxpay.single.service.func.AbsTransferStrategy;
|
import cn.daxpay.single.service.func.AbsTransferStrategy;
|
||||||
@@ -10,10 +11,13 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static cn.daxpay.single.code.TransferPayeeTypeEnum.*;
|
||||||
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝转账测策略
|
* 支付宝转账策略
|
||||||
* @author xxm
|
* @author xxm
|
||||||
* @since 2024/3/21
|
* @since 2024/3/21
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +31,6 @@ public class AliPayTransferStrategy extends AbsTransferStrategy {
|
|||||||
|
|
||||||
private final AliPayTransferService aliPayTransferService;
|
private final AliPayTransferService aliPayTransferService;
|
||||||
|
|
||||||
private AliPayConfig config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 策略标识
|
* 策略标识
|
||||||
@@ -37,15 +40,26 @@ public class AliPayTransferStrategy extends AbsTransferStrategy {
|
|||||||
return PayChannelEnum.ALI.getCode();
|
return PayChannelEnum.ALI.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doValidateParam(TransferParam transferParam) {
|
||||||
|
// 转账接收方类型校验
|
||||||
|
String payeeType = transferParam.getPayeeType();
|
||||||
|
if (!Arrays.asList(ALI_USER_ID.getCode(), ALI_OPEN_ID.getCode(), ALI_LOGIN_NAME.getCode()).contains(payeeType)){
|
||||||
|
throw new PayFailureException("支付宝不支持该类型收款人");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转账前操作
|
* 转账前操作
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doBeforeHandler() {
|
public void doBeforeHandler() {
|
||||||
this.config = payConfigService.getAndCheckConfig();
|
payConfigService.initConfig(payConfigService.getAndCheckConfig());
|
||||||
payConfigService.initConfig(this.config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账操作
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doTransferHandler() {
|
public void doTransferHandler() {
|
||||||
aliPayTransferService.transfer(this.getTransferOrder());
|
aliPayTransferService.transfer(this.getTransferOrder());
|
||||||
|
@@ -0,0 +1,71 @@
|
|||||||
|
package cn.daxpay.single.service.core.payment.transfer.strategy;
|
||||||
|
|
||||||
|
import cn.daxpay.single.code.PayChannelEnum;
|
||||||
|
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||||
|
import cn.daxpay.single.param.payment.transfer.TransferParam;
|
||||||
|
import cn.daxpay.single.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||||
|
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||||
|
import cn.daxpay.single.service.core.channel.wechat.service.WeChatPayTransferService;
|
||||||
|
import cn.daxpay.single.service.func.AbsTransferStrategy;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static cn.daxpay.single.code.TransferPayeeTypeEnum.WX_PERSONAL;
|
||||||
|
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信转账策略
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/6/14
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@Scope(SCOPE_PROTOTYPE)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WeChatTransferStrategy extends AbsTransferStrategy {
|
||||||
|
|
||||||
|
private final WeChatPayConfigService weChatPayConfigService;
|
||||||
|
|
||||||
|
private final WeChatPayTransferService weChatPayTransferService;
|
||||||
|
|
||||||
|
private WeChatPayConfig weChatPayConfig;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChannel() {
|
||||||
|
return PayChannelEnum.WECHAT.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doValidateParam(TransferParam transferParam) {
|
||||||
|
// 转账接收方类型校验
|
||||||
|
String payeeType = transferParam.getPayeeType();
|
||||||
|
if (!Objects.equals(WX_PERSONAL.getCode(), payeeType)){
|
||||||
|
throw new PayFailureException("支付宝不支持该类型收款人");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账前操作
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doBeforeHandler() {
|
||||||
|
this.weChatPayConfig = weChatPayConfigService.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账操作
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doTransferHandler() {
|
||||||
|
weChatPayTransferService.transfer(this.getTransferOrder(), weChatPayConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -105,13 +105,6 @@ public class PayOrderDto extends BaseDto {
|
|||||||
@Schema(description = "过期时间")
|
@Schema(description = "过期时间")
|
||||||
private LocalDateTime expiredTime;
|
private LocalDateTime expiredTime;
|
||||||
|
|
||||||
/** 错误码 */
|
|
||||||
@Schema(description = "错误码")
|
|
||||||
private String errorCode;
|
|
||||||
|
|
||||||
/** 错误信息 */
|
|
||||||
@Schema(description = "错误信息")
|
|
||||||
private String errorMsg;
|
|
||||||
|
|
||||||
/** 支付终端ip */
|
/** 支付终端ip */
|
||||||
@Schema(description = "支付终端ip")
|
@Schema(description = "支付终端ip")
|
||||||
@@ -128,4 +121,12 @@ public class PayOrderDto extends BaseDto {
|
|||||||
/** 请求时间,时间戳转时间, 以最后一次为准 */
|
/** 请求时间,时间戳转时间, 以最后一次为准 */
|
||||||
@Schema(description = "请求时间,传输时间戳,以最后一次为准")
|
@Schema(description = "请求时间,传输时间戳,以最后一次为准")
|
||||||
private LocalDateTime reqTime;
|
private LocalDateTime reqTime;
|
||||||
|
|
||||||
|
/** 错误码 */
|
||||||
|
@Schema(description = "错误码")
|
||||||
|
private String errorCode;
|
||||||
|
|
||||||
|
/** 错误信息 */
|
||||||
|
@Schema(description = "错误信息")
|
||||||
|
private String errorMsg;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,125 @@
|
|||||||
|
package cn.daxpay.single.service.dto.order.transfer;
|
||||||
|
|
||||||
|
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||||
|
import cn.daxpay.single.code.PayChannelEnum;
|
||||||
|
import cn.daxpay.single.code.TransferPayeeTypeEnum;
|
||||||
|
import cn.daxpay.single.code.TransferTypeEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账订单
|
||||||
|
* @author xxm
|
||||||
|
* @since 2024/6/14
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Schema(title = "转账订单")
|
||||||
|
public class TransferOrderDto extends BaseDto {
|
||||||
|
|
||||||
|
/** 商户转账号 */
|
||||||
|
@Schema(description = "商户转账号")
|
||||||
|
private String bizTransferNo;
|
||||||
|
|
||||||
|
/** 转账号 */
|
||||||
|
@Schema(description = "收款人账号")
|
||||||
|
private String transferNo;
|
||||||
|
|
||||||
|
/** 通道转账号 */
|
||||||
|
@Schema(description = "通道转账号")
|
||||||
|
private String outTransferNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付通道
|
||||||
|
* @see PayChannelEnum
|
||||||
|
*/
|
||||||
|
@Schema(description = "支付通道")
|
||||||
|
private String channel;
|
||||||
|
|
||||||
|
/** 转账金额 */
|
||||||
|
@Schema(description = "转账金额")
|
||||||
|
private Integer amount;
|
||||||
|
|
||||||
|
/** 标题 */
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/** 转账原因/备注 */
|
||||||
|
@Schema(description = "转账原因/备注")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转账类型, 微信使用
|
||||||
|
* @see TransferTypeEnum
|
||||||
|
*/
|
||||||
|
@Schema(description = "转账类型, 微信使用")
|
||||||
|
private String transferType;
|
||||||
|
|
||||||
|
/** 付款方 */
|
||||||
|
@Schema(description = "付款方")
|
||||||
|
private String payer;
|
||||||
|
|
||||||
|
/** 付款方显示名称 */
|
||||||
|
@Schema(description = "付款方显示名称")
|
||||||
|
private String payerShowName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款人类型
|
||||||
|
* @see TransferPayeeTypeEnum
|
||||||
|
*/
|
||||||
|
@Schema(description = "收款人类型")
|
||||||
|
private String payeeType;
|
||||||
|
|
||||||
|
/** 收款人账号 */
|
||||||
|
@Schema(description = "收款人账号")
|
||||||
|
private String payeeAccount;
|
||||||
|
|
||||||
|
/** 收款人姓名 */
|
||||||
|
@Schema(description = "收款人姓名")
|
||||||
|
private String payeeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
* @see cn.daxpay.single.code.TransferStatusEnum
|
||||||
|
*/
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 成功时间 */
|
||||||
|
@Schema(description = "成功时间")
|
||||||
|
private LocalDateTime successTime;
|
||||||
|
|
||||||
|
|
||||||
|
/** 异步通知地址 */
|
||||||
|
@Schema(description = "异步通知地址")
|
||||||
|
private String notifyUrl;
|
||||||
|
|
||||||
|
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
|
||||||
|
@Schema(description = "商户扩展参数")
|
||||||
|
private String attach;
|
||||||
|
|
||||||
|
/** 请求时间,时间戳转时间 */
|
||||||
|
@Schema(description = "请求时间,传输时间戳")
|
||||||
|
private LocalDateTime reqTime;
|
||||||
|
|
||||||
|
/** 终端ip */
|
||||||
|
@Schema(description = "支付终端ip")
|
||||||
|
private String clientIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误码
|
||||||
|
*/
|
||||||
|
@Schema(description = "错误码")
|
||||||
|
private String errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误原因
|
||||||
|
*/
|
||||||
|
@Schema(description = "错误原因")
|
||||||
|
private String errorMsg;
|
||||||
|
}
|
@@ -20,6 +20,7 @@ public abstract class AbsTransferStrategy implements PayStrategy{
|
|||||||
* 校验参数
|
* 校验参数
|
||||||
*/
|
*/
|
||||||
public void doValidateParam(TransferParam transferParam) {
|
public void doValidateParam(TransferParam transferParam) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user