ref 去除NotNotify字段, 各类型订单扩展合并到订单对象中

This commit is contained in:
DaxPay
2024-06-11 16:11:05 +08:00
parent 5b49ff70dc
commit b2b9e98583
70 changed files with 372 additions and 929 deletions

View File

@@ -1,7 +1,5 @@
package cn.daxpay.single.service.common.context;
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -35,10 +33,4 @@ public class PayLocal {
/** 订单超时时间, */
private LocalDateTime expiredTime;
/** 支付订单 */
private PayOrder payOrder;
/** 支付订单扩展 */
private PayOrderExtra payOrderExtra;
}

View File

@@ -2,7 +2,6 @@ package cn.daxpay.single.service.common.context;
import cn.daxpay.single.code.RefundStatusEnum;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -38,7 +37,4 @@ public class RefundLocal {
/** 退款完成时间 */
private LocalDateTime finishTime;
/** 退款订单扩展 */
private RefundOrderExtra runOrderExtra;
}

View File

@@ -4,12 +4,10 @@ import cn.daxpay.single.result.order.AllocOrderDetailResult;
import cn.daxpay.single.result.order.AllocOrderResult;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.payment.notice.result.AllocDetailNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.AllocNoticeResult;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -24,8 +22,6 @@ public interface AllocationConvert {
AllocationOrderDto convert(AllocationOrder in);
AllocationOrderExtraDto convert(AllocationOrderExtra in);
AllocOrderResult toResult(AllocationOrder in);
AllocOrderDetailResult toResult(AllocationOrderDetail in);

View File

@@ -1,18 +0,0 @@
package cn.daxpay.single.service.core.order.allocation.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
* 分账订单扩展
* @author xxm
* @since 2024/5/22
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class AllocationOrderExtraManager extends BaseManager<AllocationOrderExtraMapper, AllocationOrderExtra> {
}

View File

@@ -1,14 +0,0 @@
package cn.daxpay.single.service.core.order.allocation.dao;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 分账订单扩展
* @author xxm
* @since 2024/5/22
*/
@Mapper
public interface AllocationOrderExtraMapper extends BaseMapper<AllocationOrderExtra> {
}

View File

@@ -109,6 +109,27 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction<
@DbColumn(comment = "处理结果")
private String result;
/** 分账完成时间 */
@DbColumn(comment = "分账完成时间")
private LocalDateTime finishTime;
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
/**
* 错误码
*/
@@ -123,10 +144,6 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction<
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String errorMsg;
/** 分账完成时间 */
@DbColumn(comment = "分账完成时间")
private LocalDateTime finishTime;
/**
* 转换
*/

View File

@@ -1,51 +0,0 @@
package cn.daxpay.single.service.core.order.allocation.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 分账订单扩展
* @author xxm
* @since 2024/5/22
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "分账订单扩展")
@TableName("pay_allocation_order_extra")
public class AllocationOrderExtra extends MpBaseEntity implements EntityBaseFunction<AllocationOrderExtraDto> {
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
@Override
public AllocationOrderExtraDto toDto() {
return AllocationConvert.CONVERT.convert(this);
}
}

View File

@@ -8,14 +8,11 @@ import cn.bootx.platform.common.core.util.ResultConvertUtil;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDetailDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderDto;
import cn.daxpay.single.service.dto.order.allocation.AllocationOrderExtraDto;
import cn.daxpay.single.service.param.order.AllocationOrderQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -35,8 +32,8 @@ import java.util.List;
public class AllocationOrderQueryService {
private final AllocationOrderDetailManager allocationOrderDetailManager;
private final AllocationOrderManager allocationOrderManager;
private final AllocationOrderExtraManager allocationOrderExtraManager;
/**
* 获取可以分账的通道
@@ -83,11 +80,4 @@ public class AllocationOrderQueryService {
return allocationOrderDetailManager.findById(id).map(AllocationOrderDetail::toDto).orElseThrow(() -> new DataNotExistException("分账订单明细不存在"));
}
/**
* 查询扩展订单信息
*/
public AllocationOrderExtraDto findExtraById(Long id) {
return allocationOrderExtraManager.findById(id).map(AllocationOrderExtra::toDto)
.orElseThrow(() -> new DataNotExistException("未找到"));
}
}

View File

@@ -7,11 +7,9 @@ import cn.daxpay.single.exception.pay.PayFailureException;
import cn.daxpay.single.param.payment.allocation.AllocReceiverParam;
import cn.daxpay.single.param.payment.allocation.AllocationParam;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.order.allocation.entity.OrderAndDetail;
import cn.daxpay.single.service.core.order.pay.dao.PayOrderManager;
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
@@ -50,8 +48,6 @@ public class AllocationOrderService {
private final PayOrderManager payOrderManager;
private final AllocationOrderExtraManager allocationOrderExtraManager;
/**
* 生成分账订单, 根据分账组创建
@@ -167,7 +163,10 @@ public class AllocationOrderService {
.setChannel(payOrder.getChannel())
.setDescription(param.getDescription())
.setStatus(AllocOrderStatusEnum.ALLOCATION_PROCESSING.getCode())
.setAmount(sumAmount);
.setAmount(sumAmount)
.setNotifyUrl(param.getNotifyUrl())
.setAttach(param.getAttach())
.setClientIp(param.getClientIp());
// 如果分账订单金额为0, 设置为忽略状态
if (sumAmount == 0){
allocationOrder.setStatus(AllocOrderStatusEnum.IGNORE.getCode())
@@ -177,17 +176,10 @@ public class AllocationOrderService {
}
allocationOrder.setId(allocId);
// 分账订单扩展
AllocationOrderExtra extend = new AllocationOrderExtra()
.setNotifyUrl(param.getNotifyUrl())
.setAttach(param.getAttach());
extend.setId(allocId);
// 更新支付订单分账状态
payOrder.setAllocStatus(PayOrderAllocStatusEnum.ALLOCATION.getCode());
payOrderManager.updateById(payOrder);
allocationOrderDetailManager.saveAll(details);
allocationOrderExtraManager.save(extend);
allocationOrderManager.save(allocationOrder);
return new OrderAndDetail().setOrder(allocationOrder).setDetails(details);
}

View File

@@ -6,10 +6,7 @@ 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.service.core.order.pay.entity.PayOrderExtra;
import cn.daxpay.single.util.OrderNoGenerateUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import lombok.experimental.UtilityClass;
import java.time.LocalDateTime;
@@ -44,33 +41,16 @@ public class PayBuilder {
.setChannel(payParam.getChannel())
.setMethod(payParam.getMethod())
.setExpiredTime(expiredTime)
.setRefundableBalance(payParam.getAmount());
.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;
}
/**
* 构建支付订单的额外信息
* @param payParam 支付参数
* @param payOrderId 支付订单id
*/
public PayOrderExtra buildPayOrderExtra(PayParam payParam, Long payOrderId) {
PayOrderExtra payOrderExtra = new PayOrderExtra()
.setClientIp(payParam.getClientIp())
.setNotifyUrl(payParam.getNotifyUrl())
.setReturnUrl(payParam.getReturnUrl())
.setAttach(payParam.getAttach())
.setReqTime(payParam.getReqTime());
// 扩展参数
if (CollUtil.isNotEmpty(payParam.getExtraParam())) {
payOrderExtra.setExtraParam(JSONUtil.toJsonStr(payParam.getExtraParam()));
}
payOrderExtra.setId(payOrderId);
return payOrderExtra;
}
}

View File

@@ -2,10 +2,8 @@ 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;
import org.mapstruct.factory.Mappers;
@@ -18,8 +16,6 @@ import org.mapstruct.factory.Mappers;
public interface PayOrderConvert {
PayOrderConvert CONVERT = Mappers.getMapper(PayOrderConvert.class);
PayOrderExtraDto convert(PayOrderExtra in);
PayOrderDto convert(PayOrder in);
PayOrderResult convertResult(PayOrder in);

View File

@@ -1,18 +0,0 @@
package cn.daxpay.single.service.core.order.pay.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
* 支付订单扩展信息
* @author xxm
* @since 2023/12/20
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class PayOrderExtraManager extends BaseManager<PayOrderExtraMapper, PayOrderExtra> {
}

View File

@@ -1,14 +0,0 @@
package cn.daxpay.single.service.core.order.pay.dao;
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 支付订单扩展信息
* @author xxm
* @since 2023/12/20
*/
@Mapper
public interface PayOrderExtraMapper extends BaseMapper<PayOrderExtra> {
}

View File

@@ -7,6 +7,9 @@ import cn.daxpay.single.code.PayOrderAllocStatusEnum;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.code.PayOrderRefundStatusEnum;
import cn.daxpay.single.code.PayStatusEnum;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert;
import cn.daxpay.single.service.dto.order.pay.PayOrderDto;
import cn.bootx.table.modify.annotation.DbColumn;
@@ -132,6 +135,38 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction<PayOrde
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String errorMsg;
/** 同步跳转地址, 以最后一次为准 */
@DbColumn(comment = "同步跳转地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String returnUrl;
/** 异步通知地址,以最后一次为准 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
@DbColumn(comment = "附加参数")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String extraParam;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间, 以最后一次为准 */
@DbColumn(comment = "请求时间,传输时间戳,以最后一次为准")
private LocalDateTime reqTime;
/** 支付终端ip 以最后一次为准 */
@DbColumn(comment = "支付终端ip")
private String clientIp;
/**
* 如果
*/

View File

@@ -1,73 +0,0 @@
package cn.daxpay.single.service.core.order.pay.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
import cn.daxpay.single.service.core.order.pay.convert.PayOrderConvert;
import cn.daxpay.single.service.dto.order.pay.PayOrderExtraDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 支付订单扩展信息
* @author xxm
* @since 2023/12/18
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "支付订单扩展信息")
@TableName("pay_order_extra")
public class PayOrderExtra extends MpBaseEntity implements EntityBaseFunction<PayOrderExtraDto> {
/** 同步跳转地址, 以最后一次为准 */
@DbColumn(comment = "同步跳转地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String returnUrl;
/** 异步通知地址,以最后一次为准 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
@DbColumn(comment = "附加参数")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String extraParam;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间, 以最后一次为准 */
@DbColumn(comment = "请求时间,传输时间戳,以最后一次为准")
private LocalDateTime reqTime;
/** 支付终端ip 以最后一次为准 */
@DbColumn(comment = "支付终端ip")
private String clientIp;
/**
* 转换
*/
@Override
public PayOrderExtraDto toDto() {
return PayOrderConvert.CONVERT.convert(this);
}
}

View File

@@ -1,40 +0,0 @@
package cn.daxpay.single.service.core.order.pay.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.daxpay.single.service.core.order.pay.dao.PayOrderExtraManager;
import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra;
import cn.daxpay.single.service.dto.order.pay.PayOrderExtraDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* 支付订单扩展信息
* @author xxm
* @since 2024/1/9
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PayOrderExtraService {
private final PayOrderExtraManager payOrderExtraManager;
/**
* 查询详情
*/
public PayOrderExtraDto findById(Long id){
return payOrderExtraManager.findById(id).map(PayOrderExtra::toDto)
.orElseThrow(()->new DataNotExistException("支付订单扩展信息不存在"));
}
/**
* 更新, 使用单独事务
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void update(PayOrderExtra payOrderExtra){
payOrderExtraManager.updateById(payOrderExtra);
}
}

View File

@@ -7,7 +7,6 @@ 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;
@@ -31,7 +30,6 @@ import java.util.Optional;
@RequiredArgsConstructor
public class PayOrderQueryService {
private final PayOrderManager payOrderManager;
private final PayOrderExtraManager payOrderExtraManager;
/**
* 分页
@@ -86,9 +84,6 @@ public class PayOrderQueryService {
// 查询支付单
PayOrder payOrder = this.findByBizOrOrderNo(param.getOrderNo(), param.getBizOrderNoeNo())
.orElseThrow(() -> new PayFailureException("支付订单不存在"));
// 查询扩展数据
payOrderExtraManager.findById(payOrder.getId())
.orElseThrow(() -> new PayFailureException("支付订单不完整"));
return PayOrderConvert.CONVERT.convertResult(payOrder);
}

View File

@@ -2,10 +2,8 @@ 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;
import org.mapstruct.factory.Mappers;
@@ -20,8 +18,6 @@ public interface RefundOrderConvert {
RefundOrderDto convert(RefundOrder in);
RefundOrderExtraDto convert(RefundOrderExtra in);
RefundOrderResult convertResult(RefundOrder in);
RefundNoticeResult convertNotice(RefundOrder order);

View File

@@ -1,18 +0,0 @@
package cn.daxpay.single.service.core.order.refund.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/2/22
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class RefundOrderExtraManager extends BaseManager<RefundOrderExtraMapper, RefundOrderExtra> {
}

View File

@@ -1,14 +0,0 @@
package cn.daxpay.single.service.core.order.refund.dao;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xxm
* @since 2024/2/22
*/
@Mapper
public interface RefundOrderExtraMapper extends BaseMapper<RefundOrderExtra> {
}

View File

@@ -4,10 +4,15 @@ import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.code.RefundStatusEnum;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert;
import cn.daxpay.single.service.dto.order.refund.RefundOrderDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -89,6 +94,33 @@ public class RefundOrder extends MpBaseEntity implements EntityBaseFunction<Refu
@DbColumn(comment = "退款状态")
private String status;
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
@DbColumn(comment = "附加参数")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String extraParam;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
/** 错误码 */
@DbColumn(comment = "错误码")
private String errorCode;

View File

@@ -1,64 +0,0 @@
package cn.daxpay.single.service.core.order.refund.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
import cn.daxpay.single.service.core.order.refund.convert.RefundOrderConvert;
import cn.daxpay.single.service.dto.order.refund.RefundOrderExtraDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 退款订单扩展信息
* @author xxm
* @since 2024/2/21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@TableName("pay_refund_order_extra")
@DbTable(comment = "退款订单扩展信息")
public class RefundOrderExtra extends MpBaseEntity implements EntityBaseFunction<RefundOrderExtraDto> {
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
@DbColumn(comment = "附加参数")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String extraParam;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
@Override
public RefundOrderExtraDto toDto() {
return RefundOrderConvert.CONVERT.convert(this);
}
}

View File

@@ -8,12 +8,9 @@ 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;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderExtraManager;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager;
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.dto.order.refund.RefundOrderDto;
import cn.daxpay.single.service.dto.order.refund.RefundOrderExtraDto;
import cn.daxpay.single.service.param.order.PayOrderQuery;
import cn.daxpay.single.service.param.order.RefundOrderQuery;
import cn.hutool.core.util.StrUtil;
@@ -35,7 +32,6 @@ import java.util.Optional;
@RequiredArgsConstructor
public class RefundOrderQueryService {
private final RefundOrderManager refundOrderManager;
private final RefundOrderExtraManager refundOrderExtraManager;
/**
* 分页查询
@@ -53,14 +49,6 @@ public class RefundOrderQueryService {
.orElseThrow(() -> new DataNotExistException("退款订单不存在"));
}
/**
* 根据id查询扩展信息
*/
public RefundOrderExtraDto findExtraById(Long id) {
return refundOrderExtraManager.findById(id).map(RefundOrderExtra::toDto)
.orElseThrow(() -> new DataNotExistException("退款订单扩展信息不存在"));
}
/**
* 根据退款号查询
*/

View File

@@ -3,10 +3,8 @@ package cn.daxpay.single.service.core.order.refund.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.spring.util.WebServletUtil;
import cn.daxpay.single.param.payment.refund.RefundParam;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderExtraManager;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager;
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;
import cn.daxpay.single.service.core.payment.refund.service.RefundService;
import cn.daxpay.single.service.param.order.PayOrderRefundParam;
@@ -34,8 +32,6 @@ public class RefundOrderService {
private final PaymentAssistService paymentAssistService;
private final RefundOrderExtraManager refundOrderExtraManager;
private final RefundOrderManager refundOrderManager;
/**
@@ -65,10 +61,6 @@ public class RefundOrderService {
*/
public void resetRefund(Long id){
// 查询扩展信息
RefundOrderExtra refundOrderExtra = refundOrderExtraManager.findById(id)
.orElseThrow(() -> new DataNotExistException("未找到退款订单"));
// 查询扩展信息
RefundOrder refundOrder = refundOrderManager.findById(id)
.orElseThrow(() -> new DataNotExistException("未找到退款订单"));
@@ -80,8 +72,8 @@ public class RefundOrderService {
RefundParam refundParam = new RefundParam();
refundParam.setBizRefundNo(refundOrder.getBizRefundNo());
// 回调通知
refundParam.setNotifyUrl(refundOrderExtra.getNotifyUrl());
refundParam.setAttach(refundOrderExtra.getAttach());
refundParam.setNotifyUrl(refundOrder.getNotifyUrl());
refundParam.setAttach(refundOrder.getAttach());
refundParam.setReqTime(LocalDateTime.now());
refundParam.setClientIp(ip);

View File

@@ -1,16 +0,0 @@
package cn.daxpay.single.service.core.order.transfer.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrderExtra;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
* 转账订单扩展数据
* @author xxm
* @since 2024/6/6
*/
@Slf4j
@Repository
public class TransferOrderExtraManager extends BaseManager<TransferOrderExtraMapper, TransferOrderExtra> {
}

View File

@@ -1,14 +0,0 @@
package cn.daxpay.single.service.core.order.transfer.dao;
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrderExtra;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 转账订单扩展
* @author xxm
* @since 2024/6/6
*/
@Mapper
public interface TransferOrderExtraMapper extends BaseMapper<TransferOrderExtra> {
}

View File

@@ -1,9 +1,13 @@
package cn.daxpay.single.service.core.order.transfer.entity;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.daxpay.single.code.PayChannelEnum;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.code.TransferPayeeTypeEnum;
import cn.daxpay.single.code.TransferTypeEnum;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -24,56 +28,101 @@ import java.time.LocalDateTime;
public class TransferOrder extends MpBaseEntity {
/** 商户转账号 */
@DbColumn(comment = "商户转账号")
private String bizTransferNo;
/** 转账号 */
@DbColumn(comment = "转账号")
private String transferNo;
/** 通道转账号 */
@DbColumn(comment = "通道转账号")
private String outTransferNo;
/**
* 支付通道
* @see PayChannelEnum
*/
@DbColumn(comment = "支付通道")
private String channel;
/** 转账金额 */
@DbColumn(comment = "转账金额")
private Integer amount;
/** 标题 */
@DbColumn(comment = "标题")
private String title;
/** 转账原因/备注 */
@DbColumn(comment = "转账原因/备注")
private String reason;
/**
* 转账类型, 微信使用
* @see TransferTypeEnum
*/
@DbColumn(comment = "转账类型, 微信使用")
private String transferType;
/** 付款方 */
@DbColumn(comment = "付款方")
private String payer;
/** 付款方显示名称 */
@DbColumn(comment = "付款方显示名称")
private String payerShowName;
/**
* 收款人类型
* @see TransferPayeeTypeEnum
*/
@DbColumn(comment = "收款人类型")
private String payeeType;
/** 收款人账号 */
@DbColumn(comment = "收款人账号")
private String payeeAccount;
/** 收款人姓名 */
@DbColumn(comment = "收款人姓名")
private String payeeName;
/** 状态 */
/**
* 状态
* @see cn.daxpay.single.code.TransferStatusEnum
*/
@DbColumn(comment = "状态")
private String status;
/** 成功时间 */
@DbColumn(comment = "成功时间")
private LocalDateTime successTime;
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
/** 错误提示码 */
@DbColumn(comment = "错误提示码")
private String errorCode;
/** 错误提示 */
@DbColumn(comment = "错误提示")
private String errorMsg;
}

View File

@@ -1,43 +0,0 @@
package cn.daxpay.single.service.core.order.transfer.entity;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 转账订单扩展数据
* @author xxm
* @since 2024/6/6
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "转账订单扩展数据")
@TableName("pay_transfer_order_extra")
public class TransferOrderExtra extends MpBaseEntity {
/** 异步通知地址 */
@DbColumn(comment = "异步通知地址")
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@DbColumn(comment = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@DbColumn(comment = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@DbColumn(comment = "支付终端ip")
private String clientIp;
}

View File

@@ -1,8 +1,8 @@
package cn.daxpay.single.service.core.payment.allocation.service;
import cn.daxpay.single.param.payment.allocation.AllocationParam;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -19,19 +19,19 @@ import org.springframework.transaction.annotation.Transactional;
public class AllocationAssistService {
private final AllocationOrderExtraManager allocationOrderExtraManager;
private final AllocationOrderManager allocationOrderManager;
/**
* 根据新传入的分账订单更新订单和扩展信息
*/
@Transactional(rollbackFor = Exception.class)
public void updateOrder(AllocationParam allocationParam, AllocationOrderExtra orderExtra) {
public void updateOrder(AllocationParam allocationParam, AllocationOrder orderExtra) {
// 扩展信息
orderExtra.setClientIp(allocationParam.getClientIp())
.setNotifyUrl(allocationParam.getNotifyUrl())
.setAttach(allocationParam.getAttach())
.setClientIp(allocationParam.getClientIp())
.setReqTime(allocationParam.getReqTime());
allocationOrderExtraManager.updateById(orderExtra);
allocationOrderManager.updateById(orderExtra);
}
}

View File

@@ -17,11 +17,9 @@ import cn.daxpay.single.result.order.AllocOrderResult;
import cn.daxpay.single.service.common.local.PaymentContextLocal;
import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderDetailManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.order.allocation.entity.OrderAndDetail;
import cn.daxpay.single.service.core.order.allocation.service.AllocationOrderService;
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
@@ -70,8 +68,6 @@ public class AllocationService {
private final PayOrderQueryService payOrderQueryService;
private final AllocationOrderExtraManager allocationOrderExtraManager;
private final LockTemplate lockTemplate;
/**
@@ -170,11 +166,8 @@ public class AllocationService {
allocationStrategy.initParam(order, details);
// 分账预处理
allocationStrategy.doBeforeHandler();
// 查询扩展信息
AllocationOrderExtra orderExtra = allocationOrderExtraManager.findById(order.getId())
.orElseThrow(() -> new PayFailureException("未查询到分账单扩展信息"));
// 更新分账单扩展信息
allocationAssistService.updateOrder(param, orderExtra);
allocationAssistService.updateOrder(param, order);
try {
// 重复分账处理
allocationStrategy.allocation();

View File

@@ -149,7 +149,7 @@ public class AllocationSyncService {
// 如果状态为完成, 发送通知
if (Objects.equals(AllocOrderStatusEnum.ALLOCATION_END.getCode(), allocationOrder.getStatus())){
// 发送通知
clientNoticeService.registerAllocNotice(allocationOrder, null, details);
clientNoticeService.registerAllocNotice(allocationOrder, details);
}
}

View File

@@ -89,7 +89,7 @@ public class PayCancelService {
.setCloseTime(LocalDateTime.now());
payOrderService.updateById(payOrder);
// 发送通知
clientsService.registerPayNotice(payOrder,null);
clientsService.registerPayNotice(payOrder);
this.saveRecord(payOrder,true,null);
}

View File

@@ -96,7 +96,7 @@ public class PayCloseService {
.setCloseTime(LocalDateTime.now());
payOrderService.updateById(payOrder);
// 发送通知
clientsService.registerPayNotice(payOrder,null);
clientsService.registerPayNotice(payOrder);
this.saveRecord(payOrder,true,null);
}

View File

@@ -6,13 +6,10 @@ import cn.daxpay.single.service.core.notice.entity.ClientNoticeTask;
import cn.daxpay.single.service.core.order.allocation.convert.AllocationConvert;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
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.PaymentSignService;
import cn.daxpay.single.service.core.payment.notice.result.AllocDetailNoticeResult;
import cn.daxpay.single.service.core.payment.notice.result.AllocNoticeResult;
@@ -40,12 +37,12 @@ public class ClientNoticeAssistService {
/**
* 构建出支付通知任务对象
*/
public ClientNoticeTask buildPayTask(PayOrder order, PayOrderExtra orderExtra){
public ClientNoticeTask buildPayTask(PayOrder order){
PayNoticeResult payNoticeResult = PayOrderConvert.CONVERT.convertNotice(order);
payNoticeResult.setAttach(orderExtra.getAttach());
payNoticeResult.setAttach(order.getAttach());
paymentSignService.sign(payNoticeResult);
return new ClientNoticeTask()
.setUrl(orderExtra.getNotifyUrl())
.setUrl(order.getNotifyUrl())
// 时间序列化进行了重写, 所以使用Jackson的序列化工具类
.setContent(JacksonUtil.toJson(payNoticeResult))
.setNoticeType(ClientNoticeTypeEnum.PAY.getType())
@@ -58,14 +55,14 @@ public class ClientNoticeAssistService {
/**
* 构建出退款通知任务对象
*/
public ClientNoticeTask buildRefundTask(RefundOrder order, RefundOrderExtra orderExtra){
public ClientNoticeTask buildRefundTask(RefundOrder order){
// 创建退款通知内容
RefundNoticeResult refundNoticeResult = RefundOrderConvert.CONVERT.convertNotice(order);
refundNoticeResult.setAttach(orderExtra.getAttach());
refundNoticeResult.setAttach(order.getAttach());
// 签名
paymentSignService.sign(refundNoticeResult);
return new ClientNoticeTask()
.setUrl(orderExtra.getNotifyUrl())
.setUrl(order.getNotifyUrl())
// 时间序列化进行了重写
.setContent(JacksonUtil.toJson(refundNoticeResult))
.setNoticeType(ClientNoticeTypeEnum.REFUND.getType())
@@ -78,7 +75,7 @@ public class ClientNoticeAssistService {
/**
* 构建分账通知
*/
public ClientNoticeTask buildAllocTask(AllocationOrder order, AllocationOrderExtra orderExtra, List<AllocationOrderDetail> list){
public ClientNoticeTask buildAllocTask(AllocationOrder order, List<AllocationOrderDetail> list){
// 分账
AllocNoticeResult allocOrderResult = AllocationConvert.CONVERT.toNotice(order);
// 分账详情
@@ -86,12 +83,12 @@ public class ClientNoticeAssistService {
.map(AllocationConvert.CONVERT::toNotice)
.collect(Collectors.toList());
// 分账扩展和明细
allocOrderResult.setAttach(orderExtra.getAttach())
allocOrderResult.setAttach(order.getAttach())
.setDetails(details);
// 签名
paymentSignService.sign(allocOrderResult);
return new ClientNoticeTask()
.setUrl(orderExtra.getNotifyUrl())
.setUrl(order.getNotifyUrl())
// 时间序列化进行了重写
.setContent(JacksonUtil.toJson(allocOrderResult))
.setNoticeType(ClientNoticeTypeEnum.ALLOCATION.getType())

View File

@@ -8,16 +8,10 @@ import cn.daxpay.single.service.core.notice.dao.ClientNoticeTaskManager;
import cn.daxpay.single.service.core.notice.entity.ClientNoticeRecord;
import cn.daxpay.single.service.core.notice.entity.ClientNoticeTask;
import cn.daxpay.single.service.core.notice.service.ClientNoticeRecordService;
import cn.daxpay.single.service.core.order.allocation.dao.AllocationOrderExtraManager;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrder;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderDetail;
import cn.daxpay.single.service.core.order.allocation.entity.AllocationOrderExtra;
import cn.daxpay.single.service.core.order.pay.dao.PayOrderExtraManager;
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.dao.RefundOrderExtraManager;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.HttpResponse;
@@ -43,18 +37,12 @@ import java.util.*;
@RequiredArgsConstructor
public class ClientNoticeService {
private final PayOrderExtraManager payOrderExtraManager;
private final RefundOrderExtraManager refundOrderExtraManager;
private final ClientNoticeAssistService clientNoticeAssistService;
private final ClientNoticeTaskManager taskManager;
private final ClientNoticeRecordService recordService;
private final AllocationOrderExtraManager allocationOrderExtraManager;
private final RedisClient redisClient;
private final LockTemplate lockTemplate;
@@ -89,27 +77,17 @@ public class ClientNoticeService {
/**
* 注册支付消息通知任务
* @param order 支付订单
* @param orderExtra 支付订单扩展信息
*/
@Async("bigExecutor")
public void registerPayNotice(PayOrder order, PayOrderExtra orderExtra) {
// 支付订单扩展信息为空则进行查询
if (Objects.isNull(orderExtra)){
Optional<PayOrderExtra> extraOpt = payOrderExtraManager.findById(order.getId());
if (!extraOpt.isPresent()){
log.error("未找到支付扩展信息,数据错误,订单号:{}",order.getOrderNo());
return;
}
orderExtra = extraOpt.get();
}
public void registerPayNotice(PayOrder order) {
// 判断是否需要进行通知
if (StrUtil.isBlank(orderExtra.getNotifyUrl())){
if (StrUtil.isBlank(order.getNotifyUrl())){
log.info("支付订单无需通知,订单号:{}",order.getOrderNo());
return;
}
// 创建通知任务并保存
ClientNoticeTask task = clientNoticeAssistService.buildPayTask(order, orderExtra);
ClientNoticeTask task = clientNoticeAssistService.buildPayTask(order);
try {
taskManager.save(task);
} catch (Exception e) {
@@ -124,27 +102,17 @@ public class ClientNoticeService {
/**
* 注册退款消息通知任务
* @param order 退款订单
* @param orderExtra 退款订单扩展信息
*/
@Async("bigExecutor")
public void registerRefundNotice(RefundOrder order, RefundOrderExtra orderExtra) {
// 退款订单扩展信息为空则进行查询
if (Objects.isNull(orderExtra)){
Optional<RefundOrderExtra> extraOpt = refundOrderExtraManager.findById(order.getId());
if (!extraOpt.isPresent()){
log.error("未找到退款扩展信息数据错误订单ID{}",order.getId());
return;
}
orderExtra = extraOpt.get();
}
public void registerRefundNotice(RefundOrder order) {
// 判断是否需要进行通知
if (StrUtil.isBlank(orderExtra.getNotifyUrl())){
if (StrUtil.isBlank(order.getNotifyUrl())){
log.info("退款订单无需通知订单ID{}",order.getId());
return;
}
// 创建通知任务并保存
ClientNoticeTask task = clientNoticeAssistService.buildRefundTask(order, orderExtra);
ClientNoticeTask task = clientNoticeAssistService.buildRefundTask(order);
try {
taskManager.save(task);
} catch (Exception e) {
@@ -160,23 +128,14 @@ public class ClientNoticeService {
* 注册分账消息通知任务
*/
@Async("bigExecutor")
public void registerAllocNotice(AllocationOrder order, AllocationOrderExtra orderExtra, List<AllocationOrderDetail> list) {
// 创建通知任务并保存
if (Objects.isNull(orderExtra)){
Optional<AllocationOrderExtra> extraOpt = allocationOrderExtraManager.findById(order.getId());
if (!extraOpt.isPresent()){
log.error("未找到分账扩展信息数据错误订单ID{}",order.getId());
return;
}
orderExtra = extraOpt.get();
}
public void registerAllocNotice(AllocationOrder order, List<AllocationOrderDetail> list) {
// 判断是否需要进行通知
if (StrUtil.isBlank(orderExtra.getNotifyUrl())){
if (StrUtil.isBlank(order.getNotifyUrl())){
log.info("分账订单无需通知订单ID{}",order.getId());
return;
}
// 创建通知任务并保存
ClientNoticeTask task = clientNoticeAssistService.buildAllocTask(order, orderExtra, list);
ClientNoticeTask task = clientNoticeAssistService.buildAllocTask(order, list);
try {
taskManager.save(task);
} catch (Exception e) {

View File

@@ -1,9 +1,7 @@
package cn.daxpay.single.service.core.payment.notice.service;
import cn.daxpay.single.service.configuration.DaxPayProperties;
import cn.daxpay.single.service.core.order.pay.dao.PayOrderExtraManager;
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.pay.service.PayOrderQueryService;
import cn.daxpay.single.service.core.system.config.service.PlatformConfigService;
import cn.daxpay.single.service.param.channel.alipay.AliPayReturnParam;
@@ -26,7 +24,6 @@ import java.util.Objects;
@RequiredArgsConstructor
public class PayReturnService {
private final PayOrderQueryService payOrderQueryService;
private final PayOrderExtraManager payOrderExtraManager;
private final PlatformConfigService platformConfigService;
private final DaxPayProperties properties;
@@ -39,17 +36,13 @@ public class PayReturnService {
if ( Objects.isNull(payOrder)){
return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查"));
}
PayOrderExtra payOrderExtra = payOrderExtraManager.findById(payOrder.getId()).orElse(null);
if ( Objects.isNull(payOrderExtra)){
return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查"));
}
// 如果同步跳转参数为空, 获取系统配置地址, 系统配置如果也为空, 则返回默认地址
String returnUrl = payOrderExtra.getReturnUrl();
String returnUrl = payOrder.getReturnUrl();
if (StrUtil.isBlank(returnUrl)){
returnUrl = platformConfigService.getConfig().getReturnUrl();
}
if (StrUtil.isNotBlank(returnUrl)){
return StrUtil.format("{}?orderNo={}&bizOrderNo={}", payOrderExtra.getReturnUrl(),payOrder.getOrderNo(),payOrder.getBizOrderNo());
return StrUtil.format("{}?orderNo={}&bizOrderNo={}", payOrder.getReturnUrl(),payOrder.getOrderNo(),payOrder.getBizOrderNo());
}
// 跳转到默认页
return StrUtil.format("{}/result/success?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付成功..."));
@@ -62,19 +55,18 @@ public class PayReturnService {
orderId = param.getOrderNo();
}
PayOrderExtra payOrderExtra = payOrderExtraManager.findById(orderId).orElse(null);
PayOrder prOrder = payOrderQueryService.findById(Long.valueOf(orderId)).orElse(null);
if (Objects.isNull(payOrderExtra) || Objects.isNull(prOrder)){
if (Objects.isNull(prOrder)){
return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查"));
}
// 如果同步跳转参数为空, 获取系统配置地址, 系统配置如果也为空, 则返回默认地址
String returnUrl = payOrderExtra.getReturnUrl();
String returnUrl = prOrder.getReturnUrl();
if (StrUtil.isBlank(returnUrl)){
returnUrl = platformConfigService.getConfig().getReturnUrl();
}
if (StrUtil.isNotBlank(returnUrl)){
return StrUtil.format("{}?orderNo={}&bizOrderNo={}", payOrderExtra.getReturnUrl(),prOrder.getOrderNo(), prOrder.getBizOrderNo());
return StrUtil.format("{}?orderNo={}&bizOrderNo={}", prOrder.getReturnUrl(),prOrder.getOrderNo(), prOrder.getBizOrderNo());
}
// 跳转到默认页
return StrUtil.format("{}/result/success?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付成功..."));

View File

@@ -11,9 +11,7 @@ import cn.daxpay.single.service.common.context.PayLocal;
import cn.daxpay.single.service.common.context.PlatformLocal;
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.dao.PayOrderExtraManager;
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.pay.service.PayOrderQueryService;
import cn.daxpay.single.service.core.order.pay.service.PayOrderService;
import cn.daxpay.single.service.core.payment.sync.service.PaySyncService;
@@ -48,8 +46,6 @@ public class PayAssistService {
private final PayOrderQueryService payOrderQueryService;
private final PayOrderExtraManager payOrderExtraManager;
/**
* 初始化支付相关上下文
*/
@@ -99,11 +95,6 @@ public class PayAssistService {
// 构建支付订单并保存
PayOrder order = PayBuilder.buildPayOrder(payParam);
payOrderService.save(order);
// 构建支付订单扩展表并保存
PayOrderExtra payOrderExtra = PayBuilder.buildPayOrderExtra(payParam, order.getId());
payOrderExtraManager.save(payOrderExtra);
payInfo.setPayOrder(order)
.setPayOrderExtra(payOrderExtra);
return order;
}
@@ -111,30 +102,27 @@ public class PayAssistService {
* 根据新传入的支付订单更新订单和扩展信息
*/
@Transactional(rollbackFor = Exception.class)
public void updatePayOrder(PayParam payParam,PayOrder order, PayOrderExtra payOrderExtra) {
public void updatePayOrder(PayParam payParam,PayOrder order) {
// 订单信息
order.setAllocation(payParam.getAllocation())
.setClientIp(payParam.getClientIp())
.setNotifyUrl(payParam.getNotifyUrl())
.setReturnUrl(payParam.getReturnUrl())
.setAttach(payParam.getAttach())
.setClientIp(payParam.getClientIp())
.setReqTime(payParam.getReqTime())
.setChannel(payParam.getChannel())
.setMethod(payParam.getMethod());
if (!order.getAllocation()) {
order.setAllocStatus(null);
}
// 扩展信息
payOrderExtra.setClientIp(payParam.getClientIp())
.setNotifyUrl(payParam.getNotifyUrl())
.setReturnUrl(payParam.getReturnUrl())
.setAttach(payParam.getAttach())
.setClientIp(payParam.getClientIp())
.setReqTime(payParam.getReqTime());
if (CollUtil.isNotEmpty(payParam.getExtraParam())){
payOrderExtra.setExtraParam(JSONUtil.toJsonStr(payParam.getExtraParam()));
order.setExtraParam(JSONUtil.toJsonStr(payParam.getExtraParam()));
} else {
payOrderExtra.setExtraParam(null);
order.setExtraParam(null);
}
payOrderService.updateById(order);
payOrderExtraManager.updateById(payOrderExtra);
}
/**

View File

@@ -1,19 +1,15 @@
package cn.daxpay.single.service.core.payment.pay.service;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.daxpay.single.exception.pay.PayUnsupportedMethodException;
import cn.daxpay.single.param.payment.pay.PayParam;
import cn.daxpay.single.result.pay.PayResult;
import cn.daxpay.single.service.common.context.PayLocal;
import cn.daxpay.single.service.common.local.PaymentContextLocal;
import cn.daxpay.single.service.core.order.pay.dao.PayOrderExtraManager;
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.pay.service.PayOrderService;
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.func.AbsPayStrategy;
import cn.daxpay.single.service.func.AbsRefundSyncStrategy;
import cn.daxpay.single.service.util.PayStrategyFactory;
import cn.daxpay.single.util.PayUtil;
import cn.hutool.extra.spring.SpringUtil;
@@ -47,8 +43,6 @@ public class PayService {
private final ClientNoticeService clientNoticeService;
private final PayOrderExtraManager payOrderExtraManager;
private final TradeFlowRecordService tradeFlowRecordService;
private final LockTemplate lockTemplate;
@@ -138,7 +132,7 @@ public class PayService {
// 如果支付完成 发送通知, 记录流水
if (Objects.equals(payOrder.getStatus(), SUCCESS.getCode())){
tradeFlowRecordService.savePay(payOrder);
clientNoticeService.registerPayNotice(payOrder, payInfo.getPayOrderExtra());
clientNoticeService.registerPayNotice(payOrder);
}
return payAssistService.buildResult(payOrder);
}
@@ -153,10 +147,8 @@ public class PayService {
payStrategy.initPayParam(payOrder, payParam);
// 执行支付前处理动作
payStrategy.doBeforePayHandler();
// 查询订单扩展记录
PayOrderExtra payOrderExtra = payOrderExtraManager.findById(payOrder.getId()).orElseThrow(() -> new DataNotExistException("支付订单不完整"));
// 执行支付前的更新动作, 更新并保存订单和扩展的数据
payAssistService.updatePayOrder(payParam, payOrder, payOrderExtra);
// 执行支付前的更新动作, 更新并保存订单数据
payAssistService.updatePayOrder(payParam, payOrder);
try {
// 支付操作
@@ -168,14 +160,14 @@ public class PayService {
throw e;
}
// 支付调起成功后操作, 使用事务来保证数据一致性
return SpringUtil.getBean(this.getClass()).repeatPaySuccess(payOrder, payOrderExtra);
return SpringUtil.getBean(this.getClass()).repeatPaySuccess(payOrder);
}
/**
* 重复支付成功后操作
*/
@Transactional(rollbackFor = Exception.class)
public PayResult repeatPaySuccess(PayOrder payOrder, PayOrderExtra payOrderExtra) {
public PayResult repeatPaySuccess(PayOrder payOrder) {
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();
// 如果支付完成, 进行订单完成处理, 同时发送回调消息
if (payInfo.isComplete()) {
@@ -191,7 +183,7 @@ public class PayService {
// 如果支付完成 发送通知, 记录流水
if (Objects.equals(payOrder.getStatus(), SUCCESS.getCode())){
tradeFlowRecordService.savePay(payOrder);
clientNoticeService.registerPayNotice(payOrder, payOrderExtra);
clientNoticeService.registerPayNotice(payOrder);
}
return payAssistService.buildResult(payOrder);
}

View File

@@ -11,10 +11,8 @@ import cn.daxpay.single.service.common.context.PlatformLocal;
import cn.daxpay.single.service.common.context.RefundLocal;
import cn.daxpay.single.service.common.local.PaymentContextLocal;
import cn.daxpay.single.service.core.order.pay.entity.PayOrder;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderExtraManager;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrder;
import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra;
import cn.daxpay.single.util.OrderNoGenerateUtil;
import cn.daxpay.single.util.PaySignUtil;
import cn.hutool.core.util.StrUtil;
@@ -42,8 +40,6 @@ import static cn.daxpay.single.code.RefundStatusEnum.SUCCESS;
public class RefundAssistService {
private final RefundOrderManager refundOrderManager;
private final RefundOrderExtraManager refundOrderExtraManager;
/**
* 检查并处理退款参数
*/
@@ -90,17 +86,12 @@ public class RefundAssistService {
.setOrderAmount(payOrder.getAmount())
.setAmount(refundParam.getAmount())
.setTitle(payOrder.getTitle())
.setReason(refundParam.getReason());
refundOrderManager.save(refundOrder);
// 生成退款扩展订单
RefundOrderExtra orderExtra = new RefundOrderExtra()
.setReason(refundParam.getReason())
.setClientIp(refundParam.getClientIp())
.setReqTime(refundParam.getReqTime())
.setAttach(refundParam.getAttach())
.setNotifyUrl(refundParam.getNotifyUrl());
orderExtra.setId(refundOrder.getId());
refundOrderExtraManager.save(orderExtra);
.setNotifyUrl(refundParam.getNotifyUrl());;
refundOrderManager.save(refundOrder);
return refundOrder;
}

View File

@@ -13,10 +13,8 @@ import cn.daxpay.single.service.common.local.PaymentContextLocal;
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.PayOrderService;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderExtraManager;
import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager;
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.service.ClientNoticeService;
import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService;
import cn.daxpay.single.service.func.AbsRefundStrategy;
@@ -57,8 +55,6 @@ public class RefundService {
private final TradeFlowRecordService tradeFlowRecordService;
private final RefundOrderExtraManager refundOrderExtraManager;
private final LockTemplate lockTemplate;
@@ -154,15 +150,13 @@ public class RefundService {
// 获取支付订单
PayOrder payOrder = payOrderQueryService.findByBizOrOrderNo(refundOrder.getOrderNo(), refundOrder.getBizOrderNo())
.orElseThrow(() -> new DataNotExistException("支付订单不存在"));
RefundOrderExtra refundOrderExtra = refundOrderExtraManager.findById(refundOrder.getId())
.orElseThrow(() -> new DataNotExistException("退款订单扩展信息不存在"));
AbsRefundStrategy refundStrategy = PayStrategyFactory.create(refundOrder.getChannel(), AbsRefundStrategy.class);
// 设置退款订单对象
refundStrategy.setRefundOrder(refundOrder);
// 退款前准备操作
refundStrategy.doBeforeRefundHandler();
// 进行发起退款前的操作, 更新扩展记录信息
this.updateExtra(refundOrderExtra, param);
this.updateOrder(param,refundOrder);
try {
// 执行退款策略
refundStrategy.doRefundHandler();
@@ -184,15 +178,15 @@ public class RefundService {
/**
* 更新退款订单扩展信息
*/
private void updateExtra(RefundOrderExtra refundOrderExtra, RefundParam param){
refundOrderExtra.setAttach(param.getAttach())
private void updateOrder(RefundParam param, RefundOrder order){
order.setAttach(param.getAttach())
.setClientIp(param.getClientIp())
.setNotifyUrl(param.getNotifyUrl())
.setReqTime(param.getReqTime());
if (CollUtil.isNotEmpty(param.getExtraParam())){
refundOrderExtra.setExtraParam(JSONUtil.toJsonStr(param.getExtraParam()));
order.setExtraParam(JSONUtil.toJsonStr(param.getExtraParam()));
}
refundOrderExtraManager.updateById(refundOrderExtra);
refundOrderManager.updateById(order);
}
/**
@@ -226,7 +220,7 @@ public class RefundService {
// 发送通知
List<String> list = Arrays.asList(RefundStatusEnum.SUCCESS.getCode(), RefundStatusEnum.CLOSE.getCode(), RefundStatusEnum.FAIL.getCode());
if (list.contains(refundOrder.getStatus())){
clientNoticeService.registerRefundNotice(refundOrder, refundInfo.getRunOrderExtra());
clientNoticeService.registerRefundNotice(refundOrder);
}
}

View File

@@ -88,7 +88,7 @@ public class PayRepairService {
// 设置修复iD
repairResult.setRepairNo(IdUtil.getSnowflakeNextIdStr());
// 发送通知
clientNoticeService.registerPayNotice(order, null);
clientNoticeService.registerPayNotice(order);
this.saveRecord(order, repairType, repairResult);
return repairResult;
}

View File

@@ -87,7 +87,7 @@ public class RefundRepairService {
PayRepairRecord refundRepairRecord = this.refundRepairRecord(refundOrder, repairType, repairResult);
// 发送通知
clientNoticeService.registerRefundNotice(refundOrder, null);
clientNoticeService.registerRefundNotice(refundOrder);
recordService.saveAllRecord(Arrays.asList(payRepairRecord, refundRepairRecord));
return repairResult;
} finally {
@@ -126,7 +126,7 @@ public class RefundRepairService {
// 发送通知
List<String> list = Arrays.asList(RefundStatusEnum.SUCCESS.getCode(), RefundStatusEnum.CLOSE.getCode(), RefundStatusEnum.FAIL.getCode());
if (list.contains(refundOrder.getStatus())){
clientNoticeService.registerRefundNotice(refundOrder, null);
clientNoticeService.registerRefundNotice(refundOrder);
}
return new RefundRepairResult()

View File

@@ -1,11 +1,15 @@
package cn.daxpay.single.service.core.payment.transfer.service;
import cn.daxpay.single.code.TransferStatusEnum;
import cn.daxpay.single.param.payment.transfer.TransferParam;
import cn.daxpay.single.result.transfer.TransferResult;
import cn.daxpay.single.service.core.order.transfer.dao.TransferOrderManager;
import cn.daxpay.single.service.core.order.transfer.entity.TransferOrder;
import cn.daxpay.single.util.OrderNoGenerateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 转账辅助服务
@@ -17,28 +21,48 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class TransferAssistService {
private final TransferOrderManager transferOrderManager;
/**
* 创建转账订单
*/
@Transactional(rollbackFor = Exception.class)
public TransferOrder createOrder(TransferParam param) {
// 1. 创建转账订单
return null;
// 创建转账订单
TransferOrder transferOrder = new TransferOrder()
.setTransferNo(OrderNoGenerateUtil.transfer())
.setAmount(param.getAmount())
.setBizTransferNo(param.getBizTransferNo())
.setChannel(param.getChannel())
.setPayeeName(param.getPayeeName())
.setPayeeAccount(param.getPayeeAccount())
.setPayeeType(param.getPayeeType())
.setPayerShowName(param.getPayerShowName())
.setReason(param.getReason())
.setStatus(TransferStatusEnum.TRANSFERRING.getCode())
.setTitle(param.getTitle())
.setNotifyUrl(param.getNotifyUrl())
.setAttach(param.getAttach())
.setClientIp(param.getClientIp());
transferOrderManager.save(transferOrder);
return transferOrder;
}
/**
* 更新转账订单错误信息
*/
public void updateOrderByError(TransferOrder order) {
order.setErrorMsg("")
.setErrorCode("");
}
/**
* 构造
* @param order
*/
public TransferResult buildResult(TransferOrder order) {
return null;
return new TransferResult()
.setTransferNo(order.getTransferNo())
.setBizTransferNo(order.getBizTransferNo())
.setStatus(order.getStatus());
}
}

View File

@@ -1,20 +0,0 @@
package cn.daxpay.single.service.dto.order.allocation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 分账订单和扩展信息
* @author xxm
* @since 2024/5/29
*/
@Data
@Accessors(chain = true)
@Schema(title = "分账订单和扩展信息")
public class AllocationOrderAndExtraDto {
@Schema(description = "分账订单")
private AllocationOrderDto order;
@Schema(description = "分账订单扩展信息")
private AllocationOrderExtraDto extra;
}

View File

@@ -8,6 +8,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 分账订单
* @author xxm
@@ -98,6 +100,22 @@ public class AllocationOrderDto extends BaseDto {
@Schema(description = "分账处理结果")
private String result;
/** 异步通知地址 */
@Schema(description = "异步通知地址")
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@Schema(description = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@Schema(description = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@Schema(description = "支付终端ip")
private String clientIp;
/**
* 错误码
*/

View File

@@ -1,35 +0,0 @@
package cn.daxpay.single.service.dto.order.allocation;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 分账订单扩展
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "分账订单扩展")
public class AllocationOrderExtraDto extends BaseDto {
/** 异步通知地址 */
@Schema(description = "异步通知地址")
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@Schema(description = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间 */
@Schema(description = "请求时间,传输时间戳")
private LocalDateTime reqTime;
/** 终端ip */
@Schema(description = "支付终端ip")
private String clientIp;
}

View File

@@ -1,18 +0,0 @@
package cn.daxpay.single.service.dto.order.pay;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 支付订单和扩展信息
* @author xxm
* @since 2024/4/26
*/
@Data
@Schema(title = "支付订单和扩展信息")
public class PayOrderAndExtraDto {
@Schema(description = "支付订单")
private PayOrderDto payOrder;
@Schema(description = "支付订单扩展信息")
private PayOrderExtraDto payOrderExtra;
}

View File

@@ -113,5 +113,19 @@ public class PayOrderDto extends BaseDto {
@Schema(description = "错误信息")
private String errorMsg;
/** 支付终端ip */
@Schema(description = "支付终端ip")
private String clientIp;
/** 异步通知地址 */
@Schema(description = "异步通知地址,以最后一次为准")
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回 */
@Schema(description = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间, 以最后一次为准 */
@Schema(description = "请求时间,传输时间戳,以最后一次为准")
private LocalDateTime reqTime;
}

View File

@@ -1,57 +0,0 @@
package cn.daxpay.single.service.dto.order.pay;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
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/1/9
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "支付订单扩展信息")
public class PayOrderExtraDto extends BaseDto {
/** 描述 */
@Schema(description = "描述")
private String description;
/** 支付终端ip */
@Schema(description = "支付终端ip")
private String clientIp;
/** 异步通知地址 */
@Schema(description = "异步通知地址,以最后一次为准")
private String notifyUrl;
/** 签名类型 */
@Schema(description = "签名类型")
private String reqSignType;
/** 签名,以最后一次为准 */
@Schema(description = "签名")
private String reqSign;
/** 商户扩展参数,回调时会原样返回 */
@Schema(description = "商户扩展参数")
private String attach;
/** 请求时间,时间戳转时间, 以最后一次为准 */
@Schema(description = "请求时间,传输时间戳,以最后一次为准")
private LocalDateTime reqTime;
/** 错误码 */
@Schema(description = "错误码")
private String errorCode;
/** 错误信息 */
@Schema(description = "错误信息")
private String errorMsg;
}

View File

@@ -1,20 +0,0 @@
package cn.daxpay.single.service.dto.order.refund;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 退款订单信息
* @author xxm
* @since 2024/4/28
*/
@Data
@Accessors(chain = true)
@Schema(title = "退款订单信息")
public class RefundOrderAndExtraDto {
@Schema(description = "退款订单")
RefundOrderDto refundOrder;
@Schema(description = "退款订单扩展信息")
RefundOrderExtraDto refundOrderExtra;
}

View File

@@ -3,6 +3,9 @@ package cn.daxpay.single.service.dto.order.refund;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.daxpay.single.code.PayChannelEnum;
import cn.daxpay.single.code.RefundStatusEnum;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -73,6 +76,7 @@ public class RefundOrderDto extends BaseDto {
@Schema(description = "退款原因")
private String reason;
/** 退款结束时间 */
@Schema(description = "退款结束时间")
private LocalDateTime finishTime;
@@ -83,6 +87,31 @@ public class RefundOrderDto extends BaseDto {
@Schema(description = "退款状态")
private String status;
/** 异步通知地址 */
@Schema(description = "异步通知地址")
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
@Schema(description = "商户扩展参数,回调时会原样返回, 以最后一次为准")
private String attach;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
@Schema(description = "附加参数 以最后一次为准")
private String extraParam;
/** 请求时间,时间戳转时间 */
@Schema(description = "请求时间,时间戳转时间")
private LocalDateTime reqTime;
/** 终端ip */
@Schema(description = "终端ip")
private String clientIp;
/** 错误码 */
@Schema(description = "错误码")
private String errorCode;

View File

@@ -1,44 +0,0 @@
package cn.daxpay.single.service.dto.order.refund;
import cn.bootx.platform.common.core.rest.dto.BaseDto;
import cn.daxpay.single.param.channel.AliPayParam;
import cn.daxpay.single.param.channel.WalletPayParam;
import cn.daxpay.single.param.channel.WeChatPayParam;
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/4/26
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "退款订单扩展信息")
public class RefundOrderExtraDto extends BaseDto {
/** 异步通知地址 */
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
private String attach;
/**
* 附加参数 以最后一次为准
* @see AliPayParam
* @see WeChatPayParam
* @see WalletPayParam
*/
private String extraParam;
/** 请求时间,时间戳转时间 */
private LocalDateTime reqTime;
/** 终端ip */
private String clientIp;
}

View File

@@ -23,7 +23,6 @@ class PayParamSignTest {
PayParam payParam = new PayParam();
payParam.setBizOrderNo("123");
payParam.setClientIp("127.0.0.1");
payParam.setNotNotify(true);
payParam.setNotifyUrl("http://127.0.0.1:8080/pay/notify");
payParam.setReturnUrl("http://127.0.0.1:8080/pay/return");
// 传入的话需要传输时间戳