TRX 1 ano atrás
commit
7657d7b780

+ 16 - 0
.gitignore

@@ -0,0 +1,16 @@
+# IDE specific files
+/.idea/
+*.iml
+*.log
+*.gz
+
+# log
+/logs/
+
+# Compiler generated files
+target/
+
+
+# jrebel
+rebel.xml
+

+ 73 - 0
PaymentClient/pom.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.github.microservice</groupId>
+		<artifactId>MSModule</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+		<relativePath>../../../super/MSModule</relativePath>
+	</parent>
+
+	<groupId>com.github.microservice.payment</groupId>
+	<artifactId>PaymentClient</artifactId>
+	<name>PaymentClient</name>
+	<properties>
+		<java.version>17</java.version>
+	</properties>
+	<dependencies>
+
+		<dependency>
+			<groupId>com.github.microservice</groupId>
+			<artifactId>PCore</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<!--应用中心客户端-->
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>ApplicationClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<!-- 文档 -->
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>Swagger2</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>5.8.20</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.wechatpay-apiv3</groupId>
+			<artifactId>wechatpay-java</artifactId>
+			<version>0.2.12</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.microservice.auth</groupId>
+			<artifactId>AuthClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>cn.afterturn</groupId>
+			<artifactId>easypoi-base</artifactId>
+			<version>4.1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.zswl</groupId>
+			<artifactId>ConfigModel</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+	</dependencies>
+
+</project>

+ 12 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/config/PaymentClientConfiguration.java

@@ -0,0 +1,12 @@
+package com.zhongshu.payment.client.config;
+
+
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableFeignClients("com.zhongshu.card.client.service")
+@ComponentScan({"com.zhongshu.card.client"})
+public class PaymentClientConfiguration {
+}

+ 8 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/config/PaymentServerConfiguration.java

@@ -0,0 +1,8 @@
+package com.zhongshu.payment.client.config;
+
+
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class PaymentServerConfiguration {
+}

+ 19 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/types/DataState.java

@@ -0,0 +1,19 @@
+package com.zhongshu.payment.client.types;
+
+import lombok.Getter;
+
+/**
+ *
+ */
+public enum DataState {
+    Enable("启用"),
+    Disable("已停用"),
+    ;
+
+    @Getter
+    private String remark;
+
+    DataState(String remark) {
+        this.remark = remark;
+    }
+}

+ 145 - 0
PaymentServer/pom.xml

@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.github.microservice</groupId>
+        <artifactId>MSRunnable</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath>../../../super/MSRunnable</relativePath>
+    </parent>
+
+    <groupId>com.github.microservice.payment</groupId>
+    <artifactId>PaymentServer</artifactId>
+    <name>PaymentServer</name>
+    <properties>
+        <java.version>17</java.version>
+    </properties>
+    <dependencies>
+
+        <dependency>
+            <groupId>com.github.microservice</groupId>
+            <artifactId>PCore</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!--应用中心客户端-->
+        <dependency>
+            <groupId>com.github.microservice.components</groupId>
+            <artifactId>ApplicationClient</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!--    全卡业务    -->
+        <dependency>
+            <groupId>com.github.microservice.card</groupId>
+            <artifactId>FullCardClient</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!--   支付中心     -->
+        <dependency>
+            <groupId>com.github.microservice.payment</groupId>
+            <artifactId>PaymentClient</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.microservice.components</groupId>
+            <artifactId>RedisData</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.microservice.components</groupId>
+            <artifactId>MongodbData</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!--		<dependency>-->
+        <!--			<groupId>com.github.microservice.auth</groupId>-->
+        <!--			<artifactId>AuthClient</artifactId>-->
+        <!--			<version>${project.version}</version>-->
+        <!--		</dependency>-->
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>${lombok.version}</version>
+        </dependency>
+
+        <!--二维码-->
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.4.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>3.4.1</version>
+        </dependency>
+
+        <!--	拼音 	-->
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+
+        <!--    excel导出    -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>4.1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>4.1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-base</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+
+        <!--阿里云 oss-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>4.6.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-sts</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.14.0</version>
+        </dependency>
+
+
+        <!--	artemis 	-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-artemis</artifactId>
+            <version>3.2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.zswl</groupId>
+            <artifactId>ConfigModel</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+
+    </dependencies>
+</project>

+ 20 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/PaymentServerApplication.java

@@ -0,0 +1,20 @@
+package com.zhongshu.payment.server.core;
+
+import com.github.microservice.app.annotation.EnableApplicationClient;
+import com.github.microservice.core.boot.ApplicationBootSuper;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+
+
+@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
+@EnableApplicationClient
+@ComponentScan("com.zhongshu.payment.server.core")
+public class PaymentServerApplication extends ApplicationBootSuper {
+
+    public static void main(String[] args) {
+        SpringApplication.run(PaymentServerApplication.class, args);
+    }
+
+}

+ 11 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/config/AuthServerConfig.java

@@ -0,0 +1,11 @@
+package com.zhongshu.payment.server.core.config;
+
+import com.github.microservice.auth.config.AuthClientConfiguration;
+import com.github.microservice.auth.config.AuthServerConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Configuration
+@Import(AuthClientConfiguration.class)
+public class AuthServerConfig {
+}

+ 10 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/config/MVCConfig.java

@@ -0,0 +1,10 @@
+package com.zhongshu.payment.server.core.config;
+
+import com.github.microservice.core.mvc.MVCConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Configuration
+@Import(MVCConfiguration.class)
+public class MVCConfig {
+}

+ 15 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/config/MongoConfig.java

@@ -0,0 +1,15 @@
+package com.zhongshu.payment.server.core.config;
+
+import com.github.microservice.components.data.mongo.mongo.config.MongoConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+
+@Configuration
+@Import(MongoConfiguration.class)
+@EnableMongoRepositories(
+        value = "com.zhongshu.payment.server.core.dao"
+)
+public class MongoConfig {
+
+}

+ 16 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/config/SwaggerConfig.java

@@ -0,0 +1,16 @@
+package com.zhongshu.payment.server.core.config;
+
+import com.github.microservice.components.swagger.config.SwaggerConfiguration;
+import io.swagger.v3.oas.models.Operation;
+import org.springdoc.core.customizers.OperationCustomizer;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.web.method.HandlerMethod;
+
+@Configuration
+@Import(SwaggerConfiguration.class)
+public class SwaggerConfig  {
+
+}

+ 34 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/base/SuperMain.java

@@ -0,0 +1,34 @@
+package com.zhongshu.payment.server.core.domain.base;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author TRX
+ * @date 2024/5/30
+ */
+@Data
+public class SuperMain extends SuperEntity {
+
+    @Schema(description = "排序")
+    private Long sort = 1l;
+
+    @Schema(description = "备注")
+    private String remark;
+
+    @Schema(description = "是否删除")
+    private Boolean isDelete = Boolean.FALSE;
+
+    @Schema(description = "所属机构ID")
+    private String oid;
+
+    @Schema(description = "创建用户ID")
+    private String createUserId;
+
+    @Schema(description = "添加用户名称")
+    private String createUserName;
+
+    @Schema(description = "添加用户电话", hidden = true)
+    private String createPhone;
+}

+ 36 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/wallet/Wallet.java

@@ -0,0 +1,36 @@
+package com.zhongshu.payment.server.core.domain.wallet;
+
+import com.zhongshu.payment.client.types.DataState;
+import com.zhongshu.payment.server.core.domain.base.SuperMain;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 个人钱包
+ *
+ * @author TRX
+ * @date 2024/6/28
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class Wallet extends SuperMain {
+
+    @Schema(description = "用户userId")
+    private String userId;
+
+    @Schema(description = "可用金额,单位:分")
+    private BigDecimal amount = BigDecimal.ZERO;
+
+    @Schema(description = "钱包状态:是否可用")
+    private DataState dataState = DataState.Enable;
+
+}

+ 90 - 0
PaymentServer/src/main/resources/application-dev.yml

@@ -0,0 +1,90 @@
+spring:
+  cloud:
+    inetutils:
+      preferred-networks:
+        - 192.168
+    consul:
+      discovery:
+        hostname: 172.24.50.53
+        prefer-ip-address: false
+  jms:
+    pub-sub-domain: true
+  artemis:
+    mode: native  # cluster native EMBEDDED
+    broker-url: tcp://162.14.78.247:61616?connectionTimeout=6000
+    user: admin
+    password: admin123
+  data:
+    mongodb:
+      uri: mongodb://root:8756mongo2024@172.24.50.53:27017,172.24.50.53:27018,172.24.50.53:27019/payment?authSource=admin
+      auto-index-creation: true
+    redis:
+      host: 172.24.50.53
+      port: 6379
+      password: 8756redis2024
+      database: 7
+      timeout: 5000
+      lettuce:
+        pool:
+          max-active: 32 # 最大连接
+          max-idle: 16   # 最大空闲连接
+          min-idle: 8   # 最小空闲连接
+          max-wait: 100ms # 连接等待时间
+
+# c端的小程序配置 (学生端)
+cwechat:
+  appid: wx3be1d6d84d46cdf7
+  secret: 4401df45d409cbf28560e87c4c21b4bf
+
+# 商户端的小程序配置
+swechat:
+  appid: wx3be1d6d84d46cdf7
+  secret: 4401df45d409cbf28560e87c4c21b4bf
+
+springdoc:
+  api-docs:
+    # 是否开启接口文档
+    enabled: true
+  swagger-ui:
+    # 持久化认证数据,如果设置为 true,它会保留授权数据并且不会在浏览器关闭/刷新时丢失
+    persistAuthorization: true
+
+oAuth:
+  clientId: test
+  clientSecret: 123456
+
+# 阿里云OSS
+oss:
+  maxCacheMinutes: 10
+  maxCacheCount: 100
+  _other:
+    host: https://oss.dev.zonelife.cn/
+  _type: ALiObjectStorage
+  endpoint: oss-cn-chengdu.aliyuncs.com
+  bucket: zswl-dev
+  accessKeyId: LTAI5tCvJccdHK17R4kYrLgy
+  accessKeySecret: Vbt3NiZfi6f47vU8QcfqQIsjiFo6vH
+  arn: acs:ram::1540890773231210:role/oss
+
+# 物联网平台的配置
+iotcenter:
+  url: http://172.24.50.53:9101
+  iotserverName: # 服务名称
+
+#logging:
+#  level:
+#    org:
+#      springframework:
+#        web: trace
+#debug: true
+#trace: true
+
+logging:
+  level:
+    com:
+      github:
+        microservice:
+          core:
+            runner: debug
+
+#    org.springframework.security: trace

+ 75 - 0
PaymentServer/src/main/resources/application-local.yml

@@ -0,0 +1,75 @@
+spring:
+  cloud:
+    inetutils:
+      preferred-networks:
+        - 192.168
+  data:
+    mongodb:
+      uri: mongodb://admin:admin123@192.168.0.104:37047,192.168.0.104:47037,192.168.0.104:37027/payment?replicaSet=rs
+#      uri: mongodb://root:8756mongo2024@172.24.50.53:27017,172.24.50.53:27018,172.24.50.53:27019/fullcard?authSource=admin
+      auto-index-creation: true
+    redis:
+      host: 127.0.0.1
+      port: 6378
+#      password: 8756redis2024
+      database: 7
+      timeout: 5000
+      lettuce:
+        pool:
+          max-active: 32 # 最大连接
+          max-idle: 16   # 最大空闲连接
+          min-idle: 8   # 最小空闲连接
+          max-wait: 100ms # 连接等待时间
+
+# c端的小程序配置 (学生端)
+cwechat:
+  appid: wx3be1d6d84d46cdf7
+  secret: 4401df45d409cbf28560e87c4c21b4bf
+
+# 商户端的小程序配置
+swechat:
+  appid: wx3be1d6d84d46cdf7
+  secret: 4401df45d409cbf28560e87c4c21b4bf
+
+springdoc:
+  api-docs:
+    # 是否开启接口文档
+    enabled: true
+  swagger-ui:
+    # 持久化认证数据,如果设置为 true,它会保留授权数据并且不会在浏览器关闭/刷新时丢失
+    persistAuthorization: true
+
+oAuth:
+  clientId: test
+  clientSecret: 123456
+
+# 阿里云OSS
+oss:
+  maxCacheMinutes: 10
+  maxCacheCount: 100
+  _other:
+    host: https://oss.dev.zonelife.cn/
+  _type: ALiObjectStorage
+  endpoint: oss-cn-chengdu.aliyuncs.com
+  bucket: zswl-dev
+  accessKeyId: LTAI5tCvJccdHK17R4kYrLgy
+  accessKeySecret: Vbt3NiZfi6f47vU8QcfqQIsjiFo6vH
+  arn: acs:ram::1540890773231210:role/oss
+
+#logging:
+#  level:
+#    org:
+#      springframework:
+#        web: trace
+#debug: true
+#trace: true
+
+logging:
+  level:
+    com:
+      github:
+        microservice:
+          core:
+            runner: debug
+
+#    org.springframework.security: trace

+ 63 - 0
PaymentServer/src/main/resources/application.yml

@@ -0,0 +1,63 @@
+#Web服务器端口
+# 服务器上的端口是 9400 本地启动的端口是 9401
+server:
+  port: 9401
+
+debug: true
+
+spring:
+  cloud:
+    consul:
+      discovery:
+        prefer-ip-address: true # ip自动注册
+        hostname: localhost    # 配置实例地址
+        port: ${server.port}
+        health-check-path: /actuator/health  # 检测实例健康
+        health-check-interval: 10s   # 每隔10s检查
+        register: true  # 自动注册
+        service-name: ${spring.application.name} # 实例名称
+        instance-id: ${spring.application.name}:${server.port}
+      host: ${ApplicationCenter.url}
+      port: ${ApplicationCenter.port}
+
+
+    #kafka
+    stream:
+      kafka:
+        binder:
+          brokers: ${Kafka.brokers}
+          replication-factor: 1
+      bindings:
+        userLogStreamConsumer-in-0:
+          destination: UserLogStream
+          group: ${project.artifactId}
+    function: #注意:此处有调整
+      definition: userLogStreamConsumer
+
+    bus:
+      enabled: true
+  #配置zipkin链路追踪客户端
+  zipkin:
+    base-url: ${Zipkin.baseUrl}
+    enabled: true
+    sender:
+      type: web
+  sleuth:
+    sampler:
+      probability: ${Zipkin.sampler.probability}
+
+  thymeleaf:
+    suffix: .html
+    mode: HTML
+    prefix: classpath:/templates/
+    cache: false
+    encoding: UTF-8
+
+
+
+
+
+#调试或者输出日志
+logging:
+  file:
+    name: logs/${project.artifactId}.log

+ 22 - 0
PaymentServer/src/main/resources/bootstrap.yml

@@ -0,0 +1,22 @@
+###需拷贝到每一个模块下
+
+spring:
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
+  main: #允许循环引用
+    allow-circular-references: true
+  # 应用名
+  application:
+    name: ${project.artifactId}-trx
+  # 当前读取配置文件的类型
+  profiles:
+    active: ${spring.profiles.active}
+  #配置中心
+  cloud:
+    config:
+      uri: ${ConfigCenter.url}
+      name: ${project.artifactId},ConfigCenter
+  autoconfigure:
+    exclude:
+      - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

+ 31 - 0
pom.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.github.microservice.center</groupId>
+    <artifactId>PaymentCenter</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <packaging>pom</packaging>
+    <name>${project.artifactId}</name>
+    <description>支付中心</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <modules>
+
+        <module>PaymentClient</module>
+        <module>PaymentServer</module>
+
+    </modules>
+
+
+</project>