From 7501140cf637fef9629a80202907ed067c8a5a06 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 08 三月 2024 20:07:45 +0800
Subject: [PATCH] 添加方法
---
cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java | 65 +++++++++++++++++++++++++++++---
1 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java b/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java
index 0f8df47..045db5c 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java
@@ -71,12 +71,13 @@
private String appid = "";//微信appid
private String appletsAppid = "";//微信小程序appid
+ private String smid = "2088330203191220";//平台支付宝商户号
private String mchId = "";//微信商户号
private String key = "";//微信商户号
- private String callbackPath = "http://8.137.22.229:56666/account";//支付回调网关地址
+ private String callbackPath = "http://221.182.45.100:56666/account";//支付回调网关地址
private String app_cert_path = "C:/cert/alipay/user/app_cert_path.crt";//应用公钥证书路径
@@ -90,7 +91,7 @@
/**
* 支付宝支付
*/
- public ResultUtil alipay(String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) {
+ public ResultUtil alipay(String smid,String body, String subject, String passbackParams, String outTradeNo, String amount, String notifyUrl) {
// //构造client
// CertAlipayRequest certAlipayRequest = new CertAlipayRequest ();
// //设置网关地址
@@ -142,7 +143,6 @@
// e.printStackTrace();
// }
-
//实例化客户端
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2");
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
@@ -156,8 +156,21 @@
model.setTotalAmount(amount);//付款金额
model.setProductCode("QUICK_MSECURITY_PAY");
model.setPassbackParams(passbackParams);//自定义参数
-
-
+ SettleInfo settleInfo = new SettleInfo();
+ settleInfo.setSettlePeriodTime("3d");
+ SettleDetailInfo settleDetailInfo = new SettleDetailInfo();
+ settleDetailInfo.setTransInType("defaultSettle");
+ settleDetailInfo.setAmount(amount);
+ List<SettleDetailInfo> settleDetailInfos = new ArrayList<>();
+ settleDetailInfos.add(settleDetailInfo);
+ settleInfo.setSettleDetailInfos(settleDetailInfos);
+ model.setSettleInfo(settleInfo);
+ SubMerchant subMerchant = new SubMerchant();
+ subMerchant.setMerchantId(smid);
+ model.setSubMerchant(subMerchant);
+ ExtendParams extendParams = new ExtendParams();
+ extendParams.setRoyaltyFreeze("true");// 冻结资金 用于后续分账处理
+ model.setExtendParams(extendParams);
//分账
// Integer coursePackagePayments = coursePackageClient.queryByCode(outTradeNo);
// Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo);
@@ -245,7 +258,47 @@
System.err.print(alipay_trade_precreate_response.getString("qr_code"));
return ResultUtil.success(alipay_trade_precreate_response.getString("qr_code"));
}
-
+ // 直付通模式 alipay.trade.settle.confirm(统一收单确认结算接口)
+ public ResultUtil confirm(String smid1,String code, String outTradeNo, String amount) {
+ AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
+ aliAppid,
+ appPrivateKey,
+ "json",
+ "GBK",
+ alipay_public_key,
+ "RSA2");
+ AlipayTradeSettleConfirmRequest request = new AlipayTradeSettleConfirmRequest();
+ request.setBizContent("{" +
+ " \"out_request_no\":\""+code+"\"," +
+ " \"trade_no\":\""+outTradeNo+"\"," +
+ " \"settle_info\":{" +
+ " \"settle_detail_infos\":[" +
+ " {" +
+ " \"trans_in_type\":\"defaultSettle\"," +
+ " \"settle_entity_id\":\""+smid1+"\"," +
+ " \"settle_entity_type\":\"SecondMerchant\"," +
+ " \"amount\":"+amount+"," +
+ " }" +
+ " ]" +
+ " }," +
+ " \"extend_params\":{" +
+ " \"royalty_freeze\":\"false\"" +
+ " }" +
+ "}");
+ AlipayTradeSettleConfirmResponse response = null;
+ try {
+ response = alipayClient.execute(request);
+ } catch (AlipayApiException e) {
+ e.printStackTrace();
+ }
+ if(response.isSuccess()){
+ System.out.println("调用成功");
+ return ResultUtil.success();
+ } else {
+ System.out.println("调用失败");
+ return ResultUtil.error("出现问题啦");
+ }
+ }
/**
* 支付成功后的回调处理逻辑
--
Gitblit v1.7.1