Your Name hace 3 años
padre
commit
98feceb780

+ 2
- 0
.gitignore Ver fichero

@@ -39,3 +39,5 @@ build/
39 39
 /deploy/*.zip
40 40
 /deploy/.fun/
41 41
 /deploy/.env
42
+
43
+cert/

+ 27
- 0
pom.xml Ver fichero

@@ -24,6 +24,12 @@
24 24
 			<artifactId>spring-boot-starter-web</artifactId>
25 25
 		</dependency>
26 26
 
27
+		<dependency>
28
+			<groupId>org.springframework.boot</groupId>
29
+			<artifactId>spring-boot-configuration-processor</artifactId>
30
+			<optional>true</optional>
31
+		</dependency>
32
+
27 33
 		<dependency>
28 34
 			<groupId>org.springframework.boot</groupId>
29 35
 			<artifactId>spring-boot-starter-test</artifactId>
@@ -116,6 +122,11 @@
116 122
 			<artifactId>weixin-java-miniapp</artifactId>
117 123
 			<version>3.8.0</version>
118 124
 		</dependency>
125
+		<dependency>
126
+			<groupId>com.github.binarywang</groupId>
127
+			<artifactId>weixin-java-pay</artifactId>
128
+			<version>3.8.0</version>
129
+		</dependency>
119 130
 		<!--weixin-miniapp start-->
120 131
 
121 132
 		<!--lombok start-->
@@ -150,6 +161,14 @@
150 161
 					<plugin>
151 162
 						<groupId>org.springframework.boot</groupId>
152 163
 						<artifactId>spring-boot-maven-plugin</artifactId>
164
+						<configuration>
165
+							<excludes>
166
+								<exclude>
167
+									<groupId>org.springframework.boot</groupId>
168
+									<artifactId>spring-boot-configuration-processor</artifactId>
169
+								</exclude>
170
+							</excludes>
171
+						</configuration>
153 172
 					</plugin>
154 173
 				</plugins>
155 174
 				<resources>
@@ -175,6 +194,14 @@
175 194
 					<plugin>
176 195
 						<groupId>org.springframework.boot</groupId>
177 196
 						<artifactId>spring-boot-maven-plugin</artifactId>
197
+						<configuration>
198
+							<excludes>
199
+								<exclude>
200
+									<groupId>org.springframework.boot</groupId>
201
+									<artifactId>spring-boot-configuration-processor</artifactId>
202
+								</exclude>
203
+							</excludes>
204
+						</configuration>
178 205
 					</plugin>
179 206
 
180 207
 					<!-- 跳过测试 -->

+ 24
- 0
src/main/java/com/yunzhi/shigongli/common/WxUtils.java Ver fichero

@@ -3,6 +3,9 @@ package com.yunzhi.shigongli.common;
3 3
 import cn.binarywang.wx.miniapp.api.WxMaService;
4 4
 import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5 5
 import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
6
+import com.github.binarywang.wxpay.config.WxPayConfig;
7
+import com.github.binarywang.wxpay.service.WxPayService;
8
+import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
6 9
 import com.yunzhi.shigongli.config.WeixinConfig;
7 10
 import org.springframework.beans.factory.annotation.Autowired;
8 11
 import org.springframework.stereotype.Component;
@@ -10,10 +13,12 @@ import org.springframework.stereotype.Component;
10 13
 @Component
11 14
 public class WxUtils {
12 15
     private static WxMaService service;
16
+    private static WxPayService payService;
13 17
 
14 18
     @Autowired
15 19
     public WxUtils(WeixinConfig config) {
16 20
         setService(config);
21
+        setPay(config);
17 22
     }
18 23
 
19 24
     private void setService(WeixinConfig config) {
@@ -28,7 +33,26 @@ public class WxUtils {
28 33
         service.setWxMaConfig(conf);
29 34
     }
30 35
 
36
+    private void setPay(WeixinConfig config) {
37
+        WxPayConfig payConfig = new WxPayConfig();
38
+        payConfig.setAppId(config.getPay().getAppId());
39
+        payConfig.setMchId(config.getPay().getMchId());
40
+        payConfig.setMchKey(config.getPay().getMchKey());
41
+        payConfig.setSubAppId(config.getPay().getSubAppId());
42
+        payConfig.setSubMchId(config.getPay().getSubMchId());
43
+        payConfig.setKeyPath(config.getPay().getKeyPath());
44
+
45
+        // 可以指定是否使用沙箱环境
46
+        payConfig.setUseSandboxEnv(false);
47
+
48
+        WxPayService wxPayService = new WxPayServiceImpl();
49
+        wxPayService.setConfig(payConfig);
50
+    }
51
+
31 52
     public WxMaService getService() {
32 53
         return service;
33 54
     }
55
+    public WxPayService getPayService() {
56
+        return payService;
57
+    }
34 58
 }

+ 3
- 6
src/main/java/com/yunzhi/shigongli/config/AliyunConfig.java Ver fichero

@@ -12,11 +12,9 @@ public class AliyunConfig {
12 12
     private String accessKeyId;
13 13
     private String accessKeySecret;
14 14
 
15
-    @NestedConfigurationProperty
16
-    private Oss oss = new Oss();
15
+    private Oss oss;
17 16
 
18
-    @NestedConfigurationProperty
19
-    private Sms sms = new Sms();
17
+    private Sms sms;
20 18
 
21 19
     @Data
22 20
     public  static class Oss {
@@ -32,8 +30,7 @@ public class AliyunConfig {
32 30
 
33 31
     @Data
34 32
     public static class Sms {
35
-        @NestedConfigurationProperty
36
-        private Captcha captcha = new Captcha();
33
+        private Captcha captcha;
37 34
     }
38 35
 
39 36
     @Data

+ 1
- 2
src/main/java/com/yunzhi/shigongli/config/InterceptorConfig.java Ver fichero

@@ -10,8 +10,7 @@ import org.springframework.stereotype.Component;
10 10
 @ConfigurationProperties(prefix = "interceptor")
11 11
 public class InterceptorConfig {
12 12
 
13
-    @NestedConfigurationProperty
14
-    private Config permission = new Config();
13
+    private Config permission;
15 14
 
16 15
     @Data
17 16
     public static class Config {

+ 36
- 2
src/main/java/com/yunzhi/shigongli/config/WeixinConfig.java Ver fichero

@@ -10,8 +10,9 @@ import org.springframework.stereotype.Component;
10 10
 @ConfigurationProperties(prefix = "weixin")
11 11
 public class WeixinConfig {
12 12
 
13
-    @NestedConfigurationProperty
14
-    private Miniapp miniapp = new Miniapp();
13
+    private Miniapp miniapp;
14
+
15
+    private Pay pay;
15 16
 
16 17
     @Data
17 18
     public static class Miniapp {
@@ -21,4 +22,37 @@ public class WeixinConfig {
21 22
         private String aesKey;
22 23
         private String msgDataFormat;
23 24
     }
25
+
26
+    @Data
27
+    public static class Pay {
28
+        /**
29
+         * 设置微信公众号或者小程序等的appid
30
+         */
31
+        private String appId;
32
+
33
+        /**
34
+         * 微信支付商户号
35
+         */
36
+        private String mchId;
37
+
38
+        /**
39
+         * 微信支付商户密钥
40
+         */
41
+        private String mchKey;
42
+
43
+        /**
44
+         * 服务商模式下的子商户公众账号ID,普通模式请不要配置,请在配置文件中将对应项删除
45
+         */
46
+        private String subAppId;
47
+
48
+        /**
49
+         * 服务商模式下的子商户号,普通模式请不要配置,最好是请在配置文件中将对应项删除
50
+         */
51
+        private String subMchId;
52
+
53
+        /**
54
+         * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
55
+         */
56
+        private String keyPath;
57
+    }
24 58
 }

+ 4
- 0
src/main/resources/application-dev.yml Ver fichero

@@ -14,3 +14,7 @@ logging:
14 14
   level:
15 15
     root: info
16 16
     springfox: info
17
+
18
+weixin:
19
+  pay:
20
+    keyPath: E:/work/shigongli/v2/service/cert/apiclient_cert.p12

+ 9
- 2
src/main/resources/application.yml Ver fichero

@@ -45,11 +45,18 @@ aliyun:
45 45
 ###
46 46
 weixin:
47 47
   miniapp:
48
-    appid: wx75ce0dc4b59e0458
49
-    secret: 0fb386cad221580dda74b7471460a73e
48
+    appid: wx06a7372d48d56843
49
+    secret: ead0c7b1dd40ce828b1fd9bf18183584
50 50
     token:
51 51
     aesKey:
52 52
     msgDataFormat: JSON
53
+  pay:
54
+    appId: wx06a7372d48d56843
55
+    mchId: 1612121997
56
+    mchKey: fUbYPldU5bUCYRl97vMv69JQujsJ8dj5
57
+    subAppId:
58
+    subMchId:
59
+    keyPath: /yunpan/shigongli/cert/apiclient_cert.p12
53 60
 
54 61
 ###
55 62
 spring: