Browse Source

增加分账接口

missmylove 4 years ago
parent
commit
b5f727f6af
22 changed files with 1586 additions and 553 deletions
  1. 309 309
      .idea/workspace.xml
  2. 2 0
      src/main/java/com/wechat/WeChatPayServersApplication.java
  3. 13 6
      src/main/java/com/wechat/common/enums/RegisterStatus.java
  4. 17 0
      src/main/java/com/wechat/common/enums/SepAccountEnums.java
  5. 25 0
      src/main/java/com/wechat/common/enums/SepAccountErrorCodeError.java
  6. 76 49
      src/main/java/com/wechat/common/util/ClientCustomSSL.java
  7. 1 2
      src/main/java/com/wechat/common/util/WeChatUtil.java
  8. 54 5
      src/main/java/com/wechat/controller/sepAccount/SepAccountController.java
  9. 26 0
      src/main/java/com/wechat/core/KtjTimeUnit.java
  10. 7 0
      src/main/java/com/wechat/dao/sepAccount/SepRecordDao.java
  11. 10 0
      src/main/java/com/wechat/dao/sepAccount/SepUserDao.java
  12. 7 0
      src/main/java/com/wechat/dao/sepAccount/SepUserRecordDao.java
  13. 0 4
      src/main/java/com/wechat/entity/sepAccount/H.java
  14. 105 0
      src/main/java/com/wechat/entity/sepAccount/KtjSepRecord.java
  15. 134 0
      src/main/java/com/wechat/entity/sepAccount/KtjSepUser.java
  16. 73 0
      src/main/java/com/wechat/entity/sepAccount/KtjSepUserRecord.java
  17. 3 3
      src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java
  18. 32 0
      src/main/java/com/wechat/entity/sepAccount/help/SepUserHandleHelp.java
  19. 22 0
      src/main/java/com/wechat/service/sepAccount/ISepAccountService.java
  20. 397 175
      src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java
  21. 273 0
      src/main/java/com/wechat/service/sepAccount/impl/SepAccountTest.java
  22. BIN
      target/classes/com/wechat/common/util/WeChatUtil.class

+ 309 - 309
.idea/workspace.xml

@@ -2,8 +2,15 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="5f8773c2-5a61-46f3-970b-7546734b3165" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/common/enums/RegisterStatus.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/common/enums/RegisterStatus.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUtil.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/H.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUser.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/ISepAccountService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/ISepAccountService.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java" afterDir="false" />
     </list>
     <ignored path="$PROJECT_DIR$/target/" />
@@ -69,8 +76,8 @@
       </usages-collector>
       <usages-collector id="statistics.file.extensions.open">
         <counts>
-          <entry key="class" value="1" />
-          <entry key="java" value="38" />
+          <entry key="class" value="3" />
+          <entry key="java" value="74" />
           <entry key="md" value="1" />
           <entry key="xml" value="1" />
           <entry key="yml" value="1" />
@@ -78,8 +85,8 @@
       </usages-collector>
       <usages-collector id="statistics.file.types.open">
         <counts>
-          <entry key="CLASS" value="1" />
-          <entry key="JAVA" value="38" />
+          <entry key="CLASS" value="3" />
+          <entry key="JAVA" value="74" />
           <entry key="Markdown" value="1" />
           <entry key="XML" value="1" />
           <entry key="YAML" value="1" />
@@ -87,13 +94,15 @@
       </usages-collector>
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
-          <entry key="java" value="2217" />
+          <entry key="dummy" value="7" />
+          <entry key="java" value="11081" />
           <entry key="xml" value="2" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.edit">
         <counts>
-          <entry key="JAVA" value="2217" />
+          <entry key="JAVA" value="11081" />
+          <entry key="PLAIN_TEXT" value="7" />
           <entry key="XML" value="2" />
         </counts>
       </usages-collector>
@@ -102,13 +111,19 @@
   <component name="FileEditorManager">
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUserRecord.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="64">
-              <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
+            <state relative-caret-position="68">
+              <caret line="4" column="29" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="29" />
               <folding>
-                <element signature="imports" expanded="true" />
-                <element signature="class#SepUser#0;class#SepAccountServiceImpl#0" />
+                <element signature="e#380#381#0" expanded="true" />
+                <element signature="e#412#413#0" expanded="true" />
+                <element signature="e#462#463#0" expanded="true" />
+                <element signature="e#504#505#0" expanded="true" />
+                <element signature="e#899#900#0" expanded="true" />
+                <element signature="e#945#946#0" expanded="true" />
+                <element signature="e#1059#1060#0" expanded="true" />
+                <element signature="e#1099#1100#0" expanded="true" />
               </folding>
             </state>
           </provider>
@@ -119,6 +134,7 @@
   <component name="FileTemplateManagerImpl">
     <option name="RECENT_TEMPLATES">
       <list>
+        <option value="Enum" />
         <option value="Interface" />
         <option value="Class" />
       </list>
@@ -127,6 +143,7 @@
   <component name="FindInProjectRecents">
     <findStrings>
       <find>HMAC-SHA256</find>
+      <find>SepAccountEnums</find>
     </findStrings>
     <dirStrings>
       <dir>F:\康体佳\微信支付\comtika-we-chat-pay</dir>
@@ -147,7 +164,6 @@
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/controller/merchant/Tess.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/config/ProjectConfig.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/config/DBConfig.java" />
-        <option value="$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/KtjUploadBase.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/controller/photo/uploadFileTest.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/controller/photo/WechatUploadUtil.java" />
@@ -159,16 +175,34 @@
         <option value="$PROJECT_DIR$/src/main/resources/application.yml" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/service/upload/impl/UploadServiceImpl.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/UserSepReceiver.java" />
-        <option value="$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java" />
-        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/parameter/ProjectConstant.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/ComtikaWeChatUtil.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/HMACSHA256.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/WxXmlParser.java" />
         <option value="$PROJECT_DIR$/pom.xml" />
-        <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUtil.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/enums/SepAccountEnums.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/enums/SepAccountErrorCodeError.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/H.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountTest.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepUserDao.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/common/enums/RegisterStatus.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUser.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepAccountHandleHelp.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepUserQueryHelp.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepRecordDao.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepUserRecordDao.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUserRecord.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/core/Time.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/core/TimeUnit.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/core/KtjTimeUnit.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/ISepAccountService.java" />
         <option value="$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepRecord.java" />
       </list>
     </option>
   </component>
@@ -186,7 +220,7 @@
       </MavenGeneralSettings>
     </option>
   </component>
-  <component name="ProjectFrameBounds">
+  <component name="ProjectFrameBounds" extendedState="6">
     <option name="x" value="-10" />
     <option name="y" value="-10" />
     <option name="width" value="1386" />
@@ -278,35 +312,7 @@
               <item name="main" type="462c0819:PsiDirectoryNode" />
               <item name="java" type="462c0819:PsiDirectoryNode" />
               <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="common" type="462c0819:PsiDirectoryNode" />
-              <item name="util" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="controller" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="dao" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="service" type="462c0819:PsiDirectoryNode" />
+              <item name="entity" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
               <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
@@ -315,48 +321,9 @@
               <item name="main" type="462c0819:PsiDirectoryNode" />
               <item name="java" type="462c0819:PsiDirectoryNode" />
               <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="service" type="462c0819:PsiDirectoryNode" />
+              <item name="entity" type="462c0819:PsiDirectoryNode" />
               <item name="sepAccount" type="462c0819:PsiDirectoryNode" />
             </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="service" type="462c0819:PsiDirectoryNode" />
-              <item name="sepAccount" type="462c0819:PsiDirectoryNode" />
-              <item name="impl" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="service" type="462c0819:PsiDirectoryNode" />
-              <item name="upload" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="wechat" type="462c0819:PsiDirectoryNode" />
-              <item name="service" type="462c0819:PsiDirectoryNode" />
-              <item name="upload" type="462c0819:PsiDirectoryNode" />
-              <item name="impl" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="comtika-we-chat-pay" type="b2602c69:ProjectViewProjectNode" />
-              <item name="comtika-we-chat-pay" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="resources" type="462c0819:PsiDirectoryNode" />
-            </path>
           </expand>
           <select />
         </subPane>
@@ -370,7 +337,7 @@
     <property name="RequestMappingsPanelWidth1" value="75" />
     <property name="WebServerToolWindowFactoryState" value="false" />
     <property name="aspect.path.notification.shown" value="true" />
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1587190570600" />
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1587210562133" />
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -492,15 +459,15 @@
       <updated>1585659003567</updated>
       <workItem from="1585659008051" duration="4876000" />
       <workItem from="1585967285544" duration="5041000" />
-      <workItem from="1587170301385" duration="15535000" />
+      <workItem from="1587170301385" duration="35482000" />
     </task>
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="25452000" />
+    <option name="totallyTimeSpent" value="45399000" />
   </component>
   <component name="ToolWindowManager">
-    <frame x="-10" y="-10" width="1386" height="788" extended-state="0" />
+    <frame x="-8" y="-8" width="1382" height="754" extended-state="6" />
     <editor active="true" />
     <layout>
       <window_info id="Image Layers" order="0" />
@@ -509,17 +476,17 @@
       <window_info id="Capture Tool" order="3" />
       <window_info id="Web" order="4" side_tool="true" />
       <window_info id="Designer" order="5" />
-      <window_info active="true" content_ui="combo" id="Project" order="6" visible="true" weight="0.33333334" />
+      <window_info active="true" content_ui="combo" id="Project" order="6" visible="true" weight="0.37670198" />
       <window_info id="Structure" order="7" side_tool="true" weight="0.25" />
-      <window_info anchor="bottom" id="Terminal" order="0" />
+      <window_info anchor="bottom" id="Terminal" order="0" weight="0.06451613" />
       <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" />
-      <window_info anchor="bottom" id="Messages" order="2" weight="0.617737" />
+      <window_info anchor="bottom" id="Messages" order="2" weight="0.61612904" />
       <window_info anchor="bottom" id="Java Enterprise" order="3" />
       <window_info anchor="bottom" id="Database Changes" order="4" show_stripe_button="false" />
       <window_info anchor="bottom" id="Version Control" order="5" />
       <window_info anchor="bottom" id="Spring" order="6" />
       <window_info anchor="bottom" id="Message" order="7" />
-      <window_info anchor="bottom" id="Run" order="8" visible="true" weight="0.29663607" />
+      <window_info anchor="bottom" id="Run" order="8" weight="0.18387097" />
       <window_info anchor="bottom" id="Debug" order="9" weight="0.4" />
       <window_info anchor="bottom" id="Find" order="10" weight="0.32874617" />
       <window_info anchor="bottom" id="Cvs" order="11" weight="0.25" />
@@ -543,17 +510,17 @@
       <window_info id="Capture Tool" order="3" />
       <window_info id="Web" order="4" side_tool="true" />
       <window_info id="Designer" order="5" />
-      <window_info content_ui="combo" id="Project" order="6" visible="true" weight="0.25339368" />
+      <window_info content_ui="combo" id="Project" order="6" visible="true" weight="0.25113463" />
       <window_info id="Structure" order="7" side_tool="true" weight="0.25" />
-      <window_info anchor="bottom" id="Terminal" order="0" />
+      <window_info anchor="bottom" id="Terminal" order="0" weight="0.06451613" />
       <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" />
-      <window_info anchor="bottom" id="Messages" order="2" weight="0.617737" />
+      <window_info anchor="bottom" id="Messages" order="2" weight="0.61612904" />
       <window_info anchor="bottom" id="Java Enterprise" order="3" />
       <window_info anchor="bottom" id="Database Changes" order="4" show_stripe_button="false" />
       <window_info anchor="bottom" id="Version Control" order="5" />
       <window_info anchor="bottom" id="Spring" order="6" />
       <window_info anchor="bottom" id="Message" order="7" />
-      <window_info active="true" anchor="bottom" id="Run" order="8" visible="true" weight="0.41284403" />
+      <window_info active="true" anchor="bottom" id="Run" order="8" visible="true" weight="0.18387097" />
       <window_info anchor="bottom" id="Debug" order="9" weight="0.4" />
       <window_info anchor="bottom" id="Find" order="10" weight="0.32874617" />
       <window_info anchor="bottom" id="Cvs" order="11" weight="0.25" />
@@ -578,247 +545,275 @@
     <option name="myLimit" value="2678400000" />
   </component>
   <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/db/HelperDBConfig.java" />
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/token/ComtikaCertificate.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/merchant/MerchantController.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="357">
-          <caret line="31" column="32" selection-start-line="31" selection-start-column="19" selection-end-line="31" selection-end-column="32" />
+        <state relative-caret-position="51">
+          <caret line="19" column="44" lean-forward="true" selection-start-line="19" selection-start-column="44" selection-end-line="19" selection-end-column="44" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/merchant/Tess.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/pay/jsapi/WeChatPayJsapi.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="289">
-          <caret line="58" column="61" lean-forward="true" selection-start-line="58" selection-start-column="61" selection-end-line="58" selection-end-column="61" />
+        <state relative-caret-position="34">
+          <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/config/SQLManagerConfig.java" />
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/config/FtpConfig.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/pay/WeChatPayJsapiDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="136">
-          <caret line="8" column="33" lean-forward="true" selection-start-line="8" selection-start-column="33" selection-end-line="8" selection-end-column="33" />
+        <state relative-caret-position="51">
+          <caret line="9" column="32" selection-start-line="9" selection-start-column="18" selection-end-line="9" selection-end-column="32" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/resources/SQL config/UserDao.md">
-      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
-        <state split_layout="SPLIT">
-          <first_editor />
-          <second_editor />
+    <entry file="file://$PROJECT_DIR$/src/main/resources/application.yml">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="442">
+          <caret line="26" column="16" lean-forward="true" selection-start-line="26" selection-start-column="16" selection-end-line="26" selection-end-column="16" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/resources/config/db.properties">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/KtjUploadBase.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="34">
-          <caret line="2" column="6" selection-start-line="2" selection-end-line="2" selection-end-column="6" />
+        <state relative-caret-position="119">
+          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
+          <folding>
+            <element signature="e#1263#1264#0" expanded="true" />
+            <element signature="e#1294#1295#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.1.4.RELEASE/spring-boot-autoconfigure-2.1.4.RELEASE.jar!/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="2380">
-          <caret line="254" column="44" selection-start-line="254" selection-start-column="44" selection-end-line="254" selection-end-column="44" />
+    <entry file="file://$PROJECT_DIR$/src/main/resources/SQL config/pay/weChatPayJsapi.md">
+      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
+        <state split_layout="SPLIT">
+          <first_editor relative-caret-position="85">
+            <caret line="5" column="24" selection-start-line="5" selection-start-column="6" selection-end-line="5" selection-end-column="24" />
+          </first_editor>
+          <second_editor />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/config/DBConfig.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/merchant/MiniProgramDetailsDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="153">
-          <caret line="14" column="46" selection-start-line="14" selection-start-column="39" selection-end-line="14" selection-end-column="46" />
-          <folding>
-            <element signature="imports" expanded="true" />
-          </folding>
+        <state relative-caret-position="68">
+          <caret line="6" column="17" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
         </state>
       </provider>
     </entry>
-    <entry file="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.1.4.RELEASE/spring-boot-autoconfigure-2.1.4.RELEASE.jar!/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.class">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/merchant/MerchantDetailsDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="918">
-          <caret line="97" selection-start-line="97" selection-end-line="97" />
+        <state relative-caret-position="68">
+          <caret line="9" column="62" lean-forward="true" selection-start-line="9" selection-start-column="62" selection-end-line="9" selection-end-column="62" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/config/ProjectConfig.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/register/RegisterData.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="119">
-          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
-          <folding>
-            <element signature="imports" expanded="true" />
-          </folding>
+        <state relative-caret-position="34">
+          <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/UserDao.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/merchant/KtjMerchantDetails.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="85">
-          <caret line="10" column="51" selection-start-line="10" selection-start-column="44" selection-end-line="10" selection-end-column="51" />
+        <state relative-caret-position="272">
+          <caret line="152" column="22" lean-forward="true" selection-start-line="152" selection-start-column="22" selection-end-line="152" selection-end-column="22" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/Teqqq.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/merchant/WeChatMerchant.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state>
-          <caret column="24" lean-forward="true" selection-start-column="24" selection-end-column="24" />
+        <state relative-caret-position="153">
+          <caret line="13" column="27" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="27" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/UploadBaseDao.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/WeChatPayJsapiController.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="85">
-          <caret line="5" column="30" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="30" />
+        <state relative-caret-position="-119">
+          <caret line="18" column="15" selection-start-line="18" selection-start-column="1" selection-end-line="18" selection-end-column="15" />
         </state>
       </provider>
     </entry>
-    <entry file="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11.jar!/org/apache/commons/codec/digest/DigestUtils.class">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUploadUtil.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="192">
-          <caret line="191" column="25" selection-start-line="191" selection-start-column="25" selection-end-line="191" selection-end-column="25" />
+        <state relative-caret-position="-853">
+          <caret line="48" column="59" lean-forward="true" selection-start-line="48" selection-start-column="59" selection-end-line="48" selection-end-column="59" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/core/ftp/FtpUtils.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/upload/impl/UploadServiceImpl.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="134">
-          <caret line="100" column="19" selection-start-line="100" selection-start-column="19" selection-end-line="100" selection-end-column="19" />
+        <state relative-caret-position="-154">
+          <caret line="48" column="69" lean-forward="true" selection-start-line="48" selection-start-column="69" selection-end-line="48" selection-end-column="69" />
+          <folding>
+            <element signature="imports" expanded="true" />
+            <element signature="e#1147#1148#0" expanded="true" />
+            <element signature="e#1190#1191#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/merchant/impl/MerchantServiceImpl.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="85">
-          <caret line="6" column="22" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="22" />
-          <folding>
-            <element signature="e#249#250#0" expanded="true" />
-            <element signature="e#327#328#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="99">
+          <caret line="142" column="50" selection-start-line="142" selection-start-column="31" selection-end-line="142" selection-end-column="50" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/upload/IUploadService.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/HMACSHA256.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="153">
-          <caret line="9" column="28" selection-start-line="9" selection-start-column="28" selection-end-line="9" selection-end-column="28" />
+        <state relative-caret-position="136">
+          <caret line="8" column="23" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="23" />
           <folding>
             <element signature="imports" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/photo/PhotoController.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/encrypt/MD5Coding.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="187">
-          <caret line="19" column="42" lean-forward="true" selection-start-line="19" selection-start-column="42" selection-end-line="19" selection-end-column="42" />
+        <state relative-caret-position="131">
+          <caret line="24" column="25" selection-start-line="24" selection-start-column="25" selection-end-line="24" selection-end-column="25" />
           <folding>
-            <element signature="e#726#727#0" expanded="true" />
-            <element signature="e#773#774#0" expanded="true" />
+            <element signature="e#1852#1853#0" expanded="true" />
+            <element signature="e#1901#1902#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/merchant/MerchantController.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatHttp.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="51">
-          <caret line="19" column="44" lean-forward="true" selection-start-line="19" selection-start-column="44" selection-end-line="19" selection-end-column="44" />
+        <state relative-caret-position="391">
+          <caret line="39" column="25" selection-start-line="39" selection-start-column="25" selection-end-line="39" selection-end-column="25" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/pay/jsapi/WeChatPayJsapi.java">
+    <entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.10/httpclient-4.5.10.jar!/org/apache/http/conn/ssl/SSLContextBuilder.class">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="34">
-          <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
+        <state relative-caret-position="162">
+          <caret line="93" column="29" selection-start-line="93" selection-start-column="29" selection-end-line="93" selection-end-column="29" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/pay/WeChatPayJsapiDao.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/parameter/ProjectConstant.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="51">
-          <caret line="9" column="32" selection-start-line="9" selection-start-column="18" selection-end-line="9" selection-end-column="32" />
+        <state relative-caret-position="204">
+          <caret line="34" column="48" selection-start-line="34" selection-start-column="25" selection-end-line="34" selection-end-column="48" />
+          <folding>
+            <element signature="imports" expanded="true" />
+            <element signature="e#156#157#0" expanded="true" />
+            <element signature="e#232#233#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/resources/application.yml">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/ComtikaWeChatUtil.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="442">
-          <caret line="26" column="16" lean-forward="true" selection-start-line="26" selection-start-column="16" selection-end-line="26" selection-end-column="16" />
+        <state relative-caret-position="68">
+          <caret line="16" column="30" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="30" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/KtjUploadBase.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WxXmlParser.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="119">
-          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
-          <folding>
-            <element signature="e#1263#1264#0" expanded="true" />
-            <element signature="e#1294#1295#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="-68">
+          <caret line="35" column="52" lean-forward="true" selection-start-line="35" selection-start-column="52" selection-end-line="35" selection-end-column="52" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/resources/SQL config/pay/weChatPayJsapi.md">
-      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
-        <state split_layout="SPLIT">
-          <first_editor relative-caret-position="85">
-            <caret line="5" column="24" selection-start-line="5" selection-start-column="6" selection-end-line="5" selection-end-column="24" />
-          </first_editor>
-          <second_editor />
+    <entry file="file://$PROJECT_DIR$/pom.xml">
+      <provider editor-type-id="MavenHelperPluginDependencyAnalyzer" />
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="129">
+          <caret line="104" column="21" selection-start-line="104" selection-start-column="21" selection-end-line="104" selection-end-column="21" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/merchant/MiniProgramDetailsDao.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUtil.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="68">
-          <caret line="6" column="17" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
+        <state relative-caret-position="306">
+          <caret line="148" column="37" lean-forward="true" selection-start-line="148" selection-start-column="37" selection-end-line="148" selection-end-column="37" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/merchant/MerchantDetailsDao.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/enums/SepAccountErrorCodeError.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="68">
-          <caret line="9" column="62" lean-forward="true" selection-start-line="9" selection-start-column="62" selection-end-line="9" selection-end-column="62" />
+        <state relative-caret-position="272">
+          <caret line="16" selection-start-line="16" selection-end-line="16" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/H.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="34">
-          <caret line="2" column="14" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
+        <state relative-caret-position="377">
+          <caret line="42" column="75" selection-start-line="42" selection-start-column="59" selection-end-line="42" selection-end-column="75" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/register/RegisterData.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="34">
-          <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
+        <state relative-caret-position="85">
+          <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
+          <folding>
+            <element signature="e#241#242#0" expanded="true" />
+            <element signature="e#271#272#0" expanded="true" />
+            <element signature="e#317#318#0" expanded="true" />
+            <element signature="e#355#356#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/merchant/KtjMerchantDetails.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepUserDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="272">
-          <caret line="152" column="22" lean-forward="true" selection-start-line="152" selection-start-column="22" selection-end-line="152" selection-end-column="22" />
+        <state relative-caret-position="136">
+          <caret line="8" column="26" selection-start-line="8" selection-start-column="26" selection-end-line="8" selection-end-column="26" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/ISepAccountService.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepAccountHandleHelp.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="34">
-          <caret line="2" column="35" selection-start-line="2" selection-start-column="35" selection-end-line="2" selection-end-column="35" />
+        <state relative-caret-position="85">
+          <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
+          <folding>
+            <element signature="e#226#227#0" expanded="true" />
+            <element signature="e#257#258#0" expanded="true" />
+            <element signature="e#305#306#0" expanded="true" />
+            <element signature="e#345#346#0" expanded="true" />
+            <element signature="e#381#382#0" expanded="true" />
+            <element signature="e#413#414#0" expanded="true" />
+            <element signature="e#463#464#0" expanded="true" />
+            <element signature="e#505#506#0" expanded="true" />
+            <element signature="e#540#541#0" expanded="true" />
+            <element signature="e#570#571#0" expanded="true" />
+            <element signature="e#617#618#0" expanded="true" />
+            <element signature="e#655#656#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/merchant/WeChatMerchant.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/enums/SepAccountEnums.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="153">
-          <caret line="13" column="27" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="27" />
+        <state relative-caret-position="34">
+          <caret line="2" column="27" selection-start-line="2" selection-start-column="12" selection-end-line="2" selection-end-column="27" />
+          <folding>
+            <element signature="e#542#543#0" expanded="true" />
+            <element signature="e#568#569#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountTest.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="434">
-          <caret line="29" column="20" selection-start-line="29" selection-start-column="20" selection-end-line="29" selection-end-column="20" />
+        <state relative-caret-position="340">
+          <caret line="255" column="61" lean-forward="true" selection-start-line="255" selection-start-column="8" selection-end-line="255" selection-end-column="61" />
           <folding>
             <element signature="imports" expanded="true" />
           </folding>
@@ -827,179 +822,184 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/UserSepReceiver.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="136">
-          <caret line="8" column="28" selection-start-line="8" selection-start-column="28" selection-end-line="8" selection-end-column="28" />
-          <folding>
-            <element signature="e#310#311#0" expanded="true" />
-            <element signature="e#344#345#0" expanded="true" />
-            <element signature="e#413#414#0" expanded="true" />
-            <element signature="e#459#460#0" expanded="true" />
-            <element signature="e#494#495#0" expanded="true" />
-            <element signature="e#525#526#0" expanded="true" />
-            <element signature="e#573#574#0" expanded="true" />
-            <element signature="e#613#614#0" expanded="true" />
-            <element signature="e#648#649#0" expanded="true" />
-            <element signature="e#679#680#0" expanded="true" />
-            <element signature="e#727#728#0" expanded="true" />
-            <element signature="e#767#768#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="119">
+          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/pay/impl/WeChatPayJsapiServiceImpl.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="255">
-          <caret line="15" column="31" lean-forward="true" selection-start-line="15" selection-start-column="31" selection-end-line="15" selection-end-column="31" />
+        <state relative-caret-position="187">
+          <caret line="37" column="26" lean-forward="true" selection-start-line="37" selection-start-column="26" selection-end-line="37" selection-end-column="26" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUser.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-340">
+          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
           <folding>
-            <element signature="e#243#244#0" expanded="true" />
-            <element signature="e#273#274#0" expanded="true" />
-            <element signature="e#320#321#0" expanded="true" />
-            <element signature="e#358#359#0" expanded="true" />
-            <element signature="e#203#204#0" expanded="true" />
-            <element signature="e#235#236#0" expanded="true" />
-            <element signature="e#285#286#0" expanded="true" />
-            <element signature="e#327#328#0" expanded="true" />
-            <element signature="e#362#363#0" expanded="true" />
-            <element signature="e#393#394#0" expanded="true" />
-            <element signature="e#441#442#0" expanded="true" />
-            <element signature="e#481#482#0" expanded="true" />
+            <element signature="e#2014#2015#0" expanded="true" />
+            <element signature="e#2062#2063#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/WeChatPayJsapiController.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/order/KtjJsapiOrderDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-119">
-          <caret line="18" column="15" selection-start-line="18" selection-start-column="1" selection-end-line="18" selection-end-column="15" />
+        <state relative-caret-position="85">
+          <caret line="7" column="33" selection-start-line="7" selection-start-column="17" selection-end-line="7" selection-end-column="33" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUploadUtil.java">
+    <entry file="jar://H:/JAVA/jdk1.8.0_77/src.zip!/java/lang/Float.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-853">
-          <caret line="48" column="59" lean-forward="true" selection-start-line="48" selection-start-column="59" selection-end-line="48" selection-end-column="59" />
+        <state relative-caret-position="190">
+          <caret line="414" column="24" selection-start-line="414" selection-start-column="24" selection-end-line="414" selection-end-column="24" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/upload/impl/UploadServiceImpl.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/enums/RegisterStatus.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-154">
-          <caret line="48" column="69" lean-forward="true" selection-start-line="48" selection-start-column="69" selection-end-line="48" selection-end-column="69" />
-          <folding>
-            <element signature="imports" expanded="true" />
-            <element signature="e#1147#1148#0" expanded="true" />
-            <element signature="e#1190#1191#0" expanded="true" />
-          </folding>
+        <state relative-caret-position="-102">
+          <caret line="3" column="12" selection-start-line="3" selection-start-column="12" selection-end-line="3" selection-end-column="12" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/pay/impl/WeChatPayJsapiServiceImpl.java">
+    <entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.10/httpclient-4.5.10.jar!/org/apache/http/client/utils/DateUtils.class">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="170">
-          <caret line="87" column="82" selection-start-line="87" selection-start-column="30" selection-end-line="87" selection-end-column="82" />
+        <state relative-caret-position="198">
+          <caret line="64" column="25" selection-start-line="64" selection-start-column="25" selection-end-line="64" selection-end-column="25" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/merchant/impl/MerchantServiceImpl.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepUserRecordDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="99">
-          <caret line="142" column="50" selection-start-line="142" selection-start-column="31" selection-end-line="142" selection-end-column="50" />
+        <state relative-caret-position="85">
+          <caret line="5" column="69" selection-start-line="5" selection-start-column="53" selection-end-line="5" selection-end-column="69" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/HMACSHA256.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/entity/order/KtjJsapiOrder.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="136">
-          <caret line="8" column="23" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="23" />
+        <state relative-caret-position="17">
+          <caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/help/SepUserHandleHelp.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="102">
+          <caret line="6" column="32" selection-start-line="6" selection-start-column="19" selection-end-line="6" selection-end-column="32" />
           <folding>
-            <element signature="imports" expanded="true" />
+            <element signature="e#184#185#0" expanded="true" />
+            <element signature="e#220#221#0" expanded="true" />
+            <element signature="e#278#279#0" expanded="true" />
+            <element signature="e#328#329#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/encrypt/MD5Coding.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/dao/sepAccount/SepRecordDao.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="131">
-          <caret line="24" column="25" selection-start-line="24" selection-start-column="25" selection-end-line="24" selection-end-column="25" />
+        <state relative-caret-position="85">
+          <caret line="5" column="61" selection-start-line="5" selection-start-column="49" selection-end-line="5" selection-end-column="61" />
           <folding>
-            <element signature="e#1852#1853#0" expanded="true" />
-            <element signature="e#1901#1902#0" expanded="true" />
+            <element signature="imports" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatHttp.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/core/ftp/Time.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="391">
-          <caret line="39" column="25" selection-start-line="39" selection-start-column="25" selection-end-line="39" selection-end-column="25" />
+        <state relative-caret-position="34">
+          <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
         </state>
       </provider>
     </entry>
-    <entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.10/httpclient-4.5.10.jar!/org/apache/http/conn/ssl/SSLContextBuilder.class">
+    <entry file="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/5.1.6.RELEASE/spring-context-5.1.6.RELEASE.jar!/org/springframework/scheduling/annotation/Scheduled.class">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="162">
-          <caret line="93" column="29" selection-start-line="93" selection-start-column="29" selection-end-line="93" selection-end-column="29" />
+        <state relative-caret-position="289">
+          <caret line="25" column="19" selection-start-line="25" selection-start-column="9" selection-end-line="25" selection-end-column="19" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/parameter/ProjectConstant.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/controller/sepAccount/SepAccountController.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="204">
-          <caret line="34" column="48" selection-start-line="34" selection-start-column="25" selection-end-line="34" selection-end-column="48" />
+        <state relative-caret-position="383">
+          <caret line="77" column="42" selection-start-line="77" selection-start-column="42" selection-end-line="77" selection-end-column="42" />
           <folding>
             <element signature="imports" expanded="true" />
-            <element signature="e#156#157#0" expanded="true" />
-            <element signature="e#232#233#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/ComtikaWeChatUtil.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/ISepAccountService.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="68">
-          <caret line="16" column="30" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="30" />
+        <state relative-caret-position="272">
+          <caret line="23" column="32" selection-start-line="23" selection-start-column="32" selection-end-line="23" selection-end-column="32" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WxXmlParser.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-68">
-          <caret line="35" column="52" lean-forward="true" selection-start-line="35" selection-start-column="52" selection-end-line="35" selection-end-column="52" />
+        <state relative-caret-position="131">
+          <caret line="37" column="14" lean-forward="true" selection-start-line="37" selection-start-column="14" selection-end-line="37" selection-end-column="14" />
+          <folding>
+            <element signature="imports" expanded="true" />
+            <element signature="method#handleSepUserData#0;class#SepAccountServiceImpl#0" />
+            <element signature="method#initSepUser#0;class#SepAccountServiceImpl#0" />
+            <element signature="method#doWxRequest#0;class#SepAccountServiceImpl#0" />
+            <element signature="e#20144#20145#0" expanded="true" />
+            <element signature="e#20191#20192#0" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/pom.xml">
-      <provider editor-type-id="MavenHelperPluginDependencyAnalyzer" />
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/core/KtjTimeUnit.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="129">
-          <caret line="104" column="21" selection-start-line="104" selection-start-column="21" selection-end-line="104" selection-end-column="21" />
+        <state relative-caret-position="272">
+          <caret line="16" column="14" selection-start-line="16" selection-start-column="5" selection-end-line="16" selection-end-column="14" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/ClientCustomSSL.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/WeChatPayServersApplication.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="672">
-          <caret line="69" selection-start-line="69" selection-end-line="69" />
+        <state relative-caret-position="102">
+          <caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
           <folding>
-            <element signature="imports" expanded="true" />
+            <element signature="e#249#250#0" expanded="true" />
+            <element signature="e#327#328#0" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/common/util/WeChatUtil.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepRecord.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-61">
-          <caret line="140" column="25" selection-start-line="140" selection-start-column="25" selection-end-line="140" selection-end-column="25" />
+        <state relative-caret-position="68">
+          <caret line="4" column="25" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="25" />
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/wechat/entity/sepAccount/KtjSepUserRecord.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="64">
-          <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
+        <state relative-caret-position="68">
+          <caret line="4" column="29" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="29" />
           <folding>
-            <element signature="imports" expanded="true" />
-            <element signature="class#SepUser#0;class#SepAccountServiceImpl#0" />
+            <element signature="e#380#381#0" expanded="true" />
+            <element signature="e#412#413#0" expanded="true" />
+            <element signature="e#462#463#0" expanded="true" />
+            <element signature="e#504#505#0" expanded="true" />
+            <element signature="e#899#900#0" expanded="true" />
+            <element signature="e#945#946#0" expanded="true" />
+            <element signature="e#1059#1060#0" expanded="true" />
+            <element signature="e#1099#1100#0" expanded="true" />
           </folding>
         </state>
       </provider>

+ 2 - 0
src/main/java/com/wechat/WeChatPayServersApplication.java

@@ -2,9 +2,11 @@ package com.wechat;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 
 @SpringBootApplication
+@EnableScheduling
 public class WeChatPayServersApplication {
 	public static void main(String[] args) {
         SpringApplication.run(WeChatPayServersApplication.class, args);

+ 13 - 6
src/main/java/com/wechat/common/enums/RegisterStatus.java

@@ -10,11 +10,11 @@ public enum RegisterStatus {
 	APPLYMENT_STATE_SIGNING(5,"开通权限中","APPLYMENT_STATE_SIGNING"),
 	APPLYMENT_STATE_FINISHED(6,"已完成","APPLYMENT_STATE_FINISHED"),
 	APPLYMENT_STATE_CANCELED(7,"已作废","APPLYMENT_STATE_CANCELED");
-	
+
 	private int id;
-	
+
 	private String status;
-	
+
 	private String type;
 
 	public int getId() {
@@ -46,7 +46,14 @@ public enum RegisterStatus {
 		this.status = status;
 		this.type = type;
 	}
-	
+
+	public static RegisterStatus findRegisterStatus(Integer id){
+		for(RegisterStatus r:RegisterStatus.values()){
+			if(r.id == id) return r;
+		}
+		return null;
+	}
+
 	public static Integer getIdByType(String type){
 		for (RegisterStatus status : RegisterStatus.values()) {
 			if(status.getType().equals(type)){
@@ -55,7 +62,7 @@ public enum RegisterStatus {
 		}
 		return RegisterStatus.APPLYMENT_STATE_AUDITING.getId();
 	}
-	
 
-	
+
+
 }

+ 17 - 0
src/main/java/com/wechat/common/enums/SepAccountEnums.java

@@ -0,0 +1,17 @@
+package com.wechat.common.enums;
+
+public enum SepAccountEnums {
+    单次分账("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"),
+    查询分账结果("https://api.mch.weixin.qq.com/pay/profitsharingquery"),
+    添加分账接收方("https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver"),
+    删除分账接收方("https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver"),
+    完结分账("https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish");
+    private String url;
+    SepAccountEnums(String url){
+        this.url = url;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+}

+ 25 - 0
src/main/java/com/wechat/common/enums/SepAccountErrorCodeError.java

@@ -0,0 +1,25 @@
+package com.wechat.common.enums;
+
+public enum SepAccountErrorCodeError {
+    SYSTEMERROR("接口返回错误","系统超时","请不要更换商户分账单号,请使用相同参数再次调用API。否则可能造成资金损失"),
+    AMOUNT_OVERDUE("分账金额超限","分账金额大于可分金额或大于分账最大比例","分账金额不能大于可分金额或大于最大分账比例金额,请调整分账金额"),
+    RECEIVER_INVALID("分账接收方非法","未配置分账接收方","分账接收方在分账之前需要进行添加"),
+    INVALID_TRANSACTIONID("无效的微信支付订单号","请求参数未按指引进行填写","请求参数错误,检查原交易号是否存在或发起支付交易接口返回失败"),
+    PARAM_ERROR("参数错误","请求参数未按指引进行填写","请求参数错误,请重新检查再调用分账接口"),
+    INVALID_REQUEST("请求不合法","参数中APPID或 MCHID不存在等","请检查请求参数"),
+    OPENID_MISMATCH("Openid错误","Openid 与Appid不匹配","请检查Openid 是否正确"),
+    FREQUENCY_LIMITED("频率限制","请求过多被频率限制","该笔请求未受理,请降低频率后原单重试,请勿更换商户分账单号"),
+    ORDER_NOT_READY("订单处理中","订单处理中,暂时无法分账","订单处理中,暂时无法分账,请稍后再试"),
+    NOAUTH("无分账权限","未开通分账权限","请先开通分账"),
+    ORDERNOTEXIST("分账单不存在","订单号错误或分账单号错误","请检查订单号或分账单号是否有误"),
+    NOT_SHARE_ORDER("非分账订单","不是分账订单 无法分账","下单时请用分账的合适参数");
+
+    private String desc;
+    private String reason;
+    private String advise;
+    SepAccountErrorCodeError(String desc,String reason,String advise){
+        this.desc = desc;
+        this.reason = reason;
+        this.advise = advise;
+    }
+}

+ 76 - 49
src/main/java/com/wechat/common/util/ClientCustomSSL.java

@@ -1,13 +1,13 @@
 package com.wechat.common.util;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.InputStream;
 import java.security.KeyStore;
-import java.security.PrivateKey;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.net.ssl.SSLContext;
 
+import com.wechat.common.parameter.ProjectConstant;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -17,6 +17,8 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 
 
@@ -25,56 +27,81 @@ import org.springframework.core.io.ClassPathResource;
  * context.
  */
 public class ClientCustomSSL {
+    private static Logger logger = LoggerFactory.getLogger(ClientCustomSSL.class);
+    private static final Map<String,CloseableHttpClient> HTTPS_MAP = new ConcurrentHashMap<>(4);
 
-    public static String doCertWX(String url, String data,String mchId) throws Exception {
-        /**
-         * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的
-         */
-        ClassPathResource cp = new ClassPathResource("apiclient_cert.p12");
-        InputStream inStream = cp.getInputStream();
-        KeyStore keyStore = KeyStore.getInstance("PKCS12");
-        try {
-            keyStore.load(inStream, mchId.toCharArray());//这里写密码..默认是你的MCHID
-        } finally {
-            inStream.close();
-        }
-        // Trust own CA and all self-signed certs
-        /**
-         * 此处要改
-         * */
-        SSLContext sslcontext = SSLContexts.custom()
-                .loadKeyMaterial(keyStore, mchId.toCharArray())//这里也是写密码的
-                .build();
-        // Allow TLSv1 protocol only
-        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
-                sslcontext,
-                new String[]{"TLSv1"},
-                null,
-                SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-        CloseableHttpClient httpclient = HttpClients.custom()
-                .setSSLSocketFactory(sslsf)
-                .build();
-        try {
-            HttpPost httpost = new HttpPost(url); // 设置响应头信息
-            httpost.addHeader("Connection", "keep-alive");
-            httpost.addHeader("Accept", "*/*");
-            httpost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
-            httpost.addHeader("Host", "api.mch.weixin.qq.com");
-            httpost.addHeader("X-Requested-With", "XMLHttpRequest");
-            httpost.addHeader("Cache-Control", "max-age=0");
-            httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
-            httpost.setEntity(new StringEntity(data, "UTF-8"));
-            CloseableHttpResponse response = httpclient.execute(httpost);
+    public static void stop(){
+        HTTPS_MAP.forEach((k,v)->{
+            try {
+                v.close();
+            }catch (Exception e){}
+
+        });
+    }
+
+
+    public static String doCertWX(String url, String data) throws Exception{
+        return doCertWX(url,data, ProjectConstant.merchantId);
+    }
+    private static CloseableHttpClient findHttpClient(String mchId){
+        CloseableHttpClient closeableHttpClient = HTTPS_MAP.get(mchId);
+        if(closeableHttpClient == null){
+            /**
+             * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的
+             */
             try {
-                HttpEntity entity = response.getEntity();
-                String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
-                EntityUtils.consume(entity);
-                return jsonStr;
-            } finally {
-                response.close();
+                ClassPathResource cp = new ClassPathResource("apiclient_cert.p12");
+                InputStream inStream = cp.getInputStream();
+                KeyStore keyStore = KeyStore.getInstance("PKCS12");
+                try {
+                    keyStore.load(inStream, mchId.toCharArray());//这里写密码..默认是你的MCHID
+                } finally {
+                    inStream.close();
+                }
+                // Trust own CA and all self-signed certs
+                /**
+                 * 此处要改
+                 * */
+                SSLContext sslcontext = SSLContexts.custom()
+                        .loadKeyMaterial(keyStore, mchId.toCharArray())//这里也是写密码的
+                        .build();
+                // Allow TLSv1 protocol only
+                SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+                        sslcontext,
+                        new String[]{"TLSv1"},
+                        null,
+                        SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+                closeableHttpClient = HttpClients.custom()
+                        .setSSLSocketFactory(sslsf)
+                        .build();
+                HTTPS_MAP.put(mchId,closeableHttpClient);
+            }catch (Exception e){
+                logger.error("初始化SSL错误:{}",e);
+                throw new RuntimeException("初始化HTTP出错:"+e.getMessage());
             }
+        }
+        return closeableHttpClient;
+    }
+
+    public static String doCertWX(String url, String data,String mchId) throws Exception {
+        CloseableHttpClient httpclient = findHttpClient(mchId);
+        HttpPost httpost = new HttpPost(url); // 设置响应头信息
+        httpost.addHeader("Connection", "keep-alive");
+        httpost.addHeader("Accept", "*/*");
+        httpost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+        httpost.addHeader("Host", "api.mch.weixin.qq.com");
+        httpost.addHeader("X-Requested-With", "XMLHttpRequest");
+        httpost.addHeader("Cache-Control", "max-age=0");
+        httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
+        httpost.setEntity(new StringEntity(data, "UTF-8"));
+        CloseableHttpResponse response = httpclient.execute(httpost);
+        try {
+            HttpEntity entity = response.getEntity();
+            String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
+            EntityUtils.consume(entity);
+            return jsonStr;
         } finally {
-            httpclient.close();
+            response.close();
         }
     }
 }

+ 1 - 2
src/main/java/com/wechat/common/util/WeChatUtil.java

@@ -139,9 +139,8 @@ public class WeChatUtil {
 	  }
 	}
 	public static String sha256_HMAC(Map<String,Object> params, String mch_key){
-		if(params == null){
+		if(params == null)
 			return "";
-		}
 		//去掉空值和sign参数,使用Iterator遍历可在遍历同时删除元素
 		Iterator<Entry<String, Object>> it = params.entrySet().iterator();
 		while(it.hasNext()){

+ 54 - 5
src/main/java/com/wechat/controller/sepAccount/SepAccountController.java

@@ -3,14 +3,17 @@ package com.wechat.controller.sepAccount;
 
 import com.wechat.common.action.BaseController;
 import com.wechat.common.response.RespWrapper;
+import com.wechat.common.util.StringUtil;
+import com.wechat.entity.sepAccount.KtjSepUser;
 import com.wechat.entity.sepAccount.help.SepReceiverHelp;
+import com.wechat.entity.sepAccount.help.SepUserHandleHelp;
 import com.wechat.entity.sepAccount.help.UserSepReceiver;
+import com.wechat.service.sepAccount.ISepAccountService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Assert;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -20,14 +23,60 @@ import java.util.List;
 public class SepAccountController extends BaseController {
 
 
+    @Autowired
+    private ISepAccountService iSepAccountService;
 
+    @ApiOperation(value = "新增分账人接口")
     @PostMapping("addSepReceive")
     public RespWrapper<Boolean> addSepReceive(@RequestBody UserSepReceiver userSepReceiver){
         Assert.notNull(userSepReceiver.getSubMchId(),"服务商子商户不能为空");
         List<SepReceiverHelp> sepUserList = userSepReceiver.getSepUserList();
         if(sepUserList == null || sepUserList.isEmpty())
             return RespWrapper.makeFailResp("分账人不能为空");
-        return null;
+        int num = 0;
+        for(SepReceiverHelp help:sepUserList){
+            if(StringUtil.isEmpty(help.getNickName()))
+                return RespWrapper.makeFailResp("分账人不能为空");
+            if(StringUtil.isEmpty(help.getWxAccount()))
+                return RespWrapper.makeFailResp("分账微信账号不能为空");
+            if(StringUtil.isEmpty(help.getSepRate()))
+                return RespWrapper.makeFailResp("分账费率不能为空");
+            Float fl = Float.valueOf(help.getSepRate());
+            num = (int) (fl.floatValue()*100);
+        }
+        if(num > 30) return RespWrapper.makeFailResp("分账订单金额不能超过30%");
+        return iSepAccountService.addSepReceive(userSepReceiver);
     }
+    @ApiOperation(value = "查询自己分账接口")
+    @PostMapping("findSepUserList")
+    public RespWrapper<List<KtjSepUser>> findSepUserList(@RequestBody SepUserHandleHelp help){
+        if(StringUtil.isEmpty(help.getSubMchId()))
+            return RespWrapper.makeFailResp("特约商户号不能为空");
+        return iSepAccountService.findSepUserList(help);
+    }
+    @ApiOperation(value = "分账操作")
+    @PostMapping("sepAccountHandle")
+    public RespWrapper<String> sepAccountHandle(@RequestBody SepUserHandleHelp handleHelp){
+        if(StringUtil.isEmpty(handleHelp.getSubMchId()))
+            return RespWrapper.makeFailResp("特约商户号不为空");
+        if(StringUtil.isEmpty(handleHelp.getTransactionId()))
+            return RespWrapper.makeFailResp("微信支付订单号不能为空");
+        return iSepAccountService.sepAccountHandle(handleHelp);
+    }
+    @ApiOperation(value = "根据outOrderNo编号查询分账结果")
+    @GetMapping("findSepAccountResult/{outOrderNo}")
+    public RespWrapper<Boolean> findSepAccountResult(@PathVariable("outOrderNo")String outOrderNo){
+        return iSepAccountService.findSepAccountResult(outOrderNo);
+    }
+    @ApiOperation(value = "完结分账")
+    @PostMapping("noSepAccountHandle")
+    public RespWrapper<Boolean> noSepAccountHandle(@RequestBody SepUserHandleHelp handleHelp){
+        if(StringUtil.isEmpty(handleHelp.getSubMchId()))
+            return RespWrapper.makeFailResp("特约商户号不为空");
+        if(StringUtil.isEmpty(handleHelp.getTransactionId()))
+            return RespWrapper.makeFailResp("微信支付订单号不能为空");
+        return iSepAccountService.noSepAccountHandle(handleHelp);
+    }
+
 
 }

+ 26 - 0
src/main/java/com/wechat/core/KtjTimeUnit.java

@@ -0,0 +1,26 @@
+package com.wechat.core;
+
+import com.wechat.service.sepAccount.ISepAccountService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class KtjTimeUnit {
+
+
+    @Autowired
+    private ISepAccountService iSepAccountService;
+
+    private static final long TIME_RATE = 5*1000*60;
+    @Scheduled(fixedDelay = TIME_RATE,initialDelay = TIME_RATE)
+    public void handleSepAccountOrderNo(){
+        try {
+            iSepAccountService.doFindSepAccountResult();
+        }catch (Exception e){
+        }
+    }
+
+
+}

+ 7 - 0
src/main/java/com/wechat/dao/sepAccount/SepRecordDao.java

@@ -0,0 +1,7 @@
+package com.wechat.dao.sepAccount;
+
+import com.wechat.entity.sepAccount.KtjSepRecord;
+import org.beetl.sql.core.mapper.BaseMapper;
+
+public interface SepRecordDao extends BaseMapper<KtjSepRecord> {
+}

+ 10 - 0
src/main/java/com/wechat/dao/sepAccount/SepUserDao.java

@@ -0,0 +1,10 @@
+package com.wechat.dao.sepAccount;
+
+import com.wechat.entity.sepAccount.KtjSepUser;
+import org.beetl.sql.core.annotatoin.Sql;
+import org.beetl.sql.core.mapper.BaseMapper;
+
+public interface SepUserDao extends BaseMapper<KtjSepUser> {
+    @Sql(value = "select d.register_status from ktj_merchant_details d where d.sub_mchid = ? limit 1")
+    Integer findMerchantRegisterStatus(String subMchId);
+}

+ 7 - 0
src/main/java/com/wechat/dao/sepAccount/SepUserRecordDao.java

@@ -0,0 +1,7 @@
+package com.wechat.dao.sepAccount;
+
+import com.wechat.entity.sepAccount.KtjSepUserRecord;
+import org.beetl.sql.core.mapper.BaseMapper;
+
+public interface SepUserRecordDao extends BaseMapper<KtjSepUserRecord> {
+}

+ 0 - 4
src/main/java/com/wechat/entity/sepAccount/H.java

@@ -1,4 +0,0 @@
-package com.wechat.entity.sepAccount;
-
-public class H {
-}

+ 105 - 0
src/main/java/com/wechat/entity/sepAccount/KtjSepRecord.java

@@ -0,0 +1,105 @@
+package com.wechat.entity.sepAccount;
+
+import org.beetl.sql.core.annotatoin.AutoID;
+
+public class KtjSepRecord {
+    @AutoID
+    private Integer id;
+    private String outOrderNo;
+    private Integer orderId;//
+    private String subMchId;//特约商户
+    private String wxOrderNo;//微信分账处理的id
+    private Integer amount;//分账金额
+    private String transactionId;// 微信支付单号
+    /**
+     * 分账单状态:
+     * ACCEPTED—受理成功
+     * PROCESSING—处理中
+     * FINISHED—处理完成
+     * CLOSED—处理失败,已关单
+     */
+    private String status;
+    private Long createTime;//创建时间
+    private Boolean isSep;// 是否分账成功 0 没有 1成功 定时任务根据 sep=0 去查询
+
+    public Boolean getSep() {
+        return isSep;
+    }
+
+    public void setSep(Boolean sep) {
+        isSep = sep;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+
+    public Integer getAmount() {
+        return amount;
+    }
+
+    public void setAmount(Integer amount) {
+        this.amount = amount;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getOutOrderNo() {
+        return outOrderNo;
+    }
+
+    public void setOutOrderNo(String outOrderNo) {
+        this.outOrderNo = outOrderNo;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getSubMchId() {
+        return subMchId;
+    }
+
+    public void setSubMchId(String subMchId) {
+        this.subMchId = subMchId;
+    }
+
+    public String getWxOrderNo() {
+        return wxOrderNo;
+    }
+
+    public void setWxOrderNo(String wxOrderNo) {
+        this.wxOrderNo = wxOrderNo;
+    }
+
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+}

+ 134 - 0
src/main/java/com/wechat/entity/sepAccount/KtjSepUser.java

@@ -0,0 +1,134 @@
+package com.wechat.entity.sepAccount;
+
+import org.beetl.sql.core.annotatoin.AutoID;
+
+/**
+ * 微信分账用户
+ */
+public class KtjSepUser {
+
+    @AutoID
+    private Integer id;
+    /**
+     * MERCHANT_ID:商户ID
+     * PERSONAL_WECHATID:个人微信号PERSONAL_OPENID:个人openid(由父商户APPID转换得到)PERSONAL_SUB_OPENID: 个人sub_openid(由子商户APPID转换得到)
+     */
+    private String type;//默认为: PERSONAL_WECHATID
+
+    /**
+     *类型是MERCHANT_ID时,是商户ID
+     * 类型是PERSONAL_WECHATID时,是个人微信号
+     * 类型是PERSONAL_OPENID时,是个人openid
+     * 类型是PERSONAL_SUB_OPENID时,是个人sub_openid
+     */
+    private String account;
+
+    /**
+     * 分账接收方类型是MERCHANT_ID时,是商户全称(必传)
+     * 分账接收方类型是PERSONAL_WECHATID 时,是个人姓名(必传)
+     * 分账接收方类型是PERSONAL_OPENID时,是个人姓名(选传,传则校验)
+     * 分账接收方类型是PERSONAL_SUB_OPENID时,是个人姓名(选传,传则校验)
+     */
+    private String name;
+
+    /**
+     * 子商户与接收方的关系。
+     * 本字段值为枚举:
+     * SERVICE_PROVIDER:服务商
+     * STORE:门店
+     * STAFF:员工
+     * STORE_OWNER:店主
+     * PARTNER:合作伙伴
+     * HEADQUARTER:总部
+     * BRAND:品牌方
+     * DISTRIBUTOR:分销商
+     * USER:用户
+     * SUPPLIER:供应商
+     * CUSTOM:自定义
+     */
+    private String relationType;
+
+    /**
+     * 子商户与接收方具体的关系,本字段最多10个字。
+     * 当字段relation_type的值为CUSTOM时,本字段必填
+     * 当字段relation_type的值不为CUSTOM时,本字段无需填写
+     */
+    private String customRelation;
+
+
+    private String subMchId;//商户id
+    private String groupName;//分组
+    private String sepRate;//分账比例
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getAccount() {
+        return account;
+    }
+
+    public void setAccount(String account) {
+        this.account = account;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRelationType() {
+        return relationType;
+    }
+
+    public void setRelationType(String relationType) {
+        this.relationType = relationType;
+    }
+
+    public String getCustomRelation() {
+        return customRelation;
+    }
+
+    public void setCustomRelation(String customRelation) {
+        this.customRelation = customRelation;
+    }
+
+    public String getSubMchId() {
+        return subMchId;
+    }
+
+    public void setSubMchId(String subMchId) {
+        this.subMchId = subMchId;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String getSepRate() {
+        return sepRate;
+    }
+
+    public void setSepRate(String sepRate) {
+        this.sepRate = sepRate;
+    }
+}

+ 73 - 0
src/main/java/com/wechat/entity/sepAccount/KtjSepUserRecord.java

@@ -0,0 +1,73 @@
+package com.wechat.entity.sepAccount;
+
+import org.beetl.sql.core.annotatoin.AutoID;
+
+public class KtjSepUserRecord {
+    @AutoID
+    private Integer id;
+    private Integer amount;//分账金额
+    private Integer sepRecordId;//分账记录id
+    private String nickName;
+    private String wxAccount;
+    private Long createTime;
+    private String groupName;
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+
+    public Integer getAmount() {
+        return amount;
+    }
+
+    public void setAmount(Integer amount) {
+        this.amount = amount;
+    }
+
+
+
+    public Integer getSepRecordId() {
+        return sepRecordId;
+    }
+
+    public void setSepRecordId(Integer sepRecordId) {
+        this.sepRecordId = sepRecordId;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getWxAccount() {
+        return wxAccount;
+    }
+
+    public void setWxAccount(String wxAccount) {
+        this.wxAccount = wxAccount;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+}

+ 3 - 3
src/main/java/com/wechat/entity/sepAccount/help/SepReceiverHelp.java

@@ -6,13 +6,13 @@ package com.wechat.entity.sepAccount.help;
 public class SepReceiverHelp {
     private String wxAccount;//微信个人账户
     private String nickName;//微信账号名字
-    private Integer sepRate;//分账比例 0-100
+    private String sepRate;//分账比例 0.01-1 保留2位小数
 
-    public Integer getSepRate() {
+    public String getSepRate() {
         return sepRate;
     }
 
-    public void setSepRate(Integer sepRate) {
+    public void setSepRate(String sepRate) {
         this.sepRate = sepRate;
     }
 

+ 32 - 0
src/main/java/com/wechat/entity/sepAccount/help/SepUserHandleHelp.java

@@ -0,0 +1,32 @@
+package com.wechat.entity.sepAccount.help;
+
+public class SepUserHandleHelp {
+    private String subMchId;
+    private String groupName;// 没有传使用默认的
+    // private Integer account;//分账金额
+    private String transactionId;//分账id
+
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+    public String getSubMchId() {
+        return subMchId;
+    }
+
+    public void setSubMchId(String subMchId) {
+        this.subMchId = subMchId;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+}

+ 22 - 0
src/main/java/com/wechat/service/sepAccount/ISepAccountService.java

@@ -1,4 +1,26 @@
 package com.wechat.service.sepAccount;
 
+import com.wechat.common.response.RespWrapper;
+import com.wechat.entity.sepAccount.KtjSepRecord;
+import com.wechat.entity.sepAccount.KtjSepUser;
+import com.wechat.entity.sepAccount.help.SepUserHandleHelp;
+import com.wechat.entity.sepAccount.help.UserSepReceiver;
+
+import java.util.List;
+import java.util.Map;
+
 public interface ISepAccountService {
+    RespWrapper<Boolean> addSepReceive(UserSepReceiver userSepReceiver);
+
+    RespWrapper<List<KtjSepUser>> findSepUserList(SepUserHandleHelp help);
+
+    RespWrapper<String> sepAccountHandle(SepUserHandleHelp handleHelp);
+
+    RespWrapper<Boolean> findSepAccountResult(String outOrderNo);
+
+    RespWrapper<Boolean> noSepAccountHandle(SepUserHandleHelp handleHelp);
+
+
+    void doFindSepAccountResult();
+
 }

+ 397 - 175
src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java

@@ -1,203 +1,446 @@
 package com.wechat.service.sepAccount.impl;
 
-import com.alibaba.fastjson.JSONObject;
+import com.wechat.common.entity.order.KtjJsapiOrder;
+import com.wechat.common.enums.RegisterStatus;
+import com.wechat.common.enums.SepAccountEnums;
 import com.wechat.common.parameter.ProjectConstant;
+import com.wechat.common.response.RespWrapper;
 import com.wechat.common.util.ClientCustomSSL;
-import com.wechat.common.util.HMACSHA256;
+import com.wechat.common.util.StringUtil;
 import com.wechat.common.util.WeChatUtil;
 import com.wechat.common.util.WxXmlParser;
+import com.wechat.dao.order.KtjJsapiOrderDao;
+import com.wechat.dao.sepAccount.SepRecordDao;
+import com.wechat.dao.sepAccount.SepUserDao;
+import com.wechat.dao.sepAccount.SepUserRecordDao;
+import com.wechat.entity.sepAccount.KtjSepRecord;
+import com.wechat.entity.sepAccount.KtjSepUser;
+import com.wechat.entity.sepAccount.KtjSepUserRecord;
+import com.wechat.entity.sepAccount.help.SepReceiverHelp;
+import com.wechat.entity.sepAccount.help.SepUserHandleHelp;
+import com.wechat.entity.sepAccount.help.UserSepReceiver;
 import com.wechat.service.sepAccount.ISepAccountService;
+import org.apache.http.client.utils.DateUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
-public class SepAccountServiceImpl implements ISepAccountService {
+public class SepAccountServiceImpl implements ISepAccountService, DisposableBean {
+    // 不传 使用默认的分组
+    private static final String DEFAULT_GROUP_NAME = "KTJ_SEP_GROUP";
+    @Autowired
+    private SepUserDao sepUserDao;
+    @Autowired
+    private KtjJsapiOrderDao ktjJsapiOrderDao;
+    @Autowired
+    private SepUserRecordDao sepUserRecordDao;
+    @Autowired
+    private SepRecordDao sepRecordDao;
+    // 删除分账
+    private static final String DEL_SEP_ACCOUNT_USER = "{\"type\":\"%s\",\"account\":\"%s\"}";
+    // 添加分账
+    private static final String ADD_WX_ACCOUNT_USER = "{\"type\":\"%s\",\"account\":\"%s\",\"name\":\"%s\",\"relation_type\":\"%s\"}";
     private static Logger logger = LoggerFactory.getLogger(SepAccountServiceImpl.class);
-    // 添加分账人接了测试
-    public static void main(String[] args)throws Exception{
-        //addReceiver();
-        // 单次分账
-        //singleSepAccount();
-        // 查询分账
-        //findSepAccountResult();
-        // 删除分账人
-        //delSepAccountUser();
 
-        // 不分账接口
-        noSepAccount();
+    @Override
+    public RespWrapper<Boolean> addSepReceive(UserSepReceiver userSepReceiver) {
+        // 1、校验该商户是否已经添加分账功能
+        RespWrapper<Boolean> checkSepFun = checkSepFunction(userSepReceiver.getSubMchId());
+        if(!checkSepFun.isSuccess()) return checkSepFun;
+        // 2、查询所有已经添加的分账用户
+        KtjSepUser user = new KtjSepUser();
+        user.setSubMchId(userSepReceiver.getSubMchId());
+        List<KtjSepUser> template = sepUserDao.template(user);
+        String groupName = userSepReceiver.getGroupName();
+        if(StringUtil.isEmpty(groupName)) groupName = DEFAULT_GROUP_NAME;
+        // 获取当前分组的数据
+        List<KtjSepUser> groupSepUserMap = findGroupSepUserMap(template,groupName);
+        // 去掉当前分组的账号引用
+        Map<String,KtjSepUser> accountMap = findWxAccountMap(template,groupName);
+        template.clear();
+        // 需要保证并且请求微信
+        List<KtjSepUser> saveDBAndWx = new ArrayList<>(8);
+        // 只需保证到数据库
+        List<KtjSepUser> saveDB = new ArrayList<>(8);
+        // 删除数据库并删除微信
+        List<KtjSepUser> delGroupUser = new ArrayList<>(0);
+        if(groupSepUserMap.isEmpty()){
+            handleSepUserData(saveDBAndWx,saveDB,accountMap,userSepReceiver,groupName);
+        }else {
+            /**
+             * 如果分组不为空
+             * 1、新增的数据在分组中,则更新分组内对应的数据
+             * 2、不在分组,并且在其他的分组中,需要新数据库
+             * 3、不在分组,并且不在其他分组中,需新增数据库,并请求微信新增
+             */
+            // 需要删除的数据为
+            Map<String,SepReceiverHelp> tmpGroupName = new HashMap<>();
+            userSepReceiver.getSepUserList().forEach(s->{
+                tmpGroupName.put(s.getWxAccount(),s);
+            });
+            // 其他地方没有引用、或者没有新数据引用
+            delGroupUser = groupSepUserMap.stream().filter(s -> {
+                return !(tmpGroupName.containsKey(s.getAccount()) || accountMap.containsKey(s.getAccount()));
+            }).collect(Collectors.toList());
+            groupSepUserMap.forEach(s->{
+                accountMap.put(s.getAccount(),s);
+            });
+            groupSepUserMap.clear();
+            tmpGroupName.clear();
+            handleSepUserData(saveDBAndWx,saveDB,accountMap,userSepReceiver,groupName);
+        }
+        // 3、处理分账逻辑
+        if(!saveDB.isEmpty())
+            sepUserDao.insertBatch(saveDB);
+        if(!saveDBAndWx.isEmpty()){
+            for(KtjSepUser ktjSepUser:saveDBAndWx){
+                RespWrapper<Map<String, Object>> ck = addReceiver(ktjSepUser, userSepReceiver.getSubMchId());
+                if(!ck.isSuccess()) return RespWrapper.makeFailResp(ck.getMsg());
+            }
+            sepUserDao.insertBatch(saveDBAndWx);
+        }
+        if(!delGroupUser.isEmpty()){
+            for(KtjSepUser ktjSepUser:saveDBAndWx){
+                RespWrapper<Map<String, Object>> ck = delReceiver(ktjSepUser, userSepReceiver.getSubMchId());
+                if(!ck.isSuccess()) return RespWrapper.makeFailResp(ck.getMsg());
+                sepUserDao.deleteById(ktjSepUser.getId());
+            }
+        }
+        // help gc
+        saveDB.clear();
+        saveDBAndWx.clear();
+        delGroupUser.clear();
+        return RespWrapper.makeSuccessResp(true);
+    }
 
+    @Override
+    public RespWrapper<List<KtjSepUser>> findSepUserList(SepUserHandleHelp help) {
+        return RespWrapper.makeSuccessResp(doFindSepUserList(help));
+    }
+    private List<KtjSepUser> doFindSepUserList(SepUserHandleHelp help){
+        String groupName = help.getGroupName();
+        if(StringUtil.isEmpty(help.getGroupName())) groupName = DEFAULT_GROUP_NAME;
+        KtjSepUser user = new KtjSepUser();
+        user.setSubMchId(help.getSubMchId());
+        user.setGroupName(groupName);
+        List<KtjSepUser> template = sepUserDao.template(user);
+        return template;
+    }
+    private static final String SEP_DESC = "康体佳—分账";
+    @Override
+    public RespWrapper<String> sepAccountHandle(SepUserHandleHelp handleHelp) {
+        // 1、校验该商户是否已经添加分账功能
+        RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
+        if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
+        List<KtjSepUser> userList = doFindSepUserList(handleHelp);
+        if(userList.isEmpty()) return RespWrapper.makeFailResp("请检查是否设置了分账人");
+        // 查询是否有该笔订单
+        RespWrapper<KtjJsapiOrder> data = findOrder(handleHelp);
+        if(!data.isSuccess()) return RespWrapper.makeFailResp(data.getMsg());
+        KtjJsapiOrder order = data.getData();
+        Long totalFee = order.getTotalFee();//分账金额
+        if(totalFee == null || totalFee < 0)
+            return RespWrapper.makeFailResp("订单金额错误");
+        // 判断该用户已经分账啦
+        KtjSepRecord record = new KtjSepRecord();
+        record.setOrderId(order.getId().intValue());
+        if (sepRecordDao.templateCount(record) > 0) {
+            return RespWrapper.makeFailResp("该订单已经分账啦,无需在调用分账");
+        }
+        List<KtjSepUserRecord> addUserList = new ArrayList<>();
+        StringBuilder sb = new StringBuilder("[");
+        boolean isOne = true;
+        long startTime = System.currentTimeMillis();
+        int amount = 0;
+        for(KtjSepUser user:userList){
+            Float aFloat = Float.valueOf(user.getSepRate());
+            int tmpAmount = (int) (aFloat.floatValue()*totalFee);
+            KtjSepUserRecord rd = new KtjSepUserRecord();
+            rd.setNickName(user.getName());
+            rd.setGroupName(user.getGroupName());
+            rd.setCreateTime(startTime);
+            rd.setWxAccount(user.getAccount());
+            rd.setAmount(tmpAmount);
+            rd.setWxAccount(user.getAccount());
+            addUserList.add(rd);
+            amount += tmpAmount;
+            if(tmpAmount > 0){
+                String desc = String.format(SEP_RECEIVERS, user.getType(), user.getAccount(), tmpAmount, SEP_DESC);
+                if(isOne){
+                    isOne = false;
+                }else sb.append(",");
+                sb.append(desc);
+            }
+        }
+        String outOrderNo = findSepOutOrderNo();
+        record.setOutOrderNo(outOrderNo);
+        record.setCreateTime(startTime);
+        record.setStatus("ACCEPTED");
+        record.setAmount(amount);//分账
+        record.setTransactionId(handleHelp.getTransactionId());
+        record.setSep(false);
+        if(isOne){
+            // 说明什么都没有分账
+            record.setStatus("FINISHED");
+            record.setSep(true);
+            sepRecordDao.insert(record,true);
+        }else {
+            sb.append("]");
+            RespWrapper<Map<String, Object>> ck = handleSepAccount(handleHelp.getSubMchId(), handleHelp.getTransactionId(), outOrderNo, sb.toString());
+            if (!ck.isSuccess()) {
+                return RespWrapper.makeFailResp(ck.getMsg());
+            }
+            String order_id = (String) ck.getData().get("order_id");
+            record.setWxOrderNo(order_id);
+            sepRecordDao.insert(record,true);
+        }
+        addUserList.forEach(s->{
+            s.setSepRecordId(record.getId());
+        });
+        sepUserRecordDao.insertBatch(addUserList);
+        return RespWrapper.makeSuccessResp(outOrderNo);
     }
 
-    /**
-     *  分账接收方与原请求不一致
-     *  多次分账后完结分账时,out_order_no 需要注意
-     *  第一次是系统内部生成的,第二、第三次 是上次分账返回的order_id
-     * @throws Exception
-     */
-    private static void noSepAccount()throws Exception {
+    @Override
+    public RespWrapper<Boolean> findSepAccountResult(String outOrderNo) {
+        KtjSepRecord record = new KtjSepRecord();
+        record.setOutOrderNo(outOrderNo);
+        record = sepRecordDao.templateOne(record);
+        if (record == null) return RespWrapper.makeFailResp("订单编号错误");
+        if("FINISHED".equals(record.getStatus()))
+            return RespWrapper.makeSuccessResp(true);
+        Map<String, Object> condition = new HashMap<>();
+        condition.put("sub_mch_id", record.getSubMchId());//sub_mchId
+        condition.put("transaction_id", record.getTransactionId());
+        condition.put("out_order_no", outOrderNo);
+        RespWrapper<Map<String, Object>> ck = doWxRequest(SepAccountEnums.查询分账结果, condition, false);
+        if (!ck.isSuccess()) return RespWrapper.makeFailResp(ck.getMsg());
+        String status = (String) ck.getData().get("status");
+        switch (status) {
+            case "ACCEPTED":
+                return RespWrapper.makeFailResp("受理成功");
+            case "PROCESSING":
+                return RespWrapper.makeFailResp("处理中");
+            case "FINISHED":
+                return RespWrapper.makeSuccessResp(true);
+            case "CLOSED":
+                return RespWrapper.makeFailResp("处理失败,已关单");
+        }
+        return RespWrapper.makeFailResp("未知原因:" + status);
+    }
+
+    @Override
+    public RespWrapper<Boolean> noSepAccountHandle(SepUserHandleHelp handleHelp) {
+        // 1、校验该商户是否已经添加分账功能
+        RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
+        if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
+        // 查询是否有该笔订单
+        RespWrapper<KtjJsapiOrder> data = findOrder(handleHelp);
+        if(!data.isSuccess()) return RespWrapper.makeFailResp(data.getMsg());
+        KtjSepRecord record = new KtjSepRecord();
+        String outOrderNo = findSepOutOrderNo("NOSEP");
+        record.setOutOrderNo(outOrderNo);
+        record.setTransactionId(handleHelp.getTransactionId());
+        record.setSep(true);
+        record.setAmount(0);
+        record.setCreateTime(System.currentTimeMillis());
+        record.setSubMchId(handleHelp.getSubMchId());
+        record.setOrderId(data.getData().getId().intValue());
+        record.setStatus("FINISHED");
         Map<String,Object> condition = new HashMap<>();
-        condition.put("mch_id", ProjectConstant.merchantId);//商户id
-        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("sub_mch_id", handleHelp.getSubMchId());//sub_mchId
         condition.put("appid",ProjectConstant.appid);// appid
-        condition.put("nonce_str",ProjectConstant.findNonceStr());
-        condition.put("transaction_id","4200000533202004184533522457");
+        condition.put("transaction_id",handleHelp.getTransactionId());
         condition.put("sign_type","HMAC-SHA256");
-        condition.put("out_order_no","30000110062020041800341490392");
+        condition.put("out_order_no",outOrderNo);
         condition.put("description","分账完成");
-        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
-        String xml = WeChatUtil.mapFormatXML(condition);
-        String s = ClientCustomSSL.doCertWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish", xml,ProjectConstant.merchantId);
-        System.out.println(s);
+        RespWrapper<Map<String, Object>> ck = doWxRequest(SepAccountEnums.完结分账, condition, true);
+        if(!ck.isSuccess()) return RespWrapper.makeFailResp(ck.getMsg());
+        String order_id = (String) ck.getData().get("order_id");
+        record.setWxOrderNo(order_id);
+        sepRecordDao.insert(record);
+        return RespWrapper.makeSuccessResp(true);
+    }
 
+    @Override
+    public void doFindSepAccountResult() {
+        KtjSepRecord record = new KtjSepRecord();
+        record.setSep(false);
+        sepRecordDao.template(record).forEach(s->{
+            Map<String, Object> condition = new HashMap<>();
+            condition.put("sub_mch_id", record.getSubMchId());//sub_mchId
+            condition.put("transaction_id", record.getTransactionId());
+            condition.put("out_order_no", record.getOutOrderNo());
+            RespWrapper<Map<String, Object>> ck = doWxRequest(SepAccountEnums.查询分账结果, condition, false);
+            if (ck.isSuccess()) {
+                // 查询成功
+                if ("FINISHED".equals(ck.getData().get("status"))) {
+                    // 这里需要更新数据
+                    record.setSep(true);
+                    record.setStatus("FINISHED");
+                    sepRecordDao.updateTemplateById(record);
+                }
+            }
+        });
     }
 
-    private static final String DEL_SEP_ACCOUNT_USER = "{\"type\":\"%s\",\"account\":\"%s\"}";
 
-    /**
-     * {nonce_str=ed95b1c7fbd32fe8, receiver={"type":"PERSONAL_WECHATID","account":"wxid_haxp101y5saj21"}, appid=wxec504e0378010e16, sign=961EA0F51E9AC69229769F041DB5C05E86693F973F71B6DC0EF71D18709340D8, result_code=SUCCESS, mch_id=1503800091, sub_mch_id=1584278251, return_code=SUCCESS}
-     */
-    private static void delSepAccountUser() {
+
+    private RespWrapper<KtjJsapiOrder> findOrder(SepUserHandleHelp handleHelp){
+        KtjJsapiOrder order = new KtjJsapiOrder();
+        order.setTransactionId(handleHelp.getTransactionId());//查询
+        order = ktjJsapiOrderDao.templateOne(order);
+        if(order == null) return RespWrapper.makeFailResp("微信支付订单号错误");
+        if(!handleHelp.getSubMchId().equals(order.getSubMchid()))
+            return RespWrapper.makeFailResp("请检查特约商户账号或微信支付订单号");
+        if(order.getOrderStatus() == 0)
+            return RespWrapper.makeFailResp("该订单还没有支付成功,无法分账");
+        return RespWrapper.makeSuccessResp(order);
+    }
+    private static final String SEP_RECEIVERS = "{\"type\": \"%s\",\"account\":\"%s\",\"amount\":%s,\"description\": \"%s\"}";
+    private RespWrapper<Map<String,Object>> handleSepAccount(String subMchId,String transactionId,String outOrderNo,String receivers){
         Map<String,Object> condition = new HashMap<>();
-        condition.put("mch_id", ProjectConstant.merchantId);//商户id
-        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("sub_mch_id", subMchId);//sub_mchId
         condition.put("appid",ProjectConstant.appid);// appid
-        condition.put("nonce_str",ProjectConstant.findNonceStr());
-        condition.put("receiver",String.format(DEL_SEP_ACCOUNT_USER,"PERSONAL_WECHATID","wxid_haxp101y5saj21"));
-        condition.put("sign_type","HMAC-SHA256");
-        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
-        String xml = WeChatUtil.mapFormatXML(condition);
-        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver", xml);
-        System.out.println(xmlStr);
-        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
-        System.out.println(resultMap);
-        System.out.println(checkNoticeSign(resultMap));
-
+        condition.put("transaction_id",transactionId);
+        condition.put("out_order_no",outOrderNo);
+        condition.put("receivers", receivers);
+        return doWxRequest(SepAccountEnums.单次分账,condition,true);
     }
 
-    /**
-     * 查询分账结果
-     *
-     *
-     */
-    private static void findSepAccountResult() {
+
+    private RespWrapper<Map<String, Object>> delReceiver(KtjSepUser ktjSepUser, String subMchId) {
         Map<String,Object> condition = new HashMap<>();
-        condition.put("mch_id", ProjectConstant.merchantId);//商户id
-        condition.put("sub_mch_id", "1584278251");//sub_mchId
-        //condition.put("appid",ProjectConstant.appid);// appid
-        condition.put("nonce_str",ProjectConstant.findNonceStr());
-        condition.put("transaction_id","4200000533202004184533522457");
-        condition.put("sign_type","HMAC-SHA256");
-        condition.put("out_order_no",outOrderNo);
-        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
-        String xml = WeChatUtil.mapFormatXML(condition);
-        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingquery", xml);
-        System.out.println(xmlStr);
-        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
-        System.out.println(resultMap);
-        System.out.println(checkNoticeSign(resultMap));
+        condition.put("sub_mch_id", subMchId);//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("receiver",String.format(DEL_SEP_ACCOUNT_USER,ktjSepUser.getType(),ktjSepUser.getAccount()));
+        return doWxRequest(SepAccountEnums.删除分账接收方, condition, false);
     }
 
+    private RespWrapper<Map<String, Object>> addReceiver(KtjSepUser user,String subMchId){
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("sub_mch_id", subMchId);//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("receiver",String.format(ADD_WX_ACCOUNT_USER,user.getType(),user.getAccount(),user.getName(),user.getRelationType()));
+        return doWxRequest(SepAccountEnums.添加分账接收方, condition, false);
+    }
     /**
-     *   {
-     *          "type": "MERCHANT_ID",
-     *          "account":"190001001",
-     *          "amount":100,
-     *          "description": "分到商户"
-     * },
+     * 如果分组为空,则不需向微信删除分账人
+     * 1、如果在数据库存在数据--> 在数据库新增一条记录
+     * 2、如果没有在数据库--> 增加数据库的,并向微信请求新增
      */
-    static class SepUser{
-        String type;
-        String account;
-        int amount;
-        String description;
-        public SepUser(String type,String account,int amount,String description){
-            this.type = type;
-            this.account = account;
-            this.amount = amount;
-            this.description = description;
-        }
-        public String getType() {
-            return type;
+    private void handleSepUserData(List<KtjSepUser> saveDBAndWx,List<KtjSepUser> saveDB,Map<String,KtjSepUser> accountMap,UserSepReceiver userSepReceiver,String groupName){
+        for(SepReceiverHelp hr:userSepReceiver.getSepUserList()){
+            KtjSepUser ktjSepUser = accountMap.get(hr.getWxAccount());
+            // 第2种情况
+            if(ktjSepUser == null){
+                saveDBAndWx.add(initSepUser(hr,groupName,userSepReceiver.getSubMchId()));
+            }else {
+                // 第1种情况
+                ktjSepUser.setGroupName(groupName);
+                ktjSepUser.setSepRate(hr.getSepRate());
+                ktjSepUser.setId(null);
+                saveDB.add(ktjSepUser);
+            }
         }
+    }
 
-        public void setType(String type) {
-            this.type = type;
-        }
 
-        public String getAccount() {
-            return account;
-        }
+    private KtjSepUser initSepUser(SepReceiverHelp hr,String groupName,String subMchId){
+        KtjSepUser kt = new KtjSepUser();
+        kt.setName(hr.getWxAccount());
+        kt.setSepRate(hr.getSepRate());
+        kt.setGroupName(groupName);
+        kt.setName(hr.getNickName());
+        kt.setType("PERSONAL_WECHATID");
+        kt.setSubMchId(subMchId);
+        kt.setRelationType("DISTRIBUTOR");
+        return kt;
+    }
 
-        public void setAccount(String account) {
-            this.account = account;
-        }
+    // 获取其他分组的引用
+    private Map<String, KtjSepUser> findWxAccountMap(List<KtjSepUser> template,String groupName) {
+        Map<String, KtjSepUser> map  = new HashMap<>();
+        template.forEach(s->{
+            if(!groupName.equals(s.getGroupName()))
+                map.put(s.getAccount(),s);
+        });
+        return map;
+    }
 
-        public int getAmount() {
-            return amount;
-        }
 
-        public void setAmount(int amount) {
-            this.amount = amount;
-        }
+    private List<KtjSepUser> findGroupSepUserMap(List<KtjSepUser> template,String groupName) {
+        return template.stream().filter(s->s.getGroupName().equals(groupName)).collect(Collectors.toList());
+    }
 
-        public String getDescription() {
-            return description;
-        }
 
-        public void setDescription(String description) {
-            this.description = description;
-        }
+    private RespWrapper<Boolean> checkSepFunction(String subMchId){
+        Integer registerStatus = sepUserDao.findMerchantRegisterStatus(subMchId);
+        if(registerStatus == null) return RespWrapper.makeFailResp("该商户还没有入驻,请先入驻");
+        RegisterStatus status = RegisterStatus.findRegisterStatus(registerStatus);
+        if(status == null) return RespWrapper.makeFailResp("该商户还没有入驻,请先入驻");
+        if(status != RegisterStatus.APPLYMENT_STATE_FINISHED)
+            return RespWrapper.makeFailResp(status.getStatus());
+        return RespWrapper.makeSuccessResp(true);
     }
-    /**
-     * 单个分账操作
-     */
-    private static final String outOrderNo = "ktjSep20200418001";
+
 
     /**
-     * <xml>
-     * <return_code><![CDATA[SUCCESS]]></return_code>
-     * <result_code><![CDATA[SUCCESS]]></result_code>
-     * <mch_id><![CDATA[1503800091]]></mch_id>
-     * <sub_mch_id><![CDATA[1584278251]]></sub_mch_id>
-     * <appid><![CDATA[wxec504e0378010e16]]></appid>
-     * <nonce_str><![CDATA[47f68c677907aa1b]]></nonce_str>
-     * <sign><![CDATA[71B1A4DFEB6B835BB3676F25A61772B885ADD64BB9D969F29E0169BC0EE1D426]]></sign>
-     * <transaction_id><![CDATA[4200000533202004184533522457]]></transaction_id>
-     * <out_order_no><![CDATA[ktjSep20200418001]]></out_order_no>
-     * <order_id><![CDATA[30000110062020041800341490392]]></order_id>
-     * </xml>
-     * @throws Exception
+     * 包括商户号,签名类型、随机数
+     * @param enums
+     * @param condition
+     * @param isSSL
+     * @return
      */
-    private static void singleSepAccount() throws Exception{
-        Map<String,Object> condition = new HashMap<>();
+    private RespWrapper<Map<String,Object>> doWxRequest(SepAccountEnums enums, Map<String,Object> condition, boolean isSSL){
+        Assert.notNull(condition,"微信请求参数不能为空");
         condition.put("mch_id", ProjectConstant.merchantId);//商户id
-        condition.put("sub_mch_id", "1584278251");//sub_mchId
-        condition.put("appid",ProjectConstant.appid);// appid
-        condition.put("nonce_str",ProjectConstant.findNonceStr());
-        condition.put("transaction_id","4200000533202004184533522457");
         condition.put("sign_type","HMAC-SHA256");
-        //condition.put("out_order_no",outOrderNo);
-        condition.put("out_order_no","ktjSep20200418002");
-        List<SepUser> list = new ArrayList<>();
-        list.add(new SepUser("PERSONAL_WECHATID","wxid_haxp101y5saj21",1,"分到个人"));
-        condition.put("receivers", JSONObject.toJSONString(list));
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
         condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
         String xml = WeChatUtil.mapFormatXML(condition);
-        //String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", xml);
-        String s = ClientCustomSSL.doCertWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", xml,ProjectConstant.merchantId);
-        System.out.println(s);
-        //Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
-        //System.out.println(resultMap);
-        //System.out.println(checkNoticeSign(resultMap));
+        try {
+            String xmlStr;
+            if(isSSL){
+                xmlStr = ClientCustomSSL.doCertWX(enums.getUrl(), xml);
+            }else xmlStr = WeChatUtil.postWX(enums.getUrl(), xml);
+            Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+            if(checkNoticeSign(resultMap)){
+                String return_code = (String) resultMap.get("return_code");
+                if("SUCCESS".equals(return_code)){
+                    String result_code = (String) resultMap.get("result_code");
+                    if("SUCCESS".equals(result_code)){
+                        return RespWrapper.makeSuccessResp(resultMap);
+                    }
+                    return RespWrapper.makeFailResp("err_code:"+resultMap.get("err_code")+",err_code_des:"+resultMap.get("err_code_des"));
+                }
+                return RespWrapper.makeFailResp((String) resultMap.get("return_msg"));
+            }
+            return RespWrapper.makeFailResp("校验签名错误");
+        }catch (Exception e){
+            logger.error("请求微信异常:{}",e);
+            return RespWrapper.makeFailResp("请求异常,请稍后再试!异常:"+e.getMessage());
+        }
+    }
+
 
+
+
+    @Override
+    public void destroy() throws Exception {
+        ClientCustomSSL.stop();
     }
 
+
+
+
     /**
      * 校验微信响应数据
       */
@@ -207,34 +450,13 @@ public class SepAccountServiceImpl implements ISepAccountService {
         return sign.equals(WeChatUtil.sha256_HMAC(params, ProjectConstant.api));
     }
 
-    private static String account = "{ \n" +
-            "       \"type\": \"PERSONAL_WECHATID\", \n" +
-            "       \"account\": \"wxid_haxp101y5saj21\", \n" +
-            "       \"name\": \"赵路羊\", \n" +
-            "\"relation_type\": \"PARTNER\"\n" +
-            "} ";
-
-    // 添加分账人成功
-    // {nonce_str=23b0e1633fae5d5c, receiver={"type":"PERSONAL_WECHATID","account":"wxid_haxp101y5saj21","relation_type":"PARTNER"}, appid=wxec504e0378010e16, sign=3E2424E858AD437D86D9B444AD5592F5215BCCD4B1A50E6276226B747A4A8B39, result_code=SUCCESS, mch_id=1503800091, sub_mch_id=1584278251, return_code=SUCCESS}
-    private static void addReceiver(){
-        Map<String,Object> condition = new HashMap<>();
-        condition.put("mch_id", ProjectConstant.merchantId);//商户id
-        condition.put("sub_mch_id", "1584278251");//sub_mchId
-        condition.put("appid",ProjectConstant.appid);// appid
-        condition.put("nonce_str",ProjectConstant.findNonceStr());
-        condition.put("receiver",account);
-        condition.put("sign_type","HMAC-SHA256");
-        // 拼接签名
-        String sign = WeChatUtil.sha256_HMAC(condition, ProjectConstant.api);
-        condition.put("sign",sign);
-        // 使用 HMAC-SHA256 签名
-        String postXmlString = WeChatUtil.mapFormatXML(condition);// xml
-        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver", postXmlString);
-        // 将xml转map
-        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
-        System.out.println(resultMap);
-        System.out.println(checkNoticeSign(resultMap));
-
-
+    private static final String SEP_OUT_ORDER_NO = "KTJ_%s_%s_%s";
+    private static String findSepOutOrderNo(){
+        return findSepOutOrderNo("SEP");
     }
+    private static String findSepOutOrderNo(String sep){
+        String s = DateUtils.formatDate(new Date(), "yyyyMMdd");
+        return String.format(SEP_OUT_ORDER_NO,sep,s,System.nanoTime());
+    }
+
 }

+ 273 - 0
src/main/java/com/wechat/service/sepAccount/impl/SepAccountTest.java

@@ -0,0 +1,273 @@
+package com.wechat.service.sepAccount.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wechat.common.enums.SepAccountEnums;
+import com.wechat.common.parameter.ProjectConstant;
+import com.wechat.common.response.RespWrapper;
+import com.wechat.common.util.ClientCustomSSL;
+import com.wechat.common.util.WeChatUtil;
+import com.wechat.common.util.WxXmlParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 分账测试类
+ */
+public class SepAccountTest {
+    // 删除分账
+    private static final String DEL_SEP_ACCOUNT_USER = "{\"type\":\"%s\",\"account\":\"%s\"}";
+    // 添加分账
+    private static final String WX_ACCOUNT_STRING = "{\"type\": \"%s\",\"account\": \"%s\",\"name\": \"%s\",\"relation_type\": \"%s\"} ";
+    private static Logger logger = LoggerFactory.getLogger(SepAccountTest.class);
+    // 添加分账人接了测试
+    public static void main(String[] args)throws Exception{
+        //addReceiver();
+        // 单次分账
+        //singleSepAccount();
+        // 查询分账
+        //findSepAccountResult();
+        // 删除分账人
+        //delSepAccountUser();
+        // 不分账接口
+        //noSepAccount();
+
+    }
+
+    /**
+     *  分账接收方与原请求不一致
+     *  多次分账后完结分账时,out_order_no 需要注意
+     *  第一次是系统内部生成的,第二、第三次 是上次分账返回的order_id
+     * @throws Exception
+     */
+    private static void noSepAccount()throws Exception {
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("transaction_id","4200000533202004184533522457");
+        condition.put("sign_type","HMAC-SHA256");
+        condition.put("out_order_no","30000110062020041800341490392");
+        condition.put("description","分账完成");
+        condition.put("sign", WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
+        String xml = WeChatUtil.mapFormatXML(condition);
+        String s = ClientCustomSSL.doCertWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish", xml,ProjectConstant.merchantId);
+        System.out.println(s);
+
+    }
+
+    /**
+     * 包括商户号,签名类型、随机数
+     * @param enums
+     * @param condition
+     * @param isSSL
+     * @return
+     */
+    private RespWrapper<Map<String,Object>> doWxRequest(SepAccountEnums enums, Map<String,Object> condition, boolean isSSL){
+        Assert.notNull(condition,"微信请求参数不能为空");
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sign_type","HMAC-SHA256");
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
+        String xml = WeChatUtil.mapFormatXML(condition);
+        try {
+            String xmlStr;
+            if(isSSL){
+                xmlStr = ClientCustomSSL.doCertWX(enums.getUrl(), xml);
+            }else xmlStr = WeChatUtil.postWX(enums.getUrl(), xml);
+            Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+            if(checkNoticeSign(resultMap))
+                return RespWrapper.makeSuccessResp(resultMap);
+            return RespWrapper.makeFailResp("校验签名错误");
+        }catch (Exception e){
+            logger.error("请求微信异常:{}",e);
+            return RespWrapper.makeFailResp("请求异常,请稍后再试!异常:"+e.getMessage());
+        }
+    }
+
+
+
+    /**
+     * {nonce_str=ed95b1c7fbd32fe8, receiver={"type":"PERSONAL_WECHATID","account":"wxid_haxp101y5saj21"}, appid=wxec504e0378010e16, sign=961EA0F51E9AC69229769F041DB5C05E86693F973F71B6DC0EF71D18709340D8, result_code=SUCCESS, mch_id=1503800091, sub_mch_id=1584278251, return_code=SUCCESS}
+     */
+    private static void delSepAccountUser() {
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("receiver",String.format(DEL_SEP_ACCOUNT_USER,"PERSONAL_WECHATID","wxid_haxp101y5saj21"));
+        condition.put("sign_type","HMAC-SHA256");
+        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
+        String xml = WeChatUtil.mapFormatXML(condition);
+        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver", xml);
+        System.out.println(xmlStr);
+        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+        System.out.println(resultMap);
+        System.out.println(checkNoticeSign(resultMap));
+
+    }
+
+    /**
+     * 查询分账结果
+     *
+     *
+     */
+    private static void findSepAccountResult() {
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        //condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("transaction_id","4200000533202004184533522457");
+        condition.put("sign_type","HMAC-SHA256");
+        condition.put("out_order_no",outOrderNo);
+        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
+        String xml = WeChatUtil.mapFormatXML(condition);
+        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingquery", xml);
+        System.out.println(xmlStr);
+        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+        System.out.println(resultMap);
+        System.out.println(checkNoticeSign(resultMap));
+    }
+    /**
+     *   {
+     *          "type": "MERCHANT_ID",
+     *          "account":"190001001",
+     *          "amount":100,
+     *          "description": "分到商户"
+     * },
+     */
+    static class SepUser{
+        String type;
+        String account;
+        int amount;
+        String description;
+        public SepUser(String type,String account,int amount,String description){
+            this.type = type;
+            this.account = account;
+            this.amount = amount;
+            this.description = description;
+        }
+        public String getType() {
+            return type;
+        }
+
+        public void setType(String type) {
+            this.type = type;
+        }
+
+        public String getAccount() {
+            return account;
+        }
+
+        public void setAccount(String account) {
+            this.account = account;
+        }
+
+        public int getAmount() {
+            return amount;
+        }
+
+        public void setAmount(int amount) {
+            this.amount = amount;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public void setDescription(String description) {
+            this.description = description;
+        }
+    }
+    /**
+     * 单个分账操作
+     */
+    private static final String outOrderNo = "ktjSep20200418001";
+
+    /**
+     * <xml>
+     * <return_code><![CDATA[SUCCESS]]></return_code>
+     * <result_code><![CDATA[SUCCESS]]></result_code>
+     * <mch_id><![CDATA[1503800091]]></mch_id>
+     * <sub_mch_id><![CDATA[1584278251]]></sub_mch_id>
+     * <appid><![CDATA[wxec504e0378010e16]]></appid>
+     * <nonce_str><![CDATA[47f68c677907aa1b]]></nonce_str>
+     * <sign><![CDATA[71B1A4DFEB6B835BB3676F25A61772B885ADD64BB9D969F29E0169BC0EE1D426]]></sign>
+     * <transaction_id><![CDATA[4200000533202004184533522457]]></transaction_id>
+     * <out_order_no><![CDATA[ktjSep20200418001]]></out_order_no>
+     * <order_id><![CDATA[30000110062020041800341490392]]></order_id>
+     * </xml>
+     * @throws Exception
+     */
+    private static void singleSepAccount() throws Exception{
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("transaction_id","4200000533202004184533522457");
+        condition.put("sign_type","HMAC-SHA256");
+        //condition.put("out_order_no",outOrderNo);
+        condition.put("out_order_no","ktjSep20200418002");
+        List<SepAccountServiceImpl.SepUser> list = new ArrayList<>();
+        list.add(new SepAccountServiceImpl.SepUser("PERSONAL_WECHATID","wxid_haxp101y5saj21",1,"分到个人"));
+        condition.put("receivers", JSONObject.toJSONString(list));
+        condition.put("sign",WeChatUtil.sha256_HMAC(condition, ProjectConstant.api));
+        String xml = WeChatUtil.mapFormatXML(condition);
+        //String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", xml);
+        String s = ClientCustomSSL.doCertWX("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", xml,ProjectConstant.merchantId);
+        System.out.println(s);
+        //Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+        //System.out.println(resultMap);
+        //System.out.println(checkNoticeSign(resultMap));
+
+    }
+
+    /**
+     * 校验微信响应数据
+     */
+    private static boolean checkNoticeSign(Map<String,Object> params){
+        String sign = (String) params.get("sign");
+        if(sign == null) return false;
+        return sign.equals(WeChatUtil.sha256_HMAC(params, ProjectConstant.api));
+    }
+
+    private static String account = "{ \n" +
+            "       \"type\": \"PERSONAL_WECHATID\", \n" +
+            "       \"account\": \"wxid_haxp101y5saj21\", \n" +
+            "       \"name\": \"赵路羊\", \n" +
+            "\"relation_type\": \"PARTNER\"\n" +
+            "} ";
+
+    // 添加分账人成功
+    // {nonce_str=23b0e1633fae5d5c, receiver={"type":"PERSONAL_WECHATID","account":"wxid_haxp101y5saj21","relation_type":"PARTNER"}, appid=wxec504e0378010e16, sign=3E2424E858AD437D86D9B444AD5592F5215BCCD4B1A50E6276226B747A4A8B39, result_code=SUCCESS, mch_id=1503800091, sub_mch_id=1584278251, return_code=SUCCESS}
+    private static void addReceiver(){
+        Map<String,Object> condition = new HashMap<>();
+        condition.put("mch_id", ProjectConstant.merchantId);//商户id
+        condition.put("sub_mch_id", "1584278251");//sub_mchId
+        condition.put("appid",ProjectConstant.appid);// appid
+        condition.put("nonce_str",ProjectConstant.findNonceStr());
+        condition.put("receiver",account);
+        condition.put("sign_type","HMAC-SHA256");
+        // 拼接签名
+        String sign = WeChatUtil.sha256_HMAC(condition, ProjectConstant.api);
+        condition.put("sign",sign);
+        // 使用 HMAC-SHA256 签名
+        String postXmlString = WeChatUtil.mapFormatXML(condition);// xml
+        String xmlStr = WeChatUtil.postWX("https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver", postXmlString);
+        // 将xml转map
+        Map<String,Object> resultMap = WxXmlParser.parseXML(xmlStr);   		//解析微信响应的XML结果
+        System.out.println(resultMap);
+        System.out.println(checkNoticeSign(resultMap));
+
+
+    }
+}

BIN
target/classes/com/wechat/common/util/WeChatUtil.class