yexianchao 2 mesi fa
commit
be2e5de906
100 ha cambiato i file con 5602 aggiunte e 0 eliminazioni
  1. 88 0
      .gitignore
  2. 2 0
      bat/custom.bat
  3. 2 0
      bat/globex.bat
  4. 2 0
      bat/manager.bat
  5. 2 0
      bat/model.bat
  6. 2 0
      bat/pay.bat
  7. 2 0
      bat/web.bat
  8. 150 0
      crm-activity/pom.xml
  9. 23 0
      crm-activity/src/main/java/com/crm/activity/CrmActivityApplication.java
  10. 46 0
      crm-activity/src/main/java/com/crm/activity/configuration/FeignConfiguration.java
  11. 26 0
      crm-activity/src/main/java/com/crm/activity/configuration/ThreadPoolConfig.java
  12. 47 0
      crm-activity/src/main/java/com/crm/activity/controller/ManualController.java
  13. 54 0
      crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceRankingCsController.java
  14. 30 0
      crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceRuleCsController.java
  15. 86 0
      crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceSignCsController.java
  16. 47 0
      crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceRankingMsController.java
  17. 30 0
      crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceRuleMsController.java
  18. 55 0
      crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceSignMsController.java
  19. 22 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/AccountInfoMapper.java
  20. 24 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceCalcMapper.java
  21. 38 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceRankingMapper.java
  22. 30 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceRuleMapper.java
  23. 28 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceSignMapper.java
  24. 17 0
      crm-activity/src/main/java/com/crm/activity/dao/mapper/TradePositionMapper.java
  25. 18 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceRankingRepository.java
  26. 14 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceRuleRepository.java
  27. 16 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceSignRepository.java
  28. 12 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/CustomInfoRepository.java
  29. 22 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginAssetManagementRepository.java
  30. 21 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginFirmOfferRepository.java
  31. 19 0
      crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginRepository.java
  32. 51 0
      crm-activity/src/main/java/com/crm/activity/enums/ActivityRaceType.java
  33. 86 0
      crm-activity/src/main/java/com/crm/activity/service/ActivityRaceRankingService.java
  34. 43 0
      crm-activity/src/main/java/com/crm/activity/service/ActivityRaceRuleService.java
  35. 30 0
      crm-activity/src/main/java/com/crm/activity/service/ActivityRaceSignService.java
  36. 278 0
      crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceRankingServiceImpl.java
  37. 79 0
      crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceRuleServiceImpl.java
  38. 306 0
      crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceSignServiceImpl.java
  39. 240 0
      crm-activity/src/main/java/com/crm/activity/task/ActivityRaceTask.java
  40. 10 0
      crm-activity/src/main/resources/application-dev.yml
  41. 33 0
      crm-activity/src/main/resources/application-ho.yml
  42. 13 0
      crm-activity/src/main/resources/application-hu.yml
  43. 16 0
      crm-activity/src/main/resources/application-prod.yml
  44. 18 0
      crm-activity/src/main/resources/application-test.yml
  45. 10 0
      crm-activity/src/main/resources/application.yml
  46. 57 0
      crm-activity/src/main/resources/logback-prod.xml
  47. 22 0
      crm-activity/src/main/resources/mapper/AccountInfoMapper.xml
  48. 57 0
      crm-activity/src/main/resources/mapper/ActivityRaceCalcMapper.xml
  49. 144 0
      crm-activity/src/main/resources/mapper/ActivityRaceRankingMapper.xml
  50. 60 0
      crm-activity/src/main/resources/mapper/ActivityRaceRuleMapper.xml
  51. 100 0
      crm-activity/src/main/resources/mapper/ActivityRaceSignMapper.xml
  52. 13 0
      crm-activity/src/main/resources/mapper/TradePositionMapper.xml
  53. 11 0
      crm-activity/src/test/java/com/crm/activity/CrmActivityApplicationTests.java
  54. 39 0
      crm-activity/src/test/java/com/crm/activity/task/ActivityRaceTaskTest.java
  55. 55 0
      crm-custom/custom_realse_shop_start.bat
  56. 23 0
      crm-custom/custom_shop.bat
  57. 52 0
      crm-custom/custom_shop_start.bat
  58. 30 0
      crm-custom/custom_start.bat
  59. 52 0
      crm-custom/custom_test_shop_start.bat
  60. 0 0
      crm-custom/pid.txt
  61. 154 0
      crm-custom/pom.xml
  62. 24 0
      crm-custom/src/main/java/com/crm/custom/CustomApplication.java
  63. 50 0
      crm-custom/src/main/java/com/crm/custom/configuration/FeignConfiguration.java
  64. 107 0
      crm-custom/src/main/java/com/crm/custom/controller/AccountApplyPasswordResetController.java
  65. 56 0
      crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceRankingController.java
  66. 32 0
      crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceRuleController.java
  67. 107 0
      crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceSignController.java
  68. 67 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomBankController.java
  69. 378 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomController.java
  70. 249 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomFileController.java
  71. 29 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomFirmOfferRollController.java
  72. 639 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomLoginController.java
  73. 47 0
      crm-custom/src/main/java/com/crm/custom/controller/CustomRecommendController.java
  74. 35 0
      crm-custom/src/main/java/com/crm/custom/controller/FinanceController.java
  75. 66 0
      crm-custom/src/main/java/com/crm/custom/controller/SysCountryController.java
  76. 36 0
      crm-custom/src/main/java/com/crm/custom/controller/SysReasonsRefusalController.java
  77. 49 0
      crm-custom/src/main/java/com/crm/custom/controller/WebVideoController.java
  78. 17 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomFileDao.java
  79. 26 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomInfoDao.java
  80. 16 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginAssetManagementMapper.java
  81. 14 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginDemoMapper.java
  82. 17 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginFirmOfferMapper.java
  83. 22 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginMapper.java
  84. 15 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomRecommendMapper.java
  85. 15 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomSurveyDao.java
  86. 10 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyAssetManagementRepository.java
  87. 10 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyDemoRepository.java
  88. 10 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyFirmOfferRepository.java
  89. 21 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyPasswordResetRepository.java
  90. 19 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyRepository.java
  91. 30 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomBankRepository.java
  92. 14 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFileHistoryRepository.java
  93. 27 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFileRepository.java
  94. 12 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFundHistoryRepository.java
  95. 108 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomInfoRepository.java
  96. 37 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginAssetManagementRepository.java
  97. 49 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginDemoRepository.java
  98. 37 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginFirmOfferRepository.java
  99. 15 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginHistoryRepository.java
  100. 33 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginRepository.java

+ 88 - 0
.gitignore

@@ -0,0 +1,88 @@
+/crm-custom/.idea
+/crm-custom/target
+/apache-activemq-5.9.1
+/Manager/ManagerMT4Dome/.vs
+/Manager/ManagerMT4Dome/Debug
+/Manager/ManagerMT4Real/.vs
+/Manager/ManagerMT5Dome/.vs
+/Manager/ManagerMT5Real/Debug32
+/Manager/ManagerMT5Real/.vs
+/.idea
+/crm-manager/target
+/Manager/ManagerMT4Real/Debug
+/Manager/libs/logs
+/crm-sms/crm-sms.iml
+/Manager/ManagerMT4Real/log-2020-04-15.log
+/Manager/ManagerMT4Real/Release
+/Manager/ManagerMT5Real/Release64
+/Manager/ManagerMT5Real/Release32
+crm-custom/com-crm-custom.iml
+crm-manager/com-crm-manager.iml
+/crm-pay/.idea
+/crm-pay/com-crm-pay.iml
+/crm-pay/target
+/Manager/log
+/Manager/ManagerMT4/Release
+/Manager/ManagerMT4/.vs
+/Manager/ManagerMT4/Debug
+/Manager/ManagerMT4/StdAfx.pch
+/Manager/ManagerMT5Real/Debug64/ManagerMT5Real.log
+/Manager/ManagerMT5Real/Debug64/ManagerMT5Real.tlog/CL.command.1.tlog
+/Manager/ManagerMT5Real/Debug64/ManagerMT5Real.tlog/ManagerMT5Real.lastbuildstate
+/Manager/ManagerMT5Real/Debug64/ManagerMT5Real.tlog/unsuccessfulbuild
+/Manager/ManagerMT5Real/Debug64/ManagerMT5Real64.Build.CppClean.log
+/Manager/ManagerMT5Real/Debug64/vc141.pdb
+/Manager/ManagerMT5Real/Release32.zip
+/Manager/ManagerMT5/.vs
+/Manager/ManagerMT5/Release32
+/Manager/ManagerMT5/Debug32
+/Manager/libs/news/35-news.dat
+/Manager/libs/symbols.raw
+/Manager/libs/symgroups.raw
+/crm-to-globex/crm-globex.iml
+/crm-core/upload
+/crm-core/front
+/crm-core/log
+/crm-activity/*.iml
+/crm-activity/target
+/log
+crm-data-transfer/src/test/java/com/crm/data/transfer/service/OrderingTest.java
+/crm-news/*.iml
+/crm-gateway/*.iml
+/crm-news/target
+/crm-gateway/target
+/crm-to-globex/*.iml
+/Manager/ManagerMT5/crmcrm-backManagerlibs/bases/CWGMarketsUK-Dev/config/*.dat
+/Manager/ManagerMT5/crmcrm-backManagerlibs/bases/Default/config/*.dat
+/Manager/ManagerMT5/crmcrm-backManagerlibs/logs/*.log
+/lib
+/crm-merchant/target
+/Manager/ManagerMT4-follow
+/crm-markets/com-crm-markets.iml
+/crm-markets/.idea
+/crm-markets/target
+/Manager/libs/mailbox
+/Manager/libs/news
+/crm-eureka/eureka-server.iml
+/crm-eureka/.idea
+/crm-eureka/target
+/crm-manager/.idea
+/crm-manager/upload
+/crm-web/target
+/IP2LOCATION-LITE-DB3.BIN
+crm-activity/HELP.md
+crm-activity/mvnw
+crm-activity/mvnw.cmd
+crm-activity/.mvn/wrapper/maven-wrapper.jar
+crm-activity/.mvn/wrapper/maven-wrapper.properties
+crm-web/com-crm-web.iml
+/download
+/IP2LOCATION-LITE-DB.BIN
+IP2LOCATION-LITE-DB5.BIN/202304/IP2LOCATION-LITE-DB5.BIN
+IP2LOCATION-LITE-DB5.BIN/202304/LICENSE_LITE.TXT
+IP2LOCATION-LITE-DB5.BIN/202304/README_LITE.TXT
+IP2LOCATION-LITE-DB5.BIN/202305/LICENSE_LITE.TXT
+IP2LOCATION-LITE-DB5.BIN/202305/README_LITE.TXT
+IP2LOCATION-LITE-DB5.BIN/202307/IP2LOCATION-LITE-DB5.BIN
+IP2LOCATION-LITE-DB5.BIN/202307/LICENSE_LITE.TXT
+IP2LOCATION-LITE-DB5.BIN/202307/README_LITE.TXT

+ 2 - 0
bat/custom.bat

@@ -0,0 +1,2 @@
+cd ../crm-custom
+mvn clean install -DskipTests

+ 2 - 0
bat/globex.bat

@@ -0,0 +1,2 @@
+cd ../crm-to-globex
+mvn clean install -DskipTests

+ 2 - 0
bat/manager.bat

@@ -0,0 +1,2 @@
+cd ../crm-manager
+mvn clean install -DskipTests

+ 2 - 0
bat/model.bat

@@ -0,0 +1,2 @@
+cd ../crm-model
+mvn clean install -DskipTests

+ 2 - 0
bat/pay.bat

@@ -0,0 +1,2 @@
+cd ../crm-pay
+mvn clean install -DskipTests

+ 2 - 0
bat/web.bat

@@ -0,0 +1,2 @@
+cd ../crm-web
+mvn clean install -DskipTests

+ 150 - 0
crm-activity/pom.xml

@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.8.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.crm.activity</groupId>
+    <artifactId>crm-activity</artifactId>
+    <version>1.0.0</version>
+    <name>crm-activity</name>
+    <description>Demo project for Spring Boot</description>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <spring-cloud.version>Dalston.SR5</spring-cloud.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.crm.login.backend</groupId>
+            <artifactId>crm-login-backend</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.crm.model</groupId>
+            <artifactId>crm-model</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!--mybatis-->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.3.1</version>
+        </dependency>
+
+        <!--Spring Cloud-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-feign</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring-cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <outputDirectory>
+                        ${project.build.directory}/../../lib
+                    </outputDirectory>
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>com.crm.activity</groupId>
+                            <artifactId>crm-activity</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.mybatis.generator</groupId>
+                <artifactId>mybatis-generator-maven-plugin</artifactId>
+                <version>1.3.5</version>
+            </plugin>
+        </plugins>
+    </build>
+
+    <repositories>
+        <repository>
+            <id>spring-snapshots</id>
+            <name>Spring Snapshots</name>
+            <url>https://repo.spring.io/snapshot</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>spring-milestones</id>
+            <name>Spring Milestones</name>
+            <url>https://repo.spring.io/milestone</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <pluginRepositories>
+        <pluginRepository>
+            <id>spring-snapshots</id>
+            <name>Spring Snapshots</name>
+            <url>https://repo.spring.io/snapshot</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+        <pluginRepository>
+            <id>spring-milestones</id>
+            <name>Spring Milestones</name>
+            <url>https://repo.spring.io/milestone</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </pluginRepository>
+    </pluginRepositories>
+
+</project>

+ 23 - 0
crm-activity/src/main/java/com/crm/activity/CrmActivityApplication.java

@@ -0,0 +1,23 @@
+package com.crm.activity;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableScheduling
+@MapperScan("com.crm.activity.dao.mapper")
+@EnableEurekaClient
+@EnableFeignClients
+@EntityScan({"com.crm.rely.backend.core.pojo.table","com.crm.rely.backend.model.pojo.table"})
+public class CrmActivityApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(CrmActivityApplication.class, args);
+    }
+
+}

+ 46 - 0
crm-activity/src/main/java/com/crm/activity/configuration/FeignConfiguration.java

@@ -0,0 +1,46 @@
+package com.crm.activity.configuration;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.service.RedisService;
+import com.crm.rely.backend.util.UUIDUtil;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by max on 2020/6/17.
+ */
+@Configuration
+public class FeignConfiguration implements RequestInterceptor {
+
+    @Autowired
+    private RedisService redisService;
+    
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (null != attributes) {
+
+            String feignToken = UUIDUtil.getUUID();
+
+            HttpServletRequest request = attributes.getRequest();
+            String token = request.getHeader(Constants.ACCESS_TOKEN);
+            String language = request.getHeader(Constants.Language);
+            requestTemplate.header(Constants.ACCESS_TOKEN, token);
+            requestTemplate.header(Constants.Feign_Token, feignToken);
+            requestTemplate.header(Constants.Language, language);
+
+            try {
+                redisService.saveObject(feignToken, token, Constants.Feign_Token_TIME);
+            } catch (ServiceException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 26 - 0
crm-activity/src/main/java/com/crm/activity/configuration/ThreadPoolConfig.java

@@ -0,0 +1,26 @@
+package com.crm.activity.configuration;
+
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by max on 2020/6/18.
+ */
+@Component
+public class ThreadPoolConfig {
+
+    @Bean
+    public ListeningExecutorService listeningExecutorService() {
+        ThreadPoolExecutor threadPoolExecutor =
+                new ThreadPoolExecutor(4, 8, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
+
+        return MoreExecutors.listeningDecorator(threadPoolExecutor);
+    }
+
+}

+ 47 - 0
crm-activity/src/main/java/com/crm/activity/controller/ManualController.java

@@ -0,0 +1,47 @@
+package com.crm.activity.controller;
+
+import com.crm.activity.service.ActivityRaceRankingService;
+import com.crm.activity.task.ActivityRaceTask;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @ClassName ManualController
+ * @Description
+ * @Author y
+ * @Date 2022/8/5 10:14
+ */
+@RestController
+@RequestMapping("/manual")
+public class ManualController {
+
+    @Autowired
+    private ActivityRaceRankingService activityRaceRankingService;
+    @Autowired
+    private ActivityRaceTask activityRaceTask;
+
+    @GetMapping("/reOrder/{ruleId}")
+    public String reOrder(@PathVariable("ruleId") Long ruleId){
+        try {
+            activityRaceRankingService.reOrderRanking(ruleId);
+            return Constants.SUCCESS;
+        }catch (Exception e){
+            return e.getMessage();
+        }
+    }
+
+    @GetMapping("/ranking/{ruleId}")
+    public String ranking(@PathVariable("ruleId") Long ruleId){
+        try {
+            ActivityRaceRuleTable raceRuleTable = new ActivityRaceRuleTable();
+            raceRuleTable.setId(ruleId);
+            activityRaceTask.calcRuleProfit(raceRuleTable);
+            return Constants.SUCCESS;
+        }catch (Exception e){
+            return e.getMessage();
+        }
+    }
+
+}

+ 54 - 0
crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceRankingCsController.java

@@ -0,0 +1,54 @@
+package com.crm.activity.controller.custom;
+
+import com.crm.activity.service.ActivityRaceRankingService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 比赛排名api
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/custom/service/activity/race/ranking")
+public class ActivityRaceRankingCsController {
+
+    @Autowired
+    private ActivityRaceRankingService activityRaceRankingService;
+
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceRankingDto>> searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
+        entity.setHide(true);
+        return activityRaceRankingService.searchList(entity);
+    }
+
+    @PostMapping("/search/list/cover")
+    public BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>> searchListCover(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
+        entity.setHide(true);
+        return activityRaceRankingService.searchProfitCoverList(entity);
+    }
+
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceRankingDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceRankingService.getById(entity.getId()));
+    }
+
+    @PostMapping("/search/my")
+    public BaseResultDto<ActivityRaceRankingDto> searchMy(@RequestBody ActivityRaceRankingMyEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceRankingService.searchCustomRankingInfo(entity));
+    }
+
+}

+ 30 - 0
crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceRuleCsController.java

@@ -0,0 +1,30 @@
+package com.crm.activity.controller.custom;
+
+import com.crm.activity.service.ActivityRaceRuleService;
+import com.crm.rely.backend.core.dto.base.BaseLongSelectDto;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRuleDropDownEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/custom/service/activity/race/rule")
+public class ActivityRaceRuleCsController {
+
+    @Autowired
+    private ActivityRaceRuleService activityRaceRuleService;
+
+    @PostMapping("/dropdown")
+    public BaseResultDto<List<BaseLongSelectDto>> dropdown(@RequestBody ActivityRaceRuleDropDownEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceRuleService.getDropDownForCustomByType(entity.getCustomId(), entity.getRaceType()));
+    }
+}

+ 86 - 0
crm-activity/src/main/java/com/crm/activity/controller/custom/ActivityRaceSignCsController.java

@@ -0,0 +1,86 @@
+package com.crm.activity.controller.custom;
+
+import com.crm.activity.service.ActivityRaceSignService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceSignInfoDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignAddEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignInfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignLoginEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 比赛报名api
+ *
+ * @author y
+ * @create 2022/7/19
+ */
+@RestController
+@RequestMapping("/custom/service/activity/race/sign")
+public class ActivityRaceSignCsController {
+
+    @Autowired
+    private ActivityRaceSignService activityRaceSignService;
+
+    /**
+     * 添加报名
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/add")
+    public BaseResultDto<Boolean> add(@RequestBody ActivityRaceSignAddEntity entity) throws Exception {
+        activityRaceSignService.add(entity);
+        return BaseResultDto.success(true);
+    }
+
+    /**
+     * 最近一次报名信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/recent")
+    public BaseResultDto<ActivityRaceSignInfoDto> info(@RequestBody ActivityRaceSignInfoEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceSignService.info(entity));
+    }
+
+    /**
+     * 根据ID获取报名信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceSignInfoDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceSignService.searchById(entity.getId()));
+    }
+
+    /**
+     * 报名列表
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceSignInfoDto>> searchList(@RequestBody ActivityRaceSignListEntity entity) throws Exception {
+        return activityRaceSignService.searchList(entity);
+    }
+
+    @PostMapping("/logins")
+    public BaseResultDto<List<Long>> logins(@RequestBody ActivityRaceSignLoginEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceSignService.getLogins(entity));
+    }
+}

+ 47 - 0
crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceRankingMsController.java

@@ -0,0 +1,47 @@
+package com.crm.activity.controller.manager;
+
+import com.crm.activity.service.ActivityRaceRankingService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingManualEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/manager/service/activity/race/ranking")
+public class ActivityRaceRankingMsController {
+
+    @Autowired
+    private ActivityRaceRankingService activityRaceRankingService;
+
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceRankingDto>> searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
+        entity.setHide(false);
+        return activityRaceRankingService.searchList(entity);
+    }
+
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceRankingDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceRankingService.getById(entity.getId()));
+    }
+
+    @PostMapping("/update/manual")
+    public BaseResultDto<Boolean> updateManual(@RequestBody ActivityRaceRankingManualEntity entity) throws Exception {
+        activityRaceRankingService.updateManual(entity);
+        return BaseResultDto.success(true);
+    }
+
+}

+ 30 - 0
crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceRuleMsController.java

@@ -0,0 +1,30 @@
+package com.crm.activity.controller.manager;
+
+import com.crm.activity.service.ActivityRaceRuleService;
+import com.crm.rely.backend.core.dto.base.BaseLongSelectDto;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRuleDropDownEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/manager/service/activity/race/rule")
+public class ActivityRaceRuleMsController {
+
+    @Autowired
+    private ActivityRaceRuleService activityRaceRuleService;
+
+    @PostMapping("/dropdown")
+    public BaseResultDto<List<BaseLongSelectDto>> dropdown(@RequestBody ActivityRaceRuleDropDownEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceRuleService.getAllDropDownByType(entity.getRaceType()));
+    }
+}

+ 55 - 0
crm-activity/src/main/java/com/crm/activity/controller/manager/ActivityRaceSignMsController.java

@@ -0,0 +1,55 @@
+package com.crm.activity.controller.manager;
+
+import com.crm.activity.service.ActivityRaceSignService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceSignInfoDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignAddEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignInfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 比赛报名api
+ *
+ * @author y
+ * @create 2022/7/19
+ */
+@RestController
+@RequestMapping("/manager/service/activity/race/sign")
+public class ActivityRaceSignMsController {
+
+    @Autowired
+    private ActivityRaceSignService activityRaceSignService;
+
+    /**
+     * 根据ID获取报名信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceSignInfoDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return BaseResultDto.success(activityRaceSignService.searchById(entity.getId()));
+    }
+
+    /**
+     * 报名列表
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceSignInfoDto>> searchList(@RequestBody ActivityRaceSignListEntity entity) throws Exception {
+        return activityRaceSignService.searchList(entity);
+    }
+}

+ 22 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/AccountInfoMapper.java

@@ -0,0 +1,22 @@
+package com.crm.activity.dao.mapper;
+
+import com.crm.rely.backend.model.pojo.view.AccountInfoView;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 交易账户
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@Component
+public interface AccountInfoMapper {
+
+    AccountInfoView findByLogin(@Param("login") Long login, @Param("platform") String platform);
+
+    List<AccountInfoView> findAllByLoginIn(@Param("logins") List<Long> logins, @Param("platform") String platform);
+
+}

+ 24 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceCalcMapper.java

@@ -0,0 +1,24 @@
+package com.crm.activity.dao.mapper;
+
+import com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/22
+ */
+@Component
+public interface ActivityRaceCalcMapper {
+
+    List<ActivityRaceCalcView> findAllByRuleId(@Param("ruleId") Long ruleId, @Param("platform") String platform);
+
+    List<ActivityRaceCalcView> findAccountAndDwInfoByRuleId(@Param("ruleId") Long ruleId, @Param("platform") String platform);
+
+    List<ActivityRaceCalcView> findCloseTradeByRuleId(@Param("ruleId") Long ruleId, @Param("platform") String platform);
+
+    List<ActivityRaceCalcView> findOpenTradeByRuleId(@Param("ruleId") Long ruleId, @Param("platform") String platform);
+
+}

+ 38 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceRankingMapper.java

@@ -0,0 +1,38 @@
+package com.crm.activity.dao.mapper;
+
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;
+import com.crm.rely.backend.model.pojo.view.ActivityRaceRankingView;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Component
+public interface ActivityRaceRankingMapper {
+
+    Integer countList(ActivityRaceRankingListEntity entity);
+
+    List<ActivityRaceRankingView> getList(ActivityRaceRankingListEntity entity);
+
+    ActivityRaceRankingView getViewById(Long id);
+
+    ActivityRaceRankingTable getById(Long id);
+
+    List<ActivityRaceRankingTable> getAllByRaceTypeAndSerial(@Param("raceType") Integer raceType, @Param("serial") Integer serial);
+
+    void batchUpdateRank(List<ActivityRaceRankingTable> tables);
+
+    void updateById(ActivityRaceRankingTable table);
+
+    ActivityRaceRankingView getViewByCustomIdAndRuleId(@Param("customId") Long customId,@Param("ruleId") Long ruleId);
+
+    void batchUpdateProfit(List<ActivityRaceRankingTable> tables);
+
+    List<ActivityRaceRankingTable> getAllByRuleId(Long ruleId);
+
+}

+ 30 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceRuleMapper.java

@@ -0,0 +1,30 @@
+package com.crm.activity.dao.mapper;
+
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/19
+ */
+@Component
+public interface ActivityRaceRuleMapper {
+
+    ActivityRaceRuleTable findFirstBySignDateBtAndType(@Param("signDate") Date signDate, @Param("raceType") Integer raceType);
+
+    List<ActivityRaceRuleTable> findAllLimitedByRaceType(@Param("raceType") Integer raceType, @Param("limit") Integer limit);
+
+    ActivityRaceRuleTable getById(Long id);
+
+    ActivityRaceRuleTable findByCustomIdAndRaceTypeAndSerial(@Param("raceType") Integer raceType, @Param("serial") Integer serial);
+
+    Integer getMaxSerialByRaceType(Integer raceType);
+
+    List<ActivityRaceRuleTable> findAllByDateBt(Date date);
+
+    Integer countByStartDateAndEndDateAndRaceType(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("raceType") Integer raceType);
+}

+ 28 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/ActivityRaceSignMapper.java

@@ -0,0 +1,28 @@
+package com.crm.activity.dao.mapper;
+
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceSignTable;
+import com.crm.rely.backend.model.pojo.view.ActivityRaceSignView;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/19
+ */
+@Component
+public interface ActivityRaceSignMapper {
+
+    ActivityRaceSignView findFirstByCustomIdAndRaceType(@Param("customId") Long customId, @Param("raceType") Integer raceType);
+
+    Integer countList(ActivityRaceSignListEntity entity);
+
+    List<ActivityRaceSignView> getList(ActivityRaceSignListEntity entity);
+
+    ActivityRaceSignView findViewById(Long id);
+
+    List<ActivityRaceSignTable> findValidSignByCustomIdAndDate(@Param("customId") Long customId, @Param("date") Date date);
+}

+ 17 - 0
crm-activity/src/main/java/com/crm/activity/dao/mapper/TradePositionMapper.java

@@ -0,0 +1,17 @@
+package com.crm.activity.dao.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+/**
+ * 持仓持久层
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@Component
+public interface TradePositionMapper {
+
+    Integer countByLogin(@Param("login") Long login, @Param("platform") String platform);
+
+}

+ 18 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceRankingRepository.java

@@ -0,0 +1,18 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Repository
+public interface ActivityRaceRankingRepository extends BaseRepository<ActivityRaceRankingTable> {
+
+    List<ActivityRaceRankingTable> findAllByRuleId(Long ruleId);
+
+}

+ 14 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceRuleRepository.java

@@ -0,0 +1,14 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * @author y
+ * @create 2022/7/22
+ */
+@Repository
+public interface ActivityRaceRuleRepository extends BaseRepository<ActivityRaceRuleTable> {
+}

+ 16 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/ActivityRaceSignRepository.java

@@ -0,0 +1,16 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceSignTable;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author y
+ * @create 2022/7/19
+ */
+@Repository
+public interface ActivityRaceSignRepository extends BaseRepository<ActivityRaceSignTable> {
+
+    Integer countByRuleIdAndCustomIdAndRaceType(Long ruleId, Long customId, Integer raceType);
+
+}

+ 12 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/CustomInfoRepository.java

@@ -0,0 +1,12 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CustomInfoRepository extends BaseRepository<CustomInfoTable> {
+
+
+
+}

+ 22 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginAssetManagementRepository.java

@@ -0,0 +1,22 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginAssetManagementTable;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Repository
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@Repository
+public interface CustomLoginAssetManagementRepository extends BaseRepository<CustomLoginAssetManagementTable> {
+
+    CustomLoginAssetManagementTable findFirstByLogin(Long login);
+
+    List<CustomLoginAssetManagementTable> findAllByCustomId(Long customId);
+
+}

+ 21 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginFirmOfferRepository.java

@@ -0,0 +1,21 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Repository
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@Repository
+public interface CustomLoginFirmOfferRepository extends BaseRepository<CustomLoginFirmOfferTable> {
+
+    CustomLoginFirmOfferTable findFirstByLogin(Long login);
+
+    List<CustomLoginFirmOfferTable> findAllByCustomId(Long customId);
+}

+ 19 - 0
crm-activity/src/main/java/com/crm/activity/dao/repository/CustomLoginRepository.java

@@ -0,0 +1,19 @@
+package com.crm.activity.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginTable;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Repository
+public interface CustomLoginRepository extends BaseRepository<CustomLoginTable> {
+
+    CustomLoginTable findFirstByLogin(Long login);
+
+    List<CustomLoginTable> findAllByCustomId(Long customId);
+}

+ 51 - 0
crm-activity/src/main/java/com/crm/activity/enums/ActivityRaceType.java

@@ -0,0 +1,51 @@
+package com.crm.activity.enums;
+
+/**
+ * 比赛类型
+ *
+ * @author y
+ * @create 2022/1/9
+ */
+public enum ActivityRaceType {
+
+    WEEKLY(1, "周赛"),
+    MONTHLY(2, "月赛");
+
+    //目标检测类样本、目标变化检测类样本、设施变化检测类样本 、其他
+
+
+    private final Integer code;
+    private final String desc;
+
+    ActivityRaceType(Integer code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public static ActivityRaceType matchCode(String code) {
+        for (ActivityRaceType type : ActivityRaceType.values()) {
+            if (type.getCode().equals(code)) {
+                return type;
+            }
+        }
+        return null;
+    }
+
+    public static String matchDesc(Integer code) {
+        for (ActivityRaceType type : ActivityRaceType.values()) {
+            if (type.getCode().equals(code)) {
+                return type.getDesc();
+            }
+        }
+        return null;
+    }
+
+}

+ 86 - 0
crm-activity/src/main/java/com/crm/activity/service/ActivityRaceRankingService.java

@@ -0,0 +1,86 @@
+package com.crm.activity.service;
+
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingManualEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 排名服务接口
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+public interface ActivityRaceRankingService {
+
+    /**
+     * 列表信息
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    BaseResultWithPagerDto<List<ActivityRaceRankingDto>> searchList(ActivityRaceRankingListEntity entity) throws Exception;
+
+    /**
+     * 根据ID获取信息
+     * @param id
+     * @return
+     * @throws Exception
+     */
+    ActivityRaceRankingDto getById(Long id) throws Exception;
+
+    /**
+     * 重排序
+     * @param ruleId
+     */
+    void reOrderRanking(Long ruleId) throws Exception;
+
+    /**
+     * 手动添加盈利金额
+     * @param entity
+     */
+    void updateManual(ActivityRaceRankingManualEntity entity) throws Exception;
+
+    /**
+     * 查询客户排名信息
+     * @param entity
+     * @return
+     */
+    ActivityRaceRankingDto searchCustomRankingInfo(ActivityRaceRankingMyEntity entity) throws Exception;
+
+    /**
+     * 获取规则内所有排名map信息
+     * @param ruleId
+     * @return
+     * @throws Exception
+     */
+    Map<Long, ActivityRaceRankingTable> mapAllByRuleId(Long ruleId) throws Exception;
+
+    /**
+     * 保存计算结果
+     * @param tables
+     * @throws Exception
+     */
+    void updateCalcResult(List<ActivityRaceRankingTable> tables) throws Exception;
+
+    /**
+     * 重新排名
+     * @param tables
+     * @return
+     */
+    List<ActivityRaceRankingTable> reOrderRanking(List<ActivityRaceRankingTable> tables);
+
+    /**
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>> searchProfitCoverList(ActivityRaceRankingListEntity entity) throws Exception;
+}

+ 43 - 0
crm-activity/src/main/java/com/crm/activity/service/ActivityRaceRuleService.java

@@ -0,0 +1,43 @@
+package com.crm.activity.service;
+
+import com.crm.rely.backend.core.dto.base.BaseLongSelectDto;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 活动规则记录服务
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+public interface ActivityRaceRuleService {
+
+    List<BaseLongSelectDto> getAllDropDownByType(Integer raceType) throws Exception;
+
+    List<BaseLongSelectDto> getDropDownForCustomByType(Long customId, Integer raceType) throws Exception;
+
+    Integer getNextSerialByRaceType(Integer raceType) throws Exception;
+
+    void saveTable(ActivityRaceRuleTable table) throws Exception;
+
+    /**
+     * 根据时间查询当前需要计算的规则
+     *
+     * @param date
+     * @return
+     * @throws Exception
+     */
+    List<ActivityRaceRuleTable> findAllCaleRule(Date date) throws Exception;
+
+    /**
+     * 根据开始结束时间、规则类型判断是否存在规则
+     * @param startDate
+     * @param endDate
+     * @param raceType
+     * @return
+     */
+    Boolean existsByDate(Date startDate, Date endDate, Integer raceType);
+
+}

+ 30 - 0
crm-activity/src/main/java/com/crm/activity/service/ActivityRaceSignService.java

@@ -0,0 +1,30 @@
+package com.crm.activity.service;
+
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceSignInfoDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignAddEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignInfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignLoginEntity;
+
+import java.util.List;
+
+/**
+ * 周比赛服务接口
+ *
+ * @author y
+ * @create 2022/7/19
+ */
+public interface ActivityRaceSignService {
+
+    void add(ActivityRaceSignAddEntity entity) throws Exception;
+
+    ActivityRaceSignInfoDto info(ActivityRaceSignInfoEntity entity) throws Exception;
+
+    ActivityRaceSignInfoDto searchById(Long id) throws Exception;
+
+    BaseResultWithPagerDto<List<ActivityRaceSignInfoDto>> searchList(ActivityRaceSignListEntity entity) throws Exception;
+
+    List<Long> getLogins(ActivityRaceSignLoginEntity entity) throws Exception;
+
+}

+ 278 - 0
crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceRankingServiceImpl.java

@@ -0,0 +1,278 @@
+package com.crm.activity.service.impl;
+
+import com.crm.activity.dao.mapper.ActivityRaceRankingMapper;
+import com.crm.activity.dao.mapper.ActivityRaceRuleMapper;
+import com.crm.activity.dao.repository.ActivityRaceRankingRepository;
+import com.crm.activity.dao.repository.CustomInfoRepository;
+import com.crm.activity.enums.ActivityRaceType;
+import com.crm.activity.service.ActivityRaceRankingService;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.dto.base.PageDto;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingManualEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import com.crm.rely.backend.model.pojo.view.ActivityRaceRankingView;
+import com.crm.rely.backend.util.FormatPage;
+import com.crm.rely.backend.util.NameUtil;
+import com.crm.rely.backend.util.RexUtil;
+import com.crm.rely.backend.util.StringUtil;
+import com.google.common.collect.Maps;
+import org.apache.commons.compress.utils.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Service
+public class ActivityRaceRankingServiceImpl implements ActivityRaceRankingService {
+
+    private final Logger logger = LoggerFactory.getLogger(ActivityRaceRankingServiceImpl.class);
+
+    @Autowired
+    private ActivityRaceRankingMapper activityRaceRankingMapper;
+    @Autowired
+    private ActivityRaceRuleMapper activityRaceRuleMapper;
+    @Autowired
+    private ActivityRaceRankingRepository activityRaceRankingRepository;
+    @Autowired
+    private CustomInfoRepository customInfoRepository;
+
+    @Override
+    public BaseResultWithPagerDto<List<ActivityRaceRankingDto>> searchList(ActivityRaceRankingListEntity entity) throws Exception {
+
+        Integer count = activityRaceRankingMapper.countList(entity);
+        if (count == null || count == 0) {
+            return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS);
+        }
+
+        PageDto pageDto = FormatPage.format(entity.getPage(), count);
+
+        List<ActivityRaceRankingView> views = activityRaceRankingMapper.getList(entity);
+        List<ActivityRaceRankingDto> dtos = Lists.newArrayList();
+        for (ActivityRaceRankingView view : views) {
+            dtos.add(convertViewToDtoBySecret(view, entity.isHide()));
+        }
+
+        return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS, dtos, pageDto);
+    }
+
+    @Override
+    public ActivityRaceRankingDto getById(Long id) throws Exception {
+        ActivityRaceRankingView view = activityRaceRankingMapper.getViewById(id);
+        if (view == null) {
+            return null;
+        }
+        return convertViewToDto(view);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void reOrderRanking(Long ruleId) throws Exception {
+        List<ActivityRaceRankingTable> all = activityRaceRankingMapper.getAllByRuleId(ruleId);
+        all = reOrderRanking(all);
+        //保存排名
+        activityRaceRankingMapper.batchUpdateRank(all);
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateManual(ActivityRaceRankingManualEntity entity) throws Exception {
+        ActivityRaceRankingTable table = activityRaceRankingMapper.getById(entity.getId());
+        if (table == null) {
+            return;
+        }
+        //保存手动处理金额,重新计算profit
+        table.setManual(table.getManual() + entity.getAmount());
+        table.setProfit(table.getEndEquity() - table.getStartEquity() - table.getDw() + table.getManual());
+        activityRaceRankingMapper.updateById(table);
+        //重新排序
+        ActivityRaceRuleTable raceRuleTable = activityRaceRuleMapper.getById(table.getRuleId());
+        if (raceRuleTable == null) {
+            throw new ServiceException("系统错误");
+        }
+        reOrderRanking(raceRuleTable.getId());
+
+    }
+
+    @Override
+    public ActivityRaceRankingDto searchCustomRankingInfo(ActivityRaceRankingMyEntity entity) throws Exception {
+        //获取活动规则信息
+        ActivityRaceRuleTable ruleTable =
+                activityRaceRuleMapper.findByCustomIdAndRaceTypeAndSerial(entity.getRaceType(), entity.getSerial());
+        if (ruleTable == null) {
+            throw new ServiceException(String.format("当前%s不存在", ActivityRaceType.matchDesc(entity.getRaceType())));
+        }
+        //根据规则获取当前用户的比赛信息
+        ActivityRaceRankingView rankingView =
+                activityRaceRankingMapper.getViewByCustomIdAndRuleId(entity.getCustomId(), ruleTable.getId());
+        if (rankingView == null) {
+            CustomInfoTable custom = customInfoRepository.getOne(entity.getCustomId());
+            rankingView = new ActivityRaceRankingView();
+            rankingView.setFirstName(custom.getFirstName());
+            rankingView.setMiddle(custom.getMiddle());
+            rankingView.setLastName(custom.getLastName());
+            rankingView.setCountry(custom.getCountry());
+            rankingView.setActive(-99);
+        }
+        return convertViewToDto(rankingView);
+    }
+
+    @Override
+    public Map<Long, ActivityRaceRankingTable> mapAllByRuleId(Long ruleId) throws Exception {
+
+        List<ActivityRaceRankingTable> tables = activityRaceRankingRepository.findAllByRuleId(ruleId);
+        Map<Long, ActivityRaceRankingTable> map = Maps.newHashMap();
+        for (ActivityRaceRankingTable table : tables) {
+            map.put(table.getCustomId(), table);
+        }
+
+        return map;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateCalcResult(List<ActivityRaceRankingTable> tables) throws Exception {
+        activityRaceRankingMapper.batchUpdateProfit(tables);
+    }
+
+    @Override
+    public List<ActivityRaceRankingTable> reOrderRanking(List<ActivityRaceRankingTable> tables) {
+
+        if (CollectionUtils.isEmpty(tables)) {
+            return null;
+        }
+
+        /*
+            拆分为活跃和不活跃
+         */
+        List<ActivityRaceRankingTable> actives = Lists.newArrayList();
+        List<ActivityRaceRankingTable> inactives = Lists.newArrayList();
+        for (ActivityRaceRankingTable table : tables) {
+            if (table.getActive() != null && table.getActive() >= 1) {
+                actives.add(table);
+            } else {
+                table.setRank(0);
+                inactives.add(table);
+            }
+        }
+
+        /*
+            对活跃报名排序
+         */
+        Date now = new Date();
+        if (actives.size() == 1) {
+            actives.get(0).setRank(1);
+            actives.get(0).setModifyTime(now);
+        } else {
+            //按盈利排序
+            actives.sort((i1, i2) -> (i1.getProfit() - i2.getProfit() >= 0) ? -1 : 1);
+            //设置排名
+            for (int i = 0; i < actives.size(); i++) {
+                actives.get(i).setRank(i + 1);
+                actives.get(i).setModifyTime(now);
+            }
+        }
+
+        //返回结果
+        List<ActivityRaceRankingTable> results = Lists.newArrayList();
+        results.addAll(actives);
+        results.addAll(inactives);
+        return results;
+    }
+
+    @Override
+    public BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>> searchProfitCoverList(ActivityRaceRankingListEntity entity) throws Exception {
+        Integer count = activityRaceRankingMapper.countList(entity);
+        if (count == null || count == 0) {
+            return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS);
+        }
+
+        PageDto pageDto = FormatPage.format(entity.getPage(), count);
+
+        List<ActivityRaceRankingView> views = activityRaceRankingMapper.getList(entity);
+        List<ActivityRaceRankingProfitCoverDto> dtos = Lists.newArrayList();
+        for (ActivityRaceRankingView view : views) {
+            dtos.add(convertViewToDtoWithNameAndProfitSecret(view, entity.isHide()));
+        }
+
+        return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS, dtos, pageDto);
+    }
+
+    private ActivityRaceRankingDto convertViewToDtoBySecret(ActivityRaceRankingView view, boolean isHide) {
+        ActivityRaceRankingDto dto = new ActivityRaceRankingDto();
+        BeanUtils.copyProperties(view, dto);
+//        String name =  NameUtil.getName(view.getCountry(), view.getFirstName(), view.getMiddle(), view.getLastName());
+        String name = RexUtil.rexName(view.getFirstName());
+        dto.setName(name);
+        if (isHide) {
+//            dto.setName(StringUtil.secretLastName(view.getFirstName()));
+            dto.setLogin(StringUtil.secretString(String.valueOf(view.getLogin())));
+        } else {
+            dto.setName(name);
+            dto.setLogin(String.valueOf(view.getLogin()));
+        }
+
+        if (view.getActive() <= 0) {
+            dto.setRank("暂无排名");
+        } else {
+            dto.setRank(String.format("#%d", view.getRank()));
+        }
+
+        return dto;
+    }
+
+    private ActivityRaceRankingDto convertViewToDto(ActivityRaceRankingView view) {
+        ActivityRaceRankingDto dto = new ActivityRaceRankingDto();
+        BeanUtils.copyProperties(view, dto);
+        dto.setName(NameUtil.getName(view.getCountry(), view.getFirstName(), view.getMiddle(), view.getLastName()));
+        if (view.getActive() == -99) {
+            dto.setLogin("-");
+        } else {
+            dto.setLogin(String.valueOf(view.getLogin()));
+        }
+        if (view.getActive() <= 0) {
+            if (view.getActive() == -99) {
+                dto.setRank("未参赛");
+            } else {
+                dto.setRank("暂无排名");
+            }
+
+        } else {
+            dto.setRank(String.format("#%d", view.getRank()));
+        }
+        return dto;
+    }
+
+    private ActivityRaceRankingProfitCoverDto convertViewToDtoWithNameAndProfitSecret(ActivityRaceRankingView view,
+                                                                                      boolean isHide) {
+        ActivityRaceRankingProfitCoverDto coverDto = new ActivityRaceRankingProfitCoverDto();
+        ActivityRaceRankingDto raceRankingDto = convertViewToDtoBySecret(view, isHide);
+        BeanUtils.copyProperties(raceRankingDto, coverDto);
+        if (view.getRank() != 1) {
+            coverDto.setProfit("***");
+        } else {
+            coverDto.setProfit(String.format("%.2f", raceRankingDto.getProfit()));
+        }
+        return coverDto;
+    }
+
+}

+ 79 - 0
crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceRuleServiceImpl.java

@@ -0,0 +1,79 @@
+package com.crm.activity.service.impl;
+
+import com.crm.activity.dao.mapper.ActivityRaceRuleMapper;
+import com.crm.activity.dao.repository.ActivityRaceRuleRepository;
+import com.crm.activity.service.ActivityRaceRuleService;
+import com.crm.rely.backend.core.dto.base.BaseLongSelectDto;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Service
+public class ActivityRaceRuleServiceImpl implements ActivityRaceRuleService {
+
+    @Autowired
+    private ActivityRaceRuleMapper activityRaceRuleMapper;
+    @Autowired
+    private ActivityRaceRuleRepository activityRaceRuleRepository;
+
+    @Override
+    public List<BaseLongSelectDto> getAllDropDownByType(Integer raceType) throws Exception {
+
+        List<ActivityRaceRuleTable> tables = activityRaceRuleMapper.findAllLimitedByRaceType(raceType, 10);
+        return convertTablesToDropDownDtos(tables);
+    }
+
+    @Override
+    public List<BaseLongSelectDto> getDropDownForCustomByType(Long customId, Integer raceType) throws Exception {
+        List<ActivityRaceRuleTable> tables = activityRaceRuleMapper.findAllLimitedByRaceType(raceType, 10);
+        return convertTablesToDropDownDtos(tables);
+    }
+
+    @Override
+    public Integer getNextSerialByRaceType(Integer raceType) throws Exception {
+
+        Integer maxSerial = activityRaceRuleMapper.getMaxSerialByRaceType(raceType);
+        return maxSerial + 1;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveTable(ActivityRaceRuleTable table) throws Exception {
+        activityRaceRuleRepository.save(table);
+    }
+
+    @Override
+    public List<ActivityRaceRuleTable> findAllCaleRule(Date date) throws Exception {
+        return activityRaceRuleMapper.findAllByDateBt(date);
+    }
+
+    @Override
+    public Boolean existsByDate(Date startDate, Date endDate, Integer raceType) {
+        Integer count = activityRaceRuleMapper.countByStartDateAndEndDateAndRaceType(startDate, endDate, raceType);
+        return (count != null && count > 0);
+    }
+
+    private List<BaseLongSelectDto> convertTablesToDropDownDtos(List<ActivityRaceRuleTable> tables) {
+        List<BaseLongSelectDto> dtos = Lists.newArrayList();
+        if (CollectionUtils.isEmpty(tables)) {
+            return dtos;
+        }
+        for (ActivityRaceRuleTable table : tables) {
+            BaseLongSelectDto dto = new BaseLongSelectDto();
+            dtos.add(dto);
+            dto.setId(table.getSerial().longValue());
+            dto.setVal(String.format("第%d期", table.getSerial()));
+        }
+        return dtos;
+    }
+}

+ 306 - 0
crm-activity/src/main/java/com/crm/activity/service/impl/ActivityRaceSignServiceImpl.java

@@ -0,0 +1,306 @@
+package com.crm.activity.service.impl;
+
+import com.crm.activity.dao.mapper.AccountInfoMapper;
+import com.crm.activity.dao.mapper.ActivityRaceRuleMapper;
+import com.crm.activity.dao.mapper.ActivityRaceSignMapper;
+import com.crm.activity.dao.mapper.TradePositionMapper;
+import com.crm.activity.dao.repository.*;
+import com.crm.activity.enums.ActivityRaceType;
+import com.crm.activity.service.ActivityRaceSignService;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.dto.base.PageDto;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceSignInfoDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignAddEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignInfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignLoginEntity;
+import com.crm.rely.backend.model.pojo.table.*;
+import com.crm.rely.backend.model.pojo.view.AccountInfoView;
+import com.crm.rely.backend.model.pojo.view.ActivityRaceSignView;
+import com.crm.rely.backend.util.FormatPage;
+import com.crm.rely.backend.util.NameUtil;
+import org.apache.commons.compress.utils.Lists;
+import org.apache.poi.ss.formula.functions.Now;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 周比赛服务接口实现
+ *
+ * @author y
+ * @create 2022/7/19
+ */
+@Service
+public class ActivityRaceSignServiceImpl implements ActivityRaceSignService {
+
+    @Autowired
+    private ActivityRaceSignMapper activityRaceSignMapper;
+    @Autowired
+    private ActivityRaceSignRepository activityRaceSignRepository;
+    @Autowired
+    private ActivityRaceRuleMapper activityRaceRuleMapper;
+    @Autowired
+    private AccountInfoMapper accountInfoMapper;
+    @Autowired
+    private TradePositionMapper tradePositionMapper;
+    @Autowired
+    private CustomLoginRepository customLoginRepository;
+    @Autowired
+    private CustomLoginAssetManagementRepository customLoginAssetManagementRepository;
+    @Autowired
+    private CustomLoginFirmOfferRepository customLoginFirmOfferRepository;
+    @Autowired
+    private ActivityRaceRankingRepository activityRaceRankingRepository;
+
+    /**
+     * 报名
+     *
+     * @param entity
+     * @throws Exception
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void add(ActivityRaceSignAddEntity entity) throws Exception {
+
+        /*
+            根据报名时间获取对应的报名规则信息
+         */
+        ActivityRaceRuleTable ruleTable = activityRaceRuleMapper.findFirstBySignDateBtAndType(entity.getSignDate(), entity.getRaceType());
+        if (ruleTable == null) {
+            throw new ServiceException("当前时间无" + ActivityRaceType.matchDesc(entity.getRaceType()));
+        }
+        //判断是否过了报名截至时间
+        if (entity.getSignDate().getTime() > ruleTable.getUpTo().getTime()) {
+            throw new ServiceException("报名已截至,敬请关注下期比赛");
+        }
+        //判断是否重复报名
+        Integer exists = activityRaceSignRepository.countByRuleIdAndCustomIdAndRaceType(ruleTable.getId(), entity.getCustomId(), entity.getRaceType());
+        if (exists != null && exists >= 1) {
+            throw new ServiceException("不能重复报名");
+        }
+        //判断交易账户是否已经报名
+        List<ActivityRaceSignTable> signTables = activityRaceSignMapper.findValidSignByCustomIdAndDate(entity.getCustomId(), entity.getSignDate());
+        for (ActivityRaceSignTable signTable : signTables) {
+            if (signTable.getLogin().equals(entity.getLogin())) {
+                throw new ServiceException("不能重复报名");
+            }
+        }
+        //验证交易账户是否能参与当前活动
+        validateLogin(entity);
+        //交易平台
+        String platform = Constants.MT4;
+        //判断是否有持仓
+        exists = tradePositionMapper.countByLogin(entity.getLogin(), platform);
+        if (exists != null && exists >= 1) {
+            throw new ServiceException("报名前需清仓");
+        }
+        //获取账户信息
+        AccountInfoView accountInfoView = accountInfoMapper.findByLogin(entity.getLogin(), platform);
+        //净值要求
+        validateEquity(accountInfoView, entity.getRaceType());
+        //添加报名
+        ActivityRaceSignTable signTable = new ActivityRaceSignTable();
+        BeanUtils.copyProperties(entity, signTable);
+        signTable.setAddTime(new Date());
+        signTable.setEquity(accountInfoView.getEquity());
+        signTable.setRaceStartDate(ruleTable.getStartDate());
+        signTable.setRaceEndDate(ruleTable.getEndDate());
+        signTable.setSerial(ruleTable.getSerial());
+        signTable.setRuleId(ruleTable.getId());
+        activityRaceSignRepository.save(signTable);
+        //添加排名信息
+        ActivityRaceRankingTable rankingTable = ActivityRaceRankingTable.getInstance();
+        rankingTable.setCustomId(entity.getCustomId());
+        rankingTable.setCId(entity.getCId());
+        rankingTable.setLogin(entity.getLogin());
+        rankingTable.setRuleId(ruleTable.getId());
+        rankingTable.setStartEquity(accountInfoView.getEquity());
+        rankingTable.setAddTime(new Date());
+        rankingTable.setRuleId(ruleTable.getId());
+        activityRaceRankingRepository.save(rankingTable);
+    }
+
+    @Override
+    public ActivityRaceSignInfoDto info(ActivityRaceSignInfoEntity entity) throws Exception {
+
+        //获取最近一次报名
+        ActivityRaceSignView view = activityRaceSignMapper.findFirstByCustomIdAndRaceType(entity.getCustomId(), entity.getRaceType());
+        if (view == null) {
+            return null;
+        }
+        Date now = new Date();
+        if (view.getRaceEndDate().getTime() < now.getTime()) {
+            return null;
+        }
+        return convertViewToDto(view);
+    }
+
+    @Override
+    public ActivityRaceSignInfoDto searchById(Long id) throws Exception {
+
+        ActivityRaceSignView view = activityRaceSignMapper.findViewById(id);
+        if (view == null) return null;
+        return convertViewToDto(view);
+    }
+
+    @Override
+    public BaseResultWithPagerDto<List<ActivityRaceSignInfoDto>> searchList(ActivityRaceSignListEntity entity) throws Exception {
+
+        Integer count = activityRaceSignMapper.countList(entity);
+        if (count == null || count == 0) {
+            return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS);
+        }
+
+        PageDto pageDto = FormatPage.format(entity.getPage(), count);
+
+
+        List<ActivityRaceSignInfoDto> dtos = Lists.newArrayList();
+        List<ActivityRaceSignView> views = activityRaceSignMapper.getList(entity);
+        for (ActivityRaceSignView view : views) {
+            dtos.add(convertViewToDto(view));
+        }
+
+        return new BaseResultWithPagerDto<>(Constants.SUCCESS_CODE, Constants.SUCCESS, dtos, pageDto);
+    }
+
+    @Override
+    public List<Long> getLogins(ActivityRaceSignLoginEntity entity) throws Exception {
+
+        Date now = new Date();
+        /*
+            根据报名时间获取对应的报名规则信息
+         */
+        ActivityRaceRuleTable ruleTable = activityRaceRuleMapper.findFirstBySignDateBtAndType(now, entity.getRaceType());
+        if (ruleTable == null) {
+            throw new ServiceException("当前时间无" + ActivityRaceType.matchDesc(entity.getRaceType()));
+        }
+        //可用的交易账户
+        List<Long> logins = Lists.newArrayList();
+        //获取当前时间已报名的信息
+        List<ActivityRaceSignTable> signTables = activityRaceSignMapper.findValidSignByCustomIdAndDate(entity.getCustomId(), now);
+        List<Long> signLogins = Lists.newArrayList();
+        boolean applied = false;
+        for (ActivityRaceSignTable signTable : signTables) {
+            signLogins.add(signTable.getLogin());
+            if (signTable.getRaceType().equals(entity.getRaceType())) {
+                applied = true;
+            }
+        }
+
+        if (applied) {
+            throw new ServiceException("您已经参与本次" + ActivityRaceType.matchDesc(entity.getRaceType()));
+        }
+
+        List<Long> allLogins = Lists.newArrayList();
+
+        //实盘账户
+        List<CustomLoginTable> loginTables = customLoginRepository.findAllByCustomId(entity.getCustomId());
+        for (CustomLoginTable loginTable : loginTables) {
+            allLogins.add(loginTable.getLogin());
+        }
+        //月赛账户
+        if (ActivityRaceType.MONTHLY.getCode().equals(entity.getRaceType())) {
+
+            List<CustomLoginAssetManagementTable> managementTables = customLoginAssetManagementRepository.findAllByCustomId(entity.getCustomId());
+            for (CustomLoginAssetManagementTable managementTable : managementTables) {
+                allLogins.add(managementTable.getLogin());
+            }
+
+            List<CustomLoginFirmOfferTable> offerTables = customLoginFirmOfferRepository.findAllByCustomId(entity.getCustomId());
+            for (CustomLoginFirmOfferTable offerTable : offerTables) {
+                allLogins.add(offerTable.getLogin());
+            }
+
+        }
+
+        //剔除已报名的账户
+        for (Long allLogin : allLogins) {
+            if (!signLogins.contains(allLogin)) {
+                logins.add(allLogin);
+            }
+        }
+        if (CollectionUtils.isEmpty(logins)){
+            return logins;
+        }
+        //剔除净值不满足条件账户
+        List<AccountInfoView> accountInfoViews = accountInfoMapper.findAllByLoginIn(logins, Constants.MT4);
+        logins = Lists.newArrayList();
+        for (AccountInfoView accountInfoView : accountInfoViews) {
+            try {
+                validateEquity(accountInfoView, entity.getRaceType());
+                logins.add(accountInfoView.getLogin());
+            }catch (Exception e){
+
+            }
+
+        }
+
+        if (CollectionUtils.isEmpty(logins)) {
+            throw new ServiceException("无可用的交易账户");
+        }
+
+        return logins;
+    }
+
+    private ActivityRaceSignInfoDto convertViewToDto(ActivityRaceSignView view) {
+        ActivityRaceSignInfoDto dto = new ActivityRaceSignInfoDto();
+        BeanUtils.copyProperties(view, dto);
+        dto.setName(NameUtil.getName(view.getCountry(), view.getFirstName(), view.getMiddle(), view.getLastName()));
+        return dto;
+    }
+
+    /**
+     * 验证交易账户是否能参与当前活动
+     *
+     * @param entity
+     * @throws Exception
+     */
+    private void validateLogin(ActivityRaceSignAddEntity entity) throws Exception {
+        /*
+            如果是周赛
+         */
+        if (ActivityRaceType.WEEKLY.getCode().equals(entity.getRaceType())) {
+            CustomLoginTable customLoginTable = customLoginRepository.findFirstByLogin(entity.getLogin());
+            if (customLoginTable == null) {
+                throw new ServiceException("当前账户无法参与");
+            }
+        }
+        /*
+            如果是月赛
+         */
+        else if (ActivityRaceType.MONTHLY.getCode().equals(entity.getRaceType())) {
+            CustomLoginTable customLoginTable = customLoginRepository.findFirstByLogin(entity.getLogin());
+            if (customLoginTable == null) {
+                CustomLoginFirmOfferTable firmOfferTable = customLoginFirmOfferRepository.findFirstByLogin(entity.getLogin());
+                if (firmOfferTable == null) {
+                    CustomLoginAssetManagementTable assetManagementTable = customLoginAssetManagementRepository.findFirstByLogin(entity.getLogin());
+                    if (assetManagementTable == null) {
+                        throw new ServiceException("当前账户无法参与");
+                    }
+                }
+            }
+        }
+
+    }
+
+    private void validateEquity(AccountInfoView accountInfoView, Integer raceType) {
+
+        if (ActivityRaceType.WEEKLY.getCode().equals(raceType)) {
+            if (accountInfoView.getEquity() < 500F) {
+                throw new ServiceException("个人实盘账户净值需500美元以上");
+            }
+        } else if (ActivityRaceType.MONTHLY.getCode().equals(raceType)) {
+            if (accountInfoView.getEquity() < 5000F) {
+                throw new ServiceException("个人实盘账户净值需5000美元以上");
+            }
+        }
+    }
+}

+ 240 - 0
crm-activity/src/main/java/com/crm/activity/task/ActivityRaceTask.java

@@ -0,0 +1,240 @@
+package com.crm.activity.task;
+
+import com.crm.activity.dao.mapper.ActivityRaceCalcMapper;
+import com.crm.activity.enums.ActivityRaceType;
+import com.crm.activity.service.ActivityRaceRankingService;
+import com.crm.activity.service.ActivityRaceRuleService;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable;
+import com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable;
+import com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView;
+import com.crm.rely.backend.util.DateUtil;
+import com.crm.rely.backend.util.ListSplitUtil;
+import org.apache.commons.compress.utils.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@Service
+public class ActivityRaceTask {
+
+    private final Logger logger = LoggerFactory.getLogger(ActivityRaceTask.class);
+
+    @Autowired
+    private ActivityRaceRuleService activityRaceRuleService;
+    @Autowired
+    private ActivityRaceCalcMapper activityRaceCalcMapper;
+    @Autowired
+    private ActivityRaceRankingService activityRaceRankingService;
+
+    /**
+     * 周比赛生成
+     * 每周日0点生成周规则
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Scheduled(cron = "10 0 0 ? * 7")
+    public void generateWeeklyRule() throws Exception {
+        try {
+            Calendar calendar = Calendar.getInstance();
+            //开始时间
+            Date start = DateUtil.getPureDate(new Date());
+            calendar.setTime(start);
+            //截至时间
+            calendar.add(Calendar.DATE, 5);
+            calendar.add(Calendar.HOUR, 18);
+            Date upTo = calendar.getTime();
+            //结束时间
+            calendar.setTime(start);
+            calendar.add(Calendar.DATE, 7);
+            Date end = calendar.getTime();
+            //保存
+            createRuleInfo(start, upTo, end, ActivityRaceType.WEEKLY.getCode());
+        } catch (Exception e) {
+            logger.error(e.getMessage());
+            throw e;
+        }
+
+    }
+
+    /**
+     * 月比赛生成
+     * 每月1日生成月规则
+     *
+     * @throws Exception
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Scheduled(cron = "30 0 0 1 * ?")
+    public void generateMonthlyRule() throws Exception {
+        try {
+            Calendar calendar = Calendar.getInstance();
+            //开始时间
+            calendar.setTime(DateUtil.getPureDate(new Date()));
+            calendar.set(Calendar.DATE, 1);
+            Date start = calendar.getTime();
+            //截至时间
+            calendar.add(Calendar.DATE, 24);
+            Date upTo = calendar.getTime();
+            //结束时间
+            calendar.setTime(start);
+            calendar.add(Calendar.MONTH, 1);
+            Date end = calendar.getTime();
+            //保存
+            createRuleInfo(start, upTo, end, ActivityRaceType.MONTHLY.getCode());
+        } catch (Exception e) {
+            logger.error(e.getMessage());
+            throw e;
+        }
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Scheduled(cron = "5 0 0 * * ?")
+    public void calcProfit() throws Exception {
+        try {
+            //当前时间
+            Date now = DateUtil.getPureDate(new Date());
+            //获取周、月比赛规则
+            List<ActivityRaceRuleTable> ruleTables = activityRaceRuleService.findAllCaleRule(now);
+            //获取对应规则
+            ActivityRaceRuleTable weeklyRule = null;
+            ActivityRaceRuleTable monthlyRule = null;
+            for (ActivityRaceRuleTable ruleTable : ruleTables) {
+                if (ActivityRaceType.WEEKLY.getCode().equals(ruleTable.getRaceType()) && weeklyRule == null) {
+                    weeklyRule = ruleTable;
+                }
+                if (ActivityRaceType.MONTHLY.getCode().equals(ruleTable.getRaceType()) && monthlyRule == null) {
+                    monthlyRule = ruleTable;
+                }
+            }
+            //计算对应规则盈利
+            if (weeklyRule != null) {
+                calcRuleProfit(weeklyRule);
+            }
+
+            if (monthlyRule != null) {
+                calcRuleProfit(monthlyRule);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage());
+            throw e;
+        }
+    }
+
+    /**
+     * 1.计算规则内的盈利信息
+     * 2.保存信息
+     * 3.重新排名
+     *
+     * @param ruleTable
+     * @throws Exception
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void calcRuleProfit(ActivityRaceRuleTable ruleTable) throws Exception {
+        Long ruleId = ruleTable.getId();
+        //获取规则内的出入金、净值信息
+        List<ActivityRaceCalcView> views = getCalcViews(ruleId, Constants.MT4);
+        if (CollectionUtils.isEmpty(views)) {
+            return;
+        }
+        //获取对应排名信息
+        Map<Long, ActivityRaceRankingTable> rankingMap = activityRaceRankingService.mapAllByRuleId(ruleId);
+        //生成保存信息
+        List<ActivityRaceRankingTable> tables = Lists.newArrayList();
+        Date now = new Date();
+        for (ActivityRaceCalcView view : views) {
+
+            ActivityRaceRankingTable table = rankingMap.get(view.getCustomId());
+            if (table == null) continue;
+            table.setActive((view.getHasTrade() >= 1 || view.getHasOpen() >= 1) ? 1 : 0);
+            table.setDw(view.getDw());
+            table.setEndEquity(view.getEquity());
+            table.setProfit(table.getEndEquity() - table.getStartEquity() + table.getManual() - table.getDw());
+            table.setModifyTime(now);
+            tables.add(table);
+        }
+        //重新排名
+        tables = activityRaceRankingService.reOrderRanking(tables);
+        //保存信息
+        List<List<ActivityRaceRankingTable>> lists = ListSplitUtil.split(tables);
+        for (List<ActivityRaceRankingTable> list : lists) {
+            activityRaceRankingService.updateCalcResult(list);
+        }
+    }
+
+    /**
+     * 保存规则信息
+     *
+     * @param start 活动开始时间
+     * @param upTo  活动截至时间
+     * @param end   活动结束时间
+     * @param type  活动类型
+     * @throws Exception
+     */
+    @Transactional(rollbackFor = Exception.class)
+    void createRuleInfo(Date start, Date upTo, Date end, Integer type) throws Exception {
+        //判断是否已存在规则
+        boolean exists = activityRaceRuleService.existsByDate(start, end, type);
+        if (exists) return;
+        //保存信息
+        ActivityRaceRuleTable ruleTable = new ActivityRaceRuleTable();
+        ruleTable.setAddTime(new Date());
+        ruleTable.setSerial(activityRaceRuleService.getNextSerialByRaceType(type));
+        ruleTable.setStartDate(start);
+        ruleTable.setEndDate(end);
+        ruleTable.setUpTo(upTo);
+        ruleTable.setRaceType(type);
+        activityRaceRuleService.saveTable(ruleTable);
+
+    }
+
+    List<ActivityRaceCalcView> getCalcViews(Long ruleId, String platform) {
+        List<ActivityRaceCalcView> views = Lists.newArrayList();
+        //账户及出入金信息
+        List<ActivityRaceCalcView> accountViews = activityRaceCalcMapper.findAccountAndDwInfoByRuleId(ruleId, platform);
+        if (!CollectionUtils.isEmpty(accountViews)) {
+            views.addAll(accountViews);
+        }
+        //平仓信息
+        List<ActivityRaceCalcView> tradeViews = activityRaceCalcMapper.findCloseTradeByRuleId(ruleId, platform);
+        if (!CollectionUtils.isEmpty(tradeViews)) {
+            for (ActivityRaceCalcView view : views) {
+                for (ActivityRaceCalcView tradeView : tradeViews) {
+                    if (view.getCustomId().equals(tradeView.getCustomId())) {
+                        view.setHasTrade(tradeView.getHasTrade());
+                        break;
+                    }
+                }
+            }
+        }
+        //开仓信息
+        List<ActivityRaceCalcView> openViews = activityRaceCalcMapper.findOpenTradeByRuleId(ruleId, platform);
+        if (!CollectionUtils.isEmpty(openViews)) {
+            for (ActivityRaceCalcView view : views) {
+                for (ActivityRaceCalcView openView : openViews) {
+                    if (view.getCustomId().equals(openView.getCustomId())) {
+                        view.setHasOpen(openView.getHasOpen());
+                        break;
+                    }
+                }
+            }
+        }
+
+        return views;
+
+    }
+
+}

+ 10 - 0
crm-activity/src/main/resources/application-dev.yml

@@ -0,0 +1,10 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://8.210.194.53:13542/crm_trader?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
+    username: root
+    password: F28c49d8be
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123456@localhost:7000/eureka

+ 33 - 0
crm-activity/src/main/resources/application-ho.yml

@@ -0,0 +1,33 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://172.16.0.6:3306/crm_trader?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
+    username: root
+    password: 123123
+  jpa:
+    database: MYSQL
+    hibernate:
+      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+    show-sql: true
+  activemq:
+    broker-url: tcp://localhost:61616
+logging:
+  level:
+    com.crm.manager.dao.mapper: trace
+#  redis:
+#    host: 127.0.0.1
+
+web:
+  front-path: ./front
+  upload-path: ./upload
+  export-path: .//export
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123456@localhost:17000/eureka
+ribbon:
+  ReadTimeout: 60000
+  ConnectTimeout: 60000
+#logging:
+#  config: classpath:logback-dev.xml
+

+ 13 - 0
crm-activity/src/main/resources/application-hu.yml

@@ -0,0 +1,13 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://8.210.194.53:13542/crm_trader?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
+    username: root
+    password: F28c49d8be
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123456@localhost:7000/eureka
+mybatis:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 16 - 0
crm-activity/src/main/resources/application-prod.yml

@@ -0,0 +1,16 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://localhost:18234/cwg_trader?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
+    username: ib_task_user
+    password: 48fca8d6325e93e9377e483667374d72
+  activemq:
+    broker-url: tcp://localhost:61616
+  redis:
+    host: 127.0.0.1
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123456@localhost:7000/eureka
+logging:
+  config: classpath:logback-prod.xml

+ 18 - 0
crm-activity/src/main/resources/application-test.yml

@@ -0,0 +1,18 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://8.209.114.51:13542/cwg_crm?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&allowMultiQueries=true&useSSL=false
+    username: root
+    password: F28c49d8be
+  jpa:
+    database: MYSQL
+    hibernate:
+      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+    show-sql: true
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://admin:admin123456@localhost:7000/eureka
+mybatis:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 10 - 0
crm-activity/src/main/resources/application.yml

@@ -0,0 +1,10 @@
+server:
+  port: 9200
+spring:
+  profiles:
+    active: hu
+  application:
+    name: ACTIVITY-SERVICE
+mybatis:
+  type-aliases-package: com.crm.rely.backend.core.pojo.table.view
+  executor-type: batch

+ 57 - 0
crm-activity/src/main/resources/logback-prod.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<configuration>
+    <property name="LOG_HOME" value="../log/activity"/>
+
+    <appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+
+            <fileNamePattern>${LOG_HOME}/errorFile.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <maxHistory>30</maxHistory>
+        </rollingPolicy>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{35} - %msg%n</pattern>0
+        </encoder>
+    </appender>
+    <appender name="infoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>-
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_HOME}/info/infoFile.%d{yyyy-MM-dd}.log</fileNamePattern>
+
+            <maxHistory>30</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{35} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_HOME}/hibernate/logback.%d{yyyy-MM-dd}.log</fileNamePattern>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <logger name="org.hibernate.SQL" additivity="false" >
+        <level value="DEBUG" />
+        <appender-ref ref="file" />
+    </logger>
+    <logger name="org.hibernate.type.descriptor.sql.BasicBinder" additivity="false" level="TRACE" >
+        <level value="TRACE" />
+        <appender-ref ref="file" />
+    </logger>
+    <root additivity="false">
+        <level value="info"></level>
+        <appender-ref ref="infoFile" />
+        <appender-ref ref="errorFile" />
+        <appender-ref ref="file" />
+    </root>
+</configuration>

+ 22 - 0
crm-activity/src/main/resources/mapper/AccountInfoMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.AccountInfoMapper">
+
+    <select id="findByLogin" resultType="com.crm.rely.backend.model.pojo.view.AccountInfoView">
+        select equity,balance
+        from account_view_${platform} account
+        where account.login = #{login}
+    </select>
+
+    <select id="findAllByLoginIn" resultType="com.crm.rely.backend.model.pojo.view.AccountInfoView">
+        select *
+        from account_view_${platform} account
+        where login in
+        <foreach collection="logins" item="item" index="idx" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+</mapper>

+ 57 - 0
crm-activity/src/main/resources/mapper/ActivityRaceCalcMapper.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.ActivityRaceCalcMapper">
+
+<!--    <select id="findAllByRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView">-->
+<!--        select sign.custom_id,account.equity,ifnull(SUM(dw.PROFIT),0) dw-->
+<!--        from activity_race_rule rule-->
+<!--        inner join activity_race_sign sign on rule.id = sign.rule_id-->
+<!--        inner join account_view_${platform} account on sign.login = account.login-->
+<!--        left join dw_view_${platform} dw on account.login = dw.login-->
+<!--        and dw.CLOSE_TIME <![CDATA[>=]]> rule.start_date and dw.CLOSE_TIME <![CDATA[<]]> rule.end_date-->
+<!--        where rule.id = #{ruleId}-->
+<!--    </select>-->
+
+    <select id="findAllByRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView">
+        select sign.custom_id,sum(ifnull(dw.profit,0)) dw,
+        ifnull(count(trade.`order`),0) has_trade,ifnull(count(pos.`order`),0) has_open,
+        act.equity
+        from activity_race_sign sign
+        inner join account_view_${platform} act on sign.login = act.login
+        left join dw_view_${platform} dw on sign.login = dw.login and dw.close_time <![CDATA[>=]]> sign.sign_date and dw.close_time <![CDATA[<]]> sign.race_end_date
+        left join trade_history_view_${platform} trade on sign.login = trade.login and trade.close_time <![CDATA[>=]]> sign.sign_date and trade.close_time <![CDATA[<]]> sign.race_end_date
+        left join trade_position_view_${platform} pos on sign.login = pos.login and pos.open_time <![CDATA[>=]]> sign.sign_date and pos.open_time <![CDATA[<]]> sign.race_end_date
+        where sign.rule_id = #{ruleId}
+        group by sign.login
+    </select>
+
+    <select id="findAccountAndDwInfoByRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView">
+        select sign.custom_id,sum(ifnull(dw.profit,0)) dw,
+               act.equity
+        from activity_race_sign sign
+        inner join account_view_${platform} act on sign.login = act.login
+        left join dw_view_${platform} dw on sign.login = dw.login and dw.close_time <![CDATA[>=]]> sign.sign_date and dw.close_time <![CDATA[<]]> sign.race_end_date
+        where sign.rule_id = #{ruleId}
+        group by sign.login
+    </select>
+
+    <select id="findCloseTradeByRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView">
+        select sign.custom_id,ifnull(count(trade.`order`),0) has_trade
+        from activity_race_sign sign
+        inner join account_view_${platform} act on sign.login = act.login
+        left join trade_history_view_${platform} trade on sign.login = trade.login and trade.close_time <![CDATA[>=]]> sign.sign_date and trade.close_time <![CDATA[<]]> sign.race_end_date
+        where sign.rule_id = #{ruleId}
+        group by sign.login
+    </select>
+
+    <select id="findOpenTradeByRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceCalcView">
+        select sign.custom_id,ifnull(count(pos.`order`),0) has_open
+        from activity_race_sign sign
+        inner join account_view_${platform} act on sign.login = act.login
+        left join trade_position_view_${platform} pos on sign.login = pos.login and pos.open_time <![CDATA[>=]]> sign.sign_date and pos.open_time <![CDATA[<]]> sign.race_end_date
+        where sign.rule_id = #{ruleId}
+        group by sign.login
+    </select>
+</mapper>

+ 144 - 0
crm-activity/src/main/resources/mapper/ActivityRaceRankingMapper.xml

@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.ActivityRaceRankingMapper">
+
+    <select id="countList"
+            parameterType="com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity"
+            resultType="Integer">
+        select count(ranking.id)
+        from activity_race_ranking ranking
+        inner join activity_race_rule rule on ranking.rule_id = rule.id
+        where rule.race_type = #{raceType}
+        and rule.serial = #{serial}
+--         and ranking.active > 0
+        <if test="login !=null and login > 0">
+            and ranking.login = #{login}
+        </if>
+    </select>
+
+    <select id="getList"
+            parameterType="com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity"
+            resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceRankingView">
+        select ranking.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_ranking ranking
+        inner join custom_info ci on ranking.custom_id = ci.id
+        inner join activity_race_rule rule on ranking.rule_id = rule.id
+        where rule.race_type = #{raceType}
+        and rule.serial = #{serial}
+--         and ranking.active > 0
+        <if test="login !=null and login > 0">
+            and ranking.login = #{login}
+        </if>
+        order by ranking.active desc,ranking.`rank` asc
+        <if test="page != null">
+            limit #{page.offset},#{page.row}
+        </if>
+    </select>
+
+    <select id="getViewById"
+            parameterType="Long"
+            resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceRankingView">
+        select ranking.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_ranking ranking
+        inner join custom_info ci on ranking.custom_id = ci.id
+        where ranking.id = #{id}
+    </select>
+
+    <select id="getById" parameterType="Long" resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        select *
+        from activity_race_ranking where id=#{id}
+    </select>
+
+    <select id="getAllByRaceTypeAndSerial" resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        select ranking.*
+        from activity_race_ranking ranking
+        inner join activity_race_rule rule on ranking.rule_id = rule.id
+        where rule.race_type=#{raceType} and rule.serial = #{serial}
+    </select>
+
+    <update id="batchUpdateRank" parameterType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        update activity_race_ranking
+        <trim prefix="set" suffixOverrides=",">
+            <trim prefix="rank = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.rank}
+                </foreach>
+            </trim>
+            <trim prefix="modify_time = case" suffix="end,">
+                <foreach collection="list" index="idx" item="item">
+                    when id=#{item.id} then #{item.modifyTime}
+                </foreach>
+            </trim>
+        </trim>
+        <where>
+            and id in
+            <foreach collection="list" index="idx" item="item" separator="," open="(" close=")">
+                #{item.id}
+            </foreach>
+        </where>
+    </update>
+
+    <update id="updateById" parameterType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        update activity_race_ranking
+        set profit = #{profit},
+        manual = #{manual}
+        where id = #{id}
+    </update>
+
+    <select id="getViewByCustomIdAndRuleId" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceRankingView">
+        select ranking.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_ranking ranking
+        inner join custom_info ci on ranking.custom_id = ci.id
+        where ranking.rule_id = #{ruleId} and ranking.custom_id = #{customId}
+    </select>
+
+    <update id="batchUpdateProfit" parameterType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        update activity_race_ranking
+        <trim prefix="set" suffixOverrides=",">
+            <trim prefix="rank = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.rank}
+                </foreach>
+            </trim>
+            <trim prefix="profit = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.profit}
+                </foreach>
+            </trim>
+            <trim prefix="dw = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.dw}
+                </foreach>
+            </trim>
+            <trim prefix="active = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.active}
+                </foreach>
+            </trim>
+            <trim prefix="end_equity = case" suffix="end,">
+                <foreach collection="list" item="item" index="idx">
+                    when id=#{item.id} then #{item.endEquity}
+                </foreach>
+            </trim>
+            <trim prefix="modify_time = case" suffix="end,">
+                <foreach collection="list" index="idx" item="item">
+                    when id=#{item.id} then #{item.modifyTime}
+                </foreach>
+            </trim>
+        </trim>
+        <where>
+            and id in
+            <foreach collection="list" index="idx" item="item" separator="," open="(" close=")">
+                #{item.id}
+            </foreach>
+        </where>
+    </update>
+
+    <select id="getAllByRuleId" parameterType="Long" resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRankingTable">
+        select ranking.*
+        from activity_race_ranking ranking
+        where ranking.rule_id = #{ruleId}
+    </select>
+</mapper>

+ 60 - 0
crm-activity/src/main/resources/mapper/ActivityRaceRuleMapper.xml

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.ActivityRaceRuleMapper">
+
+    <select id="findFirstBySignDateBtAndType"
+            resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable">
+        select rule.*
+        from activity_race_rule rule
+        where rule.start_date <![CDATA[<=]]> #{signDate}
+        and rule.end_date <![CDATA[>]]> #{signDate}
+        and rule.race_type = #{raceType}
+        limit 1
+    </select>
+
+    <select id="findAllLimitedByRaceType"
+            parameterType="Integer"
+            resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable">
+        select rule.*
+        from activity_race_rule rule
+        where rule.race_type = #{raceType}
+        order by rule.end_date desc
+        limit #{limit}
+    </select>
+
+    <select id="getById" parameterType="Long" resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable">
+        select *
+        from activity_race_rule where id = #{id}
+    </select>
+
+    <select id="findByCustomIdAndRaceTypeAndSerial"
+            resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable">
+        select *
+        from activity_race_rule
+        where race_type = #{raceType} and serial = #{serial}
+    </select>
+
+    <select id="getMaxSerialByRaceType" parameterType="Integer" resultType="Integer">
+        select ifnull(max(serial),0)
+        from activity_race_rule
+        where race_type = #{raceType}
+    </select>
+
+    <select id="findAllByDateBt" parameterType="java.util.Date"
+            resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceRuleTable">
+        select rule.*
+        from activity_race_rule rule
+        where rule.start_date <![CDATA[<]]> #{date}
+        and rule.end_date <![CDATA[>=]]> #{date}
+    </select>
+
+    <select id="countByStartDateAndEndDateAndRaceType" resultType="Integer">
+        select count(rule.id)
+        from activity_race_rule rule
+        where rule.start_date = #{startDate}
+        and rule.end_date = #{endDate}
+        and rule.race_type = #{raceType}
+    </select>
+</mapper>

+ 100 - 0
crm-activity/src/main/resources/mapper/ActivityRaceSignMapper.xml

@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.ActivityRaceSignMapper">
+
+    <select id="findFirstByCustomIdAndRaceType" resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceSignView">
+        select sign.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_sign sign
+        inner join custom_info ci on sign.custom_id = ci.id
+        <where>
+            sign.custom_id = #{customId}
+            and sign.race_type = #{raceType}
+        </where>
+        order by sign.sign_date desc
+        limit 1
+    </select>
+
+    <select id="countList"
+            parameterType="com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity"
+            resultType="Integer">
+        select count(sign.id)
+        from activity_race_sign sign
+        <where>
+            <if test="customId != null and customId > 0">
+                and sign.custom_id = #{customId}
+            </if>
+            <if test="cId != null and cId > 0">
+                and sign.c_id = #{cId}
+            </if>
+            <if test="login != null and login > 0">
+                and sign.login = #{login}
+            </if>
+            <if test="ruleId != null and ruleId > 0">
+                and sign.rule_id = #{ruleId}
+            </if>
+            <if test="raceType != null and raceType > 0">
+                and sign.race_type = #{raceType}
+            </if>
+            <if test="startDate != null">
+                and sign.race_end_date <![CDATA[>=]]> #{startDate}
+            </if>
+            <if test="endDate != null">
+                and sign.race_end_date <![CDATA[<=]]> #{endDate}
+            </if>
+        </where>
+    </select>
+
+    <select id="getList"
+            parameterType="com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity"
+            resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceSignView">
+        select sign.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_sign sign
+        inner join custom_info ci on sign.custom_id = ci.id
+        <where>
+            <if test="customId != null and customId > 0">
+                and sign.custom_id = #{customId}
+            </if>
+            <if test="cId != null and cId > 0">
+                and sign.c_id = #{cId}
+            </if>
+            <if test="login != null and login > 0">
+                and sign.login = #{login}
+            </if>
+            <if test="ruleId != null and ruleId > 0">
+                and sign.rule_id = #{ruleId}
+            </if>
+            <if test="raceType != null and raceType > 0">
+                and sign.race_type = #{raceType}
+            </if>
+            <if test="startDate != null">
+                and sign.race_end_date <![CDATA[>=]]> #{startDate}
+            </if>
+            <if test="endDate != null">
+                and sign.race_end_date <![CDATA[<=]]> #{endDate}
+            </if>
+        </where>
+        order by sign.race_end_date desc
+        <if test="page != null">
+            limit #{page.offset},#{page.row}
+        </if>
+    </select>
+
+    <select id="findViewById"
+            parameterType="Long"
+            resultType="com.crm.rely.backend.model.pojo.view.ActivityRaceSignView">
+        select sign.*,ci.first_name,ci.middle,ci.last_name,ci.country
+        from activity_race_sign sign
+        inner join custom_info ci on sign.custom_id = ci.id
+        where sign.id = #{id}
+    </select>
+
+    <select id="findValidSignByCustomIdAndDate" resultType="com.crm.rely.backend.model.pojo.table.ActivityRaceSignTable">
+        select sign.*
+        from activity_race_sign sign
+        where sign.custom_id = #{customId}
+        and sign.race_start_date <![CDATA[<=]]> #{date}
+        and sign.race_end_date <![CDATA[>]]> #{date}
+    </select>
+</mapper>

+ 13 - 0
crm-activity/src/main/resources/mapper/TradePositionMapper.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.activity.dao.mapper.TradePositionMapper">
+
+    <select id="countByLogin" resultType="Integer">
+        select count(trade.`order`)
+        from trade_position_view_${platform} trade
+        where trade.login = #{login}
+    </select>
+
+</mapper>

+ 11 - 0
crm-activity/src/test/java/com/crm/activity/CrmActivityApplicationTests.java

@@ -0,0 +1,11 @@
+package com.crm.activity;
+
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+class CrmActivityApplicationTests {
+
+}

+ 39 - 0
crm-activity/src/test/java/com/crm/activity/task/ActivityRaceTaskTest.java

@@ -0,0 +1,39 @@
+package com.crm.activity.task;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ *
+ * @author y
+ * @create 2022/7/22
+ */
+@SpringBootTest
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ActivityRaceTaskTest {
+
+    @Autowired
+    private ActivityRaceTask activityRaceTask;
+
+
+    @Test
+    public void generateMonthlyRule(){
+        try {
+            activityRaceTask.generateMonthlyRule();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    @Test
+    public void calcProfit(){
+        try {
+            activityRaceTask.calcProfit();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+}

+ 55 - 0
crm-custom/custom_realse_shop_start.bat

@@ -0,0 +1,55 @@
+@echo off & setlocal enabledelayedexpansion
+  ::ipconfig>ip.txt
+  
+   
+netstat -aon |findstr :8000>pid.txt
+      
+     for /f "delims=" %%a in (pid.txt) do (
+         
+      for /f "tokens=1* delims=:" %%i in ('call echo %%a^|find /i "TCP"') do (
+         echo %%a
+     ::��ȡ�����ݹ��˺�,д����һ�����±���
+     rem Echo %%a>>"text.txt"
+        ) 
+    )
+rem ��ȡ�ļ�������
+set /P OEM=<pid.txt
+  
+rem ��ȡ�ļ��е��ַ���
+  
+echo  %OEM:~71,76%
+  
+taskkill /f /pid %OEM:~71,76%
+
+@echo off
+       cd D:\server\cwg_crm\custom-service
+       D:
+       if not exist D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2% md D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2%
+       if exist "D:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" (
+	copy "D:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" "D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2%\com-crm-custom-1.0.0-%date:~10,4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "D:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+) 
+       if exist "D:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" (
+	copy "D:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" "D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2%\crm-backend-1.0.0-%date:~10,4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "D:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+)
+       if exist "D:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" (
+	copy "D:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" "D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2%\crm-login-backend-1.0.0-%date:~10,4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "D:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+)
+       if exist "D:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" (
+	copy "D:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" "D:\server\cwg_crm\backup\custom\%date:~10,4%%date:~4,2%%date:~7,2%\crm-core-1.0.0-%date:~10,4%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "D:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+)
+       cd "C:\Users\Administrator\crm\crm-custom"
+
+       copy "C:\Users\Administrator\crm\crm-custom\com-crm-custom-1.0.0.jar" "D:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-backend-1.0.0.jar" "D:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-login-backend-1.0.0.jar" "D:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-core-1.0.0.jar" "D:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+       cd "D:\server\cwg_crm\custom-service"
+       D:
+       title crm-custom
+
+       javaw  -Xmx4096m  -Dloader.path=dependency  -jar com-crm-custom-1.0.0.jar --spring.profiles.active=prod
+       echo good bye

+ 23 - 0
crm-custom/custom_shop.bat

@@ -0,0 +1,23 @@
+@echo off & setlocal enabledelayedexpansion
+  ::ipconfig>ip.txt
+  
+   
+netstat -aon |findstr 8000>pid.txt
+      
+     for /f "delims=" %%a in (pid.txt) do (
+         
+      for /f "tokens=1* delims=:" %%i in ('call echo %%a^|find /i "TCP"') do (
+         echo %%a
+     ::读取出内容过滤后,写入另一个记事本中
+     rem Echo %%a>>"text.txt"
+        ) 
+    )
+rem 读取文件中内容
+set /P OEM=<pid.txt
+  
+rem 截取文件中的字符串
+  
+echo  %OEM:~71,76%
+  
+taskkill /f /pid %OEM:~71,76%
+exit 0

+ 52 - 0
crm-custom/custom_shop_start.bat

@@ -0,0 +1,52 @@
+@echo off & setlocal enabledelayedexpansion
+  ::ipconfig>ip.txt
+  
+   
+netstat -aon |findstr 8000>pid.txt
+      
+     for /f "delims=" %%a in (pid.txt) do (
+         
+      for /f "tokens=1* delims=:" %%i in ('call echo %%a^|find /i "TCP"') do (
+         echo %%a
+     ::��ȡ�����ݹ��˺�,д����һ�����±���
+     rem Echo %%a>>"text.txt"
+        ) 
+    )
+rem ��ȡ�ļ�������
+set /P OEM=<pid.txt
+  
+rem ��ȡ�ļ��е��ַ���
+  
+echo  %OEM:~71,76%
+  
+taskkill /f /pid %OEM:~71,76%
+
+@echo off
+       cd C:\server\cwg_crm\custom-service
+       if not exist C:\server\cwg_crm\backup\custom md C:\server\cwg_crm\backup\custom
+       if exist "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\backup\custom\com-crm-custom-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+) 
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-login-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-core-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+)
+       cd "C:\Users\Administrator\crm\crm-custom"
+
+       copy "C:\Users\Administrator\crm\crm-custom\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+       cd "C:\server\cwg_crm\custom-service"
+       title crm-custom
+       javaw -Xmx1024m  -Dloader.path=dependency  -jar com-crm-custom-1.0.0.jar --spring.profiles.active=prod
+       echo good bye

+ 30 - 0
crm-custom/custom_start.bat

@@ -0,0 +1,30 @@
+@echo off
+       cd C:\server\cwg_crm\custom-service
+       if not exist C:\server\cwg_crm\backup\custom md C:\server\cwg_crm\backup\custom
+       if exist "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\backup\custom\com-crm-custom-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+) 
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-login-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-core-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+)
+       cd "C:\Users\Administrator\crm\crm-custom"
+       c:
+       copy "C:\Users\Administrator\crm\crm-custom\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+       C:\server
+       cd "C:\server\cwg_crm\custom-service"
+       title crm-custom
+       java -Xmx512m -Dloader.path=dependency  -jar com-crm-custom-1.0.0.jar --spring.profiles.active=prod
+       echo good bye

+ 52 - 0
crm-custom/custom_test_shop_start.bat

@@ -0,0 +1,52 @@
+@echo off & setlocal enabledelayedexpansion
+  ::ipconfig>ip.txt
+  
+   
+netstat -aon |findstr 8000>pid.txt
+      
+     for /f "delims=" %%a in (pid.txt) do (
+         
+      for /f "tokens=1* delims=:" %%i in ('call echo %%a^|find /i "TCP"') do (
+         echo %%a
+     ::��ȡ�����ݹ��˺�,д����һ�����±���
+     rem Echo %%a>>"text.txt"
+        ) 
+    )
+rem ��ȡ�ļ�������
+set /P OEM=<pid.txt
+  
+rem ��ȡ�ļ��е��ַ���
+  
+echo  %OEM:~71,76%
+  
+taskkill /f /pid %OEM:~71,76%
+
+@echo off
+       cd C:\server\cwg_crm\custom-service
+       if not exist C:\server\cwg_crm\backup\custom md C:\server\cwg_crm\backup\custom
+       if exist "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\backup\custom\com-crm-custom-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+) 
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-login-backend-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+)
+       if exist "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" (
+	copy "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\backup\custom\crm-core-1.0.0-%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.jar"
+	del "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+)
+       cd "C:\Users\Administrator\crm\crm-custom"
+
+       copy "C:\Users\Administrator\crm\crm-custom\com-crm-custom-1.0.0.jar" "C:\server\cwg_crm\custom-service\com-crm-custom-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-login-backend-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-login-backend-1.0.0.jar"
+       copy "C:\Users\Administrator\crm\crm-custom\dependency\crm-core-1.0.0.jar" "C:\server\cwg_crm\custom-service\dependency\crm-core-1.0.0.jar"
+       cd "C:\server\cwg_crm\custom-service"
+       title crm-custom
+       javaw -Xmx1024m  -Dloader.path=dependency  -jar com-crm-custom-1.0.0.jar --spring.profiles.active=test
+       echo good bye

+ 0 - 0
crm-custom/pid.txt


+ 154 - 0
crm-custom/pom.xml

@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.crm.custom</groupId>
+    <artifactId>com-crm-custom</artifactId>
+    <version>1.0.0</version>
+    <packaging>jar</packaging>
+
+    <name>com_crm_custom</name>
+    <description>crm custom module for eman</description>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.8.RELEASE</version>
+        <relativePath/> <!-- lookup parent fromAccount repository -->
+    </parent>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <spring-cloud.version>Dalston.SR5</spring-cloud.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.crm.login.backend</groupId>
+            <artifactId>crm-login-backend</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.crm.model</groupId>
+            <artifactId>crm-model</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!--mybatis-->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-feign</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.maxmind.geoip2</groupId>
+            <artifactId>geoip2</artifactId>
+            <version>2.9.0</version>
+        </dependency>
+
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring-cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <outputDirectory>
+                        ${project.build.directory}/../../lib
+                    </outputDirectory>
+                    <layout>ZIP</layout>
+                    <includes>
+                        <include>
+                            <groupId>com.crm.custom</groupId>
+                            <artifactId>com-crm-custom</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.mybatis.generator</groupId>
+                <artifactId>mybatis-generator-maven-plugin</artifactId>
+                <version>1.3.5</version>
+            </plugin>
+        </plugins>
+    </build>
+
+    <repositories>
+        <repository>
+            <id>spring-snapshots</id>
+            <name>Spring Snapshots</name>
+            <url>https://repo.spring.io/snapshot</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>spring-milestones</id>
+            <name>Spring Milestones</name>
+            <url>https://repo.spring.io/milestone</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <pluginRepositories>
+        <pluginRepository>
+            <id>spring-snapshots</id>
+            <name>Spring Snapshots</name>
+            <url>https://repo.spring.io/snapshot</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+        <pluginRepository>
+            <id>spring-milestones</id>
+            <name>Spring Milestones</name>
+            <url>https://repo.spring.io/milestone</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </pluginRepository>
+    </pluginRepositories>
+
+
+</project>

+ 24 - 0
crm-custom/src/main/java/com/crm/custom/CustomApplication.java

@@ -0,0 +1,24 @@
+package com.crm.custom;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @author houn
+ */
+@SpringBootApplication
+@EnableEurekaClient
+@EnableFeignClients
+@EnableScheduling
+@EntityScan({"com.crm.rely.backend.core.pojo.table","com.crm.rely.backend.model.pojo.table"})
+@MapperScan("com.crm.custom.dao.mapper")
+public class CustomApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(CustomApplication.class, args);
+    }
+}

+ 50 - 0
crm-custom/src/main/java/com/crm/custom/configuration/FeignConfiguration.java

@@ -0,0 +1,50 @@
+package com.crm.custom.configuration;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.service.RedisService;
+import com.crm.rely.backend.util.UUIDUtil;
+import com.google.common.base.Strings;
+import feign.RequestInterceptor;
+import feign.RequestTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by max on 2020/6/17.
+ */
+@Configuration
+public class FeignConfiguration implements RequestInterceptor {
+
+    @Autowired
+    private RedisService redisService;
+
+    @Override
+    public void apply(RequestTemplate requestTemplate) {
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if (null != attributes) {
+
+            String feignToken = UUIDUtil.getUUID();
+
+            HttpServletRequest request = attributes.getRequest();
+            String token = request.getHeader(Constants.ACCESS_TOKEN);
+            String language = request.getHeader(Constants.Language);
+            if (Strings.isNullOrEmpty(token)) {
+                token = feignToken;
+            }
+            requestTemplate.header(Constants.ACCESS_TOKEN, token);
+            requestTemplate.header(Constants.Feign_Token, feignToken);
+            requestTemplate.header(Constants.Language, language);
+
+            try {
+                redisService.saveObject(feignToken, token, Constants.Feign_Token_TIME);
+            } catch (ServiceException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 107 - 0
crm-custom/src/main/java/com/crm/custom/controller/AccountApplyPasswordResetController.java

@@ -0,0 +1,107 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.*;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.constant.FeignClientAnnotation;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.account.apply.password.reset.AccountApplyPasswordResetAddEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import com.crm.rely.backend.model.pojo.table.CustomLoginAssetManagementTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginDemoTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
+import com.crm.rely.backend.model.pojo.view.CustomLoginView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/account/password/reset")
+public class AccountApplyPasswordResetController extends BaseLoginController {
+
+    @Autowired
+    private AccountApplyPasswordResetService service;
+
+    @Autowired
+    private CustomLoginDemoService customLoginDemoService;
+
+    @Autowired
+    private CustomLoginFirmOfferService customLoginFirmOfferService;
+
+    @Autowired
+    private CustomLoginAssetManagementService customLoginAssetManagementService;
+
+    @Autowired
+    private CustomLoginService customLoginService;
+
+    @PostMapping("/apply")
+    public BaseResultDto<Object> customAdd(@RequestBody @Validated AccountApplyPasswordResetAddEntity entity,
+                                              CustomInfoEntity infoEntity) throws Exception {
+
+        switch (entity.getLoginType()) {
+            case 1:
+                CustomLoginDemoTable customLoginDemoTable = customLoginDemoService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginDemoTable.getCustomId());
+                entity.setCId(customLoginDemoTable.getCId());
+                break;
+            case 2:
+                CustomLoginFirmOfferTable customLoginFirmOfferServiceByLogin = customLoginFirmOfferService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginFirmOfferServiceByLogin.getCustomId());
+                entity.setCId(customLoginFirmOfferServiceByLogin.getCId());
+                break;
+            case 3:
+                CustomLoginAssetManagementTable customLoginAssetManagementTable = customLoginAssetManagementService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginAssetManagementTable.getCustomId());
+                entity.setCId(customLoginAssetManagementTable.getCId());
+                break;
+            case 4:
+                CustomLoginView customLoginView = customLoginService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginView.getCustomId());
+                entity.setCId(customLoginView.getCId());
+                break;
+        }
+
+        if (infoEntity.getId().equals(entity.getCustomId())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+
+        service.addAccountApply(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/add")
+    @FeignClientAnnotation
+    public BaseResultDto<Object> managerAdd(@RequestBody @Validated AccountApplyPasswordResetAddEntity entity) throws Exception {
+
+
+        switch (entity.getLoginType()) {
+            case 1:
+                CustomLoginDemoTable customLoginDemoTable = customLoginDemoService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginDemoTable.getCustomId());
+                entity.setCId(customLoginDemoTable.getCId());
+                break;
+            case 2:
+                CustomLoginFirmOfferTable customLoginFirmOfferServiceByLogin = customLoginFirmOfferService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginFirmOfferServiceByLogin.getCustomId());
+                entity.setCId(customLoginFirmOfferServiceByLogin.getCId());
+                break;
+            case 3:
+                CustomLoginAssetManagementTable customLoginAssetManagementTable = customLoginAssetManagementService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginAssetManagementTable.getCustomId());
+                entity.setCId(customLoginAssetManagementTable.getCId());
+                break;
+            case 4:
+                CustomLoginView customLoginView = customLoginService.getByLogin(entity.getLogin());
+                entity.setCustomId(customLoginView.getCustomId());
+                entity.setCId(customLoginView.getCId());
+                break;
+        }
+
+        service.addAccountApply(entity);
+        return BaseResultDto.success();
+    }
+
+}

+ 56 - 0
crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceRankingController.java

@@ -0,0 +1,56 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.activity.ActivityRaceRankingFeignService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.core.entity.login.InfoEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingDto;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceRankingProfitCoverDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRankingMyEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 比赛排名api
+ *
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/activity/race/ranking")
+public class ActivityRaceRankingController {
+
+    @Autowired
+    private ActivityRaceRankingFeignService activityRaceRankingFeignService;
+
+//    @PostMapping("/search/list")
+//    public BaseResultWithPagerDto<List<ActivityRaceRankingDto>>
+//    searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
+//        return activityRaceRankingFeignService.searchList(entity);
+//    }
+
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceRankingProfitCoverDto>>
+    searchList(@RequestBody ActivityRaceRankingListEntity entity) throws Exception {
+        return activityRaceRankingFeignService.searchListCover(entity);
+    }
+
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceRankingDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return activityRaceRankingFeignService.searchSingle(entity);
+    }
+
+    @PostMapping("/search/my")
+    public BaseResultDto<ActivityRaceRankingDto> searchMy(@RequestBody ActivityRaceRankingMyEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        return activityRaceRankingFeignService.searchMy(entity);
+    }
+
+}

+ 32 - 0
crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceRuleController.java

@@ -0,0 +1,32 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.activity.ActivityRaceRuleFeignService;
+import com.crm.rely.backend.core.dto.base.BaseLongSelectDto;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.entity.login.InfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceRuleDropDownEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author y
+ * @create 2022/7/21
+ */
+@RestController
+@RequestMapping("/activity/race/rule")
+public class ActivityRaceRuleController {
+
+    @Autowired
+    private ActivityRaceRuleFeignService activityRaceRuleFeignService;
+
+    @PostMapping("/dropdown")
+    public BaseResultDto<List<BaseLongSelectDto>> dropdown(@RequestBody ActivityRaceRuleDropDownEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        return activityRaceRuleFeignService.dropdown(entity);
+    }
+}

+ 107 - 0
crm-custom/src/main/java/com/crm/custom/controller/ActivityRaceSignController.java

@@ -0,0 +1,107 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomInfoService;
+import com.crm.custom.service.activity.ActivityRaceSignFeignService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.core.entity.login.InfoEntity;
+import com.crm.rely.backend.model.dto.activity.ActivityRaceSignInfoDto;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignAddEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignInfoEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignListEntity;
+import com.crm.rely.backend.model.entity.activity.ActivityRaceSignLoginEntity;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 比赛报名api
+ *
+ * @author y
+ * @create 2022/7/19
+ */
+@RestController
+@RequestMapping("/activity/race/sign")
+public class ActivityRaceSignController extends BaseLoginController {
+
+    @Autowired
+    private ActivityRaceSignFeignService activityRaceSignFeignService;
+    @Autowired
+    private CustomInfoService customInfoService;
+
+    /**
+     * 添加报名
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/add")
+    public BaseResultDto<Boolean> add(@RequestBody ActivityRaceSignAddEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        CustomInfoTable custom = customInfoService.getById(infoEntity.getId());
+        entity.setCId(custom.getCId());
+        entity.setSignDate(new Date());
+        return activityRaceSignFeignService.add(entity);
+    }
+
+    /**
+     * 最近一次报名信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/recent")
+    public BaseResultDto<ActivityRaceSignInfoDto> info(@RequestBody ActivityRaceSignInfoEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        return activityRaceSignFeignService.info(entity);
+    }
+
+    /**
+     * 根据ID获取报名信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/single")
+    public BaseResultDto<ActivityRaceSignInfoDto> searchSingle(@RequestBody SingleLongEntity entity) throws Exception {
+        return activityRaceSignFeignService.searchSingle(entity);
+    }
+
+    /**
+     * 报名列表
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/search/list")
+    public BaseResultWithPagerDto<List<ActivityRaceSignInfoDto>>
+    searchList(@RequestBody ActivityRaceSignListEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        return activityRaceSignFeignService.searchList(entity);
+    }
+
+    /**
+     * 获取可用的交易账户
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/logins")
+    public BaseResultDto<List<Long>> logins(@RequestBody ActivityRaceSignLoginEntity entity, InfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        return activityRaceSignFeignService.logins(entity);
+    }
+}

+ 67 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomBankController.java

@@ -0,0 +1,67 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomBankService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.custom.bank.CustomBankAddEntity;
+import com.crm.rely.backend.model.entity.custom.bank.CustomBankDeleteEntity;
+import com.crm.rely.backend.model.entity.custom.bank.CustomBankUpdateEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/custom/bank")
+public class CustomBankController extends BaseLoginController {
+
+    @Autowired
+    private CustomBankService customBankService;
+
+    @PostMapping("/add")
+    public BaseResultDto add(@RequestBody @Validated CustomBankAddEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setCustomId(infoEntity.getId());
+
+        customBankService.add(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/update")
+    public BaseResultDto update(@RequestBody @Validated CustomBankUpdateEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setCustomId(infoEntity.getId());
+
+        customBankService.update(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/delete")
+    public BaseResultDto delete(@RequestBody @Validated CustomBankDeleteEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setCustomId(infoEntity.getId());
+
+        customBankService.delete(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/upload")
+    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file,
+                                CustomInfoEntity infoEntity, HttpServletRequest req) throws Exception {
+
+        customBankService.validated(file);
+
+        String path = customBankService.uploadBankFile(infoEntity.getId(), file);
+        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, path);
+    }
+}

+ 378 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomController.java

@@ -0,0 +1,378 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomInfoService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.*;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.constant.CustomConstants;
+import com.crm.rely.backend.model.dto.custom.InfoDto;
+import com.crm.rely.backend.model.dto.custom.login.CustomInfoAmountDto;
+import com.crm.rely.backend.model.dto.user.info.UserInfoDto;
+import com.crm.rely.backend.model.entity.custom.info.*;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import com.crm.rely.backend.service.EmailService;
+import com.crm.rely.backend.service.SysCountryService;
+import com.crm.rely.backend.util.GetIpAndMac;
+import com.crm.rely.backend.util.MD5Util;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.LocaleResolver;
+import org.springframework.web.servlet.support.RequestContextUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/custom")
+public class CustomController extends BaseLoginController {
+
+
+    @Autowired
+    private CustomInfoService customInfoService;
+
+    @Autowired
+    private EmailService emailService;
+
+    @Autowired
+    private SysCountryService sysCountryService;
+
+    /**
+     * 注册用户 发送短信验证码
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/register/send/code")
+    public BaseResultDto registerSendCode(@RequestBody @Validated CustomInfoRegisterSendEmailCodeEntity entity, HttpServletRequest req) throws Exception {
+
+        entity.setIp(GetIpAndMac.getIp(req));
+        entity.setTime(new Date());
+        customInfoService.registerSendEmailCode(entity);
+
+        return BaseResultDto.success(Constants.SEND_SUCCESS);
+    }
+
+    /**
+     * 注册用户
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/register")
+    public BaseResultDto add(@RequestBody @Validated CustomInfoRegisterEntity entity) throws Exception {
+
+        entity.setEmail(entity.getEmail().toLowerCase());
+
+        //密码
+        entity.setPassword(MD5Util.getMD5(entity.getPassword()));
+
+        entity.setValid(1);
+        entity.setStatus(StatusConstants.APPLY_STATUS);
+        entity.setPosition(CustomConstants.POSITION1);
+        customInfoService.add(entity);
+
+        return BaseResultDto.success(Constants.REGISTER_SUCCESS);
+    }
+
+    @PostMapping("/apply/real")
+    public BaseResultDto applyReal(CustomInfoEntity infoEntity, HttpServletRequest httpServletRequest) throws Exception {
+        Runnable runnable = () -> {
+
+            CustomApplyRealEntity customApplyRealEntity = new CustomApplyRealEntity();
+            customApplyRealEntity.setCustomId(infoEntity.getId());
+            customApplyRealEntity.setApplyRealTime(new Date());
+            CustomInfoTable customInfoTable = customInfoService.applyReal(customApplyRealEntity);
+
+            infoEntity.setApplyRealStatus(customInfoTable.getApplyRealStatus());
+            infoEntity.setStatus(customInfoTable.getStatus());
+            infoEntity.setApplyRealTime(customInfoTable.getApplyRealTime());
+            try {
+                super.saveLoginInfo(infoEntity);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        };
+
+        redisService.tryLock(infoEntity, httpServletRequest, runnable, "no_repeat_submit_error");
+
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 修改邮件发送验证码
+     *
+     * @param entity
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/update/email/send/code")
+    public BaseResultDto registerSendCode(@RequestBody @Validated CustomInfoUpdateEmailSendEmailCodeEntity entity, HttpServletRequest req, CustomInfoEntity infoEntity) throws Exception {
+
+        if (!entity.getOldEmail().equals(infoEntity.getEmail())) {
+            return BaseResultDto.error(Constants.LOGIN_EMAIL_ERROR);
+        }
+
+        entity.setCountry(infoEntity.getCountry());
+        entity.setIp(GetIpAndMac.getIp(req));
+        entity.setTime(new Date());
+
+        customInfoService.updateEmailSendEmailCode(entity);
+
+        return BaseResultDto.success(Constants.SEND_SUCCESS);
+    }
+
+    @PostMapping("/update/email")
+    public BaseResultDto updateEmail(@RequestBody @Validated CustomInfoUpdateEmailEntity entity, HttpServletRequest req, CustomInfoEntity infoEntity) throws Exception {
+        entity.setEmail(entity.getEmail().toLowerCase());
+        entity.setOldEmail(entity.getOldEmail().toLowerCase());
+        if (!entity.getOldEmail().equals(infoEntity.getEmail())) {
+            return BaseResultDto.error(Constants.LOGIN_EMAIL_ERROR);
+        }
+
+        entity.setCustomId(infoEntity.getId());
+        entity.setModifyIp(GetIpAndMac.getIp(req));
+        entity.setModifyTime(new Date());
+        entity.setModifyUser(infoEntity.getId());
+        customInfoService.updateEmail(entity);
+
+        //更新缓存上的信息
+        infoEntity.setEmail(entity.getEmail());
+        if (infoEntity.getIbInfo() != null) {
+            infoEntity.getIbInfo().setEmail(entity.getEmail());
+        }
+
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success(Constants.REGISTER_SUCCESS);
+    }
+
+    /**
+     * 登录信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/login")
+    public BaseResultDto login(@RequestBody @Validated CustomInfoLoginEntity entity, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        entity.setLoginName(entity.getLoginName().toLowerCase());
+        //密码处理为
+        entity.setPassword(MD5Util.getMD5(entity.getPassword()));
+
+        /**
+         * 处理登录时间 登录ip 登录地区
+         */
+        entity.setIp(sysCountryService.getAdderByIp(request));
+
+        entity.setAddress(entity.getIp());
+        entity.setTime(new Date());
+
+        CustomInfoEntity infoEntity = customInfoService.login(entity);
+
+        infoEntity.setPrefix(PrefixEnum.PREFIX_CUSTOM);
+
+        String accessToken = super.login(infoEntity, entity.getSource());
+        setLocaleResolver(infoEntity.getLang(), request, response);
+
+        return BaseResultDto.success(Constants.LOGIN_SUCCESS, accessToken);
+    }
+
+    @PostMapping("/get/language")
+    public BaseResultDto getLanguage(HttpServletRequest request) throws Exception {
+        String language = request.getHeader("accept-language");
+        return BaseResultDto.success(language);
+    }
+
+    /**
+     * 退出登录
+     *
+     * @param httpServletRequest
+     * @throws Exception
+     */
+    @Override
+    @PostMapping("/logout")
+    public BaseResultDto logout(HttpServletRequest httpServletRequest) throws Exception {
+
+        return super.logout(httpServletRequest);
+    }
+
+    /**
+     * 获取登录信息
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/info")
+    public BaseResultDto info(CustomInfoEntity entity) throws Exception {
+
+        InfoDto infoDto = new InfoDto();
+
+        BeanUtils.copyProperties(entity, infoDto);
+
+        if (entity.getIbInfo() != null) {
+            UserInfoDto ibInfoDto = new UserInfoDto();
+            BeanUtils.copyProperties(entity.getIbInfo(), ibInfoDto);
+            infoDto.setIbInfo(ibInfoDto);
+        } else {
+            infoDto.setIbInfo(null);
+        }
+        infoDto.setPosition(customInfoService.getPosition(entity.getId()));
+        return BaseResultDto.success(infoDto);
+    }
+
+    @PostMapping("/get/amount")
+    public BaseResultDto getAmount(CustomInfoEntity entity) throws Exception {
+
+        CustomInfoAmountDto customInfoAmountDto = new CustomInfoAmountDto();
+
+        CustomInfoTable customInfoTable = customInfoService.getById(entity.getId());
+        BeanUtils.copyProperties(customInfoTable, customInfoAmountDto);
+        return BaseResultDto.success(customInfoAmountDto);
+    }
+
+    /**
+     * 修改用户信息,
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/update/info")
+    public BaseResultDto update(@RequestBody @Validated CustomInfoUpdateEntity entity, HttpServletRequest req, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setId(infoEntity.getId());
+        entity.setModifyIp(sysCountryService.getAdderByIp(req));
+        entity.setModifyTime(new Date());
+        entity.setValid(1);
+        entity.setSno(null);
+        customInfoService.update(entity);
+
+        infoEntity.setValid(entity.getValid());
+        //更新redis数据
+        BeanUtils.copyProperties(entity, infoEntity);
+        saveLoginInfo(infoEntity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manage/update/info")
+    @FeignClientAnnotation
+    public BaseResultDto manageUpdate(@RequestBody @Validated CustomInfoUpdateEntity entity, HttpServletRequest req) throws Exception {
+
+        entity.setModifyIp(sysCountryService.getAdderByIp(req));
+        entity.setModifyTime(new Date());
+        entity.setValid(1);
+
+        customInfoService.update(entity);
+
+        CustomInfoEntity customInfoEntity =
+                redisService.getEntity(PrefixEnum.PREFIX_CUSTOM.getCode() + entity.getId(), CustomInfoEntity.class);
+        if (customInfoEntity != null) {
+            BeanUtils.copyProperties(entity, customInfoEntity);
+            saveLoginInfo(customInfoEntity);
+        }
+
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 登录修改密码
+     *
+     * @param entity
+     * @param req
+     * @param infoEntity
+     * @return
+     */
+    @PostMapping("/update/login/password")
+    public BaseResultDto updatePassword(@RequestBody @Validated CustomUpdateLoginPasswordEntity entity, HttpServletRequest req, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setId(infoEntity.getId());
+        if (entity.getNewPassword().equals(entity.getOldPassword())) {
+            return BaseResultDto.error(Constants.PASSWORD_NEW_AND_OLD_IDENTICAL_ERROR);
+        }
+
+        entity.setModifyIp(sysCountryService.getAdderByIp(GetIpAndMac.getIp(req)));
+        entity.setModifyTime(new Date());
+        entity.setModifyUser(infoEntity.getId());
+        entity.setNewPassword(MD5Util.getMD5(entity.getNewPassword()));
+        entity.setOldPassword(MD5Util.getMD5(entity.getOldPassword()));
+
+        customInfoService.updatePassword(entity);
+        return BaseResultDto.success(Constants.UPDATE_SUCCESS);
+    }
+
+    /**
+     * 未登录修改密码发送邮件
+     *
+     * @param entity
+     * @param req
+     * @return
+     */
+    @PostMapping("/update/password/send/email")
+    public BaseResultDto updatePasswordSendEmail(@RequestBody @Validated CustomUpdatePasswordSendEmailEntity entity, HttpServletRequest req) throws Exception {
+        String ip = GetIpAndMac.getIp(req);
+        emailService.validate(ip, EmailSendEnum.FORGET_PASSWORD.getCode(), ip);
+
+        entity.setIp(ip);
+        entity.setTime(new Date());
+        customInfoService.updatePasswordSendEmail(entity);
+
+        return BaseResultDto.success(Constants.SEND_SUCCESS);
+    }
+
+    /**
+     * 未登录根据邮件修改密码
+     *
+     * @param entity
+     * @param req
+     * @return
+     */
+    @PostMapping("/update/email/password")
+    public BaseResultDto updatePassword(@RequestBody @Validated CustomUpdateEmailPasswordEntity entity, HttpServletRequest req) throws Exception {
+
+        entity.setModifyIp(GetIpAndMac.getIp(req));
+        entity.setModifyTime(new Date());
+        entity.setPassword(MD5Util.getMD5(entity.getPassword()));
+
+        customInfoService.updatePassword(entity);
+
+        return BaseResultDto.success(Constants.SUCCESS);
+    }
+
+    @PostMapping("/manage/update/agent")
+    @FeignClientAnnotation
+    public BaseResultDto manageUpdateAgentId(@RequestBody @Validated CustomInfoUpdateAgentEntity entity) throws Exception {
+
+        customInfoService.updateAgentId(entity);
+
+        return BaseResultDto.success();
+    }
+
+    private void setLocaleResolver(String lang, HttpServletRequest request, HttpServletResponse response) {
+        LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
+        try {
+            if ("cn".equals(lang)) {
+
+                localeResolver.setLocale(request, response, new Locale("zh", "CN"));
+            } else {
+                localeResolver.setLocale(request, response, new Locale("en", "US"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 249 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomFileController.java

@@ -0,0 +1,249 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomFileService;
+import com.crm.custom.service.PushMessageFeignService;
+import com.crm.custom.service.SysConfigService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.*;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.custom.file.CustomFileDto;
+import com.crm.rely.backend.core.entity.websocket.WebsocketPushMessageEntity;
+import com.crm.rely.backend.core.entity.websocket.bank.file.WebSocketCustomFileEntity;
+import com.crm.rely.backend.core.pojo.table.SysConfigTable;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.entity.custom.file.CustomFileAddAndUpdateEntity;
+import com.crm.rely.backend.model.entity.custom.file.CustomFileAllEntity;
+import com.crm.rely.backend.model.entity.custom.file.CustomFileApproveEntity;
+import com.crm.rely.backend.model.entity.custom.file.CustomFileDeleteEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import com.crm.rely.backend.model.entity.custom.info.InfoEntity;
+import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
+import com.crm.rely.backend.util.GetIpAndMac;
+import com.crm.rely.backend.util.QRCodeImgeUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/custom/file")
+public class CustomFileController extends BaseLoginController {
+
+    @Autowired
+    private CustomFileService customFileService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @Autowired
+    private PushMessageFeignService pushMessageFeignService;
+
+    @PostMapping("/upload/{type}")
+    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file, @PathVariable("type") Integer type, HttpServletRequest req,
+                                CustomInfoEntity infoEntity) throws Exception {
+
+
+        return upload(file, type, null, req, infoEntity);
+    }
+
+    @PostMapping("/upload/{type}/{id}")
+    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file, @PathVariable("type") Integer type, @PathVariable("id") Long id,
+                                HttpServletRequest req, CustomInfoEntity infoEntity) throws Exception {
+
+        customFileService.validated(file);
+
+        CustomFileAddAndUpdateEntity customFileAddAndUpdateEntity = new CustomFileAddAndUpdateEntity();
+        customFileAddAndUpdateEntity.setCustomId(infoEntity.getId());
+        customFileAddAndUpdateEntity.setType(type);
+        customFileAddAndUpdateEntity.setId(id);
+        customFileAddAndUpdateEntity.setIp(GetIpAndMac.getIp(req));
+        customFileAddAndUpdateEntity.setTime(new Date());
+        customFileAddAndUpdateEntity.setUser(infoEntity.getId());
+        customFileAddAndUpdateEntity.setUploadUserType(1);
+        CustomFileDto customFileDto = customFileService.save(customFileAddAndUpdateEntity, file);
+
+        setCache(type, customFileDto, infoEntity);
+        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, customFileDto);
+    }
+
+    @PostMapping("/delete")
+    public BaseResultDto delete(@RequestBody @Validated CustomFileDeleteEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setCustomId(infoEntity.getId());
+        customFileService.delete(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/delete")
+    @FeignClientAnnotation
+    public BaseResultDto managerDelete(@RequestBody @Validated CustomFileDeleteEntity entity) throws Exception {
+
+        customFileService.delete(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/upload/{customId}/{type}")
+    @FeignClientAnnotation
+    public BaseResultDto mangerUpload(@RequestParam(value = "file", required = false) MultipartFile file, @PathVariable("customId") Long customId, @PathVariable("type") Integer type, HttpServletRequest req,
+                                      UserInfoEntity infoEntity) throws Exception {
+
+        customFileService.validated(file);
+
+        CustomFileAddAndUpdateEntity customFileAddAndUpdateEntity = new CustomFileAddAndUpdateEntity();
+        customFileAddAndUpdateEntity.setCustomId(customId);
+        customFileAddAndUpdateEntity.setType(type);
+        customFileAddAndUpdateEntity.setIp(GetIpAndMac.getIp(req));
+        customFileAddAndUpdateEntity.setTime(new Date());
+        customFileAddAndUpdateEntity.setUser(infoEntity.getId());
+        customFileAddAndUpdateEntity.setUploadUserType(2);
+
+        CustomFileDto customFileDto = customFileService.save(customFileAddAndUpdateEntity, file);
+
+        CustomInfoEntity customInfoEntity =
+                redisService.getEntity(PrefixEnum.PREFIX_CUSTOM.getCode() +customId, CustomInfoEntity.class);
+        if (customInfoEntity != null) {
+            setCache(type, customFileDto, customInfoEntity);
+        }
+
+
+        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, customFileDto);
+    }
+
+    @PostMapping("/manager/upload/{customId}/{type}/{id}")
+    @FeignClientAnnotation
+    public BaseResultDto mangerUpload(@RequestParam(value = "file", required = false) MultipartFile file, @PathVariable("customId") Long customId, @PathVariable("type") Integer type, @PathVariable("id") Long id,
+                                      HttpServletRequest req, UserInfoEntity infoEntity) throws Exception {
+
+        customFileService.validated(file);
+
+        CustomFileAddAndUpdateEntity customFileAddAndUpdateEntity = new CustomFileAddAndUpdateEntity();
+        customFileAddAndUpdateEntity.setCustomId(customId);
+        customFileAddAndUpdateEntity.setType(type);
+        customFileAddAndUpdateEntity.setId(id);
+        customFileAddAndUpdateEntity.setIp(GetIpAndMac.getIp(req));
+        customFileAddAndUpdateEntity.setTime(new Date());
+        customFileAddAndUpdateEntity.setUser(infoEntity.getId());
+        customFileAddAndUpdateEntity.setUploadUserType(2);
+
+        CustomFileDto customFileDto = customFileService.save(customFileAddAndUpdateEntity, file);
+
+        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, customFileDto);
+    }
+
+    @PostMapping("/list")
+    public BaseResultDto list(CustomInfoEntity infoEntity) throws Exception {
+
+        CustomFileAllEntity entity = new CustomFileAllEntity();
+        entity.setCustomId(infoEntity.getId());
+        List<CustomFileDto> customFileDtos = customFileService.getAllFiles(entity);
+
+        if (customFileDtos == null) {
+            customFileDtos = new ArrayList<>(0);
+        }
+        return BaseResultDto.success(Constants.SUCCESS, customFileDtos);
+    }
+
+    @PostMapping("/manager/search/list")
+    @FeignClientAnnotation
+    public BaseResultDto manageSearchList(@RequestBody @Validated CustomFileAllEntity entity) throws Exception {
+
+        List<CustomFileDto> customFileDtos = customFileService.getAllFiles(entity);
+
+        if (customFileDtos == null) {
+            customFileDtos = new ArrayList<>(0);
+        }
+        return BaseResultDto.success(Constants.SUCCESS, customFileDtos);
+    }
+
+    @PostMapping("/manager/approve")
+    @FeignClientAnnotation
+    public BaseResultDto manageApprove(@RequestBody @Validated CustomFileApproveEntity entity) throws Exception {
+
+        customFileService.approve(entity);
+
+        return BaseResultDto.success(Constants.APPROVE_SUCCESS);
+    }
+
+    @GetMapping("/mobile")
+    public void websocketMobile(HttpServletRequest req, HttpServletResponse response) throws Exception {
+        String token = req.getHeader(Constants.ACCESS_TOKEN);
+        String localhost;
+        try {
+            SysConfigTable sysConfigTable = sysConfigService.getByCode(GlobalConfigConstants.WEB_MY_URE_CONFIG);
+            localhost = sysConfigTable.getValue();
+        } catch (ServiceException e) {
+            localhost = GetIpAndMac.getIpAndPort();
+        }
+        String mobileUploadIndex;
+        try {
+            SysConfigTable sysConfigTable = sysConfigService.getByCode(GlobalConfigConstants.WEB_MY_URL_MOBILE_UPLOAD_CONFIG);
+            mobileUploadIndex = sysConfigTable.getValue();
+        } catch (ServiceException e) {
+            mobileUploadIndex = null;
+        }
+
+        BufferedImage bufferedImage = QRCodeImgeUtil.getQRCodeImge(localhost + mobileUploadIndex + "?" + Constants.ACCESS_TOKEN + "=" + token);
+
+        response.setContentType("image/jpg");
+        try {
+            OutputStream out = response.getOutputStream();
+
+            ImageIO.write(bufferedImage, "jpg", out);
+            out.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void pushMessage(HttpServletRequest req, CustomFileDto customFileDto) {
+        WebSocketCustomFileEntity webSocketCustomFileEntity = new WebSocketCustomFileEntity();
+        BeanUtils.copyProperties(customFileDto, webSocketCustomFileEntity);
+        webSocketCustomFileEntity.setNewsType(NewsConstants.NEWS_CUSTOM_FILE);
+        String accessToken = req.getHeader(Constants.ACCESS_TOKEN);
+        WebsocketPushMessageEntity websocketPushMessageEntity = new WebsocketPushMessageEntity();
+        websocketPushMessageEntity.setToken(accessToken);
+        websocketPushMessageEntity.setData(webSocketCustomFileEntity);
+        try {
+            pushMessageFeignService.pushMessageToTokenNotice(websocketPushMessageEntity);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    private void setCache(int type, CustomFileDto customFileDto, CustomInfoEntity infoEntity) throws Exception {
+        boolean push = false;
+        if (infoEntity.getFiles() != null && infoEntity.getFiles().size() > 0) {
+
+            for (CustomFileDto infoEntityFile : infoEntity.getFiles()) {
+                if (infoEntityFile.getType().equals(type)) {
+                    BeanUtils.copyProperties(customFileDto, infoEntityFile);
+                    push = true;
+                    break;
+                }
+            }
+        }
+
+        if (!push) {
+            List<CustomFileDto> fileDtos = new ArrayList<>(1);
+            infoEntity.setFiles(fileDtos);
+        }
+        saveLoginInfo(infoEntity);
+    }
+
+}

+ 29 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomFirmOfferRollController.java

@@ -0,0 +1,29 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomLoginFirmOfferService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.dto.custom.login.CustomLoginFirmOfferRollDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/roll")
+public class CustomFirmOfferRollController extends BaseLoginController {
+    @Autowired
+    private CustomLoginFirmOfferService service;
+
+    @PostMapping("/firm/offer/list")
+    public BaseResultDto searchList() throws Exception {
+
+
+        List<CustomLoginFirmOfferRollDto> dtos = service.rollList();
+
+        return BaseResultDto.success(dtos);
+    }
+
+}

+ 639 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomLoginController.java

@@ -0,0 +1,639 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.*;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.constant.FeignClientAnnotation;
+import com.crm.rely.backend.core.constant.PrefixEnum;
+import com.crm.rely.backend.core.constant.StatusConstants;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.constant.CustomConstants;
+import com.crm.rely.backend.model.dto.custom.login.*;
+import com.crm.rely.backend.model.entity.account.apply.AccountApplyAddEntity;
+import com.crm.rely.backend.model.entity.account.apply.demo.AccountApplyDemoAddEntity;
+import com.crm.rely.backend.model.entity.account.apply.firm.offer.AccountApplyFirmOfferAddEntity;
+import com.crm.rely.backend.model.entity.custom.CustomLoginUpdateAssessmentByLoginEntity;
+import com.crm.rely.backend.model.entity.custom.CustomLoginUpdateCheckByLoginEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import com.crm.rely.backend.model.entity.custom.login.CustomLoginApproveEntity;
+import com.crm.rely.backend.model.entity.custom.login.CustomLoginCheckByLoginEntity;
+import com.crm.rely.backend.model.entity.custom.login.CustomLoginSearchListEntity;
+import com.crm.rely.backend.model.entity.custom.login.asset.management.CustomLoginAssetManagementApproveEntity;
+import com.crm.rely.backend.model.entity.custom.login.asset.management.CustomLoginAssetManagementSearchListEntity;
+import com.crm.rely.backend.model.entity.custom.login.asset.management.CustomLoginAssetManagementUpdateCheckByLoginEntity;
+import com.crm.rely.backend.model.entity.custom.login.demo.CustomLoginDemoApproveEntity;
+import com.crm.rely.backend.model.entity.custom.login.demo.CustomLoginDemoSearchListEntity;
+import com.crm.rely.backend.model.entity.custom.login.demo.CustomLoginDemoUpdateCheckByLoginEntity;
+import com.crm.rely.backend.model.entity.custom.login.firm.offer.CustomLoginFirmOfferApproveEntity;
+import com.crm.rely.backend.model.entity.custom.login.firm.offer.CustomLoginFirmOfferSearchListEntity;
+import com.crm.rely.backend.model.entity.custom.login.firm.offer.CustomLoginFirmOfferUpdateCheckByLoginEntity;
+import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
+import com.crm.rely.backend.model.pojo.table.CustomLoginAssetManagementTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginDemoTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginTable;
+import com.google.common.base.Strings;
+import lombok.extern.log4j.Log4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Log4j
+@RestController
+@RequestMapping("/custom/login")
+public class CustomLoginController extends BaseLoginController {
+    @Autowired
+    private AccountApplyDemoService accountApplyDemoService;
+    @Autowired
+    private AccountApplyFirmOfferService accountApplyFirmOfferService;
+    @Autowired
+    private AccountApplyAssetManagementService accountApplyAssetManagementService;
+    @Autowired
+    private CustomLoginDemoService customLoginDemoService;
+    @Autowired
+    private CustomLoginFirmOfferService customLoginFirmOfferService;
+    @Autowired
+    private CustomLoginAssetManagementService customLoginAssetManagementService;
+    @Autowired
+    private WebVideoFeignService webVideoFeignService;
+
+    @Autowired
+    private AccountApplyService accountApplyService;
+    @Autowired
+    private CustomLoginService customLoginService;
+
+    @Autowired
+    private CustomInfoService customInfoService;
+
+    @PostMapping("/demo/apply")
+    public BaseResultDto<Object> addDemo(CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION1.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION1);
+
+//        BaseResultDto<Boolean> resultDto = webVideoFeignService.customValidateRead();
+//        if (resultDto == null || resultDto.getCode() != 200 || !resultDto.getData()) {
+//
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        AccountApplyDemoAddEntity entity = new AccountApplyDemoAddEntity();
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setAgentId(infoEntity.getAgentId());
+        accountApplyDemoService.addAccountApplyDemo(entity);
+        infoEntity.setPosition(CustomConstants.POSITION2);
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/demo/search/list")
+    public ResultWithPagerDto<CustomLoginDemoDto> searchPageList(@RequestBody @Validated CustomLoginDemoSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        entity.setCId(infoEntity.getCId());
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginDemoDto> result = customLoginDemoService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/demo/apply/check")
+    public BaseResultDto<Object> applyCheck(@RequestBody @Validated CustomLoginDemoUpdateCheckByLoginEntity entity,
+                                            CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION2.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION2);
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_STATUS);
+        customLoginDemoService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 放弃考核
+     *
+     * @param entity
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/demo/abandon")
+    public BaseResultDto<Object> applyAbandon(@RequestBody @Validated CustomLoginDemoUpdateCheckByLoginEntity entity,
+                                              CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION2.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION2);
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_ABANDON_STATUS);
+        customLoginDemoService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/demo/search/list")
+    @FeignClientAnnotation
+    public ResultWithPagerDto<CustomLoginDemoDto> managerSearchPageList(@RequestBody @Validated CustomLoginDemoSearchListEntity entity, UserInfoEntity infoEntity) throws Exception {
+        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
+            entity.setStamp(infoEntity.getStamp());
+        } else {
+            entity.setStamp(null);
+        }
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginDemoDto> result = customLoginDemoService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/manager/demo/approve")
+    @FeignClientAnnotation
+    public BaseResultDto approveDemo(@RequestBody @Validated CustomLoginDemoApproveEntity entity) throws Exception {
+
+        CustomLoginDemoTable table = customLoginDemoService.approve(entity);
+
+        return BaseResultDto.success();
+    }
+
+
+    @PostMapping("/demo/condition")
+    public BaseResultDto<CustomLoginConditionDto> conditionDemo(@RequestBody @Validated CustomLoginCheckByLoginEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION2.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION2);
+        entity.setCustomId(infoEntity.getId());
+        CustomLoginConditionDto customLoginDemoConditionDto =
+                customLoginDemoService.conditionDemo(entity);
+
+        return BaseResultDto.success(customLoginDemoConditionDto);
+    }
+
+    @PostMapping("/demo/again/study")
+    public BaseResultDto<Object> againStudy(@RequestBody @Validated CustomLoginCheckByLoginEntity entity,
+                                            CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION2.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION2);
+        entity.setCustomId(infoEntity.getId());
+        customLoginDemoService.studyDemo(entity);
+        infoEntity.setPosition(CustomConstants.POSITION1);
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success();
+    }
+
+
+    @PostMapping("/firm/offer/apply")
+    public BaseResultDto<Object> addFirmOffer(CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION2.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION2);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+
+        /**
+         * todo 核验客户状态 核验模拟账户状态
+         */
+
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())
+                || !customLoginDemoService.existDemoStatus(infoEntity.getId(), StatusConstants.PASSED_STATUS)) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+
+        AccountApplyFirmOfferAddEntity entity = new AccountApplyFirmOfferAddEntity();
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setAgentId(infoEntity.getAgentId());
+        accountApplyFirmOfferService.addAccountApply(entity);
+        infoEntity.setPosition(CustomConstants.POSITION3);
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/firm/offer/search/list")
+    public ResultWithPagerDto<CustomLoginFirmOfferDto> searchFirmOfferPageList(@RequestBody @Validated CustomLoginFirmOfferSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+        entity.setCId(infoEntity.getCId());
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginFirmOfferDto> result = customLoginFirmOfferService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/firm/offer/apply/check")
+    public BaseResultDto<Object> applyCheckFirmOffer(@RequestBody @Validated CustomLoginFirmOfferUpdateCheckByLoginEntity entity,
+                                                     CustomInfoEntity infoEntity) throws Exception {
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+//        if (!CustomConstants.POSITION3.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION3);
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_STATUS);
+        customLoginFirmOfferService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 放弃考核
+     *
+     * @param entity
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/firm/offer/abandon")
+    public BaseResultDto<Object> applyAbandonFirmOffer(@RequestBody @Validated CustomLoginFirmOfferUpdateCheckByLoginEntity entity,
+                                                       CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION3.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION3);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_ABANDON_STATUS);
+        customLoginFirmOfferService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/firm/offer/condition")
+    public BaseResultDto<CustomLoginConditionDto> conditionFirmOffer(@RequestBody @Validated CustomLoginCheckByLoginEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION3.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION3);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        CustomLoginConditionDto customLoginDemoConditionDto =
+                customLoginFirmOfferService.conditionFirmOffer(entity);
+
+        return BaseResultDto.success(customLoginDemoConditionDto);
+    }
+
+    /**
+     * 重新学习 验证条件
+     *
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/firm/offer/again/study")
+    public BaseResultDto<Object> againStudyFirmOffer(@RequestBody @Validated CustomLoginCheckByLoginEntity entity,
+                                                     CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION3.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION3);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        customLoginFirmOfferService.studyFirmOffer(entity);
+
+        infoEntity.setPosition(CustomConstants.POSITION1);
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success();
+    }
+
+
+    @PostMapping("/manager/firm/offer/search/list")
+    @FeignClientAnnotation
+    public ResultWithPagerDto<CustomLoginFirmOfferDto> managerSearchFirmOfferPageList(@RequestBody @Validated CustomLoginFirmOfferSearchListEntity entity, UserInfoEntity infoEntity) throws Exception {
+        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
+            entity.setStamp(infoEntity.getStamp());
+        } else {
+            entity.setStamp(null);
+        }
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginFirmOfferDto> result = customLoginFirmOfferService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/manager/firm/offer/approve")
+    @FeignClientAnnotation
+    public BaseResultDto approveFirmOffer(@RequestBody @Validated CustomLoginFirmOfferApproveEntity entity) throws Exception {
+
+        if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            if (entity.getBalance() == null || entity.getBalance().compareTo(BigDecimal.ZERO) <= 0) {
+                return BaseResultDto.error(Constants.PARAMETER_ERROR);
+            }
+        } else {
+            entity.setBalance(null);
+        }
+        CustomLoginFirmOfferTable table = customLoginFirmOfferService.approve(entity);
+
+        if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            CustomInfoEntity infoEntity = super.loginInfo(PrefixEnum.PREFIX_CUSTOM, table.getCustomId(),
+                    CustomInfoEntity.class);
+            if (infoEntity != null) {
+
+                infoEntity.setPosition(CustomConstants.POSITION4);
+            }
+            super.saveLoginInfo(infoEntity);
+        }
+
+        return BaseResultDto.success();
+    }
+
+
+    @PostMapping("/asset/management/search/list")
+    public ResultWithPagerDto<CustomLoginAssetManagementDto> searchAssetManagementPageList(@RequestBody @Validated CustomLoginAssetManagementSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setReal(0);
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginAssetManagementDto> result =
+                customLoginAssetManagementService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/asset/management/real/search/list")
+    public ResultWithPagerDto<CustomLoginAssetManagementDto> searchRealAssetManagementPageList(@RequestBody @Validated CustomLoginAssetManagementSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setReal(1);
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginAssetManagementDto> result =
+                customLoginAssetManagementService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/asset/management/apply/check")
+    public BaseResultDto<Object> applyCheckAssetManagement(@RequestBody @Validated CustomLoginAssetManagementUpdateCheckByLoginEntity entity,
+                                                           CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION4.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION4);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_STATUS);
+        customLoginAssetManagementService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 放弃考核
+     *
+     * @param entity
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/asset/management/abandon")
+    public BaseResultDto<Object> applyAbandonAssetManagement(@RequestBody @Validated CustomLoginAssetManagementUpdateCheckByLoginEntity entity,
+                                                             CustomInfoEntity infoEntity) throws Exception {
+//        if (!CustomConstants.POSITION4.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION4);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_ABANDON_STATUS);
+        customLoginAssetManagementService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/asset/management/condition")
+    public BaseResultDto<CustomLoginConditionDto> conditionAssetManagement(@RequestBody @Validated CustomLoginCheckByLoginEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION4.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION4);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        CustomLoginConditionDto customLoginDemoConditionDto =
+                customLoginAssetManagementService.conditionAssetManagement(entity);
+
+        return BaseResultDto.success(customLoginDemoConditionDto);
+    }
+
+    /**
+     * 重新学习 验证条件
+     *
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/asset/management/again/study")
+    public BaseResultDto<Object> againStudyAssetManagement(@RequestBody @Validated CustomLoginCheckByLoginEntity entity, CustomInfoEntity infoEntity) throws Exception {
+
+//        if (!CustomConstants.POSITION4.equals(infoEntity.getPosition())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        customInfoService.validPosition(infoEntity.getId(), CustomConstants.POSITION4);
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        customLoginAssetManagementService.studyAssetManagement(entity);
+
+        infoEntity.setPosition(CustomConstants.POSITION1);
+        super.saveLoginInfo(infoEntity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/asset/management/search/list")
+    @FeignClientAnnotation
+    public ResultWithPagerDto<CustomLoginAssetManagementDto> managerSearchAssetManagementPageList(@RequestBody @Validated CustomLoginAssetManagementSearchListEntity entity, UserInfoEntity infoEntity) throws Exception {
+        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
+            entity.setStamp(infoEntity.getStamp());
+        } else {
+            entity.setStamp(null);
+        }
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginAssetManagementDto> result =
+                customLoginAssetManagementService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/manager/asset/management/approve")
+    @FeignClientAnnotation
+    public BaseResultDto approveAssetManagement(@RequestBody @Validated CustomLoginAssetManagementApproveEntity entity) throws Exception {
+
+        if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            if (entity.getAmount() == null && entity.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+                return BaseResultDto.error(Constants.PARAMETER_ERROR);
+            }
+        } else {
+            entity.setAmount(null);
+        }
+        CustomLoginAssetManagementTable table = customLoginAssetManagementService.approve(entity);
+
+
+        return BaseResultDto.success();
+    }
+
+
+    @PostMapping("/apply")
+    public BaseResultDto<Object> add(@RequestBody @Validated AccountApplyAddEntity entity,
+                                     CustomInfoEntity infoEntity) throws Exception {
+
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setAgentId(infoEntity.getAgentId());
+        accountApplyService.addAccountApply(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/search/list")
+    public ResultWithPagerDto<CustomLoginDto> searchPageList(@RequestBody @Validated CustomLoginSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginDto> result = customLoginService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/manager/search/list")
+    @FeignClientAnnotation
+    public ResultWithPagerDto<CustomLoginDto> managerSearchPageList(@RequestBody @Validated CustomLoginSearchListEntity entity, UserInfoEntity infoEntity) throws Exception {
+        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
+            entity.setStamp(infoEntity.getStamp());
+        } else {
+            entity.setStamp(null);
+        }
+
+        validSortName(entity.getSortName());
+        ResultWithPagerDto<CustomLoginDto> result = customLoginService.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/apply/assessment")
+    public BaseResultDto<Object> applyAssessment(@RequestBody @Validated CustomLoginUpdateAssessmentByLoginEntity entity,
+                                                 CustomInfoEntity infoEntity) throws Exception {
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        customLoginService.assessment(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/abandon/assessment")
+    public BaseResultDto<Object> abandonAssessment(@RequestBody @Validated CustomLoginUpdateAssessmentByLoginEntity entity,
+                                                   CustomInfoEntity infoEntity) throws Exception {
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        customLoginService.abandonAssessment(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/apply/check")
+    public BaseResultDto<Object> applyCheck(@RequestBody @Validated CustomLoginUpdateCheckByLoginEntity entity,
+                                            CustomInfoEntity infoEntity) throws Exception {
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_STATUS);
+        customLoginService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    /**
+     * 放弃考核
+     *
+     * @param entity
+     * @param infoEntity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/abandon")
+    public BaseResultDto<Object> applyAbandonAssetManagement(@RequestBody @Validated CustomLoginUpdateCheckByLoginEntity entity,
+                                                             CustomInfoEntity infoEntity) throws Exception {
+        if (!StatusConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setCustomId(infoEntity.getId());
+        entity.setCId(infoEntity.getCId());
+        entity.setStatus(StatusConstants.APPLY_ABANDON_STATUS);
+        customLoginService.applyCheck(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve")
+    @FeignClientAnnotation
+    public BaseResultDto approve(@RequestBody @Validated CustomLoginApproveEntity entity) throws Exception {
+
+        if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            if (entity.getBalance() == null && entity.getBalance().compareTo(BigDecimal.ZERO) <= 0) {
+                return BaseResultDto.error(Constants.PARAMETER_ERROR);
+            }
+        } else {
+            entity.setBalance(null);
+        }
+        CustomLoginTable table = customLoginService.approve(entity);
+
+
+        return BaseResultDto.success();
+    }
+
+    private void validSortName(String sortName) {
+        if (!Strings.isNullOrEmpty(sortName)) {
+            List<String> tableFields = new ArrayList<>(10);
+            tableFields.add("last_ip");
+            tableFields.add("add_ip");
+            tableFields.add("modify_ip");
+            if (!tableFields.contains(sortName)) {
+                throw ServiceException.exception(Constants.FAIL);
+            }
+        }
+    }
+
+}

+ 47 - 0
crm-custom/src/main/java/com/crm/custom/controller/CustomRecommendController.java

@@ -0,0 +1,47 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CustomRecommendService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
+import com.crm.rely.backend.model.dto.custom.CustomInfoLoginDto;
+import com.crm.rely.backend.model.dto.custom.CustomInfoRecommendDto;
+import com.crm.rely.backend.model.entity.custom.CustomInfoListEntity;
+import com.crm.rely.backend.model.entity.custom.CustomInfoLoginListEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/recommend")
+public class CustomRecommendController extends BaseLoginController {
+    @Autowired
+    private CustomRecommendService service;
+
+    @PostMapping("/search/list")
+    public BaseResultDto searchPageList(@RequestBody @Validated CustomInfoLoginListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        if (infoEntity.getIbId() == null) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setAgentId(infoEntity.getIbId());
+        ResultWithPagerDto<CustomInfoLoginDto> result = service.searchPageList(entity);
+
+        return result;
+    }
+
+    @PostMapping("/real/search/list")
+    public BaseResultDto searchPageList(@RequestBody @Validated CustomInfoListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        if (infoEntity.getIbId() == null) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        entity.setAgentId(infoEntity.getIbId());
+        ResultWithPagerDto<CustomInfoRecommendDto> result = service.searchPageList(entity);
+
+        return result;
+    }
+}

+ 35 - 0
crm-custom/src/main/java/com/crm/custom/controller/FinanceController.java

@@ -0,0 +1,35 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.CommonService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/finance/file")
+public class FinanceController extends BaseLoginController {
+    @Autowired
+    private CommonService commonService;
+
+    @PostMapping("/upload")
+    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file,
+                                CustomInfoEntity infoEntity) throws Exception {
+        String middlePath = "/" + infoEntity.getId() + "/finance/file";
+
+        commonService.validated(file);
+        String path = commonService.uploadFile(middlePath, file);
+
+        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, path);
+    }
+
+}

+ 66 - 0
crm-custom/src/main/java/com/crm/custom/controller/SysCountryController.java

@@ -0,0 +1,66 @@
+package com.crm.custom.controller;
+
+import com.crm.rely.backend.core.constant.FeignClientAnnotation;
+import com.crm.rely.backend.core.dto.country.SysCountryDto;
+import com.crm.rely.backend.core.entity.country.SysCountryEntity;
+import com.crm.custom.service.SysCountryService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.util.GetIpAndMac;
+import org.apache.catalina.servlet4preview.http.HttpServletRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/country")
+public class SysCountryController {
+
+    @Autowired
+    private SysCountryService sysCountryService;
+
+    /**
+     * 根据pid获取列表
+     *
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/get")
+    public BaseResultDto getAllCountry(@RequestBody  SysCountryEntity entity) throws Exception {
+
+        if (entity.getPid() == null) {
+            entity.setPid(0L);
+        }
+        List<SysCountryDto> sysCountryDtos = sysCountryService.getByPid(entity);
+
+        return BaseResultDto.success(sysCountryDtos);
+    }
+
+    @PostMapping("/manager/get")
+    @FeignClientAnnotation
+    public BaseResultDto getManagerAllCountry(@RequestBody  SysCountryEntity entity) throws Exception {
+
+        if (entity.getPid() == null) {
+            entity.setPid(0L);
+        }
+        List<SysCountryDto> sysCountryDtos = sysCountryService.getByPid(entity);
+
+        return BaseResultDto.success(sysCountryDtos);
+    }
+
+    @PostMapping("/getCodeByIp")
+    public BaseResultDto<String> getCodeByIp(HttpServletRequest request) throws Exception{
+        String ip = GetIpAndMac.getIp(request);
+//        String ip = "114.101.199.90";
+        return BaseResultDto.success(sysCountryService.getCodeByIp(ip));
+    }
+
+
+}

+ 36 - 0
crm-custom/src/main/java/com/crm/custom/controller/SysReasonsRefusalController.java

@@ -0,0 +1,36 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.SysReasonsRefusalFeignService;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.dto.system.reasons.refusal.SysReasonsRefusalSearchDto;
+import com.crm.rely.backend.core.entity.system.reasons.refusal.SysReasonsRefusalSearchEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 拒绝理由
+ *
+ * @author houn
+ */
+@RestController
+@RequestMapping("/reasons/refusal")
+public class SysReasonsRefusalController {
+
+    @Autowired
+    private SysReasonsRefusalFeignService sysReasonsRefusalFeignService;
+
+
+    @PostMapping("/list")
+    public BaseResultDto<Map<String, SysReasonsRefusalSearchDto>> customList(@RequestBody @Validated SysReasonsRefusalSearchEntity entity) throws Exception {
+
+        BaseResultDto<Map<String, SysReasonsRefusalSearchDto>> result = sysReasonsRefusalFeignService.customList(entity);
+
+        return result;
+    }
+}

+ 49 - 0
crm-custom/src/main/java/com/crm/custom/controller/WebVideoController.java

@@ -0,0 +1,49 @@
+package com.crm.custom.controller;
+
+import com.crm.custom.service.WebVideoFeignService;
+import com.crm.login.rely.backend.controller.BaseLoginController;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.entity.custom.video.record.CustomVideoRecordAddEntity;
+import com.crm.rely.backend.model.entity.web.video.WebVideoSearchListEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author: houn
+ */
+@RestController
+@RequestMapping("/web/video")
+public class WebVideoController extends BaseLoginController {
+
+    @Autowired
+    private WebVideoFeignService feignService;
+
+    /**
+     * @param entity
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/list")
+    public BaseResultDto list(@RequestBody @Validated WebVideoSearchListEntity entity) throws Exception {
+
+        return feignService.customList(entity);
+    }
+
+    @PostMapping("/single")
+    public BaseResultDto single(@RequestBody @Validated SingleLongEntity entity) throws Exception {
+
+
+        return feignService.customSingle(entity);
+    }
+
+    @PostMapping("/read")
+    public BaseResultDto read(@RequestBody @Validated CustomVideoRecordAddEntity entity) throws Exception {
+
+        return feignService.customRead(entity);
+    }
+}

+ 17 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomFileDao.java

@@ -0,0 +1,17 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.core.entity.base.LongEntitys;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by max on 2020/6/18.
+ */
+@Repository
+public interface CustomFileDao {
+
+    void deleteInBatchByCustomId(LongEntitys entitys);
+
+    List<String> getAllPathByCustomId(LongEntitys entitys);
+}

+ 26 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomInfoDao.java

@@ -0,0 +1,26 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.core.entity.base.LongEntitys;
+import com.crm.rely.backend.model.entity.custom.CustomInfoListEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomBelongsListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomInfoView;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by max on 2020/6/18.
+ */
+@Repository
+public interface CustomInfoDao {
+
+    void deleteInBatch(LongEntitys entitys);
+
+    Integer countBelongs(CustomBelongsListEntity entity);
+
+    List<CustomInfoView> listBelongs(CustomBelongsListEntity entity);
+
+    Integer countRecommend(CustomInfoListEntity entity);
+
+    List<CustomInfoView> getPageRecommend(CustomInfoListEntity entity);
+}

+ 16 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginAssetManagementMapper.java

@@ -0,0 +1,16 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.custom.login.asset.management.CustomLoginAssetManagementSearchListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomLoginAssetManagementView;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CustomLoginAssetManagementMapper {
+    Integer countList(CustomLoginAssetManagementSearchListEntity entity);
+
+    List<CustomLoginAssetManagementView> pageList(CustomLoginAssetManagementSearchListEntity entity);
+
+    CustomLoginAssetManagementView getOne(Long id);
+}

+ 14 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginDemoMapper.java

@@ -0,0 +1,14 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.custom.login.demo.CustomLoginDemoSearchListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomLoginDemoView;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CustomLoginDemoMapper {
+    Integer countList(CustomLoginDemoSearchListEntity entity);
+
+    List<CustomLoginDemoView> pageList(CustomLoginDemoSearchListEntity entity);
+}

+ 17 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginFirmOfferMapper.java

@@ -0,0 +1,17 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.custom.login.firm.offer.CustomLoginFirmOfferSearchListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomLoginFirmOfferRollView;
+import com.crm.rely.backend.model.pojo.view.CustomLoginFirmOfferView;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CustomLoginFirmOfferMapper {
+    Integer countList(CustomLoginFirmOfferSearchListEntity entity);
+
+    List<CustomLoginFirmOfferView> pageList(CustomLoginFirmOfferSearchListEntity entity);
+
+    List<CustomLoginFirmOfferRollView> rollList();
+}

+ 22 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomLoginMapper.java

@@ -0,0 +1,22 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.custom.login.CustomLoginSearchListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomLoginView;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Repository
+public interface CustomLoginMapper {
+    Integer countList(CustomLoginSearchListEntity entity);
+
+    List<CustomLoginView> pageList(CustomLoginSearchListEntity entity);
+
+    CustomLoginView getByLogin(Long login);
+
+    CustomLoginView getById(Long id);
+
+    int existByCustomIdAndEquity(@Param("customId") Long customId, @Param("equity") BigDecimal equity);
+}

+ 15 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomRecommendMapper.java

@@ -0,0 +1,15 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.custom.CustomInfoLoginListEntity;
+import com.crm.rely.backend.model.pojo.view.CustomInfoLoginView;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface CustomRecommendMapper {
+    Integer countList(CustomInfoLoginListEntity entity);
+
+    List<CustomInfoLoginView> pageList(CustomInfoLoginListEntity entity);
+
+}

+ 15 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/CustomSurveyDao.java

@@ -0,0 +1,15 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.core.entity.base.LongEntitys;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by max on 2020/6/18.
+ */
+@Repository
+public interface CustomSurveyDao {
+
+    void deleteInBatchByCustomId(LongEntitys entitys);
+}

+ 10 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyAssetManagementRepository.java

@@ -0,0 +1,10 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.AccountApplyAssetManagementTable;
+
+public interface AccountApplyAssetManagementRepository extends BaseRepository<AccountApplyAssetManagementTable> {
+
+    boolean existsByCustomIdAndStatus(Long customId, Integer status);
+
+}

+ 10 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyDemoRepository.java

@@ -0,0 +1,10 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.AccountApplyDemoTable;
+
+public interface AccountApplyDemoRepository extends BaseRepository<AccountApplyDemoTable> {
+
+    boolean existsByCustomIdAndStatus(Long customId, Integer status);
+
+}

+ 10 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyFirmOfferRepository.java

@@ -0,0 +1,10 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.AccountApplyFirmOfferTable;
+
+public interface AccountApplyFirmOfferRepository extends BaseRepository<AccountApplyFirmOfferTable> {
+
+    boolean existsByCustomIdAndStatus(Long customId, Integer status);
+
+}

+ 21 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyPasswordResetRepository.java

@@ -0,0 +1,21 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.AccountApplyPasswordResetTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface AccountApplyPasswordResetRepository extends BaseRepository<AccountApplyPasswordResetTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    AccountApplyPasswordResetTable findFirstByPasswordStatus(Integer passwordStatus);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    AccountApplyPasswordResetTable findFirstBySerial(String serial);
+}

+ 19 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/AccountApplyRepository.java

@@ -0,0 +1,19 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.AccountApplyTable;
+
+import java.util.List;
+
+public interface AccountApplyRepository extends BaseRepository<AccountApplyTable> {
+
+    boolean existsByCustomIdAndStatus(Long customId, Integer status);
+
+    Integer countByCustomIdAndStatusInAndAccountStatusIsNull(Long customId, List<Integer> accountStatus);
+
+    Integer countByCustomIdAndAccountStatusNotInAndStatusNot(Long customId, List<Integer> accountStatus,
+                                                             Integer status);
+
+    Integer countByCustomIdAndStatusNot(Long customId, Integer status);
+
+}

+ 30 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomBankRepository.java

@@ -0,0 +1,30 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomBankTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface CustomBankRepository extends BaseRepository<CustomBankTable> {
+
+
+    List<CustomBankTable> getAllByCustomId(Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomBankTable findFirstById(Long id);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomBankTable getFirstByCustomId(Long customId);
+
+    List<CustomBankTable> findAllByCustomIdAndDefaultBankAndType(Long customId, Integer defaultBank, Integer type);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomBankTable> findAllByCustomIdAndIdIn(Long customId, List<Long> ids);
+}

+ 14 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFileHistoryRepository.java

@@ -0,0 +1,14 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.core.pojo.table.CustomFileHistoryTable;
+import com.crm.rely.backend.core.pojo.table.CustomFileTable;
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import org.springframework.data.jpa.repository.Lock;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+
+public interface CustomFileHistoryRepository extends BaseRepository<CustomFileHistoryTable> {
+
+}

+ 27 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFileRepository.java

@@ -0,0 +1,27 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.core.pojo.table.CustomFileTable;
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import org.springframework.data.jpa.repository.Lock;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+
+public interface CustomFileRepository extends BaseRepository<CustomFileTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomFileTable findFirstById(Long id);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomFileTable findFirstByCustomIdAndType(Long customId, Integer type);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomFileTable> findAllByIdInAndCustomId(List<Long> ids, Long customId);
+
+    List<CustomFileTable> getAllByCustomIdOrderByType(Long customId);
+
+    Integer countByCustomId(Long customId);
+
+    CustomFileTable findFirstByCustomIdAndId(Long customId, Long id);
+}

+ 12 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomFundHistoryRepository.java

@@ -0,0 +1,12 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomFundHistoryTable;
+import org.springframework.stereotype.Repository;
+
+
+@Repository
+public interface CustomFundHistoryRepository extends BaseRepository<CustomFundHistoryTable> {
+
+
+}

+ 108 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomInfoRepository.java

@@ -0,0 +1,108 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @program: crm-backend
+ * @description:
+ * @author: houn
+ * @create: 2019-07-25 16:25
+ */
+@Repository
+public interface CustomInfoRepository extends BaseRepository<CustomInfoTable> {
+
+    /**
+     * 邮箱密码查询用户
+     *
+     * @param email
+     * @param password
+     * @return
+     */
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstByEmailAndPassword(String email, String password);
+
+    /**
+     * id密码查询用户
+     *
+     * @param id
+     * @param password
+     * @return
+     */
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstByIdAndPassword(Long id, String password);
+
+    /**
+     * 根据id查询用户信息
+     *
+     * @param id
+     * @return
+     */
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstById(Long id);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstByCId(Long cId);
+
+    /**
+     * 根据手机号码获取账户
+     *
+     * @param phone
+     * @return
+     */
+    CustomInfoTable getFirstByPhoneNotNullAndPhone(String phone);
+
+    /**
+     * 根据手机号码获取账户
+     *
+     * @param phone
+     * @return
+     */
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstByPhoneNotNullAndPhone(String phone);
+
+    /**
+     * 根据邮箱获取账号
+     *
+     * @param email
+     * @return
+     */
+    CustomInfoTable getFirstByEmailNotNullAndEmail(String email);
+
+    /**
+     * 根据邮箱获取账号
+     *
+     * @param email
+     * @return
+     */
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomInfoTable findFirstByEmailNotNullAndEmail(String email);
+
+    List<CustomInfoTable> findAllByAgentId(Long agentId);
+
+    CustomInfoTable getFirstById(Long id);
+
+    /**
+     * 查询邮箱是否已存在
+     *
+     * @param email
+     * @return
+     */
+    boolean existsByEmail(String email);
+
+    /**
+     * 查询手机号码是否已存在
+     *
+     * @param phone
+     * @return
+     */
+    boolean existsByPhone(String phone);
+
+    boolean existsByIdentity(String identity);
+    CustomInfoTable getFirstBySno(String sno);
+}

+ 37 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginAssetManagementRepository.java

@@ -0,0 +1,37 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginAssetManagementTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginDemoTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface CustomLoginAssetManagementRepository extends BaseRepository<CustomLoginAssetManagementTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginAssetManagementTable findFirstById(Long id);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginAssetManagementTable findFirstByLoginAndCustomId(Long login, Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginAssetManagementTable findFirstByLogin(Long login);
+
+    boolean existsByCustomIdAndStatusIn(Long customId, List<Integer> status);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginAssetManagementTable> findAllByCustomId(Long customId);
+
+    boolean existsByCustomIdAndStatusInAndSourceLoginIsNull(Long customId, List<Integer> status);
+
+    CustomLoginAssetManagementTable getFirstByLogin(Long login);
+
+    boolean existsByLogin(Long login);
+}

+ 49 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginDemoRepository.java

@@ -0,0 +1,49 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginDemoTable;
+import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface CustomLoginDemoRepository extends BaseRepository<CustomLoginDemoTable> {
+
+    List<CustomLoginDemoTable> getAllByCustomId(Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginDemoTable findFirstById(Long id);
+
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginDemoTable findFirstByLoginAndCustomId(Long login, Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginDemoTable> findAllByCustomIdAndIdIn(Long customId, List<Long> ids);
+
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginDemoTable> findAllByCustomIdAndStatus(Long customId, Integer status);
+
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginDemoTable> findAllByCustomIdAndStatusInAndLoginNot(Long customId, List<Integer> status,Long login);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginDemoTable findFirstByLogin(Long login);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginDemoTable> findAllByCustomId(Long customId);
+
+    boolean existsByCustomIdAndStatusIn(Long customId, List<Integer> status);
+
+    boolean existsByCustomIdAndStatus(Long customId, Integer status);
+
+    CustomLoginDemoTable getFirstByLogin(Long login);
+}

+ 37 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginFirmOfferRepository.java

@@ -0,0 +1,37 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginFirmOfferTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface CustomLoginFirmOfferRepository extends BaseRepository<CustomLoginFirmOfferTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginFirmOfferTable findFirstById(Long id);
+
+    CustomLoginFirmOfferTable getFirstByLogin(Long login);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginFirmOfferTable findFirstByLoginAndCustomId(Long login, Long customId);
+
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginFirmOfferTable findFirstByLogin(Long login);
+
+    boolean existsByCustomIdAndStatusIn(Long customId, List<Integer> status);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginFirmOfferTable> findAllByCustomId(Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginFirmOfferTable> findAllByCustomIdAndStatus(Long customId, Integer status);
+
+}

+ 15 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginHistoryRepository.java

@@ -0,0 +1,15 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.core.pojo.table.CustomLoginHistoryTable;
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 登录记录
+ *
+ * @author: houn
+ */
+@Repository
+public interface CustomLoginHistoryRepository extends BaseRepository<CustomLoginHistoryTable> {
+
+}

+ 33 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/CustomLoginRepository.java

@@ -0,0 +1,33 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.CustomLoginTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+/**
+ * @author: houn
+ */
+@Repository
+public interface CustomLoginRepository extends BaseRepository<CustomLoginTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginTable findFirstById(Long id);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginTable findFirstByLoginAndCustomId(Long login, Long customId);
+
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    List<CustomLoginTable> findAllByCustomId(Long customId);
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    CustomLoginTable findFirstByLogin(Long login);
+
+    CustomLoginTable getFirstByLogin(Long login);
+
+    Integer countByCustomId(Long customId);
+}

Some files were not shown because too many files changed in this diff