mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-09 13:59:05 +00:00
ref 调整查询和回调通知接口
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package cn.daxpay.single.service.core.order.pay.convert;
|
||||
|
||||
import cn.daxpay.single.result.order.PayOrderResult;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.PayNoticeResult;
|
||||
import cn.daxpay.single.service.dto.order.pay.PayOrderDto;
|
||||
import cn.daxpay.single.service.dto.order.pay.PayOrderExtraDto;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -20,4 +22,7 @@ public interface PayOrderConvert {
|
||||
|
||||
PayOrderDto convert(PayOrder in);
|
||||
|
||||
PayOrderResult convertResult(PayOrder in);
|
||||
|
||||
PayNoticeResult convertNotice(PayOrder order);
|
||||
}
|
||||
|
@@ -1,19 +1,17 @@
|
||||
package cn.daxpay.single.service.core.order.pay.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.exception.ValidationFailedException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.pay.QueryPayParam;
|
||||
import cn.daxpay.single.result.order.PayOrderResult;
|
||||
import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert;
|
||||
import cn.daxpay.single.service.core.order.pay.dao.PayOrderExtraManager;
|
||||
import cn.daxpay.single.service.core.order.pay.dao.PayOrderManager;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.dto.order.pay.PayOrderDto;
|
||||
import cn.daxpay.single.service.param.order.PayOrderQuery;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -83,17 +81,15 @@ public class PayOrderQueryService {
|
||||
public PayOrderResult queryPayOrder(QueryPayParam param) {
|
||||
// 校验参数
|
||||
if (StrUtil.isBlank(param.getBizOrderNoeNo()) && Objects.isNull(param.getOrderNo())){
|
||||
throw new ValidationFailedException("业务号或支付单ID不能都为空");
|
||||
throw new PayFailureException("业务号或支付单ID不能都为空");
|
||||
}
|
||||
// 查询支付单
|
||||
PayOrder payOrder = this.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNoeNo())
|
||||
.orElseThrow(() -> new DataNotExistException("未查询到支付订单"));
|
||||
.orElseThrow(() -> new PayFailureException("未查询到支付订单"));
|
||||
// 查询扩展数据
|
||||
payOrderExtraManager.findById(payOrder.getId())
|
||||
.orElseThrow(() -> new PayFailureException("支付订单不完整"));
|
||||
PayOrderResult payOrderResult = new PayOrderResult();
|
||||
BeanUtil.copyProperties(payOrder, payOrderResult);
|
||||
return payOrderResult;
|
||||
return PayOrderConvert.CONVERT.convertResult(payOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@ package cn.daxpay.single.service.core.order.refund.convert;
|
||||
import cn.daxpay.single.result.order.RefundOrderResult;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.RefundNoticeResult;
|
||||
import cn.daxpay.single.service.dto.order.refund.RefundOrderDto;
|
||||
import cn.daxpay.single.service.dto.order.refund.RefundOrderExtraDto;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -23,5 +24,5 @@ public interface RefundOrderConvert {
|
||||
|
||||
RefundOrderResult convertResult(RefundOrder in);
|
||||
|
||||
|
||||
RefundNoticeResult convertNotice(RefundOrder order);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class RefundOrder extends MpBaseEntity implements EntityBaseFunction<Refu
|
||||
private String bizOrderNo;
|
||||
|
||||
/** 通道支付订单号 */
|
||||
@DbColumn(comment = "商户支付订单号")
|
||||
@DbColumn(comment = "通道支付订单号")
|
||||
private String outOrderNo;
|
||||
|
||||
/** 支付标题 */
|
||||
@@ -51,12 +51,12 @@ public class RefundOrder extends MpBaseEntity implements EntityBaseFunction<Refu
|
||||
@DbColumn(comment = "退款号")
|
||||
private String refundNo;
|
||||
|
||||
/** 商户退款号 */
|
||||
@DbColumn(comment = "商户退款号")
|
||||
private String bizRefundNo;
|
||||
|
||||
|
||||
/** 三方支付系统退款交易号 */
|
||||
@DbColumn(comment = "三方支付系统退款交易号")
|
||||
/** 通道退款交易号 */
|
||||
@DbColumn(comment = "通道退款交易号")
|
||||
private String outRefundNo;
|
||||
|
||||
/**
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package cn.daxpay.single.service.core.order.refund.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.exception.ValidationFailedException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.daxpay.single.exception.pay.PayFailureException;
|
||||
import cn.daxpay.single.param.payment.refund.QueryRefundParam;
|
||||
import cn.daxpay.single.result.order.RefundOrderResult;
|
||||
import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert;
|
||||
@@ -89,18 +89,11 @@ public class RefundOrderQueryService {
|
||||
public RefundOrderResult queryRefundOrder(QueryRefundParam param) {
|
||||
// 校验参数
|
||||
if (StrUtil.isBlank(param.getRefundNo()) && Objects.isNull(param.getBizRefundNo())){
|
||||
throw new ValidationFailedException("退款号或退款ID不能都为空");
|
||||
throw new PayFailureException("退款号或=商户退款号不能都为空");
|
||||
}
|
||||
// 查询退款单
|
||||
RefundOrder refundOrder = null;
|
||||
if (Objects.nonNull(param.getRefundNo())){
|
||||
refundOrder = refundOrderManager.findById(param.getRefundNo())
|
||||
.orElseThrow(() -> new DataNotExistException("未查询到支付订单"));
|
||||
}
|
||||
if (Objects.isNull(refundOrder)){
|
||||
refundOrder = refundOrderManager.findByRefundNo(param.getRefundNo())
|
||||
.orElseThrow(() -> new DataNotExistException("未查询到支付订单"));
|
||||
}
|
||||
RefundOrder refundOrder = this.findByBizOrRefundNo(param.getRefundNo(), param.getBizRefundNo())
|
||||
.orElseThrow(() -> new PayFailureException("退款订单不存在"));
|
||||
|
||||
return RefundOrderConvert.CONVERT.convertResult(refundOrder);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.daxpay.single.service.core.payment.notice.result;
|
||||
|
||||
import cn.daxpay.single.code.PayChannelEnum;
|
||||
import cn.daxpay.single.code.PayOrderAllocStatusEnum;
|
||||
import cn.daxpay.single.code.PayStatusEnum;
|
||||
import cn.daxpay.single.result.PaymentCommonResult;
|
||||
import cn.daxpay.single.serializer.LocalDateTimeToTimestampSerializer;
|
||||
@@ -23,33 +24,54 @@ import java.time.LocalDateTime;
|
||||
@Schema(title = "支付异步通知类")
|
||||
public class PayNoticeResult extends PaymentCommonResult {
|
||||
|
||||
/** 订单号 */
|
||||
@Schema(description = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
/** 商户订单号 */
|
||||
@Schema(description = "商户订单号")
|
||||
private String bizOrderNo;
|
||||
|
||||
@Schema(description = "支付订单号")
|
||||
private String orderNo;
|
||||
|
||||
/** 通道系统交易号 */
|
||||
@Schema(description = "通道支付订单号")
|
||||
private String outOrderNo;
|
||||
|
||||
/** 标题 */
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
/** 描述 */
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
/** 是否支持分账 */
|
||||
@Schema(description = "是否需要分账")
|
||||
private Boolean allocation;
|
||||
|
||||
/** 是否开启自动分账, 不传输为不开启 */
|
||||
@Schema(description = "是否开启自动分账")
|
||||
private Boolean autoAllocation;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* @see PayChannelEnum
|
||||
*/
|
||||
@Schema(description = "支付通道")
|
||||
@Schema(description = "异步支付通道")
|
||||
private String channel;
|
||||
|
||||
/** 支付方式 */
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
@Schema(description = "支付方式")
|
||||
private String method;
|
||||
|
||||
/** 支付金额 */
|
||||
@Schema(description = "支付金额")
|
||||
/** 金额 */
|
||||
@Schema(description = "金额")
|
||||
private Integer amount;
|
||||
|
||||
/** 可退款余额 */
|
||||
@Schema(description = "可退款余额")
|
||||
private Integer refundableBalance;
|
||||
|
||||
/**
|
||||
* 支付状态
|
||||
* @see PayStatusEnum
|
||||
@@ -57,23 +79,38 @@ public class PayNoticeResult extends PaymentCommonResult {
|
||||
@Schema(description = "支付状态")
|
||||
private String status;
|
||||
|
||||
/** 支付成功时间 */
|
||||
@Schema(description = "支付成功时间")
|
||||
/**
|
||||
* 分账状态
|
||||
* @see PayOrderAllocStatusEnum
|
||||
*/
|
||||
@Schema(description = "分账状态")
|
||||
private String allocationStatus;
|
||||
|
||||
/** 支付时间 */
|
||||
@Schema(description = "支付时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime payTime;
|
||||
|
||||
/** 支付关闭时间 */
|
||||
@Schema(description = "支付关闭时间")
|
||||
/** 过期时间 */
|
||||
@Schema(description = "过期时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime expiredTime;
|
||||
|
||||
/** 关闭时间 */
|
||||
@Schema(description = "关闭时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime closeTime;
|
||||
|
||||
/** 支付创建时间 */
|
||||
@Schema(description = "支付创建时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
@Schema(description = "商户扩展参数,回调时会原样返回")
|
||||
private String attach;
|
||||
|
||||
/** 错误码 */
|
||||
@Schema(description = "错误码")
|
||||
private String errorCode;
|
||||
|
||||
/** 错误原因 */
|
||||
@Schema(description = "错误原因")
|
||||
private String errorMsg;
|
||||
|
||||
}
|
||||
|
@@ -23,6 +23,22 @@ import java.time.LocalDateTime;
|
||||
@Schema(title = "退款通知消息")
|
||||
public class RefundNoticeResult extends PaymentCommonResult {
|
||||
|
||||
/** 支付订单号 */
|
||||
@Schema(description = "支付订单号")
|
||||
private String orderNo;
|
||||
|
||||
/** 商户支付订单号 */
|
||||
@Schema(description = "商户支付订单号")
|
||||
private String bizOrderNo;
|
||||
|
||||
/** 通道支付订单号 */
|
||||
@Schema(description = "通道支付订单号")
|
||||
private String outOrderNo;
|
||||
|
||||
/** 支付标题 */
|
||||
@Schema(description = "支付标题")
|
||||
private String title;
|
||||
|
||||
/** 退款号 */
|
||||
@Schema(description = "退款号")
|
||||
private String refundNo;
|
||||
@@ -31,17 +47,39 @@ public class RefundNoticeResult extends PaymentCommonResult {
|
||||
@Schema(description = "商户退款号")
|
||||
private String bizRefundNo;
|
||||
|
||||
/** 通道退款交易号 */
|
||||
@Schema(description = "通道退款交易号")
|
||||
private String outRefundNo;
|
||||
|
||||
/**
|
||||
* 支付通道
|
||||
* 退款通道
|
||||
* @see PayChannelEnum
|
||||
*/
|
||||
@Schema(description = "支付通道")
|
||||
private String channel;
|
||||
|
||||
/** 订单金额 */
|
||||
@Schema(description = "订单金额")
|
||||
private Integer orderAmount;
|
||||
|
||||
/** 退款金额 */
|
||||
@Schema(description = "退款金额")
|
||||
private Integer amount;
|
||||
|
||||
/** 退款原因 */
|
||||
@Schema(description = "退款原因")
|
||||
private String reason;
|
||||
|
||||
/** 退款发起时间 */
|
||||
@Schema(description = "退款发起时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime refundTime;
|
||||
|
||||
/** 退款完成时间 */
|
||||
@Schema(description = "退款完成时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @see RefundStatusEnum
|
||||
@@ -49,17 +87,15 @@ public class RefundNoticeResult extends PaymentCommonResult {
|
||||
@Schema(description = "退款状态")
|
||||
private String status;
|
||||
|
||||
/** 退款成功时间 */
|
||||
@Schema(description = "退款成功时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/** 退款创建时间 */
|
||||
@Schema(description = "退款创建时间")
|
||||
@JsonSerialize(using = LocalDateTimeToTimestampSerializer.class)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 商户扩展参数,回调时会原样返回 */
|
||||
@Schema(description = "商户扩展参数,回调时会原样返回")
|
||||
private String attach;
|
||||
|
||||
/** 错误码 */
|
||||
@Schema(description = "错误码")
|
||||
private String errorCode;
|
||||
|
||||
/** 错误信息 */
|
||||
@Schema(description = "错误信息")
|
||||
private String errorMsg;
|
||||
}
|
||||
|
@@ -2,8 +2,10 @@ package cn.daxpay.single.service.core.payment.notice.service;
|
||||
|
||||
import cn.bootx.platform.common.jackson.util.JacksonUtil;
|
||||
import cn.daxpay.single.service.code.ClientNoticeTypeEnum;
|
||||
import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
|
||||
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
|
||||
import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
|
||||
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
|
||||
import cn.daxpay.single.service.core.payment.common.service.PaymentAssistService;
|
||||
@@ -35,19 +37,8 @@ public class ClientNoticeAssistService {
|
||||
public ClientNoticeTask buildPayTask(PayOrder order, PayOrderExtra orderExtra){
|
||||
// 获取系统签名
|
||||
paymentAssistService.initPlatform();
|
||||
PayNoticeResult payNoticeResult = new PayNoticeResult()
|
||||
.setOrderNo(order.getOrderNo())
|
||||
.setBizOrderNo(order.getBizOrderNo())
|
||||
.setTitle(order.getTitle())
|
||||
.setChannel(order.getChannel())
|
||||
.setMethod(order.getMethod())
|
||||
.setAmount(order.getAmount())
|
||||
.setPayTime(order.getPayTime())
|
||||
.setCloseTime(order.getCloseTime())
|
||||
.setCreateTime(order.getCreateTime())
|
||||
.setStatus(order.getStatus())
|
||||
.setAttach(orderExtra.getAttach());
|
||||
|
||||
PayNoticeResult payNoticeResult = PayOrderConvert.CONVERT.convertNotice(order);
|
||||
payNoticeResult.setAttach(orderExtra.getAttach());
|
||||
paymentSignService.sign(payNoticeResult);
|
||||
return new ClientNoticeTask()
|
||||
.setUrl(orderExtra.getNotifyUrl())
|
||||
@@ -67,22 +58,15 @@ public class ClientNoticeAssistService {
|
||||
// 获取系统签名
|
||||
paymentAssistService.initPlatform();
|
||||
// 创建退款通知内容
|
||||
RefundNoticeResult payNoticeResult = new RefundNoticeResult()
|
||||
.setRefundNo(order.getRefundNo())
|
||||
.setBizRefundNo(order.getBizRefundNo())
|
||||
.setChannel(order.getChannel())
|
||||
.setAmount(order.getAmount())
|
||||
.setFinishTime(order.getFinishTime())
|
||||
.setCreateTime(order.getCreateTime())
|
||||
.setStatus(order.getStatus())
|
||||
.setAttach(orderExtra.getAttach());
|
||||
RefundNoticeResult refundNoticeResult = RefundOrderConvert.CONVERT.convertNotice(order);
|
||||
refundNoticeResult.setAttach(orderExtra.getAttach());
|
||||
|
||||
// 签名
|
||||
paymentSignService.sign(payNoticeResult);
|
||||
paymentSignService.sign(refundNoticeResult);
|
||||
return new ClientNoticeTask()
|
||||
.setUrl(orderExtra.getNotifyUrl())
|
||||
// 时间序列化进行了重写
|
||||
.setContent(JacksonUtil.toJson(payNoticeResult))
|
||||
.setContent(JacksonUtil.toJson(refundNoticeResult))
|
||||
.setNoticeType(ClientNoticeTypeEnum.REFUND.getType())
|
||||
.setSendCount(0)
|
||||
.setTradeId(order.getId())
|
||||
|
@@ -2,15 +2,17 @@ package cn.daxpay.single.service.core.task.notice.entity;
|
||||
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.daxpay.single.code.PayStatusEnum;
|
||||
import cn.daxpay.single.code.RefundStatusEnum;
|
||||
import cn.daxpay.single.service.code.ClientNoticeTypeEnum;
|
||||
import cn.daxpay.single.service.core.task.notice.convert.ClientNoticeConvert;
|
||||
import cn.daxpay.single.service.dto.record.notice.ClientNoticeTaskDto;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
import cn.bootx.table.modify.annotation.DbTable;
|
||||
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
|
||||
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
|
||||
import cn.daxpay.single.code.PayStatusEnum;
|
||||
import cn.daxpay.single.code.RefundStatusEnum;
|
||||
import cn.daxpay.single.service.code.ClientNoticeTypeEnum;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.PayNoticeResult;
|
||||
import cn.daxpay.single.service.core.payment.notice.result.RefundNoticeResult;
|
||||
import cn.daxpay.single.service.core.task.notice.convert.ClientNoticeConvert;
|
||||
import cn.daxpay.single.service.dto.record.notice.ClientNoticeTaskDto;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -53,7 +55,11 @@ public class ClientNoticeTask extends MpBaseEntity implements EntityBaseFunction
|
||||
@DbColumn(comment = "交易状态")
|
||||
private String tradeStatus;
|
||||
|
||||
/** 消息内容 */
|
||||
/**
|
||||
* 消息内容
|
||||
* @see PayNoticeResult
|
||||
* @see RefundNoticeResult
|
||||
*/
|
||||
@DbColumn(comment = "消息内容")
|
||||
@DbMySqlFieldType(MySqlFieldTypeEnum.LONGTEXT)
|
||||
private String content;
|
||||
|
@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "具体支付日志基类")
|
||||
@Schema(title = "支付订单")
|
||||
public class PayOrderDto extends BaseDto {
|
||||
|
||||
/** 商户订单号 */
|
||||
|
@@ -30,6 +30,10 @@ public class RefundOrderDto extends BaseDto {
|
||||
@Schema(description = "支付订单号")
|
||||
private String orderNo;
|
||||
|
||||
/** 通道支付订单号 */
|
||||
@Schema(description = "通道支付订单号")
|
||||
private String outOrderNo;
|
||||
|
||||
/** 商户支付订单号 */
|
||||
@Schema(description = "商户支付订单号")
|
||||
private String bizOrderNo;
|
||||
@@ -42,11 +46,12 @@ public class RefundOrderDto extends BaseDto {
|
||||
@Schema(description = "退款号")
|
||||
private String refundNo;
|
||||
|
||||
/** 商户退款号 */
|
||||
@Schema(description = "商户退款号")
|
||||
private String bizRefundNo;
|
||||
|
||||
/** 三方支付系统退款交易号 */
|
||||
@Schema(description = "三方支付系统退款交易号")
|
||||
/** 通道退款交易号 */
|
||||
@Schema(description = "通道退款交易号")
|
||||
private String outRefundNo;
|
||||
|
||||
/**
|
||||
|
@@ -27,8 +27,8 @@ public class RefundOrderQuery extends QueryOrder {
|
||||
@Schema(description = "商户退款号")
|
||||
private String bizRefundNo;
|
||||
|
||||
/** 三方支付系统退款交易号 */
|
||||
@Schema(description = "三方支付系统退款交易号")
|
||||
/** 通道退款交易号 */
|
||||
@Schema(description = "通道退款交易号")
|
||||
private String outRefundNo;
|
||||
|
||||
/** 支付订单ID */
|
||||
|
Reference in New Issue
Block a user