Browse Source

所有接口进入测试服

mac 2 years ago
parent
commit
8b6f78e919
78 changed files with 1605 additions and 242 deletions
  1. 111 0
      .drone.yml
  2. 42 0
      docker-compose.yml
  3. 13 0
      install.txt
  4. 10 0
      kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/ServiceNameConstants.java
  5. 2 2
      kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/enums/BrandTypeEnum.java
  6. 3 1
      kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/enums/MachineTypeEnum.java
  7. 42 0
      kxs-common/kxs-common-seata/pom.xml
  8. 19 0
      kxs-common/kxs-common-seata/src/main/java/com/kxs/common/seata/config/SeataAutoConfiguration.java
  9. 45 0
      kxs-common/kxs-common-seata/src/main/java/com/kxs/common/seata/factory/YamlPropertySourceFactory.java
  10. 1 0
      kxs-common/kxs-common-seata/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  11. 57 0
      kxs-common/kxs-common-seata/src/main/resources/seata-config.yml
  12. 1 10
      kxs-common/pom.xml
  13. 76 0
      kxs-gateway/pom.xml
  14. 5 0
      kxs-product/kxs-product-api/pom.xml
  15. 11 4
      kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/feign/config/KxsProductFeignClientConfiguration.java
  16. 3 0
      kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsBrand.java
  17. 9 2
      kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsMachine.java
  18. 3 0
      kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsTicket.java
  19. 6 0
      kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/constant/enums/MerchantEnum.java
  20. 1 2
      kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/constant/enums/ProductErrorTypeEnum.java
  21. 9 17
      kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/controller/kxsapp/MachineController.java
  22. 3 3
      kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsMachineServiceImpl.java
  23. 2 0
      kxs-product/kxs-product-biz/src/main/resources/mapper/KxsMachineMapper.xml
  24. 1 1
      kxs-product/kxs-product-biz/src/main/resources/mapper/KxsTicketMapper.xml
  25. 15 0
      kxs-store/kxs-store-api/pom.xml
  26. 4 3
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeAdvance/StoreAdvanceAddAdvanceDTO.java
  27. 4 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeRecycle/RecycleConfirmDTO.java
  28. 25 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeRecycle/UserReturnRecycleDTO.java
  29. 28 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/feign/RemoteKxsStoreService.java
  30. 85 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/feign/config/KxsStoreFeignClientConfiguration.java
  31. 6 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineApply.java
  32. 2 18
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineRecycle.java
  33. 2 4
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineRecycleInfo.java
  34. 0 7
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeAdvance/UserWarehouseListVO.java
  35. 2 1
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeRecycle/NeedConfirmRecycleVO.java
  36. 1 15
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeRecycle/StoreRecycleMachineListVO.java
  37. 0 1
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userAdvance/AdvanceDevModalVO.java
  38. 141 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userOrder/UserApplyMachineDetailVO.java
  39. 76 0
      kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userOrder/UserApplyMahineListVO.java
  40. 1 0
      kxs-store/kxs-store-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  41. 20 0
      kxs-store/kxs-store-biz/pom.xml
  42. 24 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/KxsStoreApplication.java
  43. 1 6
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/MachineOrderEnum.java
  44. 26 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/MachineOrderStatusEnum.java
  45. 2 1
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/RecycleOrderEnum.java
  46. 1 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/StoreErrorTypeEnum.java
  47. 2 1
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreAdvanceController.java
  48. 3 16
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreOrderController.java
  49. 17 2
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreRecycleController.java
  50. 15 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/UserAdvanceController.java
  51. 72 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/UserOrderController.java
  52. 10 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/mapper/KxsMachineApplyMapper.java
  53. 7 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/mapper/KxsMachineRecycleMapper.java
  54. 18 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsMachineApplyService.java
  55. 10 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsMachineRecycleService.java
  56. 8 0
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsWarehouseLimitService.java
  57. 3 1
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsForAmountWithdrawServiceImpl.java
  58. 48 8
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineAdvanceServiceImpl.java
  59. 98 30
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineApplyServiceImpl.java
  60. 73 47
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineRecycleServiceImpl.java
  61. 20 11
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseLimitServiceImpl.java
  62. 7 1
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseMachineApplyServiceImpl.java
  63. 5 5
      kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseServiceImpl.java
  64. 9 5
      kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineAdvanceMapper.xml
  65. 10 2
      kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineApplyMapper.xml
  66. 24 11
      kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineRecycleMapper.xml
  67. 3 3
      kxs-store/kxs-store-biz/src/main/resources/mapper/KxsWarehouseMapper.xml
  68. 5 0
      kxs-system/kxs-system-api/pom.xml
  69. 7 0
      kxs-system/kxs-system-api/src/main/java/com/kxs/system/api/feign/config/KxsSystemFeignClientConfiguration.java
  70. 76 0
      kxs-system/kxs-system-biz/pom.xml
  71. 5 1
      kxs-user/kxs-user-api/pom.xml
  72. 7 0
      kxs-user/kxs-user-api/src/main/java/com/kxs/user/api/feign/config/KxsUserFeignClientConfiguration.java
  73. 4 0
      kxs-user/kxs-user-biz/pom.xml
  74. 1 0
      kxs-user/kxs-user-biz/src/main/java/com/kxs/user/biz/constant/enums/UserErrorTypeEnum.java
  75. 17 0
      kxs-user/kxs-user-biz/src/main/java/com/kxs/user/biz/service/impl/KxsUserServiceImpl.java
  76. 57 0
      kxs-visual/kxs-seataServer/resources/application.yml
  77. 17 0
      kxs-visual/pom.xml
  78. 6 0
      pom.xml

+ 111 - 0
.drone.yml

@@ -0,0 +1,111 @@
+kind: pipeline
+type: docker
+name: build
+
+volumes: # 声明数据卷
+  - name: mvn_repo # 数据卷名称
+    # Host Volume, 挂载到宿主机上的卷轴
+    host:
+      # 宿主机的绝对路径
+      path: /home/gite/drone/cache/mvn_repo
+  - name: uploadDir
+    host:
+      path: /home/ABServer/webroot/kxs-gateway/
+
+clone:
+  disable: false # 启用代码拉取
+
+steps:
+  - name: build-project
+    image: alibabadragonwell/dragonwell:17-anolis
+    pull: always
+    depends_on: [clone] # 依赖的步骤
+    volumes: # 挂载数据卷
+      - name: mvn_repo # 数据卷名称
+        path: /drone/src/node_modules # 容器内目录 绝对路径
+      - name: targetDir
+        path: /drone/kxs-gateway/target
+    commands: # 执行命令
+      - pwd # 查看当前目录
+      - mvn dependency:resolve
+      - mvn clean package -Dmaven.test.skip=true -P test
+
+      - pwd targetDir # 查看当前目录
+      # - cp -a ./package.json /nodeServer1 && cp -a ./bootstrap.js /nodeServer1
+      # - cp -a ./node_modules /nodeServer1
+      # - cp -a dist/* fwdocs
+
+  # - name: build-image # 步骤名称
+  #   image: plugins/docker # 使用镜像
+  #   depends_on: [build-project] # 依赖步骤
+  #   settings: # 当前设置
+  #     username: # 账号名称
+  #       from_secret: docker_username
+  #     password: # 账号密码
+  #       from_secret: docker_password
+  #     dockerfile: deploy/Dockerfile # Dockerfile地址, 注意是相对地址
+  #     repo: yxs970707/deploy-web-demo # 镜像名称
+
+trigger:
+  branch:
+    include:
+      - master
+  event:
+    include:
+      - push
+
+# ---
+
+# kind: pipeline
+# type: docker
+# name: deploy
+
+# depends_on: # 依赖build管道
+#   - build
+
+# clone:
+#   disable: true # 禁用拉取
+
+# steps:
+#   # - name: scp-project
+#   #   image: appleboy/drone-scp
+#   #   settings:
+#   #     host: 47.109.40.208
+#   #     username: root
+#   #     password: Ym*87540628
+#   #     port: 22
+#   #     command_timeout: 2m
+#   #     target: /home/deploy/web
+#   #     source:
+#   #       - release/*.tar.gz
+
+#   - name: deploy-project
+#     image: appleboy/drone-ssh
+#     settings:
+#       host: 47.109.40.208
+#         # from_secret: server_host
+#       user: root
+#         # from_secret: server_username
+#       password: Ym*87540628
+#         # from_secret: server_password
+#       port: 22
+#       command_timeout: 2m
+#       script:
+#         - echo ====开始部署=======
+#         - cd /home/ABServer
+#         # - cp -a /home/ABServer/drone/dist/midwayjs/* /home/ABServer/webroot/nodeServer1
+#         # - if [[ "$(docker ps -q nodeServer1 2> /dev/null)" != "" ]];
+#         #     then
+#         #       xxx
+#         - docker restart nodeServer1
+#         # - docker restart nodeServer1
+#         - echo ====部署成功=======
+
+
+# trigger:
+#   branch:
+#     include:
+#       - master
+#   event:
+#     include:
+#       - push

+ 42 - 0
docker-compose.yml

@@ -121,6 +121,48 @@ services:
     networks:
       - kxs_cloud_network
 
+#  kxs-mongo:
+#    image: mongo:6.0.3
+#    ports:
+#      - 27017:27017
+#    restart: always
+#    container_name: kxs-mongo
+#    hostname: kxs-mongo
+#    environment:
+#      TZ: Asia/Shanghai
+#      MONGO_INITDB_ROOT_USERNAME: root
+#      MONGO_INITDB_ROOT_PASSWORD: root
+#    command: mongod --auth
+#    volumes:
+#      # 数据目录  挂载出来后,即使删除容器,再用该挂载数据与docker-compose.yml文件启动容器,即可恢复到原来的数据以及用户信息
+#      - ./data/mongodb/db:/data/db
+#      - ./data/mongodb/log:/var/log/mongodb
+#      - ./data/mongodb/config:/etc/mongo
+#    networks:
+#      - kxs_cloud_network
+
+  kxs-seata:
+    restart: always
+    container_name: kxs-seata
+    image: seataio/seata-server:1.8.0
+    ports:
+      - "7091:7091"
+      - "8091:8091"
+    environment:
+      TZ: Asia/Shanghai
+      LANG: en_US.UTF-8
+      STORE_MODE: db
+      # 以SEATA_IP作为host注册seata server
+      SEATA_IP: kxs-seata
+      SEATA_PORT: 8091
+    volumes:
+      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"        #设置系统时区
+      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"  #设置时区
+      - "./kxs-visual/kxs-seataServer/resources/application.yml:/seata-server/resources/application.yml"
+    networks:
+      - kxs_cloud_network
+
+
 networks:
   kxs_cloud_network:
     name: kxs_cloud_network

+ 13 - 0
install.txt

@@ -0,0 +1,13 @@
+
+打包命令 进入项目根目录
+mvn clean package -Dmaven.test.skip=true -P test
+
+
+
+启动命令
+ java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/jdk17/errorDump.hprof -Xms4g -Xmx4g -Dloader.path=lib,config -Dspring.profiles.active=prod  -jar app.jar
+参数解释:
+1): spring.profiles.active=test  代表测试环境
+2): spring.profiles.active=prod  代表正式环境
+3): -Xms4g -Xmx4g 根据运行服务器的内存大小调整,一般不超过机器最大内存的80%
+4): -XX:HeapDumpPath=/opt/jdk17/errorDump.hprof 指定内存溢出oom错误日志存放路径,方便线上排查问题

+ 10 - 0
kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/ServiceNameConstants.java

@@ -23,4 +23,14 @@ public interface ServiceNameConstants {
 	 */
 	String USER_SERVICE = "kxs-user-biz";
 
+	/**
+	 * 产品模块
+	 */
+	String PRODUCT_SERVICE = "kxs-product-biz";
+
+	/**
+	 * 仓库模块
+	 */
+	String STORE_SERVICE = "kxs-store-biz";
+
 }

+ 2 - 2
kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/enums/BrandTypeEnum.java

@@ -17,8 +17,8 @@ public enum BrandTypeEnum {
     /**
      * 产品类型
      */
-    DQ_PRICE(200, "电签价格"),
-    DJ_PRICE(300, "大机价格"),
+    DQ_PRICE(200, "0"),
+    DJ_PRICE(300, "1"),
     DIANQIAN(0, "电签"),
     DAJI(1, "大POS");
 

+ 3 - 1
kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/constant/enums/MachineTypeEnum.java

@@ -20,7 +20,9 @@ public enum MachineTypeEnum {
     STATUS_OUT(1, "已出库"),
     STATUS_REFUND(2, "已退回"),
     STATUS_RECYCLE(3, "可回收"),
-    STATUS_RE_OVER(4, "已回收"),
+    STATUS_RE_ON(4, "回收中"),
+    STATUS_RE_OVER(5, "已回收"),
+    STATUS_ADVANCE(6, "已预发"),
     /**
      * 机具类型
      */

+ 42 - 0
kxs-common/kxs-common-seata/pom.xml

@@ -0,0 +1,42 @@
+<?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>
+    <parent>
+        <groupId>com.kxs</groupId>
+        <artifactId>kxs-common</artifactId>
+        <version>1.1.0</version>
+    </parent>
+
+    <artifactId>kxs-common-seata</artifactId>
+
+    <description>sky 分布式事务处理模块</description>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+
+    <dependencies>
+        <!--核心依赖-->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-core</artifactId>
+        </dependency>
+        <!-- seata-->
+        <dependency>
+            <groupId>io.seata</groupId>
+            <artifactId>seata-spring-boot-starter</artifactId>
+        </dependency>
+        <!--  seata kryo 序列化-->
+        <dependency>
+            <groupId>io.seata</groupId>
+            <artifactId>seata-serializer-kryo</artifactId>
+            <version>1.6.1</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 19 - 0
kxs-common/kxs-common-seata/src/main/java/com/kxs/common/seata/config/SeataAutoConfiguration.java

@@ -0,0 +1,19 @@
+package com.kxs.common.seata.config;
+
+import com.kxs.common.seata.factory.YamlPropertySourceFactory;
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata 配置类
+ *
+ * @author 没秃顶的码农
+ * @date 2024-01-15
+ */
+@PropertySource(value = "classpath:seata-config.yml", factory = YamlPropertySourceFactory.class)
+@EnableAutoDataSourceProxy(useJdkProxy = true)
+@Configuration(proxyBeanMethods = false)
+public class SeataAutoConfiguration {
+
+}

+ 45 - 0
kxs-common/kxs-common-seata/src/main/java/com/kxs/common/seata/factory/YamlPropertySourceFactory.java

@@ -0,0 +1,45 @@
+package com.kxs.common.seata.factory;
+
+import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
+import org.springframework.core.env.PropertiesPropertySource;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.io.support.EncodedResource;
+import org.springframework.core.io.support.PropertySourceFactory;
+import org.springframework.lang.Nullable;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * @author lengleng
+ * @date 2022/3/29
+ *
+ * 读取自定义 yaml 文件工厂类
+ */
+public class YamlPropertySourceFactory implements PropertySourceFactory {
+
+	@Override
+	public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
+		Properties propertiesFromYaml = loadYamlIntoProperties(resource);
+		String sourceName = name != null ? name : resource.getResource().getFilename();
+		return new PropertiesPropertySource(sourceName, propertiesFromYaml);
+	}
+
+	private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {
+		try {
+			YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
+			factory.setResources(resource.getResource());
+			factory.afterPropertiesSet();
+			return factory.getObject();
+		}
+		catch (IllegalStateException e) {
+			Throwable cause = e.getCause();
+			if (cause instanceof FileNotFoundException) {
+				throw (FileNotFoundException) e.getCause();
+			}
+			throw e;
+		}
+	}
+
+}

+ 1 - 0
kxs-common/kxs-common-seata/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+ com.kxs.common.seata.config.SeataAutoConfiguration

+ 57 - 0
kxs-common/kxs-common-seata/src/main/resources/seata-config.yml

@@ -0,0 +1,57 @@
+seata:
+  enabled: true
+  tx-service-group: kxs_tx_group # 事务群组(可以每个应用独立取名,也可以使用相同的名字)
+  client:
+    rm-report-success-enable: true
+    rm-table-meta-check-enable: false # 自动刷新缓存中的表结构(默认false)
+    rm-report-retry-count: 5 # 一阶段结果上报TC重试次数(默认5)
+    rm-async-commit-buffer-limit: 10000 # 异步提交缓存队列长度(默认10000)
+    rm:
+      lock:
+        lock-retry-internal: 10 # 校验或占用全局锁重试间隔(默认10ms)
+        lock-retry-times: 30 # 校验或占用全局锁重试次数(默认30)
+        lock-retry-policy-branch-rollback-on-conflict: true # 分支事务与其它全局回滚事务冲突时锁策略(优先释放本地锁让回滚成功)
+    tm-commit-retry-count: 3 # 一阶段全局提交结果上报TC重试次数(默认1次,建议大于1)
+    tm-rollback-retry-count: 3 # 一阶段全局回滚结果上报TC重试次数(默认1次,建议大于1)
+    undo:
+      data-validation: true # 二阶段回滚镜像校验(默认true开启)
+#      log-serialization: kryo # undo序列化方式(默认jackson 不支持 LocalDateTime)
+      log-serialization: jackson # undo序列化方式(默认jackson 不支持 LocalDateTime)
+      log-table: undo_log  # 自定义undo表名(默认undo_log)
+    log:
+      exceptionRate: 100 # 日志异常输出概率(默认100)
+    support:
+      spring:
+        datasource-autoproxy: true
+  service:
+    vgroup-mapping:
+      kxs_tx_group: default # TC 集群(必须与seata-server保持一致)
+    enable-degrade: false # 降级开关
+    disable-global-transaction: false # 禁用全局事务(默认false)
+    grouplist:
+      default: kxs-seata:8091
+  transport:
+    shutdown:
+      wait: 3
+    thread-factory:
+      boss-thread-prefix: NettyBoss
+      worker-thread-prefix: NettyServerNIOWorker
+      server-executor-thread-prefix: NettyServerBizHandler
+      share-boss-worker: false
+      client-selector-thread-prefix: NettyClientSelector
+      client-selector-thread-size: 1
+      client-worker-thread-prefix: NettyClientWorkerThread
+    type: TCP
+    server: NIO
+    heartbeat: true
+    serialization: seata
+    compressor: none
+    enable-client-batch-send-request: true # 客户端事务消息请求是否批量合并发送(默认true)
+  registry:
+    file:
+      name: file.conf
+    type: file
+  config:
+    file:
+      name: file.conf
+    type: file

+ 1 - 10
kxs-common/pom.xml

@@ -22,15 +22,6 @@
         <module>kxs-common-log</module>
         <module>kxs-common-mybatis</module>
         <module>kxs-common-swagger</module>
+        <module>kxs-common-seata</module>
     </modules>
-    <dependencyManagement>
-        <dependencies>
-            <!--sky 公共版本定义-->
-            <dependency>
-                <groupId>com.kxs</groupId>
-                <artifactId>kxs-common-core</artifactId>
-                <version>${kxs.common.version}</version>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
 </project>

+ 76 - 0
kxs-gateway/pom.xml

@@ -87,9 +87,85 @@
 
     <build>
         <plugins>
+            <!--该插件的作用是打包spring-boot的jar包-->
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!--不排除的话,systemScope的依赖包会自动被此插件打包进xxx.jar\BOOT-INF\lib,和外部依赖产生冲突 -->
+                    <includeSystemScope>false</includeSystemScope>
+                    <skip>false</skip>
+                    <!--分离Jar包-->
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制依赖的jar包到指定的文件夹里 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib/</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制指定的文件 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <!-- 复制配置文件 -->
+                    <execution>
+                        <id>copy-resources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <resources>
+                                <!--复制资源文件到外部,注意这里先不做filtering处理,防止某些静态文件损坏-->
+                                <resource>
+                                    <filtering>false</filtering>
+                                    <directory>src/main/resources</directory>
+                                    <includes>
+                                        <include>**/*</include>
+                                    </includes>
+                                </resource>
+                                <!--仅针对配置文件filtering处理(占位符@@等)-->
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                    <includes>
+                                        <include>*.xml</include>
+                                        <include>*.yml</include>
+                                        <include>*.properties</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                            <outputDirectory>${project.build.directory}/config</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>

+ 5 - 0
kxs-product/kxs-product-api/pom.xml

@@ -45,5 +45,10 @@
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
         </dependency>
+        <!-- seata -->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-seata</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 11 - 4
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/feign/config/KxsProductFeignClientConfiguration.java

@@ -3,6 +3,7 @@ package com.kxs.product.api.feign.config;
 import cn.hutool.core.text.CharSequenceUtil;
 import com.kxs.common.core.constant.ServiceNameConstants;
 import com.kxs.product.api.feign.RemoteKxsProductService;
+import io.seata.core.context.RootContext;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -36,7 +37,7 @@ public class KxsProductFeignClientConfiguration {
 	 */
 	private final ReactorLoadBalancerExchangeFilterFunction reactorLoadBalancerExchangeFilterFunction;
 
-	private static final String SERVICE_NAME = ServiceNameConstants.CLIENT_NAME + ServiceNameConstants.USER_SERVICE;
+	private static final String SERVICE_NAME = ServiceNameConstants.CLIENT_NAME + ServiceNameConstants.PRODUCT_SERVICE;
 
 	@Bean("kxsProductFeignClient")
 	public WebClient oauthRequestInterceptor() {
@@ -46,6 +47,12 @@ public class KxsProductFeignClientConfiguration {
 			.filter((request, next) -> {
 				ClientRequest.Builder filtered = ClientRequest.from(request);
 
+				// seata XID传递
+				String xid = RootContext.getXID();
+				if (CharSequenceUtil.isNotBlank(xid)) {
+					filtered.header(RootContext.KEY_XID, xid);
+				}
+
 				ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
 					.getRequestAttributes();
 				// 不是web请求不传递token
@@ -64,12 +71,12 @@ public class KxsProductFeignClientConfiguration {
 	}
 
 	/**
-	 * 远程日志服务
+	 * 远程产品模块服务
 	 * @param client 客户端
-	 * @return 远程日志服务
+	 * @return 远程产品模块服务
 	 */
 	@Bean
-	RemoteKxsProductService remoteKxsUserService(@Qualifier("kxsProductFeignClient") WebClient client) {
+	RemoteKxsProductService remoteKxsProductService(@Qualifier("kxsProductFeignClient") WebClient client) {
 		HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();
 		return factory.createClient(RemoteKxsProductService.class);
 	}

+ 3 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsBrand.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Builder;
 import lombok.Data;
@@ -43,6 +44,7 @@ public class KxsBrand extends Model<KxsBrand> implements Serializable {
      */
     @TableField(fill = FieldFill.INSERT)
     @Schema(description = "新增时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
 
@@ -51,6 +53,7 @@ public class KxsBrand extends Model<KxsBrand> implements Serializable {
      */
     @TableField(fill = FieldFill.UPDATE)
     @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 
 

+ 9 - 2
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsMachine.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -42,6 +43,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      */
     @TableField(fill = FieldFill.INSERT)
     @Schema(description = "新增时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
 
@@ -50,6 +52,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      */
     @TableField(fill = FieldFill.UPDATE)
     @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 
 
@@ -119,6 +122,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      * 循环结束时间
      */
     @Schema(description = "循环结束时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime recycleEndTime;
 
 
@@ -147,6 +151,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      * 绑定时间
      */
     @Schema(description = "绑定时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime bindTime;
 
 
@@ -154,6 +159,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      * 激活时间
      */
     @Schema(description = "激活时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime actTime;
 
 
@@ -161,6 +167,7 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
      * 出库时间
      */
     @Schema(description = "出库时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime deliveryTime;
 
 
@@ -193,9 +200,9 @@ public class KxsMachine extends Model<KxsMachine> implements Serializable {
 
 
     /**
-     * 状态 0在库 1出库 2已退回 3可回收
+     * 状态 0在库 1出库 2已退回 3可回收 4回收中 5已回收 6已预发
      */
-    @Schema(description = "状态 0在库 1出库 2已退回 3可回收")
+    @Schema(description = "状态 0在库 1出库 2已退回 3可回收 4回收中 5已回收 6已预发")
     private Integer status;
 
 

+ 3 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsTicket.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -42,6 +43,7 @@ public class KxsTicket extends Model<KxsTicket> implements Serializable {
      */
     @TableField(fill = FieldFill.INSERT)
     @Schema(description = "新增时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
 
@@ -50,6 +52,7 @@ public class KxsTicket extends Model<KxsTicket> implements Serializable {
      */
     @TableField(fill = FieldFill.UPDATE)
     @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 
 

+ 6 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/constant/enums/MerchantEnum.java

@@ -13,8 +13,14 @@ import lombok.Getter;
 @AllArgsConstructor
 public enum MerchantEnum {
 
+    /**
+     * 机具类型
+     */
     M_TYPE_SN(0, "兑换机"),
     M_TYPE_RE(1, "循环机"),
+    /**
+     * 商户状态
+     */
     NO_ACT(0, "未激活"),
     ACT(1, "已激活"),
     NO_BIND(0, "未绑定"),

+ 1 - 2
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/constant/enums/ProductErrorTypeEnum.java

@@ -23,8 +23,7 @@ public enum ProductErrorTypeEnum {
 	TICKET_NOT_FOUND(-1, "券码不存在"),
 	TICKET_NOT_USER(-1, "券码不属于该创客"),
 	MACHINE_NOT_USER(-1, "机具不属于该创客"),
-	MACHINE_TRANSFER_NO(-1, "循环机不可划拨"),
-	SYS_USER_UPDATE_PASSWORD_ERROR(-1, "用户原密码错误"), SYS_DICT_UPDATE_SYSTEM(-1, "系统内置字典不能修改");
+	MACHINE_TRANSFER_NO(-1, "循环机不可划拨");
 
 	private final int code;
 

+ 9 - 17
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/controller/kxsapp/MachineController.java

@@ -199,7 +199,7 @@ public class MachineController {
 
 
     /**
-     * 机具搜索
+     * 仓库机具搜索
      *
      * @param page 分页对象
      * @param param 查询实体
@@ -211,26 +211,11 @@ public class MachineController {
         return R.ok(kxsMachineService.searchStoreMachine(page, param));
     }
 
-
-
-    /**
-     * 通过sn查询信息
-     *
-     * @param sn sn
-     * @return 兑换券划拨详情
-     */
-    @Inner
-    @GetMapping("/loadTicketBySn")
-    public R loadTicketBySn(@RequestParam("sn") Integer sn) {
-
-        return R.ok(kxsMachineService.getOne(Wrappers.<KxsMachine>lambdaQuery().eq(KxsMachine::getPosSn, sn)));
-    }
-
     /**
      * 通过id查询信息
      *
      * @param id sn
-     * @return 兑换券划拨详情
+     * @return machine
      */
     @Inner
     @GetMapping("/loadMachineById")
@@ -280,5 +265,12 @@ public class MachineController {
         return R.ok(kxsMachineService.activateMachineMonthTotalDetail(page, param));
     }
 
+    @Inner
+    @GetMapping("/loadMachineBySn")
+    public R loadMachineBySn(@RequestParam("sn") String sn){
+
+        return R.ok(kxsMachineService.getOne(Wrappers.lambdaQuery(KxsMachine.class)
+                .eq(KxsMachine::getPosSn, sn)));
+    }
 }
 

+ 3 - 3
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsMachineServiceImpl.java

@@ -212,11 +212,11 @@ public class KxsMachineServiceImpl extends ServiceImpl<KxsMachineMapper, KxsMach
     @Override
     public IPage<StoreActMachineDayDetailVO> activateMachineMonthTotalDetail(Page<StoreActMachineDayDetailVO> page, StoreActMachineDayDetailDTO param) {
 
-        String month = param.getMonth();
+        String month = param.getMonth() + "-01";
         //根据月份获取本月开始时间和结束时间
-        LocalDate date = LocalDate.parse(month, DatePattern.NORM_MONTH_FORMATTER);
+        LocalDate date = LocalDate.parse(month, DatePattern.NORM_DATE_FORMATTER);
         LocalDateTime startTime = LocalDateTime.of(date, LocalTime.MIN);
-        LocalDateTime endTime = LocalDateTime.of(date.plusMonths(1), LocalTime.MAX);
+        LocalDateTime endTime = LocalDateTime.of(date.plusMonths(1), LocalTime.MIN);
 
         param.setStartDate(String.valueOf(startTime));
         param.setEndDate(String.valueOf(endTime));

+ 2 - 0
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsMachineMapper.xml

@@ -34,6 +34,8 @@
     <select id="machineStoreList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineStoreListVO">
         select create_time, pos_sn from kxs_machine
           <where>
+              and del_flag = 0
+              and status = 0
               <if test="query.warehouseId != null">
                   and warehouse_id = #{query.warehouseId}
               </if>

+ 1 - 1
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsTicketMapper.xml

@@ -32,7 +32,7 @@
 
     <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.ticket.TicketListVO">
         select id, ticket_code, ticket_type from kxs_ticket
-        where user_id = #{userId} and ticket_type = #{ticketType}
+        where user_id = #{userId} and status = 0 and ticket_type = #{ticketType}
     </select>
 
 </mapper>

+ 15 - 0
kxs-store/kxs-store-api/pom.xml

@@ -43,5 +43,20 @@
             <groupId>org.springdoc</groupId>
             <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
         </dependency>
+        <!-- LB 扩展 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
+        </dependency>
+        <!--caffeine 替换LB 默认缓存实现-->
+        <dependency>
+            <groupId>com.github.ben-manes.caffeine</groupId>
+            <artifactId>caffeine</artifactId>
+        </dependency>
+        <!-- seata -->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-seata</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 4 - 3
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeAdvance/StoreAdvanceAddAdvanceDTO.java

@@ -3,6 +3,7 @@ package com.kxs.store.api.dto.kxsapp.storeAdvance;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 import java.util.List;
@@ -21,15 +22,15 @@ public class StoreAdvanceAddAdvanceDTO {
      * 品牌ID
      */
     @Schema(description = "品牌ID")
-    @NotBlank(message = "品牌不能为空")
+    @NotNull(message = "品牌不能为空")
     private Integer brandId;
 
     /**
      * 发货仓库ID
      */
     @Schema(description = "发货仓库ID")
-    @NotBlank(message = "发货仓库不能为空")
-    private Integer sendWarehouseId;
+    @NotNull(message = "发货仓库不能为空")
+    private Integer warehouseId;
 
     /**
      * 用户编号

+ 4 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeRecycle/RecycleConfirmDTO.java

@@ -1,6 +1,8 @@
 package com.kxs.store.api.dto.kxsapp.storeRecycle;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 import java.util.List;
@@ -20,6 +22,7 @@ public class RecycleConfirmDTO {
      * 订单ID
      */
     @Schema(description = "订单ID")
+    @NotNull(message = "订单ID不能为空")
     private Integer id;
 
 
@@ -27,6 +30,7 @@ public class RecycleConfirmDTO {
      * 机具号
      */
     @Schema(description = "机具号")
+    @NotEmpty(message = "机具号不能为空")
     private List<String> snList;
 
 }

+ 25 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/dto/kxsapp/storeRecycle/UserReturnRecycleDTO.java

@@ -0,0 +1,25 @@
+package com.kxs.store.api.dto.kxsapp.storeRecycle;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 撤回回收 DTO
+ *
+ * @author 没秃顶的码农
+ * @date 2024-01-09
+ */
+@Data
+@Schema(description = "机具回收-撤回回收")
+public class UserReturnRecycleDTO {
+
+
+    /**
+     * 机具号
+     */
+    @Schema(description = "机具号")
+    private List<String> snList;
+
+}

+ 28 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/feign/RemoteKxsStoreService.java

@@ -0,0 +1,28 @@
+
+package com.kxs.store.api.feign;
+
+import com.kxs.common.core.constant.SecurityConstants;
+import com.kxs.common.core.util.R;
+import com.kxs.store.api.model.KxsWarehouseLimit;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.service.annotation.PostExchange;
+
+/**
+ * @author Lxq
+ * @date 2021/6/22
+ */
+public interface RemoteKxsStoreService {
+
+	/**
+	 * 用户预发机额度
+	 *
+	 * @param limit 用户额度
+	 * @param from    调用标志
+	 * @return {@link R}<{@link Boolean}>
+	 */
+	@PostExchange("/userAdvance/addUserAdvanceLimit")
+	R<Boolean> addUserAdvanceLimit(@RequestBody KxsWarehouseLimit limit, @RequestHeader(SecurityConstants.FROM) String from);
+
+
+}

+ 85 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/feign/config/KxsStoreFeignClientConfiguration.java

@@ -0,0 +1,85 @@
+package com.kxs.store.api.feign.config;
+
+import cn.hutool.core.text.CharSequenceUtil;
+import com.kxs.common.core.constant.ServiceNameConstants;
+import com.kxs.store.api.feign.RemoteKxsStoreService;
+import io.seata.core.context.RootContext;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cloud.client.loadbalancer.reactive.ReactorLoadBalancerExchangeFilterFunction;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.reactive.function.client.ClientRequest;
+import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.reactive.function.client.support.WebClientAdapter;
+import org.springframework.web.service.invoker.HttpServiceProxyFactory;
+
+/**
+ * <p>
+ * 当前服务的webClient配置
+ * 服务下的远程调用统一在此配置
+ * 使用注册中心 需配置远程调用器 以实现负载均衡
+ * </p>
+ *
+ * @author 没秃顶的码农
+ * @date 2023/11/13
+ */
+@Configuration
+@RequiredArgsConstructor
+public class KxsStoreFeignClientConfiguration {
+
+	/**
+	 * 负载均衡器
+	 */
+	private final ReactorLoadBalancerExchangeFilterFunction reactorLoadBalancerExchangeFilterFunction;
+
+	private static final String SERVICE_NAME = ServiceNameConstants.CLIENT_NAME + ServiceNameConstants.STORE_SERVICE;
+
+	@Bean("kxsStoreFeignClient")
+	public WebClient oauthRequestInterceptor() {
+
+
+		return WebClient.builder()
+			// 给请求添加过滤器,添加自定义的认证头
+			.filter((request, next) -> {
+				ClientRequest.Builder filtered = ClientRequest.from(request);
+
+				// seata XID传递
+				String xid = RootContext.getXID();
+				if (CharSequenceUtil.isNotBlank(xid)) {
+					filtered.header(RootContext.KEY_XID, xid);
+				}
+
+				ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
+					.getRequestAttributes();
+				// 不是web请求不传递token
+				if (requestAttributes != null) {
+					HttpServletRequest httpServletRequest = requestAttributes.getRequest();
+					String token = httpServletRequest.getHeader(HttpHeaders.AUTHORIZATION);
+					if (!CharSequenceUtil.isBlank(token)) {
+						// 传递token
+						filtered.header(HttpHeaders.AUTHORIZATION, token);
+					}
+				}
+				return next.exchange(filtered.build());
+			}).filter(reactorLoadBalancerExchangeFilterFunction)
+			.baseUrl(SERVICE_NAME)
+			.build();
+	}
+
+	/**
+	 * 远程仓库模块服务
+	 * @param client 客户端
+	 * @return 远程仓库模块服务
+	 */
+	@Bean
+	RemoteKxsStoreService remoteKxsStoreService(@Qualifier("kxsStoreFeignClient") WebClient client) {
+		HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();
+		return factory.createClient(RemoteKxsStoreService.class);
+	}
+
+}

+ 6 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineApply.java

@@ -86,6 +86,12 @@ public class KxsMachineApply extends Model<KxsMachineApply> implements Serializa
     @Schema(description = "品牌ID")
     private Integer brandId;
 
+    /**
+     * 品牌
+     */
+    @Schema(description = "品牌")
+    private String brandName;
+
 
     /**
      * 仓库ID

+ 2 - 18
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineRecycle.java

@@ -4,10 +4,7 @@ import java.io.Serial;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -56,6 +53,7 @@ public class KxsMachineRecycle extends Model<KxsMachineRecycle> implements Seria
      * 删除标记,0未删除,1已删除
      */
     @Schema(description = "删除标记,0未删除,1已删除")
+    @TableLogic
     private Integer delFlag;
 
 
@@ -140,20 +138,6 @@ public class KxsMachineRecycle extends Model<KxsMachineRecycle> implements Seria
     private String phone;
 
 
-    /**
-     * 状态 0待发货 1待确认 2已完成
-     */
-    @Schema(description = "状态 0待发货 1待确认 2已完成")
-    private Integer status;
-
-
-    /**
-     * 操作时间
-     */
-    @Schema(description = "操作时间")
-    private LocalDateTime operatingDate;
-
-
 
 
 }

+ 2 - 4
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/model/KxsMachineRecycleInfo.java

@@ -5,10 +5,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -63,6 +60,7 @@ public class KxsMachineRecycleInfo extends Model<KxsMachineRecycleInfo> implemen
      * 删除标记,0未删除,1已删除
      */
     @Schema(description = "删除标记,0未删除,1已删除")
+    @TableLogic
     private Integer delFlag;
 
 

+ 0 - 7
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeAdvance/UserWarehouseListVO.java

@@ -21,13 +21,6 @@ public class UserWarehouseListVO implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 
-    /**
-     * 主键ID
-     */
-    @Schema(description = "主键ID")
-    private Integer id;
-
-
     /**
      * 用户ID
      */

+ 2 - 1
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeRecycle/NeedConfirmRecycleVO.java

@@ -6,6 +6,7 @@ import lombok.Data;
 
 import java.io.Serial;
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 /**
  * 仓库数据vo
@@ -24,7 +25,7 @@ public class NeedConfirmRecycleVO implements Serializable {
      * 循环结束时间
      */
     @Schema(description = "循环结束时间")
-    private Integer recycleEndTime;
+    private LocalDateTime recycleEndTime;
 
     /**
      * sn

+ 1 - 15
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/storeRecycle/StoreRecycleMachineListVO.java

@@ -73,20 +73,6 @@ public class StoreRecycleMachineListVO implements Serializable {
     private String trackNo;
 
 
-    /**
-     * 状态 0待发货 1已发货 2已完成 3已取消
-     */
-    @Schema(description = "状态 0待发货 1已发货 2已完成 3已取消")
-    private Integer status;
-
-
-    /**
-     * 操作时间
-     */
-    @Schema(description = "操作时间")
-    private LocalDateTime operatingDate;
-
-
     /**
      * 申请用户姓名
      */
@@ -112,7 +98,7 @@ public class StoreRecycleMachineListVO implements Serializable {
      * 寄回机具数量
      */
     @Schema(description = "寄回机具数量")
-    private String totalNumber;
+    private Integer totalNumber;
 
     /**
      * 寄回机具数量

+ 0 - 1
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userAdvance/AdvanceDevModalVO.java

@@ -17,7 +17,6 @@ import java.util.List;
  */
 @Data
 @Schema(description = "接收预发机弹窗返回实体")
-@Builder
 public class AdvanceDevModalVO implements Serializable {
 
 	@Serial

+ 141 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userOrder/UserApplyMachineDetailVO.java

@@ -0,0 +1,141 @@
+package com.kxs.store.api.vo.kxsapp.userOrder;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 机具申请-申请记录详情vo
+ *
+ * @author 系统
+ * @date 2024-01-16 15:40:07
+ */
+@Data
+@Schema(description = "机具申请-申请记录详情返回实体")
+public class UserApplyMachineDetailVO implements Serializable {
+
+	@Serial
+	private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    private Integer id;
+
+
+    /**
+     * 新增时间
+     */
+    @Schema(description = "新增时间")
+    private LocalDateTime createTime;
+
+
+    /**
+     * 订单号
+     */
+    @Schema(description = "订单号")
+    private String orderSn;
+
+
+    /**
+     * 提货方式 0自提 1邮寄
+     */
+    @Schema(description = "提货方式 0自提 1邮寄")
+    private Integer getMode;
+
+
+    /**
+     * 申请数量
+     */
+    @Schema(description = "申请数量")
+    private Integer applyNum;
+
+
+    /**
+     * 收货人
+     */
+    @Schema(description = "收货人")
+    private String contacts;
+
+
+    /**
+     * 联系电话
+     */
+    @Schema(description = "联系电话")
+    private String phone;
+
+
+    /**
+     * 收货地址
+     */
+    @Schema(description = "收货地址")
+    private String address;
+
+
+    /**
+     * 申请类型 1循环申请 0兑换券
+     */
+    @Schema(description = "申请类型 1循环申请 0兑换券")
+    private Integer applyType;
+
+
+    /**
+     * 订单状态 0待审核 1申请成功 2已驳回
+     */
+    @Schema(description = "订单状态 0待审核 1申请成功 2已驳回")
+    private Integer status;
+
+    /**
+     * 订单状态
+     */
+    @Schema(description = "订单状态")
+    private String statusNo;
+
+
+    /**
+     * 备注
+     */
+    @Schema(description = "备注")
+    private String remark;
+
+
+    /**
+     * 品牌名称
+     */
+    @Schema(description = "品牌名称")
+    private String brandName;
+
+
+    /**
+     * 仓库名称
+     */
+    @Schema(description = "仓库名称")
+    private Object warehouseName;
+
+    /**
+     * 仓库电话
+     */
+    @Schema(description = "仓库电话")
+    private Object warehousePhone;
+
+
+    /**
+     * 列表
+     */
+    @Schema(description = "列表")
+    private List<String> snList;
+
+
+
+
+
+	
+
+}

+ 76 - 0
kxs-store/kxs-store-api/src/main/java/com/kxs/store/api/vo/kxsapp/userOrder/UserApplyMahineListVO.java

@@ -0,0 +1,76 @@
+package com.kxs.store.api.vo.kxsapp.userOrder;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 机具申请-申请记录vo
+ *
+ * @author 系统
+ * @date 2024-01-16 15:40:07
+ */
+@Data
+@Schema(description = "机具申请-申请记录返回实体")
+public class UserApplyMahineListVO implements Serializable {
+
+	@Serial
+	private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    private Integer id;
+
+
+    /**
+     * 新增时间
+     */
+    @Schema(description = "新增时间")
+    private LocalDateTime createTime;
+
+    /**
+     * 申请数量
+     */
+    @Schema(description = "申请数量")
+    private Integer applyNum;
+
+
+    /**
+     * 订单号
+     */
+    @Schema(description = "订单号")
+    private String orderSn;
+
+
+    /**
+     * 收货地址
+     */
+    @Schema(description = "收货地址")
+    private String address;
+
+
+    /**
+     * 订单状态 0待审核 1申请成功 2已驳回
+     */
+    @Schema(description = "订单状态 0待审核 1申请成功 2已驳回")
+    private Integer status;
+
+
+    /**
+     * 状态
+     */
+    @Schema(description = "状态")
+    private String statusNo;
+
+
+
+	
+
+}

+ 1 - 0
kxs-store/kxs-store-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+com.kxs.store.api.feign.config.KxsStoreFeignClientConfiguration

+ 20 - 0
kxs-store/kxs-store-biz/pom.xml

@@ -19,6 +19,16 @@
     </properties>
 
     <dependencies>
+        <!--注册中心客户端-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+        <!--配置中心客户端-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
         <!--undertow容器-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -67,6 +77,16 @@
             <groupId>com.mysql</groupId>
             <artifactId>mysql-connector-j</artifactId>
         </dependency>
+        <!--多数据源-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
+        </dependency>
+        <!--接口文档-->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-swagger</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 24 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/KxsStoreApplication.java

@@ -0,0 +1,24 @@
+package com.kxs.store.biz;
+
+import com.kxs.common.security.annotation.EnableAuthResourceServer;
+import com.kxs.common.swagger.annotation.EnableKxsDoc;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+/**
+ * KXS仓库模块
+ *
+ * @author 没秃顶的码农
+ * @date 2024-01-15
+ */
+@SpringBootApplication
+@EnableAuthResourceServer
+@EnableKxsDoc(value = "store")
+public class KxsStoreApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(KxsStoreApplication.class, args);
+	}
+
+}

+ 1 - 6
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/MachineOrderEnum.java

@@ -12,12 +12,7 @@ import lombok.RequiredArgsConstructor;
 @Getter
 @RequiredArgsConstructor
 public enum MachineOrderEnum {
-    /**
-     * 订单状态
-     */
-    UNDER_REVIEW(0, "待审核"),
-    APPLY_SUCCESSFUL(1, "申请成功"),
-    REJECTED(2, "已驳回"),
+
     /**
      * 申请类型
      */

+ 26 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/MachineOrderStatusEnum.java

@@ -0,0 +1,26 @@
+package com.kxs.store.biz.constant.enums;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 机具申请相关枚举
+ *
+ * @author 没秃顶的码农
+ * @date 2024-01-08
+ */
+@Getter
+@RequiredArgsConstructor
+public enum MachineOrderStatusEnum {
+    /**
+     * 订单状态
+     */
+    UNDER_REVIEW(0, "待审核"),
+    APPLY_SUCCESSFUL(1, "申请成功"),
+    REJECTED(2, "已驳回");
+
+    //状态码
+    private final Integer type;
+    //状态码码描述
+    private final String description;
+}

+ 2 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/RecycleOrderEnum.java

@@ -24,7 +24,8 @@ public enum RecycleOrderEnum {
      */
     INFO_UNCONFIRM(0, "未确认"),
     INFO_CONFIRM(1, "已确认"),
-    INFO_CANCEL(2, "已驳回");
+    INFO_CANCEL(2, "已驳回"),
+    INFO_RETURN(3, "已取消");
 
     //状态码
     private final Integer type;

+ 1 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/constant/enums/StoreErrorTypeEnum.java

@@ -33,6 +33,7 @@ public enum StoreErrorTypeEnum {
 	USER_IS_NOT_FIND(-1, "该创客不在您的预发范围内"),
 	INSUFFICIENT_QUOTA(-1, "可用额度不足"),
 	ADVANCE_MACHINE_NUMBER_ERROR(-1, "预发数量超限"),
+	WAREHOUSE_NOT_FIND(-1, "仓库数据错误"),
 	DATA_ERROR(-1, "数据错误");
 
 	private final int code;

+ 2 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreAdvanceController.java

@@ -11,6 +11,7 @@ import com.kxs.store.biz.mapper.KxsWarehouseLimitMapper;
 import com.kxs.store.biz.service.KxsMachineAdvanceService;
 import com.kxs.store.biz.service.KxsWarehouseLimitService;
 import com.kxs.store.biz.service.KxsWarehouseUserService;
+import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.springdoc.core.annotations.ParameterObject;
 import org.springframework.web.bind.annotation.*;
@@ -71,7 +72,7 @@ public class StoreAdvanceController {
      * @return 小分仓-预发货到小分仓
      */
     @PostMapping("/addAdvance")
-    public R addAdvance(@RequestBody StoreAdvanceAddAdvanceDTO param) {
+    public R addAdvance(@Valid @RequestBody StoreAdvanceAddAdvanceDTO param) {
 
         return kxsMachineAdvanceService.addAdvanceMachine(param);
     }

+ 3 - 16
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreOrderController.java

@@ -30,26 +30,13 @@ public class StoreOrderController {
     private final KxsMachineApplyService kxsMachineApplyService;
 
 
-
-    /**
-     * 订单管理-申请机具
-     *
-     * @param param 实体对象
-     * @return 订单管理-申请机具
-     */
-    @PostMapping("/applyMachine")
-    public R applyMachine(@Valid @RequestBody ApplyMachineDTO param) {
-
-        return kxsMachineApplyService.applyMachine(param);
-    }
-
     /**
      * 订单管理-划拨
      *
      * @param param 实体对象
      * @return 订单管理-划拨
      */
-    @PutMapping("/storeOrderTransferUser")
+    @PostMapping("/storeOrderTransferUser")
     public R storeOrderTransferUser(@Valid @RequestBody StoreOrderTransferUserDTO param) {
 
         return kxsMachineApplyService.storeOrderTransferUser(param);
@@ -89,10 +76,10 @@ public class StoreOrderController {
      * @param param 实体对象
      * @return 订单管理-驳回订单
      */
-    @PutMapping("/orderCancel")
+    @PostMapping("/orderCancel")
     public R orderCancel(@RequestBody KxsMachineApply param) {
 
-        return R.ok(kxsMachineApplyService.orderCancel(param));
+        return kxsMachineApplyService.orderCancel(param);
     }
 
 

+ 17 - 2
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/StoreRecycleController.java

@@ -5,6 +5,7 @@ import com.kxs.common.core.util.R;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleConfirmDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleSubmitDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.StoreRecycleMachineListDTO;
+import com.kxs.store.api.dto.kxsapp.storeRecycle.UserReturnRecycleDTO;
 import com.kxs.store.api.model.KxsMachineRecycle;
 import com.kxs.store.api.vo.kxsapp.storeRecycle.NeedConfirmRecycleVO;
 import com.kxs.store.api.vo.kxsapp.storeRecycle.RecycleUserListVO;
@@ -15,6 +16,8 @@ import lombok.RequiredArgsConstructor;
 import org.springdoc.core.annotations.ParameterObject;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * 仓库模块(StoreRecycle)控制层
  *
@@ -52,7 +55,7 @@ public class StoreRecycleController {
      * @return 待回收机具-确认收货
      */
     @PostMapping("/confirm")
-    public R confirm(@RequestBody RecycleConfirmDTO param) {
+    public R confirm(@Valid @RequestBody RecycleConfirmDTO param) {
 
         return kxsMachineRecycleService.confirm(param);
     }
@@ -64,7 +67,7 @@ public class StoreRecycleController {
      * @return 待回收机具-确认收货
      */
     @PostMapping("/cancel")
-    public R cancel(@RequestBody RecycleConfirmDTO param) {
+    public R cancel(@Valid @RequestBody RecycleConfirmDTO param) {
 
         return kxsMachineRecycleService.cancel(param);
     }
@@ -94,6 +97,18 @@ public class StoreRecycleController {
         return kxsMachineRecycleService.userSubmit(param);
     }
 
+    /**
+     * 机具回收-撤回
+     *
+     * @param param 撤回
+     * @return 机具回收-撤回
+     */
+    @PostMapping("/userReturnRecycle")
+    public R userReturnRecycle(@RequestBody UserReturnRecycleDTO param) {
+
+        return kxsMachineRecycleService.userReturnRecycle(param);
+    }
+
     /**
      * 机具回收-用户寄回记录
      *

+ 15 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/UserAdvanceController.java

@@ -2,8 +2,10 @@ package com.kxs.store.biz.controller.kxsapp;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.kxs.common.core.util.R;
+import com.kxs.common.security.annotation.Inner;
 import com.kxs.store.api.dto.kxsapp.storeLimit.ForAmountWithdrawDTO;
 import com.kxs.store.api.dto.kxsapp.userAdvance.ConfirmAdvanceMachineDTO;
+import com.kxs.store.api.model.KxsWarehouseLimit;
 import com.kxs.store.api.vo.kxsapp.userAdvance.UserAdvanceListVO;
 import com.kxs.store.biz.service.KxsForAmountWithdrawService;
 import com.kxs.store.biz.service.KxsMachineAdvanceService;
@@ -33,6 +35,19 @@ public class UserAdvanceController {
 
 
 
+    /**
+     * 用户预发机额度初始化
+     * 内部调用
+     *
+     * @return 预发机额度详情
+     */
+    @Inner
+    @PostMapping("/addUserAdvanceLimit")
+    public R addUserAdvanceLimit(@RequestBody KxsWarehouseLimit kxsWarehouseLimit) {
+
+        return R.ok(kxsWarehouseLimitService.addUserAdvanceLimit(kxsWarehouseLimit));
+    }
+
     /**
      * 预发机额度详情
      *

+ 72 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/controller/kxsapp/UserOrderController.java

@@ -0,0 +1,72 @@
+package com.kxs.store.biz.controller.kxsapp;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.kxs.common.core.util.R;
+import com.kxs.store.api.dto.kxsapp.storeOrder.*;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMahineListVO;
+import com.kxs.store.biz.service.KxsMachineApplyService;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.springdoc.core.annotations.ParameterObject;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 用户机具申请
+ *
+ * @author 系统
+ * @since 2024-01-08 11:15:03
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("userOrder")
+public class UserOrderController {
+
+    /**
+     * 服务对象
+     */
+    private final KxsMachineApplyService kxsMachineApplyService;
+
+
+
+    /**
+     * 订单管理-申请机具
+     *
+     * @param param 实体对象
+     * @return 订单管理-申请机具
+     */
+    @PostMapping("/applyMachine")
+    public R applyMachine(@Valid @RequestBody ApplyMachineDTO param) {
+
+        return kxsMachineApplyService.applyMachine(param);
+    }
+
+    /**
+     * 机具申请-申请记录
+     *
+     * @param page 分页对象
+     * @return 机具申请-申请记录
+     */
+    @GetMapping("/userApplyMachineList")
+    public R userApplyMachineList(@ParameterObject Page<UserApplyMahineListVO> page) {
+
+        return R.ok(kxsMachineApplyService.userApplyMachineList(page));
+    }
+
+
+    /**
+     * 机具申请-申请记录详情
+     *
+     * @param id 主键
+     * @return 机具申请-申请记录详情
+     */
+    @GetMapping("/userApplyMachineDetail")
+    public R userApplyMachineDetail(@RequestParam("id") Long id) {
+
+        return R.ok(kxsMachineApplyService.userApplyMachineDetail(id));
+    }
+
+
+
+
+}
+

+ 10 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/mapper/KxsMachineApplyMapper.java

@@ -10,6 +10,7 @@ import com.kxs.store.api.model.KxsMachineApply;
 import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderListVO;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMahineListVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -48,5 +49,14 @@ public interface KxsMachineApplyMapper extends BaseMapper<KxsMachineApply> {
      * @return {@link IPage}<{@link OrderMonthTotalDetailVO}>
      */
     IPage<OrderMonthTotalDetailVO> orderMonthTotalDetail(Page<OrderMonthTotalDetailVO> page, @Param("query") OrderMonthTotalDetailDTO param);
+
+    /**
+     * app 用户申请记录
+     *
+     * @param page   页
+     * @param userId 用户 ID
+     * @return {@link IPage}<{@link UserApplyMahineListVO}>
+     */
+    IPage<UserApplyMahineListVO> userApplyMachineList(Page<UserApplyMahineListVO> page, @Param("userId") Long userId);
 }
 

+ 7 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/mapper/KxsMachineRecycleMapper.java

@@ -62,5 +62,12 @@ public interface KxsMachineRecycleMapper extends BaseMapper<KxsMachineRecycle> {
      */
     Integer recoverableData(Long userId);
 
+    /**
+     * 仓库待确认数量
+     *
+     * @param warehouseUserId 用户 ID
+     * @return {@link Long}
+     */
+    Integer storeRecoverableData(@Param("warehouseUserId") Integer warehouseUserId, @Param("status") Integer status);
 }
 

+ 18 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsMachineApplyService.java

@@ -10,6 +10,8 @@ import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderDetailVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderListVO;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMachineDetailVO;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMahineListVO;
 
 /**
  * 客小爽机具申请表(KxsMachineApply)表服务接口
@@ -77,5 +79,21 @@ public interface KxsMachineApplyService extends IService<KxsMachineApply> {
      * @return {@link IPage}<{@link OrderMonthTotalDetailVO}>
      */
     IPage<OrderMonthTotalDetailVO> orderMonthTotalDetail(Page<OrderMonthTotalDetailVO> page, OrderMonthTotalDetailDTO param);
+
+    /**
+     * app 用户申请记录
+     *
+     * @param page 页
+     * @return {@link IPage}<{@link UserApplyMahineListVO}>
+     */
+    IPage<UserApplyMahineListVO> userApplyMachineList(Page<UserApplyMahineListVO> page);
+
+    /**
+     * app 用户申请记录详情
+     *
+     * @param id 编号
+     * @return {@link UserApplyMachineDetailVO}
+     */
+    UserApplyMachineDetailVO userApplyMachineDetail(Long id);
 }
 

+ 10 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsMachineRecycleService.java

@@ -7,6 +7,7 @@ import com.kxs.common.core.util.R;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleConfirmDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleSubmitDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.StoreRecycleMachineListDTO;
+import com.kxs.store.api.dto.kxsapp.storeRecycle.UserReturnRecycleDTO;
 import com.kxs.store.api.model.KxsMachineRecycle;
 import com.kxs.store.api.vo.kxsapp.storeRecycle.*;
 
@@ -81,5 +82,14 @@ public interface KxsMachineRecycleService extends IService<KxsMachineRecycle> {
      * @return {@link recoverableDataVO}
      */
     recoverableDataVO recoverableData();
+
+    /**
+     * 用户撤回回收
+     *
+     * @param userReturnRecycleDTO SN列表
+     * @return {@link R}
+     */
+    R userReturnRecycle(UserReturnRecycleDTO userReturnRecycleDTO);
+
 }
 

+ 8 - 0
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/KxsWarehouseLimitService.java

@@ -56,5 +56,13 @@ public interface KxsWarehouseLimitService extends IService<KxsWarehouseLimit> {
      * @param kind        add sub
      */
     void refreshWarehouseAmount(Integer userId, int amount, String kind);
+
+    /**
+     * 用户预发机额度初始化
+     *
+     * @param kxsWarehouseLimit KXS仓库限制
+     * @return {@link Boolean}
+     */
+    Boolean addUserAdvanceLimit(KxsWarehouseLimit kxsWarehouseLimit);
 }
 

+ 3 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsForAmountWithdrawServiceImpl.java

@@ -21,6 +21,7 @@ import com.kxs.store.biz.service.KxsForAmountWithdrawService;
 import com.kxs.user.api.feign.RemoteKxsUserService;
 import com.kxs.user.api.model.KxsUserAmountLog;
 import com.kxs.user.api.vo.kxsapp.user.RealUserInfoVO;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,6 +43,7 @@ public class KxsForAmountWithdrawServiceImpl extends ServiceImpl<KxsForAmountWit
     private final KxsWarehouseLimitMapper kxsWarehouseLimitMapper;
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R forAmountWithdraw(ForAmountWithdrawDTO param, Integer withdrawType) {
 
@@ -64,7 +66,7 @@ public class KxsForAmountWithdrawServiceImpl extends ServiceImpl<KxsForAmountWit
         kxsForAmountWithdraw.setWithdrawType(withdrawType);
 
         KxsWarehouseLimit userLimit = kxsWarehouseLimitMapper.selectOne(Wrappers.<KxsWarehouseLimit>lambdaQuery()
-                .eq(KxsWarehouseLimit::getWarehouseType, WarehouseLimitTypeEnum.XFC.getType())
+                .eq(KxsWarehouseLimit::getWarehouseType, param.getWithdrawType())
                 .eq(KxsWarehouseLimit::getUserId, userId));
 
         BigDecimal forAmount;

+ 48 - 8
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineAdvanceServiceImpl.java

@@ -11,6 +11,7 @@ import com.kxs.common.core.constant.SecurityConstants;
 import com.kxs.common.core.constant.enums.BrandTypeEnum;
 import com.kxs.common.core.constant.enums.ErrorTypeEnum;
 import com.kxs.common.core.constant.enums.KindTypeEnum;
+import com.kxs.common.core.constant.enums.MachineTypeEnum;
 import com.kxs.common.core.exception.GlobalCustomerException;
 import com.kxs.common.core.util.R;
 import com.kxs.common.core.util.RetOps;
@@ -35,6 +36,7 @@ import com.kxs.system.api.model.KxsUserMsg;
 import com.kxs.system.api.util.MsgTemplateUtil;
 import com.kxs.user.api.feign.RemoteKxsUserService;
 import com.kxs.user.api.model.KxsUser;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -134,6 +136,7 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
     }
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R cancelAdvance(KxsMachineAdvanceInfo advance) {
 
@@ -148,6 +151,15 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
         machineAdvanceInfo.setReturnTime(LocalDateTime.now());
         kxsMachineAdvanceInfoMapper.updateById(machineAdvanceInfo);
 
+        //修改状态为在库
+        KxsMachine machine = new KxsMachine();
+        machine.setId(machineAdvanceInfo.getMachineId());
+        machine.setStatus(MachineTypeEnum.STATUS_IS.getType());
+        R<Boolean> result = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+        if(!result.getData()){
+            throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
+        }
+
         if(machineAdvanceInfo.getIsUseAmount() == 1){
 
             //查询主订单预发机
@@ -160,8 +172,10 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
                     .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
 
             //小分仓减少已用额度 刷新可用额度
-            Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getType, brand.getBrandType());
+            Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(brand.getBrandType()));
             kxsWarehouseLimitService.refreshUserAmount(kxsMachineAdvance.getToUserId(), price, KindTypeEnum.SUB.getType());
+            //增加仓库已用额度减少仓库可用额度
+            kxsWarehouseLimitService.refreshWarehouseAmount(kxsMachineAdvance.getSendUserId(), price, KindTypeEnum.ADD.getType());
         }
 
         KxsMachineAdvance kxsMachineAdvance = baseMapper.selectById(machineAdvanceInfo.getOrderId());
@@ -206,7 +220,7 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
             return R.failed(StoreErrorTypeEnum.ADVANCE_MACHINE_NUMBER_ERROR.getDescription());
         }
         //查询仓库
-        KxsWarehouse warehouse = kxsWarehouseMapper.selectById(param.getSendWarehouseId());
+        KxsWarehouse warehouse = kxsWarehouseMapper.selectById(param.getWarehouseId());
 
         //查询品牌
         R<KxsBrand> kxsBrandR = remoteKxsProductService.loadByBrand(param.getBrandId(), SecurityConstants.FROM_IN);
@@ -220,7 +234,7 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
         kxsMachineAdvance.setBrandId(brand.getId());
         kxsMachineAdvance.setBrandName(brand.getName());
         kxsMachineAdvance.setToUserId(toUser.getId());
-        kxsMachineAdvance.setWarehouseId(param.getSendWarehouseId());
+        kxsMachineAdvance.setWarehouseId(param.getWarehouseId());
         kxsMachineAdvance.setWarehouseName(warehouse.getWarehouseName());
         baseMapper.insert(kxsMachineAdvance);
 
@@ -236,6 +250,12 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
             kxsMachineAdvanceInfo.setMachineId(machine.getId());
             kxsMachineAdvanceInfoMapper.insert(kxsMachineAdvanceInfo);
 
+            //修改状态为预发机
+            machine.setStatus(MachineTypeEnum.STATUS_ADVANCE.getType());
+            R<Boolean> result = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+            if(!result.getData()){
+                throw new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription());
+            }
         }
 
 
@@ -281,6 +301,12 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
 
         List<KxsMachineAdvanceInfo> machineAdvanceInfos = kxsMachineAdvanceInfoMapper.selectList(Wrappers.<KxsMachineAdvanceInfo>lambdaQuery()
                 .in(KxsMachineAdvanceInfo::getPosSn, param.getSnList()));
+        for (KxsMachineAdvanceInfo machineAdvanceInfo : machineAdvanceInfos) {
+            if(machineAdvanceInfo.getIsConfirm() != 0){
+                return R.failed(machineAdvanceInfo.getPosSn() + "该机器已确认");
+            }
+        }
+
         //同意
         if (param.getConfirmType() == 1) {
             //扣减用户预发额度
@@ -293,11 +319,7 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
             }
             //额度充足
             if (userLimit.getValidAmount().compareTo(BigDecimal.valueOf(amount)) >= 0) {
-                //修改为占用预发额度标签
-                for (KxsMachineAdvanceInfo info : machineAdvanceInfos) {
-                    info.setIsUseAmount(1);
-                    kxsMachineAdvanceInfoMapper.updateById(info);
-                }
+
                 //小分仓增加已用额度 刷新可用额度
                 userLimit.setUsedAmount(NumberUtil.add(userLimit.getUsedAmount(), amount));
                 userLimit.setValidAmount(NumberUtil.sub(userLimit.getValidAmount(), amount));
@@ -306,6 +328,14 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
                 //减少仓库已用额度增加仓库可用额度
                 kxsWarehouseLimitService.refreshWarehouseAmount(warehouse.getUserId(), amount, KindTypeEnum.SUB.getType());
             }
+            for (KxsMachineAdvanceInfo info : machineAdvanceInfos) {
+                //修改为占用预发额度标签
+                if (userLimit.getValidAmount().compareTo(BigDecimal.valueOf(amount)) >= 0) {
+                    info.setIsUseAmount(1);
+                }
+                info.setIsConfirm(1);
+                kxsMachineAdvanceInfoMapper.updateById(info);
+            }
             //给预发对象发送通知
             KxsUserMsg toUserMsg = MsgTemplateUtil.confirmAdvanceMachineUserNote(userId.intValue(), warehouse.getWarehouseName(), machineAdvance.getBrandName(), param.getSnList());
             //给仓库发送通知
@@ -318,6 +348,16 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
             for (KxsMachineAdvanceInfo info : machineAdvanceInfos) {
                 info.setIsConfirm(2);
                 kxsMachineAdvanceInfoMapper.updateById(info);
+
+                //修改状态为在库
+                KxsMachine machine = new KxsMachine();
+                machine.setId(info.getMachineId());
+                machine.setStatus(MachineTypeEnum.STATUS_IS.getType());
+                R<Boolean> result = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+                if(!result.getData()){
+                    throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
+                }
+
             }
             //给仓库发送模版消息
             KxsUserMsg toWarehouseMsg = MsgTemplateUtil.advanceMachineCancelWarehouseNote(warehouse.getUserId(), toUser.getUserCode(), toUser.getUsername(), warehouse.getWarehouseName(), brand.getName(), param.getSnList());

+ 98 - 30
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineApplyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.kxs.store.biz.service.impl;
 
 import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.IdUtil;
@@ -12,6 +13,7 @@ import com.kxs.common.core.constant.SecurityConstants;
 import com.kxs.common.core.constant.enums.BrandTypeEnum;
 import com.kxs.common.core.constant.enums.ErrorTypeEnum;
 import com.kxs.common.core.constant.enums.KindTypeEnum;
+import com.kxs.common.core.constant.enums.MachineTypeEnum;
 import com.kxs.common.core.exception.GlobalCustomerException;
 import com.kxs.common.core.util.R;
 import com.kxs.common.core.util.RetOps;
@@ -27,6 +29,8 @@ import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderDetailVO;
 import com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderListVO;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMachineDetailVO;
+import com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMahineListVO;
 import com.kxs.store.biz.constant.StoreConstants;
 import com.kxs.store.biz.constant.enums.*;
 import com.kxs.store.biz.mapper.*;
@@ -37,6 +41,7 @@ import com.kxs.system.api.util.MsgTemplateUtil;
 import com.kxs.user.api.feign.RemoteKxsUserService;
 import com.kxs.user.api.model.KxsUser;
 import com.kxs.user.api.model.KxsUserAdvance;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -45,6 +50,8 @@ import org.springframework.transaction.annotation.Transactional;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -81,6 +88,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
     private final KxsSendTotalService kxsSendTotalService;
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R applyMachine(ApplyMachineDTO param) {
 
@@ -91,7 +99,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
 
         KxsMachineApply order = new KxsMachineApply();
         BeanUtils.copyProperties(param, order);
-        order.setOrderSn(String.valueOf(orderSn));
+        order.setOrderSn("BA" + orderSn);
         //查询申请用户
         R<KxsUser> userResult = remoteKxsUserService.loadUserById(userId.intValue(), SecurityConstants.FROM_IN);
         KxsUser user = RetOps.of(userResult)
@@ -102,8 +110,14 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         order.setUserCode(user.getUserCode());
         //预发机申请
         if(param.getIsAdvance() == 1){
-            order.setStatus(MachineOrderEnum.APPLY_SUCCESSFUL.getType());
+            order.setStatus(MachineOrderStatusEnum.APPLY_SUCCESSFUL.getType());
         }
+        //查询品牌
+        R<KxsBrand> kxsBrandR = remoteKxsProductService.loadByBrand(param.getBrandId(), SecurityConstants.FROM_IN);
+        KxsBrand brand = RetOps.of(kxsBrandR)
+                .getData()
+                .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
+        order.setBrandName(brand.getName());
         //添加订单
         baseMapper.insert(order);
 
@@ -111,8 +125,8 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         //预发机
         List<String> advanceList = param.getAdvanceList();
         for (int i = 0; i < snList.size(); i++) {
+
             String sn = snList.get(i);
-            String advanceSn = advanceList.get(i);
             //新增订单详情
             KxsMachineApplyDetail orderDetail = new KxsMachineApplyDetail();
             orderDetail.setOrderId(order.getId());
@@ -132,7 +146,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                     throw new GlobalCustomerException(StoreErrorTypeEnum.TICKET_CODE_UN.getDescription());
                 }
                 //冻结券码,发货后 驳回改回未使用 通过修改为已使用
-                ticket.setStatus(TicketStatusEnum.TICKET_USED.getType());
+                ticket.setStatus(TicketStatusEnum.TICKET_FREEZE.getType());
                 R<Boolean> result = remoteKxsProductService.updateByTicket(ticket, SecurityConstants.FROM_IN);
                 if(!result.getData()){
                     throw new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription());
@@ -164,6 +178,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
 
             //预发机申请
             if(param.getIsAdvance() == 1){
+                String advanceSn = advanceList.get(i);
                 //查询机具
                 R<KxsMachine> machineResult = remoteKxsProductService.loadMachineBySn(advanceSn, SecurityConstants.FROM_IN);
                 KxsMachine adMachine = RetOps.of(machineResult)
@@ -173,11 +188,6 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                 KxsMachineAdvanceInfo kxsMachineAdvance = kxsMachineAdvanceInfoMapper.selectOne(Wrappers.<KxsMachineAdvanceInfo>lambdaQuery()
                         .eq(KxsMachineAdvanceInfo::getPosSn, advanceSn));
 
-                //查询机具品牌
-                R<KxsBrand> brandResult = remoteKxsProductService.loadByBrand(adMachine.getBrandId(), SecurityConstants.FROM_IN);
-                KxsBrand brand = RetOps.of(brandResult)
-                        .getData()
-                        .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
                 if (kxsMachineAdvance == null ) {
                     throw new GlobalCustomerException(StoreErrorTypeEnum.ADVANCE_MACHINE_NOT_FIND.getDescription());
                 }
@@ -194,7 +204,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                 //占用自己的预发额度
                 if (kxsMachineAdvance.getIsUseAmount() == 1) {
                     //小分仓减少已用额度 刷新可用额度
-                    Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getType, brand.getBrandType());
+                    Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(brand.getBrandType()));
                     kxsWarehouseLimitService.refreshUserAmount(userId.intValue(), price, KindTypeEnum.SUB.getType());
                 }
                 //已经添加到预扣款
@@ -223,6 +233,9 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                 adMachine.setUserId(userId.intValue());
                 //修改为申请的机具类型
                 adMachine.setMachineType(param.getApplyType());
+                //修改机具已出库
+                adMachine.setStatus(MachineTypeEnum.STATUS_OUT.getType());
+                adMachine.setDeliveryTime(LocalDateTime.now());
                 //如果是循环申请则继承循环机时间
                 if(param.getApplyType().equals(MachineOrderEnum.M_TYPE_RE.getType())){
                     //继承循环起止时间并变更为可循环
@@ -231,7 +244,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
                 }
                 R<Boolean> result = remoteKxsProductService.updateByMachine(adMachine, SecurityConstants.FROM_IN);
                 if(!result.getData()){
-                    throw new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription());
+                    throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
                 }
                 //机具已绑定 机具满足激活条件 && 绑定至申请时间 ≤ 30min
                 if (adMachine.getBindStatus() == 1 ) {
@@ -265,6 +278,8 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
     }
 
     @Override
+    @GlobalTransactional
+    @Transactional(rollbackFor = Exception.class)
     public R storeOrderTransferUser(StoreOrderTransferUserDTO param) {
 
         Long userId = SecurityUtils.getUser().getId();
@@ -273,9 +288,14 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         if(order == null){
             return R.failed(StoreErrorTypeEnum.ORDER_NULL.getDescription());
         }
-        if(!Objects.equals(order.getStatus(), MachineOrderEnum.UNDER_REVIEW.getType())){
+        if(!Objects.equals(order.getStatus(), MachineOrderStatusEnum.UNDER_REVIEW.getType())){
             return R.failed(StoreErrorTypeEnum.ORDER_REPETITION_SUBMIT.getDescription());
         }
+        //查询仓库
+        KxsWarehouse warehouse = kxsWarehouseMapper.selectById(order.getWarehouseId());
+        if(warehouse == null || warehouse.getUserId() != userId.intValue()){
+            return R.failed(StoreErrorTypeEnum.WAREHOUSE_NOT_FIND.getDescription());
+        }
         List<KxsMachineApplyDetail> orderDetails = kxsMachineApplyDetailMapper.selectList(Wrappers.<KxsMachineApplyDetail>lambdaQuery().eq(KxsMachineApplyDetail::getOrderId, order.getId()));
         List<String> snList = param.getSnList();
         //申请数量对应不上
@@ -292,14 +312,14 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
             KxsMachine machine = RetOps.of(machineResult)
                     .getData()
                     .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
-
+            if(machine.getStatus() != 0){
+                throw new GlobalCustomerException(machine.getPosSn() + "机具状态不是在库!");
+            }
 
             //划拨给订单用户
             machine.setUserId(order.getUserId());
-            //在库才修改状态为出库
-            if(machine.getStatus() == 0){
-                machine.setStatus(1);
-            }
+            //修改状态为出库
+            machine.setStatus(MachineTypeEnum.STATUS_OUT.getType());
             //如果为兑换机设置循环时间并设置为可循环申请
             if (order.getApplyType().equals(MachineOrderEnum.M_TYPE_SN.getType())) {
                 machine.setRecycleEndTime(LocalDateTime.now().plusDays(StoreConstants.RECYC_MAX_DAY));
@@ -335,6 +355,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
 
             //订单详情绑定机具
             orderDetail.setMachineId(machine.getId());
+            orderDetail.setPosSn(machine.getPosSn());
             kxsMachineApplyDetailMapper.updateById(orderDetail);
 
             if (machine.getBindStatus() == 1 ) {
@@ -351,14 +372,14 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         //新增仓库日志记录
         kxsWarehouseStockLogService.addKxsWarehouseStockLog(order.getWarehouseId(), order.getBrandId(), warehouseStock, KindTypeEnum.SUB.getType(), 1, snList.size());
         //修改订单状态
-        order.setStatus(MachineOrderEnum.APPLY_SUCCESSFUL.getType());
+        order.setStatus(MachineOrderStatusEnum.APPLY_SUCCESSFUL.getType());
         baseMapper.updateById(order);
         //刷新仓库额度
         R<KxsBrand> kxsBrandR = remoteKxsProductService.loadByBrand(order.getBrandId(), SecurityConstants.FROM_IN);
         KxsBrand kxsBrand = RetOps.of(kxsBrandR)
                 .getData()
                 .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription()));
-        Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getType, kxsBrand.getBrandType());
+        Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(kxsBrand.getBrandType()));
         int amount = snList.size() * price;
         //减少仓库已用额度增加仓库可用额度
         kxsWarehouseLimitService.refreshWarehouseAmount(userId.intValue(), amount, KindTypeEnum.SUB.getType());
@@ -375,7 +396,7 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         IPage<StoreOrderListVO> byPage = baseMapper.getByPage(page, param);
         //如果已完成的订单才去查询机具号
         for (StoreOrderListVO orderListVo : byPage.getRecords()) {
-            if (Objects.equals(orderListVo.getStatus(), MachineOrderEnum.APPLY_SUCCESSFUL.getType())) {
+            if (Objects.equals(orderListVo.getStatus(), MachineOrderStatusEnum.APPLY_SUCCESSFUL.getType())) {
                 List<KxsMachineApplyDetail> orderDetails = kxsMachineApplyDetailMapper.selectList(Wrappers.<KxsMachineApplyDetail>lambdaQuery().eq(KxsMachineApplyDetail::getOrderId, orderListVo.getId()));
                 orderListVo.setSnList(orderDetails.stream().map(KxsMachineApplyDetail::getPosSn).collect(Collectors.toList()));
             }
@@ -400,13 +421,13 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
     public R orderCancel(KxsMachineApply param) {
         KxsMachineApply order = baseMapper.selectById(param.getId());
 
-        if(Objects.equals(order.getStatus(), MachineOrderEnum.APPLY_SUCCESSFUL.getType())){
+        if(Objects.equals(order.getStatus(), MachineOrderStatusEnum.APPLY_SUCCESSFUL.getType())){
             return R.failed(StoreErrorTypeEnum.ORDER_REPETITION_TRANSFER.getDescription());
         }
-        if(Objects.equals(order.getStatus(), MachineOrderEnum.REJECTED.getType())){
+        if(Objects.equals(order.getStatus(), MachineOrderStatusEnum.REJECTED.getType())){
             return R.failed(StoreErrorTypeEnum.ORDER_REPETITION_CANCEL.getDescription());
         }
-        order.setStatus(MachineOrderEnum.REJECTED.getType());
+        order.setStatus(MachineOrderStatusEnum.REJECTED.getType());
         baseMapper.updateById(order);
         //查询订单详情回退券码状态
         List<KxsMachineApplyDetail> orderDetail = kxsMachineApplyDetailMapper.selectList(Wrappers.<KxsMachineApplyDetail>lambdaQuery().eq(KxsMachineApplyDetail::getOrderId, param.getId()));
@@ -467,21 +488,20 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
     @Override
     public IPage<OrderMonthTotalDetailVO> orderMonthTotalDetail(Page<OrderMonthTotalDetailVO> page, OrderMonthTotalDetailDTO param) {
 
-        String month = param.getMonth();
+        //组装本月日期
+        String month = param.getMonth() + "-01";
         //根据月份获取本月开始时间和结束时间
-        LocalDate monthDate = LocalDate.parse(month, DatePattern.NORM_MONTH_FORMATTER);
+        LocalDate monthDate = LocalDate.parse(month, DatePattern.NORM_DATE_FORMATTER);
         LocalDateTime monthStartTime = LocalDateTime.of(monthDate, LocalTime.MIN);
-        LocalDateTime monthEndTime = LocalDateTime.of(monthDate.plusMonths(1), LocalTime.MAX);
+        LocalDateTime monthEndTime = LocalDateTime.of(monthDate.plusMonths(1), LocalTime.MIN);
 
         param.setStartDate(String.valueOf(monthStartTime));
         param.setEndDate(String.valueOf(monthEndTime));
         IPage<OrderMonthTotalDetailVO> byPage = baseMapper.orderMonthTotalDetail(page, param);
 
         for (OrderMonthTotalDetailVO record : byPage.getRecords()) {
-
-            String date = record.getDate();
-            String startTime = date + " 00:00:00";
-            String endTime = date + " 23:59:59";
+            String startTime = record.getDate() + " 00:00:00";
+            String endTime = record.getDate() + " 23:59:59";
             //查询当天发出的机器
             List<String> snList = kxsMachineApplyDetailMapper.listDateQueries(param.getWarehouseId(), param.getBrandId(),
                     startTime, endTime);
@@ -491,6 +511,54 @@ public class KxsMachineApplyServiceImpl extends ServiceImpl<KxsMachineApplyMappe
         return byPage;
     }
 
+    @Override
+    public IPage<UserApplyMahineListVO> userApplyMachineList(Page<UserApplyMahineListVO> page) {
+
+        IPage<UserApplyMahineListVO> pageList = baseMapper.userApplyMachineList(page, SecurityUtils.getUser().getId());
+        for (UserApplyMahineListVO record : pageList.getRecords()) {
+            String statusNo = EnumUtil.getFieldBy(MachineOrderStatusEnum::getDescription, MachineOrderStatusEnum::getType, record.getStatus());
+            record.setStatusNo(statusNo);
+        }
+        return pageList;
+    }
+
+    @Override
+    public UserApplyMachineDetailVO userApplyMachineDetail(Long id) {
+
+        UserApplyMachineDetailVO userApplyMachineDetailVO = new UserApplyMachineDetailVO();
+        KxsMachineApply order = baseMapper.selectById(id);
+        BeanUtils.copyProperties(order, userApplyMachineDetailVO);
+        //查询仓库
+        KxsWarehouse warehouse = kxsWarehouseMapper.selectById(order.getWarehouseId());
+        userApplyMachineDetailVO.setWarehouseName(warehouse.getWarehouseName() + "--" + warehouse.getBrandName());
+        userApplyMachineDetailVO.setWarehousePhone(warehouse.getWarehousePhone());
+
+        //订单状态
+        String statusNo = EnumUtil.getFieldBy(MachineOrderStatusEnum::getDescription, MachineOrderStatusEnum::getType, order.getStatus());
+        userApplyMachineDetailVO.setStatusNo(statusNo);
+        //查询订单详情
+        List<KxsMachineApplyDetail> orderInfos = kxsMachineApplyDetailMapper.selectList(Wrappers.lambdaQuery(KxsMachineApplyDetail.class).eq(KxsMachineApplyDetail::getOrderId, order.getId()));
+        //兑换机申请
+        if(Objects.equals(order.getApplyType(), MachineOrderEnum.M_TYPE_SN.getType())){
+            List<String> snList = orderInfos.stream().map(KxsMachineApplyDetail::getTicketCode).toList();
+            userApplyMachineDetailVO.setSnList(snList);
+        }else{
+            //循环机申请
+            for (KxsMachineApplyDetail orderInfo : orderInfos) {
+                R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineById(orderInfo.getRecycleMachineId(), SecurityConstants.FROM_IN);
+                KxsMachine machine = RetOps.of(kxsMachineR)
+                        .getData()
+                        .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
+                //兑换机
+                if(Objects.equals(machine.getMachineType(), MachineTypeEnum.M_TYPE_SN.getType())){
+                    userApplyMachineDetailVO.getSnList().add(machine.getPosSn() + ":" + MachineTypeEnum.M_TYPE_SN.getDescription());
+                }else{
+                    userApplyMachineDetailVO.getSnList().add(machine.getPosSn() + ":" + MachineTypeEnum.M_TYPE_RE.getDescription());
+                }
+            }
+        }
+        return userApplyMachineDetailVO;
+    }
 
 }
 

+ 73 - 47
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineRecycleServiceImpl.java

@@ -3,9 +3,6 @@ package com.kxs.store.biz.service.impl;
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -23,6 +20,7 @@ import com.kxs.product.api.model.KxsMachine;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleConfirmDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleSubmitDTO;
 import com.kxs.store.api.dto.kxsapp.storeRecycle.StoreRecycleMachineListDTO;
+import com.kxs.store.api.dto.kxsapp.storeRecycle.UserReturnRecycleDTO;
 import com.kxs.store.api.model.KxsMachineRecycleInfo;
 import com.kxs.store.api.model.KxsWarehouse;
 import com.kxs.store.api.vo.kxsapp.storeRecycle.*;
@@ -35,10 +33,10 @@ import com.kxs.store.biz.mapper.KxsWarehouseMapper;
 import com.kxs.store.biz.service.KxsMachineRecycleService;
 import com.kxs.system.api.feign.RemoteUserMsgService;
 import com.kxs.system.api.model.KxsUserMsg;
-import com.kxs.system.api.model.SysPublicParam;
 import com.kxs.system.api.util.MsgTemplateUtil;
 import com.kxs.user.api.feign.RemoteKxsUserService;
 import com.kxs.user.api.model.KxsUser;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -77,20 +75,15 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
         long start = (page.getCurrent() - 1) * page.getSize();
         start = start < 0 ? 0L : start;
 
-        Long count = baseMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
-                .like(StrUtil.isNotBlank(param.getKeyword()), KxsMachineRecycle::getUserCode,
-                        param.getKeyword())
-                .eq(KxsMachineRecycle::getStatus, param.getStatus())
-                .eq(KxsMachineRecycle::getWarehouseUserId, param.getWarehouseUserId()));
-
         List<StoreRecycleMachineListVO> orderListVos = baseMapper.getByPage(start, page.getSize(), param);
+        orderListVos.parallelStream().forEach(item -> item.setTotalNumber(item.getSnList().size()));
         page.setRecords(orderListVos);
-        page.setTotal(count);
 
         return page;
     }
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R confirm(RecycleConfirmDTO param) {
 
@@ -99,8 +92,11 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
             return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
         }
         List<KxsMachineRecycleInfo> recycleInfos = kxsMachineRecycleInfoMapper.selectList(Wrappers.<KxsMachineRecycleInfo>lambdaQuery()
+                .eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
                 .eq(KxsMachineRecycleInfo::getOrderId, machineRecycle.getId()));
-
+        if(recycleInfos.isEmpty()){
+            return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
+        }
         for (KxsMachineRecycleInfo recycleInfo : recycleInfos) {
             if(param.getSnList().contains(recycleInfo.getPosSn())){
                 //远程查询机具号
@@ -126,17 +122,13 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
                 }
             }
         }
-        if(isComplete(recycleInfos)){
-            machineRecycle.setStatus(RecycleOrderEnum.RE_OVER.getType());
-            machineRecycle.setOperatingDate(LocalDateTime.now());
-            baseMapper.updateById(machineRecycle);
-        }
 
         return R.ok();
     }
 
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R cancel(RecycleConfirmDTO param) {
 
@@ -146,6 +138,7 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
             return R.failed(StoreErrorTypeEnum.DATA_ERROR.getDescription());
         }
         List<KxsMachineRecycleInfo> recycleInfos = kxsMachineRecycleInfoMapper.selectList(Wrappers.<KxsMachineRecycleInfo>lambdaQuery()
+                .eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
                 .eq(KxsMachineRecycleInfo::getOrderId, recycleOrder.getId()));
 
         for (KxsMachineRecycleInfo recycleInfo : recycleInfos) {
@@ -153,32 +146,25 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
                 recycleInfo.setStatus(RecycleOrderEnum.INFO_CANCEL.getType());
                 recycleInfo.setCancelTime(LocalDateTime.now());
                 kxsMachineRecycleInfoMapper.updateById(recycleInfo);
-            }
-        }
-        if(isComplete(recycleInfos)){
-            recycleOrder.setStatus(RecycleOrderEnum.RE_OVER.getType());
-            recycleOrder.setOperatingDate(LocalDateTime.now());
-            baseMapper.updateById(recycleOrder);
-        }
-        return R.ok();
-    }
 
-    /**
-     * 是否完成所有机具的操作
-     *
-     * @param recycleInfos 回收信息
-     * @return {@link Boolean}
-     */
-    private Boolean isComplete(List<KxsMachineRecycleInfo> recycleInfos){
+                //修改机具状态未可回收
+                R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineBySn(recycleInfo.getPosSn(), SecurityConstants.FROM_IN);
+                KxsMachine machine = RetOps.of(kxsMachineR)
+                        .getData()
+                        .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
+                machine.setStatus(MachineTypeEnum.STATUS_RECYCLE.getType());
 
-        for (KxsMachineRecycleInfo recycleInfo : recycleInfos) {
-            if (Objects.equals(recycleInfo.getStatus(), RecycleOrderEnum.INFO_UNCONFIRM.getType())) {
-                return Boolean.FALSE;
+                R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+                if(!booleanR.getData()){
+                    throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
+                }
             }
         }
-        return Boolean.TRUE;
+
+        return R.ok();
     }
 
+
     @Override
     public StoreRecycleDataVO recycleCount() {
 
@@ -187,20 +173,17 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
         StoreRecycleDataVO storeRecycleDataVO = new StoreRecycleDataVO();
 
         //待确认机具数量
-        Long recycleCount = baseMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
-                .eq(KxsMachineRecycle::getWarehouseUserId, userId)
-                .eq(KxsMachineRecycle::getStatus, 1));
-        storeRecycleDataVO.setRecycleCount(recycleCount.intValue());
+        Integer recycleCount = baseMapper.storeRecoverableData(userId.intValue(), 0);
+        storeRecycleDataVO.setRecycleCount(recycleCount);
         //已完成
-        Long recyclableCount = baseMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
-                .eq(KxsMachineRecycle::getWarehouseUserId, userId)
-                .eq(KxsMachineRecycle::getStatus, 2));
-        storeRecycleDataVO.setRecyclableCount(recyclableCount.intValue());
+        Integer recyclableCount = baseMapper.storeRecoverableData(userId.intValue(), 1);
+        storeRecycleDataVO.setRecyclableCount(recyclableCount);
 
         return storeRecycleDataVO;
     }
 
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R userSubmit(RecycleSubmitDTO param) {
 
@@ -225,7 +208,7 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
         //订单号
         Snowflake snowflake = IdUtil.getSnowflake(1, userId);
         long orderSn = snowflake.nextId();
-        machineRecycle.setOrderSn(String.valueOf(orderSn));
+        machineRecycle.setOrderSn("JJHS" + orderSn);
 
         machineRecycle.setUserId(userId.intValue());
         machineRecycle.setUsername(user.getUsername());
@@ -251,6 +234,12 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
             kxsMachineRecycleInfo.setBrandId(brand.getId());
             kxsMachineRecycleInfo.setRecycleEndTime(machine.getRecycleEndTime());
             kxsMachineRecycleInfoMapper.insert(kxsMachineRecycleInfo);
+
+            machine.setStatus(MachineTypeEnum.STATUS_RE_ON.getType());
+            R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+            if (!booleanR.getData()) {
+                throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
+            }
         }
         KxsUserMsg kxsUserMsg = MsgTemplateUtil.machineRecycleNote(param.getSnList(), brand.getName(), kxsWarehouse.getUserId(), user.getUserCode());
         remoteUserMsgService.pushUserMsg(kxsUserMsg, SecurityConstants.FROM_IN);
@@ -301,7 +290,44 @@ public class KxsMachineRecycleServiceImpl extends ServiceImpl<KxsMachineRecycleM
 
         recoverableDataVO.setNeedConfirmCount(count);
         recoverableDataVO.setRecoverableCount(recoverableCount);
-        return null;
+        return recoverableDataVO;
+    }
+
+    @Override
+    @GlobalTransactional
+    @Transactional(rollbackFor = Exception.class)
+    public R userReturnRecycle(UserReturnRecycleDTO userReturnRecycleDTO) {
+
+        userReturnRecycleDTO.getSnList().parallelStream().forEach(sn -> {
+            KxsMachineRecycleInfo recycleInfo = kxsMachineRecycleInfoMapper.selectOne(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
+                    .eq(KxsMachineRecycleInfo::getStatus, RecycleOrderEnum.INFO_UNCONFIRM.getType())
+                    .eq(KxsMachineRecycleInfo::getPosSn, sn));
+            if (recycleInfo == null) {
+                throw new GlobalCustomerException(sn + "机具已处理");
+            }
+            //删除回收机具
+            kxsMachineRecycleInfoMapper.deleteById(recycleInfo.getId());
+            //修改机具状态未可回收
+            R<KxsMachine> kxsMachineR = remoteKxsProductService.loadMachineBySn(sn, SecurityConstants.FROM_IN);
+            KxsMachine machine = RetOps.of(kxsMachineR)
+                    .getData()
+                    .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.SN_FIND_NULL.getDescription()));
+            machine.setStatus(MachineTypeEnum.STATUS_RECYCLE.getType());
+
+            R<Boolean> booleanR = remoteKxsProductService.updateByMachine(machine, SecurityConstants.FROM_IN);
+            if(!booleanR.getData()){
+                throw new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription());
+            }
+
+            //删除主订单
+            Long count = kxsMachineRecycleInfoMapper.selectCount(Wrappers.lambdaQuery(KxsMachineRecycleInfo.class)
+                    .eq(KxsMachineRecycleInfo::getOrderId, recycleInfo.getOrderId()));
+            if(count == 0){
+                baseMapper.deleteById(recycleInfo.getOrderId());
+            }
+        });
+
+        return R.ok();
     }
 
 

+ 20 - 11
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseLimitServiceImpl.java

@@ -24,7 +24,9 @@ import com.kxs.store.api.model.KxsWarehouseLimit;
 import com.kxs.store.biz.service.KxsWarehouseLimitService;
 import com.kxs.user.api.feign.RemoteKxsUserService;
 import com.kxs.user.api.model.KxsUser;
+import io.seata.core.context.RootContext;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
@@ -39,6 +41,7 @@ import java.util.Objects;
  */
 @Service("kxsWarehouseLimitService")
 @RequiredArgsConstructor
+@Slf4j
 public class KxsWarehouseLimitServiceImpl extends ServiceImpl<KxsWarehouseLimitMapper, KxsWarehouseLimit> implements KxsWarehouseLimitService {
 
     private final RemoteKxsUserService remoteKxsUserService;
@@ -90,15 +93,15 @@ public class KxsWarehouseLimitServiceImpl extends ServiceImpl<KxsWarehouseLimitM
 
         KxsWarehouseLimit kxsWarehouseLimit = baseMapper.selectOne(Wrappers.<KxsWarehouseLimit>lambdaQuery()
                 .eq(KxsWarehouseLimit::getUserId, userId)
-                .eq(KxsWarehouseLimit::getWarehouseType, WarehouseLimitTypeEnum.XFC.getType()));
+                .eq(KxsWarehouseLimit::getWarehouseType, WarehouseLimitTypeEnum.FC.getType()));
         WarehouseAmountVO warehouseAmountVO = new WarehouseAmountVO();
         BeanUtils.copyProperties(kxsWarehouseLimit, warehouseAmountVO);
         //统计为他人担保额度
         KxsWarehouseCreditAmount creditUserAmount = kxsWarehouseCreditAmountMapper.selectOne(Wrappers.query(KxsWarehouseCreditAmount.class)
-                .select("IFNULL(SUM(creditAmount), 0) as creditAmount")
+                .select("IFNULL(SUM(credit_amount), 0) as creditAmount")
                 .eq("credit_user_id", userId));
         warehouseAmountVO.setToCreditAmount(creditUserAmount.getCreditAmount());
-
+        warehouseAmountVO.setTotalAmount(NumberUtil.add(kxsWarehouseLimit.getCreditAmount(), kxsWarehouseLimit.getForAmount(), kxsWarehouseLimit.getFixedAmount()));
         return warehouseAmountVO;
     }
 
@@ -148,16 +151,22 @@ public class KxsWarehouseLimitServiceImpl extends ServiceImpl<KxsWarehouseLimitM
 
     }
 
+    @Override
+    public Boolean addUserAdvanceLimit(KxsWarehouseLimit kxsWarehouseLimit) {
 
+        //查询用户预发额度
+        KxsWarehouseLimit warehouseLimit = baseMapper.selectOne(Wrappers.<KxsWarehouseLimit>lambdaQuery()
+                .eq(KxsWarehouseLimit::getWarehouseType, WarehouseLimitTypeEnum.XFC.getType())
+                .eq(KxsWarehouseLimit::getUserId, kxsWarehouseLimit.getUserId()));
 
-
-
-
-
-
-
-
-
+        if(warehouseLimit == null){
+            kxsWarehouseLimit.setWarehouseType(WarehouseLimitTypeEnum.XFC.getType());
+            baseMapper.insert(kxsWarehouseLimit);
+        }else{
+            return Boolean.FALSE;
+        }
+        return Boolean.TRUE;
+    }
 
 
 }

+ 7 - 1
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseMachineApplyServiceImpl.java

@@ -1,6 +1,8 @@
 package com.kxs.store.biz.service.impl;
 
+import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.EnumUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -84,7 +86,7 @@ public class KxsWarehouseMachineApplyServiceImpl extends ServiceImpl<KxsWarehous
                     .getData()
                     .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.REMOTE_DATA_ERROR.getDescription()));
 
-            Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getType, kxsBrand.getBrandType());
+            Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(kxsBrand.getBrandType()));
             BigDecimal brandAmount = NumberUtil.mul(price, info.getNumber());
             useAmount = useAmount.add(brandAmount);
         }
@@ -95,9 +97,13 @@ public class KxsWarehouseMachineApplyServiceImpl extends ServiceImpl<KxsWarehous
             return R.failed(StoreErrorTypeEnum.INSUFFICIENT_QUOTA.getDescription());
         }
 
+        //订单号
+        Snowflake snowflake = IdUtil.getSnowflake(1, userId);
+        long orderSn = snowflake.nextId();
 
         KxsWarehouseMachineApply kxsWarehouseMachineApply = new KxsWarehouseMachineApply();
         kxsWarehouseMachineApply.setUserId(userId.intValue());
+        kxsWarehouseMachineApply.setOrderSn("FC" + orderSn);
         kxsWarehouseMachineApply.setApplyNum(param.getApplyNum());
         kxsWarehouseMachineApply.setUsername(user.getUsername());
         kxsWarehouseMachineApply.setUserCode(user.getUserCode());

+ 5 - 5
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseServiceImpl.java

@@ -11,6 +11,7 @@ import com.kxs.store.api.vo.kxsapp.store.StoreDataVO;
 import com.kxs.store.api.vo.kxsapp.store.StoreListVO;
 import com.kxs.store.api.vo.kxsapp.store.StoreSearchListVO;
 import com.kxs.store.biz.constant.enums.MachineOrderEnum;
+import com.kxs.store.biz.constant.enums.MachineOrderStatusEnum;
 import com.kxs.store.biz.mapper.*;
 import com.kxs.store.biz.service.KxsWarehouseService;
 import lombok.RequiredArgsConstructor;
@@ -55,7 +56,7 @@ public class KxsWarehouseServiceImpl extends ServiceImpl<KxsWarehouseMapper, Kxs
         StoreDataVO storeDataVO = new StoreDataVO();
         //待发货
         Long unSendCount = kxsMachineApplyMapper.selectCount(Wrappers.<KxsMachineApply>lambdaQuery()
-                .eq(KxsMachineApply::getStatus, MachineOrderEnum.UNDER_REVIEW.getType())
+                .eq(KxsMachineApply::getStatus, MachineOrderStatusEnum.UNDER_REVIEW.getType())
                 .eq(KxsMachineApply::getWarehouseId, warehouseId));
         storeDataVO.setUnSendCount(unSendCount.intValue());
 
@@ -69,10 +70,9 @@ public class KxsWarehouseServiceImpl extends ServiceImpl<KxsWarehouseMapper, Kxs
         storeDataVO.setPreMachineCount(preMachineCount.intValue());
 
         //待回收机具数量
-        Long recycleCount = kxsMachineRecycleMapper.selectCount(Wrappers.<KxsMachineRecycle>lambdaQuery()
-                .eq(KxsMachineRecycle::getWarehouseId, warehouseId)
-                .eq(KxsMachineRecycle::getStatus, 1));
-        storeDataVO.setRecycleCount(recycleCount.intValue());
+        KxsWarehouse warehouse = baseMapper.selectById(warehouseId);
+        Integer recycleCount = kxsMachineRecycleMapper.storeRecoverableData(warehouse.getUserId(), 0);
+        storeDataVO.setRecycleCount(recycleCount);
 
         return storeDataVO;
     }

+ 9 - 5
kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineAdvanceMapper.xml

@@ -30,9 +30,13 @@
 
     </select>
     <select id="getUserWareHouseList" resultType="com.kxs.store.api.vo.kxsapp.storeAdvance.UserWarehouseListVO">
-        SELECT user_id
-        FROM kxs_warehouse_user
-        where warehouse_user_id = #{userId}
+        select to_user_id as user_id
+        from (select to_user_id
+              from kxs_machine_advance
+              where del_flag = 0 and warehouse_id = #{userId}
+              group by to_user_id) as warehouse_user
+
+
     </select>
     <select id="selectUserByCount" resultType="java.lang.Long">
         select count(b.id)
@@ -72,7 +76,7 @@
             <result column="pos_sn" property="posSn"/>
         </collection>
     </resultMap>
-    <select id="selectToUserNeedConfirmList" resultType="com.kxs.store.api.vo.kxsapp.userAdvance.AdvanceDevModalVO">
+    <select id="selectToUserNeedConfirmList" resultMap="AdvanceDevModalMap">
 
         select a.id,
                a.brand_name,
@@ -111,7 +115,7 @@
           and a.to_user_id = #{userId}
           and b.is_apply = 0
           and b.is_return = 0
-          and b.is_confirm = 0
+          and b.is_confirm = 1
 
     </select>
     <select id="selectWarehouseUserCount" resultType="java.lang.Long">

+ 10 - 2
kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineApplyMapper.xml

@@ -11,6 +11,7 @@
         <result column="order_sn" property="orderSn" />
         <result column="user_id" property="userId" />
         <result column="brand_id" property="brandId" />
+        <result column="brand_name" property="brandName" />
         <result column="warehouse_id" property="warehouseId" />
         <result column="get_mode" property="getMode" />
         <result column="apply_num" property="applyNum" />
@@ -27,7 +28,7 @@
 
     </resultMap>
     <select id="getByPage" resultType="com.kxs.store.api.vo.kxsapp.storeOrder.StoreOrderListVO">
-        select a.id, a.create_time, a.order_sn, a.get_mode, a.apply_num, a.contacts, a.phone, a.address, a.applyType, a.status, a.username, a.user_code from where kxs_machine_apply a
+        select a.id, a.create_time, a.order_sn, a.get_mode, a.apply_num, a.contacts, a.phone, a.address, a.apply_type, a.status, a.username, a.user_code from kxs_machine_apply a
         <where>
             <if test="query.brandId != null">
                 and a.brand_id = #{query.brandId}
@@ -55,7 +56,7 @@
         </where>
         GROUP BY `month`
         ) as tmp
-        ORDER BY `date` desc
+        ORDER BY `month` desc
     </select>
     <select id="orderMonthTotalDetail" resultType="com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO">
         SELECT *
@@ -74,5 +75,12 @@
         ) AS tmp
         ORDER BY `date` desc
     </select>
+    <select id="userApplyMachineList" resultType="com.kxs.store.api.vo.kxsapp.userOrder.UserApplyMahineListVO">
+        select a.id, a.create_time, a.order_sn, a.apply_num, a.address, a.status from kxs_machine_apply a
+        <where>
+            and user_id = #{userId}
+        </where>
+        order by a.create_time desc
+    </select>
 
 </mapper>

+ 24 - 11
kxs-store/kxs-store-biz/src/main/resources/mapper/KxsMachineRecycleMapper.xml

@@ -15,8 +15,6 @@
         <result column="brand_id" property="brandId"/>
         <result column="brand_name" property="brandName"/>
         <result column="track_no" property="trackNo"/>
-        <result column="status" property="status"/>
-        <result column="operating_date" property="operatingDate"/>
         <result column="warehouse_user_id" property="warehouseUserId"/>
         <result column="username" property="username"/>
         <result column="user_code" property="userCode"/>
@@ -31,7 +29,6 @@
         <result column="brand_id" property="brandId"/>
         <result column="brand_name" property="brandName"/>
         <result column="track_no" property="trackNo"/>
-        <result column="status" property="status"/>
         <result column="order_sn" property="orderSn"/>
         <result column="operatingDate" property="operatingDate"/>
         <result column="username" property="username"/>
@@ -51,19 +48,19 @@
         <where>
             and del_flag = 0
             and warehouse_user_id = #{query.warehouseUserId}
-            <if test="query.status != null">
-                and status = #{query.status}
-            </if>
-            <if test="query.keyword != null and query.keyword != ''">
-                or user_code like concat('%',#{query.keyword},'%')
-            </if>
         </where>
         LIMIT #{start}, #{size}
         ) a
         LEFT JOIN kxs_machine_recycle_info t ON a.id = t.order_id
         <where>
+            <if test="query.status != null and query.status == 0">
+                and t.status = #{query.status}
+            </if>
+            <if test="query.status != null and query.status == 1">
+                and t.status in (1,2)
+            </if>
             <if test="query.keyword != null and query.keyword != ''">
-                or pos_sn like concat('%',#{query.keyword},'%')
+                and (t.pos_sn like concat('%',#{query.keyword},'%') or a.user_code like concat('%',#{query.keyword},'%'))
             </if>
         </where>
     </select>
@@ -100,6 +97,7 @@
         LEFT JOIN kxs_machine_recycle_info t ON a.id = t.order_id
         LEFT JOIN kxs_warehouse s ON a.warehouse_id = s.id
         <where>
+            and t.del_flag = 0
         </where>
     </select>
     <select id="needConfirmList" resultType="com.kxs.store.api.vo.kxsapp.storeRecycle.NeedConfirmRecycleVO">
@@ -112,7 +110,22 @@
         select count(*)
         from kxs_machine_recycle_info a
                  left join kxs_machine_recycle b on a.order_id = b.id
-        where b.user_id = #{userId} and a.status = 0
+        where b.user_id = #{userId} and a.status = 0 and a.del_flag = 0
+    </select>
+    <select id="storeRecoverableData" resultType="java.lang.Integer">
+        select count(*)
+        from kxs_machine_recycle_info a
+                 left join kxs_machine_recycle b on a.order_id = b.id
+        <where>
+            and a.del_flag = 0
+            and b.warehouse_user_id = #{warehouseUserId}
+            <if test="status == 0">
+                and a.status = #{status}
+            </if>
+            <if test="status == 1">
+                and a.status in (1,2)
+            </if>
+        </where>
     </select>
 
 </mapper>

+ 3 - 3
kxs-store/kxs-store-biz/src/main/resources/mapper/KxsWarehouseMapper.xml

@@ -35,12 +35,12 @@
         from kxs_warehouse a
         left join kxs_warehouse_stock stock on a.id = stock.warehouse_id
         <where>
-            a.del_flag = 0
+            and a.del_flag = 0
             <if test="query.brandId != null">
-                a.brand_id = #{query.brandId}
+                and a.brand_id = #{query.brandId}
             </if>
             <if test="query.keyword != null and query.keyword != ''">
-                a.warehouse_name like concat('%' #{query.keyword}, '%')
+                and a.warehouse_name like concat('%' #{query.keyword}, '%')
             </if>
         </where>
 

+ 5 - 0
kxs-system/kxs-system-api/pom.xml

@@ -44,5 +44,10 @@
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
         </dependency>
+        <!-- seata -->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-seata</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 7 - 0
kxs-system/kxs-system-api/src/main/java/com/kxs/system/api/feign/config/KxsSystemFeignClientConfiguration.java

@@ -3,6 +3,7 @@ package com.kxs.system.api.feign.config;
 import cn.hutool.core.text.CharSequenceUtil;
 import com.kxs.common.core.constant.ServiceNameConstants;
 import com.kxs.system.api.feign.*;
+import io.seata.core.context.RootContext;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -46,6 +47,12 @@ public class KxsSystemFeignClientConfiguration {
 			.filter((request, next) -> {
 				ClientRequest.Builder filtered = ClientRequest.from(request);
 
+				// seata XID传递
+				String xid = RootContext.getXID();
+				if (CharSequenceUtil.isNotBlank(xid)) {
+					filtered.header(RootContext.KEY_XID, xid);
+				}
+
 				ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
 					.getRequestAttributes();
 				// 不是web请求不传递token

+ 76 - 0
kxs-system/kxs-system-biz/pom.xml

@@ -85,9 +85,85 @@
 
     <build>
         <plugins>
+            <!--该插件的作用是打包spring-boot的jar包-->
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!--不排除的话,systemScope的依赖包会自动被此插件打包进xxx.jar\BOOT-INF\lib,和外部依赖产生冲突 -->
+                    <includeSystemScope>false</includeSystemScope>
+                    <skip>false</skip>
+                    <!--分离Jar包-->
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制依赖的jar包到指定的文件夹里 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib/</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 该插件的作用是复制指定的文件 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <!-- 复制配置文件 -->
+                    <execution>
+                        <id>copy-resources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <resources>
+                                <!--复制资源文件到外部,注意这里先不做filtering处理,防止某些静态文件损坏-->
+                                <resource>
+                                    <filtering>false</filtering>
+                                    <directory>src/main/resources</directory>
+                                    <includes>
+                                        <include>**/*</include>
+                                    </includes>
+                                </resource>
+                                <!--仅针对配置文件filtering处理(占位符@@等)-->
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                    <includes>
+                                        <include>*.xml</include>
+                                        <include>*.yml</include>
+                                        <include>*.properties</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                            <outputDirectory>${project.build.directory}/config</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>

+ 5 - 1
kxs-user/kxs-user-api/pom.xml

@@ -45,6 +45,10 @@
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
         </dependency>
-
+        <!-- seata -->
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-common-seata</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 7 - 0
kxs-user/kxs-user-api/src/main/java/com/kxs/user/api/feign/config/KxsUserFeignClientConfiguration.java

@@ -3,6 +3,7 @@ package com.kxs.user.api.feign.config;
 import cn.hutool.core.text.CharSequenceUtil;
 import com.kxs.common.core.constant.ServiceNameConstants;
 import com.kxs.user.api.feign.RemoteKxsUserService;
+import io.seata.core.context.RootContext;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -46,6 +47,12 @@ public class KxsUserFeignClientConfiguration {
 			.filter((request, next) -> {
 				ClientRequest.Builder filtered = ClientRequest.from(request);
 
+				// seata XID传递
+				String xid = RootContext.getXID();
+				if (CharSequenceUtil.isNotBlank(xid)) {
+					filtered.header(RootContext.KEY_XID, xid);
+				}
+
 				ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
 					.getRequestAttributes();
 				// 不是web请求不传递token

+ 4 - 0
kxs-user/kxs-user-biz/pom.xml

@@ -33,6 +33,10 @@
             <groupId>com.kxs</groupId>
             <artifactId>kxs-user-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.kxs</groupId>
+            <artifactId>kxs-store-api</artifactId>
+        </dependency>
         <!--core 工具类-->
         <dependency>
             <groupId>com.kxs</groupId>

+ 1 - 0
kxs-user/kxs-user-biz/src/main/java/com/kxs/user/biz/constant/enums/UserErrorTypeEnum.java

@@ -25,6 +25,7 @@ public enum UserErrorTypeEnum {
 	PARENT_IS_NULL(-1,"邀请人不存在"),
 	WITHDRAW_MAX(-1, "单笔提现金额不能超过50000"),
 	NOT_SUFFICIENT_FUNDS(-1, "可提现余额不足"),
+	USER_LIMIT_ERROR(-1, "用户预发额度初始化失败"),
 	CLIENT_NULL(-1, "客户端查询异常,请检查数据库链接");
 
 	private final int code;

+ 17 - 0
kxs-user/kxs-user-biz/src/main/java/com/kxs/user/biz/service/impl/KxsUserServiceImpl.java

@@ -1,5 +1,7 @@
 package com.kxs.user.biz.service.impl;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.text.CharSequenceUtil;
 import cn.hutool.core.util.IdcardUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -17,6 +19,8 @@ import com.kxs.common.core.exception.ValidateCodeException;
 import com.kxs.common.core.util.R;
 import com.kxs.common.core.util.SpringContextHolder;
 import com.kxs.common.security.util.SecurityUtils;
+import com.kxs.store.api.feign.RemoteKxsStoreService;
+import com.kxs.store.api.model.KxsWarehouseLimit;
 import com.kxs.system.api.feign.RemoteUserMsgService;
 import com.kxs.system.api.model.KxsUserMsg;
 import com.kxs.system.api.util.MsgTemplateUtil;
@@ -39,6 +43,8 @@ import com.kxs.user.biz.mapper.KxsUserBankMapper;
 import com.kxs.user.biz.mapper.KxsUserMapper;
 import com.kxs.user.biz.mapper.KxsUserRealMapper;
 import com.kxs.user.biz.service.KxsUserService;
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.cache.CacheManager;
@@ -82,10 +88,13 @@ public class KxsUserServiceImpl extends ServiceImpl<KxsUserMapper, KxsUser> impl
 
     private final KxsUserBankMapper kxsUserBankMapper;
 
+    private final RemoteKxsStoreService remoteKxsStoreService;
+
 
     private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
     
     @Override
+    @GlobalTransactional
     @Transactional(rollbackFor = Exception.class)
     public R register(RegisterDTO registerDTO) {
         
@@ -139,6 +148,14 @@ public class KxsUserServiceImpl extends ServiceImpl<KxsUserMapper, KxsUser> impl
         kxsUserAmount.setUserId(kxsUser.getId());
         userAmountMapper.insert(kxsUserAmount);
 
+        //初始化用户预发额度表
+        KxsWarehouseLimit kxsWarehouseLimit = new KxsWarehouseLimit();
+        kxsWarehouseLimit.setUserId(kxsUser.getId());
+        R<Boolean> booleanR = remoteKxsStoreService.addUserAdvanceLimit(kxsWarehouseLimit, SecurityConstants.FROM_IN);
+        if(!booleanR.getData()){
+            throw new GlobalCustomerException(UserErrorTypeEnum.USER_LIMIT_ERROR.getDescription());
+        }
+
         //发送个人消息
         KxsUserMsg kxsUserMsg = MsgTemplateUtil.newUserPush(inviteUser.getId());
         remoteUserMsgService.pushUserMsg(kxsUserMsg, SecurityConstants.FROM_IN);

+ 57 - 0
kxs-visual/kxs-seataServer/resources/application.yml

@@ -0,0 +1,57 @@
+server:
+  port: 7091
+
+spring:
+  application:
+    name: seata-server
+
+logging:
+  config: classpath:logback-spring.xml
+  file:
+    path: ${user.home}/logs/seata
+  extend:
+    logstash-appender:
+      destination: 127.0.0.1:4560
+    kafka-appender:
+      bootstrap-servers: 127.0.0.1:9092
+      topic: logback_to_logstash
+
+console:
+  user:
+    username: seata
+    password: seata
+
+seata:
+  config:
+    # support: nacos, consul, apollo, zk, etcd3
+    type: nacos
+    nacos:
+      server-addr: kxs-register:8848
+      namespace:
+      group: SEATA_GROUP
+      username: nacos
+      password: nacos
+      # nacos配置文件 data-id ,可以用yml(官方给的config.txt是properties 懒得改直接用.....)
+      data-id: seataServer.properties
+  registry:
+    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
+    type: nacos
+    preferred-networks: 30.240.*
+    nacos:
+      application: seata-server
+      server-addr: kxs-register:8848
+      group: SEATA_GROUP
+      namespace:
+      cluster: default
+      username: nacos
+      password: nacos
+  store:
+    # support: file 、 db 、 redis
+    mode: db
+  #  server:
+  #    service-port: 8091 #If not configured, the default is '${server.port} + 1000'
+  security:
+    secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
+    tokenValidityInMilliseconds: 1800000
+    ignore:
+      urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

+ 17 - 0
kxs-visual/pom.xml

@@ -0,0 +1,17 @@
+<?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>
+
+    <parent>
+        <groupId>com.kxs</groupId>
+        <artifactId>kxs-cloud</artifactId>
+        <version>1.1.0</version>
+    </parent>
+
+    <artifactId>kxs-visual</artifactId>
+    <packaging>pom</packaging>
+
+    <description>kxs 外置组件</description>
+</project>

+ 6 - 0
pom.xml

@@ -79,6 +79,7 @@
         <module>kxs-user</module>
         <module>kxs-store</module>
         <module>kxs-product</module>
+        <module>kxs-visual</module>
     </modules>
 
     <dependencyManagement>
@@ -215,6 +216,11 @@
                 <artifactId>kxs-common-mybatis</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.kxs</groupId>
+                <artifactId>kxs-common-seata</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.alibaba</groupId>
                 <artifactId>fastjson</artifactId>