Compare commits
50 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
3f7fc0f016 | 4 years ago |
|
|
f61826c2e3 | 4 years ago |
|
|
ccad940202 | 4 years ago |
|
|
0fa87a4482 | 4 years ago |
|
|
ebf0f007c6 | 4 years ago |
|
|
ddcf26df53 | 4 years ago |
|
|
40ee5be954 | 4 years ago |
|
|
6f85eea135 | 4 years ago |
|
|
4609dfe73e | 4 years ago |
|
|
1ff54fb82e | 4 years ago |
|
|
e7433b76f2 | 4 years ago |
|
|
9ff0068ef0 | 4 years ago |
|
|
37f46ba485 | 4 years ago |
|
|
7094d2a0a8 | 4 years ago |
|
|
28742aff97 | 4 years ago |
|
|
3073691397 | 4 years ago |
|
|
dc077aeff0 | 4 years ago |
|
|
c11582afa6 | 4 years ago |
|
|
5fd1dbe2ef | 4 years ago |
|
|
a8a7f8a851 | 4 years ago |
|
|
4e14c20928 | 4 years ago |
|
|
f38ac29b28 | 4 years ago |
|
|
e38dbb3018 | 4 years ago |
|
|
bc0a696e26 | 4 years ago |
|
|
338feae26b | 4 years ago |
|
|
c3ae720f3e | 4 years ago |
|
|
3a81eed12b | 4 years ago |
|
|
615c63a7cd | 4 years ago |
|
|
13b7e7a4e0 | 4 years ago |
|
|
bfa839459d | 4 years ago |
|
|
d8a51423f4 | 4 years ago |
|
|
e11ddd3949 | 4 years ago |
|
|
7fd3cd75a8 | 4 years ago |
|
|
8b5c72098b | 4 years ago |
|
|
78a6b44e3b | 4 years ago |
|
|
4fa049186b | 4 years ago |
|
|
8a21555621 | 4 years ago |
|
|
5e0d4666be | 4 years ago |
|
|
1e726c183a | 4 years ago |
|
|
426b53f326 | 4 years ago |
|
|
358ea88a45 | 4 years ago |
|
|
e90c4e3622 | 4 years ago |
|
|
8d310f4c3a | 4 years ago |
|
|
3216cd0b99 | 4 years ago |
|
|
b53667b991 | 4 years ago |
|
|
cd8c4d6469 | 4 years ago |
|
|
28c7ae1b5c | 4 years ago |
|
|
67cf17b6ae | 4 years ago |
|
|
b6ff9d877a | 4 years ago |
|
|
c4d98d5c88 | 4 years ago |
98 changed files with 7797 additions and 945 deletions
@ -0,0 +1,194 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> |
|||
<component name="FacetManager"> |
|||
<facet type="Spring" name="Spring"> |
|||
<configuration /> |
|||
</facet> |
|||
<facet type="web" name="Web"> |
|||
<configuration> |
|||
<webroots /> |
|||
</configuration> |
|||
</facet> |
|||
</component> |
|||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
|||
<output url="file://$MODULE_DIR$/target/classes" /> |
|||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> |
|||
<content url="file://$MODULE_DIR$"> |
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> |
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> |
|||
<excludeFolder url="file://$MODULE_DIR$/target" /> |
|||
</content> |
|||
<orderEntry type="inheritedJdk" /> |
|||
<orderEntry type="sourceFolder" forTests="false" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.26" level="project" /> |
|||
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> |
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.17" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.17" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.17" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.16.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.1.4" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.9" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:1.3.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.4.6" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:1.3.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.1.10" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.alibaba:druid:1.1.10" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.47" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-devtools:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.8" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.11.1" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.23.4" level="project" /> |
|||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.12" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.12" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" /> |
|||
<orderEntry type="library" scope="TEST" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.6.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.7.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.4.2" level="project" /> |
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.httpcomponents:httpmime:4.5.8" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-net:commons-net:3.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.4.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.1.6.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.34.Final" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.2.8.RELEASE" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.6.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.47" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.12" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.plugins:maven-assembly-plugin:3.0.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-plugin-api:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-inject-plexus:1.4.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-inject-bean:1.4.2" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.sisu:sisu-guice:noaop:2.1.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-core:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-settings:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-settings-builder:3.3.9" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-builder-support:3.3.9" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-repository-metadata:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-model-builder:3.0" level="project" /> |
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.maven:maven-aether-provider:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.aether:aether-impl:1.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.aether:aether-spi:1.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.aether:aether-api:1.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.aether:aether-util:1.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-classworlds:2.2.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-component-annotations:1.5.5" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.plexus:plexus-sec-dispatcher:1.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.plexus:plexus-cipher:1.4" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-artifact:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-model:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:maven-common-artifact-filters:3.0.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:maven-shared-utils:3.1.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:maven-artifact-transfer:0.9.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-interpolation:1.24" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-archiver:3.4" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.11" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.iq80.snappy:snappy:0.4" level="project" /> |
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.tukaani:xz:1.5" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:file-management:3.0.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:maven-shared-io:3.0.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-compat:3.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.wagon:wagon-provider-api:2.10" level="project" /> |
|||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven.shared:maven-filtering:3.1.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.sonatype.plexus:plexus-build-api:0.0.7" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-io:2.7.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.apache.maven:maven-archiver:3.1.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-utils:3.0.24" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.aliyun.oss:aliyun-sdk-oss:3.6.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: org.codehaus.jettison:jettison:1.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-core:3.4.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-ram:3.0.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-sts:3.0.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.aliyun:aliyun-java-sdk-ecs:4.2.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: io.minio:minio:8.0.3" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.carrotsearch.thirdparty:simple-xml-safe:2.7.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" /> |
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" /> |
|||
</component> |
|||
</module> |
|||
@ -0,0 +1,17 @@ |
|||
package com.base.springcloud.aspect.annotation; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@Target(ElementType.METHOD) |
|||
@Documented |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface LoginRequired { |
|||
// 用户信息
|
|||
boolean user() default true; |
|||
|
|||
// 部门 ture - 获取部门信息
|
|||
boolean department() default false; |
|||
|
|||
// 公司 ture - 获取公司信息
|
|||
boolean company() default false; |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
package com.base.springcloud.aspect.annotation; |
|||
|
|||
import java.lang.annotation.*; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Target({ElementType.METHOD}) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@Inherited |
|||
public @interface Rlock { |
|||
|
|||
/** |
|||
* 分布式锁的key前缀 |
|||
*/ |
|||
String prefix() default "redisLockPrefix::"; |
|||
|
|||
/** |
|||
* 分布式锁的key动态参数 |
|||
*/ |
|||
String suffix() default "lockDynamicKey"; |
|||
|
|||
/** |
|||
* 等待时间 默认五秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
long waitTime() default 5; |
|||
|
|||
/** |
|||
* 锁释放时间 默认十秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
long leaseTime() default 10; |
|||
|
|||
/** |
|||
* 时间格式 默认:秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
TimeUnit timeUnit() default TimeUnit.SECONDS; |
|||
} |
|||
@ -1,118 +0,0 @@ |
|||
package com.base.springcloud.aspect.aspect; |
|||
|
|||
import com.base.springcloud.aspect.annotation.Rlock; |
|||
import com.base.springcloud.handle.RBSQueueHandler; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.annotation.Pointcut; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.redisson.api.RLock; |
|||
import org.redisson.api.RedissonClient; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.DefaultParameterNameDiscoverer; |
|||
import org.springframework.expression.EvaluationContext; |
|||
import org.springframework.expression.Expression; |
|||
import org.springframework.expression.spel.standard.SpelExpressionParser; |
|||
import org.springframework.expression.spel.support.StandardEvaluationContext; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.lang.reflect.Method; |
|||
|
|||
@Aspect |
|||
@Component |
|||
@Slf4j |
|||
public class RlockAspect { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(RBSQueueHandler.class); |
|||
|
|||
@Autowired |
|||
private RedissonClient redissonClient; |
|||
|
|||
/** |
|||
* 用于SpEL表达式解析. |
|||
*/ |
|||
private SpelExpressionParser parser = new SpelExpressionParser(); |
|||
/** |
|||
* 用于获取方法参数定义名字. |
|||
*/ |
|||
private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer(); |
|||
|
|||
|
|||
|
|||
@Pointcut("@annotation(com.base.springcloud.aspect.annotation.Rlock)") |
|||
public void RlockAspect() { |
|||
} |
|||
|
|||
@Around("RlockAspect()") |
|||
public Object arround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { |
|||
Object object = null; |
|||
RLock lock = null; |
|||
try { |
|||
// 获取注解信息
|
|||
Rlock rlockInfo = getRlockInfo(proceedingJoinPoint); |
|||
String key = getLocalKey(proceedingJoinPoint, rlockInfo); |
|||
// 根据名字获取锁实例
|
|||
lock = redissonClient.getLock(key); |
|||
if (lock != null) { |
|||
final boolean status = lock.tryLock(rlockInfo.waitTime(), rlockInfo.leaseTime(), rlockInfo.timeUnit()); |
|||
if (status) { |
|||
logger.info("锁获取成功,加锁成功 : {}........",key); |
|||
object = proceedingJoinPoint.proceed(); |
|||
} else { |
|||
logger.info("锁被占用,加锁失败 : {} .........",key); |
|||
throw new RuntimeException("加锁失败"); |
|||
} |
|||
} |
|||
} finally { |
|||
// 方法执行完成释放锁
|
|||
if (lock != null && lock.isHeldByCurrentThread()) { |
|||
lock.unlock(); |
|||
} |
|||
} |
|||
return object; |
|||
} |
|||
|
|||
public Rlock getRlockInfo(ProceedingJoinPoint proceedingJoinPoint) { |
|||
MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature(); |
|||
return methodSignature.getMethod().getAnnotation(Rlock.class); |
|||
} |
|||
|
|||
/** |
|||
* @param proceedingJoinPoint |
|||
* @return |
|||
*/ |
|||
public String getLocalKey(ProceedingJoinPoint proceedingJoinPoint, Rlock rlockInfo) { |
|||
StringBuilder localKey = new StringBuilder(); |
|||
//获取注解参数值
|
|||
String prefix = rlockInfo.prefix(); |
|||
String spELString = rlockInfo.suffix(); |
|||
String key = generateKeyBySpEL(spELString,proceedingJoinPoint); |
|||
localKey.append(prefix).append(key); |
|||
logger.info("加锁 key :{}",localKey.toString()); |
|||
return localKey.toString(); |
|||
} |
|||
|
|||
public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) { |
|||
// 通过joinPoint获取被注解方法
|
|||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = methodSignature.getMethod(); |
|||
// 使用spring的DefaultParameterNameDiscoverer获取方法形参名数组
|
|||
String[] paramNames = nameDiscoverer.getParameterNames(method); |
|||
// 解析过后的Spring表达式对象
|
|||
Expression expression = parser.parseExpression(spELString); |
|||
// spring的表达式上下文对象
|
|||
EvaluationContext context = new StandardEvaluationContext(); |
|||
// 通过joinPoint获取被注解方法的形参
|
|||
Object[] args = joinPoint.getArgs(); |
|||
// 给上下文赋值
|
|||
for(int i = 0 ; i < args.length ; i++) { |
|||
context.setVariable(paramNames[i], args[i]); |
|||
} |
|||
// 表达式从上下文中计算出实际参数值
|
|||
return expression.getValue(context).toString(); |
|||
} |
|||
} |
|||
@ -0,0 +1,172 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.aspect.config; |
|||
|
|||
import com.base.springcloud.util.MinioUtil; |
|||
import com.base.springcloud.util.oConvertUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component("jimuMinioConfig") |
|||
@ConfigurationProperties( |
|||
prefix = "jeecg.minio" |
|||
) |
|||
@ConditionalOnProperty( |
|||
value = {"jeecg.uploadType"}, |
|||
havingValue = "minio", |
|||
matchIfMissing = true |
|||
) |
|||
public class JimuMinioConfig { |
|||
private static final Logger log = LoggerFactory.getLogger(JimuMinioConfig.class); |
|||
private String minioUrl; |
|||
private String minioName; |
|||
private String minioPass; |
|||
private String bucketName; |
|||
|
|||
@Bean |
|||
public JimuMinioConfig initJimuMinio() { |
|||
if (oConvertUtils.isNotEmpty(this.minioUrl)) { |
|||
if (!this.minioUrl.startsWith("http")) { |
|||
this.minioUrl = "http://" + this.minioUrl; |
|||
} |
|||
|
|||
if (!this.minioUrl.endsWith("/")) { |
|||
this.minioUrl = this.minioUrl.concat("/"); |
|||
} |
|||
} |
|||
|
|||
try { |
|||
MinioUtil.setMinioUrl(this.minioUrl); |
|||
MinioUtil.setMinioName(this.minioName); |
|||
MinioUtil.setMinioPass(this.minioPass); |
|||
MinioUtil.setBucketName(this.bucketName); |
|||
} catch (NoClassDefFoundError var2) { |
|||
log.error("[JimuReport] 加载上传配置失败,Minio版本不匹配,请升级Minio依赖到8.0.3+", var2); |
|||
} |
|||
|
|||
return new JimuMinioConfig(); |
|||
} |
|||
|
|||
public JimuMinioConfig() { |
|||
} |
|||
|
|||
public String getMinioUrl() { |
|||
return this.minioUrl; |
|||
} |
|||
|
|||
public String getMinioName() { |
|||
return this.minioName; |
|||
} |
|||
|
|||
public String getMinioPass() { |
|||
return this.minioPass; |
|||
} |
|||
|
|||
public String getBucketName() { |
|||
return this.bucketName; |
|||
} |
|||
|
|||
public void setMinioUrl(String minioUrl) { |
|||
this.minioUrl = minioUrl; |
|||
} |
|||
|
|||
public void setMinioName(String minioName) { |
|||
this.minioName = minioName; |
|||
} |
|||
|
|||
public void setMinioPass(String minioPass) { |
|||
this.minioPass = minioPass; |
|||
} |
|||
|
|||
public void setBucketName(String bucketName) { |
|||
this.bucketName = bucketName; |
|||
} |
|||
|
|||
public boolean equals(Object o) { |
|||
if (o == this) { |
|||
return true; |
|||
} else if (!(o instanceof JimuMinioConfig)) { |
|||
return false; |
|||
} else { |
|||
JimuMinioConfig var2 = (JimuMinioConfig)o; |
|||
if (!var2.canEqual(this)) { |
|||
return false; |
|||
} else { |
|||
label59: { |
|||
String var3 = this.getMinioUrl(); |
|||
String var4 = var2.getMinioUrl(); |
|||
if (var3 == null) { |
|||
if (var4 == null) { |
|||
break label59; |
|||
} |
|||
} else if (var3.equals(var4)) { |
|||
break label59; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
String var5 = this.getMinioName(); |
|||
String var6 = var2.getMinioName(); |
|||
if (var5 == null) { |
|||
if (var6 != null) { |
|||
return false; |
|||
} |
|||
} else if (!var5.equals(var6)) { |
|||
return false; |
|||
} |
|||
|
|||
String var7 = this.getMinioPass(); |
|||
String var8 = var2.getMinioPass(); |
|||
if (var7 == null) { |
|||
if (var8 != null) { |
|||
return false; |
|||
} |
|||
} else if (!var7.equals(var8)) { |
|||
return false; |
|||
} |
|||
|
|||
String var9 = this.getBucketName(); |
|||
String var10 = var2.getBucketName(); |
|||
if (var9 == null) { |
|||
if (var10 != null) { |
|||
return false; |
|||
} |
|||
} else if (!var9.equals(var10)) { |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected boolean canEqual(Object other) { |
|||
return other instanceof JimuMinioConfig; |
|||
} |
|||
|
|||
public int hashCode() { |
|||
boolean var1 = true; |
|||
byte var2 = 1; |
|||
String var3 = this.getMinioUrl(); |
|||
int var7 = var2 * 59 + (var3 == null ? 43 : var3.hashCode()); |
|||
String var4 = this.getMinioName(); |
|||
var7 = var7 * 59 + (var4 == null ? 43 : var4.hashCode()); |
|||
String var5 = this.getMinioPass(); |
|||
var7 = var7 * 59 + (var5 == null ? 43 : var5.hashCode()); |
|||
String var6 = this.getBucketName(); |
|||
var7 = var7 * 59 + (var6 == null ? 43 : var6.hashCode()); |
|||
return var7; |
|||
} |
|||
|
|||
public String toString() { |
|||
return "JimuMinioConfig(minioUrl=" + this.getMinioUrl() + ", minioName=" + this.getMinioName() + ", minioPass=" + this.getMinioPass() + ", bucketName=" + this.getBucketName() + ")"; |
|||
} |
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.aspect.config; |
|||
|
|||
import com.base.springcloud.util.OssBootUtil; |
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component("jimuOssConfiguration") |
|||
@ConfigurationProperties( |
|||
prefix = "jeecg.oss" |
|||
) |
|||
@ConditionalOnProperty( |
|||
value = {"jeecg.uploadType"}, |
|||
havingValue = "alioss", |
|||
matchIfMissing = true |
|||
) |
|||
public class JimuOssConfiguration { |
|||
private String endpoint; |
|||
private String accessKey; |
|||
private String secretKey; |
|||
private String bucketName; |
|||
private String staticDomain; |
|||
|
|||
@Bean |
|||
public OssBootUtil initJimuOssBootConfiguration() { |
|||
OssBootUtil.setEndPoint(this.endpoint); |
|||
OssBootUtil.setAccessKeyId(this.accessKey); |
|||
OssBootUtil.setAccessKeySecret(this.secretKey); |
|||
OssBootUtil.setBucketName(this.bucketName); |
|||
OssBootUtil.setStaticDomain(this.staticDomain); |
|||
return new OssBootUtil(); |
|||
} |
|||
|
|||
public JimuOssConfiguration() { |
|||
} |
|||
|
|||
public String getEndpoint() { |
|||
return this.endpoint; |
|||
} |
|||
|
|||
public String getAccessKey() { |
|||
return this.accessKey; |
|||
} |
|||
|
|||
public String getSecretKey() { |
|||
return this.secretKey; |
|||
} |
|||
|
|||
public String getBucketName() { |
|||
return this.bucketName; |
|||
} |
|||
|
|||
public String getStaticDomain() { |
|||
return this.staticDomain; |
|||
} |
|||
|
|||
public void setEndpoint(String endpoint) { |
|||
this.endpoint = endpoint; |
|||
} |
|||
|
|||
public void setAccessKey(String accessKey) { |
|||
this.accessKey = accessKey; |
|||
} |
|||
|
|||
public void setSecretKey(String secretKey) { |
|||
this.secretKey = secretKey; |
|||
} |
|||
|
|||
public void setBucketName(String bucketName) { |
|||
this.bucketName = bucketName; |
|||
} |
|||
|
|||
public void setStaticDomain(String staticDomain) { |
|||
this.staticDomain = staticDomain; |
|||
} |
|||
|
|||
public boolean equals(Object o) { |
|||
if (o == this) { |
|||
return true; |
|||
} else if (!(o instanceof JimuOssConfiguration)) { |
|||
return false; |
|||
} else { |
|||
JimuOssConfiguration var2 = (JimuOssConfiguration)o; |
|||
if (!var2.canEqual(this)) { |
|||
return false; |
|||
} else { |
|||
label71: { |
|||
String var3 = this.getEndpoint(); |
|||
String var4 = var2.getEndpoint(); |
|||
if (var3 == null) { |
|||
if (var4 == null) { |
|||
break label71; |
|||
} |
|||
} else if (var3.equals(var4)) { |
|||
break label71; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
String var5 = this.getAccessKey(); |
|||
String var6 = var2.getAccessKey(); |
|||
if (var5 == null) { |
|||
if (var6 != null) { |
|||
return false; |
|||
} |
|||
} else if (!var5.equals(var6)) { |
|||
return false; |
|||
} |
|||
|
|||
label57: { |
|||
String var7 = this.getSecretKey(); |
|||
String var8 = var2.getSecretKey(); |
|||
if (var7 == null) { |
|||
if (var8 == null) { |
|||
break label57; |
|||
} |
|||
} else if (var7.equals(var8)) { |
|||
break label57; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
String var9 = this.getBucketName(); |
|||
String var10 = var2.getBucketName(); |
|||
if (var9 == null) { |
|||
if (var10 != null) { |
|||
return false; |
|||
} |
|||
} else if (!var9.equals(var10)) { |
|||
return false; |
|||
} |
|||
|
|||
String var11 = this.getStaticDomain(); |
|||
String var12 = var2.getStaticDomain(); |
|||
if (var11 == null) { |
|||
if (var12 == null) { |
|||
return true; |
|||
} |
|||
} else if (var11.equals(var12)) { |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected boolean canEqual(Object other) { |
|||
return other instanceof JimuOssConfiguration; |
|||
} |
|||
|
|||
public int hashCode() { |
|||
boolean var1 = true; |
|||
byte var2 = 1; |
|||
String var3 = this.getEndpoint(); |
|||
int var8 = var2 * 59 + (var3 == null ? 43 : var3.hashCode()); |
|||
String var4 = this.getAccessKey(); |
|||
var8 = var8 * 59 + (var4 == null ? 43 : var4.hashCode()); |
|||
String var5 = this.getSecretKey(); |
|||
var8 = var8 * 59 + (var5 == null ? 43 : var5.hashCode()); |
|||
String var6 = this.getBucketName(); |
|||
var8 = var8 * 59 + (var6 == null ? 43 : var6.hashCode()); |
|||
String var7 = this.getStaticDomain(); |
|||
var8 = var8 * 59 + (var7 == null ? 43 : var7.hashCode()); |
|||
return var8; |
|||
} |
|||
|
|||
public String toString() { |
|||
return "JimuOssConfiguration(endpoint=" + this.getEndpoint() + ", accessKey=" + this.getAccessKey() + ", secretKey=" + this.getSecretKey() + ", bucketName=" + this.getBucketName() + ", staticDomain=" + this.getStaticDomain() + ")"; |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.base.springcloud.aspect.config; |
|||
|
|||
import com.base.springcloud.aspect.interceptor.PayInterceptor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
@Component |
|||
public class PayConfigurer implements WebMvcConfigurer { |
|||
|
|||
@Autowired |
|||
private PayInterceptor payInterceptor; |
|||
|
|||
// 拦截器请求 :'/merchant/**','/payment/**'
|
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry){ |
|||
registry.addInterceptor(payInterceptor).addPathPatterns("/merchant/**","/payment/**"); |
|||
} |
|||
|
|||
// 跨域配置
|
|||
@Override |
|||
public void addCorsMappings(CorsRegistry registry) { |
|||
registry.addMapping("/**").allowCredentials(true).allowedOrigins("*").allowedMethods("GET", "PUT", "DELETE", "POST", "OPTIONS").maxAge(3600); |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package com.base.springcloud.aspect.config; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; |
|||
import com.fasterxml.jackson.annotation.PropertyAccessor; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; |
|||
import org.springframework.cache.annotation.CachingConfigurerSupport; |
|||
import org.springframework.cache.annotation.EnableCaching; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
|||
import org.springframework.data.redis.serializer.RedisSerializer; |
|||
import org.springframework.data.redis.serializer.StringRedisSerializer; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
@Configuration |
|||
@EnableCaching // 开启缓存支持
|
|||
public class RedisConfig extends CachingConfigurerSupport { |
|||
|
|||
@Resource |
|||
private LettuceConnectionFactory lettuceConnectionFactory; |
|||
|
|||
/** |
|||
* RedisTemplate配置 |
|||
* |
|||
* @param lettuceConnectionFactory |
|||
* @return |
|||
*/ |
|||
@Bean |
|||
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { |
|||
// 设置序列化
|
|||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class); |
|||
ObjectMapper om = new ObjectMapper(); |
|||
om.setVisibility(PropertyAccessor.ALL, Visibility.ANY); |
|||
om.enableDefaultTyping(DefaultTyping.NON_FINAL); |
|||
jackson2JsonRedisSerializer.setObjectMapper(om); |
|||
// 配置redisTemplate
|
|||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); |
|||
redisTemplate.setConnectionFactory(lettuceConnectionFactory); |
|||
RedisSerializer<?> stringSerializer = new StringRedisSerializer(); |
|||
redisTemplate.setKeySerializer(stringSerializer);// key序列化
|
|||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);// value序列化
|
|||
redisTemplate.setHashKeySerializer(stringSerializer);// Hash key序列化
|
|||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);// Hash value序列化
|
|||
redisTemplate.afterPropertiesSet(); |
|||
return redisTemplate; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.base.springcloud.aspect.interceptor; |
|||
|
|||
import com.base.springcloud.aspect.annotation.LoginRequired; |
|||
import com.base.springcloud.entity.User; |
|||
import com.base.springcloud.util.TokenUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.lang.Nullable; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.method.HandlerMethod; |
|||
import org.springframework.web.servlet.HandlerInterceptor; |
|||
import org.springframework.web.servlet.ModelAndView; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
@Component |
|||
public class PayInterceptor implements HandlerInterceptor { |
|||
|
|||
@Autowired |
|||
private TokenUtils tokenUtils; |
|||
|
|||
// 在业务处理器处理请求之前被调用
|
|||
@Override |
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|||
LoginRequired loginRequired; |
|||
// 根据注解拦截请求
|
|||
if (handler instanceof HandlerMethod) |
|||
loginRequired = ((HandlerMethod)handler).getMethodAnnotation(LoginRequired.class); |
|||
else |
|||
return true; |
|||
// 说明此方法没有LoginRequired注解
|
|||
if (loginRequired == null) |
|||
return true; |
|||
// token数据验证
|
|||
User user = tokenUtils.verifyToken(request); |
|||
// 用户信息
|
|||
if(loginRequired.user()) |
|||
tokenUtils.userInfo(request,user.getId()); |
|||
// 部门信息获取
|
|||
if(loginRequired.department()) |
|||
tokenUtils.departmentInfo(request,user.getId()); |
|||
// 公司信息获取
|
|||
if(loginRequired.company()) |
|||
tokenUtils.companyInfo(request,user.getCtCompanyId()); |
|||
return true; |
|||
} |
|||
|
|||
// 在业务处理器处理请求执行完成后
|
|||
@Override |
|||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView){ |
|||
|
|||
}; |
|||
|
|||
// 在DispatcherServlet完全处理完请求后被调用
|
|||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex){ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.base.springcloud.base; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class MchConfigEntity { |
|||
|
|||
// 商户编号
|
|||
private String mchId; |
|||
|
|||
// 商户私钥
|
|||
private String mchPrivateKey; |
|||
|
|||
// 微信平台证书
|
|||
private String certificate; |
|||
|
|||
// 证书序列号
|
|||
private String serialNo; |
|||
|
|||
// 公众号Id
|
|||
private String appId; |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.base.springcloud.bo; |
|||
|
|||
import com.base.springcloud.base.MchConfigEntity; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class CodePayBO extends MchConfigEntity implements Serializable { |
|||
|
|||
// 商品描述
|
|||
private String body; |
|||
|
|||
// 附加数据
|
|||
private String attach; |
|||
|
|||
// 订单号
|
|||
private String orderNo; |
|||
|
|||
// 订单金额
|
|||
private BigDecimal amount; |
|||
|
|||
// 微信付款码
|
|||
private String authCode; |
|||
|
|||
// 设备号
|
|||
private String deviceInfo; |
|||
|
|||
// 终端IP
|
|||
private String spbillCreateIp; |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.base.springcloud.bo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class DepartBO { |
|||
|
|||
// 创建人Id
|
|||
private String createId; |
|||
|
|||
// 商户支付配置Id
|
|||
private String merchantConfigureId; |
|||
|
|||
// 部门id集合
|
|||
private List<String> departIdList; |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package com.base.springcloud.bo; |
|||
|
|||
import com.base.springcloud.base.MchConfigEntity; |
|||
import com.base.springcloud.entity.Order; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class RefundBO extends MchConfigEntity implements Serializable { |
|||
|
|||
// 退款订单Id
|
|||
private String refundId; |
|||
|
|||
// 创建人
|
|||
private String createId; |
|||
|
|||
// 退款单据编号
|
|||
private String billId; |
|||
|
|||
// 原订单编号
|
|||
private String origOrderNo; |
|||
|
|||
// 原订单创建时间
|
|||
private Date origCreateTime; |
|||
|
|||
// 退款订单号
|
|||
private String refundNo; |
|||
|
|||
// 退款原因
|
|||
private String reason; |
|||
|
|||
// 退款金额
|
|||
private BigDecimal refundAmount; |
|||
|
|||
// 退款通知地址
|
|||
private String notifyUrl; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package com.base.springcloud.bo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class SaleBillBO { |
|||
|
|||
private String id; |
|||
|
|||
private BigDecimal payAmount; |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
package com.base.springcloud.client; |
|||
|
|||
import com.base.springcloud.base.CommonResult; |
|||
import com.base.springcloud.dto.MerchantConfigReqDTO; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
@FeignClient(value = "payment-service-client") |
|||
public interface PaymentClient { |
|||
|
|||
@PostMapping(value = "/merchant/merchantConfig") |
|||
CommonResult paymentConfigure(@RequestBody MerchantConfigReqDTO merchantConfigDTO); |
|||
} |
|||
@ -1,58 +0,0 @@ |
|||
package com.base.springcloud.constant; |
|||
|
|||
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|||
import com.fasterxml.jackson.annotation.PropertyAccessor; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.redisson.Redisson; |
|||
import org.redisson.config.Config; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.cache.annotation.CachingConfigurerSupport; |
|||
import org.springframework.cache.annotation.EnableCaching; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.serializer.StringRedisSerializer; |
|||
|
|||
@Configuration |
|||
@EnableCaching |
|||
public class RedisConfig extends CachingConfigurerSupport { |
|||
|
|||
@Value("${spring.redis.host}") |
|||
private String host; |
|||
|
|||
@Value("${spring.redis.port}") |
|||
private String port; |
|||
|
|||
@Value("${spring.redis.password}") |
|||
private String password; |
|||
|
|||
@Bean |
|||
@SuppressWarnings(value = {"unchecked", "rawtypes"}) |
|||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { |
|||
RedisTemplate<Object, Object> template = new RedisTemplate<>(); |
|||
template.setConnectionFactory(redisConnectionFactory); |
|||
|
|||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
|||
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
|||
serializer.setObjectMapper(mapper); |
|||
|
|||
template.setValueSerializer(serializer); |
|||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
|||
template.setKeySerializer(new StringRedisSerializer()); |
|||
template.afterPropertiesSet(); |
|||
return template; |
|||
} |
|||
|
|||
@Bean |
|||
public Redisson redisson() { |
|||
Config config = new Config(); |
|||
config.useSingleServer().setAddress("redis://" + host + ":" + port); |
|||
config.useSingleServer().setPassword(password); |
|||
return (Redisson) Redisson.create(config); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.Depart; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
public interface DepartMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(Depart record); |
|||
|
|||
int insertSelective(Depart record); |
|||
|
|||
Depart selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(Depart record); |
|||
|
|||
int updateByPrimaryKey(Depart record); |
|||
|
|||
List<String> getUserDepart(@Param("userId")String useId); |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.OrderBill; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
public interface OrderBillMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(OrderBill record); |
|||
|
|||
int insertSelective(OrderBill record); |
|||
|
|||
OrderBill selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(OrderBill record); |
|||
|
|||
int updateByPrimaryKey(OrderBill record); |
|||
|
|||
List<String> getBillId(@Param("orderId") String orderId); |
|||
|
|||
String getOrderId(@Param("billId") String billId); |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.PayDepartConfig; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface PayDepartConfigMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(PayDepartConfig record); |
|||
|
|||
int insertSelective(PayDepartConfig record); |
|||
|
|||
PayDepartConfig selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(PayDepartConfig record); |
|||
|
|||
int updateByPrimaryKey(PayDepartConfig record); |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.bo.RefundBO; |
|||
import com.base.springcloud.entity.Refund; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
public interface RefundMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(Refund record); |
|||
|
|||
int insertSelective(Refund record); |
|||
|
|||
Refund selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(Refund record); |
|||
|
|||
int updateByPrimaryKey(Refund record); |
|||
|
|||
int updateRefundSuccess(Refund refund); |
|||
|
|||
List<Refund> queryRefundData(Date date); |
|||
|
|||
int superRefundCount(@Param("id") String refundId); |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.User; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface UserMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(User record); |
|||
|
|||
int insertSelective(User record); |
|||
|
|||
User selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(User record); |
|||
|
|||
int updateByPrimaryKey(User record); |
|||
|
|||
User getUser(@Param("userName") String userName); |
|||
} |
|||
@ -1,38 +1,7 @@ |
|||
package com.base.springcloud.dto; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Data |
|||
public class NoticeReqDTO { |
|||
|
|||
/** |
|||
* 微信支付证书文件 |
|||
*/ |
|||
private MultipartFile certFile; |
|||
|
|||
/** |
|||
* 公众号 |
|||
*/ |
|||
private String appId; |
|||
|
|||
/** |
|||
* 商户私钥 |
|||
*/ |
|||
private String apiKey; |
|||
|
|||
/** |
|||
* 证书序列号 |
|||
*/ |
|||
private String serialNo; |
|||
|
|||
/** |
|||
* 商户号 |
|||
*/ |
|||
private String mchId; |
|||
|
|||
/** |
|||
* 商户私钥 |
|||
*/ |
|||
private String mchPrivateKey; |
|||
} |
|||
|
|||
@ -0,0 +1,8 @@ |
|||
package com.base.springcloud.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class RefundNoticeReqDTO { |
|||
|
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package com.base.springcloud.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.File; |
|||
|
|||
@Data |
|||
public class RefundNoticeRspDTO { |
|||
|
|||
/** |
|||
* 微信支付证书文件 |
|||
*/ |
|||
private File certFile; |
|||
|
|||
/** |
|||
* 公众号 |
|||
*/ |
|||
private String appId; |
|||
|
|||
/** |
|||
* 商户私钥 |
|||
*/ |
|||
private String apiKey; |
|||
|
|||
/** |
|||
* 证书序列号 |
|||
*/ |
|||
private String serialNo; |
|||
|
|||
/** |
|||
* 商户号 |
|||
*/ |
|||
private String mchId; |
|||
|
|||
/** |
|||
* 商户私钥 |
|||
*/ |
|||
private String mchPrivateKey; |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class Depart { |
|||
private String id; |
|||
|
|||
private String parentId; |
|||
|
|||
private String departName; |
|||
|
|||
private String departNameEn; |
|||
|
|||
private String departNameAbbr; |
|||
|
|||
private Integer departOrder; |
|||
|
|||
private String description; |
|||
|
|||
private String orgCategory; |
|||
|
|||
private String orgType; |
|||
|
|||
private String orgCode; |
|||
|
|||
private String mobile; |
|||
|
|||
private String fax; |
|||
|
|||
private String address; |
|||
|
|||
private String memo; |
|||
|
|||
private String status; |
|||
|
|||
private String delFlag; |
|||
|
|||
private String createBy; |
|||
|
|||
private Date createTime; |
|||
|
|||
private String updateBy; |
|||
|
|||
private Date updateTime; |
|||
|
|||
private String ctCompanyId; |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class OrderBill { |
|||
|
|||
private String id; |
|||
|
|||
private String orderId; |
|||
|
|||
private String billId; |
|||
|
|||
private String soureBillId; |
|||
|
|||
private String createId; |
|||
|
|||
private Date createTime; |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import java.util.Date; |
|||
|
|||
public class PayDepartConfig { |
|||
private String id; |
|||
|
|||
private String mechantConfigId; |
|||
|
|||
private String departId; |
|||
|
|||
private String createId; |
|||
|
|||
private Date createTime; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getMechantConfigId() { |
|||
return mechantConfigId; |
|||
} |
|||
|
|||
public void setMechantConfigId(String mechantConfigId) { |
|||
this.mechantConfigId = mechantConfigId; |
|||
} |
|||
|
|||
public String getDepartId() { |
|||
return departId; |
|||
} |
|||
|
|||
public void setDepartId(String departId) { |
|||
this.departId = departId; |
|||
} |
|||
|
|||
public String getCreateId() { |
|||
return createId; |
|||
} |
|||
|
|||
public void setCreateId(String createId) { |
|||
this.createId = createId; |
|||
} |
|||
|
|||
public Date getCreateTime() { |
|||
return createTime; |
|||
} |
|||
|
|||
public void setCreateTime(Date createTime) { |
|||
this.createTime = createTime; |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class Refund { |
|||
private String id; |
|||
|
|||
private String mchId; |
|||
|
|||
private String refundOrderNo; |
|||
|
|||
private Date refundTime; |
|||
|
|||
private String createId; |
|||
|
|||
private Date createTime; |
|||
|
|||
private String origOrderNo; |
|||
|
|||
private Date origOrderTime; |
|||
|
|||
private String sourceBillId; |
|||
|
|||
private String reason; |
|||
|
|||
// 0 - 退款未完成 1 - 退款完成 2 - 退款部分完成
|
|||
private Integer refundState; |
|||
|
|||
private Integer refundRetryCount; |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class User implements Serializable { |
|||
private String id; |
|||
|
|||
private String userName; |
|||
|
|||
private String realName; |
|||
|
|||
private String password; |
|||
|
|||
private String salt; |
|||
|
|||
private String avatar; |
|||
|
|||
private Date birthday; |
|||
|
|||
private Integer sex; |
|||
|
|||
private String email; |
|||
|
|||
private String phone; |
|||
|
|||
private String orgCode; |
|||
|
|||
private Integer status; |
|||
|
|||
private Integer delFlag; |
|||
|
|||
private String thirdId; |
|||
|
|||
private String thirdType; |
|||
|
|||
private Integer activitiSync; |
|||
|
|||
private String workNo; |
|||
|
|||
private String post; |
|||
|
|||
private String telephone; |
|||
|
|||
private String createBy; |
|||
|
|||
private Date createTime; |
|||
|
|||
private String updateBy; |
|||
|
|||
private Date updateTime; |
|||
|
|||
private Integer userIdentity; |
|||
|
|||
private String departIds; |
|||
|
|||
private String ctCompanyId; |
|||
|
|||
private Integer accountType; |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.bo.DepartBO; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface DepartService { |
|||
|
|||
/** |
|||
* 获取用户部门 |
|||
* @param userId |
|||
* @return |
|||
*/ |
|||
List<String> getUserDepart(String userId); |
|||
|
|||
/** |
|||
* 保存商户部门信息 |
|||
* @param departBO |
|||
*/ |
|||
void savePayDepart(DepartBO departBO); |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.bo.OrderBO; |
|||
import com.base.springcloud.bo.SaleBillBO; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface OrderBillService { |
|||
|
|||
|
|||
/** |
|||
* 登记销售单据和订单关联 |
|||
* @param orderBO |
|||
*/ |
|||
void registerOrderBill(OrderBO orderBO); |
|||
|
|||
|
|||
/** |
|||
* 获取销售单据号 |
|||
* @param orderId |
|||
*/ |
|||
List<String> getBillId(String orderId); |
|||
|
|||
/** |
|||
* 查询销售单据对应订单 |
|||
* @param billId |
|||
* @return |
|||
*/ |
|||
String queryOrderNo(String billId); |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.bo.RefundBO; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
public interface RefundService { |
|||
|
|||
/** |
|||
* 退款 |
|||
* @param refundBO |
|||
*/ |
|||
void refund(RefundBO refundBO); |
|||
|
|||
/** |
|||
* 退款列表查询 |
|||
* @param date |
|||
* @return |
|||
*/ |
|||
List<RefundBO> queryRefund(Date date); |
|||
|
|||
/** |
|||
* 查询退款订单 |
|||
* @param o |
|||
*/ |
|||
void queryRefundOrder(RefundBO o); |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.entity.User; |
|||
|
|||
public interface UserService { |
|||
|
|||
/** |
|||
* 获取用户信息 |
|||
* |
|||
* @param userName |
|||
*/ |
|||
User getUser(String userName); |
|||
|
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.bo.DepartBO; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.dao.DepartMapper; |
|||
import com.base.springcloud.dao.PayDepartConfigMapper; |
|||
import com.base.springcloud.entity.PayDepartConfig; |
|||
import com.base.springcloud.service.DepartService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.util.UUID; |
|||
|
|||
@Service |
|||
public class DepartServiceImp implements DepartService { |
|||
|
|||
@Autowired |
|||
private DepartMapper departMapper; |
|||
|
|||
@Autowired |
|||
private PayDepartConfigMapper payDepartConfigMapper; |
|||
|
|||
/** |
|||
* 获取用户部门 |
|||
* @param userId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<String> getUserDepart(String userId) { |
|||
return departMapper.getUserDepart(userId); |
|||
} |
|||
|
|||
/** |
|||
* 保存商户部门信息 |
|||
* @param departBO |
|||
*/ |
|||
@Override |
|||
public void savePayDepart(DepartBO departBO) { |
|||
List<String> departIdList = departBO.getDepartIdList(); |
|||
if(!Optional.ofNullable(departIdList).isPresent()) |
|||
throw new BusinessException(ErrorConstant.USER_DEPART_RELATION_NEED); |
|||
for (String depart : departIdList){ |
|||
PayDepartConfig payDepartConfig = new PayDepartConfig(); |
|||
payDepartConfig.setId(UUID.randomUUID().toString().replace("-", "")); |
|||
payDepartConfig.setCreateId(departBO.getCreateId()); |
|||
payDepartConfig.setCreateTime(new Date()); |
|||
payDepartConfig.setDepartId(depart); |
|||
payDepartConfig.setMechantConfigId(departBO.getMerchantConfigureId()); |
|||
int count = payDepartConfigMapper.insert(payDepartConfig); |
|||
if(count < 1) |
|||
throw new BusinessException(ErrorConstant.SAVE_PAY_DEPART_CONFIG_FAIL); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.bo.OrderBO; |
|||
import com.base.springcloud.bo.SaleBillBO; |
|||
import com.base.springcloud.dao.OrderBillMapper; |
|||
import com.base.springcloud.entity.Order; |
|||
import com.base.springcloud.entity.OrderBill; |
|||
import com.base.springcloud.entity.SaleBill; |
|||
import com.base.springcloud.service.OrderBillService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
@Service |
|||
public class OrderBillServiceImp implements OrderBillService { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(OrderBillServiceImp.class); |
|||
|
|||
@Autowired |
|||
private OrderBillMapper orderBillMapper; |
|||
|
|||
/** |
|||
* 登记销售单据和订单关联 |
|||
* |
|||
* @param orderBO |
|||
*/ |
|||
@Override |
|||
public void registerOrderBill(OrderBO orderBO) { |
|||
Order order = orderBO.getOrder(); |
|||
List<SaleBill> saleBillList = orderBO.getSaleBillList(); |
|||
saleBillList.forEach(item -> { |
|||
OrderBill orderBill = new OrderBill(); |
|||
orderBill.setId(UUID.randomUUID().toString().replace("-", "")); |
|||
orderBill.setCreateTime(new Date()); |
|||
orderBill.setSoureBillId(item.getSourceId()); |
|||
orderBill.setBillId(item.getId()); |
|||
orderBill.setOrderId(order.getId()); |
|||
orderBillMapper.insert(orderBill); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 获取销售单据Id |
|||
* @param orderId |
|||
*/ |
|||
@Override |
|||
public List<String> getBillId(String orderId) { |
|||
return orderBillMapper.getBillId(orderId); |
|||
} |
|||
|
|||
/** |
|||
* 查询原支付订单 |
|||
* @param billId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public String queryOrderNo(String billId) { |
|||
return orderBillMapper.getOrderId(billId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,181 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.bo.MerchantConfigBO; |
|||
import com.base.springcloud.bo.RefundBO; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.dao.RefundMapper; |
|||
import com.base.springcloud.entity.Refund; |
|||
import com.base.springcloud.service.*; |
|||
import com.base.springcloud.util.DateUtil; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.util.UUID; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class RefundServiceImp implements RefundService { |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(RefundServiceImp.class); |
|||
|
|||
@Autowired |
|||
private OrderService orderService; |
|||
|
|||
@Autowired |
|||
private WecPaymentService wecPaymentService; |
|||
|
|||
@Autowired |
|||
private RefundMapper refundMapper; |
|||
|
|||
@Autowired |
|||
private BillService billService; |
|||
|
|||
@Autowired |
|||
private MerchantService merchantService; |
|||
|
|||
/** |
|||
* 退款 |
|||
* @param refundBO |
|||
*/ |
|||
@Override |
|||
public void refund(RefundBO refundBO) { |
|||
// RBS-退款金额获取 FIXME 金额暂定支付金额
|
|||
billService.refundFront(refundBO); |
|||
// TODO 退款限制检查
|
|||
// 查询原支付订单
|
|||
orderService.origOrderCheck(refundBO); |
|||
// 商户支付信息配置
|
|||
claimMerchantConfig(refundBO); |
|||
// 登记退款信息
|
|||
registerRfund(refundBO); |
|||
// 发送微信退款
|
|||
Boolean refundResult = wecPaymentService.wecRefund(refundBO); |
|||
// 同步退款信息
|
|||
if(refundResult) |
|||
updateRefundSuccess(refundBO); |
|||
// TODO RBS-业务逻辑处理
|
|||
} |
|||
|
|||
/** |
|||
* 商户支付信息查询 |
|||
* @param refundBO |
|||
*/ |
|||
private void claimMerchantConfig(RefundBO refundBO) { |
|||
MerchantConfigBO merchantConfigBO = merchantService.claimMerchantConfig(refundBO.getMchId()); |
|||
refundBO.setAppId(merchantConfigBO.getAppId()); |
|||
refundBO.setMchPrivateKey(merchantConfigBO.getMchPrivateKey()); |
|||
refundBO.setSerialNo(merchantConfigBO.getSerialNo()); |
|||
refundBO.setCertificate(merchantConfigBO.getCertificate()); |
|||
} |
|||
|
|||
/** |
|||
* 退款列表查询 |
|||
* @param date |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<RefundBO> queryRefund(Date date) { |
|||
List<Refund> refundList = refundMapper.queryRefundData(date); |
|||
if(!Optional.ofNullable(refundList).isPresent()) |
|||
return null; |
|||
return refundList.stream().map(o -> { |
|||
RefundBO refundBO = new RefundBO(); |
|||
refundBO.setMchId(o.getMchId()); |
|||
refundBO.setOrigOrderNo(o.getOrigOrderNo()); |
|||
refundBO.setOrigCreateTime(o.getOrigOrderTime()); |
|||
refundBO.setRefundNo(o.getRefundOrderNo()); |
|||
return refundBO; |
|||
}).collect(Collectors.toList()); |
|||
} |
|||
|
|||
/** |
|||
* 退款订单状态查询 |
|||
* @param refundBO |
|||
*/ |
|||
@Override |
|||
public void queryRefundOrder(RefundBO refundBO) { |
|||
try{ |
|||
// 参数检查
|
|||
String refundOrderNo = Optional.ofNullable(refundBO).map(o->refundBO.getRefundNo()).orElse(null); |
|||
String mchId = Optional.ofNullable(refundBO).map(o->refundBO.getMchId()).orElse(null); |
|||
if(StringUtils.isBlank(refundOrderNo)) |
|||
return; |
|||
if(StringUtils.isBlank(mchId)) |
|||
return; |
|||
// 商户支付配置信息查询
|
|||
claimMerchantConfig(refundBO); |
|||
// 微信退款查询
|
|||
Boolean refundResult = wecPaymentService.wecRefundQuery(refundBO); |
|||
// 同步退款信息
|
|||
if(refundResult) |
|||
updateRefundSuccess(refundBO); |
|||
}catch (BusinessException e){ |
|||
logger.info("退款订单 : {} 业务异常信息 : {}",refundBO.getRefundNo(),e.getCode()); |
|||
}catch (Exception e){ |
|||
logger.info("退款订单 : {} 系统异常信息 : {}",refundBO.getRefundNo(),e.getMessage()); |
|||
}finally { |
|||
// 叠加退款查询次数
|
|||
superRefundCount(refundBO); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 登记退款 |
|||
* @param refundBO |
|||
*/ |
|||
private void registerRfund(RefundBO refundBO) { |
|||
Refund refund = new Refund(); |
|||
refund.setId(UUID.randomUUID().toString().replace("-", "")); |
|||
refund.setCreateId(refundBO.getCreateId()); |
|||
refund.setCreateTime(new Date()); |
|||
refund.setReason(refundBO.getReason()); |
|||
refund.setMchId(refundBO.getMchId()); |
|||
refund.setRefundOrderNo(DateUtil.getDateString(25)); |
|||
refund.setRefundTime(new Date()); |
|||
refund.setRefundState(PaymentConstant.REFUND_WAIT); |
|||
refund.setRefundRetryCount(PaymentConstant.START_REFUND_COUNT); |
|||
refund.setOrigOrderNo(refundBO.getOrigOrderNo()); |
|||
refund.setOrigOrderTime(refundBO.getOrigCreateTime()); |
|||
// FIXME 原销售单据id
|
|||
// refund.setSourceBillId();
|
|||
int count = refundMapper.insert(refund); |
|||
if(count < 1) |
|||
throw new BusinessException(ErrorConstant.REGISTER_REFUND_FAIL); |
|||
refundBO.setRefundNo(refund.getRefundOrderNo()); |
|||
} |
|||
|
|||
/** |
|||
* 同步退款状态 |
|||
* @param refundBO |
|||
*/ |
|||
private void updateRefundSuccess(RefundBO refundBO) { |
|||
Refund refund = new Refund(); |
|||
refund.setRefundOrderNo(refundBO.getRefundNo()); |
|||
refund.setRefundState(PaymentConstant.REFUND_SUCCESS); |
|||
int count = refundMapper.updateRefundSuccess(refund); |
|||
if(count < 1) |
|||
throw new BusinessException(ErrorConstant.SYNC_WEC_REFUND_STATE_FAIL); |
|||
} |
|||
|
|||
/** |
|||
* 叠加查询次数 |
|||
* @param refundBO |
|||
*/ |
|||
private void superRefundCount(RefundBO refundBO) { |
|||
String refundId = Optional.ofNullable(refundBO).map(RefundBO::getRefundId).orElse(null); |
|||
if(StringUtils.isBlank(refundId)) |
|||
return; |
|||
int count = refundMapper.superRefundCount(refundId); |
|||
if(count < 1) |
|||
throw new BusinessException(ErrorConstant.SUPER_REFUND_ORDER_COUNT_FAIL); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.dao.UserMapper; |
|||
import com.base.springcloud.entity.User; |
|||
import com.base.springcloud.service.UserService; |
|||
import com.base.springcloud.util.JwtUtil; |
|||
import com.base.springcloud.util.RedisUtil; |
|||
import com.google.gson.JsonObject; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.cache.annotation.Cacheable; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
@Service |
|||
public class UserServiceImp implements UserService { |
|||
|
|||
@Autowired |
|||
private UserMapper userMapper; |
|||
|
|||
/** |
|||
* 获取用户信息 |
|||
* @param userName |
|||
* @return |
|||
*/ |
|||
@Override |
|||
@Cacheable(cacheNames="cache:pay:user", key="#userName") |
|||
public User getUser(String userName) { |
|||
User user = userMapper.getUser(userName); |
|||
if(!Optional.ofNullable(user).isPresent()){ |
|||
throw new BusinessException(ErrorConstant.USER_ERROR); |
|||
} |
|||
// 判断用户状态
|
|||
if (user.getStatus() != 1) { |
|||
throw new BusinessException(ErrorConstant.USER_LOCKING); |
|||
} |
|||
return user; |
|||
} |
|||
} |
|||
@ -0,0 +1,431 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.util; |
|||
|
|||
//import org.jeecgframework.minidao.util.MiniDaoUtil;
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
//import javax.sql.DataSource;
|
|||
import java.lang.reflect.Array; |
|||
import java.math.BigDecimal; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
import java.util.regex.PatternSyntaxException; |
|||
|
|||
public class CommonUtils { |
|||
private static final Logger log = LoggerFactory.getLogger(CommonUtils.class); |
|||
public static ThreadLocal<SimpleDateFormat> dateFormat = new ThreadLocal<SimpleDateFormat>() { |
|||
protected SimpleDateFormat initialValue() { |
|||
return new SimpleDateFormat("yyyy-MM-dd"); |
|||
} |
|||
}; |
|||
public static ThreadLocal<SimpleDateFormat> dateTimeFormat = new ThreadLocal<SimpleDateFormat>() { |
|||
protected SimpleDateFormat initialValue() { |
|||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
} |
|||
}; |
|||
private static String DB_TYPE = ""; |
|||
|
|||
public CommonUtils() { |
|||
} |
|||
|
|||
public static String getCurrentDateTimeString(Date now) { |
|||
if (now == null) { |
|||
now = new Date(); |
|||
} |
|||
|
|||
return ((SimpleDateFormat)dateTimeFormat.get()).format(now); |
|||
} |
|||
|
|||
public static String getCurrentDateString(Date now) { |
|||
if (now == null) { |
|||
now = new Date(); |
|||
} |
|||
|
|||
return ((SimpleDateFormat)dateFormat.get()).format(now); |
|||
} |
|||
|
|||
public static String getFileName(String fileName) { |
|||
int var1 = fileName.lastIndexOf(47); |
|||
int var2 = fileName.lastIndexOf(92); |
|||
int var3 = var2 > var1 ? var2 : var1; |
|||
if (var3 != -1) { |
|||
fileName = fileName.substring(var3 + 1); |
|||
} |
|||
|
|||
fileName = fileName.replace("=", "").replace(",", "").replace("&", "").replace("#", ""); |
|||
String var4 = "[`_《》~!@%^&*()+=|{}':;',\\[\\]<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; |
|||
Pattern var5 = Pattern.compile(var4); |
|||
Matcher var6 = var5.matcher(fileName); |
|||
return var6.replaceAll("").trim(); |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String bizPath, String uploadType) { |
|||
String var3 = ""; |
|||
if ("minio".equals(uploadType)) { |
|||
var3 = MinioUtil.upload(file, bizPath); |
|||
} else { |
|||
var3 = OssBootUtil.upload(file, bizPath); |
|||
} |
|||
|
|||
return var3; |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) { |
|||
String var4 = ""; |
|||
if ("minio".equals(uploadType)) { |
|||
var4 = MinioUtil.upload(file, bizPath, customBucket); |
|||
} else { |
|||
var4 = OssBootUtil.upload(file, bizPath, customBucket); |
|||
} |
|||
|
|||
return var4; |
|||
} |
|||
|
|||
/*public static String getDatabaseType() { |
|||
if (oConvertUtils.isNotEmpty(DB_TYPE)) { |
|||
return DB_TYPE; |
|||
} else { |
|||
try { |
|||
DataSource var0 = (DataSource)JimuSpringContextUtils.getApplicationContext().getBean(DataSource.class); |
|||
return MiniDaoUtil.getDbType(var0); |
|||
} catch (Exception var1) { |
|||
log.warn(var1.getMessage(), var1); |
|||
return ""; |
|||
} |
|||
} |
|||
}*/ |
|||
|
|||
/*public static Integer getIntParameter(String params, Integer def) { |
|||
HttpServletRequest var2 = JimuSpringContextUtils.getHttpServletRequest(); |
|||
String var3 = var2.getParameter(params); |
|||
return isNotEmpty(var3) ? Integer.parseInt(var3.toString()) : def; |
|||
}*/ |
|||
|
|||
public static Integer getIntParameter(HttpServletRequest request, String params, Integer def) { |
|||
String var3 = request.getParameter(params); |
|||
return isNotEmpty(var3) ? Integer.parseInt(var3.toString()) : def; |
|||
} |
|||
|
|||
public static String filter(String str) throws PatternSyntaxException { |
|||
String var1 = "[`_《》~!@#$%^&*()+=|{}':;',\\[\\].<>?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; |
|||
Pattern var2 = Pattern.compile(var1); |
|||
Matcher var3 = var2.matcher(str); |
|||
return var3.replaceAll("").trim(); |
|||
} |
|||
|
|||
public static boolean anyOneIsNull(Object... objs) { |
|||
int var1 = objs.length; |
|||
|
|||
for(int var2 = 0; var2 < var1; ++var2) { |
|||
Object var3 = objs[var2]; |
|||
if (isEmpty(var3)) { |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static boolean anyOneIsNotNull(Object... objs) { |
|||
int var1 = objs.length; |
|||
|
|||
for(int var2 = 0; var2 < var1; ++var2) { |
|||
Object var3 = objs[var2]; |
|||
if (isNotEmpty(var3)) { |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static boolean allIsNull(Object... objs) { |
|||
int var1 = objs.length; |
|||
int var2 = 0; |
|||
|
|||
for(int var3 = 0; var3 < var1; ++var3) { |
|||
Object var4 = objs[var3]; |
|||
if (isEmpty(var4)) { |
|||
++var2; |
|||
} |
|||
} |
|||
|
|||
if (var2 == var1) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public static <T> Long[] listToLong(List<T> list) { |
|||
Long[] var1 = (Long[])list.toArray(new Long[list.size()]); |
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean gt(BigDecimal v1, BigDecimal v2) { |
|||
Boolean var2 = false; |
|||
if (v1.compareTo(v2) == 1) { |
|||
var2 = true; |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static Boolean ge(BigDecimal v1, BigDecimal v2) { |
|||
Boolean var2 = false; |
|||
if (v1.compareTo(v2) == 1) { |
|||
var2 = true; |
|||
} |
|||
|
|||
if (v1.compareTo(v2) == 0) { |
|||
var2 = true; |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static Boolean lt(BigDecimal v1, BigDecimal v2) { |
|||
Boolean var2 = false; |
|||
if (v1.compareTo(v2) == -1) { |
|||
var2 = true; |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static Boolean eq(BigDecimal v1, BigDecimal v2) { |
|||
Boolean var2 = false; |
|||
if (isNotEmpty(v1) && v1.compareTo(v2) == 0) { |
|||
var2 = true; |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static Boolean le(BigDecimal v1, BigDecimal v2) { |
|||
Boolean var2 = false; |
|||
if (isNotEmpty(v1)) { |
|||
if (v1.compareTo(v2) == -1) { |
|||
var2 = true; |
|||
} |
|||
|
|||
if (v1.compareTo(v2) == 0) { |
|||
var2 = true; |
|||
} |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static Boolean gtzero(BigDecimal v) { |
|||
Boolean var1 = false; |
|||
if (isNotEmpty(v) && v.doubleValue() > 0.0D) { |
|||
var1 = true; |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean gezero(BigDecimal v) { |
|||
Boolean var1 = false; |
|||
if (isNotEmpty(v) && (v.compareTo(BigDecimal.ZERO) == 0 || v.compareTo(BigDecimal.ZERO) == 1)) { |
|||
var1 = true; |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean eqzero(BigDecimal v) { |
|||
Boolean var1 = false; |
|||
if (isNotEmpty(v) && v.compareTo(BigDecimal.ZERO) == 0) { |
|||
var1 = true; |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean nezero(BigDecimal v) { |
|||
Boolean var1 = true; |
|||
if (isNotEmpty(v) && v.compareTo(BigDecimal.ZERO) == 0) { |
|||
var1 = false; |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean ltzero(BigDecimal v) { |
|||
Boolean var1 = false; |
|||
if (isNotEmpty(v) && v.doubleValue() < 0.0D) { |
|||
var1 = true; |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Boolean lezero(BigDecimal v) { |
|||
Boolean var1 = false; |
|||
if (isNotEmpty(v)) { |
|||
if (v.compareTo(BigDecimal.ZERO) == 0) { |
|||
var1 = true; |
|||
} |
|||
|
|||
if (v.compareTo(BigDecimal.ZERO) == -1) { |
|||
var1 = true; |
|||
} |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static boolean contains(String[] stringArray, String source) { |
|||
List var2 = Arrays.asList(stringArray); |
|||
return var2.contains(source); |
|||
} |
|||
|
|||
public static boolean contains(List<String> stringArray, String source) { |
|||
return stringArray.contains(source); |
|||
} |
|||
|
|||
public static boolean allNotNull(Object... obj) { |
|||
return !anyOneIsNull(obj); |
|||
} |
|||
|
|||
public static boolean isNotEmpty(Object obj) { |
|||
return !isEmpty(obj); |
|||
} |
|||
|
|||
public static boolean isEmpty(Object obj) { |
|||
if (obj == null) { |
|||
return true; |
|||
} else if (obj.getClass().isArray()) { |
|||
return Array.getLength(obj) == 0; |
|||
} else if (obj instanceof CharSequence) { |
|||
return ((CharSequence)obj).length() == 0; |
|||
} else if (obj instanceof String) { |
|||
return ((String)obj).trim().equals(""); |
|||
} else if (obj instanceof Collection) { |
|||
return ((Collection)obj).isEmpty(); |
|||
} else { |
|||
return obj instanceof Map ? ((Map)obj).isEmpty() : false; |
|||
} |
|||
} |
|||
|
|||
public static String renamePic(String fileName) { |
|||
String var1 = fileName.substring(fileName.lastIndexOf(".")); |
|||
return UUID.randomUUID().toString().replace("-", "") + var1; |
|||
} |
|||
|
|||
public static BigDecimal getBigDecimal(BigDecimal v, String def) { |
|||
return isEmpty(v) ? new BigDecimal(def) : v; |
|||
} |
|||
|
|||
public static BigDecimal getBigDecimal(BigDecimal v, BigDecimal def) { |
|||
return isEmpty(v) ? def : v; |
|||
} |
|||
|
|||
public static String getString(String v) { |
|||
return isEmpty(v) ? "" : v; |
|||
} |
|||
|
|||
public static String getString(String v, String defval) { |
|||
return isEmpty(v) ? defval : v; |
|||
} |
|||
|
|||
public static Integer getInteger(Integer v, Integer defval) { |
|||
return isEmpty(v) ? defval : v; |
|||
} |
|||
|
|||
public static Integer getInteger(String v, Integer defval) { |
|||
return isEmpty(v) ? defval : Integer.parseInt(v); |
|||
} |
|||
|
|||
public static String chineseNumber2Int(String chineseNumber) { |
|||
String[] var1 = new String[]{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"}; |
|||
String[] var2 = new String[]{"十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"}; |
|||
String var3 = ""; |
|||
int var4 = chineseNumber.length(); |
|||
|
|||
for(int var5 = 0; var5 < var4; ++var5) { |
|||
int var6 = chineseNumber.charAt(var5) - 48; |
|||
if (var5 != var4 - 1 && var6 != 0) { |
|||
var3 = var3 + var1[var6] + var2[var4 - 2 - var5]; |
|||
} else { |
|||
var3 = var3 + var1[var6]; |
|||
} |
|||
|
|||
System.out.println(" " + var3); |
|||
} |
|||
|
|||
return var3; |
|||
} |
|||
|
|||
public static String getAlias(String tableName) { |
|||
String[] var1 = tableName.split("_"); |
|||
String var2 = ""; |
|||
if (var1.length > 2) { |
|||
String[] var3 = var1; |
|||
int var4 = var1.length; |
|||
|
|||
for(int var5 = 0; var5 < var4; ++var5) { |
|||
String var6 = var3[var5]; |
|||
var2 = var2 + var6.substring(0, 1); |
|||
} |
|||
} else { |
|||
var2 = var1[var1.length - 1]; |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static String string2Unicode(String string) { |
|||
String var1 = ""; |
|||
if (isNotEmpty(string)) { |
|||
StringBuffer var2 = new StringBuffer(); |
|||
|
|||
for(int var3 = 0; var3 < string.length(); ++var3) { |
|||
char var4 = string.charAt(var3); |
|||
var2.append("\\u" + Integer.toHexString(var4)); |
|||
} |
|||
|
|||
var1 = var2.toString(); |
|||
} |
|||
|
|||
return var1; |
|||
} |
|||
|
|||
public static Long[] StringArray2LongArray(String[] stringArray) { |
|||
ArrayList var1 = new ArrayList(); |
|||
String[] var2 = stringArray; |
|||
int var3 = stringArray.length; |
|||
|
|||
for(int var4 = 0; var4 < var3; ++var4) { |
|||
String var5 = var2[var4]; |
|||
|
|||
try { |
|||
var1.add(Long.parseLong(var5)); |
|||
} catch (NumberFormatException var7) { |
|||
var7.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
Long[] var8 = (Long[])var1.toArray(new Long[var1.size()]); |
|||
return var8; |
|||
} |
|||
|
|||
public static String getString(Object obj, String def) { |
|||
return oConvertUtils.isNotEmpty(obj) ? obj.toString() : def; |
|||
} |
|||
|
|||
public static Long getLong(Object obj, Long def) { |
|||
return oConvertUtils.isNotEmpty(obj) ? Long.parseLong(obj.toString()) : def; |
|||
} |
|||
} |
|||
@ -1,71 +0,0 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import org.apache.commons.net.ftp.FTPClient; |
|||
import org.apache.commons.net.ftp.FTPReply; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
@Component |
|||
public class FtpUtil { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(FtpUtil.class); |
|||
|
|||
//ftp服务器ip地址
|
|||
@Value("${ftp.ftp_ip}") |
|||
private String FTP_ADDRESS; |
|||
//端口号
|
|||
@Value("${ftp.ftp_prot}") |
|||
private int FTP_PORT; |
|||
//用户名
|
|||
@Value("${ftp.ftp_username}") |
|||
private String FTP_USERNAME; |
|||
//密码
|
|||
@Value("${ftp.ftp_password}") |
|||
private String FTP_PASSWORD; |
|||
|
|||
//路径都是/home/加上用户名
|
|||
@Value("${ftp.ftp_basepath}") |
|||
public String FTP_BASEPATH; |
|||
|
|||
|
|||
// 文件上传
|
|||
public boolean uploadFile(String originFileName, InputStream input) { |
|||
//这是最开始引入的依赖里的方法
|
|||
FTPClient ftp = new FTPClient(); |
|||
ftp.setControlEncoding("utf-8"); |
|||
try { |
|||
int reply; |
|||
ftp.connect(FTP_ADDRESS, FTP_PORT);// 连接FTP服务器
|
|||
ftp.login(FTP_USERNAME, FTP_PASSWORD);// 登录
|
|||
reply = ftp.getReplyCode();//连接成功会的到一个返回状态码
|
|||
System.out.println(reply);//可以输出看一下是否连接成功
|
|||
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);//设置文件类型
|
|||
ftp.changeWorkingDirectory(FTP_BASEPATH);//修改操作空间
|
|||
//对了这里说明一下你所操作的文件夹必须要有可读权限,chomd 777 文件夹名//这里我就是用的我的home文件夹
|
|||
ftp.storeFile(originFileName, input); |
|||
if (!FTPReply.isPositiveCompletion(reply)) { |
|||
logger.warn("ftp connect fail...."); |
|||
ftp.disconnect(); |
|||
return false; |
|||
} |
|||
input.close(); |
|||
ftp.logout(); |
|||
return true; |
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
}finally { |
|||
if (ftp.isConnected()) { |
|||
try { |
|||
ftp.disconnect(); |
|||
} catch (IOException ioe) { |
|||
} |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import com.auth0.jwt.JWT; |
|||
import com.auth0.jwt.JWTVerifier; |
|||
import com.auth0.jwt.algorithms.Algorithm; |
|||
import com.auth0.jwt.exceptions.JWTDecodeException; |
|||
import com.auth0.jwt.interfaces.DecodedJWT; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author Scott |
|||
* @Date 2018-07-12 14:23 |
|||
* @Desc JWT工具类 |
|||
**/ |
|||
public class JwtUtil { |
|||
|
|||
/** |
|||
* Token过期时间30分钟(用户登录过期时间是此时间的两倍,以token在reids缓存时间为准) |
|||
*/ |
|||
public static final long EXPIRE_TIME = 30 * 60 * 1000; |
|||
|
|||
/** |
|||
* 校验token是否正确 |
|||
* |
|||
* @param token 密钥 |
|||
* @param secret 用户的密码 |
|||
* @return 是否正确 |
|||
*/ |
|||
public static boolean verify(String token, String username, String secret) { |
|||
try { |
|||
// 根据密码生成JWT效验器
|
|||
Algorithm algorithm = Algorithm.HMAC256(secret); |
|||
JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build(); |
|||
// 效验TOKEN
|
|||
DecodedJWT jwt = verifier.verify(token); |
|||
return true; |
|||
} catch (Exception exception) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获得token中的信息无需secret解密也能获得 |
|||
* |
|||
* @return token中包含的用户名 |
|||
*/ |
|||
public static String getUsername(String token) { |
|||
try { |
|||
DecodedJWT jwt = JWT.decode(token); |
|||
return jwt.getClaim("username").asString(); |
|||
} catch (JWTDecodeException e) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获得token中的信息无需secret解密也能获得 |
|||
* |
|||
* @return token中包含的用户名 |
|||
*/ |
|||
public static String getPlatform(String token) { |
|||
try { |
|||
DecodedJWT jwt = JWT.decode(token); |
|||
return jwt.getClaim("platform").asString(); |
|||
} catch (JWTDecodeException e) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 生成签名,5min后过期 |
|||
* |
|||
* @param username 用户名 |
|||
* @param secret 用户的密码 |
|||
* @return 加密的token |
|||
*/ |
|||
public static String sign(String username, String secret) { |
|||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME); |
|||
Algorithm algorithm = Algorithm.HMAC256(secret); |
|||
// 附带username信息
|
|||
return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 生成签名,5min后过期 |
|||
* |
|||
* @param username 用户名 |
|||
* @param secret 用户的密码 |
|||
* @return 加密的token |
|||
*/ |
|||
public static String sign(String username, String secret,String platform) { |
|||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME); |
|||
Algorithm algorithm = Algorithm.HMAC256(secret); |
|||
// 附带username信息
|
|||
return JWT.create().withClaim("username", username).withClaim("platform",platform).withExpiresAt(date).sign(algorithm); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,160 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.util; |
|||
|
|||
import io.minio.*; |
|||
import io.minio.BucketExistsArgs.Builder; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URLDecoder; |
|||
|
|||
public class MinioUtil { |
|||
private static final Logger log = LoggerFactory.getLogger(MinioUtil.class); |
|||
private static String minioUrl; |
|||
private static String minioName; |
|||
private static String minioPass; |
|||
private static String bucketName; |
|||
private static MinioClient minioClient = null; |
|||
|
|||
public MinioUtil() { |
|||
} |
|||
|
|||
public static void setMinioUrl(String minioUrl) { |
|||
MinioUtil.minioUrl = minioUrl; |
|||
} |
|||
|
|||
public static void setMinioName(String minioName) { |
|||
MinioUtil.minioName = minioName; |
|||
} |
|||
|
|||
public static void setMinioPass(String minioPass) { |
|||
MinioUtil.minioPass = minioPass; |
|||
} |
|||
|
|||
public static void setBucketName(String bucketName) { |
|||
MinioUtil.bucketName = bucketName; |
|||
} |
|||
|
|||
public static String getMinioUrl() { |
|||
return minioUrl; |
|||
} |
|||
|
|||
public static String getBucketName() { |
|||
return bucketName; |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String bizPath, String customBucket) { |
|||
String var3 = ""; |
|||
bizPath = CommonUtils.filter(bizPath); |
|||
String var4 = bucketName; |
|||
if (oConvertUtils.isNotEmpty(customBucket)) { |
|||
var4 = customBucket; |
|||
} |
|||
|
|||
try { |
|||
initMinio(minioUrl, minioName, minioPass); |
|||
if (minioClient.bucketExists((BucketExistsArgs)((Builder)BucketExistsArgs.builder().bucket(var4)).build())) { |
|||
log.debug("Bucket already exists."); |
|||
} else { |
|||
minioClient.makeBucket((MakeBucketArgs)((io.minio.MakeBucketArgs.Builder)MakeBucketArgs.builder().bucket(var4)).build()); |
|||
log.debug("create a new bucket."); |
|||
} |
|||
|
|||
InputStream var5 = file.getInputStream(); |
|||
String var6 = file.getOriginalFilename(); |
|||
if ("".equals(var6)) { |
|||
var6 = file.getName(); |
|||
} |
|||
|
|||
var6 = CommonUtils.getFileName(var6); |
|||
String var7 = bizPath + "/" + var6.substring(0, var6.lastIndexOf(".")) + "_" + System.currentTimeMillis() + var6.substring(var6.indexOf(".")); |
|||
if (var7.startsWith("/")) { |
|||
var7 = var7.substring(1); |
|||
} |
|||
|
|||
PutObjectArgs var8 = (PutObjectArgs)((io.minio.PutObjectArgs.Builder)((io.minio.PutObjectArgs.Builder)PutObjectArgs.builder().object(var7)).bucket(var4)).contentType("application/octet-stream").stream(var5, (long)var5.available(), -1L).build(); |
|||
minioClient.putObject(var8); |
|||
var5.close(); |
|||
var3 = minioUrl + var4 + "/" + var7; |
|||
} catch (Exception var9) { |
|||
log.error(var9.getMessage(), var9); |
|||
} |
|||
|
|||
return var3; |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String bizPath) { |
|||
return upload(file, bizPath, (String)null); |
|||
} |
|||
|
|||
public static InputStream getMinioFile(String bucketName, String objectName) { |
|||
GetObjectResponse var2 = null; |
|||
|
|||
try { |
|||
initMinio(minioUrl, minioName, minioPass); |
|||
GetObjectArgs var3 = (GetObjectArgs)((io.minio.GetObjectArgs.Builder)((io.minio.GetObjectArgs.Builder)GetObjectArgs.builder().object(objectName)).bucket(bucketName)).build(); |
|||
var2 = minioClient.getObject(var3); |
|||
} catch (Exception var4) { |
|||
log.error("文件获取失败" + var4.getMessage(), var4); |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static void removeObject(String bucketName, String objectName) { |
|||
try { |
|||
initMinio(minioUrl, minioName, minioPass); |
|||
RemoveObjectArgs var2 = (RemoveObjectArgs)((io.minio.RemoveObjectArgs.Builder)((io.minio.RemoveObjectArgs.Builder)RemoveObjectArgs.builder().object(objectName)).bucket(bucketName)).build(); |
|||
minioClient.removeObject(var2); |
|||
} catch (Exception var3) { |
|||
log.error("文件删除失败" + var3.getMessage(), var3); |
|||
} |
|||
|
|||
} |
|||
|
|||
public static String getObjectURL(String bucketName, String objectName, Integer expires) { |
|||
initMinio(minioUrl, minioName, minioPass); |
|||
|
|||
try { |
|||
GetPresignedObjectUrlArgs var3 = (GetPresignedObjectUrlArgs)((io.minio.GetPresignedObjectUrlArgs.Builder)((io.minio.GetPresignedObjectUrlArgs.Builder)GetPresignedObjectUrlArgs.builder().object(objectName)).bucket(bucketName)).expiry(expires).build(); |
|||
String var4 = minioClient.getPresignedObjectUrl(var3); |
|||
return URLDecoder.decode(var4, "UTF-8"); |
|||
} catch (Exception var5) { |
|||
log.error("文件路径获取失败" + var5.getMessage(), var5); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
private static MinioClient initMinio(String minioUrl, String minioName, String minioPass) { |
|||
if (minioClient == null) { |
|||
try { |
|||
minioClient = MinioClient.builder().endpoint(minioUrl).credentials(minioName, minioPass).build(); |
|||
} catch (Exception var4) { |
|||
var4.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
return minioClient; |
|||
} |
|||
|
|||
public static String upload(InputStream stream, String relativePath) throws Exception { |
|||
initMinio(minioUrl, minioName, minioPass); |
|||
if (minioClient.bucketExists((BucketExistsArgs)((Builder)BucketExistsArgs.builder().bucket(bucketName)).build())) { |
|||
log.debug("Bucket already exists."); |
|||
} else { |
|||
minioClient.makeBucket((MakeBucketArgs)((io.minio.MakeBucketArgs.Builder)MakeBucketArgs.builder().bucket(bucketName)).build()); |
|||
log.debug("create a new bucket."); |
|||
} |
|||
|
|||
PutObjectArgs var2 = (PutObjectArgs)((io.minio.PutObjectArgs.Builder)((io.minio.PutObjectArgs.Builder)PutObjectArgs.builder().object(relativePath)).bucket(bucketName)).contentType("application/octet-stream").stream(stream, (long)stream.available(), -1L).build(); |
|||
minioClient.putObject(var2); |
|||
stream.close(); |
|||
return minioUrl + bucketName + "/" + relativePath; |
|||
} |
|||
} |
|||
@ -0,0 +1,254 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.util; |
|||
|
|||
import com.aliyun.oss.ClientConfiguration; |
|||
import com.aliyun.oss.OSSClient; |
|||
import com.aliyun.oss.common.auth.DefaultCredentialProvider; |
|||
import com.aliyun.oss.model.CannedAccessControlList; |
|||
import com.aliyun.oss.model.OSSObject; |
|||
import com.aliyun.oss.model.PutObjectResult; |
|||
import org.apache.tomcat.util.http.fileupload.FileItemStream; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.BufferedInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLDecoder; |
|||
import java.util.Date; |
|||
import java.util.UUID; |
|||
|
|||
public class OssBootUtil { |
|||
private static final Logger log = LoggerFactory.getLogger(OssBootUtil.class); |
|||
private static String endPoint; |
|||
private static String accessKeyId; |
|||
private static String accessKeySecret; |
|||
private static String bucketName; |
|||
private static String staticDomain; |
|||
private static OSSClient ossClient = null; |
|||
|
|||
public OssBootUtil() { |
|||
} |
|||
|
|||
public static void setEndPoint(String endPoint) { |
|||
OssBootUtil.endPoint = endPoint; |
|||
} |
|||
|
|||
public static void setAccessKeyId(String accessKeyId) { |
|||
OssBootUtil.accessKeyId = accessKeyId; |
|||
} |
|||
|
|||
public static void setAccessKeySecret(String accessKeySecret) { |
|||
OssBootUtil.accessKeySecret = accessKeySecret; |
|||
} |
|||
|
|||
public static void setBucketName(String bucketName) { |
|||
OssBootUtil.bucketName = bucketName; |
|||
} |
|||
|
|||
public static void setStaticDomain(String staticDomain) { |
|||
OssBootUtil.staticDomain = staticDomain; |
|||
} |
|||
|
|||
public static String getStaticDomain() { |
|||
return staticDomain; |
|||
} |
|||
|
|||
public static String getEndPoint() { |
|||
return endPoint; |
|||
} |
|||
|
|||
public static String getAccessKeyId() { |
|||
return accessKeyId; |
|||
} |
|||
|
|||
public static String getAccessKeySecret() { |
|||
return accessKeySecret; |
|||
} |
|||
|
|||
public static String getBucketName() { |
|||
return bucketName; |
|||
} |
|||
|
|||
public static OSSClient getOssClient() { |
|||
return ossClient; |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String fileDir, String customBucket) { |
|||
String var3 = null; |
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
StringBuilder var4 = new StringBuilder(); |
|||
String var5 = bucketName; |
|||
if (oConvertUtils.isNotEmpty(customBucket)) { |
|||
var5 = customBucket; |
|||
} |
|||
|
|||
try { |
|||
if (!ossClient.doesBucketExist(var5)) { |
|||
ossClient.createBucket(var5); |
|||
} |
|||
|
|||
String var6 = file.getOriginalFilename(); |
|||
if ("" == var6) { |
|||
var6 = file.getName(); |
|||
} |
|||
|
|||
var6 = CommonUtils.getFileName(var6); |
|||
String var7 = var6.substring(0, var6.lastIndexOf(".")) + "_" + System.currentTimeMillis() + var6.substring(var6.indexOf(".")); |
|||
if (!fileDir.endsWith("/")) { |
|||
fileDir = fileDir.concat("/"); |
|||
} |
|||
|
|||
fileDir = CommonUtils.filter(fileDir); |
|||
var4 = var4.append(fileDir + var7); |
|||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) { |
|||
var3 = staticDomain + "/" + var4; |
|||
} else { |
|||
var3 = "https://" + var5 + "." + endPoint + "/" + var4; |
|||
} |
|||
|
|||
PutObjectResult var8 = ossClient.putObject(var5, var4.toString(), file.getInputStream()); |
|||
if (var8 != null) { |
|||
log.debug("------OSS文件上传成功------" + var4); |
|||
} |
|||
|
|||
return var3; |
|||
} catch (IOException var9) { |
|||
var9.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static String upload(MultipartFile file, String fileDir) { |
|||
return upload(file, fileDir, (String)null); |
|||
} |
|||
|
|||
public static String upload(FileItemStream file, String fileDir) { |
|||
String var2 = null; |
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
StringBuilder var3 = new StringBuilder(); |
|||
|
|||
try { |
|||
String var4 = file.getName().substring(file.getName().lastIndexOf(46)); |
|||
String var5 = UUID.randomUUID().toString().replace("-", "") + var4; |
|||
if (!fileDir.endsWith("/")) { |
|||
fileDir = fileDir.concat("/"); |
|||
} |
|||
|
|||
fileDir = CommonUtils.filter(fileDir); |
|||
var3 = var3.append(fileDir + var5); |
|||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) { |
|||
var2 = staticDomain + "/" + var3; |
|||
} else { |
|||
var2 = "https://" + bucketName + "." + endPoint + "/" + var3; |
|||
} |
|||
|
|||
PutObjectResult var6 = ossClient.putObject(bucketName, var3.toString(), file.openStream()); |
|||
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead); |
|||
if (var6 != null) { |
|||
log.debug("------OSS文件上传成功------" + var3); |
|||
} |
|||
|
|||
return var2; |
|||
} catch (IOException var7) { |
|||
var7.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static void deleteUrl(String url) { |
|||
deleteUrl(url, (String)null); |
|||
} |
|||
|
|||
public static void deleteUrl(String url, String bucket) { |
|||
String var2 = bucketName; |
|||
if (oConvertUtils.isNotEmpty(bucket)) { |
|||
var2 = bucket; |
|||
} |
|||
|
|||
String var3 = ""; |
|||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) { |
|||
var3 = staticDomain + "/"; |
|||
} else { |
|||
var3 = "https://" + var2 + "." + endPoint + "/"; |
|||
} |
|||
|
|||
url = url.replace(var3, ""); |
|||
ossClient.deleteObject(var2, url); |
|||
} |
|||
|
|||
public static void delete(String fileName) { |
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
ossClient.deleteObject(bucketName, fileName); |
|||
} |
|||
|
|||
public static InputStream getOssFile(String objectName, String bucket) { |
|||
BufferedInputStream var2 = null; |
|||
|
|||
try { |
|||
String var3 = bucketName; |
|||
if (oConvertUtils.isNotEmpty(bucket)) { |
|||
var3 = bucket; |
|||
} |
|||
|
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
OSSObject var4 = ossClient.getObject(var3, objectName); |
|||
var2 = new BufferedInputStream(var4.getObjectContent()); |
|||
} catch (Exception var5) { |
|||
log.error("文件获取失败" + var5.getMessage()); |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
|
|||
public static InputStream getOssFile(String objectName) { |
|||
return getOssFile(objectName, (String)null); |
|||
} |
|||
|
|||
public static String getObjectURL(String bucketName, String objectName, Date expires) { |
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
|
|||
try { |
|||
if (ossClient.doesObjectExist(bucketName, objectName)) { |
|||
URL var3 = ossClient.generatePresignedUrl(bucketName, objectName, expires); |
|||
return URLDecoder.decode(var3.toString(), "UTF-8"); |
|||
} |
|||
} catch (Exception var4) { |
|||
log.error("文件路径获取失败" + var4.getMessage()); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
private static OSSClient initOSS(String endpoint, String accessKeyId, String accessKeySecret) { |
|||
if (ossClient == null) { |
|||
ossClient = new OSSClient(endpoint, new DefaultCredentialProvider(accessKeyId, accessKeySecret), new ClientConfiguration()); |
|||
} |
|||
|
|||
return ossClient; |
|||
} |
|||
|
|||
public static String upload(InputStream stream, String relativePath) { |
|||
String var2 = null; |
|||
initOSS(endPoint, accessKeyId, accessKeySecret); |
|||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) { |
|||
var2 = staticDomain + "/" + relativePath; |
|||
} else { |
|||
var2 = "https://" + bucketName + "." + endPoint + "/" + relativePath; |
|||
} |
|||
|
|||
PutObjectResult var4 = ossClient.putObject(bucketName, relativePath.toString(), stream); |
|||
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead); |
|||
if (var4 != null) { |
|||
log.debug("------OSS文件上传成功------" + relativePath); |
|||
} |
|||
|
|||
return var2; |
|||
} |
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import com.base.springcloud.bo.OrderBO; |
|||
import com.base.springcloud.bo.RefundBO; |
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.dto.NativePlaceOrderDTO; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Component |
|||
public class ParameterUtil { |
|||
|
|||
/** |
|||
* native下单入参设置 |
|||
* @param billId |
|||
* @return |
|||
*/ |
|||
public OrderBO nativePlaceOrderBefore(String billId,String createId){ |
|||
OrderBO orderBO = new OrderBO(); |
|||
orderBO.setBillIds(billId); |
|||
orderBO.setCreateId(createId); |
|||
orderBO.setMergeFlag(false); |
|||
orderBO.setMchId(PaymentConstant.DEFAULT_MCH_ID); |
|||
return orderBO; |
|||
} |
|||
|
|||
/** |
|||
* native下单响应设置 |
|||
* @param codeUrl |
|||
* @return |
|||
*/ |
|||
public List<NativePlaceOrderDTO> nativePlaceOrderAfter(String codeUrl){ |
|||
if(StringUtils.isEmpty(codeUrl)){ |
|||
return null; |
|||
} |
|||
List<NativePlaceOrderDTO> nativePlaceOrderDTOList = new ArrayList<>(); |
|||
NativePlaceOrderDTO nativePlaceOrderDTO = new NativePlaceOrderDTO(); |
|||
nativePlaceOrderDTO.setCodeUrl(codeUrl); |
|||
nativePlaceOrderDTOList.add(nativePlaceOrderDTO); |
|||
return nativePlaceOrderDTOList; |
|||
} |
|||
|
|||
/** |
|||
* 退款入参设置 |
|||
* @param billId |
|||
* @return |
|||
*/ |
|||
public RefundBO refundBefore(String billId) { |
|||
RefundBO refundBO = new RefundBO(); |
|||
refundBO.setBillId(billId); |
|||
return refundBO; |
|||
} |
|||
|
|||
public OrderBO mergeNativeBefore(String billIds,String createId) { |
|||
OrderBO orderBO = new OrderBO(); |
|||
orderBO.setMergeFlag(true); |
|||
orderBO.setBillIds(billIds); |
|||
orderBO.setCreateId(createId); |
|||
return orderBO; |
|||
} |
|||
|
|||
public List mergeNativeAfter(String codeUrl) { |
|||
if(StringUtils.isBlank(codeUrl)){ |
|||
return null; |
|||
} |
|||
List<NativePlaceOrderDTO> nativePlaceOrderDTOList = new ArrayList<>(); |
|||
NativePlaceOrderDTO nativePlaceOrderDTO = new NativePlaceOrderDTO(); |
|||
nativePlaceOrderDTO.setCodeUrl(codeUrl); |
|||
nativePlaceOrderDTOList.add(nativePlaceOrderDTO); |
|||
return nativePlaceOrderDTOList; |
|||
} |
|||
} |
|||
@ -0,0 +1,568 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/** |
|||
* redis 工具类 |
|||
* @Author Scott |
|||
* |
|||
*/ |
|||
@Component |
|||
public class RedisUtil { |
|||
|
|||
@Resource |
|||
private RedisTemplate<String, Object> redisTemplate; |
|||
|
|||
/** |
|||
* 指定缓存失效时间 |
|||
* |
|||
* @param key 键 |
|||
* @param time 时间(秒) |
|||
* @return |
|||
*/ |
|||
public boolean expire(String key, long time) { |
|||
try { |
|||
if (time > 0) { |
|||
redisTemplate.expire(key, time, TimeUnit.SECONDS); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据key 获取过期时间 |
|||
* |
|||
* @param key 键 不能为null |
|||
* @return 时间(秒) 返回0代表为永久有效 |
|||
*/ |
|||
public long getExpire(String key) { |
|||
return redisTemplate.getExpire(key, TimeUnit.SECONDS); |
|||
} |
|||
|
|||
/** |
|||
* 判断key是否存在 |
|||
* |
|||
* @param key 键 |
|||
* @return true 存在 false不存在 |
|||
*/ |
|||
public boolean hasKey(String key) { |
|||
try { |
|||
return redisTemplate.hasKey(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 删除缓存 |
|||
* |
|||
* @param key 可以传一个值 或多个 |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public void del(String... key) { |
|||
if (key != null && key.length > 0) { |
|||
if (key.length == 1) { |
|||
redisTemplate.delete(key[0]); |
|||
} else { |
|||
redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// ============================String=============================
|
|||
/** |
|||
* 普通缓存获取 |
|||
* |
|||
* @param key 键 |
|||
* @return 值 |
|||
*/ |
|||
public Object get(String key) { |
|||
return key == null ? null : redisTemplate.opsForValue().get(key); |
|||
} |
|||
|
|||
/** |
|||
* 普通缓存放入 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @return true成功 false失败 |
|||
*/ |
|||
public boolean set(String key, Object value) { |
|||
try { |
|||
redisTemplate.opsForValue().set(key, value); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 普通缓存放入并设置时间 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 |
|||
* @return true成功 false 失败 |
|||
*/ |
|||
public boolean set(String key, Object value, long time) { |
|||
try { |
|||
if (time > 0) { |
|||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); |
|||
} else { |
|||
set(key, value); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 递增 |
|||
* |
|||
* @param key 键 |
|||
* @return |
|||
*/ |
|||
public long incr(String key, long delta) { |
|||
if (delta < 0) { |
|||
throw new RuntimeException("递增因子必须大于0"); |
|||
} |
|||
return redisTemplate.opsForValue().increment(key, delta); |
|||
} |
|||
|
|||
/** |
|||
* 递减 |
|||
* |
|||
* @param key 键 |
|||
* @return |
|||
*/ |
|||
public long decr(String key, long delta) { |
|||
if (delta < 0) { |
|||
throw new RuntimeException("递减因子必须大于0"); |
|||
} |
|||
return redisTemplate.opsForValue().increment(key, -delta); |
|||
} |
|||
|
|||
// ================================Map=================================
|
|||
/** |
|||
* HashGet |
|||
* |
|||
* @param key 键 不能为null |
|||
* @param item 项 不能为null |
|||
* @return 值 |
|||
*/ |
|||
public Object hget(String key, String item) { |
|||
return redisTemplate.opsForHash().get(key, item); |
|||
} |
|||
|
|||
/** |
|||
* 获取hashKey对应的所有键值 |
|||
* |
|||
* @param key 键 |
|||
* @return 对应的多个键值 |
|||
*/ |
|||
public Map<Object, Object> hmget(String key) { |
|||
return redisTemplate.opsForHash().entries(key); |
|||
} |
|||
|
|||
/** |
|||
* HashSet |
|||
* |
|||
* @param key 键 |
|||
* @param map 对应多个键值 |
|||
* @return true 成功 false 失败 |
|||
*/ |
|||
public boolean hmset(String key, Map<String, Object> map) { |
|||
try { |
|||
redisTemplate.opsForHash().putAll(key, map); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* HashSet 并设置时间 |
|||
* |
|||
* @param key 键 |
|||
* @param map 对应多个键值 |
|||
* @param time 时间(秒) |
|||
* @return true成功 false失败 |
|||
*/ |
|||
public boolean hmset(String key, Map<String, Object> map, long time) { |
|||
try { |
|||
redisTemplate.opsForHash().putAll(key, map); |
|||
if (time > 0) { |
|||
expire(key, time); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 向一张hash表中放入数据,如果不存在将创建 |
|||
* |
|||
* @param key 键 |
|||
* @param item 项 |
|||
* @param value 值 |
|||
* @return true 成功 false失败 |
|||
*/ |
|||
public boolean hset(String key, String item, Object value) { |
|||
try { |
|||
redisTemplate.opsForHash().put(key, item, value); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 向一张hash表中放入数据,如果不存在将创建 |
|||
* |
|||
* @param key 键 |
|||
* @param item 项 |
|||
* @param value 值 |
|||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 |
|||
* @return true 成功 false失败 |
|||
*/ |
|||
public boolean hset(String key, String item, Object value, long time) { |
|||
try { |
|||
redisTemplate.opsForHash().put(key, item, value); |
|||
if (time > 0) { |
|||
expire(key, time); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 删除hash表中的值 |
|||
* |
|||
* @param key 键 不能为null |
|||
* @param item 项 可以使多个 不能为null |
|||
*/ |
|||
public void hdel(String key, Object... item) { |
|||
redisTemplate.opsForHash().delete(key, item); |
|||
} |
|||
|
|||
/** |
|||
* 判断hash表中是否有该项的值 |
|||
* |
|||
* @param key 键 不能为null |
|||
* @param item 项 不能为null |
|||
* @return true 存在 false不存在 |
|||
*/ |
|||
public boolean hHasKey(String key, String item) { |
|||
return redisTemplate.opsForHash().hasKey(key, item); |
|||
} |
|||
|
|||
/** |
|||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回 |
|||
* |
|||
* @param key 键 |
|||
* @param item 项 |
|||
* @param by 要增加几(大于0) |
|||
* @return |
|||
*/ |
|||
public double hincr(String key, String item, double by) { |
|||
return redisTemplate.opsForHash().increment(key, item, by); |
|||
} |
|||
|
|||
/** |
|||
* hash递减 |
|||
* |
|||
* @param key 键 |
|||
* @param item 项 |
|||
* @param by 要减少记(小于0) |
|||
* @return |
|||
*/ |
|||
public double hdecr(String key, String item, double by) { |
|||
return redisTemplate.opsForHash().increment(key, item, -by); |
|||
} |
|||
|
|||
// ============================set=============================
|
|||
/** |
|||
* 根据key获取Set中的所有值 |
|||
* |
|||
* @param key 键 |
|||
* @return |
|||
*/ |
|||
public Set<Object> sGet(String key) { |
|||
try { |
|||
return redisTemplate.opsForSet().members(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据value从一个set中查询,是否存在 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @return true 存在 false不存在 |
|||
*/ |
|||
public boolean sHasKey(String key, Object value) { |
|||
try { |
|||
return redisTemplate.opsForSet().isMember(key, value); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将数据放入set缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param values 值 可以是多个 |
|||
* @return 成功个数 |
|||
*/ |
|||
public long sSet(String key, Object... values) { |
|||
try { |
|||
return redisTemplate.opsForSet().add(key, values); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将set数据放入缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param time 时间(秒) |
|||
* @param values 值 可以是多个 |
|||
* @return 成功个数 |
|||
*/ |
|||
public long sSetAndTime(String key, long time, Object... values) { |
|||
try { |
|||
Long count = redisTemplate.opsForSet().add(key, values); |
|||
if (time > 0) { |
|||
expire(key, time); |
|||
} |
|||
return count; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取set缓存的长度 |
|||
* |
|||
* @param key 键 |
|||
* @return |
|||
*/ |
|||
public long sGetSetSize(String key) { |
|||
try { |
|||
return redisTemplate.opsForSet().size(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 移除值为value的 |
|||
* |
|||
* @param key 键 |
|||
* @param values 值 可以是多个 |
|||
* @return 移除的个数 |
|||
*/ |
|||
public long setRemove(String key, Object... values) { |
|||
try { |
|||
Long count = redisTemplate.opsForSet().remove(key, values); |
|||
return count; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
// ===============================list=================================
|
|||
|
|||
/** |
|||
* 获取list缓存的内容 |
|||
* |
|||
* @param key 键 |
|||
* @param start 开始 |
|||
* @param end 结束 0 到 -1代表所有值 |
|||
* @return |
|||
*/ |
|||
public List<Object> lGet(String key, long start, long end) { |
|||
try { |
|||
return redisTemplate.opsForList().range(key, start, end); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取list缓存的长度 |
|||
* |
|||
* @param key 键 |
|||
* @return |
|||
*/ |
|||
public long lGetListSize(String key) { |
|||
try { |
|||
return redisTemplate.opsForList().size(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 通过索引 获取list中的值 |
|||
* |
|||
* @param key 键 |
|||
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 |
|||
* @return |
|||
*/ |
|||
public Object lGetIndex(String key, long index) { |
|||
try { |
|||
return redisTemplate.opsForList().index(key, index); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将list放入缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @return |
|||
*/ |
|||
public boolean lSet(String key, Object value) { |
|||
try { |
|||
redisTemplate.opsForList().rightPush(key, value); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将list放入缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @param time 时间(秒) |
|||
* @return |
|||
*/ |
|||
public boolean lSet(String key, Object value, long time) { |
|||
try { |
|||
redisTemplate.opsForList().rightPush(key, value); |
|||
if (time > 0) { |
|||
expire(key, time); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将list放入缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @return |
|||
*/ |
|||
public boolean lSet(String key, List<Object> value) { |
|||
try { |
|||
redisTemplate.opsForList().rightPushAll(key, value); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将list放入缓存 |
|||
* |
|||
* @param key 键 |
|||
* @param value 值 |
|||
* @param time 时间(秒) |
|||
* @return |
|||
*/ |
|||
public boolean lSet(String key, List<Object> value, long time) { |
|||
try { |
|||
redisTemplate.opsForList().rightPushAll(key, value); |
|||
if (time > 0) { |
|||
expire(key, time); |
|||
} |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据索引修改list中的某条数据 |
|||
* |
|||
* @param key 键 |
|||
* @param index 索引 |
|||
* @param value 值 |
|||
* @return |
|||
*/ |
|||
public boolean lUpdateIndex(String key, long index, Object value) { |
|||
try { |
|||
redisTemplate.opsForList().set(key, index, value); |
|||
return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 移除N个值为value |
|||
* |
|||
* @param key 键 |
|||
* @param count 移除多少个 |
|||
* @param value 值 |
|||
* @return 移除的个数 |
|||
*/ |
|||
public long lRemove(String key, long count, Object value) { |
|||
try { |
|||
Long remove = redisTemplate.opsForList().remove(key, count, value); |
|||
return remove; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,109 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.entity.User; |
|||
import com.base.springcloud.service.DepartService; |
|||
import com.base.springcloud.service.UserService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
|
|||
@Component |
|||
public class TokenUtils { |
|||
|
|||
@Autowired |
|||
private UserService userService; |
|||
|
|||
@Autowired |
|||
private RedisUtil redisService; |
|||
|
|||
@Autowired |
|||
private DepartService departService; |
|||
|
|||
/** |
|||
* Token验证 |
|||
*/ |
|||
public User verifyToken(HttpServletRequest request) { |
|||
// 从请求头获取token
|
|||
String token = request.getHeader("X-Access-Token"); |
|||
|
|||
// 如果请求头没有token,则从请求参数中取
|
|||
if (StringUtils.isBlank(token)) |
|||
token = request.getParameter("token"); |
|||
|
|||
// 如果还是没有token,则抛异常
|
|||
if (StringUtils.isBlank(token)) |
|||
throw new BusinessException(ErrorConstant.INVALID_TOKEN); |
|||
|
|||
// 从token里获取用户姓名
|
|||
String username = JwtUtil.getUsername(token); |
|||
if (StringUtils.isEmpty(username)) |
|||
throw new BusinessException(ErrorConstant.ILLEGAL_TOKEN); |
|||
|
|||
// 查询用户信息
|
|||
User user = userService.getUser(username); |
|||
|
|||
// 校验token是否超时失效 & 或者账号密码是否错误
|
|||
TokenValidity(token,user); |
|||
|
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* TOKEN有效期校验 |
|||
* |
|||
* @param token |
|||
* @param user |
|||
*/ |
|||
public void TokenValidity(String token, User user) { |
|||
String key = PaymentConstant.TOKEN_PREFIX + token; |
|||
String redisToken = String.valueOf(redisService.get(key)); |
|||
if (StringUtils.isBlank(redisToken)) |
|||
throw new BusinessException(ErrorConstant.TOKEN_EXPIRATION_DATE); |
|||
if (!JwtUtil.verify(redisToken, user.getUserName(), user.getPassword())) |
|||
throw new BusinessException(ErrorConstant.ILLEGAL_TOKEN); |
|||
String newAuthorization = JwtUtil.sign(user.getUserName(), user.getPassword()); |
|||
// 设置Toekn缓存有效时间
|
|||
redisService.set(PaymentConstant.TOKEN_PREFIX + token, newAuthorization); |
|||
redisService.expire(PaymentConstant.TOKEN_PREFIX + token, JwtUtil.EXPIRE_TIME * 2 / 1000); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 获取用户信息 |
|||
* @param request |
|||
* @param userId |
|||
*/ |
|||
public void userInfo(HttpServletRequest request, String userId) { |
|||
if(StringUtils.isBlank(userId)) return; |
|||
request.setAttribute("createId",userId); |
|||
} |
|||
|
|||
/** |
|||
* 获取用户部门 |
|||
* |
|||
* @param request |
|||
* @param userId |
|||
*/ |
|||
public void departmentInfo(HttpServletRequest request, String userId) { |
|||
List<String> departIdList = departService.getUserDepart(userId); |
|||
if (!Optional.ofNullable(departIdList).isPresent()) return; |
|||
request.setAttribute("departIdList",departIdList); |
|||
} |
|||
|
|||
/** |
|||
* 获取公司信息 |
|||
* @param request |
|||
* @param companyId |
|||
*/ |
|||
public void companyInfo(HttpServletRequest request, String companyId) { |
|||
if(StringUtils.isBlank(companyId)) return; |
|||
request.setAttribute("companyId",companyId); |
|||
} |
|||
} |
|||
@ -0,0 +1,443 @@ |
|||
//
|
|||
// Source code recreated from a .class file by IntelliJ IDEA
|
|||
// (powered by Fernflower decompiler)
|
|||
//
|
|||
|
|||
package com.base.springcloud.util; |
|||
|
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import org.apache.commons.codec.binary.Base64; |
|||
//import org.jeecg.modules.jmreport.common.expetion.JimuReportException;
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.ObjectInputStream; |
|||
import java.io.ObjectOutputStream; |
|||
import java.lang.reflect.Array; |
|||
import java.lang.reflect.Field; |
|||
import java.math.BigDecimal; |
|||
import java.net.InetAddress; |
|||
import java.net.UnknownHostException; |
|||
import java.util.*; |
|||
|
|||
public class oConvertUtils { |
|||
private static final Logger log = LoggerFactory.getLogger(oConvertUtils.class); |
|||
|
|||
public oConvertUtils() { |
|||
} |
|||
|
|||
public static boolean isEmptyString(CharSequence str) { |
|||
return str == null || str.length() == 0 || str == "null" || str == ""; |
|||
} |
|||
|
|||
public static boolean isEmptyMap(Map<?, ?> map) { |
|||
return null == map || map.isEmpty(); |
|||
} |
|||
|
|||
public static boolean isEmptyIterable(Iterable<?> iterable) { |
|||
return null == iterable || isEmpty(iterable.iterator()); |
|||
} |
|||
|
|||
public static boolean isEmptyIterator(Iterator<?> Iterator) { |
|||
return null == Iterator || !Iterator.hasNext(); |
|||
} |
|||
|
|||
public static boolean isArray(Object obj) { |
|||
return null == obj ? false : obj.getClass().isArray(); |
|||
} |
|||
|
|||
public static boolean isEmptyArray(Object array) { |
|||
if (null == array) { |
|||
return true; |
|||
} else if (isArray(array)) { |
|||
return 0 == Array.getLength(array); |
|||
} else { |
|||
throw new BusinessException(ErrorConstant.MISTAKE_TARGET); |
|||
} |
|||
} |
|||
|
|||
public static boolean isEmpty(Object obj) { |
|||
if (null == obj) { |
|||
return true; |
|||
} else if (obj instanceof CharSequence) { |
|||
return isEmptyString((CharSequence)obj); |
|||
} else if (obj instanceof Map) { |
|||
return isEmptyMap((Map)obj); |
|||
} else if (obj instanceof Iterable) { |
|||
return isEmptyIterable((Iterable)obj); |
|||
} else if (obj instanceof Iterator) { |
|||
return isEmptyIterator((Iterator)obj); |
|||
} else { |
|||
return isArray(obj) ? isEmptyArray(obj) : false; |
|||
} |
|||
} |
|||
|
|||
public static boolean isNotEmpty(Object object) { |
|||
return !isEmpty(object); |
|||
} |
|||
|
|||
public static String decode(String strIn, String sourceCode, String targetCode) { |
|||
String var3 = code2code(strIn, sourceCode, targetCode); |
|||
return var3; |
|||
} |
|||
|
|||
public static boolean isNumeric(String str) { |
|||
return str.matches("-?[0-9]+.?[0-9]*"); |
|||
} |
|||
|
|||
private static String code2code(String strIn, String sourceCode, String targetCode) { |
|||
String var3 = null; |
|||
if (strIn != null && !strIn.trim().equals("")) { |
|||
try { |
|||
byte[] var4 = strIn.getBytes(sourceCode); |
|||
|
|||
for(int var5 = 0; var5 < var4.length; ++var5) { |
|||
System.out.print(var4[var5] + " "); |
|||
} |
|||
|
|||
var3 = new String(var4, targetCode); |
|||
return var3; |
|||
} catch (Exception var6) { |
|||
var6.printStackTrace(); |
|||
return null; |
|||
} |
|||
} else { |
|||
return strIn; |
|||
} |
|||
} |
|||
|
|||
public static int getInt(String s, int defval) { |
|||
if (s != null && s != "") { |
|||
try { |
|||
return Integer.parseInt(s); |
|||
} catch (NumberFormatException var3) { |
|||
return defval; |
|||
} |
|||
} else { |
|||
return defval; |
|||
} |
|||
} |
|||
|
|||
public static int getInt(String s) { |
|||
if (s != null && s != "") { |
|||
try { |
|||
return Integer.parseInt(s); |
|||
} catch (NumberFormatException var2) { |
|||
return 0; |
|||
} |
|||
} else { |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
public static int getInt(String s, Integer df) { |
|||
if (s != null && s != "") { |
|||
try { |
|||
return Integer.parseInt(s); |
|||
} catch (NumberFormatException var3) { |
|||
return 0; |
|||
} |
|||
} else { |
|||
return df; |
|||
} |
|||
} |
|||
|
|||
public static int getInt(Object object, int defval) { |
|||
if (isEmpty(object)) { |
|||
return defval; |
|||
} else { |
|||
try { |
|||
return object instanceof Float ? ((Float)object).intValue() : Integer.parseInt(object.toString()); |
|||
} catch (NumberFormatException var3) { |
|||
return defval; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static Integer getInt(Object object) { |
|||
if (isEmpty(object)) { |
|||
return null; |
|||
} else { |
|||
try { |
|||
return object instanceof Float ? ((Float)object).intValue() : Integer.parseInt(object.toString()); |
|||
} catch (NumberFormatException var2) { |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static int getInt(BigDecimal s, int defval) { |
|||
return s == null ? defval : s.intValue(); |
|||
} |
|||
|
|||
public static String getString(String s) { |
|||
return getString(s, ""); |
|||
} |
|||
|
|||
public static String getString(Object object) { |
|||
return isEmpty(object) ? "" : object.toString().trim(); |
|||
} |
|||
|
|||
public static String getString(int i) { |
|||
return String.valueOf(i); |
|||
} |
|||
|
|||
public static String getString(float i) { |
|||
return String.valueOf(i); |
|||
} |
|||
|
|||
public static String getString(String s, String defval) { |
|||
return isEmpty(s) ? defval : s.trim(); |
|||
} |
|||
|
|||
public static String getString(Object s, String defval) { |
|||
return isEmpty(s) ? defval : s.toString().trim(); |
|||
} |
|||
|
|||
public static String getJmString(Object s) { |
|||
return isEmpty(s) ? "" : s.toString(); |
|||
} |
|||
|
|||
public static String getIp() { |
|||
String var0 = null; |
|||
|
|||
try { |
|||
InetAddress var1 = InetAddress.getLocalHost(); |
|||
var0 = var1.getHostAddress(); |
|||
} catch (UnknownHostException var2) { |
|||
var2.printStackTrace(); |
|||
} |
|||
|
|||
return var0; |
|||
} |
|||
|
|||
public static String camelToUnderline(String para) { |
|||
if (para.length() < 3) { |
|||
return para.toLowerCase(); |
|||
} else { |
|||
StringBuilder var1 = new StringBuilder(para); |
|||
int var2 = 0; |
|||
|
|||
for(int var3 = 2; var3 < para.length(); ++var3) { |
|||
if (Character.isUpperCase(para.charAt(var3))) { |
|||
var1.insert(var3 + var2, "_"); |
|||
++var2; |
|||
} |
|||
} |
|||
|
|||
return var1.toString().toLowerCase(); |
|||
} |
|||
} |
|||
|
|||
public static Field[] getAllFields(Object object) { |
|||
Class var1 = object.getClass(); |
|||
|
|||
ArrayList var2; |
|||
for(var2 = new ArrayList(); var1 != null; var1 = var1.getSuperclass()) { |
|||
var2.addAll(new ArrayList(Arrays.asList(var1.getDeclaredFields()))); |
|||
} |
|||
|
|||
Field[] var3 = new Field[var2.size()]; |
|||
var2.toArray(var3); |
|||
return var3; |
|||
} |
|||
|
|||
public static String join(Object[] array, String separator, int startIndex, int endIndex) { |
|||
if (array == null) { |
|||
return null; |
|||
} else { |
|||
if (separator == null) { |
|||
separator = ""; |
|||
} |
|||
|
|||
int var4 = endIndex - startIndex; |
|||
if (var4 <= 0) { |
|||
return ""; |
|||
} else { |
|||
StringBuilder var5 = newStringBuilder(var4); |
|||
if (array[startIndex] != null) { |
|||
var5.append(array[startIndex]); |
|||
} |
|||
|
|||
for(int var6 = startIndex + 1; var6 < endIndex; ++var6) { |
|||
var5.append(separator); |
|||
if (array[var6] != null) { |
|||
var5.append(array[var6]); |
|||
} |
|||
} |
|||
|
|||
return var5.toString(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static StringBuilder newStringBuilder(int noOfItems) { |
|||
return new StringBuilder(noOfItems * 16); |
|||
} |
|||
|
|||
public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos) { |
|||
if (str != null && searchStr != null) { |
|||
if (startPos < 0) { |
|||
startPos = 0; |
|||
} |
|||
|
|||
int var3 = str.length() - searchStr.length() + 1; |
|||
if (startPos > var3) { |
|||
return -1; |
|||
} else if (searchStr.length() == 0) { |
|||
return startPos; |
|||
} else { |
|||
for(int var4 = startPos; var4 < var3; ++var4) { |
|||
if (regionMatches(str, true, var4, searchStr, 0, searchStr.length())) { |
|||
return var4; |
|||
} |
|||
} |
|||
|
|||
return -1; |
|||
} |
|||
} else { |
|||
return -1; |
|||
} |
|||
} |
|||
|
|||
public static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length) { |
|||
if (cs instanceof String && substring instanceof String) { |
|||
return ((String)cs).regionMatches(ignoreCase, thisStart, (String)substring, start, length); |
|||
} else { |
|||
int var6 = thisStart; |
|||
int var7 = start; |
|||
int var8 = length; |
|||
int var9 = cs.length() - thisStart; |
|||
int var10 = substring.length() - start; |
|||
if (thisStart >= 0 && start >= 0 && length >= 0) { |
|||
if (var9 >= length && var10 >= length) { |
|||
while(var8-- > 0) { |
|||
char var11 = cs.charAt(var6++); |
|||
char var12 = substring.charAt(var7++); |
|||
if (var11 != var12) { |
|||
if (!ignoreCase) { |
|||
return false; |
|||
} |
|||
|
|||
if (Character.toUpperCase(var11) != Character.toUpperCase(var12) && Character.toLowerCase(var11) != Character.toLowerCase(var12)) { |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static byte[] decodeBase64(String base64Str) { |
|||
byte[] var1 = Base64.decodeBase64(base64Str); |
|||
return var1; |
|||
} |
|||
|
|||
public static <T> List<T> deepCopy(List<T> list) { |
|||
try { |
|||
ByteArrayOutputStream var1 = new ByteArrayOutputStream(); |
|||
Throwable var2 = null; |
|||
|
|||
Object var9; |
|||
try { |
|||
ObjectOutputStream var3 = new ObjectOutputStream(var1); |
|||
Throwable var4 = null; |
|||
|
|||
try { |
|||
var3.writeObject(list); |
|||
ByteArrayInputStream var5 = new ByteArrayInputStream(var1.toByteArray()); |
|||
Throwable var6 = null; |
|||
|
|||
try { |
|||
ObjectInputStream var7 = new ObjectInputStream(var5); |
|||
Throwable var8 = null; |
|||
|
|||
try { |
|||
var9 = (List)var7.readObject(); |
|||
} catch (Throwable var85) { |
|||
var9 = var85; |
|||
var8 = var85; |
|||
throw var85; |
|||
} finally { |
|||
if (var7 != null) { |
|||
if (var8 != null) { |
|||
try { |
|||
var7.close(); |
|||
} catch (Throwable var84) { |
|||
var8.addSuppressed(var84); |
|||
} |
|||
} else { |
|||
var7.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} catch (Throwable var87) { |
|||
var6 = var87; |
|||
throw var87; |
|||
} finally { |
|||
if (var5 != null) { |
|||
if (var6 != null) { |
|||
try { |
|||
var5.close(); |
|||
} catch (Throwable var83) { |
|||
var6.addSuppressed(var83); |
|||
} |
|||
} else { |
|||
var5.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} catch (Throwable var89) { |
|||
var4 = var89; |
|||
throw var89; |
|||
} finally { |
|||
if (var3 != null) { |
|||
if (var4 != null) { |
|||
try { |
|||
var3.close(); |
|||
} catch (Throwable var82) { |
|||
var4.addSuppressed(var82); |
|||
} |
|||
} else { |
|||
var3.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} catch (Throwable var91) { |
|||
var2 = var91; |
|||
throw var91; |
|||
} finally { |
|||
if (var1 != null) { |
|||
if (var2 != null) { |
|||
try { |
|||
var1.close(); |
|||
} catch (Throwable var81) { |
|||
var2.addSuppressed(var81); |
|||
} |
|||
} else { |
|||
var1.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
return (List)var9; |
|||
} catch (Exception var93) { |
|||
log.warn(var93.getMessage()); |
|||
return Collections.emptyList(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
/** |
|||
* 域名管理,实现主备域名自动切换 |
|||
*/ |
|||
public abstract interface IWXPayDomain { |
|||
/** |
|||
* 上报域名网络状况 |
|||
* @param domain 域名。 比如:api.mch.weixin.qq.com |
|||
* @param elapsedTimeMillis 耗时 |
|||
* @param ex 网络请求中出现的异常。 |
|||
* null表示没有异常 |
|||
* ConnectTimeoutException,表示建立网络连接异常 |
|||
* UnknownHostException, 表示dns解析异常 |
|||
*/ |
|||
abstract void report(final String domain, long elapsedTimeMillis, final Exception ex); |
|||
|
|||
/** |
|||
* 获取域名 |
|||
* @param config 配置 |
|||
* @return 域名 |
|||
*/ |
|||
abstract DomainInfo getDomain(final WXPayConfig config); |
|||
|
|||
static class DomainInfo{ |
|||
public String domain; //域名
|
|||
public boolean primaryDomain; //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名
|
|||
public DomainInfo(String domain, boolean primaryDomain) { |
|||
this.domain = domain; |
|||
this.primaryDomain = primaryDomain; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "DomainInfo{" + |
|||
"domain='" + domain + '\'' + |
|||
", primaryDomain=" + primaryDomain + |
|||
'}'; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import lombok.Data; |
|||
import sun.misc.BASE64Decoder; |
|||
|
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.InputStream; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
public class MyConfig extends WXPayConfig { |
|||
|
|||
private String appid; |
|||
private String mchid; |
|||
private String key; |
|||
private byte[] certData; |
|||
|
|||
public MyConfig(String appId,String mchId,String key,String certificate){ |
|||
this.appid = appId; |
|||
this.mchid = mchId; |
|||
this.key = key; |
|||
this.certData = certificate.getBytes(StandardCharsets.UTF_8); |
|||
} |
|||
|
|||
@Override |
|||
String getAppID() { |
|||
return appid; |
|||
} |
|||
|
|||
@Override |
|||
String getMchID() { |
|||
return mchid; |
|||
} |
|||
|
|||
@Override |
|||
InputStream getCertStream() { |
|||
return new ByteArrayInputStream(this.certData); |
|||
} |
|||
|
|||
@Override |
|||
public IWXPayDomain getWXPayDomain() { // 这个方法需要这样实现, 否则无法正常初始化WXPay
|
|||
IWXPayDomain iwxPayDomain = new IWXPayDomain() { |
|||
@Override |
|||
public void report(String domain, long elapsedTimeMillis, Exception ex) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public DomainInfo getDomain(WXPayConfig config) { |
|||
return new DomainInfo(WXPayConstants.DOMAIN_API, true); |
|||
} |
|||
}; |
|||
return iwxPayDomain; |
|||
} |
|||
|
|||
/** |
|||
* 获取沙箱密钥 |
|||
* @return |
|||
*/ |
|||
public String getSandboxSignKey() { |
|||
try { |
|||
WXPay wxPay = new WXPay(this); |
|||
Map<String, String> params = new HashMap<String, String>(); |
|||
params.put("mch_id", this.getMchID()); |
|||
params.put("nonce_str", WXPayUtil.generateNonceStr()); |
|||
params.put("sign", WXPayUtil.generateSignature(params, this.getKey())); |
|||
String strXML = wxPay.requestWithoutCert("https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey", |
|||
params, this.getHttpConnectTimeoutMs(), this.getHttpReadTimeoutMs()); |
|||
System.out.println(strXML); |
|||
Map<String, String> result = WXPayUtil.xmlToMap(strXML); |
|||
if ("SUCCESS".equals(result.get("return_code"))) { |
|||
return result.get("sandbox_signkey"); |
|||
} |
|||
return null; |
|||
} catch (Exception e) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,689 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import com.base.springcloud.wxsdk.WXPayConstants.SignType; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
public class WXPay { |
|||
|
|||
private WXPayConfig config; |
|||
private SignType signType; |
|||
private boolean autoReport; |
|||
private boolean useSandbox; |
|||
private String notifyUrl; |
|||
private WXPayRequest wxPayRequest; |
|||
|
|||
public WXPay(final WXPayConfig config){ |
|||
this(config, null, true, false); |
|||
} |
|||
|
|||
public WXPay(final WXPayConfig config, final boolean autoReport) throws Exception { |
|||
this(config, null, autoReport, false); |
|||
} |
|||
|
|||
|
|||
public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{ |
|||
this(config, null, autoReport, useSandbox); |
|||
} |
|||
|
|||
public WXPay(final WXPayConfig config, final String notifyUrl) throws Exception { |
|||
this(config, notifyUrl, true, false); |
|||
} |
|||
|
|||
public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport) throws Exception { |
|||
this(config, notifyUrl, autoReport, false); |
|||
} |
|||
|
|||
public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport, final boolean useSandbox){ |
|||
this.config = config; |
|||
this.notifyUrl = notifyUrl; |
|||
this.autoReport = autoReport; |
|||
this.useSandbox = useSandbox; |
|||
if (useSandbox) { |
|||
this.signType = SignType.MD5; // 沙箱环境
|
|||
} |
|||
else { |
|||
this.signType = SignType.HMACSHA256; |
|||
} |
|||
this.wxPayRequest = new WXPayRequest(config); |
|||
} |
|||
|
|||
private void checkWXPayConfig() throws Exception { |
|||
if (this.config == null) { |
|||
throw new Exception("config is null"); |
|||
} |
|||
if (this.config.getAppID() == null || this.config.getAppID().trim().length() == 0) { |
|||
throw new Exception("appid in config is empty"); |
|||
} |
|||
if (this.config.getMchID() == null || this.config.getMchID().trim().length() == 0) { |
|||
throw new Exception("appid in config is empty"); |
|||
} |
|||
if (this.config.getCertStream() == null) { |
|||
throw new Exception("cert stream in config is empty"); |
|||
} |
|||
if (this.config.getWXPayDomain() == null){ |
|||
throw new Exception("config.getWXPayDomain() is null"); |
|||
} |
|||
|
|||
if (this.config.getHttpConnectTimeoutMs() < 10) { |
|||
throw new Exception("http connect timeout is too small"); |
|||
} |
|||
if (this.config.getHttpReadTimeoutMs() < 10) { |
|||
throw new Exception("http read timeout is too small"); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign <br> |
|||
* 该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口 |
|||
* |
|||
* @param reqData |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> fillRequestData(Map<String, String> reqData) throws Exception { |
|||
reqData.put("appid", config.getAppID()); |
|||
reqData.put("mch_id", config.getMchID()); |
|||
reqData.put("nonce_str", WXPayUtil.generateNonceStr()); |
|||
if (SignType.MD5.equals(this.signType)) { |
|||
reqData.put("sign_type", WXPayConstants.MD5); |
|||
} |
|||
else if (SignType.HMACSHA256.equals(this.signType)) { |
|||
reqData.put("sign_type", WXPayConstants.HMACSHA256); |
|||
} |
|||
reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType)); |
|||
return reqData; |
|||
} |
|||
|
|||
/** |
|||
* 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。 |
|||
* |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return 签名是否有效 |
|||
* @throws Exception |
|||
*/ |
|||
public boolean isResponseSignatureValid(Map<String, String> reqData) throws Exception { |
|||
// 返回数据的签名方式和请求中给定的签名方式是一致的
|
|||
return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), this.signType); |
|||
} |
|||
|
|||
/** |
|||
* 判断支付结果通知中的sign是否有效 |
|||
* |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return 签名是否有效 |
|||
* @throws Exception |
|||
*/ |
|||
public boolean isPayResultNotifySignatureValid(Map<String, String> reqData) throws Exception { |
|||
String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE); |
|||
SignType signType; |
|||
if (signTypeInData == null) { |
|||
signType = SignType.MD5; |
|||
} |
|||
else { |
|||
signTypeInData = signTypeInData.trim(); |
|||
if (signTypeInData.length() == 0) { |
|||
signType = SignType.MD5; |
|||
} |
|||
else if (WXPayConstants.MD5.equals(signTypeInData)) { |
|||
signType = SignType.MD5; |
|||
} |
|||
else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) { |
|||
signType = SignType.HMACSHA256; |
|||
} |
|||
else { |
|||
throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData)); |
|||
} |
|||
} |
|||
return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), signType); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 不需要证书的请求 |
|||
* @param urlSuffix String |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public String requestWithoutCert(String urlSuffix, Map<String, String> reqData, |
|||
int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String msgUUID = reqData.get("nonce_str"); |
|||
String reqBody = WXPayUtil.mapToXml(reqData); |
|||
System.out.println("请求串:" + reqBody); |
|||
String resp = this.wxPayRequest.requestWithoutCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, autoReport); |
|||
return resp; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 需要证书的请求 |
|||
* @param urlSuffix String |
|||
* @param reqData 向wxpay post的请求数据 Map |
|||
* @param connectTimeoutMs 超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public String requestWithCert(String urlSuffix, Map<String, String> reqData, |
|||
int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String msgUUID= reqData.get("nonce_str"); |
|||
String reqBody = WXPayUtil.mapToXml(reqData); |
|||
|
|||
String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport); |
|||
return resp; |
|||
} |
|||
|
|||
/** |
|||
* 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。 |
|||
* @param xmlStr API返回的XML格式数据 |
|||
* @return Map类型数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> processResponseXml(String xmlStr) throws Exception { |
|||
String RETURN_CODE = "return_code"; |
|||
String return_code; |
|||
Map<String, String> respData = WXPayUtil.xmlToMap(xmlStr); |
|||
if (respData.containsKey(RETURN_CODE)) { |
|||
return_code = respData.get(RETURN_CODE); |
|||
} |
|||
else { |
|||
throw new Exception(String.format("No `return_code` in XML: %s", xmlStr)); |
|||
} |
|||
|
|||
if (return_code.equals(WXPayConstants.FAIL)) { |
|||
return respData; |
|||
} |
|||
else if (return_code.equals(WXPayConstants.SUCCESS)) { |
|||
if (this.isResponseSignatureValid(respData)) { |
|||
return respData; |
|||
} |
|||
else { |
|||
throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr)); |
|||
} |
|||
} |
|||
else { |
|||
throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr)); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 作用:提交刷卡支付<br> |
|||
* 场景:刷卡支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> microPay(Map<String, String> reqData) throws Exception { |
|||
return this.microPay(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:提交刷卡支付<br> |
|||
* 场景:刷卡支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> microPay(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.MICROPAY_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
/** |
|||
* 提交刷卡支付,针对软POS,尽可能做成功 |
|||
* 内置重试机制,最多60s |
|||
* @param reqData |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> microPayWithPos(Map<String, String> reqData) throws Exception { |
|||
return this.microPayWithPos(reqData, this.config.getHttpConnectTimeoutMs()); |
|||
} |
|||
|
|||
/** |
|||
* 提交刷卡支付,针对软POS,尽可能做成功 |
|||
* 内置重试机制,最多60s |
|||
* @param reqData |
|||
* @param connectTimeoutMs |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> microPayWithPos(Map<String, String> reqData, int connectTimeoutMs) throws Exception { |
|||
int remainingTimeMs = 60*1000; |
|||
long startTimestampMs = 0; |
|||
Map<String, String> lastResult = null; |
|||
Exception lastException = null; |
|||
|
|||
while (true) { |
|||
startTimestampMs = WXPayUtil.getCurrentTimestampMs(); |
|||
int readTimeoutMs = remainingTimeMs - connectTimeoutMs; |
|||
if (readTimeoutMs > 1000) { |
|||
try { |
|||
lastResult = this.microPay(reqData, connectTimeoutMs, readTimeoutMs); |
|||
String returnCode = lastResult.get("return_code"); |
|||
if (returnCode.equals("SUCCESS")) { |
|||
String resultCode = lastResult.get("result_code"); |
|||
String errCode = lastResult.get("err_code"); |
|||
if (resultCode.equals("SUCCESS")) { |
|||
break; |
|||
} |
|||
else { |
|||
// 看错误码,若支付结果未知,则重试提交刷卡支付
|
|||
if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) { |
|||
remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs); |
|||
if (remainingTimeMs <= 100) { |
|||
break; |
|||
} |
|||
else { |
|||
WXPayUtil.getLogger().info("microPayWithPos: try micropay again"); |
|||
if (remainingTimeMs > 5*1000) { |
|||
Thread.sleep(5*1000); |
|||
} |
|||
else { |
|||
Thread.sleep(1*1000); |
|||
} |
|||
continue; |
|||
} |
|||
} |
|||
else { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
break; |
|||
} |
|||
} |
|||
catch (Exception ex) { |
|||
lastResult = null; |
|||
lastException = ex; |
|||
} |
|||
} |
|||
else { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (lastResult == null) { |
|||
throw lastException; |
|||
} |
|||
else { |
|||
return lastResult; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 作用:统一下单<br> |
|||
* 场景:公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> unifiedOrder(Map<String, String> reqData) throws Exception { |
|||
return this.unifiedOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:统一下单<br> |
|||
* 场景:公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> unifiedOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX; |
|||
} |
|||
if(this.notifyUrl != null) { |
|||
reqData.put("notify_url", this.notifyUrl); |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:查询订单<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> orderQuery(Map<String, String> reqData) throws Exception { |
|||
return this.orderQuery(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:查询订单<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 int |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> orderQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.ORDERQUERY_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:撤销订单<br> |
|||
* 场景:刷卡支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> reverse(Map<String, String> reqData) throws Exception { |
|||
return this.reverse(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:撤销订单<br> |
|||
* 场景:刷卡支付<br> |
|||
* 其他:需要证书 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> reverse(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.REVERSE_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:关闭订单<br> |
|||
* 场景:公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> closeOrder(Map<String, String> reqData) throws Exception { |
|||
return this.closeOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:关闭订单<br> |
|||
* 场景:公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> closeOrder(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.CLOSEORDER_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:申请退款<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> refund(Map<String, String> reqData) throws Exception { |
|||
return this.refund(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:申请退款<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付<br> |
|||
* 其他:需要证书 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> refund(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.REFUND_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:退款查询<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> refundQuery(Map<String, String> reqData) throws Exception { |
|||
return this.refundQuery(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:退款查询<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> refundQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.REFUNDQUERY_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> downloadBill(Map<String, String> reqData) throws Exception { |
|||
return this.downloadBill(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:对账单下载<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付<br> |
|||
* 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data, |
|||
* 其中return_code为`SUCCESS`,data为对账单数据。 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return 经过封装的API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> downloadBill(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX; |
|||
} |
|||
String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim(); |
|||
Map<String, String> ret; |
|||
// 出现错误,返回XML数据
|
|||
if (respStr.indexOf("<") == 0) { |
|||
ret = WXPayUtil.xmlToMap(respStr); |
|||
} |
|||
else { |
|||
// 正常返回csv数据
|
|||
ret = new HashMap<String, String>(); |
|||
ret.put("return_code", WXPayConstants.SUCCESS); |
|||
ret.put("return_msg", "ok"); |
|||
ret.put("data", respStr); |
|||
} |
|||
return ret; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:交易保障<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> report(Map<String, String> reqData) throws Exception { |
|||
return this.report(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:交易保障<br> |
|||
* 场景:刷卡支付、公共号支付、扫码支付、APP支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> report(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.REPORT_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return WXPayUtil.xmlToMap(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:转换短链接<br> |
|||
* 场景:刷卡支付、扫码支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> shortUrl(Map<String, String> reqData) throws Exception { |
|||
return this.shortUrl(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:转换短链接<br> |
|||
* 场景:刷卡支付、扫码支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> shortUrl(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.SHORTURL_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:授权码查询OPENID接口<br> |
|||
* 场景:刷卡支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> authCodeToOpenid(Map<String, String> reqData) throws Exception { |
|||
return this.authCodeToOpenid(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs()); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 作用:授权码查询OPENID接口<br> |
|||
* 场景:刷卡支付 |
|||
* @param reqData 向wxpay post的请求数据 |
|||
* @param connectTimeoutMs 连接超时时间,单位是毫秒 |
|||
* @param readTimeoutMs 读超时时间,单位是毫秒 |
|||
* @return API返回数据 |
|||
* @throws Exception |
|||
*/ |
|||
public Map<String, String> authCodeToOpenid(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception { |
|||
String url; |
|||
if (this.useSandbox) { |
|||
url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX; |
|||
} |
|||
else { |
|||
url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX; |
|||
} |
|||
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs); |
|||
return this.processResponseXml(respXml); |
|||
} |
|||
|
|||
|
|||
} // end class
|
|||
@ -0,0 +1,103 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import java.io.InputStream; |
|||
|
|||
public abstract class WXPayConfig { |
|||
|
|||
|
|||
|
|||
/** |
|||
* 获取 App ID |
|||
* |
|||
* @return App ID |
|||
*/ |
|||
abstract String getAppID(); |
|||
|
|||
|
|||
/** |
|||
* 获取 Mch ID |
|||
* |
|||
* @return Mch ID |
|||
*/ |
|||
abstract String getMchID(); |
|||
|
|||
|
|||
/** |
|||
* 获取 API 密钥 |
|||
* |
|||
* @return API密钥 |
|||
*/ |
|||
abstract String getKey(); |
|||
|
|||
|
|||
/** |
|||
* 获取商户证书内容 |
|||
* |
|||
* @return 商户证书内容 |
|||
*/ |
|||
abstract InputStream getCertStream(); |
|||
|
|||
/** |
|||
* HTTP(S) 连接超时时间,单位毫秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
public int getHttpConnectTimeoutMs() { |
|||
return 6*1000; |
|||
} |
|||
|
|||
/** |
|||
* HTTP(S) 读数据超时时间,单位毫秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
public int getHttpReadTimeoutMs() { |
|||
return 8*1000; |
|||
} |
|||
|
|||
/** |
|||
* 获取WXPayDomain, 用于多域名容灾自动切换 |
|||
* @return |
|||
*/ |
|||
abstract IWXPayDomain getWXPayDomain(); |
|||
|
|||
/** |
|||
* 是否自动上报。 |
|||
* 若要关闭自动上报,子类中实现该函数返回 false 即可。 |
|||
* |
|||
* @return |
|||
*/ |
|||
public boolean shouldAutoReport() { |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 进行健康上报的线程的数量 |
|||
* |
|||
* @return |
|||
*/ |
|||
public int getReportWorkerNum() { |
|||
return 6; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 健康上报缓存消息的最大数量。会有线程去独立上报 |
|||
* 粗略计算:加入一条消息200B,10000消息占用空间 2000 KB,约为2MB,可以接受 |
|||
* |
|||
* @return |
|||
*/ |
|||
public int getReportQueueMaxSize() { |
|||
return 10000; |
|||
} |
|||
|
|||
/** |
|||
* 批量上报,一次最多上报多个数据 |
|||
* |
|||
* @return |
|||
*/ |
|||
public int getReportBatchSize() { |
|||
return 10; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import org.apache.http.client.HttpClient; |
|||
|
|||
/** |
|||
* 常量 |
|||
*/ |
|||
public class WXPayConstants { |
|||
|
|||
public enum SignType { |
|||
MD5, HMACSHA256 |
|||
} |
|||
|
|||
public static final String DOMAIN_API = "api.mch.weixin.qq.com"; |
|||
public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com"; |
|||
public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com"; |
|||
public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com"; |
|||
|
|||
|
|||
public static final String FAIL = "FAIL"; |
|||
public static final String SUCCESS = "SUCCESS"; |
|||
public static final String HMACSHA256 = "HMAC-SHA256"; |
|||
public static final String MD5 = "MD5"; |
|||
|
|||
public static final String FIELD_SIGN = "sign"; |
|||
public static final String FIELD_SIGN_TYPE = "sign_type"; |
|||
|
|||
public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9"; |
|||
public static final String USER_AGENT = WXPAYSDK_VERSION + |
|||
" (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") + |
|||
") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion(); |
|||
|
|||
public static final String MICROPAY_URL_SUFFIX = "/pay/micropay"; |
|||
public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder"; |
|||
public static final String ORDERQUERY_URL_SUFFIX = "/pay/orderquery"; |
|||
public static final String REVERSE_URL_SUFFIX = "/secapi/pay/reverse"; |
|||
public static final String CLOSEORDER_URL_SUFFIX = "/pay/closeorder"; |
|||
public static final String REFUND_URL_SUFFIX = "/secapi/pay/refund"; |
|||
public static final String REFUNDQUERY_URL_SUFFIX = "/pay/refundquery"; |
|||
public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill"; |
|||
public static final String REPORT_URL_SUFFIX = "/payitil/report"; |
|||
public static final String SHORTURL_URL_SUFFIX = "/tools/shorturl"; |
|||
public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid"; |
|||
|
|||
// sandbox
|
|||
public static final String SANDBOX_MICROPAY_URL_SUFFIX = "/sandboxnew/pay/micropay"; |
|||
public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder"; |
|||
public static final String SANDBOX_ORDERQUERY_URL_SUFFIX = "/sandboxnew/pay/orderquery"; |
|||
public static final String SANDBOX_REVERSE_URL_SUFFIX = "/sandboxnew/secapi/pay/reverse"; |
|||
public static final String SANDBOX_CLOSEORDER_URL_SUFFIX = "/sandboxnew/pay/closeorder"; |
|||
public static final String SANDBOX_REFUND_URL_SUFFIX = "/sandboxnew/secapi/pay/refund"; |
|||
public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX = "/sandboxnew/pay/refundquery"; |
|||
public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill"; |
|||
public static final String SANDBOX_REPORT_URL_SUFFIX = "/sandboxnew/payitil/report"; |
|||
public static final String SANDBOX_SHORTURL_URL_SUFFIX = "/sandboxnew/tools/shorturl"; |
|||
public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid"; |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,265 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.client.HttpClient; |
|||
import org.apache.http.client.config.RequestConfig; |
|||
import org.apache.http.client.methods.HttpPost; |
|||
import org.apache.http.config.RegistryBuilder; |
|||
import org.apache.http.conn.socket.ConnectionSocketFactory; |
|||
import org.apache.http.conn.socket.PlainConnectionSocketFactory; |
|||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|||
import org.apache.http.entity.StringEntity; |
|||
import org.apache.http.impl.client.HttpClientBuilder; |
|||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager; |
|||
import org.apache.http.util.EntityUtils; |
|||
|
|||
import java.util.concurrent.ExecutorService; |
|||
import java.util.concurrent.Executors; |
|||
import java.util.concurrent.LinkedBlockingQueue; |
|||
import java.util.concurrent.ThreadFactory; |
|||
|
|||
/** |
|||
* 交易保障 |
|||
*/ |
|||
public class WXPayReport { |
|||
|
|||
public static class ReportInfo { |
|||
|
|||
/** |
|||
* 布尔变量使用int。0为false, 1为true。 |
|||
*/ |
|||
|
|||
// 基本信息
|
|||
private String version = "v1"; |
|||
private String sdk = WXPayConstants.WXPAYSDK_VERSION; |
|||
private String uuid; // 交易的标识
|
|||
private long timestamp; // 上报时的时间戳,单位秒
|
|||
private long elapsedTimeMillis; // 耗时,单位 毫秒
|
|||
|
|||
// 针对主域名
|
|||
private String firstDomain; // 第1次请求的域名
|
|||
private boolean primaryDomain; //是否主域名
|
|||
private int firstConnectTimeoutMillis; // 第1次请求设置的连接超时时间,单位 毫秒
|
|||
private int firstReadTimeoutMillis; // 第1次请求设置的读写超时时间,单位 毫秒
|
|||
private int firstHasDnsError; // 第1次请求是否出现dns问题
|
|||
private int firstHasConnectTimeout; // 第1次请求是否出现连接超时
|
|||
private int firstHasReadTimeout; // 第1次请求是否出现连接超时
|
|||
|
|||
public ReportInfo(String uuid, long timestamp, long elapsedTimeMillis, String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis, boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) { |
|||
this.uuid = uuid; |
|||
this.timestamp = timestamp; |
|||
this.elapsedTimeMillis = elapsedTimeMillis; |
|||
this.firstDomain = firstDomain; |
|||
this.primaryDomain = primaryDomain; |
|||
this.firstConnectTimeoutMillis = firstConnectTimeoutMillis; |
|||
this.firstReadTimeoutMillis = firstReadTimeoutMillis; |
|||
this.firstHasDnsError = firstHasDnsError?1:0; |
|||
this.firstHasConnectTimeout = firstHasConnectTimeout?1:0; |
|||
this.firstHasReadTimeout = firstHasReadTimeout?1:0; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "ReportInfo{" + |
|||
"version='" + version + '\'' + |
|||
", sdk='" + sdk + '\'' + |
|||
", uuid='" + uuid + '\'' + |
|||
", timestamp=" + timestamp + |
|||
", elapsedTimeMillis=" + elapsedTimeMillis + |
|||
", firstDomain='" + firstDomain + '\'' + |
|||
", primaryDomain=" + primaryDomain + |
|||
", firstConnectTimeoutMillis=" + firstConnectTimeoutMillis + |
|||
", firstReadTimeoutMillis=" + firstReadTimeoutMillis + |
|||
", firstHasDnsError=" + firstHasDnsError + |
|||
", firstHasConnectTimeout=" + firstHasConnectTimeout + |
|||
", firstHasReadTimeout=" + firstHasReadTimeout + |
|||
'}'; |
|||
} |
|||
|
|||
/** |
|||
* 转换成 csv 格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public String toLineString(String key) { |
|||
String separator = ","; |
|||
Object[] objects = new Object[] { |
|||
version, sdk, uuid, timestamp, elapsedTimeMillis, |
|||
firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis, |
|||
firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout |
|||
}; |
|||
StringBuffer sb = new StringBuffer(); |
|||
for(Object obj: objects) { |
|||
sb.append(obj).append(separator); |
|||
} |
|||
try { |
|||
String sign = WXPayUtil.HMACSHA256(sb.toString(), key); |
|||
sb.append(sign); |
|||
return sb.toString(); |
|||
} |
|||
catch (Exception ex) { |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
private static final String REPORT_URL = "http://report.mch.weixin.qq.com/wxpay/report/default"; |
|||
// private static final String REPORT_URL = "http://127.0.0.1:5000/test";
|
|||
|
|||
|
|||
private static final int DEFAULT_CONNECT_TIMEOUT_MS = 6*1000; |
|||
private static final int DEFAULT_READ_TIMEOUT_MS = 8*1000; |
|||
|
|||
private LinkedBlockingQueue<String> reportMsgQueue = null; |
|||
private WXPayConfig config; |
|||
private ExecutorService executorService; |
|||
|
|||
private volatile static WXPayReport INSTANCE; |
|||
|
|||
private WXPayReport(final WXPayConfig config) { |
|||
this.config = config; |
|||
reportMsgQueue = new LinkedBlockingQueue<String>(config.getReportQueueMaxSize()); |
|||
|
|||
// 添加处理线程
|
|||
executorService = Executors.newFixedThreadPool(config.getReportWorkerNum(), new ThreadFactory() { |
|||
public Thread newThread(Runnable r) { |
|||
Thread t = Executors.defaultThreadFactory().newThread(r); |
|||
t.setDaemon(true); |
|||
return t; |
|||
} |
|||
}); |
|||
|
|||
if (config.shouldAutoReport()) { |
|||
WXPayUtil.getLogger().info("report worker num: {}", config.getReportWorkerNum()); |
|||
for (int i = 0; i < config.getReportWorkerNum(); ++i) { |
|||
executorService.execute(new Runnable() { |
|||
public void run() { |
|||
while (true) { |
|||
// 先用 take 获取数据
|
|||
try { |
|||
StringBuffer sb = new StringBuffer(); |
|||
String firstMsg = reportMsgQueue.take(); |
|||
WXPayUtil.getLogger().info("get first report msg: {}", firstMsg); |
|||
String msg = null; |
|||
sb.append(firstMsg); //会阻塞至有消息
|
|||
int remainNum = config.getReportBatchSize() - 1; |
|||
for (int j=0; j<remainNum; ++j) { |
|||
WXPayUtil.getLogger().info("try get remain report msg"); |
|||
// msg = reportMsgQueue.poll(); // 不阻塞了
|
|||
msg = reportMsgQueue.take(); |
|||
WXPayUtil.getLogger().info("get remain report msg: {}", msg); |
|||
if (msg == null) { |
|||
break; |
|||
} |
|||
else { |
|||
sb.append("\n"); |
|||
sb.append(msg); |
|||
} |
|||
} |
|||
// 上报
|
|||
WXPayReport.httpRequest(sb.toString(), DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS); |
|||
} |
|||
catch (Exception ex) { |
|||
WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 单例,双重校验,请在 JDK 1.5及更高版本中使用 |
|||
* |
|||
* @param config |
|||
* @return |
|||
*/ |
|||
public static WXPayReport getInstance(WXPayConfig config) { |
|||
if (INSTANCE == null) { |
|||
synchronized (WXPayReport.class) { |
|||
if (INSTANCE == null) { |
|||
INSTANCE = new WXPayReport(config); |
|||
} |
|||
} |
|||
} |
|||
return INSTANCE; |
|||
} |
|||
|
|||
public void report(String uuid, long elapsedTimeMillis, |
|||
String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis, |
|||
boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) { |
|||
long currentTimestamp = WXPayUtil.getCurrentTimestamp(); |
|||
ReportInfo reportInfo = new ReportInfo(uuid, currentTimestamp, elapsedTimeMillis, |
|||
firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis, |
|||
firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout); |
|||
String data = reportInfo.toLineString(config.getKey()); |
|||
WXPayUtil.getLogger().info("report {}", data); |
|||
if (data != null) { |
|||
reportMsgQueue.offer(data); |
|||
} |
|||
} |
|||
|
|||
|
|||
@Deprecated |
|||
private void reportSync(final String data) throws Exception { |
|||
httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS); |
|||
} |
|||
|
|||
@Deprecated |
|||
private void reportAsync(final String data) throws Exception { |
|||
new Thread(new Runnable() { |
|||
public void run() { |
|||
try { |
|||
httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS); |
|||
} |
|||
catch (Exception ex) { |
|||
WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage()); |
|||
} |
|||
} |
|||
}).start(); |
|||
} |
|||
|
|||
/** |
|||
* http 请求 |
|||
* @param data |
|||
* @param connectTimeoutMs |
|||
* @param readTimeoutMs |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
private static String httpRequest(String data, int connectTimeoutMs, int readTimeoutMs) throws Exception{ |
|||
BasicHttpClientConnectionManager connManager; |
|||
connManager = new BasicHttpClientConnectionManager( |
|||
RegistryBuilder.<ConnectionSocketFactory>create() |
|||
.register("http", PlainConnectionSocketFactory.getSocketFactory()) |
|||
.register("https", SSLConnectionSocketFactory.getSocketFactory()) |
|||
.build(), |
|||
null, |
|||
null, |
|||
null |
|||
); |
|||
HttpClient httpClient = HttpClientBuilder.create() |
|||
.setConnectionManager(connManager) |
|||
.build(); |
|||
|
|||
HttpPost httpPost = new HttpPost(REPORT_URL); |
|||
|
|||
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build(); |
|||
httpPost.setConfig(requestConfig); |
|||
|
|||
StringEntity postEntity = new StringEntity(data, "UTF-8"); |
|||
httpPost.addHeader("Content-Type", "text/xml"); |
|||
httpPost.addHeader("User-Agent", WXPayConstants.USER_AGENT); |
|||
httpPost.setEntity(postEntity); |
|||
|
|||
HttpResponse httpResponse = httpClient.execute(httpPost); |
|||
HttpEntity httpEntity = httpResponse.getEntity(); |
|||
return EntityUtils.toString(httpEntity, "UTF-8"); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,257 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import org.apache.http.HttpEntity; |
|||
import org.apache.http.HttpResponse; |
|||
import org.apache.http.client.HttpClient; |
|||
import org.apache.http.client.config.RequestConfig; |
|||
import org.apache.http.client.methods.HttpPost; |
|||
import org.apache.http.config.RegistryBuilder; |
|||
import org.apache.http.conn.ConnectTimeoutException; |
|||
import org.apache.http.conn.socket.ConnectionSocketFactory; |
|||
import org.apache.http.conn.socket.PlainConnectionSocketFactory; |
|||
import org.apache.http.conn.ssl.DefaultHostnameVerifier; |
|||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|||
import org.apache.http.entity.StringEntity; |
|||
import org.apache.http.impl.client.HttpClientBuilder; |
|||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager; |
|||
import org.apache.http.util.EntityUtils; |
|||
|
|||
import javax.net.ssl.KeyManagerFactory; |
|||
import javax.net.ssl.SSLContext; |
|||
import java.io.InputStream; |
|||
import java.net.SocketTimeoutException; |
|||
import java.net.UnknownHostException; |
|||
import java.security.KeyStore; |
|||
import java.security.SecureRandom; |
|||
import static com.base.springcloud.wxsdk.WXPayConstants.USER_AGENT; |
|||
|
|||
public class WXPayRequest { |
|||
private WXPayConfig config; |
|||
public WXPayRequest(WXPayConfig config){ |
|||
|
|||
this.config = config; |
|||
} |
|||
|
|||
/** |
|||
* 请求,只请求一次,不做重试 |
|||
* @param domain |
|||
* @param urlSuffix |
|||
* @param uuid |
|||
* @param data |
|||
* @param connectTimeoutMs |
|||
* @param readTimeoutMs |
|||
* @param useCert 是否使用证书,针对退款、撤销等操作 |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
private String requestOnce(final String domain, String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert) throws Exception { |
|||
BasicHttpClientConnectionManager connManager; |
|||
if (useCert) { |
|||
// 证书
|
|||
char[] password = config.getMchID().toCharArray(); |
|||
InputStream certStream = config.getCertStream(); |
|||
KeyStore ks = KeyStore.getInstance("PKCS12"); |
|||
ks.load(certStream, password); |
|||
|
|||
// 实例化密钥库 & 初始化密钥工厂
|
|||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); |
|||
kmf.init(ks, password); |
|||
|
|||
// 创建 SSLContext
|
|||
SSLContext sslContext = SSLContext.getInstance("TLS"); |
|||
sslContext.init(kmf.getKeyManagers(), null, new SecureRandom()); |
|||
|
|||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory( |
|||
sslContext, |
|||
new String[]{"TLSv1"}, |
|||
null, |
|||
new DefaultHostnameVerifier()); |
|||
|
|||
connManager = new BasicHttpClientConnectionManager( |
|||
RegistryBuilder.<ConnectionSocketFactory>create() |
|||
.register("http", PlainConnectionSocketFactory.getSocketFactory()) |
|||
.register("https", sslConnectionSocketFactory) |
|||
.build(), |
|||
null, |
|||
null, |
|||
null |
|||
); |
|||
} |
|||
else { |
|||
connManager = new BasicHttpClientConnectionManager( |
|||
RegistryBuilder.<ConnectionSocketFactory>create() |
|||
.register("http", PlainConnectionSocketFactory.getSocketFactory()) |
|||
.register("https", SSLConnectionSocketFactory.getSocketFactory()) |
|||
.build(), |
|||
null, |
|||
null, |
|||
null |
|||
); |
|||
} |
|||
|
|||
HttpClient httpClient = HttpClientBuilder.create() |
|||
.setConnectionManager(connManager) |
|||
.build(); |
|||
|
|||
String url = "https://" + domain + urlSuffix; |
|||
HttpPost httpPost = new HttpPost(url); |
|||
|
|||
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build(); |
|||
httpPost.setConfig(requestConfig); |
|||
|
|||
StringEntity postEntity = new StringEntity(data, "UTF-8"); |
|||
httpPost.addHeader("Content-Type", "text/xml"); |
|||
httpPost.addHeader("User-Agent", USER_AGENT + " " + config.getMchID()); |
|||
httpPost.setEntity(postEntity); |
|||
|
|||
HttpResponse httpResponse = httpClient.execute(httpPost); |
|||
HttpEntity httpEntity = httpResponse.getEntity(); |
|||
return EntityUtils.toString(httpEntity, "UTF-8"); |
|||
|
|||
} |
|||
|
|||
|
|||
private String request(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert, boolean autoReport) throws Exception { |
|||
Exception exception = null; |
|||
long elapsedTimeMillis = 0; |
|||
long startTimestampMs = WXPayUtil.getCurrentTimestampMs(); |
|||
boolean firstHasDnsErr = false; |
|||
boolean firstHasConnectTimeout = false; |
|||
boolean firstHasReadTimeout = false; |
|||
IWXPayDomain.DomainInfo domainInfo = config.getWXPayDomain().getDomain(config); |
|||
if(domainInfo == null){ |
|||
throw new Exception("WXPayConfig.getWXPayDomain().getDomain() is empty or null"); |
|||
} |
|||
try { |
|||
String result = requestOnce(domainInfo.domain, urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, useCert); |
|||
elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs; |
|||
config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, null); |
|||
WXPayReport.getInstance(config).report( |
|||
uuid, |
|||
elapsedTimeMillis, |
|||
domainInfo.domain, |
|||
domainInfo.primaryDomain, |
|||
connectTimeoutMs, |
|||
readTimeoutMs, |
|||
firstHasDnsErr, |
|||
firstHasConnectTimeout, |
|||
firstHasReadTimeout); |
|||
return result; |
|||
} |
|||
catch (UnknownHostException ex) { // dns 解析错误,或域名不存在
|
|||
exception = ex; |
|||
firstHasDnsErr = true; |
|||
elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs; |
|||
WXPayUtil.getLogger().warn("UnknownHostException for domainInfo {}", domainInfo); |
|||
WXPayReport.getInstance(config).report( |
|||
uuid, |
|||
elapsedTimeMillis, |
|||
domainInfo.domain, |
|||
domainInfo.primaryDomain, |
|||
connectTimeoutMs, |
|||
readTimeoutMs, |
|||
firstHasDnsErr, |
|||
firstHasConnectTimeout, |
|||
firstHasReadTimeout |
|||
); |
|||
} |
|||
catch (ConnectTimeoutException ex) { |
|||
exception = ex; |
|||
firstHasConnectTimeout = true; |
|||
elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs; |
|||
WXPayUtil.getLogger().warn("connect timeout happened for domainInfo {}", domainInfo); |
|||
WXPayReport.getInstance(config).report( |
|||
uuid, |
|||
elapsedTimeMillis, |
|||
domainInfo.domain, |
|||
domainInfo.primaryDomain, |
|||
connectTimeoutMs, |
|||
readTimeoutMs, |
|||
firstHasDnsErr, |
|||
firstHasConnectTimeout, |
|||
firstHasReadTimeout |
|||
); |
|||
} |
|||
catch (SocketTimeoutException ex) { |
|||
exception = ex; |
|||
firstHasReadTimeout = true; |
|||
elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs; |
|||
WXPayUtil.getLogger().warn("timeout happened for domainInfo {}", domainInfo); |
|||
WXPayReport.getInstance(config).report( |
|||
uuid, |
|||
elapsedTimeMillis, |
|||
domainInfo.domain, |
|||
domainInfo.primaryDomain, |
|||
connectTimeoutMs, |
|||
readTimeoutMs, |
|||
firstHasDnsErr, |
|||
firstHasConnectTimeout, |
|||
firstHasReadTimeout); |
|||
} |
|||
catch (Exception ex) { |
|||
exception = ex; |
|||
elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs; |
|||
WXPayReport.getInstance(config).report( |
|||
uuid, |
|||
elapsedTimeMillis, |
|||
domainInfo.domain, |
|||
domainInfo.primaryDomain, |
|||
connectTimeoutMs, |
|||
readTimeoutMs, |
|||
firstHasDnsErr, |
|||
firstHasConnectTimeout, |
|||
firstHasReadTimeout); |
|||
} |
|||
config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, exception); |
|||
throw exception; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 可重试的,非双向认证的请求 |
|||
* @param urlSuffix |
|||
* @param uuid |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public String requestWithoutCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception { |
|||
return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), false, autoReport); |
|||
} |
|||
|
|||
/** |
|||
* 可重试的,非双向认证的请求 |
|||
* @param urlSuffix |
|||
* @param uuid |
|||
* @param data |
|||
* @param connectTimeoutMs |
|||
* @param readTimeoutMs |
|||
* @return |
|||
*/ |
|||
public String requestWithoutCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception { |
|||
return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, false, autoReport); |
|||
} |
|||
|
|||
/** |
|||
* 可重试的,双向认证的请求 |
|||
* @param urlSuffix |
|||
* @param uuid |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public String requestWithCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception { |
|||
return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), true, autoReport); |
|||
} |
|||
|
|||
/** |
|||
* 可重试的,双向认证的请求 |
|||
* @param urlSuffix |
|||
* @param uuid |
|||
* @param data |
|||
* @param connectTimeoutMs |
|||
* @param readTimeoutMs |
|||
* @return |
|||
*/ |
|||
public String requestWithCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception { |
|||
return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, true, autoReport); |
|||
} |
|||
} |
|||
@ -0,0 +1,298 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import com.base.springcloud.wxsdk.WXPayConstants.SignType; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.w3c.dom.Node; |
|||
import org.w3c.dom.NodeList; |
|||
|
|||
import javax.crypto.Mac; |
|||
import javax.crypto.spec.SecretKeySpec; |
|||
import javax.xml.parsers.DocumentBuilder; |
|||
import javax.xml.transform.OutputKeys; |
|||
import javax.xml.transform.Transformer; |
|||
import javax.xml.transform.TransformerFactory; |
|||
import javax.xml.transform.dom.DOMSource; |
|||
import javax.xml.transform.stream.StreamResult; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.InputStream; |
|||
import java.io.StringWriter; |
|||
import java.security.MessageDigest; |
|||
import java.security.SecureRandom; |
|||
import java.util.*; |
|||
|
|||
|
|||
public class WXPayUtil { |
|||
|
|||
private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|||
|
|||
private static final Random RANDOM = new SecureRandom(); |
|||
|
|||
/** |
|||
* XML格式字符串转换为Map |
|||
* |
|||
* @param strXML XML字符串 |
|||
* @return XML数据转换后的Map |
|||
* @throws Exception |
|||
*/ |
|||
public static Map<String, String> xmlToMap(String strXML) throws Exception { |
|||
try { |
|||
Map<String, String> data = new HashMap<String, String>(); |
|||
DocumentBuilder documentBuilder = WXPayXmlUtil.newDocumentBuilder(); |
|||
InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8")); |
|||
org.w3c.dom.Document doc = documentBuilder.parse(stream); |
|||
doc.getDocumentElement().normalize(); |
|||
NodeList nodeList = doc.getDocumentElement().getChildNodes(); |
|||
for (int idx = 0; idx < nodeList.getLength(); ++idx) { |
|||
Node node = nodeList.item(idx); |
|||
if (node.getNodeType() == Node.ELEMENT_NODE) { |
|||
org.w3c.dom.Element element = (org.w3c.dom.Element) node; |
|||
data.put(element.getNodeName(), element.getTextContent()); |
|||
} |
|||
} |
|||
try { |
|||
stream.close(); |
|||
} catch (Exception ex) { |
|||
// do nothing
|
|||
} |
|||
return data; |
|||
} catch (Exception ex) { |
|||
WXPayUtil.getLogger().warn("Invalid XML, can not convert to map. Error message: {}. XML content: {}", ex.getMessage(), strXML); |
|||
throw ex; |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将Map转换为XML格式的字符串 |
|||
* |
|||
* @param data Map类型数据 |
|||
* @return XML格式的字符串 |
|||
* @throws Exception |
|||
*/ |
|||
public static String mapToXml(Map<String, String> data) throws Exception { |
|||
org.w3c.dom.Document document = WXPayXmlUtil.newDocument(); |
|||
org.w3c.dom.Element root = document.createElement("xml"); |
|||
document.appendChild(root); |
|||
for (String key: data.keySet()) { |
|||
String value = data.get(key); |
|||
if (value == null) { |
|||
value = ""; |
|||
} |
|||
value = value.trim(); |
|||
org.w3c.dom.Element filed = document.createElement(key); |
|||
filed.appendChild(document.createTextNode(value)); |
|||
root.appendChild(filed); |
|||
} |
|||
TransformerFactory tf = TransformerFactory.newInstance(); |
|||
Transformer transformer = tf.newTransformer(); |
|||
DOMSource source = new DOMSource(document); |
|||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); |
|||
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
|||
StringWriter writer = new StringWriter(); |
|||
StreamResult result = new StreamResult(writer); |
|||
transformer.transform(source, result); |
|||
String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
|
|||
try { |
|||
writer.close(); |
|||
} |
|||
catch (Exception ex) { |
|||
} |
|||
return output; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 生成带有 sign 的 XML 格式字符串 |
|||
* |
|||
* @param data Map类型数据 |
|||
* @param key API密钥 |
|||
* @return 含有sign字段的XML |
|||
*/ |
|||
public static String generateSignedXml(final Map<String, String> data, String key) throws Exception { |
|||
return generateSignedXml(data, key, SignType.MD5); |
|||
} |
|||
|
|||
/** |
|||
* 生成带有 sign 的 XML 格式字符串 |
|||
* |
|||
* @param data Map类型数据 |
|||
* @param key API密钥 |
|||
* @param signType 签名类型 |
|||
* @return 含有sign字段的XML |
|||
*/ |
|||
public static String generateSignedXml(final Map<String, String> data, String key, SignType signType) throws Exception { |
|||
String sign = generateSignature(data, key, signType); |
|||
data.put(WXPayConstants.FIELD_SIGN, sign); |
|||
return mapToXml(data); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 判断签名是否正确 |
|||
* |
|||
* @param xmlStr XML格式数据 |
|||
* @param key API密钥 |
|||
* @return 签名是否正确 |
|||
* @throws Exception |
|||
*/ |
|||
public static boolean isSignatureValid(String xmlStr, String key) throws Exception { |
|||
Map<String, String> data = xmlToMap(xmlStr); |
|||
if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) { |
|||
return false; |
|||
} |
|||
String sign = data.get(WXPayConstants.FIELD_SIGN); |
|||
return generateSignature(data, key).equals(sign); |
|||
} |
|||
|
|||
/** |
|||
* 判断签名是否正确,必须包含sign字段,否则返回false。使用MD5签名。 |
|||
* |
|||
* @param data Map类型数据 |
|||
* @param key API密钥 |
|||
* @return 签名是否正确 |
|||
* @throws Exception |
|||
*/ |
|||
public static boolean isSignatureValid(Map<String, String> data, String key) throws Exception { |
|||
return isSignatureValid(data, key, SignType.MD5); |
|||
} |
|||
|
|||
/** |
|||
* 判断签名是否正确,必须包含sign字段,否则返回false。 |
|||
* |
|||
* @param data Map类型数据 |
|||
* @param key API密钥 |
|||
* @param signType 签名方式 |
|||
* @return 签名是否正确 |
|||
* @throws Exception |
|||
*/ |
|||
public static boolean isSignatureValid(Map<String, String> data, String key, SignType signType) throws Exception { |
|||
if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) { |
|||
return false; |
|||
} |
|||
String sign = data.get(WXPayConstants.FIELD_SIGN); |
|||
return generateSignature(data, key, signType).equals(sign); |
|||
} |
|||
|
|||
/** |
|||
* 生成签名 |
|||
* |
|||
* @param data 待签名数据 |
|||
* @param key API密钥 |
|||
* @return 签名 |
|||
*/ |
|||
public static String generateSignature(final Map<String, String> data, String key) throws Exception { |
|||
return generateSignature(data, key, SignType.MD5); |
|||
} |
|||
|
|||
/** |
|||
* 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 |
|||
* |
|||
* @param data 待签名数据 |
|||
* @param key API密钥 |
|||
* @param signType 签名方式 |
|||
* @return 签名 |
|||
*/ |
|||
public static String generateSignature(final Map<String, String> data, String key, SignType signType) throws Exception { |
|||
Set<String> keySet = data.keySet(); |
|||
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
|||
Arrays.sort(keyArray); |
|||
StringBuilder sb = new StringBuilder(); |
|||
for (String k : keyArray) { |
|||
if (k.equals(WXPayConstants.FIELD_SIGN)) { |
|||
continue; |
|||
} |
|||
if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名
|
|||
sb.append(k).append("=").append(data.get(k).trim()).append("&"); |
|||
} |
|||
sb.append("key=").append(key); |
|||
//String signDate = sb.toString().substring(0,sb.toString().length() -1);
|
|||
//System.out.println("签名串:" + signDate);
|
|||
if (SignType.MD5.equals(signType)) { |
|||
return MD5(sb.toString()).toUpperCase(); |
|||
} |
|||
else if (SignType.HMACSHA256.equals(signType)) { |
|||
return HMACSHA256(sb.toString(), key); |
|||
} |
|||
else { |
|||
throw new Exception(String.format("Invalid sign_type: %s", signType)); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取随机字符串 Nonce Str |
|||
* |
|||
* @return String 随机字符串 |
|||
*/ |
|||
public static String generateNonceStr() { |
|||
char[] nonceChars = new char[32]; |
|||
for (int index = 0; index < nonceChars.length; ++index) { |
|||
nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); |
|||
} |
|||
return new String(nonceChars); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 生成 MD5 |
|||
* |
|||
* @param data 待处理数据 |
|||
* @return MD5结果 |
|||
*/ |
|||
public static String MD5(String data) throws Exception { |
|||
MessageDigest md = MessageDigest.getInstance("MD5"); |
|||
byte[] array = md.digest(data.getBytes("UTF-8")); |
|||
StringBuilder sb = new StringBuilder(); |
|||
for (byte item : array) { |
|||
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); |
|||
} |
|||
return sb.toString().toUpperCase(); |
|||
} |
|||
|
|||
/** |
|||
* 生成 HMACSHA256 |
|||
* @param data 待处理数据 |
|||
* @param key 密钥 |
|||
* @return 加密结果 |
|||
* @throws Exception |
|||
*/ |
|||
public static String HMACSHA256(String data, String key) throws Exception { |
|||
System.out.println("签名串:"+data); |
|||
Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); |
|||
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256"); |
|||
sha256_HMAC.init(secret_key); |
|||
byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); |
|||
StringBuilder sb = new StringBuilder(); |
|||
for (byte item : array) { |
|||
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); |
|||
} |
|||
return sb.toString().toUpperCase(); |
|||
} |
|||
|
|||
/** |
|||
* 日志 |
|||
* @return |
|||
*/ |
|||
public static Logger getLogger() { |
|||
Logger logger = LoggerFactory.getLogger("wxpay java sdk"); |
|||
return logger; |
|||
} |
|||
|
|||
/** |
|||
* 获取当前时间戳,单位秒 |
|||
* @return |
|||
*/ |
|||
public static long getCurrentTimestamp() { |
|||
return System.currentTimeMillis()/1000; |
|||
} |
|||
|
|||
/** |
|||
* 获取当前时间戳,单位毫秒 |
|||
* @return |
|||
*/ |
|||
public static long getCurrentTimestampMs() { |
|||
return System.currentTimeMillis(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.base.springcloud.wxsdk; |
|||
|
|||
import org.w3c.dom.Document; |
|||
|
|||
import javax.xml.XMLConstants; |
|||
import javax.xml.parsers.DocumentBuilder; |
|||
import javax.xml.parsers.DocumentBuilderFactory; |
|||
import javax.xml.parsers.ParserConfigurationException; |
|||
|
|||
public final class WXPayXmlUtil { |
|||
public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { |
|||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); |
|||
documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
|||
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); |
|||
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); |
|||
documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); |
|||
documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); |
|||
documentBuilderFactory.setXIncludeAware(false); |
|||
documentBuilderFactory.setExpandEntityReferences(false); |
|||
|
|||
return documentBuilderFactory.newDocumentBuilder(); |
|||
} |
|||
|
|||
public static Document newDocument() throws ParserConfigurationException { |
|||
return newDocumentBuilder().newDocument(); |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
server: |
|||
port: 5080 #服务端口 |
|||
servlet: |
|||
context-path: /rbs-pay |
|||
#spring相关配置 |
|||
spring: |
|||
application: |
|||
name: mcroservice-payment #服务名 |
|||
datasource: |
|||
type: com.alibaba.druid.pool.DruidDataSource #当前数据源操作类型 |
|||
driver-class-name: org.gjt.mm.mysql.Driver #数据库驱动包 |
|||
url: jdbc:mysql://106.14.81.251:3306/rbs_erp_test?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false |
|||
username: root |
|||
password: hnrr%%360 |
|||
#rabbitmq 配置 |
|||
#rabbitmq: |
|||
#host: localhost |
|||
#port: 5672 |
|||
#username: rbs-payment |
|||
#password: pay123123 |
|||
# redis 配置 |
|||
redis: |
|||
database: 1 |
|||
host: 47.102.131.171 |
|||
lettuce: |
|||
pool: |
|||
max-active: 8 #最大连接数据库连接数,设 0 为没有限制 |
|||
max-idle: 8 #最大等待连接中的数量,设 0 为没有限制 |
|||
max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。 |
|||
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制 |
|||
shutdown-timeout: 100ms |
|||
password: Redis@CS0731 |
|||
port: 6200 |
|||
#JimuReport[上传配置] |
|||
jeecg: |
|||
# local|minio|alioss |
|||
uploadType: alioss |
|||
# local |
|||
path: |
|||
#文件路径 |
|||
upload: /opt/upload |
|||
# alioss |
|||
oss: |
|||
staticDomain: http://rrimage.oss-cn-beijing.aliyuncs.com |
|||
endpoint: oss-cn-beijing.aliyuncs.com |
|||
accessKey: LTAIFKTe6ghqO5q2 |
|||
secretKey: 8rhlQcMggzfx5jIWpMK8idayrHungs |
|||
bucketName: rrimage |
|||
# minio |
|||
minio: |
|||
minio_url: http://minio.jeecg.com |
|||
minio_name: ?? |
|||
minio_pass: ?? |
|||
bucketName: ?? |
|||
cache: |
|||
type: simple |
|||
servlet: |
|||
multipart : |
|||
max-request-size : 10MB |
|||
max-file-size : 10MB |
|||
#mybatis:配置 |
|||
mybatis: |
|||
type-aliases-package: com.base.springcloud.dao #实体类包路径 |
|||
mapper-locations: classpath*:com/base/payment/mapper/*.xml #mapper.xml路径 |
|||
@ -1,57 +1,3 @@ |
|||
server: |
|||
port: 5080 #服务端口 |
|||
servlet: |
|||
context-path: /rbs-pay |
|||
#spring相关配置 |
|||
spring: |
|||
application: |
|||
name: mcroservice-payment #服务名 |
|||
datasource: |
|||
type: com.alibaba.druid.pool.DruidDataSource #当前数据源操作类型 |
|||
driver-class-name: org.gjt.mm.mysql.Driver #数据库驱动包 |
|||
url: jdbc:mysql://rm-uf672osw4deemr4yt.mysql.rds.aliyuncs.com:3306/rbs_erp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false |
|||
username: hnrr |
|||
password: hnrr@0b6759c29a8e |
|||
#rabbitmq 配置 |
|||
#rabbitmq: |
|||
#host: localhost |
|||
#port: 5672 |
|||
#username: rbs-payment |
|||
#password: pay123123 |
|||
# redis 配置 |
|||
redis: |
|||
database: 10 |
|||
# 地址 |
|||
host: r-uf643kmbsoz7ledq2j.redis.rds.aliyuncs.com |
|||
# 端口,默认为6379 |
|||
port: 6379 |
|||
# 密码 |
|||
password: rds@53798a0fa6ce |
|||
# 连接超时时间 |
|||
timeout: 10s |
|||
lettuce: |
|||
pool: |
|||
# 连接池中的最小空闲连接 |
|||
min-idle: 0 |
|||
# 连接池中的最大空闲连接 |
|||
# 连接池的最大数据库连接数 |
|||
max-active: 8 |
|||
# #连接池最大阻塞等待时间(使用负值表示没有限制) |
|||
max-wait: -1ms |
|||
servlet: |
|||
multipart : |
|||
max-request-size : 10MB |
|||
max-file-size : 10MB |
|||
#mybatis:配置 |
|||
mybatis: |
|||
type-aliases-package: com.base.springcloud.dao #实体类包路径 |
|||
mapper-locations: classpath*:com/base/payment/mapper/*.xml #mapper.xml路径 |
|||
|
|||
ftp: |
|||
ftp_ip: 192.168.71.132 |
|||
ftp_prot : 21 |
|||
ftp_username : wangying |
|||
ftp_password : 123456 |
|||
ftp_basepath : /home/wangying |
|||
test_ftp: |
|||
file_path : G:\TestFile\ |
|||
profiles: |
|||
active: dev |
|||
@ -0,0 +1,292 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.base.springcloud.dao.DepartMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Depart"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="parent_id" jdbcType="VARCHAR" property="parentId" /> |
|||
<result column="depart_name" jdbcType="VARCHAR" property="departName" /> |
|||
<result column="depart_name_en" jdbcType="VARCHAR" property="departNameEn" /> |
|||
<result column="depart_name_abbr" jdbcType="VARCHAR" property="departNameAbbr" /> |
|||
<result column="depart_order" jdbcType="INTEGER" property="departOrder" /> |
|||
<result column="description" jdbcType="VARCHAR" property="description" /> |
|||
<result column="org_category" jdbcType="VARCHAR" property="orgCategory" /> |
|||
<result column="org_type" jdbcType="VARCHAR" property="orgType" /> |
|||
<result column="org_code" jdbcType="VARCHAR" property="orgCode" /> |
|||
<result column="mobile" jdbcType="VARCHAR" property="mobile" /> |
|||
<result column="fax" jdbcType="VARCHAR" property="fax" /> |
|||
<result column="address" jdbcType="VARCHAR" property="address" /> |
|||
<result column="memo" jdbcType="VARCHAR" property="memo" /> |
|||
<result column="status" jdbcType="VARCHAR" property="status" /> |
|||
<result column="del_flag" jdbcType="VARCHAR" property="delFlag" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="ct_company_id" jdbcType="VARCHAR" property="ctCompanyId" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, parent_id, depart_name, depart_name_en, depart_name_abbr, depart_order, description, |
|||
org_category, org_type, org_code, mobile, fax, address, memo, status, del_flag, create_by, |
|||
create_time, update_by, update_time, ct_company_id |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from sys_depart |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from sys_depart |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Depart"> |
|||
insert into sys_depart (id, parent_id, depart_name, |
|||
depart_name_en, depart_name_abbr, depart_order, |
|||
description, org_category, org_type, |
|||
org_code, mobile, fax, |
|||
address, memo, status, |
|||
del_flag, create_by, create_time, |
|||
update_by, update_time, ct_company_id |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{departName,jdbcType=VARCHAR}, |
|||
#{departNameEn,jdbcType=VARCHAR}, #{departNameAbbr,jdbcType=VARCHAR}, #{departOrder,jdbcType=INTEGER}, |
|||
#{description,jdbcType=VARCHAR}, #{orgCategory,jdbcType=VARCHAR}, #{orgType,jdbcType=VARCHAR}, |
|||
#{orgCode,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{fax,jdbcType=VARCHAR}, |
|||
#{address,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, |
|||
#{delFlag,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
|||
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{ctCompanyId,jdbcType=VARCHAR} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Depart"> |
|||
insert into sys_depart |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="parentId != null"> |
|||
parent_id, |
|||
</if> |
|||
<if test="departName != null"> |
|||
depart_name, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
depart_name_en, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
depart_name_abbr, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
depart_order, |
|||
</if> |
|||
<if test="description != null"> |
|||
description, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
org_category, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
org_type, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
mobile, |
|||
</if> |
|||
<if test="fax != null"> |
|||
fax, |
|||
</if> |
|||
<if test="address != null"> |
|||
address, |
|||
</if> |
|||
<if test="memo != null"> |
|||
memo, |
|||
</if> |
|||
<if test="status != null"> |
|||
status, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="parentId != null"> |
|||
#{parentId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departName != null"> |
|||
#{departName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
#{departNameEn,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
#{departNameAbbr,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
#{departOrder,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="description != null"> |
|||
#{description,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
#{orgCategory,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
#{orgType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
#{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
#{mobile,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="fax != null"> |
|||
#{fax,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="address != null"> |
|||
#{address,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="memo != null"> |
|||
#{memo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
#{status,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
#{delFlag,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
#{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
#{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
#{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
#{ctCompanyId,jdbcType=VARCHAR}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Depart"> |
|||
update sys_depart |
|||
<set> |
|||
<if test="parentId != null"> |
|||
parent_id = #{parentId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departName != null"> |
|||
depart_name = #{departName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
depart_name_en = #{departNameEn,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
depart_name_abbr = #{departNameAbbr,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
depart_order = #{departOrder,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="description != null"> |
|||
description = #{description,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
org_category = #{orgCategory,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
org_type = #{orgType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
mobile = #{mobile,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="fax != null"> |
|||
fax = #{fax,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="address != null"> |
|||
address = #{address,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="memo != null"> |
|||
memo = #{memo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
status = #{status,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag = #{delFlag,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id = #{ctCompanyId,jdbcType=VARCHAR}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Depart"> |
|||
update sys_depart |
|||
set parent_id = #{parentId,jdbcType=VARCHAR}, |
|||
depart_name = #{departName,jdbcType=VARCHAR}, |
|||
depart_name_en = #{departNameEn,jdbcType=VARCHAR}, |
|||
depart_name_abbr = #{departNameAbbr,jdbcType=VARCHAR}, |
|||
depart_order = #{departOrder,jdbcType=INTEGER}, |
|||
description = #{description,jdbcType=VARCHAR}, |
|||
org_category = #{orgCategory,jdbcType=VARCHAR}, |
|||
org_type = #{orgType,jdbcType=VARCHAR}, |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
mobile = #{mobile,jdbcType=VARCHAR}, |
|||
fax = #{fax,jdbcType=VARCHAR}, |
|||
address = #{address,jdbcType=VARCHAR}, |
|||
memo = #{memo,jdbcType=VARCHAR}, |
|||
status = #{status,jdbcType=VARCHAR}, |
|||
del_flag = #{delFlag,jdbcType=VARCHAR}, |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
ct_company_id = #{ctCompanyId,jdbcType=VARCHAR} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<select id="getUserDepart" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
select id |
|||
from sys_depart |
|||
where id in ( |
|||
select dep_id |
|||
from sys_user_depart |
|||
where user_id = #{userId,jdbcType=VARCHAR} |
|||
) |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,121 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.base.springcloud.dao.OrderBillMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.OrderBill"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="order_id" jdbcType="VARCHAR" property="orderId" /> |
|||
<result column="bill_id" jdbcType="VARCHAR" property="billId" /> |
|||
<result column="soure_bill_id" jdbcType="VARCHAR" property="soureBillId" /> |
|||
<result column="create_id" jdbcType="VARCHAR" property="createId" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, order_id, bill_id, soure_bill_id, create_id, create_time |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_order_bill |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_order_bill |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.OrderBill"> |
|||
insert into pay_order_bill (id, order_id, bill_id, |
|||
soure_bill_id, create_id, create_time |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR}, #{billId,jdbcType=VARCHAR}, |
|||
#{soureBillId,jdbcType=VARCHAR}, #{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.OrderBill"> |
|||
insert into pay_order_bill |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="orderId != null"> |
|||
order_id, |
|||
</if> |
|||
<if test="billId != null"> |
|||
bill_id, |
|||
</if> |
|||
<if test="soureBillId != null"> |
|||
soure_bill_id, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orderId != null"> |
|||
#{orderId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="billId != null"> |
|||
#{billId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="soureBillId != null"> |
|||
#{soureBillId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
#{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.OrderBill"> |
|||
update pay_order_bill |
|||
<set> |
|||
<if test="orderId != null"> |
|||
order_id = #{orderId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="billId != null"> |
|||
bill_id = #{billId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="soureBillId != null"> |
|||
soure_bill_id = #{soureBillId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.OrderBill"> |
|||
update pay_order_bill |
|||
set order_id = #{orderId,jdbcType=VARCHAR}, |
|||
bill_id = #{billId,jdbcType=VARCHAR}, |
|||
soure_bill_id = #{soureBillId,jdbcType=VARCHAR}, |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
|
|||
<select id="getBillId" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
select bill_id |
|||
from pay_order_bill |
|||
<where> |
|||
order_id = #{orderId,jdbcType=VARCHAR} |
|||
</where> |
|||
</select> |
|||
<select id="getOrderId" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
select order_id |
|||
from pay_order_bill |
|||
<where> |
|||
bill_id = #{billId,jdbcType=VARCHAR} |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,93 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.base.springcloud.dao.PayDepartConfigMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.PayDepartConfig"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="mechant_config_id" jdbcType="VARCHAR" property="mechantConfigId" /> |
|||
<result column="depart_id" jdbcType="VARCHAR" property="departId" /> |
|||
<result column="create_id" jdbcType="VARCHAR" property="createId" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, mechant_config_id, depart_id, create_id, create_time |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_depart_config |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_depart_config |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
insert into pay_depart_config (id, mechant_config_id, depart_id, |
|||
create_id, create_time) |
|||
values (#{id,jdbcType=VARCHAR}, #{mechantConfigId,jdbcType=VARCHAR}, #{departId,jdbcType=VARCHAR}, |
|||
#{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
insert into pay_depart_config |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="mechantConfigId != null"> |
|||
mechant_config_id, |
|||
</if> |
|||
<if test="departId != null"> |
|||
depart_id, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mechantConfigId != null"> |
|||
#{mechantConfigId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departId != null"> |
|||
#{departId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
#{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
update pay_depart_config |
|||
<set> |
|||
<if test="mechantConfigId != null"> |
|||
mechant_config_id = #{mechantConfigId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departId != null"> |
|||
depart_id = #{departId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
update pay_depart_config |
|||
set mechant_config_id = #{mechantConfigId,jdbcType=VARCHAR}, |
|||
depart_id = #{departId,jdbcType=VARCHAR}, |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
</mapper> |
|||
@ -0,0 +1,189 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.base.springcloud.dao.RefundMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Refund"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="mch_id" jdbcType="VARCHAR" property="mchId" /> |
|||
<result column="refund_order_no" jdbcType="VARCHAR" property="refundOrderNo" /> |
|||
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" /> |
|||
<result column="create_id" jdbcType="VARCHAR" property="createId" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="orig_order_no" jdbcType="VARCHAR" property="origOrderNo" /> |
|||
<result column="orig_order_time" jdbcType="TIMESTAMP" property="origOrderTime" /> |
|||
<result column="source_bill_id" jdbcType="VARCHAR" property="sourceBillId" /> |
|||
<result column="reason" jdbcType="VARCHAR" property="reason" /> |
|||
<result column="refund_state" jdbcType="INTEGER" property="refundState" /> |
|||
<result column="refund_retry_count" jdbcType="INTEGER" property="refundRetryCount" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id,mch_id, refund_order_no, refund_time, create_id, create_time, orig_order_no, orig_order_time, |
|||
source_bill_id, reason, refund_state, refund_retry_count |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_refund |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_refund |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Refund"> |
|||
insert into pay_refund (id,mch_id,refund_order_no, refund_time, |
|||
create_id, create_time, orig_order_no, |
|||
orig_order_time, source_bill_id, reason, |
|||
refund_state, refund_retry_count) |
|||
values (#{id,jdbcType=VARCHAR}, #{mchId,jdbcType=VARCHAR},#{refundOrderNo,jdbcType=VARCHAR}, #{refundTime,jdbcType=TIMESTAMP}, |
|||
#{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{origOrderNo,jdbcType=VARCHAR}, |
|||
#{origOrderTime,jdbcType=TIMESTAMP}, #{sourceBillId,jdbcType=VARCHAR}, #{reason,jdbcType=VARCHAR}, |
|||
#{refundState,jdbcType=INTEGER}, #{refundRetryCount,jdbcType=INTEGER}) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Refund"> |
|||
insert into pay_refund |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="refundOrderNo != null"> |
|||
refund_order_no, |
|||
</if> |
|||
<if test="refundTime != null"> |
|||
refund_time, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
<if test="origOrderNo != null"> |
|||
orig_order_no, |
|||
</if> |
|||
<if test="origOrderTime != null"> |
|||
orig_order_time, |
|||
</if> |
|||
<if test="sourceBillId != null"> |
|||
source_bill_id, |
|||
</if> |
|||
<if test="reason != null"> |
|||
reason, |
|||
</if> |
|||
<if test="refundState != null"> |
|||
refund_state, |
|||
</if> |
|||
<if test="refundRetryCount != null"> |
|||
refund_retry_count, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="refundOrderNo != null"> |
|||
#{refundOrderNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="refundTime != null"> |
|||
#{refundTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
#{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="origOrderNo != null"> |
|||
#{origOrderNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="origOrderTime != null"> |
|||
#{origOrderTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="sourceBillId != null"> |
|||
#{sourceBillId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="reason != null"> |
|||
#{reason,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="refundState != null"> |
|||
#{refundState,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="refundRetryCount != null"> |
|||
#{refundRetryCount,jdbcType=INTEGER}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Refund"> |
|||
update pay_refund |
|||
<set> |
|||
<if test="refundOrderNo != null"> |
|||
refund_order_no = #{refundOrderNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="refundTime != null"> |
|||
refund_time = #{refundTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="origOrderNo != null"> |
|||
orig_order_no = #{origOrderNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="origOrderTime != null"> |
|||
orig_order_time = #{origOrderTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="sourceBillId != null"> |
|||
source_bill_id = #{sourceBillId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="reason != null"> |
|||
reason = #{reason,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="refundState != null"> |
|||
refund_state = #{refundState,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="refundRetryCount != null"> |
|||
refund_retry_count = #{refundRetryCount,jdbcType=INTEGER}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Refund"> |
|||
update pay_refund |
|||
set refund_order_no = #{refundOrderNo,jdbcType=VARCHAR}, |
|||
refund_time = #{refundTime,jdbcType=TIMESTAMP}, |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
orig_order_no = #{origOrderNo,jdbcType=VARCHAR}, |
|||
orig_order_time = #{origOrderTime,jdbcType=TIMESTAMP}, |
|||
source_bill_id = #{sourceBillId,jdbcType=VARCHAR}, |
|||
reason = #{reason,jdbcType=VARCHAR}, |
|||
refund_state = #{refundState,jdbcType=INTEGER}, |
|||
refund_retry_count = #{refundRetryCount,jdbcType=INTEGER} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateRefundSuccess" parameterType="com.base.springcloud.entity.Refund"> |
|||
update pay_refund |
|||
set refund_state = #{refundState,jdbcType=INTEGER} |
|||
<where> |
|||
refund_order_no = #{refundOrderNo,jdbcType=VARCHAR} |
|||
</where> |
|||
</update> |
|||
<update id="superRefundCount" parameterType="java.lang.String"> |
|||
update pay_refund |
|||
set refund_retry_count = refund_retry_count + 1 |
|||
<where> |
|||
id = #{id,jdbcType=VARCHAR} |
|||
</where> |
|||
</update> |
|||
<select id="queryRefundData" resultMap="BaseResultMap" parameterType="java.util.Date"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_refund |
|||
<where> |
|||
refund_state = '0' and refund_retry_count < 6 |
|||
and DATE_FORMAT(refund_time,'%Y-%m-%d') = DATE_FORMAT(#{date},'%Y-%m-%d') |
|||
</where> |
|||
order by refund_time desc limit 10 |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,360 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.base.springcloud.dao.UserMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.User"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="username" jdbcType="VARCHAR" property="userName" /> |
|||
<result column="realname" jdbcType="VARCHAR" property="realName" /> |
|||
<result column="password" jdbcType="VARCHAR" property="password" /> |
|||
<result column="salt" jdbcType="VARCHAR" property="salt" /> |
|||
<result column="avatar" jdbcType="VARCHAR" property="avatar" /> |
|||
<result column="birthday" jdbcType="TIMESTAMP" property="birthday" /> |
|||
<result column="sex" jdbcType="INTEGER" property="sex" /> |
|||
<result column="email" jdbcType="VARCHAR" property="email" /> |
|||
<result column="phone" jdbcType="VARCHAR" property="phone" /> |
|||
<result column="org_code" jdbcType="VARCHAR" property="orgCode" /> |
|||
<result column="status" jdbcType="INTEGER" property="status" /> |
|||
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
|||
<result column="third_id" jdbcType="VARCHAR" property="thirdId" /> |
|||
<result column="third_type" jdbcType="VARCHAR" property="thirdType" /> |
|||
<result column="activiti_sync" jdbcType="INTEGER" property="activitiSync" /> |
|||
<result column="work_no" jdbcType="VARCHAR" property="workNo" /> |
|||
<result column="post" jdbcType="VARCHAR" property="post" /> |
|||
<result column="telephone" jdbcType="VARCHAR" property="telephone" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="user_identity" jdbcType="INTEGER" property="userIdentity" /> |
|||
<result column="depart_ids" jdbcType="VARCHAR" property="departIds" /> |
|||
<result column="ct_company_id" jdbcType="TIMESTAMP" property="ctCompanyId" /> |
|||
<result column="account_type" jdbcType="INTEGER" property="accountType" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, username, realname, password, salt, avatar, birthday, sex, email, phone, org_code, |
|||
status, del_flag, third_id, third_type, activiti_sync, work_no, post, telephone, |
|||
create_by, create_time, update_by, update_time, user_identity, depart_ids, ct_company_id, |
|||
account_type |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from sys_user |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from sys_user |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.User"> |
|||
insert into sys_user (id, username, realname, |
|||
password, salt, avatar, |
|||
birthday, sex, email, |
|||
phone, org_code, status, |
|||
del_flag, third_id, third_type, |
|||
activiti_sync, work_no, post, |
|||
telephone, create_by, create_time, |
|||
update_by, update_time, user_identity, |
|||
depart_ids, ct_company_id, account_type |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{realName,jdbcType=VARCHAR}, |
|||
#{password,jdbcType=VARCHAR}, #{salt,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, |
|||
#{birthday,jdbcType=TIMESTAMP}, #{sex,jdbcType=INTEGER}, #{email ,jdbcType=VARCHAR}, |
|||
#{phone,jdbcType=VARCHAR}, #{orgCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, |
|||
#{delFlag,jdbcType=INTEGER}, #{thirdId,jdbcType=VARCHAR}, #{thirdType,jdbcType=VARCHAR}, |
|||
#{activitiSync,jdbcType=INTEGER}, #{workNo,jdbcType=VARCHAR}, #{post,jdbcType=VARCHAR}, |
|||
#{telephone,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
|||
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{userIdentity,jdbcType=INTEGER}, |
|||
#{departIds,jdbcType=VARCHAR}, #{ctCompanyId,jdbcType=TIMESTAMP}, #{accountType,jdbcType=INTEGER} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.User"> |
|||
insert into sys_user |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="userName != null"> |
|||
username, |
|||
</if> |
|||
<if test="realName != null"> |
|||
realname, |
|||
</if> |
|||
<if test="password != null"> |
|||
password, |
|||
</if> |
|||
<if test="salt != null"> |
|||
salt, |
|||
</if> |
|||
<if test="avatar != null"> |
|||
avatar, |
|||
</if> |
|||
<if test="birthday != null"> |
|||
birthday, |
|||
</if> |
|||
<if test="sex != null"> |
|||
sex, |
|||
</if> |
|||
<if test="email != null"> |
|||
email, |
|||
</if> |
|||
<if test="phone != null"> |
|||
phone, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code, |
|||
</if> |
|||
<if test="status != null"> |
|||
status, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag, |
|||
</if> |
|||
<if test="thirdId != null"> |
|||
third_id, |
|||
</if> |
|||
<if test="thirdType != null"> |
|||
third_type, |
|||
</if> |
|||
<if test="activitiSync != null"> |
|||
activiti_sync, |
|||
</if> |
|||
<if test="workNo != null"> |
|||
work_no, |
|||
</if> |
|||
<if test="post != null"> |
|||
post, |
|||
</if> |
|||
<if test="telephone != null"> |
|||
telephone, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time, |
|||
</if> |
|||
<if test="userIdentity != null"> |
|||
user_identity, |
|||
</if> |
|||
<if test="departIds != null"> |
|||
depart_ids, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id, |
|||
</if> |
|||
<if test="accountType != null"> |
|||
account_type, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="userName != null"> |
|||
#{userName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="realName != null"> |
|||
#{realName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="password != null"> |
|||
#{password,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="salt != null"> |
|||
#{salt,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="avatar != null"> |
|||
#{avatar,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="birthday != null"> |
|||
#{birthday,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="sex != null"> |
|||
#{sex,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="email != null"> |
|||
#{email ,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="phone != null"> |
|||
#{phone,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
#{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
#{status,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
#{delFlag,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="thirdId != null"> |
|||
#{thirdId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="thirdType != null"> |
|||
#{thirdType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="activitiSync != null"> |
|||
#{activitiSync,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="workNo != null"> |
|||
#{workNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="post != null"> |
|||
#{post,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="telephone != null"> |
|||
#{telephone,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
#{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
#{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
#{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="userIdentity != null"> |
|||
#{userIdentity,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="departIds != null"> |
|||
#{departIds,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
#{ctCompanyId,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="accountType != null"> |
|||
#{accountType,jdbcType=INTEGER}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.User"> |
|||
update sys_user |
|||
<set> |
|||
<if test="userName != null"> |
|||
username = #{userName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="realName != null"> |
|||
realname = #{realName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="password != null"> |
|||
password = #{password,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="salt != null"> |
|||
salt = #{salt,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="avatar != null"> |
|||
avatar = #{avatar,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="birthday != null"> |
|||
birthday = #{birthday,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="sex != null"> |
|||
sex = #{sex,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="email != null"> |
|||
email = #{email ,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="phone != null"> |
|||
phone = #{phone,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
status = #{status,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag = #{delFlag,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="thirdId != null"> |
|||
third_id = #{thirdId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="thirdType != null"> |
|||
third_type = #{thirdType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="activitiSync != null"> |
|||
activiti_sync = #{activitiSync,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="workNo != null"> |
|||
work_no = #{workNo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="post != null"> |
|||
post = #{post,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="telephone != null"> |
|||
telephone = #{telephone,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="userIdentity != null"> |
|||
user_identity = #{userIdentity,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="departIds != null"> |
|||
depart_ids = #{departIds,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id = #{ctCompanyId,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="accountType != null"> |
|||
account_type = #{accountType,jdbcType=INTEGER}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.User"> |
|||
update sys_user |
|||
set username = #{userName,jdbcType=VARCHAR}, |
|||
realname = #{realName,jdbcType=VARCHAR}, |
|||
password = #{password,jdbcType=VARCHAR}, |
|||
salt = #{salt,jdbcType=VARCHAR}, |
|||
avatar = #{avatar,jdbcType=VARCHAR}, |
|||
birthday = #{birthday,jdbcType=TIMESTAMP}, |
|||
sex = #{sex,jdbcType=INTEGER}, |
|||
email = #{email ,jdbcType=VARCHAR}, |
|||
phone = #{phone,jdbcType=VARCHAR}, |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
status = #{status,jdbcType=INTEGER}, |
|||
del_flag = #{delFlag,jdbcType=INTEGER}, |
|||
third_id = #{thirdId,jdbcType=VARCHAR}, |
|||
third_type = #{thirdType,jdbcType=VARCHAR}, |
|||
activiti_sync = #{activitiSync,jdbcType=INTEGER}, |
|||
work_no = #{workNo,jdbcType=VARCHAR}, |
|||
post = #{post,jdbcType=VARCHAR}, |
|||
telephone = #{telephone,jdbcType=VARCHAR}, |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
user_identity = #{userIdentity,jdbcType=INTEGER}, |
|||
depart_ids = #{departIds,jdbcType=VARCHAR}, |
|||
ct_company_id = #{ctCompanyId,jdbcType=TIMESTAMP}, |
|||
account_type = #{accountType,jdbcType=INTEGER} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<select id="getUser" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from sys_user |
|||
where username = #{userName,jdbcType=VARCHAR} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,76 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration debug="false"> |
|||
<!--定义日志文件的存储地址 --> |
|||
<property name="LOG_HOME" value="logs" /> |
|||
|
|||
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />--> |
|||
<!-- 控制台输出 --> |
|||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
|||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!-- 按照每天生成日志文件 --> |
|||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
|||
<!--日志文件输出的文件名 --> |
|||
<FileNamePattern>${LOG_HOME}/rbs_pay-%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
|||
<!--日志文件保留天数 --> |
|||
<MaxHistory>30</MaxHistory> |
|||
<maxFileSize>20MB</maxFileSize> |
|||
</rollingPolicy> |
|||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
|||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!-- 生成 error html格式日志开始 --> |
|||
<appender name="HTML" class="ch.qos.logback.core.FileAppender"> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<!--设置日志级别,过滤掉info日志,只输入error日志--> |
|||
<level>ERROR</level> |
|||
</filter> |
|||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> |
|||
<layout class="ch.qos.logback.classic.html.HTMLLayout"> |
|||
<pattern>%p%d%msg%M%F{32}%L</pattern> |
|||
</layout> |
|||
</encoder> |
|||
<file>${LOG_HOME}/error-log.html</file> |
|||
</appender> |
|||
<!-- 生成 error html格式日志结束 --> |
|||
|
|||
<!-- 每天生成一个html格式的日志开始 --> |
|||
<appender name="FILE_HTML" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
|||
<!--日志文件输出的文件名 --> |
|||
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.html</FileNamePattern> |
|||
<!--日志文件保留天数 --> |
|||
<MaxHistory>30</MaxHistory> |
|||
<MaxFileSize>10MB</MaxFileSize> |
|||
</rollingPolicy> |
|||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> |
|||
<layout class="ch.qos.logback.classic.html.HTMLLayout"> |
|||
<pattern>%p%d%msg%M%F{32}%L</pattern> |
|||
</layout> |
|||
</encoder> |
|||
</appender> |
|||
<!-- 每天生成一个html格式的日志结束 --> |
|||
|
|||
<!--myibatis log configure --> |
|||
<logger name="com.apache.ibatis" level="TRACE" /> |
|||
<logger name="java.sql.Connection" level="DEBUG" /> |
|||
<logger name="java.sql.Statement" level="DEBUG" /> |
|||
<logger name="java.sql.PreparedStatement" level="DEBUG" /> |
|||
|
|||
<!-- 日志输出级别 --> |
|||
<root level="INFO"> |
|||
<appender-ref ref="STDOUT" /> |
|||
<appender-ref ref="FILE" /> |
|||
<appender-ref ref="HTML" /> |
|||
<appender-ref ref="FILE_HTML" /> |
|||
</root> |
|||
|
|||
</configuration> |
|||
Loading…
Reference in new issue