查询退款对象

This commit is contained in:
2023-12-27 16:27:14 +08:00
parent 26be291014
commit dff6ddffae
7 changed files with 195 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package com.jsowell.adapay.common;
import lombok.*;
/**
* 退款对象
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RefundInfo {
/**
* Adapay生成的退款对象id
*/
private String refund_id;
/**
* 退款状态I-初始P-处理中F-失败S-成功
*/
private String trans_status;
/**
* Adapay生成的支付对象id
*/
private String payment_id;
/**
* 退款金额
*/
private String refund_amt;
/**
* 退款手续费,退款成功时有值
*/
private String fee_amt;
/**
* 退款订单号
*/
private String refund_order_no;
}

View File

@@ -0,0 +1,31 @@
package com.jsowell.adapay.response;
import com.jsowell.adapay.common.RefundInfo;
import lombok.*;
import java.util.List;
/**
* 查询退款对象response
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PaymentRefundResponse extends AdapayBaseResponse{
/**
* 是否 prod模式true 是 prod模式false 是 mock模式
*/
private String prod_mode;
/**
* 退款对象列表,若未查询到结果时,字段为空
*/
private List<RefundInfo> refunds;
/**
* 当发生参数错误时返回具体的参数名,便于定位错误原因,详见 错误
*/
private String invalid_param;
}

View File

@@ -12,6 +12,7 @@ import com.huifu.adapay.model.*;
import com.jsowell.adapay.common.AdaPayment;
import com.jsowell.adapay.common.CreateAdaPaymentParam;
import com.jsowell.adapay.common.DivMember;
import com.jsowell.adapay.common.RefundInfo;
import com.jsowell.adapay.config.AbstractAdapayConfig;
import com.jsowell.adapay.dto.*;
import com.jsowell.adapay.factory.AdapayConfigFactory;
@@ -1030,6 +1031,23 @@ public class AdapayService {
return payment_reverses;
}
/**
* 查询支付退款对象
*/
public List<RefundInfo> queryPaymentRefund(String paymentId, String wechatAppId) throws BaseAdaPayException {
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
if (config == null) {
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
}
Map<String, Object> refundParams = Maps.newHashMap();
refundParams.put("payment_id", paymentId);
refundParams.put("app_id", config.getAdapayAppId());
Map<String, Object> response = Refund.query(refundParams, config.getWechatAppId());
PaymentRefundResponse paymentRefundResponse = JSON.parseObject(JSON.toJSONString(response), PaymentRefundResponse.class);
List<RefundInfo> refunds = paymentRefundResponse.getRefunds();
return refunds;
}
/**
* 查询支付确认对象列表
*/