xiongzhu 4 жил өмнө
parent
commit
044df8dedb

+ 28 - 75
src/main/java/com/izouma/awesomeAdmin/config/WxPayProperties.java

@@ -1,5 +1,6 @@
 package com.izouma.awesomeAdmin.config;
 
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -10,88 +11,40 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
  * @author Binary Wang
  */
 @ConfigurationProperties(prefix = "wx.pay")
+@Data
 public class WxPayProperties {
-  /**
-   * 设置微信公众号或者小程序等的appid
-   */
-  private String appId;
+    /**
+     * 设置微信公众号或者小程序等的appid
+     */
+    private String appId;
 
-  /**
-   * 微信支付商户号
-   */
-  private String mchId;
+    /**
+     * 微信支付商户号
+     */
+    private String mchId;
 
-  /**
-   * 微信支付商户密钥
-   */
-  private String mchKey;
+    /**
+     * 微信支付商户密钥
+     */
+    private String mchKey;
 
-  /**
-   * 服务商模式下的子商户公众账号ID,普通模式请不要配置,请在配置文件中将对应项删除
-   */
-  private String subAppId;
+    /**
+     * 服务商模式下的子商户公众账号ID,普通模式请不要配置,请在配置文件中将对应项删除
+     */
+    private String subAppId;
 
-  /**
-   * 服务商模式下的子商户号,普通模式请不要配置,最好是请在配置文件中将对应项删除
-   */
-  private String subMchId;
+    /**
+     * 服务商模式下的子商户号,普通模式请不要配置,最好是请在配置文件中将对应项删除
+     */
+    private String subMchId;
 
-  /**
-   * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
-   */
-  private String keyPath;
+    /**
+     * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
+     */
+    private String keyPath;
 
-  public String getAppId() {
-    return this.appId;
-  }
+    private String notifyUrl;
 
-  public void setAppId(String appId) {
-    this.appId = appId;
-  }
+    private String refundNotifyUrl;
 
-  public String getMchId() {
-    return mchId;
-  }
-
-  public void setMchId(String mchId) {
-    this.mchId = mchId;
-  }
-
-  public String getMchKey() {
-    return mchKey;
-  }
-
-  public void setMchKey(String mchKey) {
-    this.mchKey = mchKey;
-  }
-
-  public String getSubAppId() {
-    return subAppId;
-  }
-
-  public void setSubAppId(String subAppId) {
-    this.subAppId = subAppId;
-  }
-
-  public String getSubMchId() {
-    return subMchId;
-  }
-
-  public void setSubMchId(String subMchId) {
-    this.subMchId = subMchId;
-  }
-
-  public String getKeyPath() {
-    return this.keyPath;
-  }
-
-  public void setKeyPath(String keyPath) {
-    this.keyPath = keyPath;
-  }
-
-  @Override
-  public String toString() {
-    return ToStringBuilder.reflectionToString(this,
-        ToStringStyle.MULTI_LINE_STYLE);
-  }
 }

+ 6 - 4
src/main/java/com/izouma/awesomeAdmin/web/WxController.java

@@ -9,6 +9,7 @@ import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 import com.github.binarywang.wxpay.constant.WxPayConstants;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
+import com.izouma.awesomeAdmin.config.WxPayProperties;
 import com.izouma.awesomeAdmin.exception.BusinessException;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -32,9 +33,10 @@ import java.io.IOException;
 @RestController
 @RequestMapping("/wx")
 public class WxController {
-    private WxMpService  wxMpService;
-    private WxPayService wxPayService;
-    private Environment  env;
+    private WxMpService     wxMpService;
+    private WxPayService    wxPayService;
+    private WxPayProperties wxPayProperties;
+    private Environment     env;
 
     @RequestMapping("/testMp")
     public ModelAndView testPay(@RequestParam(required = false) String code, HttpServletRequest request,
@@ -65,7 +67,7 @@ public class WxController {
         request.setOutTradeNo(RandomStringUtils.randomAlphanumeric(32));
         request.setTotalFee(totalFee);
         request.setSpbillCreateIp("180.102.110.170");
-        request.setNotifyUrl(env.getProperty("wx.pay.notifyUrl"));
+        request.setNotifyUrl(wxPayProperties.getNotifyUrl());
         request.setTradeType(WxPayConstants.TradeType.JSAPI);
         request.setOpenid(openId);
         request.setSignType("MD5");

+ 79 - 79
src/main/resources/application.yaml

@@ -1,94 +1,94 @@
 server:
-    port: 8080
-    servlet:
-        context_path: /
-    compression:
-        enabled: true
-        mime-types: application/json,application/xml,text/html,text/xml,text/plain
-    error:
-        whitelabel:
-            enabled: false
+  port: 8080
+  servlet:
+    context_path: /
+  compression:
+    enabled: true
+    mime-types: application/json,application/xml,text/html,text/xml,text/plain
+  error:
+    whitelabel:
+      enabled: false
 spring:
-    profiles:
-        active: dev
-    datasource:
-        url: jdbc:mysql://mysql.izouma.com/awesome_admin_v2?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
-        username: microball
-        password: 2wsx@WSX#EDC
-        hikari:
-            minimum-idle: 5
-            maximum-pool-size: 30
-            auto-commit: true
-            idle-timeout: 30000
-            max-lifetime: 1800000
-            connection-timeout: 30000
-            connection-test-query: SELECT 1
-    jpa:
-        database: MySQL
-        database_platform: org.hibernate.dialect.MySQL5InnoDBDialect
-        hibernate:
-            ddl_auto: update
-        properties:
-            hibernate:
-                enable_lazy_load_no_trans: true
-    redis:
-        host: 127.0.0.1
-        port: 6379
-        lettuce:
-            pool:
-                max_active: 8
-                max_idle: 8
-                min_idle: 0
-    servlet:
-        multipart:
-            max_file_size: 100MB
-            max_request_size: 100MB
-    freemarker:
-        settings:
-            number_format: 0
-    cache:
-        type: caffeine
+  profiles:
+    active: dev
+  datasource:
+    url: jdbc:mysql://mysql.izouma.com/awesome_admin_v2?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
+    username: microball
+    password: 2wsx@WSX#EDC
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 30
+      auto-commit: true
+      idle-timeout: 30000
+      max-lifetime: 1800000
+      connection-timeout: 30000
+      connection-test-query: SELECT 1
+  jpa:
+    database: MySQL
+    database_platform: org.hibernate.dialect.MySQL5InnoDBDialect
+    hibernate:
+      ddl_auto: update
+    properties:
+      hibernate:
+        enable_lazy_load_no_trans: true
+  redis:
+    host: 127.0.0.1
+    port: 6379
+    lettuce:
+      pool:
+        max_active: 8
+        max_idle: 8
+        min_idle: 0
+  servlet:
+    multipart:
+      max_file_size: 100MB
+      max_request_size: 100MB
+  freemarker:
+    settings:
+      number_format: 0
+  cache:
+    type: caffeine
 jwt:
-    secret: XvAD0kboD76Dpebm
-    header: Authorization
-    expiration: 2592000 #30days
+  secret: XvAD0kboD76Dpebm
+  header: Authorization
+  expiration: 2592000 #30days
 wx:
-    mp:
-        app_id: wx2375cba2eec2c479
-        app_secret: 28e4829124860d9ef9e2f32aeefd1111
-    ma:
-        app_id: wx6517cbf58115c508
-        app_secret: 8af0e8ba28ffddfb7e574e6c7cb6aaf1
-        msg_token: msgToken
-        msg_aes_key: aesKey
-        msg_format: JSON
-    pay:
-        appId: wx2375cba2eec2c479
-        mchId: 1529090291
-        mchKey: uDusnGcUqYyWqsBdmvuioxDhtgZErwtu
-        subAppId: #服务商模式下的子商户公众账号ID
-        subMchId: #服务商模式下的子商户号
-        keyPath: classpath:/cert/apiclient_cert.p12
-        notifyUrl: http://zmj.izouma.com/wx/payNotify
-        refundNotifyUrl: http://zmj.izouma.com/wx/refundNotify
+  mp:
+    app-id: wx2375cba2eec2c479
+    app-secret: 28e4829124860d9ef9e2f32aeefd1111
+  ma:
+    app-id: wx6517cbf58115c508
+    app-secret: 8af0e8ba28ffddfb7e574e6c7cb6aaf1
+    msg-token: msgToken
+    msg-aes-key: aesKey
+    msg-format: JSON
+  pay:
+    app-id: wx2375cba2eec2c479
+    mch-id: 1529090291
+    mch-key: uDusnGcUqYyWqsBdmvuioxDhtgZErwtu
+    sub-app-id: #服务商模式下的子商户公众账号ID
+    sub-mch-id: #服务商模式下的子商户号
+    key-path: classpath:/cert/apiclient_cert.p12
+    notify-url: http://zmj.izouma.com/wx/payNotify
+    refund-notify-url: http://zmj.izouma.com/wx/refundNotify
 storage:
-    provider: aliyun
-    local_path: /var/www/upload/
+  provider: aliyun
+  local_path: /var/www/upload/
 aliyun:
-    access-key-id: PXzJyah5rZfWHIIH
-    access-key-secret: e1MS6j0wypXJrw8CM0hObZu8qKbfah
-    oss-end-point: oss-cn-hangzhou.aliyuncs.com
-    oss-bucket-name: ticket-exchange
-    oss-domain: https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com
+  access-key-id: PXzJyah5rZfWHIIH
+  access-key-secret: e1MS6j0wypXJrw8CM0hObZu8qKbfah
+  oss-end-point: oss-cn-hangzhou.aliyuncs.com
+  oss-bucket-name: ticket-exchange
+  oss-domain: https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com
 general:
-    host: http://art.izouma.com
+  host: http://art.izouma.com
 ---
 
 spring:
-    profiles: test
+  profiles: test
 
 ---
 
 spring:
-    profiles: prod
+  profiles: prod