Bläddra i källkod

ats支付宝接口

管理员查询添加黔通智联
master
huminghao 1 vecka sedan
förälder
incheckning
0ea985e1eb
21 ändrade filer med 378 tillägg och 68 borttagningar
  1. 4
    1
      gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AliServiceCmd.java
  2. 54
    0
      gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliOrderRefundRequest.java
  3. 27
    0
      gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliOrderRefundResponse.java
  4. 43
    0
      gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliQueryOrderApplyRequest.java
  5. 27
    0
      gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliQueryOrderApplyResponse.java
  6. 2
    1
      zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/SatisfactionManagerImpl.java
  7. 1
    1
      zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/card/InvwCardDetailsManagerImpl.java
  8. 2
    1
      zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/enter/InvwEnterApplyManagerImpl.java
  9. 1
    1
      zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/obu/InvwObuDetailsManagerImpl.java
  10. 3
    2
      zhywpt-app-managew/src/main/java/cn/com/taiji/managew/manager/issueOrder/IssueOrderRefundManagerImpl.java
  11. 2
    1
      zhywpt-app-managew/src/main/java/cn/com/taiji/managew/manager/operation/SatisfactionManagerImpl.java
  12. 1
    0
      zhywpt-app-managew/src/main/java/cn/com/taiji/managew/model/MyFinals.java
  13. 3
    2
      zhywpt-app-settlew/src/main/java/cn/com/taiji/settlew/manager/issueOrder/IssueOrderRefundManagerImpl.java
  14. 1
    0
      zhywpt-app-settlew/src/main/java/cn/com/taiji/settlew/model/MyFinals.java
  15. 0
    3
      zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/system/StaffManagerImpl.java
  16. 0
    1
      zhywpt-app-userw/src/main/java/cn/com/taiji/userw/model/system/StaffVo.java
  17. 30
    52
      zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliCreatePayOrderManager.java
  18. 70
    0
      zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliOrderRefundManager.java
  19. 61
    0
      zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliQueryPayOrderManager.java
  20. 13
    2
      zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/handler/AliServiceHandler.java
  21. 33
    0
      zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/tools/ali/AlipayConfigUtils.java

+ 4
- 1
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AliServiceCmd.java Visa fil

@@ -6,7 +6,10 @@ import cn.com.taiji.core.model.comm.protocol.SignServiceType;
import cn.com.taiji.core.model.comm.protocol.ats.AtsServiceType;

public enum AliServiceCmd implements SignServiceCommand {
ORDERAPPLY("支付宝支付订单申请","OrderApply", AtsAliOrderApplyRequest.class),
ORDERAPPLY("支付宝支付订单申请","orderApply", AtsAliOrderApplyRequest.class),
QUERYORDERAPPLY("查询支付宝支付订单申请结果","queryOrderApply", AtsAliQueryOrderApplyRequest.class),
ORDERREFUND("支付宝支付订单退费","orderRefund", AtsAliOrderRefundRequest.class),

;



+ 54
- 0
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliOrderRefundRequest.java Visa fil

@@ -0,0 +1,54 @@
package cn.com.taiji.core.model.comm.protocol.ats.ali;

import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsRequest;
import cn.com.taiji.core.model.comm.protocol.valid.ErrorMsgBuilder;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;


/**
* @Author:ChenChao
* @Date:2025/5/10 14:17
* @Filename:AtsCreatPayOrder
* @description:
*/
@Getter
@Setter
public class AtsAliOrderRefundRequest extends AbstractAtsRequest<AtsAliOrderRefundResponse> {

@NotBlank
private String privateKey;// 你的商户私钥

@NotBlank
private String publicKey;//商户公钥

@NotBlank
private String appid;//应用ID spAppid;服务商应用ID

@NotBlank
private String outTradeNo;//商户订单号

private String refundReason;//退款原因说明

private String refundAmount;//不填则默认全款

/**
* 退款请求号,标识一次退款请求,需要保证在交易号下唯一,如需部分退款,则此参数必传
* 注:针对同一次退款请求,如果调用接口失败或异常了,重试时需要保证退款请求号不能变更,防止该笔交易重复退款。支付宝会保证同样的退款请求号多次请求只会退一次。
* */
private String outRequestNo;



public AtsAliOrderRefundRequest() {
super(AliServiceCmd.ORDERREFUND);
}


@Override
protected void validate(ErrorMsgBuilder builder) {

}
}

+ 27
- 0
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliOrderRefundResponse.java Visa fil

@@ -0,0 +1,27 @@
package cn.com.taiji.core.model.comm.protocol.ats.ali;

import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsResponse;
import lombok.Getter;
import lombok.Setter;

/**
* @Author:ChenChao
* @Date:2025/5/10 14:17
* @Filename:AtsCreatPayOrder
* @description:
*/
@Getter
@Setter
public class AtsAliOrderRefundResponse extends AbstractAtsResponse {

//商户订单号
private String outTradeNo;

//交易状态,WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
private String tradeStatus;

//交易的订单金额,单位为元,两位小数
private String totalAmount;


}

+ 43
- 0
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliQueryOrderApplyRequest.java Visa fil

@@ -0,0 +1,43 @@
package cn.com.taiji.core.model.comm.protocol.ats.ali;

import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsRequest;
import cn.com.taiji.core.model.comm.protocol.valid.ErrorMsgBuilder;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;


/**
* @Author:ChenChao
* @Date:2025/5/10 14:17
* @Filename:AtsCreatPayOrder
* @description:
*/
@Getter
@Setter
public class AtsAliQueryOrderApplyRequest extends AbstractAtsRequest<AtsAliQueryOrderApplyResponse> {


@NotBlank
private String privateKey;// 你的商户私钥

@NotBlank
private String publicKey;//商户公钥

@NotBlank
private String appid;//应用ID spAppid;服务商应用ID

@NotBlank
private String outTradeNo;//商户订单号


public AtsAliQueryOrderApplyRequest() {
super(AliServiceCmd.QUERYORDERAPPLY);
}

@Override
protected void validate(ErrorMsgBuilder builder) {

}
}

+ 27
- 0
gly-base-core/src/main/java/cn/com/taiji/core/model/comm/protocol/ats/ali/AtsAliQueryOrderApplyResponse.java Visa fil

@@ -0,0 +1,27 @@
package cn.com.taiji.core.model.comm.protocol.ats.ali;

import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsResponse;
import lombok.Getter;
import lombok.Setter;

/**
* @Author:ChenChao
* @Date:2025/5/10 14:17
* @Filename:AtsCreatPayOrder
* @description:
*/
@Getter
@Setter
public class AtsAliQueryOrderApplyResponse extends AbstractAtsResponse {

//商户订单号
private String outTradeNo;

//交易状态,WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
private String tradeStatus;

//交易的订单金额,单位为元,两位小数
private String totalAmount;


}

+ 2
- 1
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/SatisfactionManagerImpl.java Visa fil

@@ -12,6 +12,7 @@ import cn.com.taiji.core.repo.jpa.user.StaffRepo;
import cn.com.taiji.core.repo.request.operation.SatisfactionPageRequest;
import cn.com.taiji.iaw.dto.comm.*;
import cn.com.taiji.iaw.manager.AbstractCommManager;
import cn.com.taiji.iaw.model.MyFinals;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,7 +42,7 @@ public class SatisfactionManagerImpl extends AbstractCommManager implements Sati
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(reqDto.getAccessToken()));
if (staff != null){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(reqDto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 1
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/card/InvwCardDetailsManagerImpl.java Visa fil

@@ -126,7 +126,7 @@ public class InvwCardDetailsManagerImpl extends AbstractInvwManager implements I
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 2
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/enter/InvwEnterApplyManagerImpl.java Visa fil

@@ -25,6 +25,7 @@ import cn.com.taiji.core.repo.jpa.user.StaffRepo;
import cn.com.taiji.core.repo.request.invw.InvwEnterApplyPageRequest;
import cn.com.taiji.invw.dto.enter.*;
import cn.com.taiji.invw.manager.AbstractInvwManager;
import cn.com.taiji.invw.model.MyFinals;
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel;
import cn.com.taiji.invw.tools.GenerateNoUtil;
import cn.com.taiji.invw.tools.SourceTargetMapper;
@@ -70,7 +71,7 @@ public class InvwEnterApplyManagerImpl extends AbstractInvwManager implements In
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(req.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(req.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 1
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/obu/InvwObuDetailsManagerImpl.java Visa fil

@@ -147,7 +147,7 @@ public class InvwObuDetailsManagerImpl extends AbstractInvwManager implements In
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 3
- 2
zhywpt-app-managew/src/main/java/cn/com/taiji/managew/manager/issueOrder/IssueOrderRefundManagerImpl.java Visa fil

@@ -17,6 +17,7 @@ import cn.com.taiji.core.repo.jpa.user.StaffRepo;
import cn.com.taiji.core.repo.request.issue.IssueOrderRefundPageRequest;
import cn.com.taiji.managew.dto.issueOrder.*;
import cn.com.taiji.managew.manager.AbstractManagewManager;
import cn.com.taiji.managew.model.MyFinals;
import cn.com.taiji.managew.model.excel.IssueOrderRefundExcelModel;
import cn.com.taiji.managew.tools.SourceTargetMapper;
import org.apache.commons.lang3.ObjectUtils;
@@ -53,7 +54,7 @@ public class IssueOrderRefundManagerImpl extends AbstractManagewManager implemen
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}
@@ -103,7 +104,7 @@ public class IssueOrderRefundManagerImpl extends AbstractManagewManager implemen
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 2
- 1
zhywpt-app-managew/src/main/java/cn/com/taiji/managew/manager/operation/SatisfactionManagerImpl.java Visa fil

@@ -13,6 +13,7 @@ import cn.com.taiji.managew.dto.operation.satisfactiono.SatisfactionInfoRequestD
import cn.com.taiji.managew.dto.operation.satisfactiono.SatisfactionInfoResponseDTO;
import cn.com.taiji.managew.dto.operation.satisfactiono.SatisfactionPageRequestDTO;
import cn.com.taiji.managew.manager.AbstractCommManager;
import cn.com.taiji.managew.model.MyFinals;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -39,7 +40,7 @@ public class SatisfactionManagerImpl extends AbstractCommManager implements Sati
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (staff != null){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 1
- 0
zhywpt-app-managew/src/main/java/cn/com/taiji/managew/model/MyFinals.java Visa fil

@@ -17,4 +17,5 @@ public class MyFinals extends SysFinals {
public final static int LOGIN_FAILED_EXPIRE = 5;// 分钟
public static final String TOKEN_HEADER = "Authorization";
public static final int EXPIRE_TIME_SECOND = 60;
public static String QTZL_AGENCY_ID = "52010106004";
}

+ 3
- 2
zhywpt-app-settlew/src/main/java/cn/com/taiji/settlew/manager/issueOrder/IssueOrderRefundManagerImpl.java Visa fil

@@ -20,6 +20,7 @@ import cn.com.taiji.core.repo.jpa.user.StaffRepo;
import cn.com.taiji.core.repo.request.issue.IssueOrderRefundPageRequest;
import cn.com.taiji.settlew.dto.issueOrder.*;
import cn.com.taiji.settlew.manager.AbstractSettlewManager;
import cn.com.taiji.settlew.model.MyFinals;
import cn.com.taiji.settlew.model.issueOrder.IssueOrderRefundExcelModel;
import cn.com.taiji.settlew.tools.SourceTargetMapper;
import org.apache.commons.lang3.ObjectUtils;
@@ -58,7 +59,7 @@ public class IssueOrderRefundManagerImpl extends AbstractSettlewManager implemen
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}
@@ -118,7 +119,7 @@ public class IssueOrderRefundManagerImpl extends AbstractSettlewManager implemen
Staff staff = staffRepo.findByOpenId(findOpenIdByToken(dto.getAccessToken()));
if (ObjectUtils.isNotEmpty(staff)){
pageRequest.setAgencyId(staff.getAgencyId());
if ("MANAGER".equals(staff.getIdentityType())){
if ("MANAGER".equals(staff.getIdentityType()) || MyFinals.QTZL_AGENCY_ID.equals(findAgencyIdByToken(dto.getAccessToken()))){
pageRequest.setAgencyId(null);
}
}

+ 1
- 0
zhywpt-app-settlew/src/main/java/cn/com/taiji/settlew/model/MyFinals.java Visa fil

@@ -17,4 +17,5 @@ public class MyFinals extends SysFinals {
public final static int LOGIN_FAILED_EXPIRE = 5;// 分钟
public static final String TOKEN_HEADER = "Authorization";
public static final int EXPIRE_TIME_SECOND = 60;
public static String QTZL_AGENCY_ID = "52010106004";
}

+ 0
- 3
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/system/StaffManagerImpl.java Visa fil

@@ -16,8 +16,6 @@ import cn.com.taiji.core.entity.user.AccountInfo;
import cn.com.taiji.core.entity.user.AccountUserRole;
import cn.com.taiji.core.entity.user.Staff;
import cn.com.taiji.core.entity.user.UserRole;
import cn.com.taiji.core.manager.cache.RedisCacheManager;
import cn.com.taiji.core.manager.cache.RedisKeyGenerator;
import cn.com.taiji.core.manager.tools.DesensitizedUtil;
import cn.com.taiji.core.manager.tools.encryption.SM4Util;
import cn.com.taiji.core.manager.tools.minio.MinioUtil;
@@ -31,7 +29,6 @@ import cn.com.taiji.core.repo.jpa.user.UserRoleRepo;
import cn.com.taiji.userw.dto.system.*;
import cn.com.taiji.userw.manager.AbstractUserwManager;
import cn.com.taiji.userw.manager.excel.listener.StaffRegisterDataListener;
import cn.com.taiji.userw.model.excel.ServiceHallRegisterData;
import cn.com.taiji.userw.model.excel.StaffRegisterData;
import cn.com.taiji.userw.model.system.*;
import cn.com.taiji.userw.repo.jpa.request.system.ServiceHallPageRequest;

+ 0
- 1
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/model/system/StaffVo.java Visa fil

@@ -1,7 +1,6 @@
package cn.com.taiji.userw.model.system;

import cn.com.taiji.common.model.BaseModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

+ 30
- 52
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliCreatePayOrderManager.java Visa fil

@@ -1,6 +1,7 @@
package cn.com.taiji.ats.manager.ali;

import cn.com.taiji.ats.manager.AbstractCommManager;
import cn.com.taiji.ats.manager.tools.ali.AlipayConfigUtils;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderApplyRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderApplyResponse;
@@ -8,20 +9,14 @@ import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.*;
import com.alipay.api.request.AlipayTradeCreateRequest;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradeCreateResponse;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import com.alipay.api.request.*;
import com.alipay.api.response.*;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;


/**
* @Auther: humh
@@ -34,44 +29,31 @@ import org.springframework.util.StringUtils;
public class AliCreatePayOrderManager extends AbstractCommManager {

public AtsAliOrderApplyResponse serviceHandle(AtsAliOrderApplyRequest request) throws ServiceHandleException {
logger.info("支付宝创建订单接口开始{},参数{}", LocalDateTime.now(), request.toJson());
switch (request.getTradeType()) {
case NATIVE:
case NATIVE://原生网页
return nativeOrderApply(request);
case APP:
return pwebOrderApply(request);
case JSAPI:
case APP://APP
return appOrderApply(request);
case JSAPI://小程序
if(!StringUtils.hasText(request.getOpenId())){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("此支付方式openid不能为空");
}
return jsapiOrderApply(request);
case MWEB:
return mwebOrderApply(request);
case MWEB://h5
return h5WebOrderApply(request);
default:
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付方式不存在");
}
}

private AlipayConfig alipayConfig(String privateKey, String publicKey, String appId) {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(appId);
alipayConfig.setPrivateKey(privateKey);//请填写您的应用私钥,例如:MIIEvQIBADANB...
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(publicKey);//请填写您的支付宝公钥,例如:MIIBIjANBg...
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
return alipayConfig;
}


private AtsAliOrderApplyResponse nativeOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayConfig alipayConfig = alipayConfig(request.getPrivateKey(), request.getPublicKey(), request.getAppid());
// 初始化SDK
AlipayClient alipayClient = null;
try {
alipayClient = new DefaultAlipayClient(alipayConfig);
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常!");
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}
AlipayTradePrecreateRequest createRequest = new AlipayTradePrecreateRequest();
AlipayTradePrecreateModel createModel = new AlipayTradePrecreateModel();
@@ -102,14 +84,13 @@ public class AliCreatePayOrderManager extends AbstractCommManager {
}


private AtsAliOrderApplyResponse pwebOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayConfig alipayConfig = alipayConfig(request.getPrivateKey(), request.getPublicKey(), request.getAppid());
// 初始化SDK
private AtsAliOrderApplyResponse h5WebOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayClient alipayClient = null;
try {
alipayClient = new DefaultAlipayClient(alipayConfig);
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常!");
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}
// 构造请求参数以调用接口
AlipayTradeWapPayRequest createRequest = new AlipayTradeWapPayRequest();
@@ -142,13 +123,12 @@ public class AliCreatePayOrderManager extends AbstractCommManager {


private AtsAliOrderApplyResponse jsapiOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayConfig alipayConfig = alipayConfig(request.getPrivateKey(), request.getPublicKey(), request.getAppid());
// 初始化SDK
AlipayClient alipayClient = null;
try {
alipayClient = new DefaultAlipayClient(alipayConfig);
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常!");
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}
// 构造请求参数以调用接口
AlipayTradeCreateRequest createRequest = new AlipayTradeCreateRequest();
@@ -188,18 +168,17 @@ public class AliCreatePayOrderManager extends AbstractCommManager {
}
}

private AtsAliOrderApplyResponse mwebOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayConfig alipayConfig = alipayConfig(request.getPrivateKey(), request.getPublicKey(), request.getAppid());
// 初始化SDK
private AtsAliOrderApplyResponse appOrderApply(AtsAliOrderApplyRequest request) throws ServiceHandleException {
AlipayClient alipayClient = null;
try {
alipayClient = new DefaultAlipayClient(alipayConfig);
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常!");
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}
// 构造请求参数以调用接口
AlipayTradePagePayRequest createRequest = new AlipayTradePagePayRequest();
AlipayTradePagePayModel createModel = new AlipayTradePagePayModel();
AlipayTradeAppPayRequest createRequest = new AlipayTradeAppPayRequest ();
AlipayTradeAppPayModel createModel = new AlipayTradeAppPayModel ();
// 设置商户订单号
createModel.setOutTradeNo(request.getOutTradeNo());
// 设置订单总金额
@@ -207,16 +186,15 @@ public class AliCreatePayOrderManager extends AbstractCommManager {
// 设置订单标题
createModel.setSubject(request.getSubject());
// 设置产品码
createModel.setProductCode("FAST_INSTANT_TRADE_PAY");
createModel.setProductCode("QUICK_MSECURITY_PAY");
// 附加信息
createModel.setBody(request.getBody());
createRequest.setBizModel(createModel);
try {
AlipayTradePagePayResponse createResponse = alipayClient.pageExecute(createRequest);
AlipayTradeAppPayResponse createResponse = alipayClient.pageExecute(createRequest);
if (!createResponse.isSuccess()) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("下单失败:" + createResponse.getMsg() + "-" + createResponse.getSubMsg());
}

AtsAliOrderApplyResponse response = new AtsAliOrderApplyResponse();
response.setOutTradeNo(request.getOutTradeNo());
response.setForm(createResponse.getBody());

+ 70
- 0
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliOrderRefundManager.java Visa fil

@@ -0,0 +1,70 @@
package cn.com.taiji.ats.manager.ali;

import cn.com.taiji.ats.manager.AbstractCommManager;
import cn.com.taiji.ats.manager.tools.ali.AlipayConfigUtils;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderApplyResponse;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderRefundRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliQueryOrderApplyRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliQueryOrderApplyResponse;
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.domain.AlipayTradeQueryModel;
import com.alipay.api.domain.AlipayTradeRefundModel;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeQueryResponse;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;


/**
* @Auther: humh
* @Description:
* @Date: 2025/7/15 17:53
* @email: huminghao@mail.taiji.com.cn
* @version: 1.0
*/
@Service
public class AliOrderRefundManager extends AbstractCommManager {

public AtsAliOrderApplyResponse serviceHandle(AtsAliOrderRefundRequest request) throws ServiceHandleException {
logger.info("支付宝退款接口开始{},参数{}", LocalDateTime.now(), request.toJson());
if (!StringUtils.isEmpty(request.getRefundAmount())){
if (StringUtils.isEmpty(request.getOutRequestNo())){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("退款金额不为空时,则退款请求号参数必传");
}
}
AlipayClient alipayClient = null;
try {
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}

// 构造请求参数以调用接口
AlipayTradeRefundRequest refundRequest = new AlipayTradeRefundRequest();
AlipayTradeRefundModel model = new AlipayTradeRefundModel();

// 设置商户订单号
model.setOutTradeNo(request.getOutTradeNo());

// 设置退款金额
model.setRefundAmount(request.getRefundAmount());

// 设置退款原因说明
model.setRefundReason(request.getRefundReason());

// 设置退款请求号
model.setOutRequestNo(request.getOutRequestNo());

refundRequest.setBizModel(model);

return null;
}

}

+ 61
- 0
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/ali/AliQueryPayOrderManager.java Visa fil

@@ -0,0 +1,61 @@
package cn.com.taiji.ats.manager.ali;

import cn.com.taiji.ats.manager.AbstractCommManager;
import cn.com.taiji.ats.manager.tools.ali.AlipayConfigUtils;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliQueryOrderApplyRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliQueryOrderApplyResponse;
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.domain.*;
import com.alipay.api.request.*;
import com.alipay.api.response.*;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


/**
* @Auther: humh
* @Description:
* @Date: 2025/7/15 17:53
* @email: huminghao@mail.taiji.com.cn
* @version: 1.0
*/
@Service
public class AliQueryPayOrderManager extends AbstractCommManager {

public AtsAliQueryOrderApplyResponse serviceHandle(AtsAliQueryOrderApplyRequest request) throws ServiceHandleException {
logger.info("支付宝订单查询接口接口开始{},参数{}", LocalDateTime.now(), request.toJson());
AlipayClient alipayClient = null;
try {
alipayClient = AlipayConfigUtils.createAlipayClient(request.getAppid(), request.getPrivateKey(), request.getPublicKey());
} catch (AlipayApiException e) {
logger.error("支付宝初始化SDK异常:"+e.getMessage());
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("支付宝初始化SDK异常:"+e.getMessage());
}
// 构造请求参数以调用接口
AlipayTradeQueryRequest queryRequest = new AlipayTradeQueryRequest();
AlipayTradeQueryModel model = new AlipayTradeQueryModel();
// 设置订单支付时传入的商户订单号
model.setOutTradeNo(request.getOutTradeNo());

queryRequest.setBizModel(model);
try {
AlipayTradeQueryResponse queryResponse = alipayClient.execute(queryRequest);
if (!queryResponse.isSuccess()) {
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("下单失败:" + queryResponse.getMsg() + "-" + queryResponse.getSubMsg());
}
AtsAliQueryOrderApplyResponse response = new AtsAliQueryOrderApplyResponse();
response.setOutTradeNo(queryResponse.getOutTradeNo());
response.setTradeStatus(queryResponse.getTradeStatus());
response.setTotalAmount(queryResponse.getTotalAmount());
return response;
} catch (AlipayApiException e) {
logger.error("调用支付宝统一收单线下交易预创建接口失败", e);
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("调用支付宝统一收单线下交易预创建接口失败:" + e.getErrMsg());
}
}

}

+ 13
- 2
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/handler/AliServiceHandler.java Visa fil

@@ -1,6 +1,8 @@
package cn.com.taiji.ats.manager.handler;

import cn.com.taiji.ats.manager.ali.AliCreatePayOrderManager;
import cn.com.taiji.ats.manager.ali.AliOrderRefundManager;
import cn.com.taiji.ats.manager.ali.AliQueryPayOrderManager;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.common.model.file.FileProtocolSystemError;
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest;
@@ -9,6 +11,8 @@ import cn.com.taiji.core.model.comm.protocol.SignJsonRequest;
import cn.com.taiji.core.model.comm.protocol.ats.AtsServiceType;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AliServiceCmd;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderApplyRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliOrderRefundRequest;
import cn.com.taiji.core.model.comm.protocol.ats.ali.AtsAliQueryOrderApplyRequest;
import cn.com.taiji.core.model.comm.protocol.ats.weiXin.*;
import com.zgglyun.common.model.AbstractHttpRequestInfo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +36,10 @@ public class AliServiceHandler extends AbstractAtsServiceHandler<WeiXinServiceCm

@Autowired
private AliCreatePayOrderManager aliCreatePayOrderManager;
@Autowired
private AliQueryPayOrderManager aliQueryPayOrderManager;
@Autowired
private AliOrderRefundManager aliOrderRefundManager;


@Override
@@ -41,8 +49,11 @@ public class AliServiceHandler extends AbstractAtsServiceHandler<WeiXinServiceCm
switch (cmd) {
case ORDERAPPLY:
return aliCreatePayOrderManager.serviceHandle((AtsAliOrderApplyRequest) request);

default:
case QUERYORDERAPPLY:
return aliQueryPayOrderManager.serviceHandle((AtsAliQueryOrderApplyRequest) request);
case ORDERREFUND:
return aliOrderRefundManager.serviceHandle((AtsAliOrderRefundRequest) request);
default:
throw FileProtocolSystemError.NOT_SUPPORT.toHandleException(jsonReq.getIfCode());
}
}

+ 33
- 0
zhywpt-service-ats/src/main/java/cn/com/taiji/ats/manager/tools/ali/AlipayConfigUtils.java Visa fil

@@ -0,0 +1,33 @@
package cn.com.taiji.ats.manager.tools.ali;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;

public class AlipayConfigUtils {

/**
* 静态方法:直接通过参数构建 AlipayConfig
* (仿微信的 initV2Config 风格)
*/
public static AlipayConfig initAlipayConfig(String appId, String privateKey, String alipayPublicKey) {
AlipayConfig config = new AlipayConfig();
config.setServerUrl("https://openapi.alipay.com/gateway.do");
config.setAppId(appId);
config.setPrivateKey(privateKey);
config.setAlipayPublicKey(alipayPublicKey);
config.setCharset("UTF-8");
config.setSignType("RSA2"); // RSA2 或 RSA
config.setFormat("json");
return config;
}

/**
* 静态方法:直接构建 AlipayClient
*/
public static AlipayClient createAlipayClient(String appId, String privateKey, String alipayPublicKey) throws AlipayApiException {
AlipayConfig config = initAlipayConfig(appId, privateKey, alipayPublicKey);
return new DefaultAlipayClient(config);
}
}

Laddar…
Avbryt
Spara