From a6b90f5322402c0345d9c5789876ffe26aef24f9 Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期三, 11 十月 2023 09:59:24 +0800
Subject: [PATCH] 10.12

---
 .idea/workspace.xml                                                       |   20 ++++--
 cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java |  123 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 129 insertions(+), 14 deletions(-)

diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2c58527..52d1bf5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -25,13 +25,9 @@
     <select />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="cb08d02f-fd4f-4fa2-85fe-abd508fa83ac" name="Default Changelist" comment="10.8">
+    <list default="true" id="cb08d02f-fd4f-4fa2-85fe-abd508fa83ac" name="Default Changelist" comment="10.11">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/cloud-server-account/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-server-account/pom.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/SiteClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/SiteClient.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-server-account/src/main/java/com/dsh/account/util/PayMoneyUtil.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/cloud-server-other/src/main/java/com/dsh/other/entity/Store.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-server-other/src/main/java/com/dsh/other/entity/Store.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -647,7 +643,15 @@
       <option name="project" value="LOCAL" />
       <updated>1696753188954</updated>
     </task>
-    <option name="localTasksCounter" value="41" />
+    <task id="LOCAL-00041" summary="10.11">
+      <option name="closed" value="true" />
+      <created>1696932564568</created>
+      <option name="number" value="00041" />
+      <option name="presentableId" value="LOCAL-00041" />
+      <option name="project" value="LOCAL" />
+      <updated>1696932564568</updated>
+    </task>
+    <option name="localTasksCounter" value="42" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -670,7 +674,6 @@
     </option>
   </component>
   <component name="VcsManagerConfiguration">
-    <MESSAGE value="后台代码删除" />
     <MESSAGE value="后台代码" />
     <MESSAGE value="9.15" />
     <MESSAGE value="学员" />
@@ -695,7 +698,8 @@
     <MESSAGE value="9.26。15" />
     <MESSAGE value="10.8" />
     <MESSAGE value="10.8。1" />
-    <option name="LAST_COMMIT_MESSAGE" value="10.8。1" />
+    <MESSAGE value="10.11" />
+    <option name="LAST_COMMIT_MESSAGE" value="10.11" />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>
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 551c246..55e132f 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
@@ -1,16 +1,17 @@
 package com.dsh.account.util;
 
+import cn.hutool.core.util.RandomUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alipay.api.AlipayApiException;
 import com.alipay.api.AlipayClient;
 import com.alipay.api.CertAlipayRequest;
 import com.alipay.api.DefaultAlipayClient;
-import com.alipay.api.domain.AlipayTradeAppPayModel;
-import com.alipay.api.domain.AlipayTradeQueryModel;
+import com.alipay.api.domain.*;
 import com.alipay.api.request.*;
 import com.alipay.api.response.*;
 import com.dsh.account.dto.Receivers;
+import com.dsh.account.entity.OperatorUser;
 import com.dsh.account.feignclient.competition.DeductionCompetitionsClient;
 import com.dsh.account.feignclient.competition.model.PaymentCompetition;
 import com.dsh.account.feignclient.course.CoursePackageClient;
@@ -19,6 +20,10 @@
 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 org.apache.commons.collections.map.HashedMap;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -26,6 +31,7 @@
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
@@ -150,6 +156,48 @@
         model.setTotalAmount(amount);//付款金额
         model.setProductCode("QUICK_MSECURITY_PAY");
         model.setPassbackParams(passbackParams);//自定义参数
+
+
+        //分账
+
+        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);
+
+
+        //
         request.setBizModel(model);
         request.setNotifyUrl(callbackPath + notifyUrl);
         try {
@@ -452,15 +500,78 @@
 
     @Resource
     private SiteClient siteClient;
+    @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);
+                  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,分账用户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);
 
 
 
@@ -484,10 +595,10 @@
 //                    CloseableHttpResponse closeableHttpResponse = HttpClientUtil.setPostHttpRequset(url, body, headers, "application/json");
 //
 
+            return  null;
 
 
 
-        return ResultUtil.success();
 
     }
 

--
Gitblit v1.7.1