修改退款申请封装
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
package com.czg;
|
||||
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.pay.NativeMerchantDTO;
|
||||
import com.czg.pay.PolyMerchantDTO;
|
||||
import com.czg.pay.*;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.NonNull;
|
||||
@@ -41,10 +37,10 @@ public interface PayAdapter {
|
||||
CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
||||
@NotBlank String notifyUrl, CzgPayBaseReq bizData);
|
||||
|
||||
CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData);
|
||||
CzgResult<RefundRespDTO> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData);
|
||||
|
||||
CzgResult<CzgBaseResp> queryPayOrder(@NotBlank String domain, @NotBlank String payData, String payOrderId, String mchOrderNo);
|
||||
|
||||
CzgResult<CzgRefundResp> queryRefund(@NotBlank String domain, @NotBlank String payData, String mchRefundNo, String refundOrderId);
|
||||
CzgResult<RefundRespDTO> queryRefund(@NotBlank String domain, @NotBlank String payData, String mchRefundNo, String refundOrderId);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@ import com.czg.PayAdapter;
|
||||
import com.czg.PayManager;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.pay.NativeMerchantDTO;
|
||||
import com.czg.pay.RefundRespDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -36,17 +35,17 @@ public class NativePayAdapter implements PayAdapter {
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, String payData, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||
try {
|
||||
NativeMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, NativeMerchantDTO.class);
|
||||
NativeMerchantDTO merchantDTO = getMerchantDTO(payData);
|
||||
return switch (payType) {
|
||||
// case H5_PAY:
|
||||
// return h5Pay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||
case JS_PAY -> jsPay(polyMerchantDTO, notifyUrl, bizData);
|
||||
case LT_PAY -> jsPay(polyMerchantDTO, notifyUrl, bizData);
|
||||
// return h5Pay(merchantDTO, domain, notifyUrl, bizData);
|
||||
case JS_PAY -> jsPay(merchantDTO, notifyUrl, bizData);
|
||||
case LT_PAY -> jsPay(merchantDTO, notifyUrl, bizData);
|
||||
// case SCAN_PAY:
|
||||
// return scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||
// return scanPay(merchantDTO, domain, notifyUrl, bizData);
|
||||
case MICRO_PAY ->
|
||||
//扫码支付 扫描码
|
||||
barPay(polyMerchantDTO, notifyUrl, bizData);
|
||||
barPay(merchantDTO, notifyUrl, bizData);
|
||||
default -> throw new CzgException("原生支付不支持该支付方式: " + bizData.getPayType());
|
||||
};
|
||||
} catch (Exception e) {
|
||||
@@ -56,8 +55,9 @@ public class NativePayAdapter implements PayAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> refund(String domain, String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||
return null;
|
||||
public CzgResult<RefundRespDTO> refund(String domain, String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||
NativeMerchantDTO merchantDTO = getMerchantDTO(payData);
|
||||
return CzgResult.success(PayManager.refund(bizData, notifyUrl, merchantDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +66,7 @@ public class NativePayAdapter implements PayAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> queryRefund(String domain, String payData, String mchRefundNo, String refundOrderId) {
|
||||
public CzgResult<RefundRespDTO> queryRefund(String domain, String payData, String mchRefundNo, String refundOrderId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -79,4 +79,8 @@ public class NativePayAdapter implements PayAdapter {
|
||||
bizData.setNotifyUrl(notifyUrl);
|
||||
return CzgResult.success(PayManager.barPay(bizData, merchantDTO));
|
||||
}
|
||||
|
||||
private NativeMerchantDTO getMerchantDTO(String payData) {
|
||||
return JSONObject.parseObject(payData, NativeMerchantDTO.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.czg.exception.CzgException;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.pay.PolyMerchantDTO;
|
||||
import com.czg.pay.RefundRespDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
@@ -51,10 +52,11 @@ public class PolyPayAdapter implements PayAdapter {
|
||||
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||
public CzgResult<RefundRespDTO> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||
PolyMerchantDTO shopMerchant = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||
bizData.setNotifyUrl(notifyUrl);
|
||||
return PolyPayUtils.refundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
CzgResult<CzgRefundResp> result = PolyPayUtils.refundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
return convertRefundResp(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,9 +67,10 @@ public class PolyPayAdapter implements PayAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> queryRefund(@NotBlank String payData, @NotBlank String domain, String mchRefundNo, String refundOrderId) {
|
||||
public CzgResult<RefundRespDTO> queryRefund(@NotBlank String payData, @NotBlank String domain, String mchRefundNo, String refundOrderId) {
|
||||
PolyMerchantDTO shopMerchant = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||
return PolyPayUtils.queryRefundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
||||
CzgResult<CzgRefundResp> result = PolyPayUtils.queryRefundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
||||
return convertRefundResp(result);
|
||||
}
|
||||
|
||||
private CzgResult<Map<String, Object>> h5Pay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||
@@ -98,4 +101,20 @@ public class PolyPayAdapter implements PayAdapter {
|
||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||
return PolyPayUtils.microPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
}
|
||||
|
||||
private CzgResult<RefundRespDTO> convertRefundResp(CzgResult<CzgRefundResp> result) {
|
||||
if (result.isSuccess()) {
|
||||
RefundRespDTO respDTO = new RefundRespDTO()
|
||||
.setStatus(result.getData().getState())
|
||||
.setMerchantRefundNo(result.getData().getMchRefundNo())
|
||||
.setThirdRefundNo(result.getData().getRefundOrderId())
|
||||
.setPlatform(result.getData().getPayType())
|
||||
.setRefundAmount(result.getData().getRefundAmt())
|
||||
.setRefundTime(result.getData().getRefundTime())
|
||||
.setOriginalData(result.getData().getExtParam());
|
||||
return CzgResult.success(respDTO);
|
||||
}
|
||||
|
||||
return CzgResult.failure(result.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user