支付类型

This commit is contained in:
2026-01-17 17:32:31 +08:00
parent cf3c58169d
commit 8242a4f905
27 changed files with 84 additions and 86 deletions

View File

@@ -80,13 +80,13 @@ public class EntryManager {
List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>();
if (platform == null || platform.length == 0) {
platform = new String[]{PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY};
platform = new String[]{PayCst.Type.WECHAT, PayCst.Type.ALIPAY};
}
if (ArrayUtil.contains(platform, PayCst.Platform.WECHAT)) {
if (ArrayUtil.contains(platform, PayCst.Type.WECHAT)) {
tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto));
}
if (ArrayUtil.contains(platform, PayCst.Platform.ALIPAY)) {
if (ArrayUtil.contains(platform, PayCst.Type.ALIPAY)) {
tasks.add(() -> AlipayIsvEntryManager.entryMerchant(null, reqDto));
}
@@ -102,11 +102,11 @@ public class EntryManager {
for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) {
// 合并两个进件结果
EntryThirdRespDto respDto = result.result();
if (PayCst.Platform.WECHAT.equals(respDto.getPlatform())) {
if (PayCst.Type.WECHAT.equals(respDto.getPlatform())) {
entryRespDto.setWechatApplyId(respDto.getEntryId());
entryRespDto.setWechatStatus(respDto.getStatus());
entryRespDto.setWechatErrorMsg(respDto.getErrorMsg());
} else if (PayCst.Platform.ALIPAY.equals(respDto.getPlatform())) {
} else if (PayCst.Type.ALIPAY.equals(respDto.getPlatform())) {
entryRespDto.setAlipayOrderId(respDto.getEntryId());
entryRespDto.setAlipayStatus(respDto.getStatus());
entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg());
@@ -384,9 +384,9 @@ public class EntryManager {
// verifyEntryParam(merchantDto);
// uploadParamImage(merchantDto);
//// System.out.println(merchantDto);
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.WECHAT);
// entryMerchant(merchantDto, PayCst.Type.ALIPAY);
// entryMerchant(merchantDto, PayCst.Type.WECHAT, PayCst.Type.ALIPAY);
System.out.println(respDto);
}

View File

@@ -21,15 +21,16 @@ public interface PayCst {
String ALIPAY_ERROR_MSG_KEY = "message";
/**
* 平台
* 支付类型
*/
class Platform {
class Type {
/**
* 微信
* 微信支付
*/
public static final String WECHAT = "WECHAT";
/**
* 支付宝
* 支付宝支付
*/
public static final String ALIPAY = "ALIPAY";
}

View File

@@ -1,6 +1,5 @@
package com.czg;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.pay.*;
import com.czg.third.alipay.AlipayIsvPayManager;
@@ -21,9 +20,9 @@ public class PayManager {
* @return 结果
*/
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
if (PayCst.Type.WECHAT.equals(paramsDto.getPayType())) {
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPayType())) {
return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
@@ -37,9 +36,9 @@ public class PayManager {
* @return 结果
*/
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
if (PayCst.Type.WECHAT.equals(paramsDto.getPayType())) {
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPayType())) {
return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
@@ -50,9 +49,9 @@ public class PayManager {
* 查询订单状态
*/
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(platform)) {
if (PayCst.Type.WECHAT.equals(platform)) {
return WechatPayManager.queryOrder(null, orderNo, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(platform)) {
} else if (PayCst.Type.ALIPAY.equals(platform)) {
return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
@@ -63,9 +62,9 @@ public class PayManager {
* 退款
*/
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
if (PayCst.Type.WECHAT.equals(paramsDto.getPlatform())) {
return WechatPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPlatform())) {
return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");

View File

@@ -106,9 +106,9 @@ public class PayParamsDto {
AssertUtil.isBlank(appId, "appId不能为空");
AssertUtil.isBlank(openId, "用户唯一标识不能为空");
if (PayCst.Platform.WECHAT.equals(platform)) {
if (PayCst.Type.WECHAT.equals(platform)) {
AssertUtil.isBlank(merchantId, "商户ID不能为空");
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
} else if (PayCst.Type.ALIPAY.equals(platform)) {
AssertUtil.isBlank(payParams, "支付参数不能为空");
alipayAuthInfo = JSONObject.parseObject(payParams, AlipayAuthInfoDto.class);
AssertUtil.isNull(alipayAuthInfo, "支付参数错误");

View File

@@ -129,7 +129,7 @@ public class WechatPayNotifyDataDto {
.setMchOrderNo(outTradeNo)
.setThirdOrderNo(transactionId)
.setAmount(getPayAmount())
.setPlatform(PayCst.Platform.WECHAT)
.setPlatform(PayCst.Type.WECHAT)
.setExtData(attach)
.setPaySuccessTime(time)
.setErrorMsg(tradeStateDesc);

View File

@@ -31,7 +31,6 @@ import com.czg.dto.resp.EntryThirdRespDto;
import com.czg.dto.resp.QueryStatusResp;
import com.czg.exception.CzgException;
import com.czg.third.alipay.dto.config.AlipayConfigDto;
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
import com.czg.utils.UploadFileUtil;
import lombok.extern.slf4j.Slf4j;
@@ -60,7 +59,7 @@ public class AlipayEntryManager {
*/
public static QueryStatusResp queryMerchantEntryStatus(AlipayConfigDto configDto, String merchantCode) {
QueryStatusResp queryStatusResp = new QueryStatusResp();
queryStatusResp.setPlatform(PayCst.Platform.ALIPAY);
queryStatusResp.setPlatform(PayCst.Type.ALIPAY);
queryStatusResp.setMerchantCode(merchantCode);
AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
@@ -158,7 +157,7 @@ public class AlipayEntryManager {
public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto);
EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.ALIPAY);
.setPlatform(PayCst.Type.ALIPAY);
try {
AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest();

View File

@@ -30,7 +30,7 @@ public class AlipayIsvEntryManager {
configDto = AlipayConfigDto.getThirdDefaultConfig();
}
QueryStatusResp respDto = new QueryStatusResp()
.setPlatform(PayCst.Platform.ALIPAY);
.setPlatform(PayCst.Type.ALIPAY);
AlipayClient.setApiClient(configDto);
try {
@@ -104,7 +104,7 @@ public class AlipayIsvEntryManager {
}
AlipayClient.setApiClient(configDto);
EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.ALIPAY);
.setPlatform(PayCst.Type.ALIPAY);
try {
String batchNo = createRequest(configDto, reqDto);
respDto.setEntryId(batchNo);

View File

@@ -43,7 +43,7 @@ public class AlipayIsvPayManager {
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
model.setSubject(paramsDto.getSubject());
model.setBody(paramsDto.getBody());
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Type.ALIPAY);
model.setExtendParams(new ExtendParams());
CustomizedParams customizedParams = new CustomizedParams();

View File

@@ -1,7 +1,6 @@
package com.czg.third.wechat;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.PayCst;
@@ -15,7 +14,10 @@ import com.czg.third.wechat.dto.req.entry.*;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryBusinessReqDto;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryLicenseReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.*;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryMiniProgramReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntrySalesInfoReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryWebInfoReqDto;
import com.czg.third.wechat.dto.req.entry.id.WechatEntryIdCardReqDto;
import com.czg.third.wechat.dto.resp.WechatAuditDetail;
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
@@ -50,7 +52,7 @@ public class WechatEntryManager {
*/
public static QueryStatusResp queryMerchantEntryStatus(WechatPayConfigDto configDto, String applyId) {
QueryStatusResp queryStatusResp = new QueryStatusResp();
queryStatusResp.setPlatform(PayCst.Platform.WECHAT);
queryStatusResp.setPlatform(PayCst.Type.WECHAT);
queryStatusResp.setMerchantCode(applyId);
String resp = WechatReqUtils.getReq(configDto, "/v3/applyment4sub/applyment/applyment_id/" + applyId, Map.of());
@@ -109,7 +111,7 @@ public class WechatEntryManager {
*/
public static EntryThirdRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) {
EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.WECHAT);
.setPlatform(PayCst.Type.WECHAT);
try {
WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto);
log.info("微信进件参数:{}", JSONObject.toJSONString(entryReqDto));

View File

@@ -56,7 +56,7 @@ public class WechatPayManager {
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
reqData.put("description", paramsDto.getSubject());
reqData.put("out_trade_no", paramsDto.getMchOrderNo());
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Type.WECHAT);
reqData.put("attach", paramsDto.getExtParam());
JSONObject amount = new JSONObject();
@@ -267,7 +267,7 @@ public class WechatPayManager {
refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
refundParam.put("reason", paramsDto.getRefundReason());
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Platform.WECHAT);
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Type.WECHAT);
JSONObject amount = new JSONObject();
amount.put("total", paramsDto.getOrderTotalAmount());
@@ -291,7 +291,7 @@ public class WechatPayManager {
.setThirdRefundNo(object.getString("refund_id"))
.setRefundTime(object.getString("success_time"))
.setOriginalData(resp)
.setPlatform(PayCst.Platform.WECHAT);
.setPlatform(PayCst.Type.WECHAT);
JSONObject resAmount = object.getJSONObject("amount");
if (resAmount != null) {