From 12e9e6b431d821ebeb91b4ddeaecfc5198deb523 Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期一, 20 十一月 2023 18:17:31 +0800
Subject: [PATCH] 11.11
---
cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java | 291 +++++++++++++++++++++++++++++----------------------------
1 files changed, 148 insertions(+), 143 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 55e132f..ef7e699 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
@@ -20,10 +20,11 @@
import com.dsh.account.feignclient.other.model.SiteBooking;
import com.dsh.account.mapper.RechargeRecordsMapper;
import com.dsh.account.util.httpClinet.HttpClientUtil;
-import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver;
-import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest;
-import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
-import com.github.binarywang.wxpay.service.WxPayService;
+//import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver;
+//import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest;
+//import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
+//import com.github.binarywang.wxpay.service.WxPayService;
+
import org.apache.commons.collections.map.HashedMap;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -75,7 +76,7 @@
private String key = "";//微信商户号
- private String callbackPath = "";//支付回调网关地址
+ private String callbackPath = "8.137.22.229:56666/account";//支付回调网关地址
private String app_cert_path = "C:/cert/alipay/user/app_cert_path.crt";//应用公钥证书路径
@@ -159,44 +160,42 @@
//分账
-
- Integer coursePackagePayments = coursePackageClient.queryByCode(outTradeNo);
- Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo);
- Integer siteBookings = siteClient.queryByCode(outTradeNo);
- List<Integer> stores = new ArrayList<>();
- stores.add(coursePackagePayments);
- stores.add(paymentCompetitions);
- stores.add(siteBookings);
-
- OperatorUser operatorUser = siteClient.queryOperator(stores);
-
- String alipayProportion = operatorUser.getAlipayProportion();
- String alipayNum = operatorUser.getAlipayNum();
-
- ExtendParams extendParams = new ExtendParams();
-// extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID");
- model.setExtendParams(extendParams);
-
- RoyaltyInfo royaltyInfo = new RoyaltyInfo();
-// royaltyInfo.setRoyaltyType("transfer");
-
- RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos();
- royaltyDetailInfo1.setTransOutType("userId");
- royaltyDetailInfo1.setTransOut(aliAppid);
- royaltyDetailInfo1.setTransInType("loginName");
- royaltyDetailInfo1.setTransIn("18398968484");
-
- royaltyDetailInfo1.setDesc("分账描述1");
- royaltyDetailInfo1.setAmountPercentage(alipayProportion);
- List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>();
-
-
-
-
- royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos);
- model.setRoyaltyInfo(royaltyInfo);
-
-
+// Integer coursePackagePayments = coursePackageClient.queryByCode(outTradeNo);
+// Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo);
+// Integer siteBookings = siteClient.queryByCode(outTradeNo);
+// List<Integer> stores = new ArrayList<>();
+// stores.add(coursePackagePayments);
+// stores.add(paymentCompetitions);
+// stores.add(siteBookings);
+//
+// OperatorUser operatorUser = siteClient.queryOperator(stores);
+//
+// String alipayProportion = operatorUser.getAlipayProportion();
+// String alipayNum = operatorUser.getAlipayNum();
+//
+// ExtendParams extendParams = new ExtendParams();
+//// extendParams.setSysServiceProviderId("YOUR_SERVICE_PROVIDER_ID");
+// model.setExtendParams(extendParams);
+//
+// RoyaltyInfo royaltyInfo = new RoyaltyInfo();
+//// royaltyInfo.setRoyaltyType("transfer");
+//
+//
+// RoyaltyDetailInfos royaltyDetailInfo1 = new RoyaltyDetailInfos();
+// royaltyDetailInfo1.setTransOutType("userId");
+// royaltyDetailInfo1.setTransOut(aliAppid);
+// royaltyDetailInfo1.setTransInType("loginName");
+// royaltyDetailInfo1.setTransIn("18398968484");
+//
+// royaltyDetailInfo1.setDesc("分账描述1");
+// royaltyDetailInfo1.setAmountPercentage(alipayProportion);
+// List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>();
+//
+//
+//
+// royaltyInfo.setRoyaltyDetailInfos(royaltyDetailInfos);
+// model.setRoyaltyInfo(royaltyInfo);
+// System.err.println("=================="+royaltyInfo);
//
request.setBizModel(model);
request.setNotifyUrl(callbackPath + notifyUrl);
@@ -205,6 +204,7 @@
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
Map<String, String> map = new HashMap<>();
map.put("orderString", response.getBody());
+ map.put("returnId",passbackParams);
System.out.println(map);//就是orderString 可以直接给客户端请求,无需再做处理。
return ResultUtil.success(map);
} catch (AlipayApiException e) {
@@ -315,19 +315,20 @@
* @return
* @throws Exception
*/
- public ResultUtil queryALIOrder(String out_trade_no) throws Exception{
+ public AlipayTradeQueryResponse queryALIOrder(String out_trade_no) throws Exception{
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppid, appPrivateKey,"json","UTF-8",alipay_public_key,"RSA2");
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
request.setBizContent("{" +
" \"out_trade_no\":\"" + out_trade_no + "\"" +
"}");
AlipayTradeQueryResponse response = alipayClient.execute(request);
- if(response.isSuccess()){
- String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
- return ResultUtil.success(tradeStatus);
- } else {
- return ResultUtil.error(response.getMsg());
- }
+ return response;
+// if(response.isSuccess()){
+// String tradeStatus = response.getTradeStatus();//交易状态:WAIT_BUYER_PAY(交易创建,等待买家付款)、TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、TRADE_SUCCESS(交易支付成功)、TRADE_FINISHED(交易结束,不可退款)
+// return ResultUtil.success(response);
+// } else {
+// return ResultUtil.error(response.getMsg());
+// }
}
@@ -401,6 +402,10 @@
if("SUCCESS".equals(result_code)){
String type = map1.get("trade_type");
String prepay_id = map1.get("prepay_id");
+
+
+
+
switch (type){
case "JSAPI":
//重新进行签名后返回给前端
@@ -500,107 +505,107 @@
@Resource
private SiteClient siteClient;
- @Autowired
- private WxPayService wxPayService;
+// @Autowired
+// private WxPayService wxPayService;
//分账
- public ResultUtil order(String code) throws Exception {
-
-
-
- Integer coursePackagePayments = coursePackageClient.queryByCode(code);
- Integer paymentCompetitions = competitionsClient.queryByCode(code);
- Integer siteBookings = siteClient.queryByCode(code);
- List<Integer> stores = new ArrayList<>();
- stores.add(coursePackagePayments);
- stores.add(paymentCompetitions);
- stores.add(siteBookings);
-
- OperatorUser operatorUser = siteClient.queryOperator(stores);
-
-
- WxPayService myWxPayService = wxPayService.switchoverTo("mch_id");
-
- ProfitSharingV3Service profitSharingV3Service = myWxPayService.getProfitSharingV3Service();
-
- String nonceStr = RandomUtil.randomString(32);
- String appId = "您的appid";
-
-
- //添加分账方
-
+// public ResultUtil order(String code) throws Exception {
+//
+//
+//
+// Integer coursePackagePayments = coursePackageClient.queryByCode(code);
+// Integer paymentCompetitions = competitionsClient.queryByCode(code);
+// Integer siteBookings = siteClient.queryByCode(code);
+// List<Integer> stores = new ArrayList<>();
+// stores.add(coursePackagePayments);
+// stores.add(paymentCompetitions);
+// stores.add(siteBookings);
+//
+// OperatorUser operatorUser = siteClient.queryOperator(stores);
+//
+//
+//// WxPayService myWxPayService = wxPayService.switchoverTo("mch_id");
+////
+//// ProfitSharingV3Service profitSharingV3Service = myWxPayService.getProfitSharingV3Service();
+//
+// String nonceStr = RandomUtil.randomString(32);
+// String appId = "您的appid";
+//
+//
+// //添加分账方
+//
+//// ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver();
+//// profitSharingReceiver.setAccount("appid对应的openId");
+//// profitSharingReceiver.setAmount(1l);
+//// profitSharingReceiver.setAppid(appId);
+//// profitSharingReceiver.setType("PERSONAL_OPENID");
+//// profitSharingReceiver.setRelationType("PARTNER");
+//// profitSharingV3Service.addProfitSharingReceiver(profitSharingReceiver);
+//
+// //分账
+// ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest();
+// profitSharingRequest.setAppid(appId);
+// profitSharingRequest.setTransactionId("微信支付订单号");
+// profitSharingRequest.setOutOrderNo("业务系统唯一编号");
+// //分账完成后,剩余金额自动解冻并返回给商户账号,默认false
+// profitSharingRequest.setUnfreezeUnsplit(true);
+// //待分账金额1元
+// Long money = 1L;
+// List<ProfitSharingReceiver> profitSharingReceivers = new ArrayList<>();
// ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver();
-// profitSharingReceiver.setAccount("appid对应的openId");
-// profitSharingReceiver.setAmount(1l);
+// profitSharingReceiver.setAccount("appid对应的openId,分账用户1");
+//
+//
+// //分账百分之5
+// profitSharingReceiver.setAmount(money * 100 / 5);
// profitSharingReceiver.setAppid(appId);
// profitSharingReceiver.setType("PERSONAL_OPENID");
// profitSharingReceiver.setRelationType("PARTNER");
-// profitSharingV3Service.addProfitSharingReceiver(profitSharingReceiver);
-
- //分账
- ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest();
- profitSharingRequest.setAppid(appId);
- profitSharingRequest.setTransactionId("微信支付订单号");
- profitSharingRequest.setOutOrderNo("业务系统唯一编号");
- //分账完成后,剩余金额自动解冻并返回给商户账号,默认false
- profitSharingRequest.setUnfreezeUnsplit(true);
- //待分账金额1元
- Long money = 1L;
- List<ProfitSharingReceiver> profitSharingReceivers = new ArrayList<>();
- ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver();
- profitSharingReceiver.setAccount("appid对应的openId,分账用户1");
-
-
- //分账百分之5
- profitSharingReceiver.setAmount(money * 100 / 5);
- profitSharingReceiver.setAppid(appId);
- profitSharingReceiver.setType("PERSONAL_OPENID");
- profitSharingReceiver.setRelationType("PARTNER");
- profitSharingReceiver.setDescription("test01");
- profitSharingReceivers.add(profitSharingReceiver);
-
- ProfitSharingReceiver receiver = new ProfitSharingReceiver();
- receiver.setAccount("appid对应的openId,分账用户2");
- //百分之10
- receiver.setAmount(money * 100 / 10);
- receiver.setAppid(appId);
- receiver.setType("PERSONAL_OPENID");
- receiver.setRelationType("PARTNER");
- receiver.setDescription("test02");
- profitSharingReceivers.add(receiver);
-
-
- profitSharingRequest.setReceivers(profitSharingReceivers);
-
- profitSharingV3Service.profitSharing(profitSharingRequest);
-
-
-
-
-// Map<String,String> headers = new HashMap<>();
-// headers.put("Authorization",map.get("sign"));
-// headers.put("Accept","application/json");
-// headers.put("Wechatpay-Serial",certPath);
+// profitSharingReceiver.setDescription("test01");
+// profitSharingReceivers.add(profitSharingReceiver);
//
-// List<Receivers> receivers = new ArrayList<>();
+// ProfitSharingReceiver receiver = new ProfitSharingReceiver();
+// receiver.setAccount("appid对应的openId,分账用户2");
+// //百分之10
+// receiver.setAmount(money * 100 / 10);
+// receiver.setAppid(appId);
+// receiver.setType("PERSONAL_OPENID");
+// receiver.setRelationType("PARTNER");
+// receiver.setDescription("test02");
+// profitSharingReceivers.add(receiver);
//
-// Map<String,Object> body = new HashMap<>();
-// body.put("appid",appid);
-// body.put("transaction_id",map.get("transaction_id"));
-// body.put("out_order_no",map.get("out_trade_no"));
-// body.put("receivers",receivers);
-// body.put("unfreeze_unsplit",true);
-
- //支付分账
-// String url ="https://api.mch.weixin.qq.com/v3/profitsharing/orders";
-// CloseableHttpResponse closeableHttpResponse = HttpClientUtil.setPostHttpRequset(url, body, headers, "application/json");
//
-
- return null;
-
-
-
-
- }
+// profitSharingRequest.setReceivers(profitSharingReceivers);
+//
+// profitSharingV3Service.profitSharing(profitSharingRequest);
+//
+//
+//
+//
+//// Map<String,String> headers = new HashMap<>();
+//// headers.put("Authorization",map.get("sign"));
+//// headers.put("Accept","application/json");
+//// headers.put("Wechatpay-Serial",certPath);
+////
+//// List<Receivers> receivers = new ArrayList<>();
+////
+//// Map<String,Object> body = new HashMap<>();
+//// body.put("appid",appid);
+//// body.put("transaction_id",map.get("transaction_id"));
+//// body.put("out_order_no",map.get("out_trade_no"));
+//// body.put("receivers",receivers);
+//// body.put("unfreeze_unsplit",true);
+//
+// //支付分账
+//// String url ="https://api.mch.weixin.qq.com/v3/profitsharing/orders";
+//// CloseableHttpResponse closeableHttpResponse = HttpClientUtil.setPostHttpRequset(url, body, headers, "application/json");
+////
+//
+// return null;
+//
+//
+//
+//
+// }
/**
* 微信扫码收款
--
Gitblit v1.7.1