diff --git a/.style/Java开发手册(黄山版).pdf b/.style/Java开发手册(黄山版).pdf
index 6ff47d6a..364dff0b 100644
Binary files a/.style/Java开发手册(黄山版).pdf and b/.style/Java开发手册(黄山版).pdf differ
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 1aa2ad61..53a83f70 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -3,14 +3,14 @@ services:
mysql:
image: mysql:8.0.33
restart: always
- container_name: mysql
+ container_name: mysql-master
ports:
- '3306:3306'
environment:
TZ: Asia/Shanghai
- MYSQL_ROOT_PASSWORD: 你的root用户密码
+ MYSQL_ROOT_PASSWORD: TMrmNY839KtZfpHb
# 初始化数据库(后续的初始化 SQL 会在这个库执行)
- MYSQL_DATABASE: continew_admin
+ MYSQL_DATABASE: zayac_admin
#MYSQL_USER: 你的数据库用户名
#MYSQL_PASSWORD: 你的数据库密码
volumes:
@@ -22,19 +22,6 @@ services:
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
-# postgresql:
-# image: postgres:14.2
-# restart: always
-# container_name: postgresql
-# ports:
-# - '5432:5432'
-# environment:
-# TZ: Asia/Shanghai
-# POSTGRES_USER: 你的用户名
-# POSTGRES_PASSWORD: 你的用户密码
-# POSTGRES_DB: continew_admin
-# volumes:
-# - /docker/postgresql/data/:/var/lib/postgresql/data/
redis:
image: redis:7.2.3
restart: always
@@ -49,7 +36,7 @@ services:
- /docker/redis/logs/:/logs/
command: 'redis-server /usr/local/redis/config/redis.conf --appendonly yes --requirepass 你的 Redis 密码'
continew-admin-server:
- build: ./continew-admin
+ build: ./zayac-admin
restart: always
container_name: continew-admin-server
ports:
@@ -72,19 +59,4 @@ services:
- /docker/continew-admin/lib/:/app/lib/
depends_on:
- redis
- - mysql
- nginx:
- image: nginx:1.25.3
- restart: always
- container_name: nginx
- ports:
- - '80:80'
- - '443:443'
- environment:
- TZ: Asia/Shanghai
- volumes:
- - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- - /docker/nginx/cert/:/etc/nginx/cert/
- - /docker/nginx/logs/:/var/log/nginx/
- # 前端页面目录
- - /docker/continew-admin/html/:/usr/share/nginx/html/
+ - mysql
\ No newline at end of file
diff --git a/docker/continew-admin/Dockerfile b/docker/zayac-admin/Dockerfile
similarity index 100%
rename from docker/continew-admin/Dockerfile
rename to docker/zayac-admin/Dockerfile
diff --git a/pom.xml b/pom.xml
index bb447386..d5cbd859 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
zayac-admin-system
zayac-admin-generator
zayac-admin-common
- zayac-admin-backend
+ zayac-admin-agent
@@ -38,7 +38,7 @@
com.zayac
- zayac-admin-backend
+ zayac-admin-agent
${revision}
diff --git a/zayac-admin-backend/pom.xml b/zayac-admin-agent/pom.xml
similarity index 90%
rename from zayac-admin-backend/pom.xml
rename to zayac-admin-agent/pom.xml
index 2fd4606c..9dfff1b5 100644
--- a/zayac-admin-backend/pom.xml
+++ b/zayac-admin-agent/pom.xml
@@ -9,8 +9,8 @@
${revision}
- zayac-admin-backend
- 后台定时任务相关组件
+ zayac-admin-agent
+ 代理线相关组件
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/config/WebClientConfig.java b/zayac-admin-agent/src/main/java/com/zayac/admin/config/WebClientConfig.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/config/WebClientConfig.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/config/WebClientConfig.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/constant/ApiPathConstants.java b/zayac-admin-agent/src/main/java/com/zayac/admin/constant/ApiPathConstants.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/constant/ApiPathConstants.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/constant/ApiPathConstants.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/FinancialStatementReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/FinancialStatementReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/FinancialStatementReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/FinancialStatementReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberDetailsReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/MemberDetailsReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberDetailsReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/MemberDetailsReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberListReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/MemberListReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberListReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/MemberListReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/PayRecordsListReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/PayRecordsListReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/PayRecordsListReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/PayRecordsListReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java b/zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/ApiResponse.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/ApiResponse.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/ApiResponse.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/ApiResponse.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Banner.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/Banner.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/Banner.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/Banner.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/FinancialStatement.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/FinancialStatement.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/FinancialStatement.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/FinancialStatement.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Member.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/Member.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/Member.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/Member.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/MemberPagination.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/MemberPagination.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/MemberPagination.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/MemberPagination.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Pagination.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/Pagination.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/Pagination.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/Pagination.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/PayRecord.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/PayRecord.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/PayRecord.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/PayRecord.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Statics.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/Statics.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/Statics.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/Statics.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Venue.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/Venue.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/Venue.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/Venue.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/Team.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/Team.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/Team.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/Team.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccount.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamAccount.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccount.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamAccount.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamMember.java b/zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamMember.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamMember.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/resp/team/TeamMember.java
diff --git a/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java
new file mode 100644
index 00000000..83f02e06
--- /dev/null
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.schedule;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.zayac.admin.common.enums.DisEnableStatusEnum;
+import com.zayac.admin.req.AgentDataVisualListReq;
+import com.zayac.admin.req.team.TeamInfoReq;
+import com.zayac.admin.resp.AgentDataVisualList;
+import com.zayac.admin.resp.Statics;
+import com.zayac.admin.resp.team.Team;
+import com.zayac.admin.resp.team.TeamAccount;
+import com.zayac.admin.service.AgentDataVisualListService;
+import com.zayac.admin.service.TeamService;
+import com.zayac.admin.service.TelegramMessageService;
+import com.zayac.admin.system.model.entity.RoleDO;
+import com.zayac.admin.system.model.entity.UserDO;
+import com.zayac.admin.system.model.req.AgentStatsReq;
+import com.zayac.admin.system.model.resp.AccountResp;
+import com.zayac.admin.system.service.*;
+import lombok.RequiredArgsConstructor;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.text.NumberFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+@Component
+@RequiredArgsConstructor
+public class DailyReport {
+ private final UserService userService;
+ private final TeamService teamService;
+ private final RoleService roleService;
+ private final UserRoleService userRoleService;
+ private final AccountService accountService;
+ private final TelegramMessageService telegramMessageService;
+ private final AgentDataVisualListService agentDataVisualListService;
+ private final AgentStatsService agentStatsService;
+
+ private static final String MINISTER_ROLE_CODE = "minister";
+
+ @Scheduled(cron = "0 40 11,14,17,21 * * ?")
+ public void teamAccountDailyReport() {
+ LocalDateTime nowDateTime = LocalDateTime.now();
+ sendDailyReport(LocalDate.now(), nowDateTime, nowDateTime, false);
+ }
+
+ @Scheduled(cron = "0 15 0 * * ?")
+ public void dailySummarize() {
+ LocalDate yesterday = LocalDate.now().minusDays(1);
+ sendDailyReport(yesterday, yesterday.atStartOfDay(), LocalDateTime.of(yesterday, LocalTime.MAX), true);
+
+ }
+
+ private void sendDailyReport(LocalDate reportDate, LocalDateTime startDateTime, LocalDateTime endDateTime, boolean saveStatics) {
+ RoleDO minister = roleService.getByCode(MINISTER_ROLE_CODE);
+ List userIds = userRoleService.listUserIdByRoleId(minister.getId());
+
+ userIds.forEach(userId -> {
+ UserDO ministerUser = userService.getById(userId);
+ List accounts = getTeamAccounts(ministerUser.getId());
+ List deptUsers = userService.getByDeptId(DisEnableStatusEnum.ENABLE, ministerUser.getDeptId());
+
+ accounts.forEach(accountResp -> {
+ Team team = getLatestTeamInfo(accountResp, startDateTime, endDateTime);
+ sendMinisterMessage(ministerUser, team.getList(), endDateTime);
+ });
+
+ AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder().build();
+ deptUsers.forEach(deptUser -> {
+ String message = getDeptUserMessage(deptUser, agentDataVisualListReq, reportDate, saveStatics);
+ if (deptUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
+ telegramMessageService.sendMessage(deptUser.getBotToken(), deptUser.getCountGroupId(), message);
+ }
+ });
+ });
+ }
+
+ private List getTeamAccounts(Long userId) {
+ return accountService.getAccountsByUserId(userId, DisEnableStatusEnum.ENABLE)
+ .stream()
+ .filter(AccountResp::getIsTeam)
+ .toList();
+ }
+
+ private Team getLatestTeamInfo(AccountResp accountResp, LocalDateTime startDateTime, LocalDateTime endDateTime) {
+ TeamInfoReq teamInfoReq = TeamInfoReq.builder().startDate(startDateTime).endDate(endDateTime).build();
+ return teamService.getLatestTeamInfoAsync(accountResp, teamInfoReq).join();
+ }
+
+ private void sendMinisterMessage(UserDO ministerUser, List list, LocalDateTime endDateTime) {
+ if (ministerUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
+ int totalNewMember = list.stream().mapToInt(TeamAccount::getSubMemberNum).sum();
+ int totalNewFirstDeposit = list.stream().mapToInt(TeamAccount::getFirstDepositNum).sum();
+ String percent = getPercent(totalNewFirstDeposit, totalNewMember);
+ String message = String
+ .format("截至%s 注册:*%d*,新增:*%d* 转化率: *%s*", endDateTime, totalNewMember, totalNewFirstDeposit, percent);
+ telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser.getCountGroupId(), message);
+ }
+ }
+
+ private String getDeptUserMessage(UserDO deptUser,
+ AgentDataVisualListReq agentDataVisualListReq,
+ LocalDate reportDate,
+ boolean saveStatics) {
+ StringBuilder message = new StringBuilder();
+ List currUserAccounts = getTeamAccounts(deptUser.getId());
+
+ currUserAccounts.forEach(currAccount -> {
+ CompletableFuture future = agentDataVisualListService
+ .getAgentDataVisualList(currAccount, agentDataVisualListReq);
+ AgentDataVisualList agentData = future.join();
+ Statics statics = agentData.getCurData()
+ .stream()
+ .filter(data -> data.getStaticsDate().equals(reportDate))
+ .findFirst()
+ .orElseThrow();
+ message.append(currAccount.getUsername())
+ .append("\n")
+ .append("注册: ")
+ .append(statics.getIsNew())
+ .append("\n")
+ .append("新增: ")
+ .append(statics.getFirstCount())
+ .append("\n")
+ .append("日活: ")
+ .append(statics.getCountBets())
+ .append("\n\n");
+ if (saveStatics) {
+ AgentStatsReq agentStatsReq = new AgentStatsReq();
+ BeanUtil.copyProperties(statics, agentStatsReq);
+ agentStatsService.add(agentStatsReq);
+ }
+ });
+
+ return message.toString();
+ }
+
+ public static String getPercent(int x, int y) {
+ double d1 = x * 1.0;
+ double d2 = y * 1.0;
+ NumberFormat percentInstance = NumberFormat.getPercentInstance();
+ percentInstance.setMinimumFractionDigits(2);
+ return percentInstance.format(d1 / d2);
+ }
+}
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/MessageSchedule.java b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/MessageSchedule.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/schedule/MessageSchedule.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/schedule/MessageSchedule.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java
similarity index 76%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java
index 466ac502..35eea398 100644
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.zayac.admin.schedule;
import com.zayac.admin.common.enums.DisEnableStatusEnum;
@@ -19,6 +35,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.Map;
@@ -66,10 +83,12 @@ public class TelegramTeamMessageSchedule {
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
}
- private CompletableFuture processTeamAccount(AccountResp account, LocalDate nowDate, LocalDateTime nowDateTime) {
+ private CompletableFuture processTeamAccount(AccountResp account,
+ LocalDate nowDate,
+ LocalDateTime nowDateTime) {
TeamInfoReq teamInfoReq = TeamInfoReq.builder()
- .startDate(nowDateTime.with(TemporalAdjusters.firstDayOfMonth()))
- .endDate(nowDateTime)
+ .startDate(nowDateTime.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN))
+ .endDate(nowDateTime.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX))
.build();
CompletableFuture teamFuture = teamService.getLatestTeamInfoAsync(account, teamInfoReq);
Team prevTeamInfo = teamService.getPreviousTeamInfo(account);
@@ -82,8 +101,10 @@ public class TelegramTeamMessageSchedule {
.stream()
.collect(Collectors.toMap(TeamAccount::getAgentName, Function.identity()));
- CompletableFuture registrationProcess = registrationService.processRegistration(account, currentTeamInfo, prevTeamInfo, nowDate, teamAccountMap);
- CompletableFuture depositProcess = depositService.processDeposits(account, currentTeamInfo, prevTeamInfo, nowDate, nowDateTime);
+ CompletableFuture registrationProcess = registrationService
+ .processRegistration(account, currentTeamInfo, prevTeamInfo, nowDate, teamAccountMap);
+ CompletableFuture depositProcess = depositService
+ .processDeposits(account, currentTeamInfo, prevTeamInfo, nowDate, nowDateTime);
return CompletableFuture.allOf(registrationProcess, depositProcess)
.thenRun(() -> teamService.updateTeamInfo(account, currentTeamInfo));
diff --git a/zayac-admin-agent/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java
new file mode 100644
index 00000000..324243f2
--- /dev/null
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.service;
+
+import com.zayac.admin.constant.ApiPathConstants;
+import com.zayac.admin.req.AgentDataVisualListReq;
+import com.zayac.admin.resp.AgentDataVisualList;
+import com.zayac.admin.system.model.resp.AccountResp;
+import lombok.RequiredArgsConstructor;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.CompletableFuture;
+
+@Service
+@RequiredArgsConstructor
+public class AgentDataVisualListService {
+ private final CompletableFutureWebClientService completableFutureWebClientService;
+
+ public CompletableFuture getAgentDataVisualList(AccountResp account,
+ AgentDataVisualListReq agentDataVisualListReq) {
+ return completableFutureWebClientService
+ .fetchDataForAccount(account, ApiPathConstants.VISUAL_LIST_URL, agentDataVisualListReq, new ParameterizedTypeReference<>() {});
+ }
+}
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/BannerService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/BannerService.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/BannerService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/BannerService.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java
similarity index 58%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java
index d64465d9..1c9e08b5 100644
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java
@@ -1,12 +1,26 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.zayac.admin.service;
import cn.hutool.core.lang.TypeReference;
-import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zayac.admin.resp.ApiResponse;
import com.zayac.admin.system.model.resp.AccountResp;
-import com.zayac.admin.system.service.AccountService;
import io.netty.handler.timeout.TimeoutException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -49,7 +63,6 @@ public class CompletableFutureWebClientService {
return fetchData(account.getPlatformUrl() + apiPath, account.getHeaders(), params, typeRef, account).toFuture();
}
-
public Mono fetchData(String url,
String headers,
Object params,
@@ -60,40 +73,39 @@ public class CompletableFutureWebClientService {
throw new RuntimeException("Unable to acquire a permit");
}
return true;
- }).subscribeOn(Schedulers.boundedElastic()).then(
- this.webClient.post().uri(url).headers(httpHeaders -> {
- try {
- Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() {
- }, true);
- headerMap.forEach(httpHeaders::add);
- } catch (Exception e) {
- log.warn("Header conversion exception: " + e.getMessage());
- throw new BusinessException("Header conversion failed", e);
- }
- })
- .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty())
- .retrieve()
- .onStatus(HttpStatusCode::isError, response -> Mono.error(new BusinessException("API call failed")))
- .bodyToMono(String.class)
- .doOnNext(resStr -> {
- log.info("request url:{}", url);
- log.info("request headers :{}", headers);
- log.info("request params:{}", params);
- log.info("response {}", resStr);
- })
- .flatMap(body -> {
- try {
- ApiResponse apiResponse = objectMapper.readValue(body, objectMapper.getTypeFactory()
- .constructType(typeRef.getType()));
- return Mono.justOrEmpty(apiResponse);
- } catch (Exception e) {
- log.warn("JSON parsing exception: " + e.getMessage());
- return Mono.just(new ApiResponse(null, "Decoding error", 6008));
- }
- })
- .flatMap(response -> respHandler(response, account))
- .retryWhen(Retry.backoff(3, Duration.ofSeconds(3)).filter(this::isRetryableException))
- ).doFinally(signal -> semaphore.release());
+ }).subscribeOn(Schedulers.boundedElastic()).then(this.webClient.post().uri(url).headers(httpHeaders -> {
+ try {
+ Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() {
+ }, true);
+ headerMap.forEach(httpHeaders::add);
+ } catch (Exception e) {
+ log.warn("Header conversion exception: " + e.getMessage());
+ throw new BusinessException("Header conversion failed", e);
+ }
+ })
+ .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty())
+ .retrieve()
+ .onStatus(HttpStatusCode::isError, response -> Mono.error(new BusinessException("API call failed")))
+ .bodyToMono(String.class)
+ .doOnNext(resStr -> {
+ log.info("request url:{}", url);
+ log.info("request headers :{}", headers);
+ log.info("request params:{}", params);
+ log.info("response {}", resStr);
+ })
+ .flatMap(body -> {
+ try {
+ ApiResponse apiResponse = objectMapper.readValue(body, objectMapper.getTypeFactory()
+ .constructType(typeRef.getType()));
+ return Mono.justOrEmpty(apiResponse);
+ } catch (Exception e) {
+ log.warn("JSON parsing exception: " + e.getMessage());
+ return Mono.just(new ApiResponse(null, "Decoding error", 6008));
+ }
+ })
+ .flatMap(response -> respHandler(response, account))
+ .retryWhen(Retry.backoff(3, Duration.ofSeconds(3)).filter(this::isRetryableException)))
+ .doFinally(signal -> semaphore.release());
}
private boolean isRetryableException(Throwable throwable) {
diff --git a/zayac-admin-agent/src/main/java/com/zayac/admin/service/DepositService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/DepositService.java
new file mode 100644
index 00000000..7bec32e0
--- /dev/null
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/DepositService.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.zayac.admin.constant.ApiPathConstants;
+import com.zayac.admin.req.MemberDetailsReq;
+import com.zayac.admin.req.PayRecordsListReq;
+import com.zayac.admin.req.team.TeamMemberListReq;
+import com.zayac.admin.resp.Member;
+import com.zayac.admin.resp.MemberPagination;
+import com.zayac.admin.resp.Pagination;
+import com.zayac.admin.resp.PayRecord;
+import com.zayac.admin.resp.team.Team;
+import com.zayac.admin.resp.team.TeamAccount;
+import com.zayac.admin.resp.team.TeamAccountWithChange;
+import com.zayac.admin.system.model.entity.UserDO;
+import com.zayac.admin.system.model.resp.AccountResp;
+import com.zayac.admin.system.service.AccountService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.stereotype.Service;
+import top.continew.starter.core.exception.BusinessException;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class DepositService {
+ private final CompletableFutureWebClientService completableFutureWebClientService;
+ private final TelegramMessageService telegramMessageService;
+ private final AccountService accountService;
+
+ public CompletableFuture processDeposits(AccountResp account,
+ Team currentTeam,
+ Team previousTeam,
+ LocalDate nowDate,
+ LocalDateTime nowDateTime) {
+ return CompletableFuture.runAsync(() -> {
+ if (previousTeam != null && currentTeam.getFirstDepositNum() > previousTeam.getFirstDepositNum()) {
+ PayRecordsListReq req = PayRecordsListReq.builder()
+ .startDate(nowDate)
+ .endDate(nowDate)
+ .pageSize(100)
+ .payState(2)
+ .build();
+ CompletableFuture>> paginationCompletableFuture = completableFutureWebClientService
+ .fetchDataForAccount(account, ApiPathConstants.PAY_RECORDS_LIST_URL, req, new ParameterizedTypeReference<>() {
+ });
+ List changedTeamAccounts = findChangedTeamAccount(previousTeam, currentTeam);
+ Set changedAgentNames = changedTeamAccounts.stream()
+ .filter(teamAccountWithChange -> teamAccountWithChange.getNewDepositNum() > 0)
+ .map(TeamAccountWithChange::getAgentName)
+ .collect(Collectors.toSet());
+ paginationCompletableFuture.thenApply(Pagination::getList).thenAccept(payRecords -> {
+ Map> agentNameWithNames = payRecords.stream()
+ .filter(record -> record.getCreatedAt().isAfter(nowDateTime.minusHours(1)) && changedAgentNames
+ .contains(record.getAgentName()))
+ .collect(Collectors.groupingBy(PayRecord::getAgentName, Collectors
+ .mapping(PayRecord::getName, Collectors.collectingAndThen(Collectors
+ .toSet(), ArrayList::new))));
+
+ agentNameWithNames.forEach((agentName, names) -> {
+ StringBuilder depositResults = new StringBuilder();
+ AtomicInteger depositCounter = new AtomicInteger(0);
+
+ TeamAccountWithChange targetTeamAccount = changedTeamAccounts.stream()
+ .filter(teamAccount -> StrUtil.equals(teamAccount.getAgentName(), agentName))
+ .findFirst()
+ .orElseThrow(() -> new BusinessException(String
+ .format("can not find agent name %s", agentName)));
+
+ List> fetchFutures = names.stream()
+ .map(name -> fetchMemberDetails(account, name, nowDate).thenAccept(member -> {
+ payRecords.stream()
+ .filter(record -> record.getCreatedAt().equals(member.getFirstPayAt()))
+ .findFirst()
+ .ifPresent(record -> {
+ if (depositCounter.getAndIncrement() < targetTeamAccount.getNewDepositNum()) {
+ depositResults.append(telegramMessageService
+ .buildDepositResultsMessage(member.getName(), record.getScoreAmount()));
+ }
+ });
+ }).exceptionally(ex -> {
+ log.error("Error fetching details for member {}: {}", name, ex.getMessage());
+ return null;
+ }))
+ .toList();
+
+ CompletableFuture allFetches = CompletableFuture.allOf(fetchFutures
+ .toArray(new CompletableFuture[0]));
+
+ allFetches.thenRun(() -> {
+ if (!depositResults.isEmpty()) {
+ String notification = telegramMessageService
+ .buildDepositMessage(agentName, targetTeamAccount.getNewDepositNum(), depositResults
+ .toString(), targetTeamAccount.getFirstDepositNum());
+ UserDO currUser = accountService.getUserByAccountUsername(agentName);
+ telegramMessageService
+ .sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification);
+ }
+ }).exceptionally(ex -> {
+ log.error("Error sending notification for account {}: {}", account.getId(), ex
+ .getMessage());
+ return null;
+ });
+ });
+ }).exceptionally(ex -> {
+ log.error("Error processing deposits for account {}: {}", account.getId(), ex.getMessage());
+ return null;
+ }).join();
+ }
+ });
+ }
+
+ private CompletableFuture fetchMemberDetails(AccountResp account, String name, LocalDate nowDate) {
+ TeamMemberListReq memberListReq = TeamMemberListReq.builder()
+ .name(name)
+ .startDate(nowDate)
+ .endDate(nowDate)
+ .status(1)
+ .build();
+
+ CompletableFuture>> memberFuture = completableFutureWebClientService
+ .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
+ });
+
+ return memberFuture.thenApply(MemberPagination::getList)
+ .thenApply(list -> list.stream().findFirst())
+ .thenCompose(optionalMember -> optionalMember.map(member -> fetchDetailedMemberInfo(account, member
+ .getId(), nowDate)).orElseThrow(() -> new RuntimeException("没有找到匹配的成员信息")));
+ }
+
+ private CompletableFuture fetchDetailedMemberInfo(AccountResp account, Long memberId, LocalDate nowDate) {
+ MemberDetailsReq detailsReq = MemberDetailsReq.builder()
+ .id(memberId)
+ .startDate(nowDate)
+ .endDate(nowDate)
+ .build();
+
+ return completableFutureWebClientService
+ .fetchDataForAccount(account, ApiPathConstants.MEMBER_DETAIL_URL, detailsReq, new ParameterizedTypeReference<>() {
+ });
+ }
+
+ private List findChangedTeamAccount(Team prevTeam, Team currTeam) {
+ Map team2AccountMap = currTeam.getList()
+ .stream()
+ .collect(Collectors.toMap(TeamAccount::getId, account -> account));
+
+ return prevTeam.getList()
+ .stream()
+ .filter(account1 -> team2AccountMap.containsKey(account1.getId()))
+ .map(account1 -> {
+ TeamAccount account2 = team2AccountMap.get(account1.getId());
+ TeamAccountWithChange changedAccount = new TeamAccountWithChange();
+ BeanUtil.copyProperties(account2, changedAccount);
+ if (account1.getFirstDepositNum() != account2.getFirstDepositNum()) {
+ changedAccount.setNewDepositNum(account2.getFirstDepositNum() - account1.getFirstDepositNum());
+ }
+ if (account1.getSubMemberNum() != account2.getSubMemberNum()) {
+ changedAccount.setNewRegisterNum(account2.getSubMemberNum() - account1.getSubMemberNum());
+ }
+ return changedAccount;
+ })
+ .collect(Collectors.toList());
+ }
+}
\ No newline at end of file
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/RegistrationService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/RegistrationService.java
similarity index 68%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/RegistrationService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/RegistrationService.java
index 268fd05e..504bd5d7 100644
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/RegistrationService.java
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/RegistrationService.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.zayac.admin.service;
import com.zayac.admin.constant.ApiPathConstants;
@@ -37,28 +53,30 @@ public class RegistrationService {
if (prevTeamInfo != null && currentTeamInfo.getSubMemberCount() > prevTeamInfo.getSubMemberCount()) {
int registerCount = currentTeamInfo.getSubMemberCount() - prevTeamInfo.getSubMemberCount();
TeamMemberReq memberListReq = TeamMemberReq.builder()
- .registerStartDate(nowDate)
- .registerEndDate(nowDate)
- .startDate(nowDate)
- .endDate(nowDate)
- .registerSort(1)
- .pageSize(registerCount)
- .build();
+ .registerStartDate(nowDate)
+ .registerEndDate(nowDate)
+ .startDate(nowDate)
+ .endDate(nowDate)
+ .registerSort(1)
+ .pageSize(registerCount)
+ .build();
CompletableFuture>> memberPaginationCompletableFuture = completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
- });
+ .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
+ });
return memberPaginationCompletableFuture.thenApply(MemberPagination::getList).thenAccept(members -> {
log.info("Successfully get {} new registered members", members.size());
if (!members.isEmpty()) {
Map> groupByTopAgentName = members.stream()
- .collect(Collectors.groupingBy(TeamMember::getTopAgentName));
+ .collect(Collectors.groupingBy(TeamMember::getTopAgentName));
groupByTopAgentName.forEach((accountName, accountMembers) -> {
- String notification = telegramMessageService.buildRegistrationMessage(accountName, accountMembers, teamAccountMap.get(accountName));
+ String notification = telegramMessageService
+ .buildRegistrationMessage(accountName, accountMembers, teamAccountMap.get(accountName));
UserDO currUser = accountService.getUserByAccountUsername(accountName);
// if (currUser != null && DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) {
// telegramMessageService.sendMessage(currUser.getBotToken(), currUser.getGroupId(), notification);
// }
- telegramMessageService.sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification);
+ telegramMessageService
+ .sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification);
});
}
});
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/TeamService.java
similarity index 84%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/TeamService.java
index 8b5b2714..d2804e32 100644
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/TeamService.java
@@ -27,9 +27,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Service;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.temporal.TemporalAdjusters;
import java.util.concurrent.CompletableFuture;
@Service
@@ -37,19 +34,18 @@ import java.util.concurrent.CompletableFuture;
public class TeamService {
private final CompletableFutureWebClientService completableFutureWebClientService;
- public CompletableFuture getLatestTeamInfoAsync(AccountResp account,
- TeamInfoReq teamInfoReq) {
+ public CompletableFuture getLatestTeamInfoAsync(AccountResp account, TeamInfoReq teamInfoReq) {
//设置一个超大的分页参数 确保一次查询到所有的代理线
if (teamInfoReq.getPageSize() == 0) {
- teamInfoReq.setPageSize(200);
+ teamInfoReq.setPageSize(100);
}
if (teamInfoReq.getPageNum() == 0) {
teamInfoReq.setPageNum(1);
}
return completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.TEAM_LIST_URL, teamInfoReq, new ParameterizedTypeReference<>() {
- });
+ .fetchDataForAccount(account, ApiPathConstants.TEAM_LIST_URL, teamInfoReq, new ParameterizedTypeReference<>() {
+ });
}
@Cached(name = "TEAM_CACHE", key = "#account.id", expire = 90, cacheType = CacheType.BOTH, syncLocal = true)
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/TelegramMessageService.java
similarity index 80%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/TelegramMessageService.java
index 9e74c8b1..ab2c0766 100644
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java
+++ b/zayac-admin-agent/src/main/java/com/zayac/admin/service/TelegramMessageService.java
@@ -40,18 +40,19 @@ public class TelegramMessageService {
private static String escapeMarkdown(String text) {
List escapeChars = Arrays
- .asList('_', '[', ']', '(', ')', '~', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!');
+ .asList('_', '[', ']', '(', ')', '~', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!');
for (Character charItem : escapeChars) {
text = text.replace(charItem.toString(), "\\" + charItem);
}
return text;
}
- public String buildRegistrationMessage(String accountName, List accountMembers, TeamAccount teamAccount) {
- String memberNames = accountMembers.stream()
- .map(TeamMember::getName)
- .collect(Collectors.joining(", "));
- return String.format("👏 %s 注册: %d 用户: `%s` 总数:*%d*", accountName, accountMembers.size(), memberNames, teamAccount.getSubMemberNum());
+ public String buildRegistrationMessage(String accountName,
+ List accountMembers,
+ TeamAccount teamAccount) {
+ String memberNames = accountMembers.stream().map(TeamMember::getName).collect(Collectors.joining(", "));
+ return String.format("👏 %s 注册: %d 用户: `%s` 总数:*%d*", accountName, accountMembers
+ .size(), memberNames, teamAccount.getSubMemberNum());
}
public String buildDepositMessage(String agentName, int newDepositNum, String depositResults, int firstDepositNum) {
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/WebClientService.java b/zayac-admin-agent/src/main/java/com/zayac/admin/service/WebClientService.java
similarity index 100%
rename from zayac-admin-backend/src/main/java/com/zayac/admin/service/WebClientService.java
rename to zayac-admin-agent/src/main/java/com/zayac/admin/service/WebClientService.java
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/DailyReport.java b/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/DailyReport.java
deleted file mode 100644
index 32f3e114..00000000
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/DailyReport.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package com.zayac.admin.schedule;
-
-import com.zayac.admin.common.enums.DisEnableStatusEnum;
-import com.zayac.admin.req.AgentDataVisualListReq;
-import com.zayac.admin.req.team.TeamInfoReq;
-import com.zayac.admin.resp.AgentDataVisualList;
-import com.zayac.admin.resp.Banner;
-import com.zayac.admin.resp.Statics;
-import com.zayac.admin.resp.team.Team;
-import com.zayac.admin.resp.team.TeamAccount;
-import com.zayac.admin.service.AgentDataVisualListService;
-import com.zayac.admin.service.BannerService;
-import com.zayac.admin.service.TeamService;
-import com.zayac.admin.service.TelegramMessageService;
-import com.zayac.admin.system.model.entity.RoleDO;
-import com.zayac.admin.system.model.entity.UserDO;
-import com.zayac.admin.system.model.resp.AccountResp;
-import com.zayac.admin.system.service.*;
-import lombok.RequiredArgsConstructor;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.text.NumberFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.temporal.TemporalAdjusters;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.IntStream;
-
-/**
- * 日报
- */
-@Component
-@RequiredArgsConstructor
-public class DailyReport {
- private final UserService userService;
- private final TeamService teamService;
-
- private final RoleService roleService;
- private final UserRoleService userRoleService;
- private final AccountService accountService;
- private final TelegramMessageService telegramMessageService;
- private final RoleDeptService roleDeptService;
- private final DeptService deptService;
- private final BannerService bannerService;
- private final AgentDataVisualListService agentDataVisualListService;
-
-
- private static final String MINISTER_ROLE_CODE = "minister";
-
- //每天11:40 14:40 17:40 21:40 23:59开启发送日报
- @Scheduled(cron = "0 40 11,14,17,21 * * ?")
- @Scheduled(cron = "0 59 23 * * ?")
- public void TeamAccountDailyReport() {
- LocalDate nowDate = LocalDate.now();
- LocalDateTime nowDateTime = LocalDateTime.now();
- //获取部长角色
- RoleDO minister = roleService.getByCode(MINISTER_ROLE_CODE);
- List userIds = userRoleService.listUserIdByRoleId(minister.getId());
- //获取所有部长角色对应部门的用户
- userIds.forEach(userId -> {
- //传入对应部长用户
- UserDO ministerUser = userService.getById(userId);
- //获取当前用户名下的所有团队账号
- List accounts = accountService.getAccountsByUserId(ministerUser.getId(), DisEnableStatusEnum.ENABLE)
- .stream()
- .filter(AccountResp::getIsTeam)
- .toList();
- Long deptId = ministerUser.getDeptId();
- List deptUsers = userService.getByDeptId(DisEnableStatusEnum.ENABLE, deptId);
- accounts.forEach(
- accountResp -> {
- TeamInfoReq teamInfoReq = TeamInfoReq.builder()
- .startDate(nowDate.atStartOfDay())
- .endDate(nowDateTime)
- .build();
- Team team = teamService.getLatestTeamInfoAsync(accountResp, teamInfoReq).join();
- List list = team.getList();
- //发送消息给部长
- if (ministerUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
- //获取当天总线的所有注册新增
- int currentDayTotalNewMember = list.stream().mapToInt(TeamAccount::getSubMemberNum).sum();
- int currentDayTotalNewFirstDeposit = list.stream().mapToInt(TeamAccount::getFirstDepositNum).sum();
- //当日转化率
- String percent = getPercent(currentDayTotalNewFirstDeposit, currentDayTotalNewMember);
- String message = String.format("截至%s 注册:*%d*,新增:*%d* 转化率: *%s*", nowDateTime, currentDayTotalNewMember, currentDayTotalNewFirstDeposit, percent);
- telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser.getChatId(), message);
- }
- }
- );
- AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder().build();
- deptUsers.forEach(deptUser -> {
- StringBuilder message = new StringBuilder();
- List currUserAccounts = accountService.getAccountsByUserId(deptUser.getId(), DisEnableStatusEnum.ENABLE);
-
- currUserAccounts.forEach(currAccount -> {
- CompletableFuture agentDataVisualListCompletableFuture = agentDataVisualListService.getAgentDataVisualList(currAccount, agentDataVisualListReq);
- AgentDataVisualList agentDataVisualList = agentDataVisualListCompletableFuture.join();
- Statics statics = agentDataVisualList.getCurData().stream().filter(data -> data.getStaticsDate().equals(nowDate)).findFirst().orElseThrow();
- message.append(currAccount.getUsername()).append("\n");
- message.append("注册: ").append(statics.getIsNew()).append("\n");
- message.append("新增: ").append(statics.getFirstCount()).append("\n");
- message.append("日活: ").append(statics.getCountBets()).append("\n\n");
- });
-// if (DisEnableStatusEnum.ENABLE.equals(deptUser.getNeedNotify())) {
-// if (DisEnableStatusEnum.ENABLE.equals(deptUser.getNeedNotify())) {
-// telegramMessageService.sendMessage(user.getBotToken(), user.getGroupId(), message.toString());
-// }
- telegramMessageService
- .sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, message.toString());
- });
- });
- }
-
- public static String getPercent(int x, int y) {
- double d1 = x * 1.0;
- double d2 = y * 1.0;
- NumberFormat percentInstance = NumberFormat.getPercentInstance();
- percentInstance.setMinimumFractionDigits(2);
- return percentInstance.format(d1 / d2);
- }
-}
-
-
-
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java
deleted file mode 100644
index fdc986dc..00000000
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/AgentDataVisualListService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.zayac.admin.service;
-
-import com.zayac.admin.constant.ApiPathConstants;
-import com.zayac.admin.req.AgentDataVisualListReq;
-import com.zayac.admin.resp.AgentDataVisualList;
-import com.zayac.admin.resp.Banner;
-import com.zayac.admin.system.model.resp.AccountResp;
-import lombok.RequiredArgsConstructor;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.stereotype.Service;
-
-import java.util.concurrent.CompletableFuture;
-
-@Service
-@RequiredArgsConstructor
-public class AgentDataVisualListService {
- private final CompletableFutureWebClientService completableFutureWebClientService;
-
- public CompletableFuture getAgentDataVisualList(AccountResp account, AgentDataVisualListReq agentDataVisualListReq) {
- return completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.VISUAL_LIST_URL, agentDataVisualListReq, new ParameterizedTypeReference<>() {});
- }
-}
diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/DepositService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/DepositService.java
deleted file mode 100644
index 8f477ff3..00000000
--- a/zayac-admin-backend/src/main/java/com/zayac/admin/service/DepositService.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package com.zayac.admin.service;
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.StrUtil;
-import com.zayac.admin.constant.ApiPathConstants;
-import com.zayac.admin.req.MemberDetailsReq;
-import com.zayac.admin.req.PayRecordsListReq;
-import com.zayac.admin.req.team.TeamMemberListReq;
-import com.zayac.admin.resp.Member;
-import com.zayac.admin.resp.MemberPagination;
-import com.zayac.admin.resp.Pagination;
-import com.zayac.admin.resp.PayRecord;
-import com.zayac.admin.resp.team.Team;
-import com.zayac.admin.resp.team.TeamAccount;
-import com.zayac.admin.resp.team.TeamAccountWithChange;
-import com.zayac.admin.system.model.entity.UserDO;
-import com.zayac.admin.system.model.resp.AccountResp;
-import com.zayac.admin.system.service.AccountService;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.stereotype.Service;
-import top.continew.starter.core.exception.BusinessException;
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.ArrayList;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class DepositService {
- private final CompletableFutureWebClientService completableFutureWebClientService;
- private final TelegramMessageService telegramMessageService;
- private final AccountService accountService;
-
- public CompletableFuture processDeposits(AccountResp account,
- Team currentTeam,
- Team previousTeam,
- LocalDate nowDate,
- LocalDateTime nowDateTime) {
- return CompletableFuture.runAsync(() -> {
- if (previousTeam != null && currentTeam.getFirstDepositNum() > previousTeam.getFirstDepositNum()) {
- PayRecordsListReq req = PayRecordsListReq.builder()
- .startDate(nowDate)
- .endDate(nowDate)
- .pageSize(100)
- .payState(2)
- .build();
- CompletableFuture>> paginationCompletableFuture = completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.PAY_RECORDS_LIST_URL, req, new ParameterizedTypeReference<>() {
- });
- List changedTeamAccounts = findChangedTeamAccount(previousTeam, currentTeam);
- Set changedAgentNames = changedTeamAccounts.stream()
- .filter(teamAccountWithChange -> teamAccountWithChange.getNewDepositNum() > 0)
- .map(TeamAccountWithChange::getAgentName)
- .collect(Collectors.toSet());
- paginationCompletableFuture.thenApply(Pagination::getList).thenAccept(payRecords -> {
- Map> agentNameWithNames = payRecords.stream()
- .filter(record -> record.getCreatedAt().isAfter(nowDateTime.minusHours(1)) && changedAgentNames.contains(record.getAgentName()))
- .collect(Collectors.groupingBy(PayRecord::getAgentName, Collectors
- .mapping(PayRecord::getName, Collectors.collectingAndThen(Collectors.toSet(), ArrayList::new))));
-
- agentNameWithNames.forEach((agentName, names) -> {
- StringBuilder depositResults = new StringBuilder();
- AtomicInteger depositCounter = new AtomicInteger(0);
-
- TeamAccountWithChange targetTeamAccount = changedTeamAccounts.stream()
- .filter(teamAccount -> StrUtil.equals(teamAccount.getAgentName(), agentName))
- .findFirst()
- .orElseThrow(() -> new BusinessException(String.format("can not find agent name %s", agentName)));
-
- List> fetchFutures = names.stream()
- .map(name -> fetchMemberDetails(account, name, nowDate).thenAccept(member -> {
- payRecords.stream()
- .filter(record -> record.getCreatedAt().equals(member.getFirstPayAt()))
- .findFirst()
- .ifPresent(record -> {
- if (depositCounter.getAndIncrement() < targetTeamAccount.getNewDepositNum()) {
- depositResults.append(telegramMessageService.buildDepositResultsMessage(member.getName(), record.getScoreAmount()));
- }
- });
- }).exceptionally(ex -> {
- log.error("Error fetching details for member {}: {}", name, ex.getMessage());
- return null;
- }))
- .toList();
-
- CompletableFuture allFetches = CompletableFuture.allOf(fetchFutures.toArray(new CompletableFuture[0]));
-
- allFetches.thenRun(() -> {
- if (!depositResults.isEmpty()) {
- String notification = telegramMessageService.buildDepositMessage(agentName, targetTeamAccount.getNewDepositNum(), depositResults.toString(), targetTeamAccount.getFirstDepositNum());
- UserDO currUser = accountService.getUserByAccountUsername(agentName);
- telegramMessageService.sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification);
- }
- }).exceptionally(ex -> {
- log.error("Error sending notification for account {}: {}", account.getId(), ex.getMessage());
- return null;
- });
- });
- }).exceptionally(ex -> {
- log.error("Error processing deposits for account {}: {}", account.getId(), ex.getMessage());
- return null;
- }).join();
- }
- });
- }
-
- private CompletableFuture fetchMemberDetails(AccountResp account, String name, LocalDate nowDate) {
- TeamMemberListReq memberListReq = TeamMemberListReq.builder()
- .name(name)
- .startDate(nowDate)
- .endDate(nowDate)
- .status(1)
- .build();
-
- CompletableFuture>> memberFuture = completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
- });
-
- return memberFuture.thenApply(MemberPagination::getList)
- .thenApply(list -> list.stream().findFirst())
- .thenCompose(optionalMember -> optionalMember.map(member -> fetchDetailedMemberInfo(account, member
- .getId(), nowDate)).orElseThrow(() -> new RuntimeException("没有找到匹配的成员信息")));
- }
-
- private CompletableFuture fetchDetailedMemberInfo(AccountResp account, Long memberId, LocalDate nowDate) {
- MemberDetailsReq detailsReq = MemberDetailsReq.builder()
- .id(memberId)
- .startDate(nowDate)
- .endDate(nowDate)
- .build();
-
- return completableFutureWebClientService
- .fetchDataForAccount(account, ApiPathConstants.MEMBER_DETAIL_URL, detailsReq, new ParameterizedTypeReference<>() {
- });
- }
-
- private List findChangedTeamAccount(Team prevTeam, Team currTeam) {
- Map team2AccountMap = currTeam.getList()
- .stream()
- .collect(Collectors.toMap(TeamAccount::getId, account -> account));
-
- return prevTeam.getList()
- .stream()
- .filter(account1 -> team2AccountMap.containsKey(account1.getId()))
- .map(account1 -> {
- TeamAccount account2 = team2AccountMap.get(account1.getId());
- TeamAccountWithChange changedAccount = new TeamAccountWithChange();
- BeanUtil.copyProperties(account2, changedAccount);
- if (account1.getFirstDepositNum() != account2.getFirstDepositNum()) {
- changedAccount.setNewDepositNum(account2.getFirstDepositNum() - account1.getFirstDepositNum());
- }
- if (account1.getSubMemberNum() != account2.getSubMemberNum()) {
- changedAccount.setNewRegisterNum(account2.getSubMemberNum() - account1.getSubMemberNum());
- }
- return changedAccount;
- })
- .collect(Collectors.toList());
- }
-}
\ No newline at end of file
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/config/file/FileStorageConfigLoader.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/config/file/FileStorageConfigLoader.java
index 5a8ccf22..78ff42ab 100644
--- a/zayac-admin-system/src/main/java/com/zayac/admin/system/config/file/FileStorageConfigLoader.java
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/config/file/FileStorageConfigLoader.java
@@ -16,20 +16,12 @@
package com.zayac.admin.system.config.file;
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.CollUtil;
-import com.zayac.admin.system.model.query.StorageQuery;
-import com.zayac.admin.system.model.req.StorageReq;
-import com.zayac.admin.system.model.resp.StorageResp;
import com.zayac.admin.system.service.StorageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
-import com.zayac.admin.common.enums.DisEnableStatusEnum;
-
-import java.util.List;
/**
* 文件存储配置加载器
@@ -46,12 +38,13 @@ public class FileStorageConfigLoader implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
- StorageQuery query = new StorageQuery();
- query.setStatus(DisEnableStatusEnum.ENABLE.getValue());
- List storageList = storageService.list(query, null);
- if (CollUtil.isEmpty(storageList)) {
- return;
- }
- storageList.forEach(s -> storageService.load(BeanUtil.copyProperties(s, StorageReq.class)));
+ // StorageQuery query = new StorageQuery();
+ // query.setStatus(DisEnableStatusEnum.ENABLE.getValue());
+ // List storageList = storageService.list(query, null);
+ // if (CollUtil.isEmpty(storageList)) {
+ // return;
+ // }
+ // storageList.forEach(s -> storageService.load(BeanUtil.copyProperties(s, StorageReq.class)));
+ log.info("执行存储");
}
}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AgentStatsMapper.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AgentStatsMapper.java
new file mode 100644
index 00000000..c1e71a3b
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AgentStatsMapper.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.mapper;
+
+import com.zayac.admin.system.model.entity.AgentStatsDO;
+import top.continew.starter.data.mybatis.plus.base.BaseMapper;
+
+public interface AgentStatsMapper extends BaseMapper {
+}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentFinanceDO.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentFinanceDO.java
new file mode 100644
index 00000000..83a109fd
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentFinanceDO.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.entity;
+
+import top.continew.starter.extension.crud.model.entity.BaseDO;
+
+import java.io.Serial;
+
+public class AgentFinanceDO extends BaseDO {
+ @Serial
+ private static final long serialVersionUID = 1L;
+}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentStatsDO.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentStatsDO.java
new file mode 100644
index 00000000..31b88e99
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AgentStatsDO.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+import top.continew.starter.extension.crud.model.entity.BaseDO;
+
+import java.io.Serial;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+/**
+ * 代理线每日数据
+ */
+@Data
+@TableName("agent_daily_stats")
+public class AgentStatsDO extends BaseDO {
+ @Serial
+ private static final long serialVersionUID = 1L;
+ /**
+ * 日期
+ */
+ LocalDate staticsDate;
+ /**
+ * 代理id
+ */
+ Long agentId;
+ /**
+ * 代理类型
+ */
+ Integer agentType;
+ /**
+ * 代理推荐码
+ */
+ String agentCode;
+ /**
+ * 代理名称
+ */
+ String agentName;
+ /**
+ * 新增人数
+ */
+ Integer isNew;
+ /**
+ * 首存人数
+ */
+ Double firstDeposit;
+ /**
+ * 投注额
+ */
+ Double deposit;
+ /**
+ * 投注红利
+ */
+ Double depositPromo;
+ /**
+ * 取款
+ */
+ Double draw;
+ /**
+ * 返水
+ */
+ Double promo;
+ /**
+ * 返水比例
+ */
+ Double promoDividend;
+ Double rebate;
+ /**
+ * 账号调整
+ */
+ Double adjust;
+ /**
+ * 风险等级
+ */
+ Double riskAdjust;
+ /**
+ * 有效投注额
+ */
+ Double bets;
+ /**
+ * 输赢
+ */
+ Double profit;
+ /**
+ * 总投注额
+ */
+ Double allBets;
+ /**
+ * 首存人数
+ */
+ Integer firstCount;
+ /**
+ * 存款人数
+ */
+ Integer countDeposit;
+ /**
+ * 取款人数
+ */
+ Integer countDraw;
+ /**
+ * 投注人数
+ */
+ Integer countBets;
+ /**
+ * 创建日期
+ */
+ LocalDateTime createdAt;
+ /**
+ * 更新日期
+ */
+ LocalDateTime updatedAt;
+ /**
+ * 老用户存款人数
+ */
+ Double oldDeposit;
+ /**
+ * 老用户存款金额
+ */
+ Integer oldDepositCount;
+ /**
+ * 新用户存款金额
+ */
+ Double newDeposit;
+}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AgentStatsQuery.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AgentStatsQuery.java
new file mode 100644
index 00000000..30958d0b
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AgentStatsQuery.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.query;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@Schema(description = "代理线每日报表查询条件")
+public class AgentStatsQuery implements Serializable {
+}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AgentStatsReq.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AgentStatsReq.java
new file mode 100644
index 00000000..201fcc51
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AgentStatsReq.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.req;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import top.continew.starter.extension.crud.model.req.BaseReq;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class AgentStatsReq extends BaseReq {
+ /**
+ * 日期
+ */
+ LocalDate staticsDate;
+ /**
+ * 代理id
+ */
+ Long agentId;
+ /**
+ * 代理类型
+ */
+ Integer agentType;
+ /**
+ * 代理推荐码
+ */
+ String agentCode;
+ /**
+ * 代理名称
+ */
+ String agentName;
+ /**
+ * 新增人数
+ */
+ Integer isNew;
+ /**
+ * 首存人数
+ */
+ Double firstDeposit;
+ /**
+ * 投注额
+ */
+ Double deposit;
+ /**
+ * 投注红利
+ */
+ Double depositPromo;
+ /**
+ * 取款
+ */
+ Double draw;
+ /**
+ * 返水
+ */
+ Double promo;
+ /**
+ * 返水比例
+ */
+ Double promoDividend;
+ Double rebate;
+ /**
+ * 账号调整
+ */
+ Double adjust;
+ /**
+ * 风险等级
+ */
+ Double riskAdjust;
+ /**
+ * 有效投注额
+ */
+ Double bets;
+ /**
+ * 输赢
+ */
+ Double profit;
+ /**
+ * 总投注额
+ */
+ Double allBets;
+ /**
+ * 首存人数
+ */
+ Integer firstCount;
+ /**
+ * 存款人数
+ */
+ Integer countDeposit;
+ /**
+ * 取款人数
+ */
+ Integer countDraw;
+ /**
+ * 投注人数
+ */
+ Integer countBets;
+ /**
+ * 创建日期
+ */
+ LocalDateTime createdAt;
+ /**
+ * 更新日期
+ */
+ LocalDateTime updatedAt;
+ /**
+ * 老用户存款人数
+ */
+ Double oldDeposit;
+ /**
+ * 老用户存款金额
+ */
+ Integer oldDepositCount;
+ /**
+ * 新用户存款金额
+ */
+ Double newDeposit;
+}
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java
index b2af6f90..bf9d2a85 100644
--- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java
@@ -29,8 +29,6 @@ import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.continew.starter.extension.crud.model.resp.BaseResp;
-import top.continew.starter.security.mask.annotation.JsonMask;
-import top.continew.starter.security.mask.enums.MaskType;
/**
* 账号信息
@@ -61,7 +59,7 @@ public class AccountResp extends BaseResp {
* 密码
*/
@Schema(description = "密码", example = "tg666888")
-// @JsonMask(MaskType.PASSWORD)
+ // @JsonMask(MaskType.PASSWORD)
private String password;
/**
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsDetailResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsDetailResp.java
new file mode 100644
index 00000000..c37a7441
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsDetailResp.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.resp;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
+
+import java.io.Serial;
+
+/**
+ * 账号详情信息
+ *
+ * @author zayac
+ * @since 2024/05/10 20:44
+ */
+@Data
+@ExcelIgnoreUnannotated
+@Schema(description = "代理线每日报表详情信息")
+public class AgentStatsDetailResp extends BaseDetailResp {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+ // TODO 完善字段信息
+}
\ No newline at end of file
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsResp.java
new file mode 100644
index 00000000..79f0e100
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AgentStatsResp.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.model.resp;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import top.continew.starter.extension.crud.model.resp.BaseResp;
+
+import java.io.Serial;
+
+/**
+ * 账号信息
+ *
+ * @author zayac
+ * @since 2024/05/10 20:44
+ */
+@Data
+@Schema(description = "代理线每日报表信息")
+public class AgentStatsResp extends BaseResp {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ // TODO 完善字段信息
+}
\ No newline at end of file
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java
index fdb86f44..8b65df57 100644
--- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java
@@ -17,7 +17,6 @@
package com.zayac.admin.system.service;
import com.zayac.admin.common.enums.DisEnableStatusEnum;
-import com.zayac.admin.system.model.entity.AccountDO;
import com.zayac.admin.system.model.entity.UserDO;
import com.zayac.admin.system.model.query.AccountQuery;
import com.zayac.admin.system.model.req.AccountReq;
@@ -38,5 +37,5 @@ public interface AccountService extends BaseService {
+}
\ No newline at end of file
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java
index 5acdeabd..b20d09fa 100644
--- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java
@@ -33,7 +33,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
-import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
import java.util.List;
diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AgentStatsServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AgentStatsServiceImpl.java
new file mode 100644
index 00000000..1b40a33b
--- /dev/null
+++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AgentStatsServiceImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zayac.admin.system.service.impl;
+
+import com.zayac.admin.system.mapper.AgentStatsMapper;
+import com.zayac.admin.system.model.entity.AgentStatsDO;
+import com.zayac.admin.system.model.query.AgentStatsQuery;
+import com.zayac.admin.system.model.req.AgentStatsReq;
+import com.zayac.admin.system.model.resp.*;
+import com.zayac.admin.system.service.AgentStatsService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
+@Service
+@RequiredArgsConstructor
+public class AgentStatsServiceImpl extends BaseServiceImpl implements AgentStatsService {
+
+}
diff --git a/zayac-admin-webapi/pom.xml b/zayac-admin-webapi/pom.xml
index 6fbdb17d..9bd83492 100644
--- a/zayac-admin-webapi/pom.xml
+++ b/zayac-admin-webapi/pom.xml
@@ -52,7 +52,7 @@
com.zayac
- zayac-admin-backend
+ zayac-admin-agent
diff --git a/zayac-admin-webapi/src/main/resources/config/application-prod.yml b/zayac-admin-webapi/src/main/resources/config/application-prod.yml
index 0aa12abc..c301a56e 100644
--- a/zayac-admin-webapi/src/main/resources/config/application-prod.yml
+++ b/zayac-admin-webapi/src/main/resources/config/application-prod.yml
@@ -1,14 +1,14 @@
--- ### 项目配置
project:
# URL(跨域配置默认放行此 URL,请注意更改为你实际的前端 URL)
- url: https://admin.continew.top
+ url: http://localhost:5173
# 是否为生产环境
production: true
--- ### 服务器配置
server:
# HTTP 端口(默认 8080)
- port: 18000
+ port: 8000
--- ### 数据源配置
spring.datasource:
@@ -24,16 +24,16 @@ spring.datasource:
datasource:
# 主库配置(可配多个,构成多主)
master:
- url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:continew_admin}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false
- username: ${DB_USER:root}
- password: ${DB_PWD:123456}
+ url: jdbc:mysql://${DB_HOST:45.89.233.228}:${DB_PORT:3306}/${DB_NAME:zayac_admin}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false
+ username: ${DB_USER:zayac_admin}
+ password: ${DB_PWD:2hMtBRzZrDAkRynX}
driver-class-name: com.mysql.cj.jdbc.Driver
type: ${spring.datasource.type}
# 从库配置(可配多个,构成多从)
slave_1:
- url: jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:continew_admin}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false
- username:
- password:
+ url: jdbc:mysql://${DB_HOST:38.6.218.29}:${DB_PORT:3306}/${DB_NAME:zayac_admin}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true&autoReconnect=true&maxReconnects=10&failOverReadOnly=false
+ username: zayac_admin
+ password: PxkF52eGTz48izZG
lazy: true
driver-class-name: com.mysql.cj.jdbc.Driver
type: ${spring.datasource.type}
@@ -69,11 +69,11 @@ spring.data:
## Redis 配置(单机模式)
redis:
# 地址
- host: ${REDIS_HOST:127.0.0.1}
+ host: ${REDIS_HOST:38.6.218.29}
# 端口(默认 6379)
port: ${REDIS_PORT:6379}
# 密码(未设置密码时可为空或注释掉)
- password: ${REDIS_PWD:123456}
+ password: ${REDIS_PWD:jhkdjhkjdhsIUTYURTU_mWHmDY}
# 数据库索引
database: ${REDIS_DB:0}
# 连接超时时间
@@ -271,3 +271,14 @@ spring.servlet:
## 头像支持格式配置
avatar:
support-suffix: jpg,jpeg,png,gif
+
+webclient:
+ max-concurrent-requests: 60
+
+spring:
+ rabbitmq:
+ host: 45.89.233.228
+ port: 5672
+ username: bot
+ password: xiaomi@123
+
diff --git a/zayac-admin-webapi/src/main/resources/config/application.yml b/zayac-admin-webapi/src/main/resources/config/application.yml
index a7ae7fa3..ffc3f3f2 100644
--- a/zayac-admin-webapi/src/main/resources/config/application.yml
+++ b/zayac-admin-webapi/src/main/resources/config/application.yml
@@ -233,7 +233,7 @@ webclient:
spring:
rabbitmq:
- host: mq.stupidpz.com
+ host: 45.89.233.228
port: 5672
username: bot
password: xiaomi@123