libo 4 роки тому
батько
коміт
a431910763
80 змінених файлів з 4866 додано та 0 видалено
  1. 6 0
      .gitignore
  2. 111 0
      pom.xml
  3. 32 0
      src/main/java/com/tdba/cxb/ares/api/ApplicationStartup.java
  4. 37 0
      src/main/java/com/tdba/cxb/ares/api/config/FIlterConfig.java
  5. 75 0
      src/main/java/com/tdba/cxb/ares/api/config/JacksonConfig.java
  6. 18 0
      src/main/java/com/tdba/cxb/ares/api/config/MybatisConfig.java
  7. 41 0
      src/main/java/com/tdba/cxb/ares/api/config/PageEntity.java
  8. 18 0
      src/main/java/com/tdba/cxb/ares/api/config/PageEntityBuilder.java
  9. 82 0
      src/main/java/com/tdba/cxb/ares/api/config/RedisConfig.java
  10. 188 0
      src/main/java/com/tdba/cxb/ares/api/config/WebExceptionHandler.java
  11. 22 0
      src/main/java/com/tdba/cxb/ares/api/config/WebMvcConfig.java
  12. 83 0
      src/main/java/com/tdba/cxb/ares/api/config/http/LoggingClientHttpRequestInterceptor.java
  13. 47 0
      src/main/java/com/tdba/cxb/ares/api/config/http/RestTemplateConfig.java
  14. 31 0
      src/main/java/com/tdba/cxb/ares/api/controller/PaymentController.java
  15. 55 0
      src/main/java/com/tdba/cxb/ares/api/controller/ProductAttrValueController.java
  16. 37 0
      src/main/java/com/tdba/cxb/ares/api/controller/ProductController.java
  17. 78 0
      src/main/java/com/tdba/cxb/ares/api/model/BaseUser.java
  18. 54 0
      src/main/java/com/tdba/cxb/ares/api/model/MerchantVo.java
  19. 43 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductAttrDto.java
  20. 38 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductAttrValueReq.java
  21. 82 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductAttrValueVo.java
  22. 63 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductAttrVo.java
  23. 43 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductContent.java
  24. 117 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductResp.java
  25. 78 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductSimple.java
  26. 117 0
      src/main/java/com/tdba/cxb/ares/api/model/ProductVo.java
  27. 277 0
      src/main/java/com/tdba/cxb/ares/api/model/RrxStoreGroupOrder.java
  28. 43 0
      src/main/java/com/tdba/cxb/ares/api/model/TDBAResponse.java
  29. 69 0
      src/main/java/com/tdba/cxb/ares/api/model/TDBAResponseBuilder.java
  30. 23 0
      src/main/java/com/tdba/cxb/ares/api/repository/MerchantMapper.java
  31. 19 0
      src/main/java/com/tdba/cxb/ares/api/repository/ProductAttrMapper.java
  32. 31 0
      src/main/java/com/tdba/cxb/ares/api/repository/ProductAttrValueMapper.java
  33. 23 0
      src/main/java/com/tdba/cxb/ares/api/repository/ProductContentMapper.java
  34. 32 0
      src/main/java/com/tdba/cxb/ares/api/repository/ProductMapper.java
  35. 16 0
      src/main/java/com/tdba/cxb/ares/api/repository/RrxStoreGroupOrderMapper.java
  36. 27 0
      src/main/java/com/tdba/cxb/ares/api/resolver/CustomBigDecimalSerializer.java
  37. 24 0
      src/main/java/com/tdba/cxb/ares/api/resolver/CustomDoubleSerializer.java
  38. 28 0
      src/main/java/com/tdba/cxb/ares/api/resolver/CustomLocalDateTimeSerializer.java
  39. 23 0
      src/main/java/com/tdba/cxb/ares/api/resolver/OriginalDoubleSerializer.java
  40. 23 0
      src/main/java/com/tdba/cxb/ares/api/service/PaymentService.java
  41. 94 0
      src/main/java/com/tdba/cxb/ares/api/service/ProductService.java
  42. 74 0
      src/main/java/com/tdba/cxb/ares/api/util/AESUtil.java
  43. 20 0
      src/main/java/com/tdba/cxb/ares/api/util/Base64Util.java
  44. 53 0
      src/main/java/com/tdba/cxb/ares/api/util/BaseUserArgumentResolver.java
  45. 79 0
      src/main/java/com/tdba/cxb/ares/api/util/BigDecimalUtil.java
  46. 14 0
      src/main/java/com/tdba/cxb/ares/api/util/CFCAUtil.java
  47. 64 0
      src/main/java/com/tdba/cxb/ares/api/util/ConfigTool.java
  48. 192 0
      src/main/java/com/tdba/cxb/ares/api/util/DateUtil.java
  49. 21 0
      src/main/java/com/tdba/cxb/ares/api/util/DoubleUtil.java
  50. 39 0
      src/main/java/com/tdba/cxb/ares/api/util/SHA1Util.java
  51. 76 0
      src/main/java/com/tdba/cxb/ares/api/util/SignUtil.java
  52. 27 0
      src/main/java/com/tdba/cxb/ares/api/util/TDBAController.java
  53. 14 0
      src/main/java/com/tdba/cxb/ares/api/util/TDBAException.java
  54. 25 0
      src/main/java/module-info.java
  55. 30 0
      src/main/resources/application-dev.yml
  56. 30 0
      src/main/resources/application-test.yml
  57. 17 0
      src/main/resources/application.yml
  58. 65 0
      src/main/resources/logback-spring.xml
  59. 17 0
      src/main/resources/mapper/MerchantMapper.xml
  60. 15 0
      src/main/resources/mapper/ProductAttrMapper.xml
  61. 31 0
      src/main/resources/mapper/ProductAttrValueMapper.xml
  62. 15 0
      src/main/resources/mapper/ProductContentMapper.xml
  63. 42 0
      src/main/resources/mapper/ProductMapper.xml
  64. 8 0
      src/main/resources/mapper/RrxStoreGroupOrderMapper.xml
  65. 70 0
      src/test/java/com/tdba/cxb/ares/api/BuilderSupport.java
  66. 14 0
      src/test/java/com/tdba/cxb/ares/api/ObjectUtils.java
  67. 553 0
      src/test/java/com/tdba/cxb/ares/api/PayOrderReq.java
  68. 133 0
      src/test/java/com/tdba/cxb/ares/api/Payer.java
  69. 115 0
      src/test/java/com/tdba/cxb/ares/api/ProductDetails.java
  70. 300 0
      src/test/java/com/tdba/cxb/ares/api/ShouxinyiTest.java
  71. 211 0
      src/test/java/com/tdba/cxb/ares/api/SignPublisher.java
  72. 50 0
      src/test/java/com/tdba/cxb/ares/api/SortTest.java
  73. 18 0
      src/test/java/com/tdba/cxb/ares/api/StringUtil.java
  74. 27 0
      src/test/resources/5upay/899104033
  75. 9 0
      src/test/resources/5upay/899104033_public
  76. BIN
      src/test/resources/5upay/private.pfx
  77. 25 0
      src/test/resources/5upay/public.cer
  78. 25 0
      src/test/resources/5upay/public.pem
  79. BIN
      src/test/resources/5upay/public_der.cer
  80. BIN
      src/test/resources/5upay/test.cer

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
1
+target/
2
+.idea/
3
+*.iml
4
+*.DS_Store
5
+package-lock.json
6
+

+ 111 - 0
pom.xml

@@ -0,0 +1,111 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <parent>
8
+        <groupId>org.springframework.boot</groupId>
9
+        <artifactId>spring-boot-starter-parent</artifactId>
10
+        <version>2.7.0</version>
11
+        <relativePath/> <!-- lookup parent from repository -->
12
+    </parent>
13
+
14
+    <groupId>com.tdba.cxb.ares</groupId>
15
+    <artifactId>order-web</artifactId>
16
+    <packaging>jar</packaging>
17
+    <version>1.0.0-SNAPSHOT</version>
18
+
19
+    <properties>
20
+        <java.version>17</java.version>
21
+    </properties>
22
+
23
+    <dependencies>
24
+        <dependency>
25
+            <groupId>com.github.ben-manes.caffeine</groupId>
26
+            <artifactId>caffeine</artifactId>
27
+        </dependency>
28
+
29
+        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
30
+        <dependency>
31
+            <groupId>mysql</groupId>
32
+            <artifactId>mysql-connector-java</artifactId>
33
+            <version>8.0.29</version>
34
+        </dependency>
35
+
36
+        <dependency>
37
+            <groupId>org.springframework.boot</groupId>
38
+            <artifactId>spring-boot-starter-validation</artifactId>
39
+        </dependency>
40
+
41
+        <!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
42
+        <dependency>
43
+            <groupId>com.auth0</groupId>
44
+            <artifactId>java-jwt</artifactId>
45
+            <version>3.19.2</version>
46
+        </dependency>
47
+
48
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
49
+        <dependency>
50
+            <groupId>org.apache.httpcomponents</groupId>
51
+            <artifactId>httpclient</artifactId>
52
+            <version>4.5.13</version>
53
+        </dependency>
54
+
55
+        <dependency>
56
+            <groupId>org.springframework.boot</groupId>
57
+            <artifactId>spring-boot-starter-data-redis</artifactId>
58
+        </dependency>
59
+
60
+        <dependency>
61
+            <groupId>org.springframework.boot</groupId>
62
+            <artifactId>spring-boot-starter-web</artifactId>
63
+        </dependency>
64
+
65
+        <dependency>
66
+            <groupId>org.mybatis.spring.boot</groupId>
67
+            <artifactId>mybatis-spring-boot-starter</artifactId>
68
+            <version>2.2.2</version>
69
+        </dependency>
70
+
71
+        <dependency>
72
+          <groupId>org.springframework.boot</groupId>
73
+          <artifactId>spring-boot-starter</artifactId>
74
+        </dependency>
75
+
76
+        <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
77
+        <dependency>
78
+            <groupId>com.github.pagehelper</groupId>
79
+            <artifactId>pagehelper</artifactId>
80
+            <version>5.3.0</version>
81
+        </dependency>
82
+
83
+        <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
84
+        <dependency>
85
+            <groupId>redis.clients</groupId>
86
+            <artifactId>jedis</artifactId>
87
+            <version>3.8.0</version>
88
+        </dependency>
89
+
90
+        <dependency>
91
+          <groupId>org.springframework.boot</groupId>
92
+          <artifactId>spring-boot-starter-test</artifactId>
93
+          <scope>test</scope>
94
+        </dependency>
95
+
96
+        <dependency>
97
+            <groupId>com.alibaba.fastjson2</groupId>
98
+            <artifactId>fastjson2</artifactId>
99
+            <version>2.0.2</version>
100
+        </dependency>
101
+    </dependencies>
102
+
103
+    <build>
104
+        <plugins>
105
+            <plugin>
106
+                <groupId>org.springframework.boot</groupId>
107
+                <artifactId>spring-boot-maven-plugin</artifactId>
108
+            </plugin>
109
+        </plugins>
110
+    </build>
111
+</project>

+ 32 - 0
src/main/java/com/tdba/cxb/ares/api/ApplicationStartup.java

@@ -0,0 +1,32 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import org.springframework.boot.CommandLineRunner;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+import org.springframework.cache.annotation.EnableCaching;
7
+import org.springframework.context.ApplicationContext;
8
+import org.springframework.scheduling.annotation.EnableAsync;
9
+import org.springframework.scheduling.annotation.EnableScheduling;
10
+
11
+import javax.annotation.Resource;
12
+
13
+/**
14
+ * 入口类
15
+ */
16
+@EnableAsync
17
+@EnableScheduling
18
+@EnableCaching
19
+@SpringBootApplication
20
+public class ApplicationStartup implements CommandLineRunner {
21
+
22
+    public static void main(String[] args) {
23
+        SpringApplication.run(ApplicationStartup.class, args);
24
+    }
25
+
26
+    @Resource
27
+    private ApplicationContext context;
28
+
29
+    @Override
30
+    public void run(String... args) throws Exception {
31
+    }
32
+}

+ 37 - 0
src/main/java/com/tdba/cxb/ares/api/config/FIlterConfig.java

@@ -0,0 +1,37 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.cors.CorsConfiguration;
6
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
7
+import org.springframework.web.filter.CorsFilter;
8
+
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+/**
13
+ * 过滤器配置
14
+ */
15
+@Configuration
16
+public class FIlterConfig {
17
+
18
+    private CorsConfiguration buildConfig() {
19
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
20
+        corsConfiguration.setAllowCredentials(true);  //sessionid 多次访问一致
21
+
22
+        // 允许访问的客户端域名
23
+        List<String> allowedOriginPatterns = new ArrayList<>();
24
+        allowedOriginPatterns.add("*");
25
+        corsConfiguration.setAllowedOriginPatterns(allowedOriginPatterns);
26
+        corsConfiguration.addAllowedHeader("*"); // 允许任何头
27
+        corsConfiguration.addAllowedMethod("*"); // 允许任何方法(post、get等)
28
+        return corsConfiguration;
29
+    }
30
+
31
+    @Bean
32
+    public CorsFilter corsFilter() {
33
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
34
+        source.registerCorsConfiguration("/**", buildConfig()); // 对接口配置跨域设置
35
+        return new CorsFilter(source);
36
+    }
37
+}

+ 75 - 0
src/main/java/com/tdba/cxb/ares/api/config/JacksonConfig.java

@@ -0,0 +1,75 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import com.tdba.cxb.ares.api.resolver.CustomBigDecimalSerializer;
4
+import com.tdba.cxb.ares.api.resolver.CustomDoubleSerializer;
5
+import com.tdba.cxb.ares.api.resolver.CustomLocalDateTimeSerializer;
6
+import com.fasterxml.jackson.annotation.JsonInclude;
7
+import com.fasterxml.jackson.databind.DeserializationFeature;
8
+import com.fasterxml.jackson.databind.ObjectMapper;
9
+import com.fasterxml.jackson.databind.SerializationFeature;
10
+import com.fasterxml.jackson.databind.module.SimpleModule;
11
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
12
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
13
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
14
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
15
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
16
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
17
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
18
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
19
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
20
+import org.slf4j.Logger;
21
+import org.slf4j.LoggerFactory;
22
+import org.springframework.context.annotation.Bean;
23
+import org.springframework.context.annotation.Configuration;
24
+import org.springframework.context.annotation.Primary;
25
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
26
+
27
+import java.math.BigDecimal;
28
+import java.text.SimpleDateFormat;
29
+import java.time.LocalDate;
30
+import java.time.LocalDateTime;
31
+import java.time.LocalTime;
32
+import java.time.format.DateTimeFormatter;
33
+import java.util.Locale;
34
+import java.util.TimeZone;
35
+
36
+@Configuration
37
+public class JacksonConfig {
38
+
39
+    private static Logger log = LoggerFactory.getLogger(JacksonConfig.class);
40
+
41
+    /**
42
+     * jackson 增加jdk8支持
43
+     */
44
+    @Bean
45
+    public ObjectMapper customObjectMapper(){
46
+        log.info("初始化customObjectMapper");
47
+        ObjectMapper objectMapper = createObjectMapper();
48
+        JavaTimeModule javaTimeModule = new JavaTimeModule();
49
+        javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss", Locale.CHINA)));
50
+        javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA)));
51
+        javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss", Locale.CHINA)));
52
+        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer((DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss", Locale.CHINA))));
53
+        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.CHINA)));
54
+        javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss", Locale.CHINA)));
55
+        objectMapper.registerModule(javaTimeModule);
56
+        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
57
+        objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+08:00"));
58
+        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
59
+
60
+        SimpleModule simpleModule = new SimpleModule();
61
+        simpleModule.addSerializer(Double.class, new CustomDoubleSerializer());
62
+        simpleModule.addSerializer(BigDecimal.class, new CustomBigDecimalSerializer());
63
+        objectMapper.registerModule(simpleModule);
64
+        return objectMapper;
65
+    }
66
+
67
+    private ObjectMapper createObjectMapper(){
68
+        ObjectMapper objectMapper = new ObjectMapper();
69
+        objectMapper.registerModule(new ParameterNamesModule());
70
+        objectMapper.registerModule(new Jdk8Module());
71
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
72
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL );
73
+        return objectMapper;
74
+    }
75
+}

+ 18 - 0
src/main/java/com/tdba/cxb/ares/api/config/MybatisConfig.java

@@ -0,0 +1,18 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import com.github.pagehelper.PageInterceptor;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+
7
+/**
8
+ * @description: mybatis配置信息
9
+ * @author: libo
10
+ */
11
+@Configuration
12
+public class MybatisConfig {
13
+
14
+    @Bean
15
+    public PageInterceptor sqlExplainInterceptor() {
16
+        return new PageInterceptor();
17
+    }
18
+}

+ 41 - 0
src/main/java/com/tdba/cxb/ares/api/config/PageEntity.java

@@ -0,0 +1,41 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
6
+/**
7
+ * 分页配置
8
+ */
9
+public class PageEntity<T> {
10
+
11
+    private List<T> list;
12
+    private Integer currentPage;
13
+    private Long total;
14
+
15
+    public List<T> getList() {
16
+        if (list == null) {
17
+            list = new ArrayList<>();
18
+        }
19
+        return list;
20
+    }
21
+
22
+    public void setList(List<T> list) {
23
+        this.list = list;
24
+    }
25
+
26
+    public Integer getCurrentPage() {
27
+        return currentPage;
28
+    }
29
+
30
+    public void setCurrentPage(Integer currentPage) {
31
+        this.currentPage = currentPage;
32
+    }
33
+
34
+    public Long getTotal() {
35
+        return total;
36
+    }
37
+
38
+    public void setTotal(Long total) {
39
+        this.total = total;
40
+    }
41
+}

+ 18 - 0
src/main/java/com/tdba/cxb/ares/api/config/PageEntityBuilder.java

@@ -0,0 +1,18 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import com.github.pagehelper.PageInfo;
4
+
5
+/**
6
+ * 分页配置
7
+ */
8
+public class PageEntityBuilder {
9
+
10
+    public static <T> PageEntity<T> buildByPageInfo(PageInfo<T> pageInfo){
11
+        PageEntity<T> pageEntity = new PageEntity<T>();
12
+        pageEntity.setList(pageInfo.getList());
13
+        pageEntity.setCurrentPage(pageInfo.getPageNum());
14
+        pageEntity.setTotal(pageInfo.getTotal());
15
+        return pageEntity;
16
+    }
17
+}
18
+

+ 82 - 0
src/main/java/com/tdba/cxb/ares/api/config/RedisConfig.java

@@ -0,0 +1,82 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.beans.factory.annotation.Value;
6
+import org.springframework.context.annotation.Bean;
7
+import org.springframework.context.annotation.Configuration;
8
+import org.springframework.data.redis.connection.RedisConnectionFactory;
9
+import org.springframework.data.redis.core.RedisTemplate;
10
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
11
+import org.springframework.data.redis.serializer.StringRedisSerializer;
12
+import org.springframework.util.StringUtils;
13
+import redis.clients.jedis.JedisPool;
14
+import redis.clients.jedis.JedisPoolConfig;
15
+
16
+/**
17
+ * redis 配置类
18
+ */
19
+@Configuration
20
+public class RedisConfig {
21
+
22
+    private static Logger log = LoggerFactory.getLogger(RedisConfig.class);
23
+
24
+    @Value("${spring.redis.host}")
25
+    private String host;
26
+
27
+    @Value("${spring.redis.port}")
28
+    private int port;
29
+
30
+    @Value("${spring.redis.password}")
31
+    private String password;
32
+
33
+    @Value("${spring.redis.timeout}")
34
+    private int timeout;
35
+
36
+    @Value("${spring.redis.jedis.pool.max-active}")
37
+    private int maxActive;
38
+
39
+    @Value("${spring.redis.jedis..pool.max-wait}")
40
+    private int maxWait;
41
+
42
+    @Value("${spring.redis.jedis..pool.max-idle}")
43
+    private int maxIdle;
44
+
45
+    @Value("${spring.redis.jedis..pool.min-idle}")
46
+    private int minIdle;
47
+
48
+    @Value("${spring.redis.database}")
49
+    private int database;
50
+
51
+    @Bean
52
+    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
53
+        RedisTemplate redisTemplate = new RedisTemplate();
54
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
55
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
56
+        redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
57
+        redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
58
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
59
+        return redisTemplate;
60
+    }
61
+
62
+    @Bean
63
+    public JedisPool redisPoolFactory() {
64
+        try {
65
+            JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
66
+            jedisPoolConfig.setMaxIdle(maxIdle);
67
+            jedisPoolConfig.setMaxWaitMillis(maxWait);
68
+            jedisPoolConfig.setMaxTotal(maxActive);
69
+            jedisPoolConfig.setMinIdle(minIdle);
70
+            // 密码为空设置为null
71
+            if (!StringUtils.hasLength(password)) {
72
+                password = null;
73
+            }
74
+            JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password, database);
75
+            log.info("初始化Redis连接池JedisPool成功!地址: " + host + ":" + port + ":" + database);
76
+            return jedisPool;
77
+        } catch (Exception e) {
78
+            log.error("初始化Redis连接池JedisPool异常:" + e.getMessage());
79
+        }
80
+        return null;
81
+    }
82
+}

+ 188 - 0
src/main/java/com/tdba/cxb/ares/api/config/WebExceptionHandler.java

@@ -0,0 +1,188 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import com.auth0.jwt.exceptions.TokenExpiredException;
4
+import com.tdba.cxb.ares.api.model.TDBAResponse;
5
+import com.tdba.cxb.ares.api.model.TDBAResponseBuilder;
6
+import com.tdba.cxb.ares.api.util.TDBAException;
7
+import org.slf4j.Logger;
8
+import org.slf4j.LoggerFactory;
9
+import org.springframework.http.HttpStatus;
10
+import org.springframework.http.converter.HttpMessageNotReadableException;
11
+import org.springframework.util.StringUtils;
12
+import org.springframework.validation.BindException;
13
+import org.springframework.validation.ObjectError;
14
+import org.springframework.web.HttpRequestMethodNotSupportedException;
15
+import org.springframework.web.bind.MethodArgumentNotValidException;
16
+import org.springframework.web.bind.annotation.ExceptionHandler;
17
+import org.springframework.web.bind.annotation.RestControllerAdvice;
18
+
19
+import javax.servlet.http.HttpServletRequest;
20
+import javax.servlet.http.HttpServletResponse;
21
+import javax.validation.ConstraintViolation;
22
+import javax.validation.ConstraintViolationException;
23
+import java.util.*;
24
+import java.util.stream.Collectors;
25
+
26
+/**
27
+ * @description: 统一异常处理
28
+ * @author: libo
29
+ */
30
+@RestControllerAdvice
31
+public class WebExceptionHandler {
32
+
33
+    private static Logger log = LoggerFactory.getLogger(WebExceptionHandler.class);
34
+
35
+    /**
36
+     * 系统内部异常
37
+     * @return
38
+     */
39
+    @ExceptionHandler(TDBAException.class)
40
+    public TDBAResponse bhException(TDBAException e, HttpServletRequest request) {
41
+
42
+        if("GET".equalsIgnoreCase(request.getMethod())){
43
+            Map<String, String[]> requestParam = request.getParameterMap();
44
+            Map<String, Object> paramMap = new HashMap();
45
+
46
+            requestParam.forEach((key, value) -> {
47
+                if((null != value) && (0 < value.length)){
48
+                    paramMap.put(key, value[0]);
49
+                }
50
+            });
51
+
52
+            log.error("parameter = {}", paramMap, e);
53
+        }else{
54
+            log.error("", e);
55
+        }
56
+
57
+        return TDBAResponseBuilder.buildError("", e.getMessage());
58
+    }
59
+
60
+    /**
61
+     * 校验失败
62
+     * @param e
63
+     * @return
64
+     */
65
+    @ExceptionHandler(BindException.class)
66
+    public TDBAResponse validException(BindException e){
67
+        log.error("校验失败", e);
68
+        return TDBAResponseBuilder.buildError("", e.getBindingResult().getAllErrors().iterator().next().getDefaultMessage());
69
+    }
70
+
71
+    /**
72
+     * 参数校验
73
+     * @param exception
74
+     * @return
75
+     */
76
+    @ExceptionHandler(ConstraintViolationException.class)
77
+    public TDBAResponse constraintViolationException(ConstraintViolationException exception){
78
+        ConstraintViolation constraintViolation = exception.getConstraintViolations().iterator().next();
79
+        log.error("{}: {} = {}", constraintViolation.getMessageTemplate(),
80
+                constraintViolation.getPropertyPath(), constraintViolation.getInvalidValue(), exception);
81
+        return TDBAResponseBuilder.buildError("", constraintViolation.getMessageTemplate());
82
+    }
83
+
84
+    /**
85
+     * 参数校验
86
+     * @param exception
87
+     * @return
88
+     */
89
+    @ExceptionHandler(MethodArgumentNotValidException.class)
90
+    public TDBAResponse methodArgumentNotValidException(MethodArgumentNotValidException exception){
91
+
92
+        ObjectError error = exception.getBindingResult().getAllErrors().iterator().next();
93
+        return TDBAResponseBuilder.buildError("",error.getDefaultMessage());
94
+    }
95
+
96
+    /**
97
+     * 未登录
98
+     * @param exception
99
+     * @return
100
+     */
101
+//    @ExceptionHandler(UnauthenticatedException.class)
102
+//    public TDBAResponse unauthenticatedException(UnauthenticatedException exception, HttpServletResponse response){
103
+////        response.setStatus(HttpStatus.UNAUTHORIZED.value());
104
+//        return TDBAResponseBuilder.buildAuthorize();
105
+//    }
106
+
107
+    /**
108
+     * 其它所有异常
109
+     * @param e
110
+     * @return
111
+     */
112
+    @ExceptionHandler(Exception.class)
113
+    public TDBAResponse unknownException(Exception e, HttpServletResponse response, HttpServletRequest request) {
114
+
115
+        String token = response.getHeader("Authorization");
116
+
117
+        //复制header
118
+        Map<String, Collection<String>> map = new HashMap<>();
119
+        List<String> names = response.getHeaderNames().stream().distinct().collect(Collectors.toList());
120
+        for(String row : names){
121
+            map.put(row, response.getHeaders(row));
122
+        }
123
+
124
+        // 防止response中既有成功消息,也有异常消息;
125
+        // 例如: 成功消息写入response时报错 json解析报错
126
+        // 清空之前写入的响应信息
127
+        response.reset();
128
+
129
+        //保留header
130
+        Collection<String> values = null;
131
+        for(String row: names){
132
+            values = map.get(row);
133
+            for(String item : values){
134
+                response.addHeader(row, item);
135
+            }
136
+        }
137
+//
138
+//        if(StringUtils.hasText(token)){ // 保留刷新的token信息
139
+//            response.setHeader("Authorization", token);
140
+//            response.setHeader("Access-Control-Expose-Headers", "Authorization");
141
+//            response.setHeader("Cache-Control", "no-store");
142
+//        }
143
+//
144
+//        //设置跨域
145
+//        response.setHeader("Access-Control-Allow-Origin", "*");
146
+//        response.setHeader("Access-Control-Allow-Methods", "*");
147
+//        response.setHeader("Access-Control-Max-Age", "3600");
148
+//        response.setHeader("Access-Control-Allow-Headers", "*");
149
+//        response.setHeader("Access-Control-Allow-Credentials", "true");
150
+        log.error("全局异常", e);
151
+        return TDBAResponseBuilder.buildDefaultError();
152
+    }
153
+
154
+//    @ExceptionHandler(AuthenticationException.class)
155
+//    public TDBAResponse authenticationException(AuthenticationException e, HttpServletResponse response){
156
+//        log.error("用户信息验证失败 ", e);
157
+////        response.setStatus(HttpStatus.UNAUTHORIZED.value());
158
+//        return TDBAResponseBuilder.buildAuthorize();
159
+//    }
160
+
161
+    @ExceptionHandler(TokenExpiredException.class)
162
+    public TDBAResponse tokenExpiredException(TokenExpiredException e, HttpServletResponse response){
163
+        log.error("token失效 ", e);
164
+//        response.setStatus(HttpStatus.UNAUTHORIZED.value());
165
+        return TDBAResponseBuilder.buildAuthorize();
166
+    }
167
+
168
+    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
169
+    public void httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e,
170
+                                                       HttpServletResponse response){
171
+        log.error("request method 不支持", e);
172
+        response.setStatus(HttpStatus.METHOD_NOT_ALLOWED.value());
173
+
174
+    }
175
+
176
+    @ExceptionHandler(HttpMessageNotReadableException.class)
177
+    public TDBAResponse httpMessageNotReadableException(HttpMessageNotReadableException e){
178
+        log.error("请求参数有误", e);
179
+        return TDBAResponseBuilder.buildError("", "请检查参数是否有误");
180
+    }
181
+
182
+    @ExceptionHandler(NullPointerException.class)
183
+    public TDBAResponse nullPointerException(NullPointerException e){
184
+        log.error("请求参数有误", e);
185
+        return StringUtils.hasText(e.getMessage()) ?
186
+           TDBAResponseBuilder.buildError("", e.getMessage()) : TDBAResponseBuilder.buildDefaultError();
187
+    }
188
+}

+ 22 - 0
src/main/java/com/tdba/cxb/ares/api/config/WebMvcConfig.java

@@ -0,0 +1,22 @@
1
+package com.tdba.cxb.ares.api.config;
2
+
3
+import com.tdba.cxb.ares.api.util.BaseUserArgumentResolver;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
6
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * @description:
12
+ * @author: libo
13
+ */
14
+@Configuration
15
+public class WebMvcConfig implements WebMvcConfigurer {
16
+
17
+    @Override
18
+    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
19
+        resolvers.add(new BaseUserArgumentResolver());
20
+    }
21
+
22
+}

+ 83 - 0
src/main/java/com/tdba/cxb/ares/api/config/http/LoggingClientHttpRequestInterceptor.java

@@ -0,0 +1,83 @@
1
+package com.tdba.cxb.ares.api.config.http;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.http.HttpRequest;
6
+import org.springframework.http.client.ClientHttpRequestExecution;
7
+import org.springframework.http.client.ClientHttpRequestInterceptor;
8
+import org.springframework.http.client.ClientHttpResponse;
9
+import org.springframework.util.CollectionUtils;
10
+
11
+import java.io.BufferedReader;
12
+import java.io.IOException;
13
+import java.io.InputStreamReader;
14
+import java.net.URLDecoder;
15
+import java.util.List;
16
+
17
+/**
18
+ * @description: http客户端请求日志
19
+ * @author: libo
20
+ */
21
+public class LoggingClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
22
+
23
+    private static Logger log = LoggerFactory.getLogger(LoggingClientHttpRequestInterceptor.class);
24
+
25
+    @Override
26
+    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
27
+        traceRequest(request, body);
28
+        ClientHttpResponse response = execution.execute(request, body);
29
+        traceResponse(response);
30
+        return response;
31
+    }
32
+
33
+    private void traceRequest(HttpRequest request, byte[] body) throws IOException {
34
+
35
+        List<String> contentTyps = request.getHeaders().get("Content-Type");
36
+        Boolean flag = true;
37
+        if(null != contentTyps){
38
+            for(String row : contentTyps){
39
+                if(row.contains("boundary=")){
40
+                    flag = false;
41
+                    break;
42
+                }
43
+            }
44
+        }
45
+
46
+        if(flag) {
47
+            log.debug("===========================request begin================================================");
48
+            log.debug("URI         : {}", request.getURI());
49
+            log.debug("Method      : {}", request.getMethod());
50
+            log.debug("Headers     : {}", request.getHeaders());
51
+            log.debug("Request body: {}", URLDecoder.decode(new String(body, "UTF-8"), "utf-8"));
52
+            log.debug("==========================request end================================================");
53
+        }
54
+    }
55
+
56
+    private void traceResponse(ClientHttpResponse response) throws IOException {
57
+        StringBuilder inputStringBuilder = new StringBuilder();
58
+        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getBody(), "UTF-8"))) {
59
+            String line = bufferedReader.readLine();
60
+            while (line != null) {
61
+                inputStringBuilder.append(line);
62
+                inputStringBuilder.append('\n');
63
+                line = bufferedReader.readLine();
64
+            }
65
+        }
66
+
67
+        List<String> contentTypes = response.getHeaders().get("Content-Type");
68
+        if(CollectionUtils.isEmpty(contentTypes)){
69
+            return;
70
+        }
71
+        if(!(contentTypes.contains("application/msexcel;charset=UTF-8")
72
+                || contentTypes.contains("application/pdf")
73
+                || contentTypes.contains("application/vnd.ms-excel"))){
74
+            log.debug("============================response begin==========================================");
75
+            log.debug("Status code  : {}", response.getStatusCode());
76
+            log.debug("Status text  : {}", response.getStatusText());
77
+            log.debug("Headers      : {}", response.getHeaders());
78
+            log.debug("Response body: {}", inputStringBuilder);//WARNING: comment out in production to improve performance
79
+            log.debug("=======================response end=================================================");
80
+        }
81
+    }
82
+
83
+}

+ 47 - 0
src/main/java/com/tdba/cxb/ares/api/config/http/RestTemplateConfig.java

@@ -0,0 +1,47 @@
1
+package com.tdba.cxb.ares.api.config.http;
2
+
3
+import org.apache.http.client.HttpClient;
4
+import org.apache.http.impl.client.HttpClientBuilder;
5
+import org.apache.http.impl.client.LaxRedirectStrategy;
6
+import org.springframework.context.ApplicationContext;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
10
+import org.springframework.http.client.ClientHttpRequestFactory;
11
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
12
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
13
+import org.springframework.web.client.RestTemplate;
14
+
15
+import javax.annotation.PostConstruct;
16
+import javax.annotation.Resource;
17
+
18
+/**
19
+ * @description: http客户端配置
20
+ * @author: libo
21
+ */
22
+@Configuration
23
+public class RestTemplateConfig {
24
+    @Bean
25
+    public RestTemplate restTemplate() {
26
+
27
+        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
28
+        final HttpClient httpClient = HttpClientBuilder.create()
29
+                .setRedirectStrategy(new LaxRedirectStrategy()) //处理响应302
30
+                .build();
31
+        factory.setHttpClient(httpClient);
32
+
33
+        // 当我们希望读取两次body时需要使用BufferingClientHttpRequestFactory,默认的SimpleClientHttpRequestFactory实现只能读取一次body
34
+        RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(factory));
35
+        restTemplate.getInterceptors().add(new LoggingClientHttpRequestInterceptor());
36
+
37
+        return restTemplate;
38
+    }
39
+
40
+    @Bean
41
+    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
42
+        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
43
+        factory.setReadTimeout(5000);//单位为ms
44
+        factory.setConnectTimeout(5000);//单位为ms
45
+        return factory;
46
+    }
47
+}

+ 31 - 0
src/main/java/com/tdba/cxb/ares/api/controller/PaymentController.java

@@ -0,0 +1,31 @@
1
+package com.tdba.cxb.ares.api.controller;
2
+
3
+import com.tdba.cxb.ares.api.model.TDBAResponse;
4
+import com.tdba.cxb.ares.api.service.PaymentService;
5
+import com.tdba.cxb.ares.api.util.TDBAController;
6
+import org.springframework.context.annotation.Profile;
7
+import org.springframework.web.bind.annotation.GetMapping;
8
+
9
+import javax.annotation.Resource;
10
+
11
+import static com.tdba.cxb.ares.api.model.TDBAResponseBuilder.buildSuccess;
12
+
13
+/**
14
+ * @program: order-web
15
+ * @description: 支付
16
+ * @author: libo
17
+ * @create: 2022-05-23 15:47:00
18
+ */
19
+@Profile("dev")
20
+@TDBAController("payment")
21
+public class PaymentController {
22
+
23
+    @Resource
24
+    private PaymentService paymentService;
25
+
26
+    @GetMapping("list")
27
+    public TDBAResponse test(){
28
+        paymentService.test();
29
+        return buildSuccess("123");
30
+    }
31
+}

+ 55 - 0
src/main/java/com/tdba/cxb/ares/api/controller/ProductAttrValueController.java

@@ -0,0 +1,55 @@
1
+package com.tdba.cxb.ares.api.controller;
2
+
3
+import com.tdba.cxb.ares.api.model.ProductAttrValueReq;
4
+import com.tdba.cxb.ares.api.model.TDBAResponse;
5
+import com.tdba.cxb.ares.api.service.ProductService;
6
+import com.tdba.cxb.ares.api.util.TDBAController;
7
+import org.springframework.validation.annotation.Validated;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.RequestBody;
11
+import org.springframework.web.bind.annotation.RequestParam;
12
+
13
+import javax.annotation.PostConstruct;
14
+import javax.annotation.Resource;
15
+import javax.validation.constraints.NotEmpty;
16
+import javax.validation.constraints.NotNull;
17
+
18
+import static com.tdba.cxb.ares.api.model.TDBAResponseBuilder.buildSuccess;
19
+
20
+/**
21
+ * @program: order-web
22
+ * @description: 商品规格
23
+ * @author: libo
24
+ * @create: 2022-05-29 11:46:43
25
+ */
26
+@Validated
27
+@TDBAController("/api/v1/product_attr_value")
28
+public class ProductAttrValueController {
29
+
30
+    @Resource
31
+    private ProductService productService;
32
+
33
+//    /**
34
+//     * 获取规格详情
35
+//     * @param sku   规格标识
36
+//     *     多个属性逗号隔开,例如: 黑色,32
37
+//     * @param productId 上皮ID
38
+//     * @return
39
+//     */
40
+//    @GetMapping("detail")
41
+//    public TDBAResponse detail(@RequestParam(required = false, name = "sku") @NotEmpty(message = "规格标识不能为空") String sku,
42
+//                               @RequestParam(required = false, name = "product_id") @NotNull(message = "商品ID不能为空") Integer productId){
43
+//        return buildSuccess(productService.attrValueDetail(sku, productId));
44
+//    }
45
+
46
+    /**
47
+     * 获取规格详情
48
+     * @param sku   规格标识
49
+     * @return
50
+     */
51
+    @PostMapping("detail")
52
+    public TDBAResponse detail(@Validated @RequestBody ProductAttrValueReq param){
53
+        return buildSuccess(productService.attrValueDetail(param));
54
+    }
55
+}

+ 37 - 0
src/main/java/com/tdba/cxb/ares/api/controller/ProductController.java

@@ -0,0 +1,37 @@
1
+package com.tdba.cxb.ares.api.controller;
2
+
3
+import com.tdba.cxb.ares.api.model.TDBAResponse;
4
+import com.tdba.cxb.ares.api.service.ProductService;
5
+import com.tdba.cxb.ares.api.util.TDBAController;
6
+import org.springframework.validation.annotation.Validated;
7
+import org.springframework.web.bind.annotation.GetMapping;
8
+import org.springframework.web.bind.annotation.RequestParam;
9
+
10
+import javax.annotation.Resource;
11
+import javax.validation.constraints.NotNull;
12
+
13
+import static com.tdba.cxb.ares.api.model.TDBAResponseBuilder.buildSuccess;
14
+
15
+/**
16
+ * @program: order-web
17
+ * @description: 商品
18
+ * @author: libo
19
+ * @create: 2022-05-29 11:01:02
20
+ */
21
+@Validated
22
+@TDBAController("/api/v1/product")
23
+public class ProductController {
24
+
25
+    @Resource
26
+    private ProductService productService;
27
+
28
+    /**
29
+     * 商品详情
30
+     * @param id    商品ID
31
+     * @return
32
+     */
33
+    @GetMapping("detail")
34
+    public TDBAResponse detail(@RequestParam(required = false, name = "id") @NotNull(message = "商品ID不能为空") Integer id){
35
+        return buildSuccess(productService.detail(id));
36
+    }
37
+}

+ 78 - 0
src/main/java/com/tdba/cxb/ares/api/model/BaseUser.java

@@ -0,0 +1,78 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @description: 登录用户信息
5
+ * @author: libo
6
+ */
7
+public class BaseUser {
8
+
9
+    /** 登录用户ID*/
10
+    private Integer loginId;
11
+
12
+
13
+    /** 企业ID*/
14
+    private Integer companyId;
15
+
16
+    /** 用户ID*/
17
+    private Integer userId;
18
+
19
+    public Integer getLoginId() {
20
+        return loginId;
21
+    }
22
+
23
+    public void setLoginId(Integer loginId) {
24
+        this.loginId = loginId;
25
+    }
26
+
27
+    public Integer getCompanyId() {
28
+        return companyId;
29
+    }
30
+
31
+    public void setCompanyId(Integer companyId) {
32
+        this.companyId = companyId;
33
+    }
34
+
35
+    public Integer getUserId() {
36
+        return userId;
37
+    }
38
+
39
+    public void setUserId(Integer userId) {
40
+        this.userId = userId;
41
+    }
42
+
43
+    public static final class BaseUserBuilder {
44
+        private Integer loginId;
45
+        private Integer companyId;
46
+        private Integer userId;
47
+
48
+        private BaseUserBuilder() {
49
+        }
50
+
51
+        public static BaseUserBuilder aBaseUser() {
52
+            return new BaseUserBuilder();
53
+        }
54
+
55
+        public BaseUserBuilder withLoginId(Integer loginId) {
56
+            this.loginId = loginId;
57
+            return this;
58
+        }
59
+
60
+        public BaseUserBuilder withCompanyId(Integer companyId) {
61
+            this.companyId = companyId;
62
+            return this;
63
+        }
64
+
65
+        public BaseUserBuilder withUserId(Integer userId) {
66
+            this.userId = userId;
67
+            return this;
68
+        }
69
+
70
+        public BaseUser build() {
71
+            BaseUser baseUser = new BaseUser();
72
+            baseUser.setLoginId(loginId);
73
+            baseUser.setCompanyId(companyId);
74
+            baseUser.setUserId(userId);
75
+            return baseUser;
76
+        }
77
+    }
78
+}

+ 54 - 0
src/main/java/com/tdba/cxb/ares/api/model/MerchantVo.java

@@ -0,0 +1,54 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 商户
6
+ * @author: libo
7
+ * @create: 2022-05-29 14:10:23
8
+ */
9
+public class MerchantVo {
10
+
11
+    /** 商户ID*/
12
+    private Integer id;
13
+
14
+    /** 商户名称*/
15
+    private String name;
16
+
17
+    /** 在售商品总数*/
18
+    private Integer product_count;
19
+
20
+    /** 头像*/
21
+    private String avatar;
22
+
23
+    public Integer getId() {
24
+        return id;
25
+    }
26
+
27
+    public void setId(Integer id) {
28
+        this.id = id;
29
+    }
30
+
31
+    public String getName() {
32
+        return name;
33
+    }
34
+
35
+    public void setName(String name) {
36
+        this.name = name;
37
+    }
38
+
39
+    public Integer getProduct_count() {
40
+        return product_count;
41
+    }
42
+
43
+    public void setProduct_count(Integer product_count) {
44
+        this.product_count = product_count;
45
+    }
46
+
47
+    public String getAvatar() {
48
+        return avatar;
49
+    }
50
+
51
+    public void setAvatar(String avatar) {
52
+        this.avatar = avatar;
53
+    }
54
+}

+ 43 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductAttrDto.java

@@ -0,0 +1,43 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 商品规格
6
+ * @author: libo
7
+ * @create: 2022-05-29 16:13:01
8
+ */
9
+public class ProductAttrDto {
10
+
11
+    /** 商品ID*/
12
+    private Integer product_id;
13
+
14
+    /** 属性名称*/
15
+    private String attr_name;
16
+
17
+    /** 属性值,多个 -!- 隔开*/
18
+    private String attr_values;
19
+
20
+    public Integer getProduct_id() {
21
+        return product_id;
22
+    }
23
+
24
+    public void setProduct_id(Integer product_id) {
25
+        this.product_id = product_id;
26
+    }
27
+
28
+    public String getAttr_name() {
29
+        return attr_name;
30
+    }
31
+
32
+    public void setAttr_name(String attr_name) {
33
+        this.attr_name = attr_name;
34
+    }
35
+
36
+    public String getAttr_values() {
37
+        return attr_values;
38
+    }
39
+
40
+    public void setAttr_values(String attr_values) {
41
+        this.attr_values = attr_values;
42
+    }
43
+}

+ 38 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductAttrValueReq.java

@@ -0,0 +1,38 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import javax.validation.constraints.NotEmpty;
4
+import javax.validation.constraints.NotNull;
5
+import java.util.List;
6
+
7
+/**
8
+ * @program: order-web
9
+ * @description: 商品规格查询参数
10
+ * @author: libo
11
+ * @create: 2022-05-29 17:13:52
12
+ */
13
+public class ProductAttrValueReq {
14
+
15
+    /** 商品ID*/
16
+    @NotNull(message = "商品ID不能为空")
17
+    private Integer product_id;
18
+
19
+    /** 属性值列表*/
20
+//    @NotEmpty(message = "属性值列表不能为空")
21
+    private List<String> value_list;
22
+
23
+    public Integer getProduct_id() {
24
+        return product_id;
25
+    }
26
+
27
+    public void setProduct_id(Integer product_id) {
28
+        this.product_id = product_id;
29
+    }
30
+
31
+    public List<String> getValue_list() {
32
+        return value_list;
33
+    }
34
+
35
+    public void setValue_list(List<String> value_list) {
36
+        this.value_list = value_list;
37
+    }
38
+}

+ 82 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductAttrValueVo.java

@@ -0,0 +1,82 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnore;
4
+
5
+import java.math.BigDecimal;
6
+import java.util.List;
7
+
8
+/**
9
+ * @program: order-web
10
+ * @description: 商品规格关联
11
+ * @author: libo
12
+ * @create: 2022-05-29 15:37:19
13
+ */
14
+public class ProductAttrValueVo {
15
+
16
+    /** 名称*/
17
+    @JsonIgnore
18
+    private String sku;
19
+
20
+    /** 库存*/
21
+    private Integer stock;
22
+
23
+    /** 价格*/
24
+    private BigDecimal price;
25
+
26
+    /** 原价*/
27
+    private BigDecimal ot_price;
28
+
29
+    /** 唯一标识*/
30
+    private String unique;
31
+
32
+    /** 属性值列表*/
33
+    private List<String> value_list;
34
+
35
+    public List<String> getValue_list() {
36
+        return value_list;
37
+    }
38
+
39
+    public void setValue_list(List<String> value_list) {
40
+        this.value_list = value_list;
41
+    }
42
+
43
+    public String getSku() {
44
+        return sku;
45
+    }
46
+
47
+    public void setSku(String sku) {
48
+        this.sku = sku;
49
+    }
50
+
51
+    public Integer getStock() {
52
+        return stock;
53
+    }
54
+
55
+    public void setStock(Integer stock) {
56
+        this.stock = stock;
57
+    }
58
+
59
+    public BigDecimal getPrice() {
60
+        return price;
61
+    }
62
+
63
+    public void setPrice(BigDecimal price) {
64
+        this.price = price;
65
+    }
66
+
67
+    public BigDecimal getOt_price() {
68
+        return ot_price;
69
+    }
70
+
71
+    public void setOt_price(BigDecimal ot_price) {
72
+        this.ot_price = ot_price;
73
+    }
74
+
75
+    public String getUnique() {
76
+        return unique;
77
+    }
78
+
79
+    public void setUnique(String unique) {
80
+        this.unique = unique;
81
+    }
82
+}

+ 63 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductAttrVo.java

@@ -0,0 +1,63 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.util.List;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description: 商品规格
8
+ * @author: libo
9
+ * @create: 2022-05-29 14:41:12
10
+ */
11
+public class ProductAttrVo {
12
+
13
+    /** 名称*/
14
+    private String name;
15
+
16
+    /** 属性值列表*/
17
+    private List<String> valueList;
18
+
19
+    public String getName() {
20
+        return name;
21
+    }
22
+
23
+    public void setName(String name) {
24
+        this.name = name;
25
+    }
26
+
27
+    public List<String> getValueList() {
28
+        return valueList;
29
+    }
30
+
31
+    public void setValueList(List<String> valueList) {
32
+        this.valueList = valueList;
33
+    }
34
+
35
+    public static final class ProductAttrVoBuilder {
36
+        private String name;
37
+        private List<String> valueList;
38
+
39
+        private ProductAttrVoBuilder() {
40
+        }
41
+
42
+        public static ProductAttrVoBuilder aProductAttrVo() {
43
+            return new ProductAttrVoBuilder();
44
+        }
45
+
46
+        public ProductAttrVoBuilder withName(String name) {
47
+            this.name = name;
48
+            return this;
49
+        }
50
+
51
+        public ProductAttrVoBuilder withValueList(List<String> valueList) {
52
+            this.valueList = valueList;
53
+            return this;
54
+        }
55
+
56
+        public ProductAttrVo build() {
57
+            ProductAttrVo productAttrVo = new ProductAttrVo();
58
+            productAttrVo.setName(name);
59
+            productAttrVo.setValueList(valueList);
60
+            return productAttrVo;
61
+        }
62
+    }
63
+}

+ 43 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductContent.java

@@ -0,0 +1,43 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 商品详情介绍
6
+ * @author: libo
7
+ * @create: 2022-05-29 17:38:10
8
+ */
9
+public class ProductContent {
10
+
11
+    /** 商品ID*/
12
+    private Integer product_id;
13
+
14
+    /** 内容*/
15
+    private String content;
16
+
17
+    /** 类型*/
18
+    private Integer type;
19
+
20
+    public Integer getProduct_id() {
21
+        return product_id;
22
+    }
23
+
24
+    public void setProduct_id(Integer product_id) {
25
+        this.product_id = product_id;
26
+    }
27
+
28
+    public String getContent() {
29
+        return content;
30
+    }
31
+
32
+    public void setContent(String content) {
33
+        this.content = content;
34
+    }
35
+
36
+    public Integer getType() {
37
+        return type;
38
+    }
39
+
40
+    public void setType(Integer type) {
41
+        this.type = type;
42
+    }
43
+}

+ 117 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductResp.java

@@ -0,0 +1,117 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.util.List;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description: 商品详情
8
+ * @author: libo
9
+ * @create: 2022-05-29 13:37:29
10
+ */
11
+public class ProductResp {
12
+
13
+    /** 商品*/
14
+    private ProductVo product;
15
+
16
+    /** 商户*/
17
+    private MerchantVo merchant;
18
+
19
+    /** 推荐商品列表*/
20
+    private List<ProductSimple> recommend_list;
21
+
22
+    /** 规格列表*/
23
+    private List<ProductAttrVo> attr_list;
24
+
25
+    /** 默认规格信息*/
26
+    private ProductAttrValueVo attr_value;
27
+
28
+    public ProductVo getProduct() {
29
+        return product;
30
+    }
31
+
32
+    public void setProduct(ProductVo product) {
33
+        this.product = product;
34
+    }
35
+
36
+    public MerchantVo getMerchant() {
37
+        return merchant;
38
+    }
39
+
40
+    public void setMerchant(MerchantVo merchant) {
41
+        this.merchant = merchant;
42
+    }
43
+
44
+    public List<ProductSimple> getRecommend_list() {
45
+        return recommend_list;
46
+    }
47
+
48
+    public void setRecommend_list(List<ProductSimple> recommend_list) {
49
+        this.recommend_list = recommend_list;
50
+    }
51
+
52
+    public List<ProductAttrVo> getAttr_list() {
53
+        return attr_list;
54
+    }
55
+
56
+    public void setAttr_list(List<ProductAttrVo> attr_list) {
57
+        this.attr_list = attr_list;
58
+    }
59
+
60
+    public ProductAttrValueVo getAttr_value() {
61
+        return attr_value;
62
+    }
63
+
64
+    public void setAttr_value(ProductAttrValueVo attr_value) {
65
+        this.attr_value = attr_value;
66
+    }
67
+
68
+    public static final class ProductRespBuilder {
69
+        private ProductVo product;
70
+        private MerchantVo merchant;
71
+        private List<ProductSimple> recommend_list;
72
+        private List<ProductAttrVo> attr_list;
73
+        private ProductAttrValueVo attr_value;
74
+
75
+        private ProductRespBuilder() {
76
+        }
77
+
78
+        public static ProductRespBuilder aProductResp() {
79
+            return new ProductRespBuilder();
80
+        }
81
+
82
+        public ProductRespBuilder withProduct(ProductVo product) {
83
+            this.product = product;
84
+            return this;
85
+        }
86
+
87
+        public ProductRespBuilder withMerchant(MerchantVo merchant) {
88
+            this.merchant = merchant;
89
+            return this;
90
+        }
91
+
92
+        public ProductRespBuilder withRecommend_list(List<ProductSimple> recommend_list) {
93
+            this.recommend_list = recommend_list;
94
+            return this;
95
+        }
96
+
97
+        public ProductRespBuilder withAttr_list(List<ProductAttrVo> attr_list) {
98
+            this.attr_list = attr_list;
99
+            return this;
100
+        }
101
+
102
+        public ProductRespBuilder withAttr_value(ProductAttrValueVo attr_value) {
103
+            this.attr_value = attr_value;
104
+            return this;
105
+        }
106
+
107
+        public ProductResp build() {
108
+            ProductResp productResp = new ProductResp();
109
+            productResp.setProduct(product);
110
+            productResp.setMerchant(merchant);
111
+            productResp.setRecommend_list(recommend_list);
112
+            productResp.setAttr_list(attr_list);
113
+            productResp.setAttr_value(attr_value);
114
+            return productResp;
115
+        }
116
+    }
117
+}

+ 78 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductSimple.java

@@ -0,0 +1,78 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.math.BigDecimal;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description: 商品
8
+ * @author: libo
9
+ * @create: 2022-05-29 14:23:44
10
+ */
11
+public class ProductSimple {
12
+
13
+    /** 商品ID*/
14
+    private Integer id;
15
+
16
+    /** 商品名称*/
17
+    private String name;
18
+
19
+    /** 养老金*/
20
+    private BigDecimal annuity;
21
+
22
+    /** 价格*/
23
+    private BigDecimal price;
24
+
25
+    /** 原价*/
26
+    private BigDecimal ot_price;
27
+
28
+    /** 主图*/
29
+    private String image;
30
+
31
+    public Integer getId() {
32
+        return id;
33
+    }
34
+
35
+    public void setId(Integer id) {
36
+        this.id = id;
37
+    }
38
+
39
+    public String getName() {
40
+        return name;
41
+    }
42
+
43
+    public void setName(String name) {
44
+        this.name = name;
45
+    }
46
+
47
+    public BigDecimal getAnnuity() {
48
+        return annuity;
49
+    }
50
+
51
+    public void setAnnuity(BigDecimal annuity) {
52
+        this.annuity = annuity;
53
+    }
54
+
55
+    public BigDecimal getPrice() {
56
+        return price;
57
+    }
58
+
59
+    public void setPrice(BigDecimal price) {
60
+        this.price = price;
61
+    }
62
+
63
+    public BigDecimal getOt_price() {
64
+        return ot_price;
65
+    }
66
+
67
+    public void setOt_price(BigDecimal ot_price) {
68
+        this.ot_price = ot_price;
69
+    }
70
+
71
+    public String getImage() {
72
+        return image;
73
+    }
74
+
75
+    public void setImage(String image) {
76
+        this.image = image;
77
+    }
78
+}

+ 117 - 0
src/main/java/com/tdba/cxb/ares/api/model/ProductVo.java

@@ -0,0 +1,117 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import com.fasterxml.jackson.annotation.JacksonAnnotation;
4
+import com.fasterxml.jackson.annotation.JsonIgnore;
5
+
6
+import java.math.BigDecimal;
7
+import java.util.List;
8
+
9
+/**
10
+ * @program: order-web
11
+ * @description: 商品
12
+ * @author: libo
13
+ * @create: 2022-05-29 13:38:06
14
+ */
15
+public class ProductVo {
16
+
17
+    /** 商品ID*/
18
+    private Integer id;
19
+
20
+    /** 主图url*/
21
+    private String image;
22
+
23
+    /** 轮播图列表*/
24
+    @JsonIgnore
25
+    private String slider_image;
26
+
27
+    /** 商品简介*/
28
+    private String info;
29
+
30
+    /** 商品名称*/
31
+    private String name;
32
+
33
+    /** 养老金*/
34
+    private BigDecimal annuity;
35
+
36
+    /** 详情介绍HTML源码*/
37
+    private String content;
38
+
39
+    /** 商户ID*/
40
+    @JsonIgnore
41
+    private Integer mer_id;
42
+
43
+    /** 轮播图列表*/
44
+    private List<String> slider_image_list;
45
+
46
+    public Integer getId() {
47
+        return id;
48
+    }
49
+
50
+    public void setId(Integer id) {
51
+        this.id = id;
52
+    }
53
+
54
+    public String getImage() {
55
+        return image;
56
+    }
57
+
58
+    public void setImage(String image) {
59
+        this.image = image;
60
+    }
61
+
62
+    public String getSlider_image() {
63
+        return slider_image;
64
+    }
65
+
66
+    public void setSlider_image(String slider_image) {
67
+        this.slider_image = slider_image;
68
+    }
69
+
70
+    public String getInfo() {
71
+        return info;
72
+    }
73
+
74
+    public void setInfo(String info) {
75
+        this.info = info;
76
+    }
77
+
78
+    public String getName() {
79
+        return name;
80
+    }
81
+
82
+    public void setName(String name) {
83
+        this.name = name;
84
+    }
85
+
86
+    public BigDecimal getAnnuity() {
87
+        return annuity;
88
+    }
89
+
90
+    public void setAnnuity(BigDecimal annuity) {
91
+        this.annuity = annuity;
92
+    }
93
+
94
+    public String getContent() {
95
+        return content;
96
+    }
97
+
98
+    public void setContent(String content) {
99
+        this.content = content;
100
+    }
101
+
102
+    public Integer getMer_id() {
103
+        return mer_id;
104
+    }
105
+
106
+    public void setMer_id(Integer mer_id) {
107
+        this.mer_id = mer_id;
108
+    }
109
+
110
+    public List<String> getSlider_image_list() {
111
+        return slider_image_list;
112
+    }
113
+
114
+    public void setSlider_image_list(List<String> slider_image_list) {
115
+        this.slider_image_list = slider_image_list;
116
+    }
117
+}

+ 277 - 0
src/main/java/com/tdba/cxb/ares/api/model/RrxStoreGroupOrder.java

@@ -0,0 +1,277 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+import java.math.BigDecimal;
4
+import java.time.LocalDateTime;
5
+
6
+/**
7
+ * @program: order-web
8
+ * @description: 订单主表
9
+ * @author: libo
10
+ * @create: 2022-05-23 15:52:14
11
+ */
12
+public class RrxStoreGroupOrder {
13
+
14
+    /** */
15
+    private Integer groupOrderId;
16
+
17
+    /** 订单号*/
18
+    private String groupOrderSn;
19
+
20
+    /** 用户*/
21
+    private Integer uid;
22
+
23
+    /** 邮费*/
24
+    private BigDecimal totalPostage;
25
+
26
+    /** 订单总额*/
27
+    private BigDecimal totalPrice;
28
+
29
+    /** 商品数*/
30
+    private Integer totalNum;
31
+
32
+    /** 优惠金额*/
33
+    private BigDecimal couponPrice;
34
+
35
+    /** 联系人*/
36
+    private String realName;
37
+
38
+    /** 联系电话*/
39
+    private String userPhone;
40
+
41
+    /** 收货地址*/
42
+    private String userAddress;
43
+
44
+    /** 支付金额*/
45
+    private BigDecimal payPrice;
46
+
47
+    /** 支付邮费*/
48
+    private BigDecimal payPostage;
49
+
50
+    /** 成本价*/
51
+    private BigDecimal cost;
52
+
53
+    /** 赠送优惠券*/
54
+    private String giveCouponIds;
55
+
56
+    /** 是否支付*/
57
+    private Integer paid;
58
+
59
+    /** 支付时间*/
60
+    private LocalDateTime payTime;
61
+
62
+    /** 支付方式*/
63
+    private Integer payType;
64
+
65
+    /** 创建时间*/
66
+    private LocalDateTime createTime;
67
+
68
+    /** 是否提醒*/
69
+    private Integer isRemind;
70
+
71
+    /** */
72
+    private Integer isDel;
73
+
74
+    /** 订单号随机数*/
75
+    private String rand;
76
+
77
+    /** 分账*/
78
+    private Integer split;
79
+
80
+    /** 首信易交易流水号*/
81
+    private String serialNumber;
82
+
83
+    /** 测试订单*/
84
+    private Integer testOrder;
85
+
86
+    public Integer getGroupOrderId() {
87
+        return groupOrderId;
88
+    }
89
+
90
+    public void setGroupOrderId(Integer groupOrderId) {
91
+        this.groupOrderId = groupOrderId;
92
+    }
93
+
94
+    public String getGroupOrderSn() {
95
+        return groupOrderSn;
96
+    }
97
+
98
+    public void setGroupOrderSn(String groupOrderSn) {
99
+        this.groupOrderSn = groupOrderSn;
100
+    }
101
+
102
+    public Integer getUid() {
103
+        return uid;
104
+    }
105
+
106
+    public void setUid(Integer uid) {
107
+        this.uid = uid;
108
+    }
109
+
110
+    public BigDecimal getTotalPostage() {
111
+        return totalPostage;
112
+    }
113
+
114
+    public void setTotalPostage(BigDecimal totalPostage) {
115
+        this.totalPostage = totalPostage;
116
+    }
117
+
118
+    public BigDecimal getTotalPrice() {
119
+        return totalPrice;
120
+    }
121
+
122
+    public void setTotalPrice(BigDecimal totalPrice) {
123
+        this.totalPrice = totalPrice;
124
+    }
125
+
126
+    public Integer getTotalNum() {
127
+        return totalNum;
128
+    }
129
+
130
+    public void setTotalNum(Integer totalNum) {
131
+        this.totalNum = totalNum;
132
+    }
133
+
134
+    public BigDecimal getCouponPrice() {
135
+        return couponPrice;
136
+    }
137
+
138
+    public void setCouponPrice(BigDecimal couponPrice) {
139
+        this.couponPrice = couponPrice;
140
+    }
141
+
142
+    public String getRealName() {
143
+        return realName;
144
+    }
145
+
146
+    public void setRealName(String realName) {
147
+        this.realName = realName;
148
+    }
149
+
150
+    public String getUserPhone() {
151
+        return userPhone;
152
+    }
153
+
154
+    public void setUserPhone(String userPhone) {
155
+        this.userPhone = userPhone;
156
+    }
157
+
158
+    public String getUserAddress() {
159
+        return userAddress;
160
+    }
161
+
162
+    public void setUserAddress(String userAddress) {
163
+        this.userAddress = userAddress;
164
+    }
165
+
166
+    public BigDecimal getPayPrice() {
167
+        return payPrice;
168
+    }
169
+
170
+    public void setPayPrice(BigDecimal payPrice) {
171
+        this.payPrice = payPrice;
172
+    }
173
+
174
+    public BigDecimal getPayPostage() {
175
+        return payPostage;
176
+    }
177
+
178
+    public void setPayPostage(BigDecimal payPostage) {
179
+        this.payPostage = payPostage;
180
+    }
181
+
182
+    public BigDecimal getCost() {
183
+        return cost;
184
+    }
185
+
186
+    public void setCost(BigDecimal cost) {
187
+        this.cost = cost;
188
+    }
189
+
190
+    public String getGiveCouponIds() {
191
+        return giveCouponIds;
192
+    }
193
+
194
+    public void setGiveCouponIds(String giveCouponIds) {
195
+        this.giveCouponIds = giveCouponIds;
196
+    }
197
+
198
+    public Integer getPaid() {
199
+        return paid;
200
+    }
201
+
202
+    public void setPaid(Integer paid) {
203
+        this.paid = paid;
204
+    }
205
+
206
+    public LocalDateTime getPayTime() {
207
+        return payTime;
208
+    }
209
+
210
+    public void setPayTime(LocalDateTime payTime) {
211
+        this.payTime = payTime;
212
+    }
213
+
214
+    public Integer getPayType() {
215
+        return payType;
216
+    }
217
+
218
+    public void setPayType(Integer payType) {
219
+        this.payType = payType;
220
+    }
221
+
222
+    public LocalDateTime getCreateTime() {
223
+        return createTime;
224
+    }
225
+
226
+    public void setCreateTime(LocalDateTime createTime) {
227
+        this.createTime = createTime;
228
+    }
229
+
230
+    public Integer getIsRemind() {
231
+        return isRemind;
232
+    }
233
+
234
+    public void setIsRemind(Integer isRemind) {
235
+        this.isRemind = isRemind;
236
+    }
237
+
238
+    public Integer getIsDel() {
239
+        return isDel;
240
+    }
241
+
242
+    public void setIsDel(Integer isDel) {
243
+        this.isDel = isDel;
244
+    }
245
+
246
+    public String getRand() {
247
+        return rand;
248
+    }
249
+
250
+    public void setRand(String rand) {
251
+        this.rand = rand;
252
+    }
253
+
254
+    public Integer getSplit() {
255
+        return split;
256
+    }
257
+
258
+    public void setSplit(Integer split) {
259
+        this.split = split;
260
+    }
261
+
262
+    public String getSerialNumber() {
263
+        return serialNumber;
264
+    }
265
+
266
+    public void setSerialNumber(String serialNumber) {
267
+        this.serialNumber = serialNumber;
268
+    }
269
+
270
+    public Integer getTestOrder() {
271
+        return testOrder;
272
+    }
273
+
274
+    public void setTestOrder(Integer testOrder) {
275
+        this.testOrder = testOrder;
276
+    }
277
+}

+ 43 - 0
src/main/java/com/tdba/cxb/ares/api/model/TDBAResponse.java

@@ -0,0 +1,43 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 公共响应
6
+ * @author: libo
7
+ * @create: 2022-05-23 14:44:14
8
+ */
9
+public class TDBAResponse {
10
+
11
+    /** 数据*/
12
+    private Object data;
13
+
14
+    /** 状态值*/
15
+    private String status;
16
+
17
+    /** 消息*/
18
+    private String message;
19
+
20
+    public Object getData() {
21
+        return data;
22
+    }
23
+
24
+    public void setData(Object data) {
25
+        this.data = data;
26
+    }
27
+
28
+    public String getStatus() {
29
+        return status;
30
+    }
31
+
32
+    public void setStatus(String status) {
33
+        this.status = status;
34
+    }
35
+
36
+    public String getMessage() {
37
+        return message;
38
+    }
39
+
40
+    public void setMessage(String message) {
41
+        this.message = message;
42
+    }
43
+}

+ 69 - 0
src/main/java/com/tdba/cxb/ares/api/model/TDBAResponseBuilder.java

@@ -0,0 +1,69 @@
1
+package com.tdba.cxb.ares.api.model;
2
+
3
+/**
4
+ * @description: 响应构造器
5
+ * @author: libo
6
+ */
7
+public class TDBAResponseBuilder {
8
+
9
+    /**
10
+     * 构建成功消息体
11
+     *
12
+     * @param data 返回数据
13
+     * @return
14
+     */
15
+    public static TDBAResponse buildSuccess(Object data) {
16
+        return build(data, "success", "0");
17
+    }
18
+
19
+    /**
20
+     * 构建失败消息体
21
+     *
22
+     * @param data 返回数据
23
+     * @return
24
+     */
25
+    public static TDBAResponse buildFail(Object data) {
26
+        return build(data, "fail", "1");
27
+    }
28
+
29
+    /**
30
+     * 构建失败消息体
31
+     *
32
+     * @param data    返回数据
33
+     * @param message 消息
34
+     * @return
35
+     */
36
+    public static TDBAResponse buildError(Object data, String message) {
37
+        return build(data, message, "1");
38
+    }
39
+
40
+
41
+    public static TDBAResponse buildUnauthorize() {
42
+        return buildError("", "未授权操作");
43
+    }
44
+
45
+    public static TDBAResponse buildDefaultError() {
46
+        return buildError("", "系统出现错误, 请联系客服!");
47
+    }
48
+
49
+    public static TDBAResponse buildAuthorize() {
50
+        return build("", "登录状态过期,请重新登录", "2");
51
+    }
52
+
53
+    /**
54
+     * 构建返回消息体
55
+     *
56
+     * @param data    返回数据
57
+     * @param message 消息
58
+     * @param code    状态值
59
+     * @return
60
+     */
61
+    private static TDBAResponse build(Object data, String message, String code) {
62
+
63
+        TDBAResponse response = new TDBAResponse();
64
+        response.setData(data);
65
+        response.setStatus(code);
66
+        response.setMessage(message);
67
+        return response;
68
+    }
69
+}

+ 23 - 0
src/main/java/com/tdba/cxb/ares/api/repository/MerchantMapper.java

@@ -0,0 +1,23 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.MerchantVo;
4
+import com.tdba.cxb.ares.api.model.ProductVo;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+/**
9
+ * @program: order-web
10
+ * @description: 商户
11
+ * @author: libo
12
+ * @create: 2022-05-23 15:53:02
13
+ */
14
+@Mapper
15
+public interface MerchantMapper {
16
+
17
+    /**
18
+     * 商户详情
19
+     * @param id 商户ID
20
+     * @return
21
+     */
22
+    MerchantVo selectById(@Param("id") Integer id);
23
+}

+ 19 - 0
src/main/java/com/tdba/cxb/ares/api/repository/ProductAttrMapper.java

@@ -0,0 +1,19 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.ProductAttrDto;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * @program: order-web
11
+ * @description: 商品规格
12
+ * @author: libo
13
+ * @create: 2022-05-29 16:15:44
14
+ */
15
+@Mapper
16
+public interface ProductAttrMapper {
17
+
18
+    List<ProductAttrDto> selectList(@Param("productId") Integer productId);
19
+}

+ 31 - 0
src/main/java/com/tdba/cxb/ares/api/repository/ProductAttrValueMapper.java

@@ -0,0 +1,31 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.ProductAttrValueVo;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+/**
8
+ * @program: order-web
9
+ * @description: 商户规格关联
10
+ * @author: libo
11
+ * @create: 2022-05-29 15:34:30
12
+ */
13
+@Mapper
14
+public interface ProductAttrValueMapper {
15
+
16
+    /**
17
+     * 查询一条,商品规格关联信息
18
+     * @param productId 商品ID
19
+     * @return
20
+     */
21
+    ProductAttrValueVo selectOne(@Param("productId") Integer productId);
22
+
23
+    /**
24
+     * 商品规格关联信息
25
+     * @param sku 多个规格属性值
26
+     * @param productId 商品ID
27
+     * @return
28
+     */
29
+    ProductAttrValueVo selectBySku(@Param("sku") String sku,
30
+                                   @Param("productId") Integer productId);
31
+}

+ 23 - 0
src/main/java/com/tdba/cxb/ares/api/repository/ProductContentMapper.java

@@ -0,0 +1,23 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.MerchantVo;
4
+import com.tdba.cxb.ares.api.model.ProductContent;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+/**
9
+ * @program: order-web
10
+ * @description: 商品详情介绍
11
+ * @author: libo
12
+ * @create: 2022-05-23 15:53:02
13
+ */
14
+@Mapper
15
+public interface ProductContentMapper {
16
+
17
+    /**
18
+     * 商品详情介绍
19
+     * @param productId 商品ID
20
+     * @return
21
+     */
22
+    ProductContent selectByProductId(@Param("productId") Integer productId);
23
+}

+ 32 - 0
src/main/java/com/tdba/cxb/ares/api/repository/ProductMapper.java

@@ -0,0 +1,32 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import com.tdba.cxb.ares.api.model.ProductSimple;
4
+import com.tdba.cxb.ares.api.model.ProductVo;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * @program: order-web
12
+ * @description: 商品
13
+ * @author: libo
14
+ * @create: 2022-05-23 15:53:02
15
+ */
16
+@Mapper
17
+public interface ProductMapper {
18
+
19
+    /**
20
+     * 商品详情
21
+     * @param id 商品ID
22
+     * @return
23
+     */
24
+    ProductVo selectById(@Param("id") Integer id);
25
+
26
+    /**
27
+     * 商品列表
28
+     * @param merId 商户ID
29
+     * @return
30
+     */
31
+    List<ProductSimple> selectList(@Param("merId") Integer merId);
32
+}

+ 16 - 0
src/main/java/com/tdba/cxb/ares/api/repository/RrxStoreGroupOrderMapper.java

@@ -0,0 +1,16 @@
1
+package com.tdba.cxb.ares.api.repository;
2
+
3
+import org.apache.ibatis.annotations.Mapper;
4
+import org.apache.ibatis.annotations.Param;
5
+
6
+/**
7
+ * @program: order-web
8
+ * @description: 订单主表
9
+ * @author: libo
10
+ * @create: 2022-05-23 15:53:02
11
+ */
12
+@Mapper
13
+public interface RrxStoreGroupOrderMapper{
14
+
15
+    Integer countById(@Param("id") Integer id);
16
+}

+ 27 - 0
src/main/java/com/tdba/cxb/ares/api/resolver/CustomBigDecimalSerializer.java

@@ -0,0 +1,27 @@
1
+package com.tdba.cxb.ares.api.resolver;
2
+
3
+import com.fasterxml.jackson.core.JsonGenerator;
4
+import com.fasterxml.jackson.databind.JsonSerializer;
5
+import com.fasterxml.jackson.databind.SerializerProvider;
6
+import com.tdba.cxb.ares.api.util.BigDecimalUtil;
7
+
8
+import java.io.IOException;
9
+import java.math.BigDecimal;
10
+import java.math.RoundingMode;
11
+
12
+/**
13
+ * @program: api-factoring
14
+ * @description: 自定义BigDecimal序列化
15
+ * @author: libo
16
+ * @create: 2021-04-20 18:44:45
17
+ */
18
+public class CustomBigDecimalSerializer extends JsonSerializer<BigDecimal> {
19
+
20
+    @Override
21
+    public void serialize(BigDecimal value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
22
+        if (null != value) {
23
+            jsonGenerator.writeString(BigDecimalUtil.getFormatOrginal(value.setScale(2, RoundingMode.HALF_UP)));
24
+        }
25
+    }
26
+}
27
+

+ 24 - 0
src/main/java/com/tdba/cxb/ares/api/resolver/CustomDoubleSerializer.java

@@ -0,0 +1,24 @@
1
+package com.tdba.cxb.ares.api.resolver;
2
+
3
+import com.fasterxml.jackson.core.JsonGenerator;
4
+import com.fasterxml.jackson.databind.JsonSerializer;
5
+import com.fasterxml.jackson.databind.SerializerProvider;
6
+import com.tdba.cxb.ares.api.util.DoubleUtil;
7
+
8
+import java.io.IOException;
9
+
10
+/**
11
+ * @program: api-factoring
12
+ * @description: 自定义Double序列化
13
+ * @author: libo
14
+ * @create: 2021-04-20 18:44:45
15
+ */
16
+public class CustomDoubleSerializer extends JsonSerializer<Double> {
17
+
18
+    @Override
19
+    public void serialize(Double value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
20
+        if(null != value) {
21
+            jsonGenerator.writeString(DoubleUtil.roundOff(value));
22
+        }
23
+    }
24
+}

+ 28 - 0
src/main/java/com/tdba/cxb/ares/api/resolver/CustomLocalDateTimeSerializer.java

@@ -0,0 +1,28 @@
1
+package com.tdba.cxb.ares.api.resolver;
2
+
3
+import com.fasterxml.jackson.core.JsonGenerator;
4
+import com.fasterxml.jackson.core.JsonProcessingException;
5
+import com.fasterxml.jackson.databind.JsonSerializer;
6
+import com.fasterxml.jackson.databind.SerializerProvider;
7
+import com.tdba.cxb.ares.api.util.DateUtil;
8
+
9
+import java.io.IOException;
10
+import java.time.LocalDateTime;
11
+
12
+/**
13
+ * @program: api-factoring
14
+ * @description: 自定义LocalDateTime序列化
15
+ * @author: libo
16
+ * @create: 2021-04-20 18:44:45
17
+ */
18
+public class CustomLocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
19
+
20
+    @Override
21
+    public void serialize(LocalDateTime value, JsonGenerator jgen, SerializerProvider provider)  throws IOException {
22
+        String result = "";
23
+        if(null != value){
24
+            result = DateUtil.formatString(value);
25
+        }
26
+        jgen.writeString(result);
27
+    }
28
+}

+ 23 - 0
src/main/java/com/tdba/cxb/ares/api/resolver/OriginalDoubleSerializer.java

@@ -0,0 +1,23 @@
1
+package com.tdba.cxb.ares.api.resolver;
2
+
3
+import com.fasterxml.jackson.core.JsonGenerator;
4
+import com.fasterxml.jackson.databind.JsonSerializer;
5
+import com.fasterxml.jackson.databind.SerializerProvider;
6
+
7
+import java.io.IOException;
8
+import java.time.LocalDateTime;
9
+
10
+/**
11
+ * @description: 原样输出数字
12
+ * @author: libo
13
+ * @create: 2021-03-02 09:43:48
14
+ */
15
+public class OriginalDoubleSerializer extends JsonSerializer<Double> {
16
+
17
+    @Override
18
+    public void serialize(Double value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
19
+        if (null != value) {
20
+            jsonGenerator.writeNumber(value);
21
+        }
22
+    }
23
+}

+ 23 - 0
src/main/java/com/tdba/cxb/ares/api/service/PaymentService.java

@@ -0,0 +1,23 @@
1
+package com.tdba.cxb.ares.api.service;
2
+
3
+import com.tdba.cxb.ares.api.repository.RrxStoreGroupOrderMapper;
4
+import org.springframework.stereotype.Service;
5
+
6
+import javax.annotation.Resource;
7
+
8
+/**
9
+ * @program: order-web
10
+ * @description: 支付
11
+ * @author: libo
12
+ * @create: 2022-05-23 15:48:14
13
+ */
14
+@Service
15
+public class PaymentService {
16
+
17
+    @Resource
18
+    private RrxStoreGroupOrderMapper rrxStoreGroupOrderMapper;
19
+
20
+    public void test(){
21
+        rrxStoreGroupOrderMapper.countById(2700);
22
+    }
23
+}

+ 94 - 0
src/main/java/com/tdba/cxb/ares/api/service/ProductService.java

@@ -0,0 +1,94 @@
1
+package com.tdba.cxb.ares.api.service;
2
+
3
+import com.tdba.cxb.ares.api.model.*;
4
+import com.tdba.cxb.ares.api.repository.*;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+import org.springframework.stereotype.Service;
8
+
9
+import javax.annotation.Resource;
10
+import java.util.List;
11
+import java.util.Objects;
12
+
13
+/**
14
+ * @program: order-web
15
+ * @description: 商品
16
+ * @author: libo
17
+ * @create: 2022-05-29 15:03:14
18
+ */
19
+@Service
20
+public class ProductService {
21
+
22
+    private static Logger logger = LoggerFactory.getLogger(ProductService.class);
23
+
24
+    @Resource
25
+    private ProductMapper productMapper;
26
+
27
+    @Resource
28
+    private MerchantMapper merchantMapper;
29
+
30
+    @Resource
31
+    private ProductAttrValueMapper productAttrValueMapper;
32
+
33
+    @Resource
34
+    private ProductAttrMapper productAttrMapper;
35
+
36
+    @Resource
37
+    private ProductContentMapper productContentMapper;
38
+
39
+    /**
40
+     * 商品详情
41
+     * @param id 商品ID
42
+     * @return
43
+     */
44
+    public ProductResp detail(Integer id){
45
+
46
+        ProductVo productVo = productMapper.selectById(id);
47
+        Objects.requireNonNull(productVo, "商品信息不存在或状态暂不可用");
48
+        Objects.requireNonNull(productVo.getMer_id(), "关联商户ID为空");
49
+        productVo.setSlider_image_list(List.of(productVo.getSlider_image().split(",")));
50
+
51
+        ProductContent productContent = productContentMapper.selectByProductId(productVo.getId());
52
+        Objects.requireNonNull(productContent, "商品详情介绍为空");
53
+        productVo.setContent("<html><head></head><body>" + productContent.getContent() + "</body><html>");
54
+
55
+        MerchantVo merchantVo = merchantMapper.selectById(productVo.getMer_id());
56
+        Objects.requireNonNull(merchantVo, "商户信息不存在或已关闭");
57
+
58
+        ProductAttrValueVo productAttrValueVo = productAttrValueMapper.selectOne(productVo.getId());
59
+        Objects.requireNonNull(productAttrValueVo, "商品规格关联信息为空");
60
+        productAttrValueVo.setValue_list(List.of(productAttrValueVo.getSku().split(",")));
61
+
62
+        return ProductResp.ProductRespBuilder.aProductResp()
63
+                .withProduct(productVo)
64
+                .withAttr_list(productAttrMapper.selectList(productVo.getId()).stream().map(row -> ProductAttrVo.ProductAttrVoBuilder.aProductAttrVo()
65
+                        .withName(row.getAttr_name())
66
+                        .withValueList(List.of(row.getAttr_values().split("-!-"))).build()).toList())
67
+                .withMerchant(merchantVo)
68
+                .withAttr_value(productAttrValueVo)
69
+                .withRecommend_list(productMapper.selectList(merchantVo.getId()))
70
+                .build();
71
+    }
72
+
73
+    /**
74
+     * 商品规格关联信息
75
+     * @param sku 多个规格属性值
76
+     * @param productId 商品ID
77
+     * @return
78
+     */
79
+    public ProductAttrValueVo attrValueDetail(String sku, Integer productId){
80
+        return productAttrValueMapper.selectBySku(sku, productId);
81
+    }
82
+
83
+    /**
84
+     * 商品规格关联信息
85
+     * @param param 封装参数
86
+     * @return
87
+     */
88
+    public ProductAttrValueVo attrValueDetail(ProductAttrValueReq param){
89
+        ProductAttrValueVo productAttrValueVo =  productAttrValueMapper.selectBySku(String.join(",", param.getValue_list()),
90
+                param.getProduct_id());
91
+        productAttrValueVo.setValue_list(List.of(productAttrValueVo.getSku().split(",")));
92
+        return productAttrValueVo;
93
+    }
94
+}

+ 74 - 0
src/main/java/com/tdba/cxb/ares/api/util/AESUtil.java

@@ -0,0 +1,74 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import javax.crypto.Cipher;
4
+import javax.crypto.SecretKey;
5
+import javax.crypto.spec.IvParameterSpec;
6
+import javax.crypto.spec.SecretKeySpec;
7
+import java.util.Base64;
8
+
9
+/**
10
+ * @program: api-factoring
11
+ * @description:
12
+ * @author: libo
13
+ * @create: 2022-02-15 19:44:14
14
+ */
15
+public class AESUtil {
16
+
17
+    public static String decrypt(String src, byte[] keyArray) throws Exception {
18
+        SecretKey key = new SecretKeySpec(keyArray, "AES");
19
+        byte[] IV = new byte[]{-36, 5, -7, 72, 25, -128, -94, -47, 38, 102, 20, 22, 48, -65, 59, -107};
20
+        return decrypt(Base64.getDecoder().decode(src),key, IV);
21
+    }
22
+
23
+    public static byte[] encrypt (byte[] plaintext, byte[] keyArray) throws Exception{
24
+        return encrypt(plaintext, new SecretKeySpec(keyArray, "AES"), null);
25
+    }
26
+    public static byte[] encrypt (byte[] plaintext, SecretKey keySpec, byte[] IV ) throws Exception
27
+    {
28
+        //Get Cipher Instance
29
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
30
+
31
+        //Create SecretKeySpec
32
+//        SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), "AES");
33
+
34
+        if(null == IV) {
35
+            //Initialize Cipher for ENCRYPT_MODE
36
+            cipher.init(Cipher.ENCRYPT_MODE, keySpec);
37
+        }else {
38
+            //Create IvParameterSpec
39
+            IvParameterSpec ivSpec = new IvParameterSpec(IV);
40
+
41
+            //Initialize Cipher for ENCRYPT_MODE
42
+            cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
43
+        }
44
+        //Perform Encryption
45
+        byte[] cipherText = cipher.doFinal(plaintext);
46
+
47
+        return cipherText;
48
+    }
49
+
50
+
51
+    public static String decrypt (byte[] cipherText, SecretKey key,byte[] IV) throws Exception
52
+    {
53
+        //Get Cipher Instance
54
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
55
+
56
+        //Create SecretKeySpec
57
+        SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), "AES");
58
+
59
+        if(null == IV) {
60
+            //Initialize Cipher for DECRYPT_MODE
61
+            cipher.init(Cipher.DECRYPT_MODE, keySpec);
62
+        }else{
63
+            //Create IvParameterSpec
64
+            IvParameterSpec ivSpec = new IvParameterSpec(IV);
65
+
66
+            //Initialize Cipher for DECRYPT_MODE
67
+            cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
68
+        }
69
+        //Perform Decryption
70
+        byte[] decryptedText = cipher.doFinal(cipherText);
71
+
72
+        return new String(decryptedText);
73
+    }
74
+}

+ 20 - 0
src/main/java/com/tdba/cxb/ares/api/util/Base64Util.java

@@ -0,0 +1,20 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import java.io.UnsupportedEncodingException;
4
+import java.util.Base64;
5
+
6
+/**
7
+ * base64工具
8
+ */
9
+public class Base64Util {
10
+
11
+    public static String encode(String str) throws UnsupportedEncodingException {
12
+        byte[] encodeBytes = Base64.getEncoder().encode(str.getBytes("utf-8"));
13
+        return new String(encodeBytes);
14
+    }
15
+
16
+    public static String decode(String str) throws UnsupportedEncodingException {
17
+        byte[] decodeBytes = Base64.getDecoder().decode(str.getBytes("utf-8"));
18
+        return new String(decodeBytes);
19
+    }
20
+}

+ 53 - 0
src/main/java/com/tdba/cxb/ares/api/util/BaseUserArgumentResolver.java

@@ -0,0 +1,53 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import com.tdba.cxb.ares.api.model.BaseUser;
4
+import org.springframework.core.MethodParameter;
5
+import org.springframework.util.StringUtils;
6
+import org.springframework.web.bind.support.WebDataBinderFactory;
7
+import org.springframework.web.context.request.NativeWebRequest;
8
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
9
+import org.springframework.web.method.support.ModelAndViewContainer;
10
+
11
+import javax.servlet.http.HttpServletRequest;
12
+
13
+/**
14
+ * 注入当前登录的用户信息
15
+ */
16
+public class BaseUserArgumentResolver implements HandlerMethodArgumentResolver {
17
+
18
+    /**
19
+     * 监控指定的参数
20
+     * @param parameter 方法参数 用于校验
21
+     * @return
22
+     */
23
+    @Override
24
+    public boolean supportsParameter(MethodParameter parameter) {
25
+        return parameter.getParameterType().equals(BaseUser.class);
26
+    }
27
+
28
+    @Override
29
+    public Object resolveArgument(MethodParameter parameter,
30
+                                  ModelAndViewContainer mavContainer,
31
+                                  NativeWebRequest webRequest,
32
+                                  WebDataBinderFactory binderFactory)  {
33
+
34
+//        if((null != parameter) && parameter.getParameterType().equals(BaseUser.class)){
35
+//            String token = webRequest.getNativeRequest(HttpServletRequest.class).getHeader(BHConstant.HEADER_TOKEN);
36
+//            if (StringUtils.hasLength(token)) {
37
+//                return BaseUser.BaseUserBuilder.aBaseUser()
38
+//                        .loginId(JwtUtil.getClaimOfInt(token, BaseConstant.ACCOUNT))
39
+//                        .companyType(CompanyTypeEnum.values()[resolveNull(JwtUtil.getClaimOfInt(token, BaseConstant.COMPANY_TYPE))])
40
+//                        .companyId(JwtUtil.getClaimOfInt(token, BaseConstant.COMPANY_ID))
41
+//                        .userId(JwtUtil.getClaimOfInt(token, BaseConstant.USER_ID))
42
+//                        .userType(UserTypeEnum.values()[resolveNull(JwtUtil.getClaimOfInt(token, BaseConstant.USER_TYPE))])
43
+//                        .build();
44
+//            }
45
+//        }
46
+
47
+        return null;
48
+    }
49
+
50
+    private int resolveNull(Integer src){
51
+        return (null == src)? 0: src.intValue();
52
+    }
53
+}

+ 79 - 0
src/main/java/com/tdba/cxb/ares/api/util/BigDecimalUtil.java

@@ -0,0 +1,79 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+
4
+import java.math.BigDecimal;
5
+import java.text.DecimalFormat;
6
+
7
+/**
8
+ * 金额工具类
9
+ */
10
+public class BigDecimalUtil {
11
+
12
+    /**
13
+     * 格式化金额 1 -> 1.00
14
+     * @param src
15
+     * @return
16
+     */
17
+    public static String getFormatString(BigDecimal src){
18
+
19
+        if(null == src){
20
+            throw new RuntimeException("格式化");
21
+        }
22
+        DecimalFormat df = new DecimalFormat();
23
+        df.applyPattern("0.00");// 将格式应用于格式化器
24
+
25
+        return df.format(src.doubleValue());
26
+    }
27
+
28
+    /**
29
+     * 格式化金额 1 -> 100%
30
+     * @param src
31
+     * @return
32
+     */
33
+    public static String getFormatPercent(BigDecimal src){
34
+
35
+        if(null == src){
36
+            throw new RuntimeException("格式化");
37
+        }
38
+        DecimalFormat df = new DecimalFormat();
39
+        df.applyPattern("0.##%");// 将格式应用于格式化器
40
+
41
+        return df.format(src.doubleValue());
42
+    }
43
+
44
+    /**
45
+     * 格式化金额 12345 -> 12,345.00
46
+     * @param src
47
+     * @return
48
+     */
49
+    public static String getFormatHasComma(BigDecimal src){
50
+
51
+        if(null == src){
52
+            throw new RuntimeException("格式化");
53
+        }
54
+        DecimalFormat df = new DecimalFormat();
55
+        df.applyPattern(",##0.00");// 将格式应用于格式化器
56
+
57
+        return df.format(src.doubleValue());
58
+    }
59
+
60
+    /**
61
+     * 原样输出
62
+     * @param src
63
+     * @return
64
+     */
65
+    public static String getFormatOrginal(BigDecimal src){
66
+
67
+        if(null == src){
68
+            throw new RuntimeException("格式化");
69
+        }
70
+        DecimalFormat df = new DecimalFormat();
71
+        df.applyPattern("0.########");// 将格式应用于格式化器
72
+
73
+        return df.format(src.doubleValue());
74
+    }
75
+
76
+    public static void main(String[] args) {
77
+        System.out.println(getFormatPercent(new BigDecimal("3.00")));
78
+    }
79
+}

+ 14 - 0
src/main/java/com/tdba/cxb/ares/api/util/CFCAUtil.java

@@ -0,0 +1,14 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import java.security.Security;
4
+
5
+/**
6
+ * @program: order-web
7
+ * @description:
8
+ * @author: libo
9
+ * @create: 2022-05-23 17:12:08
10
+ */
11
+public class CFCAUtil {
12
+
13
+
14
+}

+ 64 - 0
src/main/java/com/tdba/cxb/ares/api/util/ConfigTool.java

@@ -0,0 +1,64 @@
1
+//package com.tdba.cxb.ares.api.util;
2
+//
3
+//import org.slf4j.Logger;
4
+//import org.slf4j.LoggerFactory;
5
+//
6
+//import java.io.File;
7
+//import java.io.FileInputStream;
8
+//import java.io.IOException;
9
+//import java.net.URL;
10
+//
11
+///**
12
+// * @program: order-web
13
+// * @description:
14
+// * @author: libo
15
+// * @create: 2022-05-25 10:45:24
16
+// */
17
+//public class ConfigTool {
18
+//
19
+//    private static final Logger log = LoggerFactory.getLogger(ConfigTool.class);
20
+//
21
+//    private ConfigTool(){
22
+//
23
+//    }
24
+//
25
+//    private static ConfigTool configTool = new ConfigTool();
26
+//
27
+//    public static ConfigTool getInstance(){
28
+//        return configTool;
29
+//    }
30
+//
31
+//    private static boolean initialized = false;
32
+//
33
+//    public void init(String keyStoreName) throws IOException, CertApiException {
34
+//        //初始化不可重复
35
+//        if (initialized) {
36
+//            return;
37
+//        }
38
+//
39
+//        //在此处设置配置文件的路径
40
+//        ClassLoader classLoader = ConfigTool.class.getClassLoader();
41
+//        // URL resource = classLoader.getResource("TopESA.SignAndVerify.onlyCACert.conf.json");
42
+//        URL resource = classLoader.getResource(keyStoreName+".TopESA.SignAndVerify.onlyCACert.conf.json");
43
+//        FileInputStream fis = new FileInputStream(new File(resource.getPath()));
44
+//        log.info("json文件路径======================================");
45
+//        log.info(resource.getPath());
46
+//        byte[] buf = new byte[fis.available()];
47
+//        fis.read(buf);
48
+//        fis.close();
49
+//        String json = new String(buf, "UTF-8");
50
+//        String val= json.replaceAll("AAA",classLoader.getResource("").getPath());
51
+//        log.info("pfx文件路径======================================");
52
+//        log.info(classLoader.getResource("").getPath());
53
+//        TCA.config(val);
54
+//        initialized = false;
55
+//    }
56
+//
57
+//    public static void main(String[] args) {
58
+//        ClassLoader classLoader = ConfigTool.class.getClassLoader();
59
+//        URL resource = classLoader.getResource("TopESA.SignAndVerify.onlyCACert.conf.json");
60
+//        System.out.println(resource);
61
+//    }
62
+//
63
+//
64
+//}

+ 192 - 0
src/main/java/com/tdba/cxb/ares/api/util/DateUtil.java

@@ -0,0 +1,192 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+
4
+import org.springframework.util.CollectionUtils;
5
+import org.springframework.util.StringUtils;
6
+
7
+import java.time.Duration;
8
+import java.time.LocalDate;
9
+import java.time.LocalDateTime;
10
+import java.time.LocalTime;
11
+import java.time.format.DateTimeFormatter;
12
+import java.time.temporal.ChronoUnit;
13
+import java.util.Collection;
14
+import java.util.List;
15
+
16
+/**
17
+ * 日期工具类
18
+ */
19
+public class DateUtil {
20
+
21
+
22
+    public static String converString(LocalDate localDate){
23
+
24
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
25
+        return localDate.format(formatter);
26
+    }
27
+
28
+    public static String minusDay(LocalDate localDate, int dayNum){
29
+
30
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
31
+        return localDate.minus(dayNum, ChronoUnit.DAYS).format(formatter);
32
+    }
33
+
34
+
35
+    /**
36
+     * 格式化日期
37
+     * @param time uuuu-MM-dd HH:mm:ss
38
+     * @return
39
+     */
40
+    public static String formatString(LocalDateTime time){
41
+        if(null == time){
42
+            throw new TDBAException("时间不能为空");
43
+        }
44
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
45
+        return time.format(formatter);
46
+    }
47
+
48
+    /**
49
+     * 格式化日期
50
+     * @param time uuuu-MM-dd HH:mm:ss
51
+     * @return
52
+     */
53
+    public static String formatString(LocalDateTime time, String pattern){
54
+        if(null == time){
55
+            throw new TDBAException("时间不能为空");
56
+        }
57
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
58
+        return time.format(formatter);
59
+    }
60
+
61
+    /**
62
+     * 格式化日期
63
+     * @param time uuuu-MM-dd
64
+     * @return
65
+     */
66
+    public static String formatString(LocalDate time){
67
+        if(null == time){
68
+            throw new TDBAException("时间不能为空");
69
+        }
70
+        return formatString(time, "uuuu-MM-dd");
71
+    }
72
+
73
+    public static String formatString(LocalDate time, String pattern){
74
+        if(null == time){
75
+            throw new TDBAException("时间不能为空");
76
+        }
77
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
78
+        return time.format(formatter);
79
+    }
80
+
81
+    /**
82
+     * 当前日期
83
+     * @return
84
+     */
85
+    public static String currentDate(){
86
+        return formatString(LocalDate.now());
87
+    }
88
+
89
+    /**
90
+     * 当前时间戳
91
+     * @return
92
+     */
93
+    public static String currentDateTime(){
94
+        return formatString(LocalDateTime.now(), "uuuu-MM-dd HH:mm:ss");
95
+    }
96
+
97
+    /**
98
+     * 当前时间戳
99
+     * @return
100
+     */
101
+    public static String currentTimestamp(){
102
+        return formatString(LocalDateTime.now(), "uuuuMMddHHmmss");
103
+    }
104
+
105
+    /**
106
+     * 解析日期字符串
107
+     * @param time uuuu-MM-dd
108
+     * @return
109
+     */
110
+    public static LocalDate resolveDateString(String time){
111
+        if(!StringUtils.hasLength(time)){
112
+            throw new TDBAException("时间不能为空");
113
+        }
114
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
115
+        return LocalDate.parse(time, formatter);
116
+    }
117
+
118
+    /**
119
+     * 日期开始时间 2021-04-10 00:00:00
120
+     * @return
121
+     */
122
+    public static String earlyTime(LocalDate date){
123
+
124
+        if(null == date){
125
+            throw new TDBAException("日期不能为空");
126
+        }
127
+
128
+        return formatString(LocalDateTime.of(date, LocalTime.MIN));
129
+    }
130
+
131
+    /**
132
+     * 日期结束时间 2021-04-10 23:59:59
133
+     * @return
134
+     */
135
+    public static String lateTime(LocalDate date){
136
+
137
+        if(null == date){
138
+            throw new TDBAException("日期不能为空");
139
+        }
140
+
141
+        return formatString(LocalDateTime.of(date, LocalTime.MAX));
142
+    }
143
+
144
+    /**
145
+     * 计算时间差
146
+     * @param startTime 开始时间
147
+     * @param endTime   结束时间
148
+     * @return          分钟
149
+     */
150
+    public static Long getDuration(LocalDateTime startTime, LocalDateTime endTime){
151
+
152
+        if((null == startTime) || (null == endTime)){
153
+            throw new TDBAException("时间不能为空");
154
+        }
155
+
156
+        Duration duration = Duration.between(startTime, endTime);
157
+        return duration.toMinutes();
158
+    }
159
+
160
+    /**
161
+     * 计算时间差
162
+     * @param startTime 开始时间
163
+     * @param endTime   结束时间
164
+     * @return          天
165
+     */
166
+    public static Long getDuration(LocalDate startTime, LocalDate endTime){
167
+
168
+        if((null == startTime) || (null == endTime)){
169
+            throw new TDBAException("时间不能为空");
170
+        }
171
+
172
+        Duration duration = Duration.between(LocalDateTime.of(startTime, LocalTime.MIN), LocalDateTime.of(endTime, LocalTime.MIN));
173
+        return duration.toDays();
174
+    }
175
+
176
+    public static boolean isAfterOfEqual(Collection<LocalDate> list, LocalDate src){
177
+        if(CollectionUtils.isEmpty(list) || (null == src)){
178
+           return true;
179
+        }
180
+        for(LocalDate row : list){
181
+            if(src.isAfter(row) || src.equals(row)){
182
+                return true;
183
+            }
184
+        }
185
+        return false;
186
+    }
187
+
188
+    public static void main(String[] args) {
189
+
190
+        System.out.println(getDuration(LocalDate.of(2021, 11, 11), LocalDate.of(2021, 11, 13)));
191
+    }
192
+}

+ 21 - 0
src/main/java/com/tdba/cxb/ares/api/util/DoubleUtil.java

@@ -0,0 +1,21 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import java.math.BigDecimal;
4
+import java.math.RoundingMode;
5
+
6
+public class DoubleUtil {
7
+
8
+    /**
9
+     * 四舍五入
10
+     * @param  value 操作的小数
11
+     * @return
12
+     */
13
+    public static String roundOff(Double value){
14
+
15
+        if(null == value){
16
+            return "0";
17
+        }
18
+
19
+        return BigDecimalUtil.getFormatString(new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
20
+    }
21
+}

+ 39 - 0
src/main/java/com/tdba/cxb/ares/api/util/SHA1Util.java

@@ -0,0 +1,39 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+import java.security.MessageDigest;
4
+
5
+/**
6
+ * @program: api-factoring
7
+ * @description: sha1加密
8
+ * @author: libo
9
+ * @create: 2021-10-25 10:16:44
10
+ */
11
+public class SHA1Util {
12
+
13
+    /**
14
+     *  获取加密串
15
+     * @param str 源内容
16
+     * @return
17
+     */
18
+    public static String encode(String str) {
19
+
20
+        char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
21
+                'A', 'B', 'C', 'D', 'E', 'F'};
22
+        try {
23
+            MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
24
+            mdTemp.update(str.getBytes("UTF-8"));
25
+            byte[] md = mdTemp.digest();
26
+            int j = md.length;
27
+            char buf[] = new char[j * 2];
28
+            int k = 0;
29
+            for (int i = 0; i < j; i++) {
30
+                byte byte0 = md[i];
31
+                buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
32
+                buf[k++] = hexDigits[byte0 & 0xf];
33
+            }
34
+            return new String(buf);
35
+        } catch (Exception e) {
36
+            return null;
37
+        }
38
+    }
39
+}

+ 76 - 0
src/main/java/com/tdba/cxb/ares/api/util/SignUtil.java

@@ -0,0 +1,76 @@
1
+//package com.tdba.cxb.ares.api.util;
2
+//
3
+//import org.slf4j.Logger;
4
+//import org.slf4j.LoggerFactory;
5
+//
6
+//import java.io.UnsupportedEncodingException;
7
+//import java.security.cert.CertStore;
8
+//import java.security.cert.Certificate;
9
+//
10
+///**
11
+// * @program: order-web
12
+// * @description: RSA签名,加解密处理核心文件,注意:密钥长度1024
13
+// * @author: libo
14
+// * @create: 2022-05-25 10:43:27
15
+// */
16
+//public class SignUtil {
17
+//
18
+//    private static final Logger log = LoggerFactory.getLogger(SignUtil.class);
19
+//
20
+//    /**
21
+//     * 计算签名
22
+//     * @param keyStoreName 证书名称
23
+//     * @param plainData 原文
24
+//     * @param encapsulate 是否包含原文
25
+//     */
26
+//    public static String sign(String keyStoreName, String plainData, boolean encapsulate) throws CertApiException, UnsupportedEncodingException {
27
+//        Certificate certificate = null;
28
+//        CertSet certSet = null;
29
+//        try {
30
+//            ConfigTool.getInstance().init(keyStoreName);
31
+//            HytProfile profile = ProfileUtil.profile();
32
+//            certSet = CertStore.getInstance(keyStoreName).listCerts();
33
+//            certificate = certSet.get(0);
34
+//
35
+//        } catch (Exception e) {
36
+//            e.printStackTrace();
37
+//        }
38
+//        //是否包含原文
39
+//        byte[] signedData = null;
40
+//        try {
41
+//
42
+//            //签名
43
+//            signedData = certificate.signP7(plainData.getBytes("UTF-8"), encapsulate);
44
+//        } catch (CertApiException e) {
45
+//            log.info("天威签名异常:{}", e.getMessage());
46
+//            throw new CertApiException(e.getErrCode(), e.getCause());
47
+//        }
48
+//        String sign = Base64.encodeBase64String(signedData);
49
+//        return sign;
50
+//    }
51
+//
52
+//    //加密byte[]
53
+//    public static byte[] encodeByte(byte[] plainData, boolean encapsulate) throws CertApiException {
54
+//        Certificate certificate = null;
55
+//        CertSet certSet = null;
56
+//        try {
57
+//            ConfigTool configTool = ConfigTool.getInstance();
58
+//            configTool.init("");
59
+//            certSet = CertStore.listAllCerts();
60
+//            certificate = certSet.get(0);
61
+//        } catch (Exception e) {
62
+//            e.printStackTrace();
63
+//        }
64
+//        byte[] retunData = null;
65
+//        try {
66
+//            //签名
67
+//            byte[] signedData = certificate.signP7(plainData, encapsulate);
68
+//            retunData = Base64.encodeBase64(signedData);
69
+//
70
+//        } catch (CertApiException e) {
71
+//            log.info("天威签名异常:{}", e.getMessage());
72
+//            throw new CertApiException(e.getErrCode(), e.getCause());
73
+//        }
74
+//        return retunData;
75
+//    }
76
+//}

+ 27 - 0
src/main/java/com/tdba/cxb/ares/api/util/TDBAController.java

@@ -0,0 +1,27 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+
4
+import org.springframework.core.annotation.AliasFor;
5
+import org.springframework.web.bind.annotation.RequestMapping;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+import java.lang.annotation.ElementType;
9
+import java.lang.annotation.Retention;
10
+import java.lang.annotation.RetentionPolicy;
11
+import java.lang.annotation.Target;
12
+
13
+/**
14
+ * @program: api-factoring
15
+ * @description: 合并 RestController, RequestMapping
16
+ * @author: libo
17
+ * @create: 2021-03-30 14:26:24
18
+ */
19
+@Target({ElementType.TYPE})
20
+@Retention(RetentionPolicy.RUNTIME)
21
+@RequestMapping
22
+@RestController
23
+public @interface TDBAController {
24
+
25
+    @AliasFor(annotation = RequestMapping.class)
26
+    String value();
27
+}

+ 14 - 0
src/main/java/com/tdba/cxb/ares/api/util/TDBAException.java

@@ -0,0 +1,14 @@
1
+package com.tdba.cxb.ares.api.util;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 异常封装
6
+ * @author: libo
7
+ * @create: 2022-05-23 15:10:50
8
+ */
9
+public class TDBAException extends RuntimeException{
10
+
11
+    public TDBAException(String message){
12
+        super(message);
13
+    }
14
+}

+ 25 - 0
src/main/java/module-info.java

@@ -0,0 +1,25 @@
1
+open module order.web {
2
+    requires spring.context;
3
+    requires spring.boot.autoconfigure;
4
+    requires java.annotation;
5
+    requires spring.boot;
6
+    requires org.slf4j;
7
+    requires spring.core;
8
+    requires pagehelper;
9
+    requires spring.web;
10
+    requires org.apache.httpcomponents.httpclient;
11
+    requires com.fasterxml.jackson.annotation;
12
+    requires com.fasterxml.jackson.databind;
13
+    requires com.fasterxml.jackson.datatype.jdk8;
14
+    requires com.fasterxml.jackson.datatype.jsr310;
15
+    requires com.fasterxml.jackson.module.paramnames;
16
+    requires spring.beans;
17
+    requires spring.data.redis;
18
+    requires redis.clients.jedis;
19
+    requires org.apache.tomcat.embed.core;
20
+    requires com.auth0.jwt;
21
+    requires java.validation;
22
+    requires spring.webmvc;
23
+    requires org.mybatis;
24
+    requires spring.aop;
25
+}

+ 30 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,30 @@
1
+spring:
2
+  datasource:
3
+    url: jdbc:mysql://10.28.5.46:3306/renrenxiang?autoReconnect=true&failOverReadOnly=false&serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
4
+    driver-class-name: com.mysql.cj.jdbc.Driver
5
+    password: Zm#T2ZW4#IwENBY
6
+    username: root
7
+    hikari:
8
+      maximum-pool-size: 16
9
+      minimum-idle: 2
10
+      idle-timeout: 10000
11
+
12
+  redis:
13
+    host: 10.28.5.46
14
+    port: 6379
15
+    password: 123
16
+    database: 0
17
+    timeout: 5000
18
+    jedis:
19
+      pool:
20
+        # 连接池最大连接数(使用负值表示没有限制)
21
+        max-active: 200
22
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
23
+        max-wait: -1
24
+        # 连接池中的最大空闲连接
25
+        max-idle: 8
26
+        # 连接池中的最小空闲连接
27
+        min-idle: 0
28
+
29
+server:
30
+  port: 8888

+ 30 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,30 @@
1
+spring:
2
+  datasource:
3
+    url: jdbc:mysql://10.28.5.46:3306/renrenxiang?autoReconnect=true&failOverReadOnly=false&serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
4
+    driver-class-name: com.mysql.cj.jdbc.Driver
5
+    password: Zm#T2ZW4#IwENBY
6
+    username: root
7
+    hikari:
8
+      maximum-pool-size: 16
9
+      minimum-idle: 2
10
+      idle-timeout: 10000
11
+
12
+  redis:
13
+    host: 10.28.5.46
14
+    port: 6379
15
+    password: 123
16
+    database: 0
17
+    timeout: 5000
18
+    jedis:
19
+      pool:
20
+        # 连接池最大连接数(使用负值表示没有限制)
21
+        max-active: 200
22
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
23
+        max-wait: -1
24
+        # 连接池中的最大空闲连接
25
+        max-idle: 8
26
+        # 连接池中的最小空闲连接
27
+        min-idle: 0
28
+
29
+server:
30
+  port: 8888

+ 17 - 0
src/main/resources/application.yml

@@ -0,0 +1,17 @@
1
+spring:
2
+  application:
3
+    name: order-web
4
+  profiles:
5
+    active: dev
6
+  cache:
7
+    type: caffeine
8
+    caffeine:
9
+      spec: maximumSize=5000,expireAfterWrite=60s
10
+
11
+mybatis:
12
+#  configuration:
13
+    ## 开启驼峰格式
14
+#    map-underscore-to-camel-case: true
15
+  type-handlers-package: com.tdba.cxb.ares.api.repository
16
+  ## mapper配置文件地址
17
+  mapper-locations: classpath*:/mapper/*.xml

+ 65 - 0
src/main/resources/logback-spring.xml

@@ -0,0 +1,65 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration>
3
+
4
+    <springProfile name="dev">
5
+        <!--控制台输出appender-->
6
+        <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
7
+            <!--设置输出格式-->
8
+            <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
9
+                <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
10
+                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} %line - %msg%n</pattern>
11
+                <!--设置编码-->
12
+                <charset>UTF-8</charset>
13
+            </encoder>
14
+        </appender>
15
+
16
+        <!-- http客户端 打印请求和响应日志-->
17
+        <logger name="com.tdba.cxb.ares.api.config.http" level="debug"/>
18
+
19
+        <!-- 打印sql-->
20
+        <logger name="com.tdba.cxb.ares.api.repository" level="debug"/>
21
+
22
+        <root level="info">
23
+            <!--appender将会添加到这个loger-->
24
+            <appender-ref ref="console"/>
25
+        </root>
26
+    </springProfile>
27
+
28
+    <springProfile name="test">
29
+        <!--设置存储路径变量-->
30
+        <property name="USER_HOME" value="/data/www/wwwlogs" />
31
+
32
+        <!--文件输出,时间窗口滚动-->
33
+        <appender name="timeFileOutput" class="ch.qos.logback.core.rolling.RollingFileAppender">
34
+            <!--日志名,指定最新的文件名,其他文件名使用FileNamePattern -->
35
+            <File>${USER_HOME}/order-web/out.log</File>
36
+            <!--文件滚动模式-->
37
+            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
38
+                <!--日志文件输出的文件名,可设置文件类型为gz,开启文件压缩-->
39
+                <FileNamePattern>${USER_HOME}/order-web/info.%d{yyyy-MM-dd}.%i.log.gz</FileNamePattern>
40
+                <!--日志文件保留天数-->
41
+                <MaxHistory>30</MaxHistory>
42
+                <!--按大小分割同一天的-->
43
+                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
44
+                    <maxFileSize>10MB</maxFileSize>
45
+                </timeBasedFileNamingAndTriggeringPolicy>
46
+            </rollingPolicy>
47
+
48
+            <!--输出格式-->
49
+            <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
50
+                <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
51
+                <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} %line - %msg%n</pattern>
52
+                <!--设置编码-->
53
+                <charset>UTF-8</charset>
54
+            </encoder>
55
+        </appender>
56
+
57
+        <!-- 打印sql-->
58
+        <logger name="com.tdba.cxb.ares.api.repository" level="debug"/>
59
+
60
+        <root level="info">
61
+            <!--appender将会添加到这个loger-->
62
+            <appender-ref ref="timeFileOutput"/>
63
+        </root>
64
+    </springProfile>
65
+</configuration>

+ 17 - 0
src/main/resources/mapper/MerchantMapper.xml

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.MerchantMapper">
4
+
5
+    <select id="selectById" resultType="com.tdba.cxb.ares.api.model.MerchantVo">
6
+        select
7
+            mer_id 'id',
8
+                mer_name 'name',
9
+                mer_avatar 'avatar'
10
+        from
11
+            rrx_merchant
12
+        where
13
+            is_del = 0
14
+          and status = 1
15
+          and mer_id = #{id}
16
+    </select>
17
+</mapper>

+ 15 - 0
src/main/resources/mapper/ProductAttrMapper.xml

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.ProductAttrMapper">
4
+
5
+    <select id="selectList" resultType="com.tdba.cxb.ares.api.model.ProductAttrDto">
6
+        select
7
+            product_id,
8
+            attr_name,
9
+            attr_values
10
+        from
11
+            rrx_store_product_attr
12
+        where
13
+            product_id = #{productId}
14
+    </select>
15
+</mapper>

+ 31 - 0
src/main/resources/mapper/ProductAttrValueMapper.xml

@@ -0,0 +1,31 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.ProductAttrValueMapper">
4
+
5
+    <select id="selectOne" resultType="com.tdba.cxb.ares.api.model.ProductAttrValueVo">
6
+        select
7
+            sku,
8
+            stock,
9
+            price,
10
+            ot_price,
11
+            `unique`
12
+        from
13
+            rrx_store_product_attr_value
14
+        where
15
+            product_id = #{productId} limit 1
16
+    </select>
17
+
18
+    <select id="selectBySku" resultType="com.tdba.cxb.ares.api.model.ProductAttrValueVo">
19
+        select
20
+            sku,
21
+            stock,
22
+            price,
23
+            ot_price,
24
+            `unique`
25
+        from
26
+            rrx_store_product_attr_value
27
+        where
28
+            product_id = #{productId}
29
+            and sku = #{sku}
30
+    </select>
31
+</mapper>

+ 15 - 0
src/main/resources/mapper/ProductContentMapper.xml

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.ProductContentMapper">
4
+
5
+    <select id="selectByProductId" resultType="com.tdba.cxb.ares.api.model.ProductContent">
6
+        select
7
+            product_id,
8
+            content,
9
+            type
10
+        from
11
+            rrx_store_product_content
12
+        where
13
+            product_id = #{productId}
14
+    </select>
15
+</mapper>

+ 42 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -0,0 +1,42 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.ProductMapper">
4
+
5
+    <select id="selectById" resultType="com.tdba.cxb.ares.api.model.ProductVo">
6
+        select
7
+            product_id 'id',
8
+            image,
9
+            slider_image,
10
+            price,
11
+            ot_price,
12
+            stock,
13
+            store_info 'info',
14
+            store_name 'name',
15
+            mer_id
16
+        from
17
+            rrx_store_product
18
+        where
19
+            is_del = 0
20
+          and is_show = 1
21
+          and status = 1
22
+          and is_used = 1
23
+          and product_id = #{id}
24
+    </select>
25
+
26
+    <select id="selectList" resultType="com.tdba.cxb.ares.api.model.ProductSimple">
27
+        select
28
+            product_id 'id',
29
+                image,
30
+            store_name 'name',
31
+                price,
32
+            ot_price
33
+        from
34
+            rrx_store_product
35
+        where
36
+            is_del = 0
37
+          and is_show = 1
38
+          and status = 1
39
+          and is_used = 1
40
+          and mer_id = #{merId}
41
+    </select>
42
+</mapper>

+ 8 - 0
src/main/resources/mapper/RrxStoreGroupOrderMapper.xml

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.tdba.cxb.ares.api.repository.RrxStoreGroupOrderMapper">
4
+
5
+    <select id="countById" resultType="java.lang.Integer">
6
+        select count(1) from rrx_store_group_order where group_order_id = #{id}
7
+    </select>
8
+</mapper>

+ 70 - 0
src/test/java/com/tdba/cxb/ares/api/BuilderSupport.java

@@ -0,0 +1,70 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import com.alibaba.fastjson2.JSONObject;
4
+
5
+import java.lang.reflect.Field;
6
+import java.util.LinkedHashMap;
7
+
8
+/**
9
+ * @program: order-web
10
+ * @description:
11
+ * @author: libo
12
+ * @create: 2022-05-27 08:57:20
13
+ */
14
+
15
+public class BuilderSupport {
16
+    public BuilderSupport() {
17
+    }
18
+
19
+    public JSONObject build(String merchantId) {
20
+        JSONObject json = new JSONObject(new LinkedHashMap());
21
+        json.put("merchantId", merchantId);
22
+        return json;
23
+    }
24
+
25
+    protected JSONObject assembleBuild() {
26
+        Class clazz = this.getClass();
27
+
28
+        try {
29
+            JSONObject json = this.findField(clazz);
30
+            return json;
31
+        } catch (Exception var4) {
32
+            throw new RuntimeException(var4);
33
+        }
34
+    }
35
+
36
+    private void putField(Class clazz, JSONObject json) throws IllegalAccessException {
37
+        Field[] var3 = clazz.getDeclaredFields();
38
+        int var4 = var3.length;
39
+
40
+        for(int var5 = 0; var5 < var4; ++var5) {
41
+            Field field = var3[var5];
42
+            field.setAccessible(true);
43
+            Object obj = field.get(this);
44
+            if (obj != null) {
45
+                json.put(field.getName(), obj);
46
+            }
47
+        }
48
+
49
+    }
50
+
51
+    private JSONObject findField(Class clazz) throws IllegalAccessException {
52
+        JSONObject json = new JSONObject();
53
+
54
+        for(Class parent = clazz.getSuperclass(); parent != null && parent != Object.class; parent = parent.getSuperclass()) {
55
+            this.putField(parent, json);
56
+        }
57
+
58
+        this.putField(clazz, json);
59
+        return json;
60
+    }
61
+
62
+    public String orderGenerateHmac() {
63
+        try {
64
+            String hmacSource = SignPublisher.generateHmacSource(this);
65
+            return hmacSource;
66
+        } catch (Exception var3) {
67
+            throw new RuntimeException(var3);
68
+        }
69
+    }
70
+}

+ 14 - 0
src/test/java/com/tdba/cxb/ares/api/ObjectUtils.java

@@ -0,0 +1,14 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description:
6
+ * @author: libo
7
+ * @create: 2022-05-27 09:51:02
8
+ */
9
+public class ObjectUtils {
10
+
11
+    public static Object defaultIfNull(Object src, Object replacement){
12
+        return (null == src)? replacement: src;
13
+    }
14
+}

+ 553 - 0
src/test/java/com/tdba/cxb/ares/api/PayOrderReq.java

@@ -0,0 +1,553 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import java.math.BigDecimal;
4
+import java.util.List;
5
+
6
+/**
7
+ * @program: order-web
8
+ * @description: 首信易接口,境内收单实体类
9
+ * https://demo.yizhifubj.com/Development/showdoc-master/web/#/5?page_id=242
10
+ * 文档最后一栏"是否必填"
11
+ * M	必填
12
+ * C	有条件的
13
+ * O	可选
14
+ * @author: libo
15
+ * @create: 2022-05-23 16:11:10
16
+ */
17
+public final class PayOrderReq extends BuilderSupport {
18
+
19
+    /**  商户编号 varchar(9) 商户在首信易系统的唯一身份标识,商户完成首信易系统注册后可登录商户后台商户服务查看。 M*/
20
+    private String merchantId;
21
+
22
+    /**  订单金额 decimal(18) 单位:分,1元=100分(订单金额=商品数量*商品单价,订单金额一定要和商品总金额保持一致) M*/
23
+    private Integer orderAmount;
24
+
25
+    /**  订单币种 varchar(15) 默认CNY(人民币) M*/
26
+    private String orderCurrency;
27
+
28
+    /**  订单号 varchar(50) 订单号为商户自行拟定,提交的订单号必须在自身平台交易中唯一。首信易支付系统已付或撤销的订单,商户平台不能以相同的订单号再次提交。 M*/
29
+    private String requestId;
30
+
31
+    /**  服务商id varchar(9) 二级商户上属服务商商户在首信易系统 的唯一身份标识,商户完成首信易系统 注册后可登录商户后台商户服务查看。 C*/
32
+    private String partnerId;
33
+
34
+    /**  通知地址 varchar(200) 服务器通知:当订单状态为终态后首信易服务器会向该地址发送五次成功通知,该地址可以带参数,如:http://www.5upay.com/callback.action?test=test。注意:如不填notifyUrl的参数值支付成功后您的服务器将得不到支付成功的通知。 M*/
35
+    private String notifyUrl;
36
+
37
+    /**  回调地址 varchar(200) 页面回调:支付成功后会向该地址进行跳转,如:http://www.5upay.com/callback.action?test=test。 M*/
38
+    private String callbackUrl;
39
+
40
+    /**  备注 varchar(300) 商户在首信易为订单进行备注,通过支付结果返回商户 O*/
41
+    private String remark;
42
+
43
+    /**  支付方式编码 varchar(50) 直连需要传入此项,见最下方支付方式编码 C*/
44
+    private String paymentModeCode;
45
+
46
+    /**  支付宝授权码 varchar(50) 此参数传在支付宝注册的授权码 C*/
47
+    private String authCode;
48
+
49
+    /**  微信appId varchar(100) 此参数传用户自己的微信appId C*/
50
+    private String appId;
51
+
52
+    /**  openId varchar(100) 此参数传用户自己的微信openId,或者支付宝的buyer_id或者用户的钱包ID,或者微包服务号的openid,或者微包扫码付的pay_code C*/
53
+    private String openId;
54
+
55
+    /**  商品信息 Json(数组) 支付商品信息,见下表 M*/
56
+    private List<ProductDetails> productDetails;
57
+
58
+    /**  分账标识 固定值 DO_SPLIT 分账,NOT_DO_SPLIT 不分帐,不传默认为不分帐 C*/
59
+    private String splitMark;
60
+
61
+    /**  身份信息 Json 此json可空,但是不可将此参数整个去掉,需以以下格式传入接口: “payer”:{} 见下表 C*/
62
+    private Payer payer;
63
+
64
+    /**  客户端IP varchar(100) 传递客户端外网IP M*/
65
+    private String clientIp;
66
+
67
+    /**  订单超时时间 Int(4) 此参数用于设置订单的超时时间(只能设置在二十四小时内),如:输入10,该订单将在10分钟后过期。分钟为单位 O*/
68
+    private Short timeout;
69
+
70
+    /**  商户会员id varchar(30) 银联快捷可通过传入此参数进行绑卡,每个商户下面唯一,请给每个用户分配一个id用于传入此参数,以便用户下次支付时可用之前绑定过的卡 O*/
71
+    private String merchantUserId;
72
+
73
+    /**  绑卡id varchar(50) 本参数暂未启用 O*/
74
+    private String bindCardId;
75
+
76
+    /**  报备序列号 varchar(50) 同一商户报备多个公众号,小程序的时候传递 C*/
77
+    private String reportSerialNo;
78
+
79
+    /**  卡号 用户卡号信息,applePay支付需要传递此参数 C*/
80
+    private String apCardNo;
81
+
82
+    /**  用户数据 用户信息,applePay支付需要传递此参数 C*/
83
+    private String apUserData;
84
+
85
+    /**  交易数据 用户交易数据,applePay支付需要传递此参数 C*/
86
+    private String apTransData;
87
+
88
+    /**  项目id 商户项目标识 O*/
89
+    private String projectId;
90
+
91
+    /**  限定账户类型 varchar(200) 见下表,需要传多个枚举值时用半角 逗号“,”分隔 O
92
+     * DISABLE_CREDIT_CARD	禁止使用信用卡	微包支付、网关支付
93
+     * ALIPAY_HB_FQ_NUM_3	花呗分期期数,3 期	支付宝花呗分期支付
94
+     * ALIPAY_HB_FQ_NUM_6	花呗分期期数,6 期	支付宝花呗分期支付
95
+     * ALIPAY_HB_FQ_NUM_12	花呗分期期数,12 期	支付宝花呗分期支付
96
+     * WEBOX_BALANCE_PAY	微包余额支付	微包支付
97
+     * */
98
+    private String limitAccType;
99
+
100
+    /**  补贴标识 固定值 DO_SUBSIDY 补贴,NOT_DO_SUBSIDY 不补贴,不传默认为不补贴(该参数为特定电商场景) O*/
101
+    private String subsidyMark;
102
+
103
+    /**  补贴金额 decimal(18) 单位:分,1元=100分 O*/
104
+    private Integer subsidyAmount;
105
+
106
+    /** 参数签名	varchar(500) 获取hmac的方法见请求请求加密流程,参数顺序按照键名首字母从a-z拼接对应的键值中间用#号隔开。 M*/
107
+    private String hmac;
108
+
109
+    /**
110
+     * 获取 hmac 源信息
111
+     * 过滤 排序
112
+     * @return
113
+     * @throws Exception
114
+     */
115
+    public byte[] generateHmacSource() throws Exception {
116
+        return super.orderGenerateHmac().getBytes("UTF-8");
117
+    }
118
+
119
+    public String getMerchantId() {
120
+        return merchantId;
121
+    }
122
+
123
+    public void setMerchantId(String merchantId) {
124
+        this.merchantId = merchantId;
125
+    }
126
+
127
+    public Integer getOrderAmount() {
128
+        return orderAmount;
129
+    }
130
+
131
+    public void setOrderAmount(Integer orderAmount) {
132
+        this.orderAmount = orderAmount;
133
+    }
134
+
135
+    public String getOrderCurrency() {
136
+        return orderCurrency;
137
+    }
138
+
139
+    public void setOrderCurrency(String orderCurrency) {
140
+        this.orderCurrency = orderCurrency;
141
+    }
142
+
143
+    public String getRequestId() {
144
+        return requestId;
145
+    }
146
+
147
+    public void setRequestId(String requestId) {
148
+        this.requestId = requestId;
149
+    }
150
+
151
+    public String getPartnerId() {
152
+        return partnerId;
153
+    }
154
+
155
+    public void setPartnerId(String partnerId) {
156
+        this.partnerId = partnerId;
157
+    }
158
+
159
+    public String getNotifyUrl() {
160
+        return notifyUrl;
161
+    }
162
+
163
+    public void setNotifyUrl(String notifyUrl) {
164
+        this.notifyUrl = notifyUrl;
165
+    }
166
+
167
+    public String getCallbackUrl() {
168
+        return callbackUrl;
169
+    }
170
+
171
+    public void setCallbackUrl(String callbackUrl) {
172
+        this.callbackUrl = callbackUrl;
173
+    }
174
+
175
+    public String getRemark() {
176
+        return remark;
177
+    }
178
+
179
+    public void setRemark(String remark) {
180
+        this.remark = remark;
181
+    }
182
+
183
+    public String getPaymentModeCode() {
184
+        return paymentModeCode;
185
+    }
186
+
187
+    public void setPaymentModeCode(String paymentModeCode) {
188
+        this.paymentModeCode = paymentModeCode;
189
+    }
190
+
191
+    public String getAuthCode() {
192
+        return authCode;
193
+    }
194
+
195
+    public void setAuthCode(String authCode) {
196
+        this.authCode = authCode;
197
+    }
198
+
199
+    public String getAppId() {
200
+        return appId;
201
+    }
202
+
203
+    public void setAppId(String appId) {
204
+        this.appId = appId;
205
+    }
206
+
207
+    public String getOpenId() {
208
+        return openId;
209
+    }
210
+
211
+    public void setOpenId(String openId) {
212
+        this.openId = openId;
213
+    }
214
+
215
+    public List<ProductDetails> getProductDetails() {
216
+        return productDetails;
217
+    }
218
+
219
+    public void setProductDetails(List<ProductDetails> productDetails) {
220
+        this.productDetails = productDetails;
221
+    }
222
+
223
+    public String getSplitMark() {
224
+        return splitMark;
225
+    }
226
+
227
+    public void setSplitMark(String splitMark) {
228
+        this.splitMark = splitMark;
229
+    }
230
+
231
+    public Payer getPayer() {
232
+        return payer;
233
+    }
234
+
235
+    public void setPayer(Payer payer) {
236
+        this.payer = payer;
237
+    }
238
+
239
+    public String getClientIp() {
240
+        return clientIp;
241
+    }
242
+
243
+    public void setClientIp(String clientIp) {
244
+        this.clientIp = clientIp;
245
+    }
246
+
247
+    public Short getTimeout() {
248
+        return timeout;
249
+    }
250
+
251
+    public void setTimeout(Short timeout) {
252
+        this.timeout = timeout;
253
+    }
254
+
255
+    public String getMerchantUserId() {
256
+        return merchantUserId;
257
+    }
258
+
259
+    public void setMerchantUserId(String merchantUserId) {
260
+        this.merchantUserId = merchantUserId;
261
+    }
262
+
263
+    public String getBindCardId() {
264
+        return bindCardId;
265
+    }
266
+
267
+    public void setBindCardId(String bindCardId) {
268
+        this.bindCardId = bindCardId;
269
+    }
270
+
271
+    public String getReportSerialNo() {
272
+        return reportSerialNo;
273
+    }
274
+
275
+    public void setReportSerialNo(String reportSerialNo) {
276
+        this.reportSerialNo = reportSerialNo;
277
+    }
278
+
279
+    public String getApCardNo() {
280
+        return apCardNo;
281
+    }
282
+
283
+    public void setApCardNo(String apCardNo) {
284
+        this.apCardNo = apCardNo;
285
+    }
286
+
287
+    public String getApUserData() {
288
+        return apUserData;
289
+    }
290
+
291
+    public void setApUserData(String apUserData) {
292
+        this.apUserData = apUserData;
293
+    }
294
+
295
+    public String getApTransData() {
296
+        return apTransData;
297
+    }
298
+
299
+    public void setApTransData(String apTransData) {
300
+        this.apTransData = apTransData;
301
+    }
302
+
303
+    public String getProjectId() {
304
+        return projectId;
305
+    }
306
+
307
+    public void setProjectId(String projectId) {
308
+        this.projectId = projectId;
309
+    }
310
+
311
+    public String getLimitAccType() {
312
+        return limitAccType;
313
+    }
314
+
315
+    public void setLimitAccType(String limitAccType) {
316
+        this.limitAccType = limitAccType;
317
+    }
318
+
319
+    public String getSubsidyMark() {
320
+        return subsidyMark;
321
+    }
322
+
323
+    public void setSubsidyMark(String subsidyMark) {
324
+        this.subsidyMark = subsidyMark;
325
+    }
326
+
327
+    public Integer getSubsidyAmount() {
328
+        return subsidyAmount;
329
+    }
330
+
331
+    public void setSubsidyAmount(Integer subsidyAmount) {
332
+        this.subsidyAmount = subsidyAmount;
333
+    }
334
+
335
+    public String getHmac() {
336
+        return hmac;
337
+    }
338
+
339
+    public void setHmac(String hmac) {
340
+        this.hmac = hmac;
341
+    }
342
+
343
+    public static final class PayOrderReqBuilder {
344
+        private String merchantId;
345
+        private Integer orderAmount;
346
+        private String orderCurrency;
347
+        private String requestId;
348
+        private String partnerId;
349
+        private String notifyUrl;
350
+        private String callbackUrl;
351
+        private String remark;
352
+        private String paymentModeCode;
353
+        private String authCode;
354
+        private String appId;
355
+        private String openId;
356
+        private List<ProductDetails> productDetails;
357
+        private String splitMark;
358
+        private Payer payer;
359
+        private String clientIp;
360
+        private Short timeout;
361
+        private String merchantUserId;
362
+        private String bindCardId;
363
+        private String reportSerialNo;
364
+        private String apCardNo;
365
+        private String apUserData;
366
+        private String apTransData;
367
+        private String projectId;
368
+        private String limitAccType;
369
+        private String subsidyMark;
370
+        private Integer subsidyAmount;
371
+        private String hmac;
372
+
373
+        private PayOrderReqBuilder() {
374
+        }
375
+
376
+        public static PayOrderReqBuilder aPayOrderReq() {
377
+            return new PayOrderReqBuilder();
378
+        }
379
+
380
+        public PayOrderReqBuilder withMerchantId(String merchantId) {
381
+            this.merchantId = merchantId;
382
+            return this;
383
+        }
384
+
385
+        public PayOrderReqBuilder withOrderAmount(Integer orderAmount) {
386
+            this.orderAmount = orderAmount;
387
+            return this;
388
+        }
389
+
390
+        public PayOrderReqBuilder withOrderCurrency(String orderCurrency) {
391
+            this.orderCurrency = orderCurrency;
392
+            return this;
393
+        }
394
+
395
+        public PayOrderReqBuilder withRequestId(String requestId) {
396
+            this.requestId = requestId;
397
+            return this;
398
+        }
399
+
400
+        public PayOrderReqBuilder withPartnerId(String partnerId) {
401
+            this.partnerId = partnerId;
402
+            return this;
403
+        }
404
+
405
+        public PayOrderReqBuilder withNotifyUrl(String notifyUrl) {
406
+            this.notifyUrl = notifyUrl;
407
+            return this;
408
+        }
409
+
410
+        public PayOrderReqBuilder withCallbackUrl(String callbackUrl) {
411
+            this.callbackUrl = callbackUrl;
412
+            return this;
413
+        }
414
+
415
+        public PayOrderReqBuilder withRemark(String remark) {
416
+            this.remark = remark;
417
+            return this;
418
+        }
419
+
420
+        public PayOrderReqBuilder withPaymentModeCode(String paymentModeCode) {
421
+            this.paymentModeCode = paymentModeCode;
422
+            return this;
423
+        }
424
+
425
+        public PayOrderReqBuilder withAuthCode(String authCode) {
426
+            this.authCode = authCode;
427
+            return this;
428
+        }
429
+
430
+        public PayOrderReqBuilder withAppId(String appId) {
431
+            this.appId = appId;
432
+            return this;
433
+        }
434
+
435
+        public PayOrderReqBuilder withOpenId(String openId) {
436
+            this.openId = openId;
437
+            return this;
438
+        }
439
+
440
+        public PayOrderReqBuilder withProductDetails(List<ProductDetails> productDetails) {
441
+            this.productDetails = productDetails;
442
+            return this;
443
+        }
444
+
445
+        public PayOrderReqBuilder withSplitMark(String splitMark) {
446
+            this.splitMark = splitMark;
447
+            return this;
448
+        }
449
+
450
+        public PayOrderReqBuilder withPayer(Payer payer) {
451
+            this.payer = payer;
452
+            return this;
453
+        }
454
+
455
+        public PayOrderReqBuilder withClientIp(String clientIp) {
456
+            this.clientIp = clientIp;
457
+            return this;
458
+        }
459
+
460
+        public PayOrderReqBuilder withTimeout(Short timeout) {
461
+            this.timeout = timeout;
462
+            return this;
463
+        }
464
+
465
+        public PayOrderReqBuilder withMerchantUserId(String merchantUserId) {
466
+            this.merchantUserId = merchantUserId;
467
+            return this;
468
+        }
469
+
470
+        public PayOrderReqBuilder withBindCardId(String bindCardId) {
471
+            this.bindCardId = bindCardId;
472
+            return this;
473
+        }
474
+
475
+        public PayOrderReqBuilder withReportSerialNo(String reportSerialNo) {
476
+            this.reportSerialNo = reportSerialNo;
477
+            return this;
478
+        }
479
+
480
+        public PayOrderReqBuilder withApCardNo(String apCardNo) {
481
+            this.apCardNo = apCardNo;
482
+            return this;
483
+        }
484
+
485
+        public PayOrderReqBuilder withApUserData(String apUserData) {
486
+            this.apUserData = apUserData;
487
+            return this;
488
+        }
489
+
490
+        public PayOrderReqBuilder withApTransData(String apTransData) {
491
+            this.apTransData = apTransData;
492
+            return this;
493
+        }
494
+
495
+        public PayOrderReqBuilder withProjectId(String projectId) {
496
+            this.projectId = projectId;
497
+            return this;
498
+        }
499
+
500
+        public PayOrderReqBuilder withLimitAccType(String limitAccType) {
501
+            this.limitAccType = limitAccType;
502
+            return this;
503
+        }
504
+
505
+        public PayOrderReqBuilder withSubsidyMark(String subsidyMark) {
506
+            this.subsidyMark = subsidyMark;
507
+            return this;
508
+        }
509
+
510
+        public PayOrderReqBuilder withSubsidyAmount(Integer subsidyAmount) {
511
+            this.subsidyAmount = subsidyAmount;
512
+            return this;
513
+        }
514
+
515
+        public PayOrderReqBuilder withHmac(String hmac) {
516
+            this.hmac = hmac;
517
+            return this;
518
+        }
519
+
520
+        public PayOrderReq build() {
521
+            PayOrderReq payOrderReq = new PayOrderReq();
522
+            payOrderReq.setMerchantId(merchantId);
523
+            payOrderReq.setOrderAmount(orderAmount);
524
+            payOrderReq.setOrderCurrency(orderCurrency);
525
+            payOrderReq.setRequestId(requestId);
526
+            payOrderReq.setPartnerId(partnerId);
527
+            payOrderReq.setNotifyUrl(notifyUrl);
528
+            payOrderReq.setCallbackUrl(callbackUrl);
529
+            payOrderReq.setRemark(remark);
530
+            payOrderReq.setPaymentModeCode(paymentModeCode);
531
+            payOrderReq.setAuthCode(authCode);
532
+            payOrderReq.setAppId(appId);
533
+            payOrderReq.setOpenId(openId);
534
+            payOrderReq.setProductDetails(productDetails);
535
+            payOrderReq.setSplitMark(splitMark);
536
+            payOrderReq.setPayer(payer);
537
+            payOrderReq.setClientIp(clientIp);
538
+            payOrderReq.setTimeout(timeout);
539
+            payOrderReq.setMerchantUserId(merchantUserId);
540
+            payOrderReq.setBindCardId(bindCardId);
541
+            payOrderReq.setReportSerialNo(reportSerialNo);
542
+            payOrderReq.setApCardNo(apCardNo);
543
+            payOrderReq.setApUserData(apUserData);
544
+            payOrderReq.setApTransData(apTransData);
545
+            payOrderReq.setProjectId(projectId);
546
+            payOrderReq.setLimitAccType(limitAccType);
547
+            payOrderReq.setSubsidyMark(subsidyMark);
548
+            payOrderReq.setSubsidyAmount(subsidyAmount);
549
+            payOrderReq.setHmac(hmac);
550
+            return payOrderReq;
551
+        }
552
+    }
553
+}

+ 133 - 0
src/test/java/com/tdba/cxb/ares/api/Payer.java

@@ -0,0 +1,133 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 境内收单-身份信息
6
+ * @author: libo
7
+ * @create: 2022-05-27 10:41:44
8
+ */
9
+public class Payer {
10
+
11
+    /**  付款方名称 varchar(100) 付款方名称 C*/
12
+    private String name;
13
+
14
+    /**  手机号码 varchar(50) 手机号码 C*/
15
+    private String phoneNum;
16
+
17
+    /**  证件类型 varchar(20) 身份证IDCARD C*/
18
+    private String idType;
19
+
20
+    /**  证件号码 varchar(100) 目前只接受18位身份证号码或9位组织机构代码,根据证件类型匹配 C*/
21
+    private String idNum;
22
+
23
+    /**  银行卡号 varchar(100) 银行卡号,银联wap支付方式可以选择传递此参数来透传至银联 O*/
24
+    private String bankCardNum;
25
+
26
+    /**  邮箱 varchar(50) 邮箱 O*/
27
+    private String email;
28
+
29
+    public String getName() {
30
+        return name;
31
+    }
32
+
33
+    public void setName(String name) {
34
+        this.name = name;
35
+    }
36
+
37
+    public String getPhoneNum() {
38
+        return phoneNum;
39
+    }
40
+
41
+    public void setPhoneNum(String phoneNum) {
42
+        this.phoneNum = phoneNum;
43
+    }
44
+
45
+    public String getIdType() {
46
+        return idType;
47
+    }
48
+
49
+    public void setIdType(String idType) {
50
+        this.idType = idType;
51
+    }
52
+
53
+    public String getIdNum() {
54
+        return idNum;
55
+    }
56
+
57
+    public void setIdNum(String idNum) {
58
+        this.idNum = idNum;
59
+    }
60
+
61
+    public String getBankCardNum() {
62
+        return bankCardNum;
63
+    }
64
+
65
+    public void setBankCardNum(String bankCardNum) {
66
+        this.bankCardNum = bankCardNum;
67
+    }
68
+
69
+    public String getEmail() {
70
+        return email;
71
+    }
72
+
73
+    public void setEmail(String email) {
74
+        this.email = email;
75
+    }
76
+
77
+    public static final class PayerBuilder {
78
+        private String name;
79
+        private String phoneNum;
80
+        private String idType;
81
+        private String idNum;
82
+        private String bankCardNum;
83
+        private String email;
84
+
85
+        private PayerBuilder() {
86
+        }
87
+
88
+        public static PayerBuilder aPayer() {
89
+            return new PayerBuilder();
90
+        }
91
+
92
+        public PayerBuilder withName(String name) {
93
+            this.name = name;
94
+            return this;
95
+        }
96
+
97
+        public PayerBuilder withPhoneNum(String phoneNum) {
98
+            this.phoneNum = phoneNum;
99
+            return this;
100
+        }
101
+
102
+        public PayerBuilder withIdType(String idType) {
103
+            this.idType = idType;
104
+            return this;
105
+        }
106
+
107
+        public PayerBuilder withIdNum(String idNum) {
108
+            this.idNum = idNum;
109
+            return this;
110
+        }
111
+
112
+        public PayerBuilder withBankCardNum(String bankCardNum) {
113
+            this.bankCardNum = bankCardNum;
114
+            return this;
115
+        }
116
+
117
+        public PayerBuilder withEmail(String email) {
118
+            this.email = email;
119
+            return this;
120
+        }
121
+
122
+        public Payer build() {
123
+            Payer payer = new Payer();
124
+            payer.idNum = this.idNum;
125
+            payer.name = this.name;
126
+            payer.email = this.email;
127
+            payer.bankCardNum = this.bankCardNum;
128
+            payer.idType = this.idType;
129
+            payer.phoneNum = this.phoneNum;
130
+            return payer;
131
+        }
132
+    }
133
+}

+ 115 - 0
src/test/java/com/tdba/cxb/ares/api/ProductDetails.java

@@ -0,0 +1,115 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description: 境内收单-商品信息
6
+ * @author: libo
7
+ * @create: 2022-05-27 10:37:18
8
+ */
9
+public class ProductDetails {
10
+
11
+    /**  商品名称 varchar(500) 商品名称,需传递真实产品名称。 M*/
12
+    private String name;
13
+
14
+    /**  商品数量 long 商品数量 M*/
15
+    private Integer quantity;
16
+
17
+    /**  商品单价 long 单位:分,1元=100分,此项为单个商品的价格。 M*/
18
+    private Integer amount;
19
+
20
+    /**  收款人 varchar(200) 收款人名称(如果为空的话自动取注册名称) O*/
21
+    private String receiver;
22
+
23
+    /**  商品描述 varchar(500) 商品描述 O*/
24
+    private String description;
25
+
26
+    public String getName() {
27
+        return name;
28
+    }
29
+
30
+    public void setName(String name) {
31
+        this.name = name;
32
+    }
33
+
34
+    public Integer getQuantity() {
35
+        return quantity;
36
+    }
37
+
38
+    public void setQuantity(Integer quantity) {
39
+        this.quantity = quantity;
40
+    }
41
+
42
+    public Integer getAmount() {
43
+        return amount;
44
+    }
45
+
46
+    public void setAmount(Integer amount) {
47
+        this.amount = amount;
48
+    }
49
+
50
+    public String getReceiver() {
51
+        return receiver;
52
+    }
53
+
54
+    public void setReceiver(String receiver) {
55
+        this.receiver = receiver;
56
+    }
57
+
58
+    public String getDescription() {
59
+        return description;
60
+    }
61
+
62
+    public void setDescription(String description) {
63
+        this.description = description;
64
+    }
65
+
66
+    public static final class ProductDetailsBuilder {
67
+        private String name;
68
+        private Integer quantity;
69
+        private Integer amount;
70
+        private String receiver;
71
+        private String description;
72
+
73
+        private ProductDetailsBuilder() {
74
+        }
75
+
76
+        public static ProductDetailsBuilder aProductDetails() {
77
+            return new ProductDetailsBuilder();
78
+        }
79
+
80
+        public ProductDetailsBuilder withName(String name) {
81
+            this.name = name;
82
+            return this;
83
+        }
84
+
85
+        public ProductDetailsBuilder withQuantity(Integer quantity) {
86
+            this.quantity = quantity;
87
+            return this;
88
+        }
89
+
90
+        public ProductDetailsBuilder withAmount(Integer amount) {
91
+            this.amount = amount;
92
+            return this;
93
+        }
94
+
95
+        public ProductDetailsBuilder withReceiver(String receiver) {
96
+            this.receiver = receiver;
97
+            return this;
98
+        }
99
+
100
+        public ProductDetailsBuilder withDescription(String description) {
101
+            this.description = description;
102
+            return this;
103
+        }
104
+
105
+        public ProductDetails build() {
106
+            ProductDetails productDetails = new ProductDetails();
107
+            productDetails.setName(name);
108
+            productDetails.setQuantity(quantity);
109
+            productDetails.setAmount(amount);
110
+            productDetails.setReceiver(receiver);
111
+            productDetails.setDescription(description);
112
+            return productDetails;
113
+        }
114
+    }
115
+}

+ 300 - 0
src/test/java/com/tdba/cxb/ares/api/ShouxinyiTest.java

@@ -0,0 +1,300 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import com.alibaba.fastjson2.JSON;
4
+import org.junit.jupiter.api.Test;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+import org.springframework.util.StringUtils;
8
+
9
+import javax.crypto.Cipher;
10
+import javax.crypto.SecretKey;
11
+import javax.crypto.spec.SecretKeySpec;
12
+import java.io.*;
13
+import java.lang.reflect.Field;
14
+import java.math.BigDecimal;
15
+import java.security.*;
16
+import java.security.cert.Certificate;
17
+import java.security.cert.CertificateFactory;
18
+import java.security.cert.X509Certificate;
19
+import java.security.spec.X509EncodedKeySpec;
20
+import java.util.*;
21
+
22
+/**
23
+ * @program: order-web
24
+ * @description: 首信易 测试
25
+ * @author: libo
26
+ * @create: 2022-05-23 16:11:10
27
+ */
28
+public class ShouxinyiTest {
29
+
30
+    Logger logger = LoggerFactory.getLogger(ShouxinyiTest.class);
31
+
32
+    /**
33
+     * 对参数进行排序并拼接(自动去除签名参数sign)
34
+     * @param param     参数
35
+     * @param suffix    后缀
36
+     * @return
37
+     */
38
+    public static String getSignContent(Map<String, Object> param, String suffix) {
39
+        StringBuffer content = new StringBuffer();
40
+        List<String> keys = new ArrayList(param.keySet());
41
+        Collections.sort(keys);
42
+        if(!StringUtils.hasLength(suffix)){
43
+            suffix = "";
44
+        }
45
+        int index = 0;
46
+        for (int i = 0; i < keys.size(); i++) {
47
+            String key = keys.get(i);
48
+            Object value = param.get(key);
49
+            if ("msg_digest".equals(key) || "sign".equals(key) || "appId".equals(key)) {
50
+                continue;
51
+            }
52
+            if (StringUtils.hasText(key) && StringUtils.hasText(value.toString())) {
53
+                content.append(value).append(suffix);
54
+                index++;
55
+            }
56
+        }
57
+        return content.toString();
58
+    }
59
+
60
+    public static String sign(byte[] data, InputStream inputStream, String strPassword)
61
+            throws Exception {
62
+//        byte[] keyBytes = decryptBASE64(privateKey);
63
+
64
+        Signature signature = Signature.getInstance("MD5withRSA");
65
+        signature.initSign(getPvkformPfx(inputStream, strPassword));
66
+        signature.update(data);
67
+        return new String(Base64.getEncoder().encode(signature.sign()), "UTF-8");
68
+    }
69
+    public static byte[] decryptBASE64(String key)
70
+            throws Exception {
71
+        return Base64.getEncoder().encode(key.getBytes("UTF-8"));
72
+    }
73
+
74
+    /**
75
+     * 加密
76
+     * @throws Exception
77
+     */
78
+    @Test
79
+    public void encrypt() throws Exception {
80
+        Map<String, Object> param = new HashMap();
81
+        param.put("merchantId", "899104033");
82
+        param.put("requestId", "wx1653544237773600570_9173");
83
+
84
+        String content = getSignContent(param, "#");
85
+        MessageDigest sha = MessageDigest.getInstance("SHA");
86
+        sha.update(content.getBytes("UTF-8"));
87
+        byte[] sha1Array = sha.digest();
88
+
89
+        byte[] data = null;
90
+        try(InputStream inputStream = ShouxinyiTest.class.getResourceAsStream("/5upay/private.pfx")){
91
+            data = inputStream.readAllBytes();
92
+        }
93
+
94
+        String hmac = sign(sha1Array, ShouxinyiTest.class.getResourceAsStream("/5upay/private.pfx"), "IDajxBO5");
95
+        logger.info("hmac = {}", hmac);
96
+        param.put("hmac", hmac);
97
+
98
+//        KeyGenerator generator = KeyGenerator.getInstance("AES");
99
+//        generator.init(128);
100
+//        SecretKey secretKey = generator.generateKey();
101
+        String aesKey = generateAlphaAndDigit(16);
102
+        logger.info("aeskey = {}", aesKey);
103
+        String result = new String(Base64.getEncoder().encode(encrypt(JSON.toJSONString(param).getBytes("UTF-8"), aesKey.getBytes("UTF-8"))));
104
+        logger.error("result = {}", result);
105
+
106
+        try(InputStream inputStream = ShouxinyiTest.class.getResourceAsStream("/5upay/test.cer")){
107
+            CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
108
+            X509Certificate x509Certificate = (X509Certificate)certificateFactory.generateCertificate(inputStream);
109
+            Cipher cipher = Cipher.getInstance("RSA");
110
+            cipher.init(Cipher.ENCRYPT_MODE, x509Certificate.getPublicKey());
111
+            logger.info("{}", Base64.getEncoder().encodeToString(cipher.doFinal(aesKey.getBytes("UTF-8"))));
112
+        }
113
+    }
114
+
115
+    public static byte[] encrypt(byte[] data, byte[] key) {
116
+        if (key.length != 16) {
117
+            throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
118
+        } else {
119
+            try {
120
+                SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
121
+                byte[] enCodeFormat = secretKey.getEncoded();
122
+                SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
123
+                Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
124
+                cipher.init(1, seckey);
125
+                byte[] result = cipher.doFinal(data);
126
+                return result;
127
+            } catch (Exception var7) {
128
+                throw new RuntimeException("encrypt fail!", var7);
129
+            }
130
+        }
131
+    }
132
+
133
+    public static String generateAlphaAndDigit(int length) {
134
+        if (length < 1) {
135
+            return "";
136
+        } else {
137
+            StringBuilder sb = new StringBuilder();
138
+            SecureRandom rand = new SecureRandom();
139
+            SecureRandom randdata = new SecureRandom();
140
+
141
+            for(int i = 0; i < length; ++i) {
142
+                int index = rand.nextInt(3);
143
+                int data;
144
+                switch (index) {
145
+                    case 0:
146
+                        data = randdata.nextInt(10);
147
+                        sb.append(data);
148
+                        break;
149
+                    case 1:
150
+                        data = randdata.nextInt(26) + 65;
151
+                        sb.append((char)data);
152
+                        break;
153
+                    case 2:
154
+                        data = randdata.nextInt(26) + 97;
155
+                        sb.append((char)data);
156
+                }
157
+            }
158
+
159
+            return sb.toString();
160
+        }
161
+    }
162
+
163
+    /**
164
+     * 解密
165
+     */
166
+    @Test
167
+    public void decrypt() throws Exception{
168
+
169
+        try(InputStream inputStream = ShouxinyiTest.class.getResourceAsStream("/5upay/private.pfx")){
170
+            String encryptKey = "DRTWcPjtuHPpVXZDg1qZyiVLDO/gYRhbhAFiyNn9CFNXwUvfCuscUda+f49h+S2zPP2SiM9ZMPn/+NUesOh6a1phJiOvjeQNnJru54gbSOATw43uv4mnSxPaC6MQWrlqDpuxW0VZLfndaH3avkW3GwwT3gdHrC5WN9n4UJ8EpsvCgj89uDeGfp1g4jp7yD0Or9nB+AEY2l9k4QLF06CfZgW091Wq1Y9PAKsYPeXZ3wo/yVOSEdlkdcS5maIqDJ3ZoIVDQGNAGnQKfIa1YiqoXc5bNOQQNx3BfH0Z0NFTy8eOq1raiPjFX65sLx+qJa1VohzqZfVPFA15fBAErQNyQQ==";
171
+            Cipher cipher = Cipher.getInstance("RSA");
172
+            cipher.init(Cipher.DECRYPT_MODE, getPvkformPfx(inputStream, "IDajxBO5"));
173
+            byte[] aesKey = cipher.doFinal(Base64.getDecoder().decode(encryptKey));
174
+            logger.info("{}", aesKey);
175
+
176
+            String aesStr = "5O3oXclAmFjd4zC8j6pWfs7A2l4hOooWNumEjlUjee1SUzpOD/eQSRlMNiFb6ORdvlqYfj4z8CrP0ZSqtRni81JpXhcxoIutw/N6Kh/hIrz4uIaG2wJc+3OsRGB/QSAGHz7D7yE8eW+/seDbVDBN3JGQUf4/RSsC4bYWUs0+88NWcm5+XwqG7xPOqsY8omJH";
177
+//            SecretKey secretKey = new SecretKeySpec("Z1O5WsEeotdeuRuc".getBytes("UTF-8"), "AES");
178
+            SecretKey secretKey = new SecretKeySpec(aesKey, "AES");
179
+            byte[] enCodeFormat = secretKey.getEncoded();
180
+            SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
181
+            Cipher cipher2 = Cipher.getInstance("AES/ECB/PKCS5Padding");
182
+            cipher2.init(Cipher.DECRYPT_MODE, seckey);
183
+            byte[] result = cipher2.doFinal(Base64.getDecoder().decode(aesStr.getBytes("UTF-8")));
184
+            logger.info("result = {}", new String(result, "UTF-8"));
185
+        }
186
+    }
187
+
188
+    @Test
189
+    public void decryptReverse() throws Exception{
190
+
191
+        try(InputStream inputStream = ShouxinyiTest.class.getResourceAsStream("/5upay/test.cer")){
192
+            String encryptKey = "rdvAnNvUm05wPuOXV2kG81efBqUplMuQe0l+L/ixLY+s8vvFW3P2doQATNI/kOdPzSPtbxgEJGr91HJBqHSTh2c440etUTSnNbKJAxdhnmSYBmb4HjyPR5dBLRR+g5EErjVwOodQ0oY4IPVIa5r67l9gjtEsSK52CIjTTN/lp0a3NvTsQ2SmTrH70/6RPgYIHSwtgCe+8BvGbJOQVDwGGEZKHU2JC8tdrD4/Ke9qfDI9YtnqUTPaEeWogYkyylnMC384WJQ6HKa3TzFWuoifzKKhT14MqaT+3OgBkWxYsnDKqcF0s8G6YKb2EQ+YTNF8IPmI8bThOewLEJetkBjK3w==";
193
+            CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
194
+            X509Certificate x509Certificate = (X509Certificate)certificateFactory.generateCertificate(inputStream);
195
+            Cipher cipher = Cipher.getInstance("RSA");
196
+            cipher.init(Cipher.DECRYPT_MODE, x509Certificate.getPublicKey());
197
+            logger.info("{}", cipher.doFinal(Base64.getDecoder().decode(encryptKey)));
198
+        }
199
+    }
200
+
201
+    /**
202
+     * RSA公钥加密
203
+     *
204
+     * @param str       加密字符串
205
+     * @param publicKey 公钥
206
+     * @return 密文
207
+     * @throws Exception 加密过程中的异常信息
208
+     */
209
+    public static String publicKeyEncrypt(byte[] value, byte[] publicKey) throws Exception {
210
+        Cipher cipher = Cipher.getInstance("RSA");
211
+        cipher.init(Cipher.ENCRYPT_MODE,  KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKey)));
212
+        return Base64.getEncoder().encodeToString(cipher.doFinal(value));
213
+    }
214
+
215
+
216
+    private static PrivateKey getPvkformPfx(InputStream inputStream, String strPassword){
217
+        try {
218
+            //密码处理
219
+            char[] nPassword = null;
220
+            if ((strPassword == null) || strPassword.trim().equals("")){
221
+                nPassword = null;
222
+            } else {
223
+                nPassword = strPassword.toCharArray();
224
+            }
225
+            //加载读取PFX文件
226
+            KeyStore ks = KeyStore.getInstance("PKCS12");
227
+            ks.load(inputStream, nPassword);
228
+            inputStream.close();
229
+            Enumeration enumas = ks.aliases();
230
+            //从文件中获取秘钥
231
+            String keyPFXFile = null;
232
+            if (enumas.hasMoreElements()) {
233
+                keyPFXFile = (String)enumas.nextElement();
234
+            }
235
+            PrivateKey prikey = (PrivateKey) ks.getKey(keyPFXFile, nPassword);
236
+            Certificate cert = ks.getCertificate(keyPFXFile);
237
+            PublicKey pubkey = cert.getPublicKey();
238
+
239
+            return prikey;
240
+        } catch (Exception e) {
241
+            e.printStackTrace();
242
+        }
243
+        return null;
244
+    }
245
+
246
+    @Test
247
+    public void payOrder() throws Exception {
248
+        PayOrderReq payOrderReq = PayOrderReq.PayOrderReqBuilder.aPayOrderReq()
249
+                .withMerchantId("899104033")
250
+                .withRequestId("wxdev1653544237773600570_9372")
251
+                .withOrderAmount(100)
252
+                .withOrderCurrency("CNY")
253
+                .withNotifyUrl("https://test.bjtdba.com/api/notify/pay_5upay")
254
+                .withCallbackUrl("https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg4NzQ4NDgzNQ==&scene=124&uin=&key=&devicetype=Windows+10+x64&version=6302019c&lang=zh_CN&a8scene=7&fontgear=2")
255
+                .withPaymentModeCode("ALIPAY_OFFICIAL_PAY")
256
+//                .withAppId("wxfb755febdb800f23")
257
+//                .withOpenId("ow5su5LU066ns3NOt3pb9Zg9sM_Y")
258
+                .withProductDetails(List.of(ProductDetails.ProductDetailsBuilder.aProductDetails()
259
+                        .withName("测试商品")
260
+                        .withQuantity(1)
261
+                        .withAmount(100)
262
+                        .build()))
263
+                .withSplitMark("DO_SPLIT")
264
+                .withPayer(Payer.PayerBuilder.aPayer()
265
+                        .withName("李博")
266
+                        .withPhoneNum("18801109107")
267
+                        .build())
268
+                .withClientIp("221.217.152.228")
269
+                .build();
270
+
271
+        //1.按a-z顺序排列键名对应的键值,中间用#拼接,示例:1#2#3#(“#”尾加首不加),
272
+        byte[] hmacSource = payOrderReq.generateHmacSource();
273
+        logger.info("hmacSource = {}", hmacSource);
274
+
275
+        //2.进行sha1签名
276
+        MessageDigest sha = MessageDigest.getInstance("SHA");
277
+        sha.update(hmacSource);
278
+        byte[] sha1Array = sha.digest();
279
+
280
+        //3.商户下载下来的cfca私钥证书对第2步生成的字节流结果再签名, 将结果做为hmac值
281
+        payOrderReq.setHmac(sign(sha1Array, ShouxinyiTest.class.getResourceAsStream("/5upay/private.pfx"), "IDajxBO5"));
282
+
283
+        //4.由商户随机生成十六位aes密钥
284
+        String aesKey = generateAlphaAndDigit(16);
285
+        logger.error("aeskey = {}", aesKey);
286
+
287
+        //5.由商户随机生成的aes密钥加密加入了hmac后的json串
288
+        String result = new String(Base64.getEncoder().encode(encrypt(JSON.toJSONString(payOrderReq).getBytes("UTF-8"), aesKey.getBytes("UTF-8"))));
289
+        logger.info("body = {}", result);
290
+
291
+        //6.用首信易demo里提供的cfca公钥加密第4步商户生成aes密钥
292
+        try(InputStream inputStream = ShouxinyiTest.class.getResourceAsStream("/5upay/test.cer")){
293
+            CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
294
+            X509Certificate x509Certificate = (X509Certificate)certificateFactory.generateCertificate(inputStream);
295
+            Cipher cipher = Cipher.getInstance("RSA");
296
+            cipher.init(Cipher.ENCRYPT_MODE, x509Certificate.getPublicKey());
297
+            logger.info("encryptKey = {}", Base64.getEncoder().encodeToString(cipher.doFinal(aesKey.getBytes("UTF-8"))));
298
+        }
299
+    }
300
+}

+ 211 - 0
src/test/java/com/tdba/cxb/ares/api/SignPublisher.java

@@ -0,0 +1,211 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.util.StringUtils;
6
+
7
+import java.lang.reflect.Field;
8
+import java.lang.reflect.ParameterizedType;
9
+import java.lang.reflect.Type;
10
+import java.math.BigDecimal;
11
+import java.math.BigInteger;
12
+import java.sql.Time;
13
+import java.sql.Timestamp;
14
+import java.util.*;
15
+
16
+/**
17
+ * @program: order-web
18
+ * @description:
19
+ * @author: libo
20
+ * @create: 2022-05-27 09:03:04
21
+ */
22
+public class SignPublisher {
23
+    static final Logger LOGGER = LoggerFactory.getLogger(SignPublisher.class);
24
+    private static HashSet<Class<?>> primitiveClasses = new HashSet();
25
+
26
+    public SignPublisher() {
27
+    }
28
+
29
+    public static String generateHmacSource(Object obj) throws IllegalAccessException {
30
+        if (obj == null) {
31
+            throw new IllegalArgumentException("the obj is null");
32
+        } else {
33
+            StringBuilder hmacSource = new StringBuilder();
34
+            append(obj, hmacSource);
35
+            LOGGER.info("generateHmacSource hmacSource:{}", hmacSource.toString());
36
+            return hmacSource.toString();
37
+        }
38
+    }
39
+
40
+    private static void sortField(Class<?> clazz, List<String> fields) {
41
+        Class<?> parent = clazz.getSuperclass();
42
+        if (parent != null) {
43
+            sortField(parent, fields);
44
+        }
45
+
46
+        Field[] var3 = clazz.getDeclaredFields();
47
+        int var4 = var3.length;
48
+
49
+        for(int var5 = 0; var5 < var4; ++var5) {
50
+            Field field = var3[var5];
51
+            fields.add(field.getName());
52
+        }
53
+
54
+        Collections.sort(fields);
55
+    }
56
+
57
+    private static void append(Object entity, List<String> fields, StringBuilder hmacSource) throws IllegalAccessException {
58
+        Class<?> clazz = entity.getClass();
59
+        Iterator var4 = fields.iterator();
60
+
61
+        label95:
62
+        while(var4.hasNext()) {
63
+            String fieldName = (String)var4.next();
64
+
65
+            Field field;
66
+            try {
67
+                field = clazz.getDeclaredField(fieldName);
68
+            } catch (NoSuchFieldException var16) {
69
+                field = findParentField(entity, fieldName);
70
+            }
71
+
72
+            if (field != null && !field.isSynthetic()) {
73
+                field.setAccessible(true);
74
+                Object obj = field.get(entity);
75
+                Class<?> type = field.getType();
76
+                Type superType = field.getGenericType();
77
+                Class<?> genericClass = null;
78
+                if (superType instanceof ParameterizedType) {
79
+                    Type[] genericType = ((ParameterizedType)superType).getActualTypeArguments();
80
+                    genericClass = (Class)genericType[0];
81
+                }
82
+
83
+                if (type.isArray()) {
84
+                    Object[] objects = (Object[])((Object[])obj);
85
+                    if (objects != null && objects.length > 0) {
86
+                        Object[] var22 = objects;
87
+                        int var23 = objects.length;
88
+
89
+                        for(int var24 = 0; var24 < var23; ++var24) {
90
+                            Object object = var22[var24];
91
+                            append(object, hmacSource);
92
+                        }
93
+                    }
94
+                } else {
95
+                    Iterator it;
96
+                    Object next;
97
+                    if (!(obj instanceof Collection)) {
98
+                        if (obj instanceof Map) {
99
+                            Map map = (Map)obj;
100
+                            it = map.keySet().iterator();
101
+
102
+                            while(it.hasNext()) {
103
+                                next = it.next();
104
+                                Object value = map.get(next);
105
+                                append(value, hmacSource);
106
+                            }
107
+                        } else if (obj instanceof Enum) {
108
+                            String strTmp = defaultString(obj.toString());
109
+                            if (StringUtils.hasText(strTmp)) {
110
+                                hmacSource.append(strTmp).append("#");
111
+                            }
112
+                        } else if (isPrimitiveClass(type)) {
113
+                            Object tmp = defaultIfNull(obj);
114
+                            if (StringUtils.hasText(tmp.toString())) {
115
+                                hmacSource.append(tmp).append("#");
116
+                            }
117
+                        } else if (obj != null) {
118
+                            append(obj, hmacSource);
119
+                        }
120
+                    } else {
121
+                        Collection collection = (Collection)obj;
122
+                        it = collection.iterator();
123
+
124
+                        while(true) {
125
+                            while(true) {
126
+                                if (!it.hasNext()) {
127
+                                    continue label95;
128
+                                }
129
+
130
+                                next = it.next();
131
+                                if (genericClass != null && isPrimitiveClass(genericClass)) {
132
+                                    hmacSource.append(next).append("#");
133
+                                } else {
134
+                                    append(next, hmacSource);
135
+                                }
136
+                            }
137
+                        }
138
+                    }
139
+                }
140
+            }
141
+        }
142
+
143
+    }
144
+
145
+    private static void append(Object obj, StringBuilder hmacSource) throws IllegalAccessException {
146
+        if (obj != null) {
147
+            List<String> fields = new ArrayList();
148
+            Class<?> clazz = obj.getClass();
149
+            sortField(clazz, fields);
150
+            append(obj, fields, hmacSource);
151
+        }
152
+    }
153
+
154
+    private static Field findParentField(Object obj, String fieldName) {
155
+        Class parent = obj.getClass().getSuperclass();
156
+        Field field = null;
157
+
158
+        while(parent != null && parent != Object.class) {
159
+            try {
160
+                field = parent.getDeclaredField(fieldName);
161
+            } catch (NoSuchFieldException var5) {
162
+                parent = parent.getSuperclass();
163
+            }
164
+
165
+            if (field != null) {
166
+                break;
167
+            }
168
+        }
169
+
170
+        return field;
171
+    }
172
+
173
+    private static boolean isPrimitiveClass(Class<?> clazz) {
174
+        return clazz != null && primitiveClasses.contains(clazz);
175
+    }
176
+
177
+    static {
178
+        primitiveClasses.add(Boolean.TYPE);
179
+        primitiveClasses.add(Boolean.class);
180
+        primitiveClasses.add(Character.TYPE);
181
+        primitiveClasses.add(Character.class);
182
+        primitiveClasses.add(Byte.TYPE);
183
+        primitiveClasses.add(Byte.class);
184
+        primitiveClasses.add(Short.TYPE);
185
+        primitiveClasses.add(Short.class);
186
+        primitiveClasses.add(Integer.TYPE);
187
+        primitiveClasses.add(Integer.class);
188
+        primitiveClasses.add(Long.TYPE);
189
+        primitiveClasses.add(Long.class);
190
+        primitiveClasses.add(Float.TYPE);
191
+        primitiveClasses.add(Float.class);
192
+        primitiveClasses.add(Double.TYPE);
193
+        primitiveClasses.add(Double.class);
194
+        primitiveClasses.add(BigInteger.class);
195
+        primitiveClasses.add(BigDecimal.class);
196
+        primitiveClasses.add(String.class);
197
+        primitiveClasses.add(Date.class);
198
+        primitiveClasses.add(java.sql.Date.class);
199
+        primitiveClasses.add(Time.class);
200
+        primitiveClasses.add(Timestamp.class);
201
+    }
202
+
203
+    public static String defaultString(String src){
204
+        return (null == src)? "": src;
205
+    }
206
+
207
+    public static Object defaultIfNull(Object src){
208
+        return (null == src)? "": src;
209
+    }
210
+}
211
+

+ 50 - 0
src/test/java/com/tdba/cxb/ares/api/SortTest.java

@@ -0,0 +1,50 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+import com.alibaba.fastjson2.JSON;
4
+import org.junit.jupiter.api.Test;
5
+import org.springframework.util.StringUtils;
6
+
7
+import java.lang.reflect.Field;
8
+import java.lang.reflect.ParameterizedType;
9
+import java.lang.reflect.Type;
10
+import java.util.*;
11
+
12
+/**
13
+ * @program: order-web
14
+ * @description:
15
+ * @author: libo
16
+ * @create: 2022-05-26 20:10:24
17
+ */
18
+public class SortTest {
19
+
20
+    @Test
21
+    public void test(){
22
+        Map<String, Object> param = new HashMap<>();
23
+        param.put("second", "1");
24
+        param.put("account", Map.of("test", "2", "bank", "3"));
25
+        param.put("bind", Map.of("apple", "4"));
26
+
27
+
28
+        String content = JSON.toJSONString(param);
29
+        System.out.println(param);
30
+
31
+    }
32
+
33
+    public static String resolveObject(Object src){
34
+
35
+        //过滤 属性值为空 或者 空字符串
36
+        //排序
37
+        //遍历,属性值为数组
38
+        return "";
39
+    }
40
+
41
+
42
+    @Test
43
+    public void jsonTest(){
44
+        Map<String, Object> map = new HashMap<>();
45
+        map.put("a", null);
46
+        map.put("b", "123");
47
+        System.out.println(JSON.toJSONString(map));
48
+    }
49
+
50
+}

+ 18 - 0
src/test/java/com/tdba/cxb/ares/api/StringUtil.java

@@ -0,0 +1,18 @@
1
+package com.tdba.cxb.ares.api;
2
+
3
+/**
4
+ * @program: order-web
5
+ * @description:
6
+ * @author: libo
7
+ * @create: 2022-05-27 09:40:07
8
+ */
9
+public class StringUtil {
10
+
11
+    public static String defaultString(String src){
12
+        return defaultString(src, "");
13
+    }
14
+
15
+    public static String defaultString(String src, String replacement){
16
+        return (src == null)? replacement: src;
17
+    }
18
+}

+ 27 - 0
src/test/resources/5upay/899104033

@@ -0,0 +1,27 @@
1
+-----BEGIN RSA PRIVATE KEY-----
2
+MIIEowIBAAKCAQEA3NyGUN90VGKfLkWw3OROtE0wy94R5kHJkl6hw1WZRcMwkJi1
3
+wzWzEpxAMMqQWFHr/uQQPSbBJQRxqKdEbUbQM4PcEckAk6yXuLTJVJOml2WY9Sja
4
+RRoAPveiwYpAsIuNPE/fx1Z7sushvYJiawR3sr914zs9gsY9BBF75ZTM6Uqq+j+W
5
+mSfrNQ9rA5GTx4LRDURr3H6Mrb5/rpLV2HqMkWwN1d+dZZjNWpMi+fTaHp28HbK2
6
+kCqWylrNM7quY5XdtRRjozB7Iq4Q07DG9A37a0BrOWArRkG1z9TWGHEFCbvstUZB
7
+L2kPXrhBFYzDxPVZI4cD9elc8mGjYlfek8UGUQIDAQABAoIBAQCBAFF3lTz2OPBu
8
+74fBTZzm1RtGSHw9+HkLBDkJxcqTo9GO85Ne5NOmcBtSJE6xN5BXPdB6V1ODEphs
9
+gN6H0U+0dzUoMjYjCzFHUlkyDFfGoDH6KBVtPSWdobivwNfOBoTFEIZNgScZNxtq
10
+/GgNx/s+LXRm9+gSpUVoReoPC52wOLXOyKBFdhwWEJhJuHyEMUWvVg7Fpr7F7FIT
11
+lApxknuz9J5PKeEalyvT07aFLghhEzO5PhPFSUuKX4ZNnfpMCBLAIn72BdMREP72
12
+ZbnChNasRuEkakRXz3v8yC+WvFPo5ZKHsuvWI/MXULOJVPMD/z6T1KfKue2uEetb
13
+Ymd0H1ltAoGBAPPRpToQLpgj+RYzvjkS1nUTYUhFLf3vDVhpE0vKJR9p5M7tTS0k
14
+3F3IahbUdGiQPSSyHTygfXsVtmmD9E2BRT8ml42nHm/mEQBKxnGlc1s/fbvSLoMG
15
+xMJ9ESJavPMUJg951sAIHdMAaB7uAbywqbk1IImS4IHENOSDIsWUoGxDAoGBAOfl
16
+Qt9AxvgEyK8sqN2S12cDdYokkB8pg8AWRnj/hwwt4t2ya43ept8rVS1yCgpDZ2M4
17
+Lum9TAluJXAtqb376Atsx5/Nxc9Ll/mbS5yvBGQYHWo5IEcDsbRo8lAsqryHU/5o
18
+ggalpZQ1yWWBqDlYPblIslU74TcYv/yZA7WzQ+PbAoGAAINuf6LNFlDtE1jki6Y4
19
+gWKbD9XldOVt98Ow4LX6QgitDKp/QRsUw7XKU2X7IMU8+7jMSvZjjUDMc4htmUQu
20
+ayWfqBK0A7ROUNvXcyHQDl8h2qVkp635+BbfVF0wjKp8MgglpZ3ewjT8AySpKEaO
21
+9O7htKh0hJFvMxP7nMLlW5UCgYBRW7UPgLmN8Je8Jc4FFuytvp/xXIyX8kfAD9Cf
22
+yP7Hfh3XLC7h8ljXeWuD6zusiCNwwxhqdziDInrOFac0+Xla8MpEvbwF0365Wwu3
23
+KAxBVdiUGQDDCX/CTQOer10jkdMdMetUi69BBXHoRAoSPGxDYkb28nA8lVleNQ0B
24
+JajO+wKBgHjruWioy39+GyLUEJXMIVxHnfhXDnfrHJ9z5WZjHlXmwwojW5kMvSbc
25
+p28vBa3BenBCLYHoYwzPcpdpLVTkVUQYqjdVrC4GaQXRHD+Qhx+vjbgTlljoTqcs
26
+y5wxu0OQH/UPBRUTs83L43ALGOhRrQBE+wwm2FTJERR/Npro4iu/
27
+-----END RSA PRIVATE KEY-----

+ 9 - 0
src/test/resources/5upay/899104033_public

@@ -0,0 +1,9 @@
1
+-----BEGIN PUBLIC KEY-----
2
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3NyGUN90VGKfLkWw3ORO
3
+tE0wy94R5kHJkl6hw1WZRcMwkJi1wzWzEpxAMMqQWFHr/uQQPSbBJQRxqKdEbUbQ
4
+M4PcEckAk6yXuLTJVJOml2WY9SjaRRoAPveiwYpAsIuNPE/fx1Z7sushvYJiawR3
5
+sr914zs9gsY9BBF75ZTM6Uqq+j+WmSfrNQ9rA5GTx4LRDURr3H6Mrb5/rpLV2HqM
6
+kWwN1d+dZZjNWpMi+fTaHp28HbK2kCqWylrNM7quY5XdtRRjozB7Iq4Q07DG9A37
7
+a0BrOWArRkG1z9TWGHEFCbvstUZBL2kPXrhBFYzDxPVZI4cD9elc8mGjYlfek8UG
8
+UQIDAQAB
9
+-----END PUBLIC KEY-----

BIN
src/test/resources/5upay/private.pfx


+ 25 - 0
src/test/resources/5upay/public.cer

@@ -0,0 +1,25 @@
1
+-----BEGIN CERTIFICATE-----
2
+MIIEMDCCAxigAwIBAgIFEzOAQJQwDQYJKoZIhvcNAQEFBQAwITELMAkGA1UEBhMC
3
+Q04xEjAQBgNVBAoTCUNGQ0EgT0NBMTAeFw0yMTA1MTcwODE1MzlaFw0yMjA1MTcw
4
+ODE1MzlaMIGbMQswCQYDVQQGEwJDTjESMBAGA1UEChMJQ0ZDQSBPQ0ExMRAwDgYD
5
+VQQLEwdQYXlFYXNlMRkwFwYDVQQLExBPcmdhbml6YXRpb25hbC0xMUswSQYDVQQD
6
+DEJQYXlFYXNlQOWMl+S6rOWkqeWcsOWNmueIseenkeaKgOaciemZkOWFrOWPuEBO
7
+OTExMTAxMDU2OTc3MjQ2NDlFQDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
8
+AoIBAQDcxcsGYd2u8bIa3ZKBSBYZ7vcJdbBtSsUmpdZo7xBcSorGDj90NENcw0UH
9
+LvYA2KwrW6l67rajUslXVOVaQRl+7T7ZfgzgH8vLYtc/oF9Ecu2tcaLFq9K19iet
10
+OgC27O61N1KuffaLhXYm3nzbSlvmCATWr2RNbnjsJeTJqT/AARi1BfL3sHerck3O
11
+11cdaRe36vYau2I9hZu1OO3MwgdwrW6SMKtJ/V7RXNieShKSaUSxmolml11wqA+8
12
+KQNfu74ahXA07q7ExOEng8XUv3/hu/xQS7azgAl7x1Y6H8ycpNN10v5Mdzhe7xN+
13
+dJ6YU1yXRFhdPd8GRqqt9/9v7L6VAgMBAAGjgfMwgfAwHwYDVR0jBBgwFoAU0dvp
14
+iILl3RqPTKoAjL588qsb9tkwSAYDVR0gBEEwPzA9BghggRyG7yoBATAxMC8GCCsG
15
+AQUFBwIBFiNodHRwOi8vd3d3LmNmY2EuY29tLmNuL3VzL3VzLTE0Lmh0bTA4BgNV
16
+HR8EMTAvMC2gK6AphidodHRwOi8vY3JsLmNmY2EuY29tLmNuL1JTQS9jcmwyNzY1
17
+MC5jcmwwCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBQuknKT5x64cobA7/JU7Rv85Wdt
18
+zjAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwDQYJKoZIhvcNAQEFBQAD
19
+ggEBAE7XX+Q4918o3OCMLjTvP3bznGxcUtBJLBT2UEQ7m4I7Nkqy0tANoWk+rjvM
20
+d8a3UZS0iQq7wCj3dkyQPbHrUAC5HeEgRJM61r/YN2NJVyaFrwhSHi/kYp7MKyHe
21
+mr5Tj5uYFgHErbq2J2TWOkaDo+yR5fsbkXOmY3SS8oMqXE+4O9kP+D3fs239tuU4
22
+M0N38vekhkK9ZCSjhdV+wWc50Oc9a+KP2WINvbUZSMfcs517cO0AbofxMz8MfMGu
23
+1bDl2I+belRuRbxgY1E/fIZmpSJtf/927kRSd1vuixCxCc70nmob59sQkF52rDPO
24
+PwmXKYTw0DElx7Ngp4z8A6Jw62M=
25
+-----END CERTIFICATE-----

+ 25 - 0
src/test/resources/5upay/public.pem

@@ -0,0 +1,25 @@
1
+-----BEGIN CERTIFICATE-----
2
+MIIEMDCCAxigAwIBAgIFEzOAQJQwDQYJKoZIhvcNAQEFBQAwITELMAkGA1UEBhMC
3
+Q04xEjAQBgNVBAoTCUNGQ0EgT0NBMTAeFw0yMTA1MTcwODE1MzlaFw0yMjA1MTcw
4
+ODE1MzlaMIGbMQswCQYDVQQGEwJDTjESMBAGA1UEChMJQ0ZDQSBPQ0ExMRAwDgYD
5
+VQQLEwdQYXlFYXNlMRkwFwYDVQQLExBPcmdhbml6YXRpb25hbC0xMUswSQYDVQQD
6
+DEJQYXlFYXNlQOWMl+S6rOWkqeWcsOWNmueIseenkeaKgOaciemZkOWFrOWPuEBO
7
+OTExMTAxMDU2OTc3MjQ2NDlFQDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
8
+AoIBAQDcxcsGYd2u8bIa3ZKBSBYZ7vcJdbBtSsUmpdZo7xBcSorGDj90NENcw0UH
9
+LvYA2KwrW6l67rajUslXVOVaQRl+7T7ZfgzgH8vLYtc/oF9Ecu2tcaLFq9K19iet
10
+OgC27O61N1KuffaLhXYm3nzbSlvmCATWr2RNbnjsJeTJqT/AARi1BfL3sHerck3O
11
+11cdaRe36vYau2I9hZu1OO3MwgdwrW6SMKtJ/V7RXNieShKSaUSxmolml11wqA+8
12
+KQNfu74ahXA07q7ExOEng8XUv3/hu/xQS7azgAl7x1Y6H8ycpNN10v5Mdzhe7xN+
13
+dJ6YU1yXRFhdPd8GRqqt9/9v7L6VAgMBAAGjgfMwgfAwHwYDVR0jBBgwFoAU0dvp
14
+iILl3RqPTKoAjL588qsb9tkwSAYDVR0gBEEwPzA9BghggRyG7yoBATAxMC8GCCsG
15
+AQUFBwIBFiNodHRwOi8vd3d3LmNmY2EuY29tLmNuL3VzL3VzLTE0Lmh0bTA4BgNV
16
+HR8EMTAvMC2gK6AphidodHRwOi8vY3JsLmNmY2EuY29tLmNuL1JTQS9jcmwyNzY1
17
+MC5jcmwwCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBQuknKT5x64cobA7/JU7Rv85Wdt
18
+zjAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwDQYJKoZIhvcNAQEFBQAD
19
+ggEBAE7XX+Q4918o3OCMLjTvP3bznGxcUtBJLBT2UEQ7m4I7Nkqy0tANoWk+rjvM
20
+d8a3UZS0iQq7wCj3dkyQPbHrUAC5HeEgRJM61r/YN2NJVyaFrwhSHi/kYp7MKyHe
21
+mr5Tj5uYFgHErbq2J2TWOkaDo+yR5fsbkXOmY3SS8oMqXE+4O9kP+D3fs239tuU4
22
+M0N38vekhkK9ZCSjhdV+wWc50Oc9a+KP2WINvbUZSMfcs517cO0AbofxMz8MfMGu
23
+1bDl2I+belRuRbxgY1E/fIZmpSJtf/927kRSd1vuixCxCc70nmob59sQkF52rDPO
24
+PwmXKYTw0DElx7Ngp4z8A6Jw62M=
25
+-----END CERTIFICATE-----

BIN
src/test/resources/5upay/public_der.cer


BIN
src/test/resources/5upay/test.cer