Przeglądaj źródła

添加支付组件

周箭河 5 lat temu
rodzic
commit
c270991fc1
31 zmienionych plików z 1820 dodań i 448 usunięć
  1. BIN
      edu-thirdparty/libs/adapay-core-sdk-1.1.1.jar
  2. BIN
      edu-thirdparty/libs/adapay-java-sdk-1.1.1.jar
  3. 10 2
      edu-thirdparty/pom.xml
  4. 88 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Bill.java
  5. 65 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/ConfigInit.java
  6. 153 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/CorpMember.java
  7. 102 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/MainDemo.java
  8. 244 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Member.java
  9. 0 82
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/NotifyCallback.java
  10. 0 56
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/NotifyEvent.java
  11. 0 196
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Pay.java
  12. 197 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Payment.java
  13. 153 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Refund.java
  14. 457 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/SettleAccount.java
  15. 17 0
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/yqpay/YqPayUtil.java
  16. 8 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamMusicTheoryController.java
  17. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java
  18. 15 5
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java
  19. 9 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamMusicTheoryDao.java
  20. 10 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectSongDao.java
  21. 32 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistration.java
  22. 8 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamMusicTheoryService.java
  23. 3 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java
  24. 9 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamSubjectSongService.java
  25. 26 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/PayService.java
  26. 14 8
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamMusicTheoryServiceImpl.java
  27. 120 90
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java
  28. 7 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java
  29. 63 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/PayServiceImpl.java
  30. 5 0
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamMusicTheoryMapper.xml
  31. 4 1
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml

BIN
edu-thirdparty/libs/adapay-core-sdk-1.1.1.jar


BIN
edu-thirdparty/libs/adapay-java-sdk-1.1.1.jar


+ 10 - 2
edu-thirdparty/pom.xml

@@ -72,9 +72,17 @@
         <dependency>
             <groupId>adapay</groupId>
             <artifactId>adapay-java-sdk</artifactId>
-            <version>1.0.2</version>
+            <version>1.1.1</version>
             <scope>system</scope>
-            <systemPath>${project.basedir}/libs/adapay-java-sdk-1.0.2.jar
+            <systemPath>${project.basedir}/libs/adapay-java-sdk-1.1.1.jar
+            </systemPath>
+        </dependency>
+        <dependency>
+            <groupId>adapay.core</groupId>
+            <artifactId>adapay-core-sdk</artifactId>
+            <version>1.1.1</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/adapay-core-sdk-1.1.1.jar
             </systemPath>
         </dependency>
         <dependency>

+ 88 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Bill.java

@@ -0,0 +1,88 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author yingyong.wang
+ */
+public class Bill extends ConfigInit {
+
+    /**
+     * 运行账单下载接口
+     * @throws Exception 异常
+     */
+    public static void executeBillTest(String merchantKey) throws Exception{
+        Bill demo = new Bill();
+        
+        Map<String, Object> download = demo.executeBillDownLoad(merchantKey);
+       
+    }
+
+    /**
+     * 运行账单下载接口
+     * @throws Exception 异常
+     */
+    public static void executeBillTest() throws Exception{
+        Bill demo = new Bill();
+        
+        Map<String, Object> download = demo.executeBillDownLoad();
+       
+    }
+
+    /**
+     * 执行一个下载对账文件操作
+     * @return 下载链接
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeBillDownLoad(String merchantKey) throws Exception {
+        System.out.println("=======execute download begin=======");
+
+        Map<String, Object> downloadParam = new  HashMap<String, Object>(2);
+        downloadParam.put("bill_date", "20190912");
+        Map<String, Object> download = com.huifu.adapay.model.Bill.download(downloadParam, merchantKey);
+        
+        String errorCode = (String)download.get("error_code");
+        
+        if(null != errorCode){
+
+            System.out.println("对账单下载,请求参数:" + JSON.toJSONString(downloadParam));
+            System.out.println("对账单下载,返回参数:" + JSON.toJSONString(download));
+
+        }else{
+            System.out.println("对账单下载,成功");
+        }
+        
+
+        return download;
+    }
+
+    /**
+     * 执行一个下载对账文件操作
+     * @return 下载链接
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeBillDownLoad() throws Exception {
+        
+
+        Map<String, Object> downloadParam = new  HashMap<String, Object>(2);
+        downloadParam.put("bill_date", "20190912");
+        
+        Map<String, Object> download = com.huifu.adapay.model.Bill.download(downloadParam);
+        
+        String errorCode = (String)download.get("error_code");
+        
+        if(null != errorCode){
+
+            System.out.println("对账单下载,请求参数:" + JSON.toJSONString(downloadParam));
+            System.out.println("对账单下载,返回参数:" + JSON.toJSONString(download));
+
+        }else{
+            System.out.println("对账单下载,成功");
+        }
+        return download;
+    }
+    
+}

+ 65 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/ConfigInit.java

@@ -0,0 +1,65 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.huifu.adapay.Adapay;
+import com.huifu.adapay.model.MerConfig;
+
+
+public class ConfigInit {
+
+
+    private static ConfigInit instance;
+    public final static Integer organId = 46; //商户对应的分部
+    public final static String merNo = "B09767221"; //商户对应的分部
+    public final static String appId = "app_f0ebdd29-046f-4b60-bd50-92e2c1285c02";
+
+    public final static String wxAppId = "wx751141096e75a4ee";
+    public final static String wxAppSecret = "e882d76c95d1613607a85338b1bed3ff";
+    public final static String wxMpOAuth2AccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
+    public final static MerConfig merConfig = new MerConfig();
+
+    static {
+        try {
+            instance = initConfig();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private static ConfigInit initConfig() throws Exception {
+        if (instance == null) {
+            instance = new ConfigInit();
+        } else {
+            return instance;
+        }
+
+        Adapay.debug = true;
+
+        /**
+         * prodMode 模式,默认为生产模式,false可以使用mock模式
+         */
+        Adapay.prodMode = true;
+
+        /**
+         *添加商户配置,一个商户只需要 添加一次,添加以后在内存中。
+         */
+
+        String apiKey = "api_live_8dd6fba0-59ca-45f7-8e82-0b3ae7bd7907";
+        String mockApiKey = "api_test_193c8f6a-514f-4d95-a26b-2861c7971105";
+        String rsaPrivateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAL3zHDr2s5Lp3b9FKAD4vB3Y2MyOypv68mKFi8uPznO9JkzBhwYLYRC8mnP+W7tw5Q7Yuf5Szhn8Mo9KZ8Bsv6S6iz3BtXzeHb/8nyeBAH2m477bJzwmapZPhPSroR8md1dnNI+4NttM/0Cn/rdAySzQn+IPHLPxWFwQw+y6FFi7AgMBAAECgYEAkuUBPfAvKzxEyng22ZmCESrzbi43La1B6UMRuxi5NfRfPBilzNzb8c+JOo7Ibgp+eZ7NJ4rt7FaG2x1VYxA2m151I86e6TlgPYNjjj56RpkrD9/LrDqePFE4AlrwO5802fK4X/iac1MCpEhaiVNQ3x6ikwcKWzKmMV/EpdijIcECQQDlt+ou3L5M2TQW8YYg9zA9TKRd+M/Xs0tPLJLE+W6m0+dmyeHBErMW6X874qhmIc3F8HYIW+O51GMy6KDgQ7PrAkEA065ujs1ZkwIPMopgIoqlRi8JDvAxgEZqktDDMMg0o2XZP6J7C5suf2BsrhKnjLlxII7dQPxDfPDiRz4jYpBKcQJBAKd77ev42W5iNk48DdTfJHas+HHjRHY5rMCu+NtQGNLdUKtqqYQBRD2CRFe/K5Q7NTIJ3aS+ikwkg6bMYO7hrb0CQDesuC1c+0M8Fm0vketj1eZotpQ0PoDDhIJK4BuzfIzBW+ttu7kovokH/m2mQGU13Pg4Ox89ei6hWJJuWHYzBzECQQDexzziaTpHMy3achL2M2pOSdaSLYoesmPTmVZ3kOZf82FpRlfxVGUs0nKpEEgagUkiHUQHAu5RVkxIiDqMYrQp";
+
+        merConfig.setApiKey(apiKey);
+        merConfig.setApiMockKey(mockApiKey);
+        merConfig.setRSAPrivateKey(rsaPrivateKey);
+        Adapay.initWithMerConfig(merConfig);
+        /**
+         *启动MQTT,一个商户只需要 启动一次,启动完成以后一直在服务器后端运行
+         */
+        // notifyCallback = new NotifyCallback();
+        //Adapay.startMqttListener(merConfig, notifyCallback);
+        return instance;
+    }
+
+    public ConfigInit() {
+    }
+}

+ 153 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/CorpMember.java

@@ -0,0 +1,153 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author yingyong.wang
+ */
+class CorpMember extends ConfigInit {
+
+    /**
+     * 运行 CorpMember 类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeCorpMemberTest(String merchantKey, String app_id) throws Exception {
+        CorpMember demo = new CorpMember();
+        Map<String, Object> member = demo.executeCreateMember(merchantKey, app_id);
+        demo.executeQueryMember(merchantKey, (String) member.get("member_id"), app_id);
+
+    }
+
+
+    /**
+     * 创建 CorpMember
+     *
+     * @return 创建的CorpMember 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateMember(String merchantKey, String app_id) throws Exception {
+        System.out.println("=======execute Create CorpMember begin=======");
+        Map<String, Object> memberParams = new HashMap<String, Object>(2);
+        memberParams.put("member_id", "jsdk_member_" + System.currentTimeMillis());
+        memberParams.put("app_id", app_id);
+        memberParams.put("order_no", "jsdk_order_" + System.currentTimeMillis());
+        memberParams.put("social_credit_code_expires", "1111");
+        memberParams.put("business_scope", "123");
+
+        memberParams.put("name", "中国测试有限公司");
+        memberParams.put("prov_code", "0011");
+        memberParams.put("area_code", "1100");
+        memberParams.put("social_credit_code", "201932658452655");
+        memberParams.put("legal_person", "张测试");
+        memberParams.put("legal_cert_id", "321485199014234852");
+        memberParams.put("legal_cert_id_expires", "20220112");
+        memberParams.put("legal_mp", "13958465215");
+        memberParams.put("address", "中国上海");
+        memberParams.put("zip_code", "225485");
+        memberParams.put("telphone", "41164452");
+        memberParams.put("email", "ceshi@qq.com");
+        memberParams.put("bank_code", "652142");
+        memberParams.put("bank_acct_type", "1");
+        memberParams.put("card_no", "622546895642156");
+        memberParams.put("card_name", "中国测试有限公司");
+        File file = new File("/Users/will/Project/Adapay/AdapayJava/AdapayDemo/src/main/java/com/huifu/adapay/demo/归档.zip");
+        
+        System.out.println("创建企业用户,请求参数:" + JSON.toJSONString(memberParams) );
+        Map<String, Object> member = com.huifu.adapay.model.CorpMember.create(memberParams, file, merchantKey);
+        System.out.println("创建企业用户,返回参数:" + JSON.toJSONString(member) );
+
+
+        System.out.println("=======execute Create CorpMember end=======");
+
+        return member;
+
+    }
+
+    /**
+     * 查询 CorpMember
+     *
+     * @param member_id 待查询的member_id
+     * @return 查询的 CorpMember 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception {
+        System.out.println("=======execute query CorpMember begin=======");
+        Map<String, Object> memberParams = new HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", app_id);
+        System.out.println("查询企业用户,请求参数:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.CorpMember.query(memberParams, merchantKey);
+        System.out.println("查询企业用户,返回参数:"+ JSON.toJSONString(member));
+
+        System.out.println("=======execute query CorpMember end=======");
+
+        return member;
+    }
+
+    /**
+     * 运行 CorpMember 类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeCorpMemberTest( String app_id) throws Exception {
+        CorpMember demo = new CorpMember();
+        //Map<String, Object> member = demo.executeCreateMember();
+        //demo.executeQueryMember( (String) member.get("member_id"), app_id);
+
+    }
+
+
+    /**
+     * 创建 CorpMember
+     *
+     * @return 创建的CorpMember 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateMember( Map<String,Object> info) throws Exception {
+        System.out.println("=======execute Create CorpMember begin=======");
+        Map<String, Object> memberParams = new HashMap<String, Object>();
+        memberParams.put("app_id", appId);
+        memberParams.putAll(info);
+
+        String path= "C:/Users/river/Desktop/mec/mec-thirdparty/libs/test.zip";
+
+        File file = new File(path);
+        System.out.println("创建企业用户,请求参数:" + JSON.toJSONString(memberParams) );
+        Map<String, Object> member = com.huifu.adapay.model.CorpMember.create(memberParams, file);
+        System.out.println("创建企业用户,返回参数:" + JSON.toJSONString(member) );
+
+
+        System.out.println("=======execute Create CorpMember end=======");
+
+        return member;
+
+    }
+
+    /**
+     * 查询 CorpMember
+     *
+     * @param member_id 待查询的member_id
+     * @return 查询的 CorpMember 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQueryMember( String member_id) throws Exception {
+        System.out.println("=======execute query CorpMember begin=======");
+        Map<String, Object> memberParams = new HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", appId);
+        System.out.println("查询企业用户,请求参数1:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.CorpMember.query(memberParams);
+        System.out.println("查询企业用户,返回参数:"+ JSON.toJSONString(member));
+
+        System.out.println("=======execute query CorpMember end=======");
+
+        return member;
+    }
+
+
+}

+ 102 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/MainDemo.java

@@ -0,0 +1,102 @@
+package com.keao.edu.thirdparty.adapay;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class MainDemo {
+
+
+    public static void main(String[] args) throws Exception {
+        //多商户测试
+        //testMultiMerchant();
+
+        testMerchant();
+
+    }
+
+
+    public static void testMerchant() throws Exception {
+
+        HashMap<String, Object> memberParams = new HashMap<>();
+        memberParams.put("member_id", "W004201");
+        memberParams.put("order_no", "corp_mem_" + System.currentTimeMillis());
+
+        memberParams.put("social_credit_code", "91420106303461541T");
+        memberParams.put("social_credit_code_expires", "20440730");
+        memberParams.put("business_scope", "教育资讯、投资资讯");
+        memberParams.put("name", "武汉大雅乐盟教育咨询有限公司");
+        memberParams.put("prov_code", "0042");
+        memberParams.put("area_code", "4201");
+        memberParams.put("legal_person", "李松");
+        memberParams.put("legal_cert_id", "420106196811210837");
+        memberParams.put("legal_cert_id_expires", "20990730");
+        memberParams.put("legal_mp", "13958465215");//法人手机号
+        memberParams.put("address", "武昌区水果湖汉街武汉中央文化旅游区K3地块第2幢34层2号");
+        memberParams.put("zip_code", "430000");
+        //memberParams.put("telphone", "41164452");
+       // memberParams.put("email", "ceshi@qq.com");
+        memberParams.put("bank_code", "03020000");
+        memberParams.put("bank_acct_type", "1");
+        memberParams.put("card_no", "‘8111501011700649152");
+        memberParams.put("card_name", "武汉大雅乐盟教育咨询有限公司");
+       // new CorpMember().executeCreateMember(memberParams);
+
+        new CorpMember().executeQueryMember("W004201");
+
+
+        //Payment.closePayment("002112020062916385810123596334923411456");
+        //Map<String, Object> payment = Payment.queryPayment("002112020062914502410123569011751485440");
+
+
+        // 运行支付类接口
+        //String pamentId = Payment.executePaymentTest("default");
+
+    }
+
+
+    public static void testMultiMerchant() throws Exception {
+
+        // //运行支付类接口
+        String pamentId = Payment.executePaymentTest("yifuyun");
+
+        // //运行退款类接口
+        // RefundDemo.executeRefundTest("yifuyun", "002112019101420422510029799145265012736");
+        // /**
+        //  * 分账使用配套接口 begin
+        //  */
+        // /**用户类接口*/
+         Map<String, Object> member = Member.executeMemberTest("app_7d87c043-aae3-4357-9b2c-269349a980d6");
+        // String memberId = (String) member.get("member_id");
+        // /** 结算户绑定*/
+        // SettleAccountDemo.executeSettleAccountTest("yidian", "app_67ba475b-26e0-4cfa-847c-0f115cae5029", memberId);
+        // /**企业开户*/
+        CorpMember.executeCorpMemberTest("yifuyun", "app_67ba475b-26e0-4cfa-847c-0f115cae5029");
+        // /**
+        //  * 分账使用配套接口 end
+        //  */
+        // //对账单下载
+        // BillDemo.executeBillTest("yifuyun");
+        // String appId = "app_67ba475b-26e0-4cfa-847c-0f115cae5029";
+
+        // /**
+        //  * 获取云闪付用户号
+        //  */
+        // AdapayToolsDemo.executeToolsTest(appId, "yifuyun");
+        // /**
+        //  * 余额查询
+        //  */
+        // SettleAccountDemo.executeQueryBalance("yifuyun", appId, "member_id", "settleCount_id");
+        // /**
+        //  *用户取现
+        //  */
+        // SettleAccountDemo.executeDrawCash("yifuyun", appId, "member_id");
+        // /**
+        //  * 钱包登录申请
+        //  */
+        // AdapayToolsDemo.executeLoginTest(appId,"yifuyun");
+
+    }
+
+
+}

+ 244 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Member.java

@@ -0,0 +1,244 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author yingyong.wang
+ */
+public class Member extends ConfigInit {
+
+
+    /**
+     * 运行 member 类接口
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> executeMemberTest(String merchantKey, String app_id) throws Exception{
+        Member demo = new Member();
+        Map<String, Object> member = demo.executeCreateMember(merchantKey, app_id);
+        demo.executeQueryMember(merchantKey, (String)member.get("member_id"),app_id);
+        demo.executeUpdateMember(merchantKey, (String)member.get("member_id"),app_id);
+        demo.executeQueryMember(merchantKey, (String)member.get("member_id"),app_id);
+        demo.executeListMember(merchantKey, app_id);
+        return member;
+    }
+
+
+    /**
+     * 创建 member
+     * @return 创建的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateMember(String merchantKey, String app_id) throws Exception {
+        System.out.println("=======execute CreateMember begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", "jsdk_member_"+System.currentTimeMillis());
+        memberParams.put("app_id",app_id);
+        memberParams.put("location", "上海市徐汇区宜山路");
+        memberParams.put("email", "123@163.com");
+        memberParams.put("gender", "MALE");
+        memberParams.put("tel_no", "13153333333");
+        memberParams.put("nickname", "nick_name");
+        System.out.println("创建用户,请求参数:" + JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.create(memberParams, merchantKey);
+        System.out.println("创建用户,返回参数:" + JSON.toJSONString(member));
+        System.out.println("=======execute CreateMember end=======");
+        
+        return member;
+    
+    }
+
+    /**
+     * 查询 member
+     * @param member_id 待查询的member_id
+     * @return 创建的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception {
+        System.out.println("=======execute queryMember begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", app_id);
+        System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.query(memberParams, merchantKey);
+        System.out.println("查询用户,返回参数:" + JSON.toJSONString(member));
+
+
+        System.out.println("=======execute queryMember end=======");
+        
+        return member;
+    
+    }
+
+
+    /**
+     * 更新 member
+     * @param member_id 待更新的member_id
+     * @return 更新的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeUpdateMember(String merchantKey, String member_id,String app_id) throws Exception {
+        System.out.println("=======execute update Member begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", app_id);
+        memberParams.put("location", "上海市徐汇区宜山路1");
+        memberParams.put("email", "1234@163.com");
+        memberParams.put("gender", "MALE");
+        memberParams.put("tel_no", "13153333333");
+        memberParams.put("nickname", "nick_name2");
+
+        System.out.println("更新用户,请求参数:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.update(memberParams, merchantKey);
+        System.out.println("更新用户,返回参数:"+ JSON.toJSONString(member));
+
+        System.out.println("=======execute update Member end=======");
+        
+        return member;
+    
+    }
+
+    /**
+     * 查询 member list
+     * @param app_id app_id
+     * @return 查询的member list
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeListMember(String merchantKey, String app_id) throws Exception {
+        System.out.println("=======execute list Member begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("page_index", "1");
+        memberParams.put("app_id", app_id);
+        memberParams.put("page_size", "20");
+        memberParams.put("created_gte", String.valueOf(System.currentTimeMillis() - 5 * 60 * 1000));
+        memberParams.put("created_lte", String.valueOf(System.currentTimeMillis()));
+        System.out.println("查询用户列表,请求参数:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.queryList(memberParams, merchantKey);
+        System.out.println("查询用户列表,返回参数:"+ JSON.toJSONString(member));
+
+
+        System.out.println("=======execute list Member end=======");
+        
+        return member;
+    
+    }
+
+     /**
+     * 运行 member 类接口
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> executeMemberTest( String app_id) throws Exception{
+        Member demo = new Member();
+        Map<String, Object> member = demo.executeCreateMember( app_id);
+        demo.executeQueryMember( (String)member.get("member_id"),app_id);
+        demo.executeUpdateMember( (String)member.get("member_id"),app_id);
+        demo.executeQueryMember( (String)member.get("member_id"),app_id);
+        demo.executeListMember( app_id);
+        return member;
+    }
+
+
+    /**
+     * 创建 member
+     * @return 创建的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateMember( String app_id) throws Exception {
+        System.out.println("=======execute CreateMember begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", "0021677");
+        memberParams.put("app_id",app_id);
+        memberParams.put("location", "上海市徐汇区宜山路");
+        memberParams.put("email", "123@163.com");
+        memberParams.put("gender", "MALE");
+        memberParams.put("tel_no", "13153333333");
+        memberParams.put("nickname", "nick_name");
+        System.out.println("创建用户,请求参数:" + JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.create(memberParams);
+        System.out.println("创建用户,返回参数:" + JSON.toJSONString(member));
+        System.out.println("=======execute CreateMember end=======");
+        
+        return member;
+    
+    }
+
+    /**
+     * 查询 member
+     * @param member_id 待查询的member_id
+     * @return 创建的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQueryMember( String member_id,String app_id) throws Exception {
+        System.out.println("=======execute queryMember begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", app_id);
+        System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.query(memberParams);
+        System.out.println("查询用户,返回参数:" + JSON.toJSONString(member));
+
+
+        System.out.println("=======execute queryMember end=======");
+        
+        return member;
+    
+    }
+
+
+    /**
+     * 更新 member
+     * @param member_id 待更新的member_id
+     * @return 更新的member 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeUpdateMember( String member_id,String app_id) throws Exception {
+        System.out.println("=======execute update Member begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("member_id", member_id);
+        memberParams.put("app_id", app_id);
+        memberParams.put("location", "上海市徐汇区宜山路1");
+        memberParams.put("email", "1234@163.com");
+        memberParams.put("gender", "MALE");
+        memberParams.put("tel_no", "13153333333");
+        memberParams.put("nickname", "nick_name2");
+
+        System.out.println("更新用户,请求参数:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.update(memberParams);
+        System.out.println("更新用户,返回参数:"+ JSON.toJSONString(member));
+
+        System.out.println("=======execute update Member end=======");
+        
+        return member;
+    
+    }
+
+    /**
+     * 查询 member list
+     * @param app_id app_id
+     * @return 查询的member list
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeListMember( String app_id) throws Exception {
+        System.out.println("=======execute list Member begin=======");
+        Map<String, Object> memberParams = new  HashMap<String, Object>(2);
+        memberParams.put("page_index", "1");
+        memberParams.put("app_id", app_id);
+        memberParams.put("page_size", "20");
+        memberParams.put("created_gte", String.valueOf(System.currentTimeMillis() - 5 * 60 * 1000));
+        memberParams.put("created_lte", String.valueOf(System.currentTimeMillis()));
+        System.out.println("查询用户列表,请求参数:"+ JSON.toJSONString(memberParams));
+        Map<String, Object> member = com.huifu.adapay.model.Member.queryList(memberParams);
+        System.out.println("查询用户列表,返回参数:"+ JSON.toJSONString(member));
+
+
+        System.out.println("=======execute list Member end=======");
+        
+        return member;
+    
+    }
+
+
+}

+ 0 - 82
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/NotifyCallback.java

@@ -1,82 +0,0 @@
-package com.keao.edu.thirdparty.adapay;
-
-import com.alibaba.fastjson.JSON;
-import com.huifu.adapay.model.payment.Payment;
-import com.huifu.adapay.model.refund.Refund;
-import com.huifu.adapay.notify.INotifyCallback;
-/**
- * @author jane.zhao
- */
-public class NotifyCallback implements INotifyCallback {
-
-    /**
-     * 用户接收并处理支付成功的异步消息
-     * @param payment 成功的支付对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void paymentSuccessMessageArrived(Payment payment) throws Exception {
-        System.out.println("receive paymentSuccess msg=" + JSON.toJSONString(payment));
-
-    }
-
-    /**
-     * 用户接收并处理支付失败的异步消息
-     * @param payment 失败的支付对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void paymentFailedMessageArrived(Payment payment) throws Exception {
-        System.out.println("receive paymentFailed msg=" + JSON.toJSONString(payment));
-    }
-
-    /**
-     * 用户接收并处理关闭支付交易成功的异步消息
-     * @param payment 关闭成功的支付对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void paymentCloseSuccessMessageArrived(Payment payment) throws Exception {
-        System.out.println("receive paymentCloseSuccess msg=" + JSON.toJSONString(payment));
-    }
-
-    /**
-     * 用户接收并处理关闭支付交易失败的异步消息
-     * @param payment 关闭失败的支付对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void paymentCloseFailedMessageArrived(Payment payment) throws Exception {
-        System.out.println("receive paymentCloseFailed msg=" + JSON.toJSONString(payment));
-    }
-
-    /**
-     * 用户接收并处理退款成功的异步消息
-     * @param refund 成功的退款对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void refundSuccessMessageArrived(Refund refund) throws Exception {
-        System.out.println("receive refundSuccess msg=" + JSON.toJSONString(refund));
-    }
-
-    /**
-     * 用户接收并处理退款失败的异步消息
-     * @param refund 失败的退款对象
-     * @throws Exception 异常
-     */
-    @Override
-    public void refundFailedMessageArrived(Refund refund) throws Exception {
-        System.out.println("receive refundFailed msg=" + JSON.toJSONString(refund));
-    }
-
-    /**
-     * 用户接收并处理未知的异步消息
-     * @param msg 未知消息
-     * @throws Exception 异常
-     */
-    @Override
-    public void unknownMessageArrived(String msg) throws Exception {
-        System.out.println("receive unknown msg=" + msg);
-    }
-}

+ 0 - 56
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/NotifyEvent.java

@@ -1,56 +0,0 @@
-package com.keao.edu.thirdparty.adapay;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-public class NotifyEvent {
-    private String id;
-    private String type;
-    private String created_time;
-    private String prod_mode;
-    private String data;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getCreated_time() {
-        return created_time;
-    }
-
-    public void setCreated_time(String created_time) {
-        this.created_time = created_time;
-    }
-
-    public String getProd_mode() {
-        return prod_mode;
-    }
-
-    public void setProd_mode(String prod_mode) {
-        this.prod_mode = prod_mode;
-    }
-
-    public String getData() {
-        return data;
-    }
-
-    public void setData(String data) {
-        this.data = data;
-    }
-
-    @Override
-    public String toString() {
-        return ToStringBuilder.reflectionToString(this);
-    }
-}

+ 0 - 196
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Pay.java

@@ -1,196 +0,0 @@
-package com.keao.edu.thirdparty.adapay;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.huifu.adapay.AdaPay;
-import com.huifu.adapay.demo.BaseDemo;
-import com.huifu.adapay.demo.NotifyCallbackDemo;
-import com.huifu.adapay.exception.BaseAdaPayException;
-import com.huifu.adapay.model.DeviceInfo;
-import com.huifu.adapay.model.payment.*;
-import com.huifu.adapay.util.AdaPaySign;
-import org.aspectj.apache.bcel.classfile.Module;
-
-import java.math.BigDecimal;
-import java.util.*;
-
-/**
- * @author jane.zhao
- */
-public class Pay {
-    private static final String appId = "app_7d87c043-aae3-4357-9b2c-269349a980d6";
-    private static final String wxAppId = "wxcf8e8b33a9477845";
-
-    /**
-     * 运行支付类接口
-     *
-     * @return paymentId
-     * @throws Exception 异常
-     */
-    public Pay() throws Exception {
-        //apiKey,商户联调用
-        String apiKey = "api_test_e640fa26-bbe6-458f-ac44-a71723ee2176";
-        //apiKey,真实交易用(live)
-        String apiKeyLive = "api_live_9c14f264-e390-41df-984d-df15a6952031";
-        //公钥
-        String pubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB";
-        //私钥
-        String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMQhsygJ2pp4nCiDAXiqnZm6AzKSVAh+C0BgGR6QaeXzt0TdSi9VR0OQ7Qqgm92NREB3ofobXvxxT+wImrDNk6R6lnHPMTuJ/bYpm+sx397rPboRAXpV3kalQmbZ3P7oxtEWOQch0zV5B1bgQnTvxcG3REAsdaUjGs9Xvg0iDS2tAgMBAAECgYAqGFmNdF/4234Yq9V7ApOE1Qmupv1mPTdI/9ckWjaAZkilfSFY+2KqO8bEiygo6xMFCyg2t/0xDVjr/gTFgbn4KRPmYucGG+FzTRLH0nVIqnliG5Ekla6a4gwh9syHfstbOpIvJR4DfldicZ5n7MmcrdEwSmMwXrdinFbIS/P1+QJBAOr6NpFtlxVSGzr6haH5FvBWkAsF7BM0CTAUx6UNHb+RCYYQJbk8g3DLp7/vyio5uiusgCc04gehNHX4laqIdl8CQQDVrckvnYy+NLz+K/RfXEJlqayb0WblrZ1upOdoFyUhu4xqK0BswOh61xjZeS+38R8bOpnYRbLf7eoqb7vGpZ9zAkEAobhdsA99yRW+WgQrzsNxry3Ua1HDHaBVpnrWwNjbHYpDxLn+TJPCXvI7XNU7DX63i/FoLhOucNPZGExjLYBH/wJATHNZQAgGiycjV20yicvgla8XasiJIDP119h4Uu21A1Su8G15J2/9vbWn1mddg1pp3rwgvxhw312oInbHoFMxsQJBAJlyDDu6x05MeZ2nMor8gIokxq2c3+cnm4GYWZgboNgq/BknbIbOMBMoe8dJFj+ji3YNTvi1MSTDdSDqJuN/qS0=";
-
-        //设置AdaPay全局参数,不同环境设置不同的apiKey/pubKey/privateKey
-        AdaPay.apiKey = apiKeyLive;
-        AdaPay.pubKey = pubKey;
-        AdaPay.privateKey = privateKey;
-        AdaPay.debug = true;
-
-        //启动 mqtt 异步监听
-        AdaPay.iNotifyCallback = new NotifyCallbackDemo();
-        AdaPay.startNotifyListener();
-    }
-
-    public static String executePaymentTest() throws Exception {
-        //test chargeId = "002112019080716223300005091372336111616";
-        Pay demo = new Pay();
-        //支付接口
-        String orderNo = "jsdk_payment_" + System.currentTimeMillis();
-        String payChannel = PayChannelEnum.ALIPAY_QR.getCode();
-        BigDecimal amount = new BigDecimal("0.01");
-        String orderSubject = "测试大雅订单";
-        String orderBody = "测试大雅订单";
-        Payment payment = demo.executePayment(amount, orderNo, payChannel, orderSubject, orderBody,null);
-        //支付查询接口
-        //demo.queryPayment(payment.getId());
-        //关单接口
-        //demo.closePayment(payment.getId());
-
-        return payment.getId();
-    }
-
-
-    public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String orderSubject, String orderBody) throws Exception {
-
-        Map<String, Object> paymentParams = new HashMap<>(10);
-        paymentParams.put("appId", appId);
-        paymentParams.put("amount", amount);
-        paymentParams.put("orderNo", orderNo);
-        paymentParams.put("notifyUrl", notifyUrl);
-        paymentParams.put("orderSubject", orderSubject);
-        paymentParams.put("orderBody", orderBody);
-        paymentParams.put("wxAppId", wxAppId);
-        String originalStr = JSONObject.toJSONString(paymentParams);
-
-        String sign = AdaPaySign.sign(originalStr, AdaPay.privateKey);
-        paymentParams.put("sign", sign);
-        paymentParams.put("host", "http://192.168.3.27:8000/api-student/studentOrder/executePayment");
-        paymentParams.remove(appId);
-        return paymentParams;
-    }
-
-    public boolean verifySign(BigDecimal amount, String orderNo, String notifyUrl, String orderSubject, String orderBody, String sign) throws Exception {
-        Map<String, Object> paymentParams = new HashMap<>(10);
-        paymentParams.put("appId", appId);
-        paymentParams.put("amount", amount);
-        paymentParams.put("orderNo", orderNo);
-        paymentParams.put("notifyUrl", notifyUrl);
-        paymentParams.put("orderSubject", orderSubject);
-        paymentParams.put("orderBody", orderBody);
-        String originalStr = JSONObject.toJSONString(paymentParams);
-        return AdaPaySign.verifySign(originalStr, sign, AdaPay.pubKey);
-    }
-
-    /**
-     * 执行一个支付交易
-     *
-     * @return 创建的支付对象
-     * @throws Exception 异常
-     */
-    public static Payment executePayment(BigDecimal amount, String orderNo, String payChannel, String orderSubject, String orderBody, String openid) throws Exception {
-        System.out.println("=======execute payment begin=======");
-        //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id3
-        Map<String, Object> paymentParams = new HashMap<>(10);
-        paymentParams.put("app_id", appId);
-        paymentParams.put("order_no", orderNo);
-        paymentParams.put("pay_channel", payChannel);
-        paymentParams.put("pay_amt", amount);
-        paymentParams.put("currency", CurrencyEnum.CNY.getCode());
-        paymentParams.put("goods_title", orderSubject);
-        paymentParams.put("goods_desc", orderBody);
-
-//        DeviceInfo deviceInfo = new DeviceInfo();
-//        deviceInfo.setDeviceType(DeviceTypeEnum.MOBILE.getCode());
-//        deviceInfo.setDeviceIp("127.0.0.1");
-//        paymentParams.put("device_info", deviceInfo);
-
-//        List<GoodsDetail> goodsDetailList = new ArrayList<>();
-//        GoodsDetail goodsDetail = new GoodsDetail();
-//        goodsDetail.setGoodsId("your goods id");
-//        goodsDetail.setGoodsName("your goods name");
-//        goodsDetail.setQuantity("1");
-//        goodsDetail.setPrice("100.00");
-//        goodsDetailList.add(goodsDetail);
-//
-//        PromotionDetail promotionDetail = new PromotionDetail();
-//        promotionDetail.setGoodsDetail(goodsDetailList);
-//        promotionDetail.setCostPrice("100.00");
-
-        if (openid != null && !openid.isEmpty()) {
-            PaymentExpend expend = new PaymentExpend();
-            expend.setWxAppId("wx751141096e75a4ee");
-            expend.setOpenId(openid);
-            expend.setIsRaw("0");
-            paymentParams.put("expend", expend);
-        }
-
-        //调用sdk方法,创建支付,得到支付对象
-        Payment payment = null;
-        try {
-            payment = Payment.create(paymentParams);
-        } catch (BaseAdaPayException e) {
-            e.printStackTrace();
-        }
-        System.out.println("payment result=" + JSON.toJSONString(payment));
-        return payment;
-    }
-
-    /**
-     * 关闭一个支付交易
-     *
-     * @param paymentId 要关闭的支付id
-     * @return 关闭的支付对象
-     * @throws Exception 异常
-     */
-    public Payment closePayment(String paymentId) throws Exception {
-        System.out.println("=======close payment begin=======");
-        //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id11
-        //调用sdk方法,关闭支付,得到支付对象
-        Payment payment = null;
-        try {
-            payment = Payment.close(paymentId);
-        } catch (BaseAdaPayException e) {
-            e.printStackTrace();
-        }
-        System.out.println("close payment result=" + JSON.toJSONString(payment));
-        return payment;
-    }
-
-    /**
-     * 查询一个支付交易
-     *
-     * @param paymentId 要查询的支付id
-     * @return 查询的支付对象
-     * @throws Exception 异常
-     */
-    public Payment queryPayment(String paymentId) throws Exception {
-        System.out.println("=======query payment begin=======");
-        //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id7
-        //调用sdk方法,查询支付交易,得到支付对象
-        Payment payment = null;
-        try {
-            payment = Payment.query(paymentId);
-        } catch (BaseAdaPayException e) {
-            e.printStackTrace();
-        }
-        System.out.println("query payment result=" + JSON.toJSONString(payment));
-        return payment;
-    }
-}

+ 197 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Payment.java

@@ -0,0 +1,197 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huifu.adapay.core.exception.BaseAdaPayException;
+import org.springframework.util.DigestUtils;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Payment extends ConfigInit {
+
+
+    /**
+     * 运行支付类接口
+     *
+     * @return paymentId
+     * @throws Exception 异常
+     */
+    public static String executePaymentTest(String merchantKey) throws Exception {
+        //支付接口
+        Map<String, Object> paymentParams = new HashMap<>(10);
+        paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
+        paymentParams.put("pay_channel", "alipay_wap");
+        paymentParams.put("pay_amt", "0.01");
+
+        paymentParams.put("goods_title", "your goods title");
+        paymentParams.put("goods_desc", "your goods desc");
+        paymentParams.put("notify_url", "https://wxwechat.utools.club/studentOrder/adaNotify");
+
+
+        paymentParams.put("div_members", "");
+
+        Map<String, Object> deviceInfo = new HashMap<>(2);
+
+        deviceInfo.put("device_ip", "127.0.0.1");
+        deviceInfo.put("device_mac", "交易设备 MAC");
+        deviceInfo.put("device_type", "1");
+        deviceInfo.put("device_imei", "交易设备 IMEI");
+        deviceInfo.put("device_imsi", "交易设备 IMSI");
+        deviceInfo.put("device_iccId", "ICCID");
+        deviceInfo.put("device_wifi_mac", "WIFIMAC");
+
+        paymentParams.put("device_info", deviceInfo);
+
+//        Map<String, Object> goodsDetail = new HashMap<>();
+//
+//        goodsDetail.put("goods_id", "gooods_id_100002");
+//        goodsDetail.put("goods_name", "商品名称");
+//        goodsDetail.put("quantity", "1");
+//        goodsDetail.put("price", "100");
+//        goodsDetail.put("goods_category", "商品类目");
+//        goodsDetail.put("goods_body", "商品描述信息");
+//        goodsDetail.put("show_url", "商品的展示地址");
+//
+//        Map<String, Object> promotionDetail = new HashMap<>();
+//
+//        promotionDetail.put("cost_price", "100");
+//        promotionDetail.put("receipt_id", "商家小票 id");
+//        promotionDetail.put("goods_detail", goodsDetail);
+
+        Map<String, Object> expendParams = new HashMap<>(2);
+        String openId = "";//微信授权获取
+        expendParams.put("open_id", openId);
+        expendParams.put("is_raw", "1");
+        expendParams.put("callback_url", "绝对路径");
+        expendParams.put("limit_pay", "1");
+
+       // expendParams.put("promotion_detail", promotionDetail);
+        paymentParams.put("expend", expendParams);
+        Map<String, Object> payment = executePayment(paymentParams);
+        System.out.println("钱包支付地址:" + payment.get("pay_url"));
+        //支付查询接口
+       // queryPayment((String) payment.get("id"));
+        // //关单接口
+       // closePayment((String) payment.get("id"));
+
+        return (String) payment.get("id");
+    }
+
+    /**
+     * 执行一个支付交易
+     *
+     * @return 创建的支付对象
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> executePayment(Map<String, Object> paymentParams) throws Exception {
+        paymentParams.put("app_id", appId);
+
+        //调用sdk方法,创建支付,得到支付对象
+        Map<String, Object> payment = new HashMap<>();
+        try {
+            payment = com.huifu.adapay.model.Payment.create(paymentParams);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+
+        String error_code = (String) payment.get("error_code");
+        if (null != error_code) {
+            System.out.println("创建支付返回参数:" + JSON.toJSONString(payment));
+
+            String error_msg = (String) payment.get("error_msg");
+            System.out.println("error_code:" + error_code + "............." + error_msg);
+        }
+
+        return payment;
+    }
+
+    /**
+     * 关闭一个支付交易
+     *
+     * @param paymentId 要关闭的支付id
+     * @return 关闭的支付对象
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> closePayment(String paymentId) throws Exception {
+        System.out.println("=======close payment begin=======");
+        //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id11
+        //调用sdk方法,关闭支付,得到支付对象
+        Map<String, Object> payment = new HashMap<>();
+        Map<String, Object> paymentParams = new HashMap<>(10);
+        paymentParams.put("payment_id", paymentId);
+        try {
+            paymentParams.put("payment_id", paymentId);
+            paymentParams.put("reason", "reason");
+            paymentParams.put("expend", "expend");
+            paymentParams.put("notify_url", "notify_url");
+            System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
+            payment = com.huifu.adapay.model.Payment.close(paymentParams);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+
+
+        String error_code = (String) payment.get("error_code");
+        if (null != error_code) {
+            System.out.println("关单返回参数:" + JSON.toJSONString(payment));
+            String error_msg = (String) payment.get("error_msg");
+            System.out.println("error_code:" + error_code + "............." + error_msg);
+        }
+
+
+        return payment;
+    }
+
+    /**
+     * 查询一个支付交易
+     *
+     * @param paymentId 要查询的支付id
+     * @return 查询的支付对象
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> queryPayment(String paymentId) throws Exception {
+        System.out.println("=======query payment begin=======");
+        //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id7
+        //调用sdk方法,查询支付交易,得到支付对象
+        Map<String, Object> payment = new HashMap<>();
+        try {
+            System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
+            payment = com.huifu.adapay.model.Payment.query(paymentId);
+        } catch (BaseAdaPayException e) {
+            e.printStackTrace();
+        }
+
+        System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
+
+        String error_code = (String) payment.get("error_code");
+        if (null == error_code) {
+            String error_msg = (String) payment.get("error_msg");
+            System.out.println("error_code:" + error_code + "............." + error_msg);
+        }
+        System.out.println("=======query payment end=======");
+        return payment;
+    }
+
+
+    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
+        Map<String, Object> paymentParams = new HashMap<>(10);
+        paymentParams.put("appId", appId);
+        paymentParams.put("amount", amount);
+        paymentParams.put("orderNo", orderNo);
+        paymentParams.put("notifyUrl", notifyUrl);
+        paymentParams.put("returnUrl", returnUrl);
+        paymentParams.put("orderSubject", orderSubject);
+        paymentParams.put("orderBody", orderBody);
+        paymentParams.put("wxAppId", wxAppId);
+
+        String originalStr = JSONObject.toJSONString(paymentParams);
+        String sign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
+
+        paymentParams.put("sign", sign);
+        paymentParams.remove(appId);
+        return paymentParams;
+    }
+}

+ 153 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/Refund.java

@@ -0,0 +1,153 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Refund extends ConfigInit {
+
+    /**
+     * 运行退款类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeRefundTest(String merchantKey, String paymentId) throws Exception {
+        Refund demo = new Refund();
+        //退款接口
+        Map<String, Object> refund = demo.executeRefund(merchantKey, paymentId);
+        //退款查询接口(通过pamentId查询)
+        demo.queryByPaymentId(merchantKey, paymentId);
+        //退款查询接口(通过refundId查询)
+        demo.queryByRefundId(merchantKey, (String) refund.get("id"));
+    }
+
+    /**
+     * 执行一个退款交易
+     *
+     * @param paymentId 要退款的原支付paymentId
+     * @return 创建的退款对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeRefund(String merchantKey, String paymentId) throws Exception {
+        System.out.println("=======execute refund begin=======");
+        Map<String, Object> refundParams = new HashMap<String, Object>(2);
+        refundParams.put("refund_amt", "0.01");
+        refundParams.put("app_id", "your appid");
+        refundParams.put("refund_order_no", "jsdk_refund_"+System.currentTimeMillis());
+        System.out.println("退款请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.create(paymentId, refundParams, merchantKey);
+        System.out.println("退款返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======execute refund end=======");
+        
+        return refund;
+    }
+
+    /**
+     * 根据原支付id查询一个退款交易
+     *
+     * @param paymentId 要查询退款的原支付paymentId
+     * @return 查询的退款对象,可能含多个退款明细RefundDetail
+     * @throws Exception 异常
+     */
+    public Map<String, Object> queryByPaymentId(String merchantKey, String paymentId) throws Exception {
+        System.out.println("=======query refund by paymentId begin=======");
+        Map<String, Object> refundParams = new  HashMap<String, Object>(1);
+        refundParams.put("payment_id", paymentId);
+        System.out.println("通过原支付ID查询退款交易,请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.query(refundParams, merchantKey);
+        System.out.println("通过原支付ID查询退款交易,返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======query refund by paymentId end=======");
+        return refund;
+    }
+
+    /**
+     * 根据退款refundId查询一个退款交易
+     *
+     * @param refundId 要查询的退款refundId
+     * @return 查询的退款对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> queryByRefundId(String merchantKey, String refundId) throws Exception {
+        System.out.println("=======query refund by refundid begin=======");
+        Map<String, Object> refundParams = new  HashMap<String, Object>(1);
+        refundParams.put("refund_id", refundId);
+        System.out.println("通过refundId查询退款交易,请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.query(refundParams, merchantKey);
+        System.out.println("通过refundId查询退款交易,返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======query refund by refundid end=======");
+        return refund;
+    }
+
+    /**
+     * 运行退款类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeRefundTest( String paymentId) throws Exception {
+        Refund demo = new Refund();
+        //退款接口
+        Map<String, Object> refund = demo.executeRefund( paymentId);
+        //退款查询接口(通过pamentId查询)
+        demo.queryByPaymentId( paymentId);
+        //退款查询接口(通过refundId查询)
+        demo.queryByRefundId( (String) refund.get("id"));
+    }
+
+    /**
+     * 执行一个退款交易
+     *
+     * @param paymentId 要退款的原支付paymentId
+     * @return 创建的退款对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeRefund( String paymentId) throws Exception {
+        System.out.println("=======execute refund begin=======");
+        Map<String, Object> refundParams = new HashMap<String, Object>(2);
+        refundParams.put("refund_amt", "0.01");
+        refundParams.put("app_id", "your appid");
+        refundParams.put("refund_order_no", "jsdk_refund_"+System.currentTimeMillis());
+        System.out.println("退款请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.create(paymentId, refundParams);
+        System.out.println("退款返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======execute refund end=======");
+        
+        return refund;
+    }
+
+    /**
+     * 根据原支付id查询一个退款交易
+     *
+     * @param paymentId 要查询退款的原支付paymentId
+     * @return 查询的退款对象,可能含多个退款明细RefundDetail
+     * @throws Exception 异常
+     */
+    public Map<String, Object> queryByPaymentId( String paymentId) throws Exception {
+        System.out.println("=======query refund by paymentId begin=======");
+        Map<String, Object> refundParams = new  HashMap<String, Object>(1);
+        refundParams.put("payment_id", paymentId);
+        System.out.println("通过原支付ID查询退款交易,请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.query(refundParams);
+        System.out.println("通过原支付ID查询退款交易,返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======query refund by paymentId end=======");
+        return refund;
+    }
+
+    /**
+     * 根据退款refundId查询一个退款交易
+     *
+     * @param refundId 要查询的退款refundId
+     * @return 查询的退款对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> queryByRefundId( String refundId) throws Exception {
+        System.out.println("=======query refund by refundid begin=======");
+        Map<String, Object> refundParams = new  HashMap<String, Object>(1);
+        refundParams.put("refund_id", refundId);
+        System.out.println("通过refundId查询退款交易,请求参数:" + JSON.toJSONString(refundParams));
+        Map<String, Object> refund = com.huifu.adapay.model.Refund.query(refundParams);
+        System.out.println("通过refundId查询退款交易,返回参数:" + JSON.toJSONString(refund));
+        System.out.println("=======query refund by refundid end=======");
+        return refund;
+    }
+}

+ 457 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/adapay/SettleAccount.java

@@ -0,0 +1,457 @@
+package com.keao.edu.thirdparty.adapay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author yingyong.wang
+ */
+public class SettleAccount extends ConfigInit {
+
+    /**
+     * 运行结算账户类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeSettleAccountTest(String merchantKey, String app_id, String member_id) throws Exception {
+        SettleAccount demo = new SettleAccount();
+        // 创建结算账户
+        Map<String, Object> settlecount = demo.executeCreateSettleAccount(merchantKey, app_id, member_id);
+        String settleCount_id = (String) settlecount.get("id");
+
+
+        // 查询结算账户
+        demo.executeQuerySettleAccount(merchantKey, settleCount_id, app_id, member_id);
+
+        // 查询结算账户明细列表
+        demo.executeQuerySettleDetails(merchantKey, app_id, member_id, settleCount_id);
+        // 删除结算账户
+        demo.executeDeleteSettleAccount(merchantKey, settleCount_id, app_id, member_id);
+
+        member_id = "user_test_10001";
+        settleCount_id = "0023056905335360";
+
+        demo.executeModifySettleAccount(merchantKey, settleCount_id, app_id, member_id);
+
+        demo.executeDrawCash(merchantKey, app_id, member_id);
+
+        demo.executeQueryBalance(merchantKey, app_id, member_id, settleCount_id);
+    }
+
+    /**
+     * 运行查询结算明细列表接口
+     *
+     * @throws Exception 异常
+     */
+//    public static void executeQuerySettleDetailTest(String merchantKey, String appId, String memberId, String settleAccountId, String beginDate, String endDate) throws Exception {
+//        SettleAccountDemo demo = new SettleAccountDemo();
+//        demo.executeQuerySettleDetails(merchantKey, appId, memberId, settleAccountId, beginDate, endDate);
+//    }
+
+
+    /**
+     * 创建 settleCount
+     *
+     * @return 创建的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateSettleAccount(String merchantKey, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute Create SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        Map<String, Object> accountInfo = new HashMap<String, Object>(2);
+        accountInfo.put("card_id", "6222021703001692221");
+        accountInfo.put("card_name", "袁电茜");
+        accountInfo.put("cert_id", "310109200006062491");
+        accountInfo.put("cert_type", "00");
+        accountInfo.put("tel_no", "18888888881");
+        accountInfo.put("bank_code", "03060000");
+        accountInfo.put("bank_acct_type", "1");
+        accountInfo.put("prov_code", "0031");
+        accountInfo.put("area_code", "3100");
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        settleCountParams.put("channel", "bank_account");
+        settleCountParams.put("account_info", accountInfo);
+        System.out.println("创建结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.create(settleCountParams, merchantKey);
+        System.out.println("创建结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute Create SettleAccount end=======");
+
+        return settleCount;
+
+    }
+
+    /**
+     * 查询 SettleAccount
+     *
+     * @param settleCount_id 待查询的settleCount_id
+     * @param app_id         app_id
+     * @return 查询的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQuerySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute query SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        System.out.println("查询结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.query(settleCountParams, merchantKey);
+        System.out.println("查询结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute query SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 删除 SettleAccount
+     *
+     * @param settleCount_id 待删除的settleCount_id
+     * @param app_id         app_id
+     * @return delete的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeDeleteSettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute delete SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        System.out.println("删除结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.delete(settleCountParams, merchantKey);
+        System.out.println("删除结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute delete SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 查询结算明细列表
+     *
+     * @param merchantKey
+     * @param app_id          app_id
+     * @param member_id       待查询的member_id
+     * @param settleAccountId 待查询的settleAccountId
+     * @return
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQuerySettleDetails(String merchantKey, String app_id, String member_id,
+                                                         String settleAccountId) throws Exception {
+        System.out.println("=======execute query settle details begin=======");
+        Map<String, Object> querySettleDetailParams = new HashMap<String, Object>(2);
+        querySettleDetailParams.put("app_id", app_id);
+        querySettleDetailParams.put("member_id", member_id);
+        querySettleDetailParams.put("settle_account_id", settleAccountId);
+        querySettleDetailParams.put("begin_date", "20191008");
+        querySettleDetailParams.put("end_date", "20191010");
+        System.out.println("查询结算明细列表,请求参数:" + JSON.toJSONString(querySettleDetailParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.querySettleDetails(querySettleDetailParams, merchantKey);
+        System.out.println("查询结算明细列表,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute query settle details end=======");
+
+        return settleCount;
+    }
+
+
+    /**
+     * 运行结算账户类接口
+     *
+     * @throws Exception 异常
+     */
+    public static void executeSettleAccountTest(String app_id, String member_id) throws Exception {
+        SettleAccount demo = new SettleAccount();
+        // 创建结算账户
+        Map<String, Object> settlecount = demo.executeCreateSettleAccount(app_id, member_id);
+        String settleCount_id = (String) settlecount.get("id");
+        // 查询结算账户
+        demo.executeQuerySettleAccount(settleCount_id, app_id, member_id);
+
+        // 查询结算账户明细列表
+        demo.executeQuerySettleDetails(app_id, member_id, settleCount_id);
+        // 删除结算账户
+        demo.executeDeleteSettleAccount(settleCount_id, app_id, member_id);
+        member_id = "user_test_10001";
+        settleCount_id = "0023056905335360";
+
+        demo.executeModifySettleAccount(settleCount_id, app_id, member_id);
+
+    }
+
+    /**
+     * 运行查询结算明细列表接口
+     *
+     * @throws Exception 异常
+     */
+//    public static void executeQuerySettleDetailTest( String appId, String memberId, String settleAccountId, String beginDate, String endDate) throws Exception {
+//        SettleAccountDemo demo = new SettleAccountDemo();
+//        demo.executeQuerySettleDetails( appId, memberId, settleAccountId, beginDate, endDate);
+//    }
+
+
+    /**
+     * 创建 settleCount
+     *
+     * @return 创建的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeCreateSettleAccount(String app_id, String member_id) throws Exception {
+        System.out.println("=======execute Create SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        Map<String, Object> accountInfo = new HashMap<String, Object>(2);
+        accountInfo.put("card_id", "6222021703001692221");
+        accountInfo.put("card_name", "袁电茜");
+        accountInfo.put("cert_id", "310109200006062491");
+        accountInfo.put("cert_type", "00");
+        accountInfo.put("tel_no", "18888888881");
+        accountInfo.put("bank_code", "03060000");
+        accountInfo.put("bank_acct_type", "1");
+        accountInfo.put("prov_code", "0031");
+        accountInfo.put("area_code", "3100");
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        settleCountParams.put("channel", "bank_account");
+        settleCountParams.put("account_info", accountInfo);
+        System.out.println("创建结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.create(settleCountParams);
+        System.out.println("创建结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute Create SettleAccount end=======");
+
+        return settleCount;
+
+    }
+
+    /**
+     * 查询 SettleAccount
+     *
+     * @param settleCount_id 待查询的settleCount_id
+     * @param app_id         app_id
+     * @return 查询的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQuerySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute query SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        System.out.println("查询结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.query(settleCountParams);
+        System.out.println("查询结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute query SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 修改 SettleAccount
+     *
+     * @param settleCount_id 待修改的settleCount_id
+     * @param app_id         app_id
+     * @return 修改的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeModifySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+
+        settleCountParams.put("min_amt", "0.10");
+        settleCountParams.put("remained_amt", "0.10");
+        System.out.println("修改结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.modify(settleCountParams);
+        System.out.println("修改结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 修改 SettleAccount
+     *
+     * @param settleCount_id 待修改的settleCount_id
+     * @param app_id         app_id
+     * @return 修改的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeModifySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        settleCountParams.put("min_amt", "");
+        settleCountParams.put("remained_amt", "");
+
+        System.out.println("修改结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.modify(settleCountParams, merchantKey);
+        System.out.println("修改结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+
+
+    /**
+     * 删除 SettleAccount
+     *
+     * @param settleCount_id 待删除的settleCount_id
+     * @param app_id         app_id
+     * @return delete的settleCount 对象
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeDeleteSettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute delete SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
+        settleCountParams.put("settle_account_id", settleCount_id);
+        settleCountParams.put("member_id", member_id);
+        settleCountParams.put("app_id", app_id);
+        System.out.println("删除结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.delete(settleCountParams);
+        System.out.println("删除结算账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute delete SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 查询结算明细列表
+     *
+     * @param app_id          app_id
+     * @param member_id       待查询的member_id
+     * @param settleAccountId 待查询的settleAccountId
+     * @return
+     * @throws Exception 异常
+     */
+    public Map<String, Object> executeQuerySettleDetails(String app_id, String member_id,
+                                                         String settleAccountId) throws Exception {
+        System.out.println("=======execute query settle details begin=======");
+        Map<String, Object> querySettleDetailParams = new HashMap<String, Object>(2);
+        querySettleDetailParams.put("app_id", app_id);
+        querySettleDetailParams.put("member_id", member_id);
+        querySettleDetailParams.put("settle_account_id", settleAccountId);
+        querySettleDetailParams.put("begin_date", "20191008");
+        querySettleDetailParams.put("end_date", "20191010");
+        System.out.println("查询结算明细列表,请求参数:" + JSON.toJSONString(querySettleDetailParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.querySettleDetails(querySettleDetailParams);
+        System.out.println("查询结算明细列表,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute query settle details end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 取现
+     *
+     * @param merchantKey
+     * @param app_id
+     * @param member_id
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> executeDrawCash(String merchantKey, String app_id, String member_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>();
+
+        settleCountParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
+        settleCountParams.put("cash_amt", "0.01");
+        settleCountParams.put("member_id", "user_00008");
+        settleCountParams.put("app_id", app_id);
+        // settleCountParams.put("settle_account_id", "0008919797515968");
+        settleCountParams.put("cash_type", "T1");
+        settleCountParams.put("notify_url", "");
+
+        System.out.println("取现接口,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.drawCash(settleCountParams,merchantKey);
+        System.out.println("取现接口返回参数" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 查询余额
+     *
+     * @param merchantKey
+     * @param app_id
+     * @param member_id
+     * @param settleCount_id
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> executeQueryBalance(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>();
+
+        settleCountParams.put("app_id", app_id);
+        settleCountParams.put("member_id", "user_00008");
+        settleCountParams.put("settle_account_id", "0035172521665088");
+
+
+        System.out.println("查询余额账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.queryBalance(settleCountParams,merchantKey);
+        System.out.println("查询余额账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+    /**
+     * 取现
+     *
+
+     * @param app_id
+     * @param member_id
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> executeDrawCash(String app_id, String member_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>();
+
+        settleCountParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
+        settleCountParams.put("cash_amt", "0.01");
+        settleCountParams.put("member_id", "user_00008");
+        settleCountParams.put("app_id", app_id);
+        // settleCountParams.put("settle_account_id", "0008919797515968");
+        settleCountParams.put("cash_type", "T1");
+        settleCountParams.put("notify_url", "");
+
+        System.out.println("取现接口,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.drawCash(settleCountParams);
+        System.out.println("取现接口返回参数" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+
+    /**
+     * 查询余额
+     *
+
+     * @param app_id
+     * @param member_id
+     * @param settleCount_id
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> executeQueryBalance( String app_id, String member_id, String settleCount_id) throws Exception {
+        System.out.println("=======execute modify SettleAccount begin=======");
+        Map<String, Object> settleCountParams = new HashMap<String, Object>();
+
+        settleCountParams.put("app_id", app_id);
+        settleCountParams.put("member_id", "user_00008");
+        settleCountParams.put("settle_account_id", "0035172521665088");
+
+
+        System.out.println("查询余额账户,请求参数:" + JSON.toJSONString(settleCountParams));
+        Map<String, Object> settleCount = com.huifu.adapay.model.SettleAccount.queryBalance(settleCountParams);
+        System.out.println("查询余额账户,返回参数:" + JSON.toJSONString(settleCount));
+        System.out.println("=======execute modify SettleAccount end=======");
+
+        return settleCount;
+    }
+
+}

+ 17 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/yqpay/YqPayUtil.java

@@ -99,6 +99,23 @@ public class YqPayUtil {
     }
 
 
+    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
+        Map<String, Object> contentMap = new LinkedHashMap<>();
+        contentMap.put("sellerNo", merNo); //收款商户号
+        contentMap.put("payChannels", payChannels); //支付方式
+        contentMap.put("orderBody", orderBody); //订单信息
+        contentMap.put("payAmount", amount); //支付金额
+        contentMap.put("apiPayType", "1"); //*API支付类型1-即时支付,2-担保支付,3-预授权支付*/
+        contentMap.put("tradeType", "0"); //*交易类型1—充值,0—收款*
+        contentMap.put("merMerOrderNo", orderNo); //商户订单号
+        contentMap.put("orderSubject", orderSubject); //订单标题
+        contentMap.put("returnUrl", returnUrl); //前台页面地址
+        Map<String, Object> payMap = getRequestMap(notifyUrl, contentMap);
+        payMap.put("host", payUrl);
+        return payMap;
+    }
+
+
     /**
      * 验签
      *

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamMusicTheoryController.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Author Joburgess
@@ -52,4 +53,11 @@ public class ExamMusicTheoryController extends BaseController {
         return succeed(examMusicTheoryService.delete(id));
     }
 
+
+    @ApiOperation("获取项目乐理级别列表")
+    @GetMapping(value = "/getTheoryLevelList")
+    public HttpResponseResult<List<ExamMusicTheory>> getTheoryLevelList(Integer examinationBasicId) {
+        return succeed(examMusicTheoryService.getTheoryLevelList(examinationBasicId));
+    }
+
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -59,7 +59,7 @@ public class ExamRegistrationController extends BaseController {
     @ApiOperation(value = "报名")
     @PostMapping(value = "add")
     @PreAuthorize("@pcs.hasPermissions('examRegistration/add')")
-    public HttpResponseResult<ExamRegistration> add(ExamRegistration examRegistration) {
+    public HttpResponseResult add(ExamRegistration examRegistration) throws Exception {
         SysUser student = sysUserFeignService.queryUserInfo();
         examRegistration.setStudentId(student.getId());
         return succeed(examRegistrationService.addRegistration(examRegistration));

+ 15 - 5
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java

@@ -38,7 +38,7 @@ public class ExamSubjectSongController extends BaseController {
 
     @ApiOperation("添加考试内容")
     @PostMapping(value = "/addExamSubjects")
-    public HttpResponseResult addExamSubjects(@RequestBody List<ExamSubjectSong> examSubjectSongs){
+    public HttpResponseResult addExamSubjects(@RequestBody List<ExamSubjectSong> examSubjectSongs) {
         examSubjectSongService.addExamSubjects(examSubjectSongs);
         return succeed();
     }
@@ -50,13 +50,23 @@ public class ExamSubjectSongController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("获取考级专业相应级别列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "examinationBasicId", value = "项目id", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "examSubjectId", value = "考试项目专业id", required = true, dataType = "Integer")})
+    @GetMapping(value = "/getExamSubjectLevel")
+    public HttpResponseResult<List<ExamSubjectSong>> getExamSubjectLevel(Integer examinationBasicId, Long examSubjectId) {
+        return succeed(examSubjectSongService.getExamSubjectLevels(examinationBasicId, examSubjectId));
+    }
 
     @ApiOperation("获取考级专业相应级别的曲目")
-    @ApiImplicitParams({@ApiImplicitParam(name = "examSubjectId", value = "考试项目专业id", required = true, dataType = "Integer"),
-            @ApiImplicitParam(name = "level", value = "级别", required = true, dataType = "Integer") })
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "examinationBasicId", value = "项目id", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "examSubjectId", value = "考试项目专业id", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "level", value = "级别", required = true, dataType = "Integer")})
     @GetMapping(value = "/getExamSubjectSong")
-    public HttpResponseResult<List<ExamSong>> getExamSubjectSong(Long examSubjectId,Integer level) {
-        return succeed(examSubjectSongService.getExamSubjectSong(examSubjectId,level));
+    public HttpResponseResult<List<ExamSong>> getExamSubjectSong(Integer examinationBasicId, Long examSubjectId, Integer level) {
+        return succeed(examSubjectSongService.getExamSubjectSong(examinationBasicId, examSubjectId, level));
     }
 
 }

+ 9 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamMusicTheoryDao.java

@@ -2,8 +2,16 @@ package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.entity.ExamMusicTheory;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface ExamMusicTheoryDao extends BaseDAO<Integer, ExamMusicTheory> {
 
-	
+    /**
+     * 获取项目乐理级别列表
+     * @param examinationBasicId
+     * @return
+     */
+    List<ExamMusicTheory> getTheoryLevelList(@Param("examinationBasicId") Integer examinationBasicId);
 }

+ 10 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectSongDao.java

@@ -23,10 +23,19 @@ public interface ExamSubjectSongDao extends BaseDAO<Long, ExamSubjectSong> {
 
     /**
      * 获取考试对应科目对应级别的曲目
+     *
      * @param examSubjectId
      * @param level
      * @return
      */
-    ExamSubjectSong getExamSubjectSong(@Param("examSubjectId") Long examSubjectId, @Param("level") Integer level);
+    ExamSubjectSong getExamSubjectSong(@Param("examinationBasicId") Integer examinationBasicId, @Param("examSubjectId") Long examSubjectId, @Param("level") Integer level);
+
+    /**
+     * 获取项目对应专业的级别
+     * @param examinationBasicId
+     * @param examSubjectId
+     * @return
+     */
+    List<ExamSubjectSong> getExamSubjectLevels(@Param("examinationBasicId") Integer examinationBasicId, @Param("examSubjectId") Long examSubjectId);
 
 }

+ 32 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistration.java

@@ -36,6 +36,9 @@ public class ExamRegistration extends Student {
 	
 	@ApiModelProperty(value = "报考级别")
 	private Integer level;
+
+	@ApiModelProperty(value = "乐理级别")
+	private Integer examMusicTheoryLevel;
 	
 	@ApiModelProperty(value = "考试内容")
 	private String songJson;
@@ -61,6 +64,12 @@ public class ExamRegistration extends Student {
 	@ApiModelProperty(value = "备注")
 	private String memo;
 
+	@ApiModelProperty(value = "考试内容id")
+	private Long examSubjectSongId;
+
+	@ApiModelProperty(value = "项目乐理id")
+	private Integer examMusicTheoryId;
+
 	private java.util.Date createTime;
 
 	private java.util.Date updateTime;
@@ -227,9 +236,31 @@ public class ExamRegistration extends Student {
 		this.memo = memo;
 	}
 
+	public Long getExamSubjectSongId() {
+		return examSubjectSongId;
+	}
+
+	public void setExamSubjectSongId(Long examSubjectSongId) {
+		this.examSubjectSongId = examSubjectSongId;
+	}
+
+	public Integer getExamMusicTheoryId() {
+		return examMusicTheoryId;
+	}
+
+	public void setExamMusicTheoryId(Integer examMusicTheoryId) {
+		this.examMusicTheoryId = examMusicTheoryId;
+	}
+	public Integer getExamMusicTheoryLevel() {
+		return examMusicTheoryLevel;
+	}
+
+	public void setExamMusicTheoryLevel(Integer examMusicTheoryLevel) {
+		this.examMusicTheoryLevel = examMusicTheoryLevel;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
-
 }

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamMusicTheoryService.java

@@ -3,6 +3,14 @@ package com.keao.edu.user.service;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.entity.ExamMusicTheory;
 
+import java.util.List;
+
 public interface ExamMusicTheoryService extends BaseService<Integer, ExamMusicTheory> {
 
+    /**
+     * 获取项目的乐理级别列表
+     * @param examinationBasicId 项目id
+     * @return
+     */
+    List<ExamMusicTheory> getTheoryLevelList(Integer examinationBasicId);
 }

+ 3 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java

@@ -7,9 +7,11 @@ import com.keao.edu.user.dto.ExamRegistrationStatisticsDto;
 import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.page.ExamRegistrationQueryInfo;
 
+import java.util.Map;
+
 public interface ExamRegistrationService extends BaseService<Long, ExamRegistration> {
 
-   ExamRegistration addRegistration(ExamRegistration examRegistration);
+   Map<String,Object> addRegistration(ExamRegistration examRegistration) throws Exception;
 
    /**
     * @describe 查询考级项目报名学员

+ 9 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamSubjectSongService.java

@@ -24,6 +24,14 @@ public interface ExamSubjectSongService extends BaseService<Long, ExamSubjectSon
      * @param level
      * @return
      */
-    List<ExamSong> getExamSubjectSong(Long examSubjectId,Integer level);
+    List<ExamSong> getExamSubjectSong(Integer examinationBasicId,Long examSubjectId,Integer level);
+
+    /**
+     * 获取考级专业相应级别列表
+     * @param examinationBasicId
+     * @param examSubjectId
+     * @return
+     */
+    List<ExamSubjectSong> getExamSubjectLevels(Integer examinationBasicId,Long examSubjectId);
 
 }

+ 26 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/PayService.java

@@ -0,0 +1,26 @@
+package com.keao.edu.user.service;
+
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * 支付服务类
+ */
+
+public interface PayService {
+
+    /**
+     * @param amount       BigDecimal 支付金额
+     * @param orderNo      String 订单号
+     * @param notifyUrl    String 异步通知地址
+     * @param returnUrl    string 支付返回地址
+     * @param orderSubject String 订单标题
+     * @param orderBody    String 订单内容
+     * @return
+     * @throws Exception
+     */
+    Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception;
+
+
+}

+ 14 - 8
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamMusicTheoryServiceImpl.java

@@ -8,15 +8,21 @@ import com.keao.edu.user.service.ExamMusicTheoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class ExamMusicTheoryServiceImpl extends BaseServiceImpl<Integer, ExamMusicTheory> implements ExamMusicTheoryService {
-	
-	@Autowired
-	private ExamMusicTheoryDao examMusicTheoryDao;
 
-	@Override
-	public BaseDAO<Integer, ExamMusicTheory> getDAO() {
-		return examMusicTheoryDao;
-	}
-	
+    @Autowired
+    private ExamMusicTheoryDao examMusicTheoryDao;
+
+    @Override
+    public BaseDAO<Integer, ExamMusicTheory> getDAO() {
+        return examMusicTheoryDao;
+    }
+
+    @Override
+    public List<ExamMusicTheory> getTheoryLevelList(Integer examinationBasicId) {
+        return examMusicTheoryDao.getTheoryLevelList(examinationBasicId);
+    }
 }

+ 120 - 90
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -5,115 +5,145 @@ import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.page.PageInfo;
-import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.service.IdGeneratorService;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.user.dao.*;
 import com.keao.edu.user.dto.ExamRegistrationStatisticsDto;
-import com.keao.edu.user.entity.ExamCertification;
-import com.keao.edu.user.entity.ExamRegistration;
-import com.keao.edu.user.entity.ExaminationBasic;
+import com.keao.edu.user.entity.*;
 import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.page.ExamRegistrationQueryInfo;
 import com.keao.edu.user.service.ExamRegistrationService;
 import com.keao.edu.user.service.OrganizationService;
+import com.keao.edu.user.service.PayService;
 import com.keao.edu.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
 public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegistration> implements ExamRegistrationService {
-	
-	@Autowired
-	private ExamRegistrationDao examRegistrationDao;
-	@Autowired
-	private StudentDao studentDao;
-	@Autowired
-	private ExamCertificationDao examCertificationDao;
-	@Autowired
-	private ExaminationBasicDao examinationBasicDao;
-	@Autowired
-	private SysUserDao sysUserDao;
-	@Autowired
-	private OrganizationService organizationService;
-
-	@Override
-	public BaseDAO<Long, ExamRegistration> getDAO() {
-		return examRegistrationDao;
-	}
+
+    @Autowired
+    private ExamRegistrationDao examRegistrationDao;
+    @Autowired
+    private StudentDao studentDao;
+    @Autowired
+    private ExamCertificationDao examCertificationDao;
+    @Autowired
+    private ExaminationBasicDao examinationBasicDao;
+    @Autowired
+    private SysUserDao sysUserDao;
+    @Autowired
+    private OrganizationService organizationService;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private ExamSubjectSongDao examSubjectSongDao;
+    @Autowired
+    private ExamMusicTheoryDao examMusicTheoryDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+
+    @Override
+    public BaseDAO<Long, ExamRegistration> getDAO() {
+        return examRegistrationDao;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> addRegistration(ExamRegistration examRegistration) throws Exception {
+        SysUser sysUser = examRegistration.getSysUser();
+        ExaminationBasic examinationBasic = examinationBasicDao.get(examRegistration.getExaminationBasicId().longValue());
+        if (examinationBasic == null || !examinationBasic.getStatus().equals(ExamStatusEnum.APPLYING)) {
+            throw new BizException("项目不在报名中,请核对");
+        }
+        SysUser user = sysUserDao.get(examRegistration.getUserId());
+        user.setBirthdate(sysUser.getBirthdate());
+        user.setGender(sysUser.getGender());
+        user.setIdCardNo(examRegistration.getCardNo());
+        user.setRealName(sysUser.getRealName());
+        user.setNation(sysUser.getNation());
+        sysUserDao.update(user);
+
+        //考试级别信息
+        ExamSubjectSong examSubjectSong = examSubjectSongDao.get(examRegistration.getExamSubjectSongId());
+        if (examSubjectSong == null) {
+            throw new BizException("请选择专业级别");
+        }
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+
+        examRegistration.setLevel(examSubjectSong.getLevel());
+        BigDecimal amount = examSubjectSong.getRegistrationFee();
+        //乐理考试级别
+        ExamMusicTheory examMusicTheory = null;
+        if (examRegistration.getExamMusicTheoryId() != null) {
+            examMusicTheory = examMusicTheoryDao.get(examRegistration.getExamMusicTheoryId());
+        }
+        if (examMusicTheory != null) {
+            examRegistration.setExamMusicTheoryLevel(examMusicTheory.getLevel());
+            amount.add(examMusicTheory.getFee());
+        }
+
+        examRegistration.setUserId(examRegistration.getStudentId());
+        studentDao.insert(examRegistration);
+        examRegistrationDao.insert(examRegistration);
+
+
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+        Map<String, Object> payMap = payService.getPayMap(
+                amount,
+                orderNo,
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
+                examinationBasic.getName(),
+                examinationBasic.getName()
+        );
+
+        return payMap;
+    }
 
     @Override
-	@Transactional(rollbackFor = Exception.class)
-    public ExamRegistration addRegistration(ExamRegistration examRegistration) {
-		SysUser sysUser = examRegistration.getSysUser();
-		ExaminationBasic examinationBasic = examinationBasicDao.get(examRegistration.getExaminationBasicId().longValue());
-		if(examinationBasic == null || !examinationBasic.getStatus().equals(ExamStatusEnum.APPLYING)){
-			throw new BizException("项目不在报名中,请核对");
-		}
-		SysUser user = sysUserDao.get(examRegistration.getUserId());
-		user.setBirthdate(sysUser.getBirthdate());
-		user.setGender(sysUser.getGender());
-		user.setIdCardNo(examRegistration.getCardNo());
-		user.setRealName(sysUser.getRealName());
-		user.setNation(sysUser.getNation());
-		sysUserDao.update(user);
-
-		examRegistration.setUserId(examRegistration.getStudentId());
-		studentDao.insert(examRegistration);
-		examRegistrationDao.insert(examRegistration);
-
-		ExamCertification examCertification = new ExamCertification();
-		examCertification.setExaminationBasicId(examRegistration.getExaminationBasicId());
-		examCertification.setStudentId(examRegistration.getStudentId());
-		examCertification.setCardNo(examRegistration.getCardNo());
-		examCertification.setSubjectId(examRegistration.getSubjectId());
-		examCertification.setLevel(examRegistration.getLevel());
-		examCertification.setExamStartTime(examinationBasic.getExpectExamStartTime());
-		examCertification.setExamEndTime(examinationBasic.getExpectExamEndTime());
-		examCertification.setTenantId(examRegistration.getTenantId());
-		examCertificationDao.insert(examCertification);
-		return examRegistration;
+    public PageInfo<ExamRegistration> queryExamRegistrationStudents(ExamRegistrationQueryInfo queryInfo) {
+        PageInfo<ExamRegistration> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<Integer> nextLevelOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);
+        params.put("organIds", nextLevelOrganIds);
+
+        List<ExamRegistration> dataList = Collections.EMPTY_LIST;
+        int count = this.findCount(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = this.getDAO().queryPage(params);
+            List<Integer> organIds = dataList.stream().map(ExamRegistration::getOrganId).collect(Collectors.toList());
+            Map<Integer, String> organIdNameMap = this.getMap("organization", "id_", "name_", organIds, Integer.class, String.class);
+            List<Integer> subjectIds = dataList.stream().map(ExamRegistration::getSubjectId).collect(Collectors.toList());
+            Map<Integer, String> subjectIdNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
+            for (ExamRegistration examRegistration : dataList) {
+                examRegistration.getOrganization().setName(organIdNameMap.get(examRegistration.getOrganId()));
+                examRegistration.getSubject().setName(subjectIdNameMap.get(examRegistration.getStudentId()));
+            }
+        }
+
+        pageInfo.setRows(dataList);
+        return pageInfo;
     }
 
-	@Override
-	public PageInfo<ExamRegistration> queryExamRegistrationStudents(ExamRegistrationQueryInfo queryInfo) {
-		PageInfo<ExamRegistration> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
-		Map<String, Object> params = new HashMap<String, Object>();
-		MapUtil.populateMap(params, queryInfo);
-
-		List<Integer> nextLevelOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);
-		params.put("organIds", nextLevelOrganIds);
-
-		List<ExamRegistration> dataList = Collections.EMPTY_LIST;
-		int count = this.findCount(params);
-		if (count > 0) {
-			pageInfo.setTotal(count);
-			params.put("offset", pageInfo.getOffset());
-			dataList = this.getDAO().queryPage(params);
-			List<Integer> organIds = dataList.stream().map(ExamRegistration::getOrganId).collect(Collectors.toList());
-			Map<Integer, String> organIdNameMap = this.getMap("organization", "id_", "name_", organIds, Integer.class, String.class);
-			List<Integer> subjectIds = dataList.stream().map(ExamRegistration::getSubjectId).collect(Collectors.toList());
-			Map<Integer, String> subjectIdNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
-			for (ExamRegistration examRegistration : dataList) {
-				examRegistration.getOrganization().setName(organIdNameMap.get(examRegistration.getOrganId()));
-				examRegistration.getSubject().setName(subjectIdNameMap.get(examRegistration.getStudentId()));
-			}
-		}
-
-		pageInfo.setRows(dataList);
-		return pageInfo;
-	}
-
-	@Override
-	public ExamRegistrationStatisticsDto getExamRegistrationStaticsInfo(Integer organId, Integer examId) {
-		List<Integer> childOrganIds = organizationService.getChildOrganIds(organId, true);
-		ExamRegistrationStatisticsDto examRegistrationStaticsInfo = examRegistrationDao.getExamRegistrationStaticsInfo(organId, childOrganIds, examId);
-		if(Objects.isNull(examRegistrationStaticsInfo)){
-			examRegistrationStaticsInfo=new ExamRegistrationStatisticsDto();
-		}
-		return examRegistrationStaticsInfo;
-	}
+    @Override
+    public ExamRegistrationStatisticsDto getExamRegistrationStaticsInfo(Integer organId, Integer examId) {
+        List<Integer> childOrganIds = organizationService.getChildOrganIds(organId, true);
+        ExamRegistrationStatisticsDto examRegistrationStaticsInfo = examRegistrationDao.getExamRegistrationStaticsInfo(organId, childOrganIds, examId);
+        if (Objects.isNull(examRegistrationStaticsInfo)) {
+            examRegistrationStaticsInfo = new ExamRegistrationStatisticsDto();
+        }
+        return examRegistrationStaticsInfo;
+    }
 }

+ 7 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java

@@ -103,9 +103,9 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 	}
 
     @Override
-    public List<ExamSong> getExamSubjectSong(Long examSubjectId, Integer level) {
+    public List<ExamSong> getExamSubjectSong(Integer examinationBasicId,Long examSubjectId, Integer level) {
 		List<ExamSong> examSongs = new ArrayList<>();
-		ExamSubjectSong examSubjectSong = examSubjectSongDao.getExamSubjectSong(examSubjectId, level);
+		ExamSubjectSong examSubjectSong = examSubjectSongDao.getExamSubjectSong(examinationBasicId,examSubjectId, level);
 		if(examSubjectSong == null){
 			return examSongs;
 		}
@@ -119,4 +119,9 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 		}
 		return examSongs;
 	}
+
+    @Override
+    public List<ExamSubjectSong> getExamSubjectLevels(Integer examinationBasicId, Long examSubjectId) {
+		return examSubjectSongDao.getExamSubjectLevels(examinationBasicId,examSubjectId);
+    }
 }

+ 63 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/PayServiceImpl.java

@@ -0,0 +1,63 @@
+package com.keao.edu.user.service.impl;
+
+import com.keao.edu.common.exception.BizException;
+import com.keao.edu.thirdparty.adapay.Payment;
+import com.keao.edu.thirdparty.yqpay.YqPayUtil;
+import com.keao.edu.user.dao.SysConfigDao;
+import com.keao.edu.user.service.PayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * 支付服务类
+ */
+@Service
+public class PayServiceImpl implements PayService {
+
+    @Autowired
+    private SysConfigDao sysConfigDao;
+
+    /**
+     * 返回订单提交数据
+     *
+     * @param amount       金额
+     * @param orderNo      订单编号
+     * @param notifyUrl    异步通知地址
+     * @param returnUrl    支付返回地址
+     * @param orderSubject 订单标题
+     * @param orderBody    订单内容
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
+
+        //支付通道决策
+        Map<String, Object> unionPay = new HashMap<>();
+        Map<String, Object> payMap = null;
+        String type = null;
+        String routingMerNos = null;
+        String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
+        if (paymentChannel.equals("YQPAY")) {
+            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
+            type = "YQPAY";
+            routingMerNos = (String) payMap.get("merNo");
+        } else if (paymentChannel.equals("ADAPAY")) {
+            payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
+            type = "ADAPAY";
+            routingMerNos = Payment.merNo;
+        } else {
+            throw new BizException("收款渠道配置错误");
+        }
+
+        unionPay.put("orderNo", orderNo);
+        unionPay.put("type", type);
+        unionPay.put("payMap", payMap);
+        unionPay.put("routingMerNos", routingMerNos);
+        return unionPay;
+    }
+
+}

+ 5 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamMusicTheoryMapper.xml

@@ -79,4 +79,9 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM exam_music_theory
 	</select>
+
+	<!-- 获取项目的乐理级别列表 -->
+	<select id="getTheoryLevelList" resultMap="ExamMusicTheory">
+		SELECT * FROM exam_music_theory WHERE examination_basic_id_ = #{examinationBasicId} ORDER BY level_ ASC
+	</select>
 </mapper>

+ 4 - 1
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml

@@ -131,6 +131,9 @@
 		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examId}
 	</select>
     <select id="getExamSubjectSong" resultType="com.keao.edu.user.entity.ExamSubjectSong">
-		SELECT * FROM exam_subject_song WHERE exam_subject_id_ = #{examSubjectId} AND level_ = #{level}
+		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} AND level_ = #{level}
+	</select>
+	<select id="getExamSubjectLevels" resultMap="ExamSubjectSong">
+		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} ORDER BY level_ ASC
 	</select>
 </mapper>